1 | <?php |
---|
2 | # ACS |
---|
3 | # (Plugin Spip) |
---|
4 | # http://acs.geomaticien.org |
---|
5 | # |
---|
6 | # Copyright Daniel FAIVRE, 2007-2011 |
---|
7 | # Copyleft: licence GPL - Cf. LICENCES.txt |
---|
8 | |
---|
9 | /** |
---|
10 | * \~french |
---|
11 | * Classe Controle : affiche une interface de saisie pour une variable ACS |
---|
12 | * @param $composant : type de composant |
---|
13 | * @param $nic : numero d'instance de composant |
---|
14 | * @param $nom : nom de variable |
---|
15 | * @param $value : valeur de la variable |
---|
16 | * @param $param : parametres definis par le fichier composant.xml du composant |
---|
17 | * @param $wid : widget id |
---|
18 | * |
---|
19 | * \~english |
---|
20 | * Controle class : display a graphic interface to edit an ACS variable |
---|
21 | */ |
---|
22 | abstract class Controle { |
---|
23 | protected $composant; |
---|
24 | protected $nic; |
---|
25 | protected $nom; |
---|
26 | protected $value; |
---|
27 | protected $param; |
---|
28 | protected $wid; |
---|
29 | protected $var; |
---|
30 | |
---|
31 | public function __construct($composant, $nic, $nom, $value, $param, $wid) { |
---|
32 | $this->composant = $composant; |
---|
33 | $this->nic = $nic; |
---|
34 | $this->nom = $nom; |
---|
35 | $this->value = $value; |
---|
36 | $this->param = $param; |
---|
37 | $this->wid = $wid; |
---|
38 | $this->var = 'acs'.ucfirst($composant).$nic.$nom; |
---|
39 | } |
---|
40 | |
---|
41 | abstract public function draw(); |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * \~french |
---|
46 | * Classe ctlColor : Choix de couleur |
---|
47 | * |
---|
48 | * \~english |
---|
49 | * ctlColor class : Color choice |
---|
50 | */ |
---|
51 | class ctlColor extends Controle { |
---|
52 | public function draw() { |
---|
53 | if (substr($this->value, 0, 4) == "=acs") |
---|
54 | $color = meta_recursive($GLOBALS['meta'], substr($this->value, 1)); |
---|
55 | if (!$color) |
---|
56 | $color = meta_recursive($GLOBALS['meta'], substr($this->value, 1).'/Color'); // Cas des variables de type "Bord", par exemple |
---|
57 | else |
---|
58 | $color = meta_recursive($GLOBALS['meta'], $this->var); |
---|
59 | return '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr><td align="'.$GLOBALS['spip_lang_right'].'"> <label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td><td><input type="text" class="palette" id="'.$this->var.'" name="'.$this->var.'_'.$this->wid.'" size="16" value="'.$this->value.'" style="background: '.$color.'"></td></tr></table></div>'; |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * \~french |
---|
65 | * Classe ctlImg : Choix d'image |
---|
66 | * |
---|
67 | * \~english |
---|
68 | * ctlImg class : image choice |
---|
69 | */ |
---|
70 | class ctlImg extends Controle { |
---|
71 | public function draw() { |
---|
72 | $path = $GLOBALS['ACS_CHEMIN'].'/'.$this->param['chemin']; |
---|
73 | if (!mkdir_recursive(_DIR_RACINE.$path)) |
---|
74 | $err = "*"; |
---|
75 | $s = @getimagesize('../'.$path.'/'.$image); |
---|
76 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
77 | if ($this->param['label'] != 'non') |
---|
78 | $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"> <label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
79 | $r .= '<td><input type="text" id="'.$this->var.'_'.$this->wid.'" name="'.$this->var.'_'.$this->wid.'"'.(is_array($s) ? ' title="'.$s[0].'x'.$s[1].'"' : '').' value="'.$this->value.'" size="40" class="forml" /></td>'; |
---|
80 | $r .= '<td> </td><td><a href="javascript:TFP.popup(document.forms[\'acs\'].elements[\''.$this->var.'_'.$this->wid.'\'], document.forms[\'acs\'].elements[\''.$this->var.'_'.$this->wid.'\'].value, \''.$path.'\', \''._DIR_RACINE.'\');" title="'._T('acs:choix_image').'"><img src="'._DIR_ACS.'images/folder_image.png" class="icon" alt="'._T('acs:choix_image').'" /></a>'.$err.'</td></tr></table></div>'; |
---|
81 | return $r; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * \~french |
---|
87 | * Classe ctlBord : Choix de bordure |
---|
88 | * |
---|
89 | * \~english |
---|
90 | * ctlBord class : Border choice |
---|
91 | */ |
---|
92 | class ctlBord extends Controle { |
---|
93 | public function draw() { |
---|
94 | $b = $GLOBALS['meta'][$this->var]; |
---|
95 | $bord = unserialize($this->value); |
---|
96 | if (is_array($bord)) { |
---|
97 | $largeur = $bord['Width']; |
---|
98 | $style = $bord['Style']; |
---|
99 | $couleur = $bord['Color']; |
---|
100 | } |
---|
101 | elseif (substr($b,0,1) == '=') { |
---|
102 | $largeur = '='; |
---|
103 | $style = '='; |
---|
104 | $couleur = $b; |
---|
105 | } |
---|
106 | $ctlColor = new ctlColor($this->composant, $this->nic, $this->nom.'Color', $couleur, $this->param, $this->wid); |
---|
107 | $this->param['label'] = 'non'; |
---|
108 | $ctlLargeurBord = new ctlLargeurBord($this->composant, $this->nic, $this->nom.'Width', $largeur, $this->param, $this->wid); |
---|
109 | $ctlStyleBord = new ctlStyleBord($this->composant, $this->nic, $this->nom.'Style', $style, $this->param, $this->wid); |
---|
110 | $r = '<table><tr> |
---|
111 | <td>'.$ctlColor->draw().'</td> |
---|
112 | <td>'.$ctlLargeurBord->draw().'</td> |
---|
113 | <td>'.$ctlStyleBord->draw().'</td>'. |
---|
114 | '</tr></table>'; |
---|
115 | return $r; |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * \~french |
---|
121 | * Classe ctlLargeurBord : Choix d'une largeur de bordure |
---|
122 | * |
---|
123 | * \~english |
---|
124 | * ctlLargeurBord class : Border width choice |
---|
125 | */ |
---|
126 | class ctlLargeurBord extends Controle { |
---|
127 | public function draw() { |
---|
128 | $largeur = $this->value; |
---|
129 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
130 | if ($this->param['label'] != 'non') $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label></td>'; |
---|
131 | if (!in_array($largeur, array('', '0', 'thin', '1px', '2px', '3px', '4px', '5px'))) |
---|
132 | $option = '<option value="'.$largeur.'" title="'.$largeur.' ('.$GLOBALS['meta'][substr($largeur, 1)].')" selected>=</option>'; |
---|
133 | $r .= '<td><select name="'.$this->var.'_'.$this->wid.'" title="'._T('acs:bordlargeur').' '.$this->var.'" class="forml" style="width: auto">'. |
---|
134 | '<option value=""'.($largeur=="" ? ' selected' : '').' title="'._T('acs:parent').'"></option>'. |
---|
135 | $option. |
---|
136 | '<option value="0"'.($largeur=="0" ? ' selected' : '').' title="0">0</option>'. |
---|
137 | '<option value="1px"'.($largeur=="1px" ? ' selected' : '').' title="1px">1px</option>'. |
---|
138 | '<option value="2px"'.($largeur=="2px" ? ' selected' : '').' title="2px">2px</option>'. |
---|
139 | '<option value="3px"'.($largeur=="3px" ? ' selected' : '').' title="3px">3px</option>'. |
---|
140 | '<option value="4px"'.($largeur=="4px" ? ' selected' : '').' title="4px">4px</option>'. |
---|
141 | '<option value="5px"'.($largeur=="5px" ? ' selected' : '').' title="5px">5px</option>'. |
---|
142 | '<option value="8px"'.($largeur=="8px" ? ' selected' : '').' title="8px">8px</option>'. |
---|
143 | '<option value="10px"'.($largeur=="10px" ? ' selected' : '').' title="10px">10px</option>'. |
---|
144 | '<option value="15px"'.($largeur=="15px" ? ' selected' : '').' title="15px">15px</option>'. |
---|
145 | '</select></td></tr></table></div>'; |
---|
146 | return $r; |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | /** |
---|
151 | * \~french |
---|
152 | * Classe ctlStyleBord : Choix d'un style de bordure |
---|
153 | * |
---|
154 | * \~english |
---|
155 | * ctlStyleBord class : Border style choice |
---|
156 | */ |
---|
157 | class ctlStyleBord extends Controle { |
---|
158 | public function draw() { |
---|
159 | $style = $this->value; |
---|
160 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
161 | if ($this->param['label'] != 'non') $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label></td>'; |
---|
162 | if (!in_array($style, array('', 'none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset'))) |
---|
163 | $option = '<option value="'.$style.'" title="'.$style.' ('.$GLOBALS['meta'][substr($style, 1)].')" selected>=</option>'; |
---|
164 | $r .= '<td><select name="'.$this->var.'_'.$this->wid.'" title="'._T('acs:bordstyle').' '.$this->var.'" class="forml" style="width: auto">'. |
---|
165 | '<option value=""'.($style=="" ? ' selected' : '').' title="'._T('acs:parent').'"></option>'. |
---|
166 | $option. |
---|
167 | '<option value="none"'.($style=="none" ? ' selected' : '').' title="'._T('acs:none').'">none</option>'. |
---|
168 | '<option value="solid"'.($style=="solid" ? ' selected' : '').' title="'._T('acs:solid').'">solid</option>'. |
---|
169 | '<option value="dashed"'.($style=="dashed" ? ' selected' : '').' title="'._T('acs:dashed').'">dashed</option>'. |
---|
170 | '<option value="dotted"'.($style=="dotted" ? ' selected' : '').' title="'._T('acs:dotted').'">dotted</option>'. |
---|
171 | '<option value="double"'.($style=="double" ? ' selected' : '').' title="'._T('acs:double').'">double</option>'. |
---|
172 | '<option value="groove"'.($style=="groove" ? ' selected' : '').' title="'._T('acs:groove').'">groove</option>'. |
---|
173 | '<option value="ridge"'.($style=="ridge" ? ' selected' : '').' title="'._T('acs:ridge').'">ridge</option>'. |
---|
174 | '<option value="inset"'.($style=="inset" ? ' selected' : '').' title="'._T('acs:inset').'">inset</option>'. |
---|
175 | '<option value="outset"'.($style=="outset" ? ' selected' : '').' title="'._T('acs:outset').'">outset</option>'. |
---|
176 | '</select></td></tr></table></div>'; |
---|
177 | return $r; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | /** |
---|
182 | * \~french |
---|
183 | * Classe ctlFontFamily : Choix d'une famille de fonte |
---|
184 | * |
---|
185 | * \~english |
---|
186 | * ctlFontFamily class : Font family choice |
---|
187 | */ |
---|
188 | class ctlFontFamily extends Controle { |
---|
189 | public function draw() { |
---|
190 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
191 | if ($this->param['label'] != 'non') $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
192 | $r .= '<td><select name="'.$this->var.'_'.$this->wid.'" title="'._T('acs:bordstyle').'" class="forml" style="width: auto">'. |
---|
193 | '<option value="serif"'.($style=="serif" ? ' selected' : '').' title="'._T('acs:serif').'">serif</option>'. |
---|
194 | '<option value="sans-serif"'.($style=="sans-serif" ? ' selected' : '').' title="'._T('acs:sans-serif').'">sans-serif</option>'. |
---|
195 | '<option value="cursive"'.($style=="cursive" ? ' selected' : '').' title="'._T('acs:cursive').'">cursive</option>'. |
---|
196 | '<option value="fantasy"'.($style=="fantasy" ? ' selected' : '').' title="'._T('acs:fantasy').'">fantasy</option>'. |
---|
197 | '<option value="monotype"'.($style=="monotype" ? ' selected' : '').' title="'._T('acs:monotype').'">monotype</option>'. |
---|
198 | '</select></td></tr></table></div>'; |
---|
199 | return $r; |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | /** |
---|
204 | * \~french |
---|
205 | * Classe ctlText : Saisie d'un texte |
---|
206 | * |
---|
207 | * \~english |
---|
208 | * ctlText class : short text |
---|
209 | */ |
---|
210 | class ctlText extends Controle { |
---|
211 | public function draw() { |
---|
212 | $r = '<table width="100%"><tr>'; |
---|
213 | if ($this->param['label'] != 'non') |
---|
214 | $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"> <label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
215 | $r .= '<td><input id="'.$this->var.'" type="text" name="'.$this->var.'_'.$this->wid.'" size="'.$this->param['taille'].'" maxlength="'.$this->param['taille'].'" class="forml" value="'.htmlspecialchars($this->value).'" /></td></tr></table>'; |
---|
216 | return $r; |
---|
217 | } |
---|
218 | } |
---|
219 | |
---|
220 | /** |
---|
221 | * \~french |
---|
222 | * Classe ctlTextarea : Saisie d'un texte long |
---|
223 | * |
---|
224 | * \~english |
---|
225 | * ctlTextarea class : long text |
---|
226 | */ |
---|
227 | class ctlTextarea extends Controle { |
---|
228 | public function draw() { |
---|
229 | return '<div align="'.$GLOBALS['spip_lang_left'].'"><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'">'._TC($this->composant, $this->nom).'</label><textarea name="'.$this->var.'_'.$this->wid.'" class="forml" rows="'.(isset($this->param['lines']) ? $this->param['lines']-1 : 2).'">'.$txt.'</textarea></div>'; |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | /** |
---|
234 | * \~french |
---|
235 | * Classe ctlChoix : Choix |
---|
236 | * |
---|
237 | * \~english |
---|
238 | * ctlChoix class : choice |
---|
239 | */ |
---|
240 | class ctlChoix extends Controle { |
---|
241 | public function draw() { |
---|
242 | if (!is_array($this->param['option'])) |
---|
243 | return 'Pas d\'options pour '.$this->nom; |
---|
244 | $r = '<table><tr valign="middle">'; |
---|
245 | if ($this->param['label'] != 'non') |
---|
246 | $r .= '<td align="'.$GLOBALS['spip_lang_right'].'"><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label></td>'; |
---|
247 | foreach($this->param['option'] as $option) { |
---|
248 | switch($option) { |
---|
249 | case 'oui': |
---|
250 | case 'yes'; |
---|
251 | $label = _T('item_oui'); |
---|
252 | break; |
---|
253 | case 'non': |
---|
254 | case 'no': |
---|
255 | $label = _T('item_non'); |
---|
256 | break; |
---|
257 | default: |
---|
258 | $label = _TC($this->composant, $this->nom.ucfirst($option)); |
---|
259 | // S'il n'existe pas de traduction propre au composant, on cherche une traduction ACS generique pour cette option |
---|
260 | if ($label == strtolower(str_replace('_', ' ', $this->nom.$option))) |
---|
261 | $label = _T('acs:'.strtolower($option)); |
---|
262 | } |
---|
263 | $r .= '<td> '.acs_bouton_radio( |
---|
264 | $this->var.'_'.$this->wid, |
---|
265 | $option, |
---|
266 | $label, |
---|
267 | $this->value == $option |
---|
268 | ).' <td>'; |
---|
269 | } |
---|
270 | $r .= '</tr></table>'; |
---|
271 | return $r; |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | /** |
---|
276 | * \~french |
---|
277 | * Classe ctlUse : Choix utiliser oui/non |
---|
278 | * |
---|
279 | * \~english |
---|
280 | * ctlUse class : choice use or not (oui/non) |
---|
281 | */ |
---|
282 | class ctlUse extends Controle { |
---|
283 | public function draw() { |
---|
284 | $ctl = new ctlChoix($this->composant, $this->nic, $this->nom, (($GLOBALS['meta'][nomvar($this->composant, $this->nic, $this->nom)] == 'oui') ? 'oui' : 'non'), array('option' => array('oui', 'non')), $this->wid); |
---|
285 | return $ctl->draw(); |
---|
286 | } |
---|
287 | } |
---|
288 | |
---|
289 | /** |
---|
290 | * \~french |
---|
291 | * Classe ctlKey : Choix d'un mot-clef |
---|
292 | * |
---|
293 | * \~english |
---|
294 | * ctlKey class : keyword choice |
---|
295 | */ |
---|
296 | class ctlKey extends Controle { |
---|
297 | public function draw() { |
---|
298 | |
---|
299 | // Requis pour fonction typo() |
---|
300 | include_spip('inc/texte'); |
---|
301 | |
---|
302 | $this->value = unserialize($this->value); |
---|
303 | $vid_group = $this->value['Group']; |
---|
304 | $vmot = $this->value['Key']; |
---|
305 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
306 | if ($this->param['label'] != 'non') |
---|
307 | $r .= '<td><label for "'.$this->var.'Key_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
308 | $r .= '<td><select id="select_'.$this->var.'Group_'.$this->wid.'" name="'.$this->var.'Group_'.$this->wid.'" class="forml" onchange="submit()">'; |
---|
309 | $r .= '<option value=""'.($vid_group =='' ? ' selected' : '').'></option>'; |
---|
310 | $groups_query = sql_select("*, ".sql_multi ("titre", "$spip_lang"), "spip_groupes_mots", "", "", "multi"); |
---|
311 | while ($row_groupes = sql_fetch($groups_query)) { |
---|
312 | $id_groupe = $row_groupes['id_groupe']; |
---|
313 | $titre_groupe = typo($row_groupes['titre']); |
---|
314 | $r .= '<option value="'.$id_groupe.'"'.($id_groupe == $vid_group ? ' selected' : '').'>'.$titre_groupe.'</option>'; |
---|
315 | } |
---|
316 | $r .= '</select></td>'; |
---|
317 | $r .= '<td><select id="select_'.$this->var.'Key_'.$this->wid.'" name="'.$this->var.'Key_'.$this->wid.'" class="forml">'; |
---|
318 | if ($vid_group) { |
---|
319 | $keys_query = sql_select("*, ".sql_multi ("titre", "$spip_lang"), "spip_mots", "id_groupe=".$vid_group, "", "multi"); |
---|
320 | while ($row_keys = sql_fetch($keys_query)) { |
---|
321 | $titre_mot = typo($row_keys['titre']); |
---|
322 | $r .= '<option value="'.$titre_mot.'"'.($titre_mot == $vmot ? ' selected' : '').'>'.$titre_mot.'</option>'; |
---|
323 | } |
---|
324 | } |
---|
325 | $r .= '</select></td></tr></table></div>'; |
---|
326 | return $r; |
---|
327 | } |
---|
328 | } |
---|
329 | |
---|
330 | /** |
---|
331 | * \~french |
---|
332 | * Classe ctlKeyGroup : Choix d'un groupe de mots-clefs |
---|
333 | * |
---|
334 | * \~english |
---|
335 | * ctlKeyGroup class : keywords group choice |
---|
336 | */ |
---|
337 | class ctlKeyGroup extends Controle { |
---|
338 | public function draw() { |
---|
339 | |
---|
340 | // Requis pour fonction typo() |
---|
341 | include_spip('inc/texte'); |
---|
342 | |
---|
343 | $vid_group = $this->value; |
---|
344 | $r = '<div align="'.$GLOBALS['spip_lang_right'].'"><table><tr>'; |
---|
345 | if ($this->param['label'] != 'non') |
---|
346 | $r .= '<td><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
347 | $r .= '<td><select id="select_'.$this->var.'_'.$this->wid.'" name="'.$this->var.'_'.$this->wid.'" class="forml" title="'.$this->var.($vid_group ? ' = '.$vid_group : '').'">'; |
---|
348 | $r .= '<option value=""'.($vid_group =='' ? ' selected' : '').'></option>'; |
---|
349 | $groups_query = sql_select("*, ".sql_multi ("titre", "$spip_lang"), "spip_groupes_mots", "", "", "multi"); |
---|
350 | while ($row_groupes = sql_fetch($groups_query)) { |
---|
351 | $id_groupe = $row_groupes['id_groupe']; |
---|
352 | $titre_groupe = typo($row_groupes['titre']); |
---|
353 | $r .= '<option value="'.$id_groupe.'"'.($id_groupe == $vid_group ? ' selected' : '').'>'.$titre_groupe.'</option>'; |
---|
354 | } |
---|
355 | $r .= '</select></td></tr></table></div>'; |
---|
356 | return $r; |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | /** |
---|
361 | * \~french |
---|
362 | * Classe ctlWidget : Choix d'un composant |
---|
363 | * |
---|
364 | * \~english |
---|
365 | * ctlWidget class : choice of a component |
---|
366 | */ |
---|
367 | class ctlWidget extends Controle { |
---|
368 | public function draw() { |
---|
369 | require_once(_DIR_PLUGIN_ACS.'inc/composant/composants_liste.php'); |
---|
370 | |
---|
371 | $r = '<table><tr>'; |
---|
372 | if ($this->param['label'] != 'non') |
---|
373 | $r .= '<td><label for "'.$this->var.'_'.$this->wid.'" title="'.$this->var.'" class="label">'._TC($this->composant, $this->nom).'</label> </td>'; |
---|
374 | $r .= '<td><div id="'.$this->var.'_'.$this->wid.'" class="ctlWidget">'; |
---|
375 | $r .= '<select id="select_'.$this->var.'_'.$this->wid.'" name="'.$this->var.'_'.$this->wid.'" class="forml select_widget">'; |
---|
376 | $r .= '<option value=""'.($this->value=='' ? ' selected' : '').'> </option>'; |
---|
377 | |
---|
378 | foreach (composants_liste() as $class => $c) { |
---|
379 | foreach($c['instances'] as $lnic => $cp) { |
---|
380 | if ($lnic == $this->nic) continue; |
---|
381 | if ($cp['on'] == 'oui') |
---|
382 | $r .= '<option value="'.$class.($lnic ? '-'.$lnic : '').'"'.($this->value==$class.($lnic ? '-'.$lnic : '') ? ' selected' : '').'>'.ucfirst($class).($lnic ? ' '.$lnic : '').'</option>'; |
---|
383 | } |
---|
384 | } |
---|
385 | $r .= '</select></div></td>'; |
---|
386 | $r .= '</tr></table>'; |
---|
387 | return $r; |
---|
388 | } |
---|
389 | } |
---|
390 | |
---|
391 | /** |
---|
392 | * \~french |
---|
393 | * Classe ctlHidden : contrôle caché |
---|
394 | * |
---|
395 | * \~english |
---|
396 | * ctlHidden class : hidden control |
---|
397 | */ |
---|
398 | class ctlHidden extends Controle { |
---|
399 | public function draw() { |
---|
400 | return '<input type="hidden" name="'.$this->var.'_'.$this->wid.'" value="'.$this->value.'" />'; |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | /** |
---|
405 | * \~french |
---|
406 | * Retourne la traduction spécifique au composant, |
---|
407 | * une traduction par défaut, ou le texte |
---|
408 | */ |
---|
409 | function _TC($composant, $texte) { |
---|
410 | // traduction ACS propre au composant |
---|
411 | $t = _T('acs:'.$composant.'_'.$texte); |
---|
412 | if ($t != str_replace('_', ' ', $composant.'_'.$texte)) |
---|
413 | return str_replace(' ', ' ', $t); |
---|
414 | // traduction ACS generique |
---|
415 | $t = _T('acs:'.strtolower($texte)); |
---|
416 | if ($t != str_replace('_', ' ', $texte)) |
---|
417 | return str_replace(' ', ' ', $t); |
---|
418 | // traduction SPIP generique |
---|
419 | $t = _T(strtolower($texte)); |
---|
420 | if ($t != str_replace('_', ' ', $texte)) |
---|
421 | return str_replace(' ', ' ', $t); |
---|
422 | return $texte; |
---|
423 | } |
---|
424 | |
---|
425 | function nomvar($composant, $nic, $nom) { |
---|
426 | return 'acs'.ucfirst($composant).$nic.$nom; |
---|
427 | } |
---|
428 | |
---|
429 | // http://doc.spip.org/@bouton_radio |
---|
430 | function acs_bouton_radio($nom, $valeur, $titre, $actif = false, $onClick="", $enable=true) { |
---|
431 | static $id_label = 0; |
---|
432 | |
---|
433 | if (strlen($onClick) > 0) $onClick = " onclick=\"$onClick\""; |
---|
434 | $texte = "<input type='radio' name='$nom' value='$valeur' id='radio_$id_label'$onClick"; |
---|
435 | if ($actif) { |
---|
436 | $texte .= ' checked="checked"'; |
---|
437 | $titre = '<b>'.$titre.'</b>'; |
---|
438 | } |
---|
439 | $texte .= ($enable ? '' : ' disabled')." /> <label for='radio_$id_label'>$titre</label>"; |
---|
440 | $id_label++; |
---|
441 | return $texte; |
---|
442 | } |
---|
443 | ?> |
---|