Source for file multilang.php

Documentation is available at multilang.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Language
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Utitlity class for multilang
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Language
  17.  * @since       2.5.4
  18.  */
  19. {
  20.     /**
  21.      * Method to determine if the language filter plugin is enabled.
  22.      * This works for both site and administrator.
  23.      *
  24.      * @return  boolean  True if site is supporting multiple languages; false otherwise.
  25.      *
  26.      * @since   2.5.4
  27.      */
  28.     public static function isEnabled()
  29.     {
  30.         // Flag to avoid doing multiple database queries.
  31.         static $tested false;
  32.  
  33.         // Status of language filter plugin.
  34.         static $enabled false;
  35.  
  36.         // Get application object.
  37.         $app JFactory::getApplication();
  38.  
  39.         // If being called from the front-end, we can avoid the database query.
  40.         if ($app->isSite())
  41.         {
  42.             $enabled $app->getLanguageFilter();
  43.             return $enabled;
  44.         }
  45.  
  46.         // If already tested, don't test again.
  47.         if (!$tested)
  48.         {
  49.             // Determine status of language filter plug-in.
  50.             $db JFactory::getDbo();
  51.             $query $db->getQuery(true)
  52.                 ->select('enabled')
  53.                 ->from($db->quoteName('#__extensions'))
  54.                 ->where($db->quoteName('type'' = ' $db->quote('plugin'))
  55.                 ->where($db->quoteName('folder'' = ' $db->quote('system'))
  56.                 ->where($db->quoteName('element'' = ' $db->quote('languagefilter'));
  57.             $db->setQuery($query);
  58.  
  59.             $enabled $db->loadResult();
  60.             $tested true;
  61.         }
  62.  
  63.         return $enabled;
  64.     }
  65. }

Documentation generated on Tue, 19 Nov 2013 15:09:03 +0100 by phpDocumentor 1.4.3