1 <?php
2 3 4 5 6 7 8
9
10 defined('JPATH_PLATFORM') or die;
11
12 JFormHelper::loadFieldClass('list');
13
14 15 16 17 18 19
20 class JFormFieldFrontend_Language extends JFormFieldList
21 {
22 23 24 25 26 27
28 public $type = 'Frontend_Language';
29
30 31 32 33 34 35 36
37 protected function getOptions()
38 {
39
40 $db = JFactory::getDbo();
41 $query = $db->getQuery(true);
42
43 $query->select('a.lang_code AS value, a.title AS text')
44 ->from($db->quoteName('#__languages') . ' AS a')
45 ->where('a.published = 1')
46 ->order('a.title');
47
48
49 $query->select('l.home, l.language')
50 ->innerJoin($db->quoteName('#__menu') . ' AS l ON l.language=a.lang_code AND l.home=1 AND l.published=1 AND l.language <> ' . $db->quote('*'))
51 ->innerJoin($db->quoteName('#__extensions') . ' AS e ON e.element = a.lang_code')
52 ->where('e.client_id = 0')
53 ->where('e.enabled = 1')
54 ->where('e.state = 0');
55
56 $db->setQuery($query);
57
58 try
59 {
60 $languages = $db->loadObjectList();
61 }
62 catch (RuntimeException $e)
63 {
64 $languages = array();
65
66 if (JFactory::getUser()->authorise('core.admin'))
67 {
68 JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
69 }
70 }
71
72
73 return array_merge(
74 parent::getOptions(),
75 $languages
76 );
77 }
78 }
79