1 <?php
2 3 4 5 6 7
8
9 defined('FOF_INCLUDED') or die;
10
11 JFormHelper::loadFieldClass('url');
12
13 14 15 16 17 18 19
20 class FOFFormFieldUrl extends JFormFieldUrl 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 $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
79 $dolink = $this->element['show_link'] == 'true';
80 $empty_replacement = '';
81
82 if ($this->element['empty_replacement'])
83 {
84 $empty_replacement = (string) $this->element['empty_replacement'];
85 }
86
87 if (!empty($empty_replacement) && empty($this->value))
88 {
89 $this->value = JText::_($empty_replacement);
90 }
91
92 $innerHtml = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
93
94 if ($dolink)
95 {
96 $innerHtml = '<a href="' . $innerHtml . '">' .
97 $innerHtml . '</a>';
98 }
99
100 return '<span id="' . $this->id . '" ' . $class . '>' .
101 $innerHtml .
102 '</span>';
103 }
104
105 106 107 108 109 110 111 112
113 public function getRepeatable()
114 {
115
116 $class = $this->id;
117 $show_link = false;
118 $empty_replacement = '';
119
120 $link_url = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
121
122
123 if ($this->element['class'])
124 {
125 $class .= ' ' . (string) $this->element['class'];
126 }
127
128 if ($this->element['show_link'] == 'true')
129 {
130 $show_link = true;
131 }
132
133 if ($this->element['empty_replacement'])
134 {
135 $empty_replacement = (string) $this->element['empty_replacement'];
136 }
137
138
139 if (!empty($empty_replacement) && empty($this->value))
140 {
141 $this->value = JText::_($empty_replacement);
142 }
143
144 $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
145
146
147 $html = '<span class="' . $class . '">';
148
149 if ($show_link)
150 {
151 $html .= '<a href="' . $link_url . '">';
152 }
153
154 $html .= $value;
155
156 if ($show_link)
157 {
158 $html .= '</a>';
159 }
160
161 $html .= '</span>';
162
163 return $html;
164 }
165 }
166