From db356340d8b125e30d27fb4a11ca5cda2c053b2c Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 12 Jun 2003 11:55:29 +0000 Subject: [PATCH] Use parentlanguage when printing documentation --- lib/moodlelib.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 0b023ddac4..27d42cbec1 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1088,32 +1088,27 @@ function document_file($file, $include=true) { global $CFG; + $file = clean_filename($file); + if (empty($file)) { - echo "Error 404"; return false; } - $lang = current_language(); - - $file = clean_filename($file); + $langs = array(current_language(), get_string("parentlanguage"), "en"); - $info->filepath = "$CFG->dirroot/lang/$lang/docs/$file"; - $info->urlpath = "$CFG->wwwroot/lang/$lang/docs/$file"; + foreach ($langs as $lang) { + $info->filepath = "$CFG->dirroot/lang/$lang/docs/$file"; + $info->urlpath = "$CFG->wwwroot/lang/$lang/docs/$file"; - if (!file_exists($info->filepath)) { - $info->filepath = "$CFG->dirroot/lang/en/docs/$file"; - $info->urlpath = "$CFG->wwwroot/lang/en/docs/$file"; - if (!file_exists($info->filepath)) { - error("Error 404 - $file does not exist"); - return NULL; + if (file_exists($info->filepath)) { + if ($include) { + include($info->filepath); + } + return $info; } } - if ($include) { - include($info->filepath); - } - - return $info; + return false; } -- 2.39.5