- md5
- 4b0b46ddeb088175cbc7ca4e6d18975b
- sha1
- ccba64790bf2c443b9c8ef3885e0ec00418420d2
- sha256
- 1343e0b2b3bd208f8127681ec376b7ce2483672cb4b9e066b7646827b8599f88
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Language;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Menu\MenuItem;
use Joomla\CMS\Menu\SiteMenu;
use Joomla\Database\DatabaseInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Utility class for multilang
*
* @since 2.5.4
*/
class Multilanguage
{
/**
* Flag indicating multilanguage functionality is enabled.
*
* @var boolean
* @since 4.0.0
*/
public static $enabled = false;
/**
* 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->createQuery()
->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;
}
/**
* Method to return a list of language home page menu items.
*
* @return MenuItem[] array of menu item objects.
*
* @since 3.5
*/
public static function getSiteHomePages()
{
/** @var SiteMenu $menu */
$menu = Factory::getApplication()->getMenu('site');
return $menu->getHomepages();
}
}
The same content is in 26 releases, Joomla 6.1.0-beta2 to 6.2.0. See them all, or every version of this file.