Mise en route du suivi.
[aidenligne_francais_universite.git] / plugins / forms_1_9_1 / exec / forms_edit.php
1 <?php
2 /*
3 * forms
4 * version plug-in de spip_form
5 *
6 * Auteur :
7 * Antoine Pitrou
8 * adaptation en 182e puis plugin par cedric.morin@yterium.com
9 * © 2005,2006 - Distribue sous licence GNU/GPL
10 *
11 */
12
13 include_spip('inc/forms');
14
15 function bloc_edition_champ($t, $link) {
16 global $couleur_claire;
17
18 $code = $t['code'];
19 $obligatoire = $t['obligatoire'];
20 $type = $t['type'];
21 $type_ext = $t['type_ext'];
22
23 if ($type != 'separateur'){
24 $checked = ($obligatoire == 'oui') ? " checked='checked'" : "";
25 echo "&nbsp; &nbsp; <input type='checkbox' name='champ_obligatoire' value='oui' id='obli_$code'$checked> ";
26 echo "<label for='obli_$code'>"._T("forms:edit_champ_obligatoire")."</label>";
27 echo "<br />\n";
28 }
29
30 if ($type == 'url') {
31 $checked = ($t['verif'] == 'oui') ? " checked='checked'" : "";
32 echo "&nbsp; &nbsp; <input type='checkbox' name='champ_verif' value='oui' id='verif_$code'$checked> ";
33 echo "<label for='verif_$code'>"._T("forms:verif_web")."</label>";
34 echo "<br />\n";
35 }
36 if ($type == 'select' || $type == 'multiple') {
37 global $ajout_choix;
38
39 echo "<div style='margin: 5px; padding: 5px; border: 1px dashed $couleur_claire;'>";
40 echo _T("forms:liste_choix")."&nbsp;:<br />\n";
41 foreach ($type_ext as $code_choix => $nom_choix) {
42 if ($ajout_choix == $code_choix) {
43 echo "<script type='text/javascript'><!-- \nvar antifocus_choix= false; // --></script>\n";
44 $js = " onfocus=\"if(!antifocus_choix){this.value='';antifocus_choix=true;}\"";
45 }
46 else $js = "";
47 echo "<input type='text' id='nom_$code_choix' name='$code_choix' value=\"".entites_html($nom_choix)."\" ".
48 "class='fondl verdana2' size='20'$js>";
49 //
50 echo " <input style='display: none;' type='submit' name='modif_choix' value=\""._T('bouton_modifier')."\" class='fondo verdana2'>";
51 $supp_link = $link;
52 $supp_link = parametre_url($supp_link,'supp_choix', $code_choix);
53 echo " &nbsp; <span class='verdana1'>[<a href='".$supp_link."#champ_visible'>".
54 _T("forms:supprimer_choix")."</a>]</span>";
55 echo "<br />\n";
56 }
57 echo "<br /><input type='submit' name='ajout_choix' value=\""._T("forms:ajouter_choix")."\" class='fondo verdana2'>";
58
59 echo "</div>";
60 if ($type=='select')
61 echo "<br /><input type='submit' name='switch_select_multi' value=\""._T("forms:changer_choix_multiple")."\" class='fondl verdana2'>";
62 if ($type=='multiple')
63 echo "<br /><input type='submit' name='switch_select_multi' value=\""._T("forms:changer_choix_unique")."\" class='fondl verdana2'>";
64 echo "<br />\n";
65 }
66 if ($type == 'mot') {
67 echo "<label for='groupe_$code'>"._T("forms:champ_nom_groupe")."</label> :";
68 echo " &nbsp;<select name='groupe_champ' value='0' id='groupe_$code' class='fondo verdana2'>\n";
69 $query = "SELECT * FROM spip_groupes_mots ORDER BY titre";
70 $result = spip_query($query);
71 while ($row = spip_fetch_array($result)) {
72 $id_groupe = $row['id_groupe'];
73 $titre_groupe = supprimer_tags(typo($row['titre']));
74 $selected = ($id_groupe == $type_ext['id_groupe']) ? " selected='selected'": "";
75 echo "<option value='$id_groupe'$selected>$titre_groupe</option>\n";
76 }
77 echo "</select>";
78 echo "<br />\n";
79 }
80 if ($type == 'fichier') {
81 $taille = intval($type_ext['taille']);
82 if (!$taille) $taille = '';
83 echo "<label for='taille_$code'>"._T("forms:taille_max")."</label> : ";
84 echo "<input type='text' name='taille_champ' value='$taille' id='taille_$code' class='fondo verdana2'>\n";
85 echo "<br />\n";
86 }
87 }
88
89 function modif_edition_champ($t) {
90 $type = $t['type'];
91 $type_ext = &$t['type_ext'];
92 $code = $t['code'];
93
94 if ($type == 'url') {
95 global $champ_verif;
96 if ($champ_verif) $t['verif'] = $champ_verif;
97 else unset($t['verif']);
98 }
99 if ($type == 'select' || $type == 'multiple') {
100 global $ajout_choix, $supp_choix;
101 if ($ajout_choix) {
102 $n = 1;
103 $code_choix = $code.'_'.$n;
104 while (isset($type_ext[$code_choix]))
105 $code_choix = $code.'_'.(++$n);
106 $type_ext[$code_choix] = _T("forms:nouveau_choix");
107 include_spip('inc/charset');
108 $type_ext[$code_choix] = unicode2charset(html2unicode($type_ext[$code_choix]));
109 $ajout_choix = $code_choix;
110 }
111 foreach ($type_ext as $code_choix => $nom_choix) {
112 if (isset($GLOBALS[$code_choix]))
113 $type_ext[$code_choix] = $GLOBALS[$code_choix];
114 }
115 /*if ($supp_choix) {
116 unset($type_ext[$supp_choix]);
117 }*/
118 }
119 if ($type == 'mot') {
120 if ($id_groupe = intval($GLOBALS['groupe_champ']))
121 $type_ext['id_groupe'] = $id_groupe;
122 }
123 if ($type == 'fichier') {
124 $type_ext['taille'] = intval($GLOBALS['taille_champ']);
125 }
126
127 return $t;
128 }
129
130 function code_nouveau_champ($structure,$type){
131 $n = 1;
132 $code = $type.'_'.strval($n);
133 foreach ($structure as $t) {
134 list($letype, $lenumero) = split('_', $t['code'] );
135 if ($type == $letype)
136 {
137 $lenumero = intval($lenumero);
138 if ($lenumero>= $n)
139 $n=$lenumero+1;
140 $code = $type.'_'.strval($n);
141 }
142 }
143 return $code;
144 }
145
146 function forms_update(){
147 $id_form = intval(_request('id_form'));
148 $new = _request('new');
149 $supp_form = intval(_request('supp_form'));
150 $modif_champ = _request('modif_champ');
151 $ajout_champ = _request('ajout_champ');
152 $retour = _request('retour');
153 $titre = _request('titre');
154 $descriptif = _request('descriptif');
155 $email = _request('email');
156 $champconfirm = _request('champconfirm');
157 $texte = _request('texte');
158 $sondage = _request('sondage');
159 $nom_champ = _request('nom_champ');
160 $champ_obligatoire = _request('champ_obligatoire');
161 $monter = _request('monter');
162 $descendre = _request('descendre');
163 $supp_choix = _request('supp_choix');
164 $supp_champ = _request('supp_champ');
165 $supp_confirme = _request('supp_confirme');
166 $supp_rejet = _request('supp_rejet');
167
168 //
169 // Modifications des donnees de base du formulaire
170 //
171
172 $nouveau_champ = $champ_visible = NULL;
173
174 $structure = array();
175 if (Forms_form_editable($id_form)) {
176 // creation
177 if ($new == 'oui' && $titre) {
178 $structure = array();
179 spip_query("INSERT INTO spip_forms (structure) VALUES ('".
180 addslashes(serialize($structure))."')");
181 $id_form = spip_insert_id();
182 unset($new);
183 }
184 // maj
185 if ($id_form && $titre) {
186 $query = "UPDATE spip_forms SET ".
187 "titre='".addslashes($titre)."', ".
188 "descriptif='".addslashes($descriptif)."', ".
189 "sondage='".addslashes($sondage)."', ".
190 "email='".addslashes(serialize($email))."', ".
191 "champconfirm='".addslashes($champconfirm)."', ".
192 "texte='".addslashes($texte)."' ".
193 "WHERE id_form=$id_form";
194 $result = spip_query($query);
195 }
196 // lecture
197 $query = "SELECT * FROM spip_forms WHERE id_form=$id_form";
198 $result = spip_query($query);
199 if ($row = spip_fetch_array($result)) {
200 $id_form = $row['id_form'];
201 $titre = $row['titre'];
202 $descriptif = $row['descriptif'];
203 $sondage = $row['sondage'];
204 $structure = unserialize($row['structure']);
205 $email = unserialize($row['email']);
206 $champconfirm = $row['champconfirm'];
207 $texte = $row['texte'];
208 }
209 }
210
211 if ($id_form && Forms_form_editable($id_form)) {
212 $modif_structure = false;
213 $champ_visible = NULL;
214 // Ajout d'un champ
215 if (($type = $ajout_champ) && Forms_types_champs_autorises($type)) {
216 $code = code_nouveau_champ($structure,$type);
217 $nom = _T("forms:nouveau_champ");
218 include_spip('inc/charset');
219 $nom = unicode2charset(html2unicode($nom));
220 $structure[] = array('code' => $code, 'nom' => $nom, 'type' => $type, 'type_ext' => array());
221 $champ_visible = $nouveau_champ = $code;
222 $modif_structure = true;
223 }
224 // Modif d'un champ
225 if ($code = $modif_champ) {
226 unset($index);
227 foreach ($structure as $index => $t) {
228 if ($code == $t['code']) break;
229 }
230 if (isset($index)) {
231 // switch select to multi ou inversement
232 if (isset($_POST['switch_select_multi'])){
233 if ($t['type']=='select') $newtype = 'multiple';
234 if ($t['type']=='multiple') $newtype = 'select';
235
236 $newcode = code_nouveau_champ($structure,$newtype);
237 $t['type'] = $newtype;
238 $new_type_ext = array();
239 foreach($t['type_ext'] as $key=>$type_ext)
240 $new_type_ext[str_replace($t['code'],$newcode,$key)] = $type_ext;
241 $t['code'] = $newcode;
242 $t['type_ext'] = $new_type_ext;
243 }
244 $t['nom'] = $nom_champ;
245 $t['obligatoire'] = $champ_obligatoire;
246 $t = modif_edition_champ($t);
247 if (!$t['type_ext']) $t['type_ext'] = array();
248 $structure[$index] = $t;
249 $modif_structure = true;
250 }
251 $champ_visible = $code;
252 }
253 // Cas particulier : suppression d'un choix
254 if ($code_choix = $supp_choix) {
255 foreach ($structure as $index => $t) {
256 if (is_array($t['type_ext']) && isset($t['type_ext'][$supp_choix])) {
257 unset($t['type_ext'][$supp_choix]);
258 if (!$t['type_ext']) $t['type_ext'] = array();
259 $champ_visible = $t['code'];
260 $structure[$index] = $t;
261 }
262 }
263 $modif_structure = true;
264 }
265 // Suppression d'un champ
266 if ($code = $supp_champ) {
267 unset($index);
268 foreach ($structure as $index => $t) {
269 if ($code == $t['code']) break;
270 }
271 if (isset($index)&&($structure[$index]['code']==$code)){
272 unset($structure[$index]);
273 if (!$structure) $structure = array();
274 $modif_structure = true;
275 }
276 }
277
278 // Monter / descendre un champ
279 if (isset($monter) && $monter > 0) {
280
281 $monter = intval($monter);
282 $n = $monter;
283 while (--$n) if ($structure[$n]) break;
284 if ($t = $structure[$n]) {
285 $structure[$n] = $structure[$monter];
286 $structure[$monter] = $t;
287 $champ_visible = $structure[$n]['code'];
288 }
289 $modif_structure = true;
290 }
291 if (isset($descendre)) {
292 $descendre = intval($descendre);
293 $max = max(array_keys($structure));
294 $n = $descendre;
295 while (++$n < $max) if ($structure[$n]) break;
296 if ($t = $structure[$n]) {
297 $structure[$n] = $structure[$descendre];
298 $structure[$descendre] = $t;
299 $champ_visible = $structure[$n]['code'];
300 }
301 $modif_structure = true;
302 }
303 if ($id_form && Forms_form_editable($id_form)) {
304 if ($modif_structure) {
305 ksort($structure);
306 $query = "UPDATE spip_forms SET `structure`='".addslashes(serialize($structure))."' ".
307 "WHERE id_form=$id_form";
308 spip_query($query);
309 }
310 }
311 }
312
313 // mettre a jour les tables de replication pour les boucles
314 include_spip("base/forms_temporaire");
315 if ($row=spip_fetch_array(spip_query("SELECT * FROM spip_forms WHERE id_form=".spip_abstract_quote($id_form))))
316 forms_structure2table($row,true);
317 return array($id_form,$champ_visible,$nouveau_champ);
318 }
319
320 function debut_block_route($id,$visible){
321 $display = $visible?'block':'none';
322 return "<script type='text/javascript'><!--
323 document.write('<div id=\"$id\" style=\"display: $display; margin-top: 1;\">');
324 //--></script>
325 <noscript>
326 <div id='bock_email_route_$code' style='display: block;'>
327 </noscript>";
328 }
329 function fin_block_route(){
330 return "<script type='text/javascript'><!--
331 document.write('<\/div>');
332 //--></script>
333 <noscript>
334 </div>
335 </noscript>";
336 }
337
338 function exec_forms_edit(){
339 global $spip_lang_right;
340 $id_form = intval(_request('id_form'));
341 $new = _request('new');
342 $supp_form = intval(_request('supp_form'));
343 $modif_champ = _request('modif_champ');
344 $ajout_champ = _request('ajout_champ');
345 $retour = _request('retour');
346 $titre = _request('titre');
347 $descriptif = _request('descriptif');
348 $email = _request('email');
349 $champconfirm = _request('champconfirm');
350 $texte = _request('texte');
351 $sondage = _request('sondage');
352 $nom_champ = _request('nom_champ');
353 $champ_obligatoire = _request('champ_obligatoire');
354 $monter = _request('monter');
355 $descendre = _request('descendre');
356 $supp_choix = _request('supp_choix');
357 $supp_champ = _request('supp_champ');
358 $supp_confirme = _request('supp_confirme');
359 $supp_rejet = _request('supp_rejet');
360
361
362 Forms_verifier_base();
363
364 if ($retour)
365 $retour = urldecode($retour);
366 include_spip("inc/presentation");
367 include_spip("inc/config");
368
369 if ($id_form) {
370 $query = "SELECT COUNT(*) FROM spip_reponses WHERE id_form=$id_form AND statut='valide'";
371 $result = spip_query($query);
372 list($nb_reponses) = spip_fetch_array($result,SPIP_NUM);
373 }
374 else $nb_reponses = 0;
375
376 $clean_link = parametre_url(self(),'new','');
377 $form_link = generer_url_ecrire('forms_edit');
378 if ($new == 'oui' && !$titre)
379 $form_link = parametre_url($form_link,"new",$new);
380 if ($retour)
381 $form_link = parametre_url($form_link,"retour",urlencode($retour));
382
383 if (Forms_form_administrable($id_form)) {
384 if ($supp_form = intval($supp_form) AND $supp_confirme AND !$supp_rejet) {
385 $result = spip_query("DELETE FROM spip_forms WHERE id_form=$supp_form");
386 $result = spip_query("DELETE FROM spip_forms_champs WHERE id_form=$supp_form");
387 $result = spip_query("DELETE FROM spip_forms_champs_choix WHERE id_form=$supp_form");
388 if ($retour) {
389 $retour = urldecode($retour);
390 Header("Location: $retour");
391 exit;
392 }
393 }
394 }
395
396 //
397 // Affichage de la page
398 //
399
400 debut_page("&laquo; $titre &raquo;", "documents", "forms","");
401
402 unset($champ_visible);
403 unset($nouveau_champ);
404 //
405 // Recupere les donnees
406 //
407 if ($new == 'oui' && !$titre) {
408 $titre = _T("forms:nouveau_formulaire");
409 include_spip('inc/charset');
410 $titre = unicode2charset(html2unicode($titre));
411 $descriptif = "";
412 $sondage = "non";
413 $structure = array();
414 $email = array();
415 $champconfirm = "";
416 $texte = "";
417 $js_titre = " onfocus=\"if(!antifocus){this.value='';antifocus=true;}\"";
418 }
419 else {
420 //
421 // Modifications au structure du formulaire
422 //
423 list($id_form,$champ_visible,$nouveau_champ) = forms_update();
424
425 $query = "SELECT * FROM spip_forms WHERE id_form=$id_form";
426 $result = spip_query($query);
427 if ($row = spip_fetch_array($result)) {
428 $id_form = $row['id_form'];
429 $titre = $row['titre'];
430 $descriptif = $row['descriptif'];
431 $sondage = $row['sondage'];
432 $structure = unserialize($row['structure']);
433 $email = unserialize($row['email']);
434 $champconfirm = $row['champconfirm'];
435 $texte = $row['texte'];
436 }
437 $js_titre = "";
438 }
439 $form_link = parametre_url($form_link,"id_form",$id_form);
440 $clean_link = parametre_url($clean_link,"id_form",$id_form);
441
442
443 debut_gauche();
444
445
446 echo "<br /><br />\n";
447
448 if (Forms_form_administrable($id_form) && $nb_reponses) {
449 debut_boite_info();
450
451 $nretour = urlencode(self());
452 icone_horizontale(_T("forms:suivi_reponses")."<br />".$nb_reponses." "._T("forms:reponses"),
453 generer_url_ecrire('forms_reponses',"id_form=$id_form"), "forum-public-24.gif", "rien.gif");
454 icone_horizontale(_T("forms:telecharger_reponses"),
455 generer_url_ecrire('forms_telecharger',"id_form=$id_form&retour=$nretour"), "doc-24.gif", "rien.gif");
456
457 fin_boite_info();
458 }
459
460
461
462 debut_droite();
463
464 if ($supp_form && $supp_confirme==NULL && $supp_rejet==NULL) {
465 if ($nb_reponses){
466 echo "<p><strong>"._T("forms:attention")."</strong> ";
467 echo _T("forms:info_supprimer_formulaire_reponses")."</p>\n";
468 }
469 else{
470 echo "<p>";
471 echo _T("forms:info_supprimer_formulaire")."</p>\n";
472 }
473 $link = parametre_url($clean_link,'supp_form', $supp_form);
474 echo "<form method='POST' action='"
475 . $link
476 . "' style='border: 0px; margin: 0px;'>";
477 echo "<div style='text-align:$spip_lang_right'>";
478 echo "<input type='submit' name='supp_confirme' value=\""._T('item_oui')."\" class='fondo'>";
479 echo " &nbsp; ";
480 echo "<input type='submit' name='supp_rejet' value=\""._T('item_non')."\" class='fondo'>";
481 echo "</div>";
482 echo "</form><br />\n";
483 }
484
485
486 if ($id_form) {
487 debut_cadre_relief("../"._DIR_PLUGIN_FORMS."/img_pack/form-24.png");
488
489 gros_titre($titre);
490
491 if ($descriptif) {
492 echo "<p /><div align='left' border: 1px dashed #aaaaaa;'>";
493 echo "<strong class='verdana2'>"._T('info_descriptif')."</strong> ";
494 echo propre($descriptif);
495 echo "</div>\n";
496 }
497
498 if ($email) {
499 echo "<p /><div align='left' border: 1px dashed #aaaaaa;'>";
500 echo "<strong class='verdana2'>"._T('email_2')."</strong> ";
501 echo $email['defaut'];
502 echo "</div>\n";
503 }
504 if ($champconfirm){
505 $champconfirm_known = false;
506 echo "<div align='left' border: 1px dashed #aaaaaa;'>";
507 echo "<strong class='verdana2'>"._T('forms:confirmer_reponse')."</strong> ";
508 foreach ($structure as $index => $t) {
509 if (($t['type'] == 'email') && ($champconfirm == $t['code'])) {
510 echo $t['nom'] . " ";
511 $champconfirm_known = true;
512 }
513 }
514 echo "</div>\n";
515 if (($champconfirm_known == true) && ($texte)) {
516 echo "<div align='left' border: 1px dashed #aaaaaa;'>";
517 echo "<strong class='verdana2'>"._T('info_texte')."</strong> ";
518 echo nl2br(entites_html($texte));
519 echo "</div>\n";
520 }
521 }
522
523 if (count($structure)) {
524 echo "<br />";
525
526 echo "<div style='padding: 2px; background-color: $couleur_claire; color: black;'>&nbsp;";
527 echo bouton_block_invisible("preview_form");
528 echo "<strong class='verdana3' style='text-transform: uppercase;'>"
529 ._T("forms:apparence_formulaire")."</strong>";
530 echo "</div>\n";
531
532 echo debut_block_invisible("preview_form");
533 echo _T("forms:info_apparence")."<p>\n";
534 //echo "<div class='spip_forms'>";
535 echo propre("<form$id_form>");
536 //echo "</div>\n";
537 echo fin_block();
538
539 }
540
541 afficher_articles(_T("forms:articles_utilisant"),
542 array('FROM' => 'spip_articles AS articles, spip_forms_articles AS lien',
543 'WHERE' => "lien.id_article=articles.id_article AND id_form=$id_form AND statut!='poubelle'",
544 'ORDER BY' => "titre"));
545
546 fin_cadre_relief();
547 }
548
549
550 //
551 // Icones retour et suppression
552 //
553 echo "<div style='text-align:$spip_lang_right'>";
554 if ($retour) {
555 icone(_T('icone_retour'), $retour, "../"._DIR_PLUGIN_FORMS."/img_pack/form-24.png", "rien.gif",'right');
556 }
557 if ($id_form && Forms_form_administrable($id_form)) {
558 echo "<div style='float:$spip_lang_left'>";
559 $link = parametre_url($clean_link,'supp_form', $id_form);
560 if (!$retour) {
561 $link=parametre_url($link,'retour', urlencode(generer_url_ecrire('form_tous')));
562 }
563 icone(_T("forms:supprimer_formulaire"), $link, "../"._DIR_PLUGIN_FORMS."/img_pack/form-24.png", "supprimer.gif");
564 echo "</div>";
565 }
566 echo "<div style='clear:both;'></div>";
567 echo "</div>";
568
569
570 //
571 // Edition des donnees du formulaire
572 //
573 if (Forms_form_editable($id_form)) {
574 echo "<p>";
575 debut_cadre_formulaire();
576
577 echo "<div class='verdana2'>";
578 echo "<form method='POST' action='"
579 . $form_link
580 . "' style='border: 0px; margin: 0px;'>";
581
582 $titre = entites_html($titre);
583 $descriptif = entites_html($descriptif);
584 $texte = entites_html($texte);
585
586 echo "<strong><label for='titre_form'>"._T("forms:titre_formulaire")."</label></strong> "._T('info_obligatoire_02');
587 echo "<br />";
588 echo "<input type='text' name='titre' id='titre_form' CLASS='formo' ".
589 "value=\"".entites_html($titre)."\" size='40'$js_titre><br />\n";
590
591 echo "<strong><label for='desc_form'>"._T('info_descriptif')."</label></strong>";
592 echo "<br />";
593 echo "<textarea name='descriptif' id='desc_form' class='forml' rows='4' cols='40' wrap='soft'>";
594 echo entites_html($descriptif);
595 echo "</textarea><br />\n";
596
597
598
599 // Routage facultatif des emails en fonction d'un champ select
600 $email_route_known = false;
601 $jshide = "";
602 $s = "";
603 $options = "";
604 if (is_array($structure)){
605 foreach ($structure as $index => $t) {
606 if ($t['type'] == 'select'){
607 $visible = false;
608 $code = $t['code'];
609 $options .= "<option value='$code'";
610 if ($email['route'] == $code){
611 $options .= " selected='selected'";
612 $email_route_known = $visible = true;
613 }
614 $options .= ">" . $t['nom'] . "</option>\n";
615 $s .= debut_block_route("bock_email_route_$code",$visible);
616 $jshide .= "cacher_email_route('bock_email_route_$code');\n";
617
618 $s .= "<table id ='email_route_$code'>\n";
619 $s .= "<tr><th>".$t['nom']."</th><th>";
620 $s .= "<strong><label for='email_route_$code'>"._T('email_2')."</label></strong>";
621 $s .= "</th></tr>\n";
622 $js = "";
623 $type_ext = $t['type_ext'];
624 foreach ($type_ext as $code_choix => $nom_choix) {
625 $s .= "<tr><td>$nom_choix</td><td>";
626 $s .= "<input type='text' name='email[$code_choix]' value=\"";
627 $s .= isset($email[$code_choix])?entites_html($email[$code_choix]):"";
628 $s .= "\" class='fondl verdana2' size='20'$js>";
629 $s .= "</td></tr>";
630 }
631 $s .="</table>";
632 $s .= fin_block_route("bock_email_route_$code",$visible);
633 }
634 }
635 $jshide = "<script type='text/javascript'><!--
636 function montrer_email_route(obj) {
637 layer = findObj(obj);
638 if (layer)
639 layer.style.display = 'block';
640 }
641 function cacher_email_route(obj) {
642 layer = findObj(obj);
643 if (layer)
644 layer.style.display = 'none';
645 }
646 function update_email_route_visibility(obj){
647 $jshide
648 cacher_email_route('bock_email_route_');
649 montrer_email_route(obj);
650 }
651 //--></script>\n";
652 echo $jshide;
653
654 echo "<strong><label for='email_route_form'>"._T('forms:choisir_email')."</label></strong> ";
655 echo "<br />";
656 echo "<select name='email[route]' id='email_route_form' class='forml'";
657 echo "onchange='update_email_route_visibility(\"bock_email_route_\"+options[selectedIndex].value)' ";
658 echo ">\n";
659 echo "<option value=''>"._T('forms:email_independant')."</option>\n";
660 echo $options;
661 echo "</select><br />\n";
662 }
663
664 echo debut_block_route("bock_email_route_",$email_route_known==false);
665 echo "<strong><label for='email_form'>"._T('email_2')."</label></strong> ";
666 echo "<br />";
667 echo "<input type='text' name=\"email[defaut]\" id='email_form' class='forml' ".
668 "value=\"".entites_html($email['defaut'])."\" size='40'$js_titre>\n";
669 echo fin_block_route();
670 echo $s;
671 echo "<br/>";
672
673 //-----
674
675 echo "<strong><label for='confirm_form'>"._T('forms:confirmer_reponse')."</label></strong> ";
676 echo "<br />";
677 echo "<select name='champconfirm' id='confirm_form' class='forml'>\n";
678 echo "<option value=''";
679 if ($champconfirm=='') echo " selected='selected'";
680 echo ">"._T('forms:pas_mail_confirmation')."</option>\n";
681 $champconfirm_known = false;
682 foreach ($structure as $index => $t) {
683 if ($t['type'] == 'email'){
684 echo "<option value='" . $t['code'] . "'";
685 if ($champconfirm == $t['code']){
686 echo " selected='selected'";
687 $champconfirm_known = true;
688 }
689 echo ">" . $t['nom'] . "</option>\n";
690 }
691 }
692 echo "</select><br />\n";
693 if ($champconfirm_known == true){
694 echo "<strong><label for='texte_form'>"._T('info_texte')."</label></strong>";
695 echo "<br />";
696 echo "<textarea name='texte' id='texte_form' class='formo' rows='4' cols='40' wrap='soft'>";
697 echo entites_html($texte);
698 echo "</textarea><br />\n";
699 }
700 else {
701 echo "<input type='hidden' name='texte' value=\"" . entites_html($texte);
702 echo "\" />\n";
703 }
704
705
706 debut_cadre_enfonce("statistiques-24.gif");
707 echo "<strong>"._T("forms:sondage")."</strong> : ";
708 echo _T("forms:info_sondage");
709 echo "<br /><br />";
710 afficher_choix('sondage', $sondage, array(
711 'non' => _T("forms:sondage_non"),
712 'public' => _T("forms:sondage_pub"),
713 'prot' => _T("forms:sondage_prot")
714 ));
715 fin_cadre_enfonce();
716
717 echo "<div align='right'>";
718 echo "<input type='submit' name='Valider' value='"._T('bouton_valider')."' class='fondo'></div>\n";
719
720 echo "</form>";
721
722 //
723 // Creer / modifier des champs
724 //
725 if ($id_form) {
726 echo "<a name='champs'></a>";
727 echo "<p><hr><p>\n";
728 echo "<div class='verdana3'>";
729 echo "<strong>"._T("forms:champs_formuaire")."</strong><br />\n";
730 echo _T("forms:info_champs_formulaire");
731 echo "</div>\n";
732 echo "<div id='forms_lang'></div>";
733
734 if (count($structure)) {
735 $keys = array_keys($structure);
736 $index_min = min($keys);
737 $index_max = max($keys);
738 }
739
740 foreach ($structure as $index => $t) {
741 $code = $t['code'];
742 $visible = ($code == $champ_visible);
743 $nouveau = ($code == $nouveau_champ);
744 $obligatoire = $t['obligatoire'];
745 $aff_min = $index > $index_min;
746 $aff_max = $index < $index_max;
747 $type = $t['type'];
748
749 if ($nouveau) echo "<a name='nouveau_champ'></a>";
750 else if ($visible) echo "<a name='champ_visible'></a>";
751 echo "<p>\n";
752 if (!in_array($type,array('separateur','textestatique')))
753 debut_cadre_relief();
754 else
755 debut_cadre_enfonce();
756
757 echo "<div style='padding: 2px; background-color: $couleur_claire; color: black;'>&nbsp;";
758 if ($aff_min || $aff_max) {
759 echo "<div class='verdana1' style='float: right; font-weight: bold;'>";
760 if ($aff_min) {
761 $link = parametre_url($form_link,'monter', $index);
762 echo "<a href='".$link."#champs'><img src='"._DIR_IMG_PACK."monter-16.png' style='border:0' alt='"._T("forms:champ_monter")."'></a>";
763 }
764 if ($aff_min && $aff_max) {
765 echo " | ";
766 }
767 if ($aff_max) {
768 $link = parametre_url($form_link,'descendre', $index);
769 echo "<a href='".$link."#champs'><img src='"._DIR_IMG_PACK."descendre-16.png' style='border:0' alt='"._T("forms:champ_descendre")."'></a>";
770 }
771 echo "</div>\n";
772 }
773
774 echo $visible ? bouton_block_visible("champ_$code") : bouton_block_invisible("champ_$code");
775 echo "<strong id='titre_nom_$code'>".typo($t['nom'])."</strong>";
776 echo "<br /></div>";
777 echo "(".Forms_nom_type_champ($t['type']).")\n";
778 echo $visible ? debut_block_visible("champ_$code") : debut_block_invisible("champ_$code");
779
780 // Modifier un champ
781 echo "<div id='forms_lang_nom_$code'></div>";
782 echo "<form class='forms_champ' method='POST' action='"
783 . $form_link . "#champ_visible"
784 . "' style='border: 0px; margin: 0px;'>";
785 echo "<input type='hidden' name='modif_champ' value='$code' />";
786
787 echo "<div class='verdana2'>";
788 echo "<p>";
789 if ($nouveau) {
790 echo "<script type='text/javascript'><!-- \nvar antifocus_champ = false; // --></script>\n";
791 $js = " onfocus=\"if(!antifocus_champ){this.value='';antifocus_champ=true;}\"";
792 }
793 else $js = "";
794 if ($type=='separateur'){
795 echo "<label for='nom_$code'>"._T("forms:champ_nom_bloc")."</label> :";
796 echo " &nbsp;<input type='text' name='nom_champ' id='nom_$code' value=\"".
797 entites_html($t['nom'])."\" class='fondo verdana2' size='30'$js><br />\n";
798 }
799 else if ($type=='textestatique'){
800 echo "<label for='nom_$code'>"._T("forms:champ_nom_texte")."</label> :<br/>";
801 echo " &nbsp;<textarea name='nom_champ' id='nom_$code' class='verdana2' style='width:100%;height:5em;' $js>".
802 entites_html($t['nom'])."</textarea><br />\n";
803 }
804 else{
805 echo "<label for='nom_$code'>"._T("forms:champ_nom")."</label> :";
806 echo " &nbsp;<input type='text' name='nom_champ' id='nom_$code' value=\"".
807 entites_html($t['nom'])."\" class='fondo verdana2' size='30'$js><br />\n";
808 bloc_edition_champ($t, $form_link);
809 }
810
811 echo "<div align='right'>";
812 echo "<input type='submit' name='Valider' value='"._T('bouton_valider')."' class='fondo verdana2'></div>\n";
813 echo "</div>\n";
814 echo "</form>";
815 // Supprimer un champ
816 $link = parametre_url($form_link,'supp_champ', $code);
817 echo "<div style='float: left;'>";
818 icone_horizontale(_T("forms:supprimer_champ"), $link."#champs","../"._DIR_PLUGIN_FORMS. "/img_pack/form-24.png", "supprimer.gif");
819 echo "</div>\n";
820
821 echo fin_block();
822 if (!in_array($t['type'],array('separateur','textestatique')))
823 fin_cadre_relief();
824 else
825 fin_cadre_enfonce();
826 }
827
828 // Ajouter un champ
829 echo "<p>";
830 debut_cadre_enfonce();
831 echo "<form method='POST' action='"
832 . $form_link. "#nouveau_champ"
833 . "' style='border: 0px; margin: 0px;'>";
834 echo "<strong>"._T("forms:ajouter_champ")."</strong><br />\n";
835 echo _T("forms:ajouter_champ_type");
836 echo " \n";
837 $types = array('ligne', 'texte', 'email', 'url', 'select', 'multiple', 'fichier', 'mot','separateur','textestatique');
838 echo "<select name='ajout_champ' value='' class='fondo'>\n";
839 foreach ($types as $type) {
840 echo "<option value='$type'>".Forms_nom_type_champ($type)."</option>\n";
841 }
842 echo "</select>\n";
843 echo " &nbsp; <input type='submit' name='valider' id='ajout_champ' VALUE='"._T('bouton_ajouter')."' class='fondo'>";
844 echo "</form>\n";
845 fin_cadre_enfonce();
846 }
847
848 echo "</div>\n";
849
850 fin_cadre_formulaire();
851 }
852
853
854 fin_page();
855 }
856 ?>