Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged branch 'MDL-27695_MOODLE_20_STABLE' of git://github.com/nebgor…

…/moodle.git with changes
  • Loading branch information...
commit bca840b4bc8362b3c3063b07cf0c42cdba35a2fa 2 parents 80406e9 + c372808
@samhemelryk samhemelryk authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 lib/weblib.php
View
23 lib/weblib.php
@@ -2816,10 +2816,29 @@ function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
*/
function get_docs_url($path) {
global $CFG;
+ // Check that $CFG->release has been set up, during installation it won't be.
+ if (empty($CFG->release)) {
+ // It's not there yet so look at version.php
+ include($CFG->dirroot.'/version.php');
+ } else {
+ // We can use $CFG->release and avoid having to include version.php
+ $release = $CFG->release;
+ }
+ // Attempt to match the branch from the release
+ if (preg_match('/^(.)\.(.)/', $release, $matches)) {
+ // We should ALWAYS get here
+ $branch = $matches[1].$matches[2];
+ } else {
+ // We should never get here but in case we do lets set $branch to .
+ // the smart one's will know that this is the current directory
+ // and the smarter ones will know that there is some smart matching
+ // that will ensure people end up at the latest version of the docs.
+ $branch = '.';
+ }
if (!empty($CFG->docroot)) {
- return $CFG->docroot . '/' . current_language() . '/' . $path;
+ return $CFG->docroot . '/' . $branch . '/' . current_language() . '/' . $path;
} else {
- return 'http://docs.moodle.org/en/'.$path;
+ return 'http://docs.moodle.org/'. $branch . '/en/' . $path;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.