1 <?php
2 3 4 5 6 7
8
9 defined('FOF_INCLUDED') or die;
10
11 JFormHelper::loadFieldClass('imagelist');
12
13 14 15 16 17 18 19
20 class FOFFormFieldImagelist extends JFormFieldImageList implements FOFFormField
21 {
22 protected $static;
23
24 protected $repeatable;
25
26
27 public $item;
28
29
30 public $rowid;
31
32 33 34 35 36 37 38 39 40
41 public function __get($name)
42 {
43 switch ($name)
44 {
45 case 'static':
46 if (empty($this->static))
47 {
48 $this->static = $this->getStatic();
49 }
50
51 return $this->static;
52 break;
53
54 case 'repeatable':
55 if (empty($this->repeatable))
56 {
57 $this->repeatable = $this->getRepeatable();
58 }
59
60 return $this->repeatable;
61 break;
62
63 default:
64 return parent::__get($name);
65 }
66 }
67
68 69 70 71 72 73 74 75
76 public function getStatic()
77 {
78 $imgattr = array(
79 'id' => $this->id
80 );
81
82 if ($this->element['class'])
83 {
84 $imgattr['class'] = (string) $this->element['class'];
85 }
86
87 if ($this->element['style'])
88 {
89 $imgattr['style'] = (string) $this->element['style'];
90 }
91
92 if ($this->element['width'])
93 {
94 $imgattr['width'] = (string) $this->element['width'];
95 }
96
97 if ($this->element['height'])
98 {
99 $imgattr['height'] = (string) $this->element['height'];
100 }
101
102 if ($this->element['align'])
103 {
104 $imgattr['align'] = (string) $this->element['align'];
105 }
106
107 if ($this->element['rel'])
108 {
109 $imgattr['rel'] = (string) $this->element['rel'];
110 }
111
112 if ($this->element['alt'])
113 {
114 $alt = JText::_((string) $this->element['alt']);
115 }
116 else
117 {
118 $alt = null;
119 }
120
121 if ($this->element['title'])
122 {
123 $imgattr['title'] = JText::_((string) $this->element['title']);
124 }
125
126 $path = (string) $this->element['directory'];
127 $path = trim($path, '/' . DIRECTORY_SEPARATOR);
128
129 if ($this->value && file_exists(JPATH_ROOT . '/' . $path . '/' . $this->value))
130 {
131 $src = FOFPlatform::getInstance()->URIroot() . '/' . $path . '/' . $this->value;
132 }
133 else
134 {
135 $src = '';
136 }
137
138 return JHtml::_('image', $src, $alt, $imgattr);
139 }
140
141 142 143 144 145 146 147 148
149 public function getRepeatable()
150 {
151 return $this->getStatic();
152 }
153 }
154