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 class JFormFieldAliastag extends JFormFieldList
20 {
21 22 23 24 25 26
27 protected $type = 'Aliastag';
28
29 30 31 32 33 34 35
36 protected function getOptions()
37 {
38
39 $db = JFactory::getDbo();
40 $query = $db->getQuery(true)
41 ->select('Distinct type_alias AS value, type_alias AS text')
42 ->from('#__contentitem_tag_map');
43 $db->setQuery($query);
44
45 $options = $db->loadObjectList();
46
47 $lang = JFactory::getLanguage();
48
49 foreach ($options as $i => $item)
50 {
51 $parts = explode('.', $item->value);
52 $extension = $parts[0];
53 $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true)
54 || $lang->load($extension, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension), null, false, true);
55 $options[$i]->text = JText::_(strtoupper($extension) . '_TAGS_' . strtoupper($parts[1]));
56 }
57
58
59 $options = array_merge(parent::getOptions(), $options);
60
61
62 usort(
63 $options,
64 function($a, $b)
65 {
66 return $a->text > $b->text;
67 }
68 );
69
70 return $options;
71 }
72 }
73