206 |
alex |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
1497 |
florian |
22 |
// CVS : $Id: HTML_formulaireAuth.class.php,v 1.5 2007-06-26 14:18:53 florian Exp $
|
206 |
alex |
23 |
/**
|
|
|
24 |
* Application projet
|
|
|
25 |
*
|
|
|
26 |
* La classe HTML_formulaireAuth
|
|
|
27 |
*
|
|
|
28 |
*@package projet
|
|
|
29 |
//Auteur original :
|
|
|
30 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
|
|
31 |
//Autres auteurs :
|
|
|
32 |
*@author Aucun
|
|
|
33 |
*@copyright Tela-Botanica 2000-2004
|
1497 |
florian |
34 |
*@version $Revision: 1.5 $
|
206 |
alex |
35 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
// | ENTETE du PROGRAMME |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
|
|
|
43 |
/** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */
|
|
|
44 |
|
832 |
florian |
45 |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
|
|
|
46 |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
|
|
|
47 |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php' ;
|
206 |
alex |
48 |
|
|
|
49 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
50 |
// | LISTE des constantes |
|
|
|
51 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* class HTML_formulaireProjet
|
|
|
56 |
* Cette classe représente un formulaire pour saisir un projet ou le modifier.
|
|
|
57 |
*/
|
|
|
58 |
class HTML_formulaireAuth extends HTML_QuickForm
|
|
|
59 |
{
|
|
|
60 |
/**
|
|
|
61 |
* Constructeur
|
|
|
62 |
*
|
|
|
63 |
* @param string formName Le nom du formulaire.
|
|
|
64 |
* @param string method Soit get soit post, voir le protocole HTTP
|
|
|
65 |
* @param string action L'action du formulaire.
|
|
|
66 |
* @param string target La cible du formulaire.
|
|
|
67 |
* @param Array attributes Des attributs supplémentaires pour la balise <form>
|
|
|
68 |
* @param bool trackSubmit Pour repérer si la formulaire a été soumis.
|
|
|
69 |
* @return void
|
|
|
70 |
* @access public
|
|
|
71 |
*/
|
332 |
jpm |
72 |
function HTML_formulaireAuth($formName = '', $method = 'post', $action = '', $target = '_self', $attributes = '', $trackSubmit = false)
|
206 |
alex |
73 |
{
|
332 |
jpm |
74 |
HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit);
|
|
|
75 |
$squelette =& $this->defaultRenderer();
|
1497 |
florian |
76 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
|
|
|
77 |
$squelette->setElementTemplate( '<p class="formulaire_element"><span class="form_label">'."\n".
|
|
|
78 |
'{label}'."\n".
|
|
|
79 |
'<!-- BEGIN required --><span style="color:red; width:5px; margin:0; padding:0;">*</span><!-- END required -->'."\n".
|
|
|
80 |
'</span>'."\n".'{element}'."\n".
|
|
|
81 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
|
|
82 |
'</p>'."\n");
|
|
|
83 |
$squelette->setGroupElementTemplate('<p style="display:inline">{element}</p>', 'form_boutons');
|
|
|
84 |
$squelette->setRequiredNoteTemplate("\n".'<p class="symbole_obligatoire">* : {requiredNote}</p>'."\n");
|
|
|
85 |
//Note pour les erreurs javascript
|
|
|
86 |
$this->setJsWarnings('Erreur de saisie', 'Veuillez verifier vos informations saisies');
|
|
|
87 |
// Note de fin de formulaire
|
|
|
88 |
$this->setRequiredNote('Indique les champs obligatoires');
|
|
|
89 |
// $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'."\n");
|
|
|
90 |
// $squelette->setElementTemplate( '<li>'."\n".
|
|
|
91 |
// '{label}'."\n".
|
|
|
92 |
// '{element}'."\n".
|
|
|
93 |
// '<!-- BEGIN required --><span class="symbole_obligatoire">'.ADAU_SYMBOLE_CHP_OBLIGATOIRE.'</span><!-- END required -->'."\n".
|
|
|
94 |
// '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
|
|
95 |
// '</li>'."\n");
|
|
|
96 |
// $squelette->setRequiredNoteTemplate("\n".'<p><span class="symbole_obligatoire">'.ADAU_SYMBOLE_CHP_OBLIGATOIRE.'</span> {requiredNote}</p>'."\n");
|
206 |
alex |
97 |
} // end of member function HTML_formulaireProjet
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* Renvoie le code HTML du formulaire.
|
|
|
101 |
*
|
|
|
102 |
* @return string
|
|
|
103 |
* @access public
|
|
|
104 |
*/
|
332 |
jpm |
105 |
function toHTML()
|
206 |
alex |
106 |
{
|
332 |
jpm |
107 |
$res = HTML_QuickForm::toHTML();
|
|
|
108 |
return $res;
|
206 |
alex |
109 |
} // end of member function toHTML
|
|
|
110 |
|
|
|
111 |
/**
|
|
|
112 |
* Ajoute les champs nécessaire au formulaire.
|
|
|
113 |
*
|
|
|
114 |
* @return void
|
|
|
115 |
* @access public
|
|
|
116 |
*/
|
|
|
117 |
function construitFormulaire($url_retour)
|
|
|
118 |
{
|
332 |
jpm |
119 |
$tab_index = 1000;
|
1497 |
florian |
120 |
$size = 35;
|
332 |
jpm |
121 |
$cols = 50;
|
|
|
122 |
$rows = 6;
|
206 |
alex |
123 |
|
1497 |
florian |
124 |
$form_debut = '<fieldset>'."\n".'<legend>'.ADAU_NOM_FORM.'</legend>'."\n";
|
332 |
jpm |
125 |
$this->addElement('html', $form_debut);
|
206 |
alex |
126 |
|
332 |
jpm |
127 |
$id = 'nom_auth';
|
|
|
128 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
129 |
$label = '<label for="'.$id.'">'.ADAU_NOM_AUTH.'</label>';
|
|
|
130 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
131 |
$this->addRule('nom_auth', ADAU_NOM_AUTH_ALERTE, 'required', '', 'client');
|
206 |
alex |
132 |
|
332 |
jpm |
133 |
$id = 'abreviation';
|
|
|
134 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
135 |
$label = '<label for="'.$id.'">'.ADAU_ABREVIATION.'</label>';
|
|
|
136 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
137 |
$this->addRule('abreviation', ADAU_ABREVIATION_ALERTE, 'required', '', 'client');
|
206 |
alex |
138 |
|
332 |
jpm |
139 |
$id = 'dsn';
|
|
|
140 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
141 |
$label = '<label for="'.$id.'">'.ADAU_DSN.'</label>';
|
|
|
142 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
143 |
$this->addRule('dsn', ADAU_DSN_ALERTE, 'required', '', 'client');
|
206 |
alex |
144 |
|
332 |
jpm |
145 |
$id = 'nom_table';
|
|
|
146 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
147 |
$label = '<label for="'.$id.'">'.ADAU_NOM_TABLE.'</label>';
|
|
|
148 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
149 |
$this->addRule('nom_table', ADAU_NOM_TABLE_ALERTE, 'required', '', 'client');
|
206 |
alex |
150 |
|
332 |
jpm |
151 |
$id = 'champs_login';
|
|
|
152 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
153 |
$label = '<label for="'.$id.'">'.ADAU_CHAMPS_LOGIN.'</label>';
|
|
|
154 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
155 |
$this->addRule('champs_login', ADAU_CHAMPS_LOGIN_ALERTE, 'required', '', 'client');
|
206 |
alex |
156 |
|
332 |
jpm |
157 |
$id = 'champs_passe';
|
|
|
158 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
159 |
$label = '<label for="'.$id.'">'.ADAU_CHAMPS_PASSE.'</label>';
|
|
|
160 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
161 |
$this->addRule('champs_passe', ADAU_CHAMPS_PASSE_ALERTE, 'required', '', 'client');
|
206 |
alex |
162 |
|
332 |
jpm |
163 |
$id = 'cryptage';
|
|
|
164 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'size' => $size);
|
|
|
165 |
$label = '<label for="'.$id.'">'.ADAU_CRYPTAGE.'</label>';
|
|
|
166 |
$this->addElement('text', $id, $label, $aso_attributs);
|
|
|
167 |
$this->addRule('cryptage', ADAU_CRYPTAGE_ALERTE, 'required', '', 'client');
|
206 |
alex |
168 |
|
332 |
jpm |
169 |
$id = 'parametres';
|
|
|
170 |
$aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'rows' => $rows, 'cols' => $cols);
|
|
|
171 |
$label = '<label for="'.$id.'">'.ADAU_PARAMETRE.'</label>';
|
|
|
172 |
$this->addElement('textarea', $id, $label, $aso_attributs);
|
206 |
alex |
173 |
|
1497 |
florian |
174 |
$form_fin = "\n".'</fieldset>'."\n";
|
332 |
jpm |
175 |
$this->addElement('html', $form_fin);
|
206 |
alex |
176 |
|
332 |
jpm |
177 |
// Gestion des boutons
|
1497 |
florian |
178 |
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', ADAU_ANNULER,
|
|
|
179 |
str_replace ("&", "&", $url_retour->getURL()), ADAU_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
|
|
|
180 |
// qui remplacent deux fois les & par des &
|
|
|
181 |
//Bouton de validation du formulaire // ce qui fait échouer le lien
|
|
|
182 |
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', ADAU_VALIDER);
|
|
|
183 |
$this->addGroup($buttons, 'form_boutons', null, ' ');
|
209 |
alex |
184 |
|
332 |
jpm |
185 |
|
1497 |
florian |
186 |
// $liste_bouton_debut = '<ul class="liste_bouton">'."\n";
|
|
|
187 |
// $this->addElement('html', $liste_bouton_debut);
|
|
|
188 |
//
|
|
|
189 |
// $this->addElement('submit', 'valider', ADAU_VALIDER);
|
|
|
190 |
//
|
|
|
191 |
// $bouton_annuler = '<li><a class="bouton" href="'.str_replace ('&', '&', $url_retour->getURL()).'">'.ADAU_ANNULER.'</a></li>'."\n";
|
|
|
192 |
// $this->addElement('html', $bouton_annuler);
|
|
|
193 |
//
|
|
|
194 |
// $liste_bouton_fin = '</ul>'."\n";
|
|
|
195 |
// $this->addElement('html', $liste_bouton_fin);
|
332 |
jpm |
196 |
|
|
|
197 |
|
|
|
198 |
$this->setRequiredNote(ADAU_CHAMPS_REQUIS);
|
|
|
199 |
|
206 |
alex |
200 |
} // end of member function _construitFormulaire
|
|
|
201 |
|
|
|
202 |
} // end of HTML_formulaireProjet
|
|
|
203 |
?>
|