From 9452cae8ddcfca63c2f09d5098370c22c1920768 Mon Sep 17 00:00:00 2001 From: Daniel Neis Date: Fri, 29 Jun 2012 12:23:45 -0300 Subject: [PATCH] MDL-23514 lang : Adding an option to force language of documentation links --- admin/settings/appearance.php | 3 +++ lang/en/admin.php | 2 ++ lib/setuplib.php | 12 +++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index f9ca6d4d5d6..d28b694b1e2 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -183,6 +183,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page // "documentation" settingpage $temp = new admin_settingpage('documentation', new lang_string('moodledocs')); $temp->add(new admin_setting_configtext('docroot', new lang_string('docroot', 'admin'), new lang_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL)); + $ltemp = array('' => get_string('forceno')); + $ltemp += get_string_manager()->get_list_of_translations(true); + $temp->add(new admin_setting_configselect('doclang', get_string('doclang', 'admin'), get_string('configdoclang', 'admin'), '', $ltemp)); $temp->add(new admin_setting_configcheckbox('doctonewwindow', new lang_string('doctonewwindow', 'admin'), new lang_string('configdoctonewwindow', 'admin'), 0)); $ADMIN->add('appearance', $temp); diff --git a/lang/en/admin.php b/lang/en/admin.php index ffea8a9f869..f1ad29ca83b 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -193,6 +193,7 @@ $string['configenabledevicedetection'] = 'Enables detection of mobiles, smartpho $string['configdisableuserimages'] = 'Disable the ability for users to change user profile images.'; $string['configdisplayloginfailures'] = 'This will display information to selected users about previous failed logins.'; $string['configdndallowtextandlinks'] = 'Enable or disable the dragging and dropping of text and links onto a course page, alongside the dragging and dropping of files. Note that the dragging of text into Firefox or between different browsers is unreliable and may result in no data being uploaded, or corrupted text being uploaded.'; +$string['configdoclang'] = 'This language will be used in links for the documentation pages.'; $string['configdocroot'] = 'Defines the path to the Moodle Docs. You can change this if you wish to have your own custom online documentation. However, if you do that make sure that the paths in your documentation follow the same format as http://docs.moodle.org.'; $string['configdoctonewwindow'] = 'If you enable this, then links to Moodle Docs will be shown in a new window.'; $string['configeditordictionary'] = 'This value will be used if aspell doesn\'t have dictionary for users own language.'; @@ -442,6 +443,7 @@ $string['disableuserimages'] = 'Disable user profile images'; $string['displayerrorswarning'] = 'Enabling the PHP setting display_errors is not recommended on production sites because some error messages may reveal sensitive information about your server.'; $string['displayloginfailures'] = 'Display login failures to'; $string['dndallowtextandlinks'] = 'Drag and drop upload of text/links'; +$string['doclang'] = 'Language for docs'; $string['docroot'] = 'Moodle Docs document root'; $string['doctonewwindow'] = 'Open in new window'; $string['download'] = 'Download'; diff --git a/lib/setuplib.php b/lib/setuplib.php index e120a909661..9cc37ec5c25 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -643,10 +643,16 @@ function get_docs_url($path = null) { // 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; + if (empty($CFG->doclang)) { + $lang = current_language(); } else { - return 'http://docs.moodle.org/'. $branch . '/' . current_language() . '/' . $path; + $lang = $CFG->doclang; + } + $end = '/' . $branch . '/' . $lang . '/' . $path; + if (empty($CFG->docroot)) { + return 'http://docs.moodle.org'. $end; + } else { + return $CFG->docroot . $end ; } }