Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
language.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Form
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
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 JFormHelper::loadFieldClass('list');
13 
14 /**
15  * Form Field class for the Joomla Platform.
16  * Supports a list of installed application languages
17  *
18  * @package Joomla.Platform
19  * @subpackage Form
20  * @see JFormFieldContentLanguage for a select list of content languages.
21  * @since 11.1
22  */
24 {
25  /**
26  * The form field type.
27  *
28  * @var string
29  * @since 11.1
30  */
31  protected $type = 'Language';
32 
33  /**
34  * Method to get the field options.
35  *
36  * @return array The field option objects.
37  *
38  * @since 11.1
39  */
40  protected function getOptions()
41  {
42  // Initialize some field attributes.
43  $client = (string) $this->element['client'];
44 
45  if ($client != 'site' && $client != 'administrator')
46  {
47  $client = 'site';
48  }
49 
50  // Merge any additional options in the XML definition.
51  $options = array_merge(
52  parent::getOptions(),
53  JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true, true)
54  );
55 
56  // Set the default value active language
57  if ($langParams = JComponentHelper::getParams('com_languages'))
58  {
59  switch ((string) $this->value)
60  {
61  case 'site':
62  case 'frontend':
63  case '0':
64  $this->value = $langParams->get('site', 'en-GB');
65  break;
66  case 'admin':
67  case 'administrator':
68  case 'backend':
69  case '1':
70  $this->value = $langParams->get('administrator', 'en-GB');
71  break;
72  case 'active':
73  case 'auto':
74  $lang = JFactory::getLanguage();
75  $this->value = $lang->getTag();
76  break;
77  default:
78  break;
79  }
80  }
81 
82  return $options;
83  }
84 }