[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/HTML/Helpers/ -> AdminLanguage.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\HTML\Helpers;
  11  
  12  use Joomla\CMS\Language\LanguageHelper;
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Object\CMSObject;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('JPATH_PLATFORM') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Utility class working with administrator language select lists
  22   *
  23   * @since  3.8.0
  24   */
  25  abstract class AdminLanguage
  26  {
  27      /**
  28       * Cached array of the administrator language items.
  29       *
  30       * @var    array
  31       * @since  3.8.0
  32       */
  33      protected static $items = null;
  34  
  35      /**
  36       * Get a list of the available administrator language items.
  37       *
  38       * @param   boolean  $all        True to include All (*)
  39       * @param   boolean  $translate  True to translate All
  40       *
  41       * @return  array
  42       *
  43       * @since   3.8.0
  44       */
  45      public static function existing($all = false, $translate = false)
  46      {
  47          if (empty(static::$items)) {
  48              $languages       = array();
  49              $admin_languages = LanguageHelper::getKnownLanguages(JPATH_ADMINISTRATOR);
  50  
  51              foreach ($admin_languages as $tag => $language) {
  52                  $languages[$tag] = $language['nativeName'];
  53              }
  54  
  55              ksort($languages);
  56  
  57              static::$items = $languages;
  58          }
  59  
  60          if ($all) {
  61              $all_option = array(new CMSObject(array('value' => '*', 'text' => $translate ? Text::alt('JALL', 'language') : 'JALL_LANGUAGE')));
  62  
  63              return array_merge($all_option, static::$items);
  64          } else {
  65              return static::$items;
  66          }
  67      }
  68  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer