Merged branch 'MDL-27695' of git://github.com/nebgor/moodle.git with changes

This commit is contained in:
Sam Hemelryk 2011-06-08 16:25:57 +08:00
commit f6bd0b9e39

View File

@ -2816,10 +2816,29 @@ function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
*/
function get_docs_url($path) {
global $CFG;
if (!empty($CFG->docroot)) {
return $CFG->docroot . '/' . current_language() . '/' . $path;
// 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 {
return 'http://docs.moodle.org/en/'.$path;
// 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 . '/' . $branch . '/' . current_language() . '/' . $path;
} else {
return 'http://docs.moodle.org/'. $branch . '/en/' . $path;
}
}