Skip to content

Commit

Permalink
Alternative approach to #9999 to deal with hardcoded import of plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed May 8, 2016
1 parent d4aa0c2 commit d939290
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 17 additions & 4 deletions libraries/cms/application/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,21 @@ protected function initialiseApp($options = array())
$user->groups = array($guestUsergroup);
}

// If a language was specified it has priority, otherwise use user or default language settings
JPluginHelper::importPlugin('system', 'languagefilter');
/*
* If a language was specified it has priority, otherwise use user or default language settings
* Check this only if the languagefilter plugin is enabled
*
* @TODO - Remove the hardcoded dependency to the languagefilter plugin
*/
if (JPluginHelper::isEnabled('system', 'languagefilter'))
{
$plugin = JPluginHelper::getPlugin('system', 'languagefilter');

$pluginParams = new Registry($plugin->params);

$this->setLanguageFilter(true);
$this->setDetectBrowser($pluginParams->get('detect_browser', '1') == '1');
}

if (empty($options['language']))
{
Expand All @@ -600,7 +613,7 @@ protected function initialiseApp($options = array())
}
}

if ($this->_language_filter && empty($options['language']))
if ($this->getLanguageFilter() && empty($options['language']))
{
// Detect cookie language
$lang = $this->input->cookie->get(md5($this->get('secret') . 'language'), null, 'string');
Expand All @@ -624,7 +637,7 @@ protected function initialiseApp($options = array())
}
}

if ($this->_detect_browser && empty($options['language']))
if ($this->getDetectBrowser() && empty($options['language']))
{
// Detect browser language
$lang = JLanguageHelper::detectLanguage();
Expand Down
5 changes: 0 additions & 5 deletions plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public function __construct(&$subject, $config)
unset($this->sefs[$language->sef]);
}
}

$this->app->setLanguageFilter(true);

// Detect browser feature.
$this->app->setDetectBrowser($this->params->get('detect_browser', '1') == '1');
}
}

Expand Down

0 comments on commit d939290

Please sign in to comment.