/**
* Method to determine if the language filter plugin is enabled.
* This works for both site and administrator.
*
* @param CMSApplication $app The application
* @param DatabaseInterface $db The database
*
* @return boolean True if site is supporting multiple languages; false otherwise.
*
* @since 2.5.4
*/
public static function isEnabled(CMSApplication $app = null, DatabaseInterface $db = null)
{
// Flag to avoid doing multiple database queries.
static $tested = false;
// Do not proceed with testing if the flag is true
if (static::$enabled) {
return true;
}
// Get application object.
$app = $app ?: Factory::getApplication();
// If being called from the frontend, we can avoid the database query.
if ($app->isClient('site')) {
static::$enabled = $app->getLanguageFilter();
return static::$enabled;
}
// If already tested, don't test again.
if (!$tested) {
// Determine status of language filter plugin.
$db = $db ?: Factory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName('enabled'))->from($db->quoteName('#__extensions'))->where([$db->quoteName('type') . ' = ' . $db->quote('plugin'), $db->quoteName('folder') . ' = ' . $db->quote('system'), $db->quoteName('element') . ' = ' . $db->quote('languagefilter')]);
$db->setQuery($query);
static::$enabled = (bool) $db->loadResult();
$tested = true;
}
return static::$enabled;
}