1 <?php
2 3 4 5 6 7
8
9 defined('FOF_INCLUDED') or die;
10
11 12 13 14 15 16
17 class extends FOFFormHeaderField
18 {
19 20 21 22 23
24 protected function getOptions()
25 {
26 $options = array();
27
28
29 foreach ($this->element->children() as $option)
30 {
31
32 if ($option->getName() != 'option')
33 {
34 continue;
35 }
36
37
38 $options[] = JHtml::_(
39 'select.option',
40 (string) $option['value'],
41 JText::alt(
42 trim((string) $option),
43 preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)
44 ),
45 'value', 'text', ((string) $option['disabled'] == 'true')
46 );
47 }
48
49
50 $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file'];
51 $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class'];
52 $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method'];
53 $source_key = empty($this->element['source_key']) ? '*' : (string) $this->element['source_key'];
54 $source_value = empty($this->element['source_value']) ? '*' : (string) $this->element['source_value'];
55 $source_translate = empty($this->element['source_translate']) ? 'true' : (string) $this->element['source_translate'];
56 $source_translate = in_array(strtolower($source_translate), array('true','yes','1','on')) ? true : false;
57 $source_format = empty($this->element['source_format']) ? '' : (string) $this->element['source_format'];
58
59 if ($source_class && $source_method)
60 {
61
62 if (!empty($source_file))
63 {
64 $source_file = FOFTemplateUtils::parsePath($source_file, true);
65
66 if (FOFPlatform::getInstance()->getIntegrationObject('filesystem')->fileExists($source_file))
67 {
68 include_once $source_file;
69 }
70 }
71
72
73 if (class_exists($source_class, true))
74 {
75
76 if (in_array($source_method, get_class_methods($source_class)))
77 {
78
79 if ($source_format == 'optionsobject')
80 {
81 $options = array_merge($options, $source_class::$source_method());
82 }
83 else
84 {
85 $source_data = $source_class::$source_method();
86
87
88 foreach ($source_data as $k => $v)
89 {
90 $key = (empty($source_key) || ($source_key == '*')) ? $k : $v[$source_key];
91 $value = (empty($source_value) || ($source_value == '*')) ? $v : $v[$source_value];
92
93 if ($source_translate)
94 {
95 $value = JText::_($value);
96 }
97
98 $options[] = JHtml::_('select.option', $key, $value, 'value', 'text');
99 }
100 }
101 }
102 }
103 }
104
105 reset($options);
106
107 return $options;
108 }
109 }
110