From 3518913cc8712a5f9f4fa749163d67b87ddcdef9 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 11 Apr 2010 20:37:13 +0000 Subject: [PATCH] MDL-21694 simplified tinymce string handling --- lib/editor/tinymce/extra/strings.php | 52 +--------------------------- lib/moodlelib.php | 20 ++++++++++- 2 files changed, 20 insertions(+), 52 deletions(-) diff --git a/lib/editor/tinymce/extra/strings.php b/lib/editor/tinymce/extra/strings.php index 845b9a2c442..8fa0f739fa7 100644 --- a/lib/editor/tinymce/extra/strings.php +++ b/lib/editor/tinymce/extra/strings.php @@ -40,34 +40,7 @@ if ($lang === 'en') { $lang = 'en'; } -// load english defaults -$string = array(); -foreach (get_langpack_en_locations() as $location) { - if (!file_exists($location)) { - continue; - } - include($location); -} - -// find parent language -if ($parent = get_parent_language($lang)) { - foreach (get_langpack_locations($parent) as $location) { - if (!file_exists($location)) { - continue; - } - include($location); - } -} - -// load wanted language -if ($lang !== 'en') { - foreach (get_langpack_locations($lang) as $location) { - if (!file_exists($location)) { - continue; - } - include($location); - } -} +$string = get_string_manager()->load_component_strings('editor_tinymce', $lang); //process the $strings to match expected tinymce lang array stucture $result = array(); @@ -94,26 +67,3 @@ $lifetime = '10'; // TODO: increase later @header('Pragma: '); echo $output; - - -/// ======= Functions ================= - -function get_langpack_en_locations() { - global $CFG; - - $result = array(); - $result[] = "$CFG->dirroot/lib/editor/tinymce/lang/en/editor_tinymce.php"; - $result[] = "$CFG->langlocalroot/en_local/editor_tinymce.php"; - - return $result; -} - -function get_langpack_locations($lang) { - global $CFG; - - $result = array(); - $result[] = "$CFG->langotherroot/$lang/editor_tinymce.php"; - $result[] = "$CFG->langlocalroot/{$lang}_local/editor_tinymce.php"; - - return $result; -} diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f4069075f7e..b5bf724ced9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5712,6 +5712,14 @@ interface string_manager { * @param bool $returnall return all or just enabled */ public function get_list_of_languages($returnall = false); + + /** + * Load all strings for one component + * @param string $component The module the string is associated with + * @param string $lang + * @return array of all string for given component and lang + */ + public function load_component_strings($component, $lang); } @@ -5774,7 +5782,7 @@ class amos_string_manager implements string_manager { * @param string $lang * @return array of all string for given component and lang */ - protected function load_component_strings($component, $lang) { + public function load_component_strings($component, $lang) { global $CFG; list($plugintype, $pluginname) = normalize_component($component); @@ -6035,6 +6043,16 @@ class install_string_manager implements string_manager { $this->installroot = "$CFG->dirroot/install/lang"; } + /** + * Load all strings for one component + * @param string $component The module the string is associated with + * @param string $lang + * @return array of all string for given component and lang + */ + public function load_component_strings($component, $lang) { + return array(); + } + /** * Get String returns a requested string * -- 2.43.0