Subversion Repositories Applications.papyrus

Rev

Rev 832 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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