1 <?php
2 3 4 5 6 7
8
9 defined('FOF_INCLUDED') or die;
10
11 JFormHelper::loadFieldClass('email');
12
13 14 15 16 17 18 19
20 class FOFFormFieldEmail extends JFormFieldEMail 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="mailto:' . $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 = '';
117 $show_link = false;
118 $link_url = '';
119 $empty_replacement = '';
120
121
122 if ($this->element['class'])
123 {
124 $class = (string) $this->element['class'];
125 }
126
127 if ($this->element['show_link'] == 'true')
128 {
129 $show_link = true;
130 }
131
132 if ($this->element['url'])
133 {
134 $link_url = $this->element['url'];
135 }
136 else
137 {
138 $link_url = 'mailto:' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
139 }
140
141 if ($this->element['empty_replacement'])
142 {
143 $empty_replacement = (string) $this->element['empty_replacement'];
144 }
145
146
147 if (!empty($empty_replacement) && empty($this->value))
148 {
149 $this->value = JText::_($empty_replacement);
150 }
151
152 $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
153
154
155 $html = '<span class="' . $this->id . ' ' . $class . '">';
156
157 if ($show_link)
158 {
159 $html .= '<a href="' . $link_url . '">';
160 }
161
162 $html .= $value;
163
164 if ($show_link)
165 {
166 $html .= '</a>';
167 }
168
169 $html .= '</span>';
170
171 return $html;
172 }
173 }
174