Skip to content

Commit

Permalink
MDL-28044 general - updated print_error() to point to versioned docs.…
Browse files Browse the repository at this point in the history
…moodle.org
  • Loading branch information
Aparup Banerjee committed Jun 30, 2011
1 parent 1b75cdd commit 5cea248
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions lib/weblib.php
Expand Up @@ -5842,11 +5842,13 @@ function print_error($errorcode, $module='error', $link='', $a=NULL, $extralocat
} }


if (!empty($CFG->errordocroot)) { if (!empty($CFG->errordocroot)) {
$errordocroot = $CFG->errordocroot; $errordoclink = $CFG->errordocroot.'/en';
} else if (!empty($CFG->docroot)) {
$errordocroot = $CFG->docroot;
} else { } else {
$errordocroot = 'http://docs.moodle.org'; $errordoclink = get_doc_root();
if (is_null($errordoclink)) {
$lang = current_language();
$errordoclink = 'http://docs.moodle.org/19/'.$lang; //no doc links set. point to default.
}
} }


if (defined('FULLME') && FULLME == 'cron') { if (defined('FULLME') && FULLME == 'cron') {
Expand All @@ -5863,7 +5865,7 @@ function print_error($errorcode, $module='error', $link='', $a=NULL, $extralocat


$message = clean_text('<p class="errormessage">'.$message.'</p>'. $message = clean_text('<p class="errormessage">'.$message.'</p>'.
'<p class="errorcode">'. '<p class="errorcode">'.
'<a href="'.$errordocroot.'/en/error/'.$modulelink.'/'.$errorcode.'">'. '<a href="'.$errordoclink.'/error/'.$modulelink.'/'.$errorcode.'">'.
get_string('moreinformation').'</a></p>'); get_string('moreinformation').'</a></p>');


if (! defined('HEADER_PRINTED')) { if (! defined('HEADER_PRINTED')) {
Expand Down Expand Up @@ -6957,17 +6959,39 @@ function page_doc_link($text='', $iconpath='') {
function doc_link($path='', $text='', $iconpath='') { function doc_link($path='', $text='', $iconpath='') {
global $CFG; global $CFG;


if (empty($CFG->docroot)) {
return '';
}

$target = ''; $target = '';
if (!empty($CFG->doctonewwindow)) { if (!empty($CFG->doctonewwindow)) {
$target = ' target="_blank"'; $target = ' target="_blank"';
} }


$lang = str_replace('_utf8', '', current_language()); if (is_null($docroot = get_doc_root())) {
return '';
}

$str = '<a href="' .$docroot. '/' .$path. '"' .$target. '>';

if (empty($iconpath)) {
$iconpath = $CFG->httpswwwroot . '/pix/docs.gif';
}

// alt left blank intentionally to prevent repetition in screenreaders
$str .= '<img class="iconhelp" src="' .$iconpath. '" alt="" />' .$text. '</a>';

return $str;
}


/**
* A function that checks if docroot is set, builds and returns the docs root url according to version release.
* @return string documentation url, null if doc root isn't set (ie:during installation perhaps).
*/
function get_doc_root() {
global $CFG;

if (empty($CFG->docroot)) {
return null;
}

$lang = str_replace('_utf8', '', current_language());
if (!empty($CFG->release)) { if (!empty($CFG->release)) {
$release = $CFG->release; $release = $CFG->release;
} else { } else {
Expand All @@ -6980,19 +7004,9 @@ function doc_link($path='', $text='', $iconpath='') {
$branch = '.'; $branch = '.';
} }


$str = '<a href="' .$CFG->docroot. '/' .$branch. '/' .$lang. '/' .$path. '"' .$target. '>'; return $CFG->docroot. '/' .$branch. '/' .$lang;

if (empty($iconpath)) {
$iconpath = $CFG->httpswwwroot . '/pix/docs.gif';
}

// alt left blank intentionally to prevent repetition in screenreaders
$str .= '<img class="iconhelp" src="' .$iconpath. '" alt="" />' .$text. '</a>';

return $str;
} }



/** /**
* Returns true if the current site debugging settings are equal or above specified level. * Returns true if the current site debugging settings are equal or above specified level.
* If passed a parameter it will emit a debugging notice similar to trigger_error(). The * If passed a parameter it will emit a debugging notice similar to trigger_error(). The
Expand Down

0 comments on commit 5cea248

Please sign in to comment.