Source for file language.php

Documentation is available at language.php

  1. <?php
  2. /**
  3.  * @package    Joomla.Installation
  4.  *
  5.  * @copyright  Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  6.  * @license    GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8.  
  9. defined('JPATH_BASE'or die;
  10.  
  11.  
  12. /**
  13.  * Language Form Field class.
  14.  *
  15.  * @package  Joomla.Installation
  16.  * @since    1.6
  17.  */
  18. {
  19.     /**
  20.      * The form field type.
  21.      *
  22.      * @var        string 
  23.      * @since   1.6
  24.      */
  25.     protected $type = 'Language';
  26.  
  27.     /**
  28.      * Method to get the field options.
  29.      *
  30.      * @return  array  The field option objects.
  31.      *
  32.      * @since   1.6
  33.      */
  34.     protected function getOptions()
  35.     {
  36.         $app JFactory::getApplication();
  37.  
  38.         // Detect the native language.
  39.         $native JLanguageHelper::detectLanguage();
  40.  
  41.         if (empty($native))
  42.         {
  43.             $native 'en-GB';
  44.         }
  45.  
  46.         // Get a forced language if it exists.
  47.         $forced $app->getLocalise();
  48.  
  49.         if (!empty($forced['language']))
  50.         {
  51.             $native $forced['language'];
  52.         }
  53.  
  54.         // If a language is already set in the session, use this instead
  55.         $model   new InstallationModelSetup;
  56.         $options $model->getOptions();
  57.  
  58.         if (isset($options['language']))
  59.         {
  60.             $native $options['language'];
  61.         }
  62.  
  63.         // Get the list of available languages.
  64.         $options JLanguageHelper::createLanguageList($native);
  65.  
  66.         if (!$options || $options  instanceof Exception)
  67.         {
  68.             $options array();
  69.         }
  70.         // Sort languages by name
  71.         else
  72.         {
  73.             usort($optionsarray($this'_sortLanguages'));
  74.         }
  75.  
  76.         // Set the default value from the native language.
  77.         $this->value = $native;
  78.  
  79.         // Merge any additional options in the XML definition.
  80.         $options array_merge(parent::getOptions()$options);
  81.  
  82.         return $options;
  83.     }
  84.  
  85.     /**
  86.      * Method to sort languages by name.
  87.      *
  88.      * @param   string  $a  The first value to determine sort
  89.      * @param   string  $b  The second value to determine sort
  90.      *
  91.      * @return  string 
  92.      *
  93.      * @since    3.1
  94.      */
  95.     protected function _sortLanguages($a$b)
  96.     {
  97.         return strcmp($a['text']$b['text']);
  98.     }
  99. }

Documentation generated on Tue, 19 Nov 2013 15:06:26 +0100 by phpDocumentor 1.4.3