- md5
- 946b0be6cff6e9c095c4c41b5431ee16
- sha1
- ea7aa8c8a5c5c7a6c6e24d23aee8f5c2a3dea256
- sha256
- 2bc19c6c7da021ea6e82e4b0977a2786bc3ab5028b754641e54c7b075b6a1022
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Language;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
/**
* Utitlity 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.
*
* @return boolean True if site is supporting multiple languages; false otherwise.
*
* @since 2.5.4
*/
public static function isEnabled()
{
// 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 = 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 = Factory::getDbo();
$query = $db->getQuery(true)
->select('enabled')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
->where($db->quoteName('element') . ' = ' . $db->quote('languagefilter'));
$db->setQuery($query);
static::$enabled = $db->loadResult();
$tested = true;
}
return (bool) static::$enabled;
}
/**
* Method to return a list of language home page menu items.
*
* @return array of menu objects.
*
* @since 3.5
*/
public static function getSiteHomePages()
{
// To avoid doing duplicate database queries.
static $multilangSiteHomePages = null;
if (!isset($multilangSiteHomePages))
{
// Check for Home pages languages.
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('language')
->select('id')
->from($db->quoteName('#__menu'))
->where('home = 1')
->where('published = 1')
->where('client_id = 0');
$db->setQuery($query);
$multilangSiteHomePages = $db->loadObjectList('language');
}
return $multilangSiteHomePages;
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.