Skip to content

Commit

Permalink
CRM-19338 - Add language and version params to doc urls
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Oct 12, 2016
1 parent 3023495 commit c15f87c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion CRM/Utils/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ public static function refererPath() {
*/
public static function getDocBaseURL() {
// FIXME: move this to configuration at some stage
return 'http://book.civicrm.org/';
return 'https://docs.civicrm.org/';
}

/**
Expand Down Expand Up @@ -1303,6 +1303,7 @@ public static function docURL2($page, $URLonly = FALSE, $text = NULL, $title = N
}
else {
$docBaseURL = self::getDocBaseURL();
$page = self::formatDocUrl($page);
}
return $docBaseURL . str_replace(' ', '+', $page);
}
Expand Down Expand Up @@ -1341,6 +1342,7 @@ public static function docURL($params) {
}
else {
$docBaseURL = self::getDocBaseURL();
$params['page'] = self::formatDocUrl($params['page']);
}

if (!isset($params['title']) or $params['title'] === NULL) {
Expand Down Expand Up @@ -1368,6 +1370,18 @@ public static function docURL($params) {
}
}

/**
* 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/((\w\w/)?stable/)?#', 'user/en/stable/', $url);
}

/**
* Exit with provided exit code.
*
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Admin/Page/ConfigTaskList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<td>{ts}Online event registration and participant tracking.{/ts}</td>
</tr>
<tr class="even">
<td class="tasklist nowrap">{docURL page="user/membership/introduction-to-memberships" text="CiviMember"}</td>
<td class="tasklist nowrap">{docURL page="user/membership/what-is-civimember" text="CiviMember"}</td>
<td>{ts}Online signup and membership management.{/ts}</td>
</tr>
<tr class="even">
Expand Down

0 comments on commit c15f87c

Please sign in to comment.