CRM-20300 - Fix in-app documentation links
authorSean Madsen <sean@seanmadsen.com>
Sat, 18 Mar 2017 03:46:35 +0000 (21:46 -0600)
committerSean Madsen <sean@seanmadsen.com>
Sat, 18 Mar 2017 03:46:35 +0000 (21:46 -0600)
CRM/Utils/System.php

index e78b144882fb2bdc785101965a297c19c0294bed..0498c5f7ee9bdfdce057f25d2a963a8a5fae7ac3 100644 (file)
@@ -1237,7 +1237,7 @@ class CRM_Utils_System {
    */
   public static function getDocBaseURL() {
     // FIXME: move this to configuration at some stage
-    return 'http://book.civicrm.org/';
+    return 'http://docs.civicrm.org/';
   }
 
   /**
@@ -1283,6 +1283,7 @@ class CRM_Utils_System {
       }
       else {
         $docBaseURL = self::getDocBaseURL();
+        $page = self::formatDocUrl($page);
       }
       return $docBaseURL . str_replace(' ', '+', $page);
     }
@@ -1321,6 +1322,7 @@ class CRM_Utils_System {
     }
     else {
       $docBaseURL = self::getDocBaseURL();
+      $params['page'] = self::formatDocUrl($params['page']);
     }
 
     if (!isset($params['title']) or $params['title'] === NULL) {
@@ -1348,6 +1350,18 @@ class CRM_Utils_System {
     }
   }
 
+  /**
+   * Add language and version parameters to the doc url.
+   *
+   * Note that this function may run before CiviCRM is initialized and so should not call ts() or perform any db lookups.
+   *
+   * @param $url
+   * @return mixed
+   */
+  public static function formatDocUrl($url) {
+    return preg_replace('#^user/#', 'user/en/4.6/', $url);
+  }
+
   /**
    * Get the locale set in the hosting CMS.
    *