diff --git a/administrator/components/com_menus/models/menutypes.php b/administrator/components/com_menus/models/menutypes.php index 0b758dcede1b9..73a4bc4d0fcd4 100644 --- a/administrator/components/com_menus/models/menutypes.php +++ b/administrator/components/com_menus/models/menutypes.php @@ -269,7 +269,6 @@ protected function getTypeOptionsFromLayouts($component, $view) $layouts = array(); $layoutNames = array(); $templateLayouts = array(); - $lang = JFactory::getLanguage(); // Get the layouts from the view folder. $path = JPATH_SITE.'/components/'.$component.'/views/'.$view.'/tmpl'; @@ -300,10 +299,7 @@ protected function getTypeOptionsFromLayouts($component, $view) { if (JFolder::exists($folder . '/html/' . $component . '/' . $view)) { $template = JFile::getName($folder); - $lang->load('tpl_'.$template.'.sys', JPATH_SITE, null, false, false) - || $lang->load('tpl_'.$template.'.sys', JPATH_SITE.'/templates/'.$template, null, false, false) - || $lang->load('tpl_'.$template.'.sys', JPATH_SITE, $lang->getDefault(), false, false) - || $lang->load('tpl_'.$template.'.sys', JPATH_SITE.'/templates/'.$template, $lang->getDefault(), false, false); + JFactory::getLanguage()->load('tpl_'.$template.'.sys', array(JPATH_SITE, JPATH_SITE.'/templates/'.$template), true, false, false); $templateLayouts = JFolder::files($folder . '/html/' . $component . '/' . $view, '.xml$', false, true); diff --git a/administrator/components/com_menus/views/items/view.html.php b/administrator/components/com_menus/views/items/view.html.php index fd49412255e4a..0a960bc9ccdfb 100644 --- a/administrator/components/com_menus/views/items/view.html.php +++ b/administrator/components/com_menus/views/items/view.html.php @@ -92,11 +92,7 @@ public function display($tpl = null) $temp = explode(':', $vars['layout']); $file = JPATH_SITE.'/templates/'.$temp[0].'/html/'.$item->componentname.'/'.$vars['view'].'/'.$temp[1].'.xml'; // Load template language file - $lang->load('tpl_'.$temp[0].'.sys', JPATH_SITE, null, false, false) - || $lang->load('tpl_'.$temp[0].'.sys', JPATH_SITE.'/templates/'.$temp[0], null, false, false) - || $lang->load('tpl_'.$temp[0].'.sys', JPATH_SITE, $lang->getDefault(), false, false) - || $lang->load('tpl_'.$temp[0].'.sys', JPATH_SITE.'/templates/'.$temp[0], $lang->getDefault(), false, false); - + $lang->load('tpl_'.$temp[0].'.sys', array(JPATH_SITE, JPATH_SITE.'/templates/'.$temp[0]), true, false, false); } else { diff --git a/administrator/components/com_modules/models/positions.php b/administrator/components/com_modules/models/positions.php index 16f70acd84d90..55c15d18eaf98 100644 --- a/administrator/components/com_modules/models/positions.php +++ b/administrator/components/com_modules/models/positions.php @@ -132,10 +132,7 @@ public function getItems() $xml = simplexml_load_file($path); if (isset($xml->positions[0])) { - $lang->load('tpl_'.$template->element.'.sys', $client->path, null, false, false) - || $lang->load('tpl_'.$template->element.'.sys', $client->path.'/templates/'.$template->element, null, false, false) - || $lang->load('tpl_'.$template->element.'.sys', $client->path, $lang->getDefault(), false, false) - || $lang->load('tpl_'.$template->element.'.sys', $client->path.'/templates/'.$template->element, $lang->getDefault(), false, false); + $lang->load('tpl_'.$template->element.'.sys', array($client->path, $client->path.'/templates/'.$template->element), true, false, false); foreach ($xml->positions[0] as $position) { $value = (string)$position['value']; diff --git a/administrator/components/com_templates/models/style.php b/administrator/components/com_templates/models/style.php index 16cd4c9e7716c..a0bd69206cf77 100644 --- a/administrator/components/com_templates/models/style.php +++ b/administrator/components/com_templates/models/style.php @@ -313,7 +313,6 @@ protected function preprocessForm(JForm $form, $data, $group = 'content') // Initialise variables. $clientId = $this->getState('item.client_id'); $template = $this->getState('item.template'); - $lang = JFactory::getLanguage(); $client = JApplicationHelper::getClientInfo($clientId); if (!$form->loadFile('style_'.$client->name, true)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); @@ -325,10 +324,7 @@ protected function preprocessForm(JForm $form, $data, $group = 'content') $formFile = JPath::clean($client->path.'/templates/'.$template.'/templateDetails.xml'); // Load the core and/or local language file(s). - $lang->load('tpl_'.$template, $client->path, null, false, false) - || $lang->load('tpl_'.$template, $client->path.'/templates/'.$template, null, false, false) - || $lang->load('tpl_'.$template, $client->path, $lang->getDefault(), false, false) - || $lang->load('tpl_'.$template, $client->path.'/templates/'.$template, $lang->getDefault(), false, false); + JFactory::getLanguage()->load('tpl_'.$template, array($client->path,$client->path.'/templates/'.$template), true, false, true); if (file_exists($formFile)) { // Get the template form. diff --git a/administrator/components/com_templates/models/template.php b/administrator/components/com_templates/models/template.php index b0655845931df..3c00aae44b5c0 100644 --- a/administrator/components/com_templates/models/template.php +++ b/administrator/components/com_templates/models/template.php @@ -50,19 +50,19 @@ public function getFiles() { // Initialise variables. $result = array(); + $standard = JFactory::getApplication()->getTemplate(); if ($template = $this->getTemplate()) { jimport('joomla.filesystem.folder'); $client = JApplicationHelper::getClientInfo($template->client_id); $path = JPath::clean($client->path.'/templates/'.$template->element.'/'); - $lang = JFactory::getLanguage(); // Load the core and/or local language file(s). - $lang->load('tpl_'.$template->element, $client->path, null, false, false) - || $lang->load('tpl_'.$template->element, $client->path.'/templates/'.$template->element, null, false, false) - || $lang->load('tpl_'.$template->element, $client->path, $lang->getDefault(), false, false) - || $lang->load('tpl_'.$template->element, $client->path.'/templates/'.$template->element, $lang->getDefault(), false, false); + if ($template->element !== $standard) + { + JFactory::getLanguage()->load('tpl_'.$template->element, $client->path, true, false, false); + } // Check if the template path exists. diff --git a/libraries/joomla/application/component/helper.php b/libraries/joomla/application/component/helper.php index 7db679077d6e8..2a478be33e0c1 100644 --- a/libraries/joomla/application/component/helper.php +++ b/libraries/joomla/application/component/helper.php @@ -301,10 +301,7 @@ public static function renderComponent($option, $params = array()) // Load template language files. $template = $app->getTemplate(true)->template; $lang = JFactory::getLanguage(); - $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, false) - || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", $lang->getDefault(), false, false); + $lang->load('tpl_' . $template, array(JPATH_BASE, JPATH_THEMES . "/{$template}"), true); if (empty($option)) { diff --git a/libraries/joomla/application/component/view.php b/libraries/joomla/application/component/view.php index a1b4555f3739f..abfd3ba753708 100644 --- a/libraries/joomla/application/component/view.php +++ b/libraries/joomla/application/component/view.php @@ -699,11 +699,7 @@ public function loadTemplate($tpl = null) $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl) : $tpl; // Load the language file for the template - $lang = JFactory::getLanguage(); - $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, false) - || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", $lang->getDefault(), false, false); + JFactory::getLanguage()->load('tpl_' . $template, array(JPATH_BASE, JPATH_THEMES . "/$template"), true, false, false); // Change the template folder if alternative layout is in different template if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) diff --git a/libraries/joomla/application/module/helper.php b/libraries/joomla/application/module/helper.php index c71dbaf7287be..8f40ee760d293 100644 --- a/libraries/joomla/application/module/helper.php +++ b/libraries/joomla/application/module/helper.php @@ -163,12 +163,7 @@ public static function renderModule($module, $attribs = array()) // $module->user is a check for 1.0 custom modules and is deprecated refactoring if (empty($module->user) && file_exists($path)) { - $lang = JFactory::getLanguage(); - // 1.5 or Core then 1.6 3PD - $lang->load($module->module, JPATH_BASE, null, false, false) || - $lang->load($module->module, dirname($path), null, false, false) || - $lang->load($module->module, JPATH_BASE, $lang->getDefault(), false, false) || - $lang->load($module->module, dirname($path), $lang->getDefault(), false, false); + JFactory::getLanguage()->load($module->module, array(JPATH_BASE, dirname($path)), true, false, true); $content = ''; ob_start(); @@ -349,8 +344,9 @@ protected static function &_load() { $module = &$modules[$i]; - // The module is excluded if there is an explicit prohibition - $negHit = ($negId === (int) $module->menuid); + // The module is excluded if there is an explicit prohibition or if + // the Itemid is missing or zero and the module is in exclude mode. + $negHit = ($negId === (int) $module->menuid) || (!$negId && (int) $module->menuid < 0); if (isset($dupes[$module->id])) { diff --git a/libraries/joomla/document/html/html.php b/libraries/joomla/document/html/html.php index 9950a77131507..0feea393daedf 100644 --- a/libraries/joomla/document/html/html.php +++ b/libraries/joomla/document/html/html.php @@ -574,13 +574,7 @@ protected function _fetchTemplate($params = array()) } // Load the language file for the template - $lang = JFactory::getLanguage(); - // 1.5 or core then 1.6 - - $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) - || $lang->load('tpl_' . $template, $directory . '/' . $template, null, false, false) - || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template, $directory . '/' . $template, $lang->getDefault(), false, false); + JFactory::getLanguage()->load('tpl_' . $template, array(JPATH_BASE, $directory . '/' . $template), true, false, false); // Assign the variables $this->template = $template; diff --git a/libraries/joomla/form/fields/componentlayout.php b/libraries/joomla/form/fields/componentlayout.php index f9779b526f97e..7fc420e5e4c47 100644 --- a/libraries/joomla/form/fields/componentlayout.php +++ b/libraries/joomla/form/fields/componentlayout.php @@ -179,12 +179,7 @@ protected function getInput() foreach ($templates as $template) { // Load language file - $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false) - || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false) - || $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false) - || $lang->load( - 'tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false - ); + $lang->load('tpl_' . $template->element . '.sys', array($client->path, $client->path . '/templates/' . $template->element), true, false, false); $template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $extn . '/' . $view); @@ -219,8 +214,7 @@ protected function getInput() { // Add an option to the template group $value = JFile::stripext(JFile::getName($file)); - $text = $lang - ->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value)) + $text = $lang->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value)) ? JText::_($key) : $value; $groups[$template->name]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text); } diff --git a/libraries/joomla/form/fields/modulelayout.php b/libraries/joomla/form/fields/modulelayout.php index a46ffffdc416f..afe94bd2a0435 100644 --- a/libraries/joomla/form/fields/modulelayout.php +++ b/libraries/joomla/form/fields/modulelayout.php @@ -147,13 +147,7 @@ protected function getInput() foreach ($templates as $template) { // Load language file - $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false) - || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false) - || $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false) - || $lang->load( - 'tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), - false, false - ); + $lang->load('tpl_' . $template->element . '.sys', array($client->path, $client->path . '/templates/' . $template->element), true, false, false); $template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $module); diff --git a/libraries/joomla/form/fields/templatestyle.php b/libraries/joomla/form/fields/templatestyle.php index 82ed784132264..e858533114455 100644 --- a/libraries/joomla/form/fields/templatestyle.php +++ b/libraries/joomla/form/fields/templatestyle.php @@ -80,10 +80,7 @@ protected function getGroups() foreach ($styles as $style) { $template = $style->template; - $lang->load('tpl_' . $template . '.sys', $client->path, null, false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, $lang->getDefault(), false, false); + $lang->load('tpl_' . $template . '.sys', array($client->path, $client->path . '/templates/' . $template), true, false, false); $name = JText::_($style->name); // Initialize the group if necessary. if (!isset($groups[$name])) diff --git a/libraries/joomla/language/language.php b/libraries/joomla/language/language.php index 0ba53486e3830..b31b5081e2779 100644 --- a/libraries/joomla/language/language.php +++ b/libraries/joomla/language/language.php @@ -700,11 +700,11 @@ public static function exists($lang, $basePath = JPATH_BASE) } /** - * Loads a single language file and appends the results to the existing strings + * Loads a single language file and appends the results to the existing strings. * * @param string $extension The extension for which a language file should be loaded. - * @param string $basePath The basepath to use. - * @param string $lang The language to load, default null for the current language. + * @param mixed $basePath The basepath to use, or an array/iterable object with paths + * @param string $lang The language to load, default TRUE for the current language. * @param boolean $reload Flag that will force a language to be reloaded if set to true. * @param boolean $default Flag that force the default language to be loaded if the current does not exist. * @@ -712,48 +712,68 @@ public static function exists($lang, $basePath = JPATH_BASE) * * @since 11.1 */ - public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false, $default = true) + public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = true, $reload = false, $default = true) { - if (!$lang) + // testing null for BC with !lang + if ($lang === true || $lang === null) { + // use current $lang = $this->lang; + if ($default == true && ($lang == $this->default)) + { + // current IS the default, no need to force it + $default == false; + } } - $path = self::getLanguagePath($basePath, $lang); - - $internal = $extension == 'joomla' || $extension == ''; - $filename = $internal ? $lang : $lang . '.' . $extension; - $filename = "$path/$filename.ini"; + if (is_string($basePath)) + { + $basePath = array($basePath); + } $result = false; + $stack = array(); - if (isset($this->paths[$extension][$filename]) && !$reload) + while ($base = array_shift($basePath)) { - // This file has already been tested for loading. - $result = $this->paths[$extension][$filename]; - } - else - { - // Load the language file - $result = $this->loadLanguage($filename, $extension); + $stack[] = $base; - // Check whether there was a problem with loading the file - if ($result === false && $default) + // one path matched, no need to iterate further + if ($result == true) { - // No strings, so either file doesn't exist or the file is invalid - $oldFilename = $filename; + break; + } - // Check the standard file name - $path = self::getLanguagePath($basePath, $this->default); - $filename = $internal ? $this->default : $this->default . '.' . $extension; - $filename = "$path/$filename.ini"; + $path = self::getLanguagePath($base, $lang); - // If the one we tried is different than the new name, try again - if ($oldFilename != $filename) - { - $result = $this->loadLanguage($filename, $extension, false); - } + $internal = $extension == 'joomla' || $extension == ''; + $filename = $internal ? $lang : $lang . '.' . $extension; + $filename = "$path/$filename.ini"; + + $result = false; + + if (isset($this->paths[$extension][$filename]) && !$reload) + { + // This file has already been tested for loading. + $result = $this->paths[$extension][$filename]; + break; } + + // Load the language file + $result = $this->loadLanguage($filename, $extension); + } + + // Check whether there was a problem with loading the file + if ($result === false && $default) + { + // refill + if (count($basePath)) + { + $stack = $stack + $basePath; + } + + // Check the standard file name and default language + $result = $this->load($extension, $stack, $this->default, $reload, $default); } return $result;