Line 17... |
Line 17... |
17 |
// | |
|
17 |
// | |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
18 |
// | You should have received a copy of the GNU Lesser 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: bazar.fonct.formulaire.php,v 1.18 2006-03-01 16:01:46 florian Exp $
|
22 |
// CVS : $Id: bazar.fonct.formulaire.php,v 1.19 2006-03-02 20:36:52 florian Exp $
|
23 |
/**
|
23 |
/**
|
24 |
* Formulaire
|
24 |
* Formulaire
|
25 |
*
|
25 |
*
|
26 |
* Les fonctions de mise en page des formulaire
|
26 |
* Les fonctions de mise en page des formulaire
|
27 |
*
|
27 |
*
|
Line 29... |
Line 29... |
29 |
//Auteur original :
|
29 |
//Auteur original :
|
30 |
*@author Florian SCHMITT <florian@ecole-et-nature.org>
|
30 |
*@author Florian SCHMITT <florian@ecole-et-nature.org>
|
31 |
//Autres auteurs :
|
31 |
//Autres auteurs :
|
32 |
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
|
32 |
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
|
33 |
*@copyright Tela-Botanica 2000-2004
|
33 |
*@copyright Tela-Botanica 2000-2004
|
34 |
*@version $Revision: 1.18 $ $Date: 2006-03-01 16:01:46 $
|
34 |
*@version $Revision: 1.19 $ $Date: 2006-03-02 20:36:52 $
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
36 |
*/
|
36 |
*/
|
Line 37... |
Line 37... |
37 |
|
37 |
|
Line 60... |
Line 60... |
60 |
while ($ligne = $resultat->fetchRow()) {
|
60 |
while ($ligne = $resultat->fetchRow()) {
|
61 |
$select[$ligne[1]] = $ligne[2] ;
|
61 |
$select[$ligne[1]] = $ligne[2] ;
|
62 |
}
|
62 |
}
|
63 |
$option=array('style'=>'width: '.$limite1.'px;');
|
63 |
$option=array('style'=>'width: '.$limite1.'px;');
|
64 |
require_once 'HTML/QuickForm/select.php';
|
64 |
require_once 'HTML/QuickForm/select.php';
|
65 |
$select= new HTML_QuickForm_select('liste'.$id_liste, constant($label), $select, $option);
|
65 |
$select= new HTML_QuickForm_select('liste'.$id_liste, $label, $select, $option);
|
66 |
$select->setSize($limite2);
|
66 |
$select->setSize($limite2);
|
67 |
$select->setMultiple(0);
|
67 |
$select->setMultiple(0);
|
68 |
$select->setSelected($defaut);
|
68 |
$select->setSelected($defaut);
|
69 |
$formtemplate->addElement($select) ;
|
69 |
$formtemplate->addElement($select) ;
|
70 |
if (isset($obligatoire)and($obligatoire==1)) {
|
70 |
if (isset($obligatoire)and($obligatoire==1)) {
|
71 |
$formtemplate->addRule('liste'.$id_liste, BAZ_CHOISIR_OBLIGATOIRE.' '.constant($label) , 'nonzero', '', 'client') ;
|
71 |
$formtemplate->addRule('liste'.$id_liste, BAZ_CHOISIR_OBLIGATOIRE.' '.$label , 'nonzero', '', 'client') ;
|
72 |
$formtemplate->addRule('liste'.$id_liste, constant($label.'_REQUIS'), 'required', '', 'client') ;}
|
72 |
$formtemplate->addRule('liste'.$id_liste, $label.' obligatoire', 'required', '', 'client') ;}
|
73 |
}
|
73 |
}
|
Line 74... |
Line 74... |
74 |
|
74 |
|
75 |
|
75 |
|
Line 93... |
Line 93... |
93 |
}
|
93 |
}
|
94 |
require_once 'HTML/QuickForm/checkbox.php' ;
|
94 |
require_once 'HTML/QuickForm/checkbox.php' ;
|
95 |
$i=0;
|
95 |
$i=0;
|
96 |
if (isset($defaut)) $tab=split(', ', $defaut);
|
96 |
if (isset($defaut)) $tab=split(', ', $defaut);
|
97 |
while ($ligne = $resultat->fetchRow()) {
|
97 |
while ($ligne = $resultat->fetchRow()) {
|
98 |
if ($i==0) $labelchkbox=constant($label) ; else $labelchkbox=' ' ;
|
98 |
if ($i==0) $labelchkbox=$label ; else $labelchkbox=' ' ;
|
99 |
$checkbox[$i]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2],
|
99 |
$checkbox[$i]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2],
|
100 |
array ('style'=>'display:inline;margin-left:2px;')) ;
|
100 |
array ('style'=>'display:inline;margin-left:2px;')) ;
|
101 |
foreach ($tab as $val) {
|
101 |
foreach ($tab as $val) {
|
102 |
if ($ligne[1]==$val) $checkbox[$i]->setChecked(1);
|
102 |
if ($ligne[1]==$val) $checkbox[$i]->setChecked(1);
|
103 |
}
|
103 |
}
|
104 |
$i++;
|
104 |
$i++;
|
105 |
}
|
105 |
}
|
106 |
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, constant($label), '<br />'."\n");
|
106 |
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, $label, '<br />'."\n");
|
107 |
if (isset($obligatoire)and($obligatoire==1)) {
|
107 |
if (isset($obligatoire)and($obligatoire==1)) {
|
108 |
$formtemplate->addGroupRule('checkbox'.$id_liste, constant($label.'_REQUIS'), 'required', null, 1, 'client');
|
108 |
$formtemplate->addGroupRule('checkbox'.$id_liste, $label.' obligatoire', 'required', null, 1, 'client');
|
109 |
}
|
109 |
}
|
110 |
}
|
110 |
}
|
Line 111... |
Line 111... |
111 |
|
111 |
|
Line 127... |
Line 127... |
127 |
'minYear' => date('Y'),
|
127 |
'minYear' => date('Y'),
|
128 |
'maxYear'=> (date('Y')+10),
|
128 |
'maxYear'=> (date('Y')+10),
|
129 |
'format' => 'd m Y',
|
129 |
'format' => 'd m Y',
|
130 |
'addEmptyOption' => true,
|
130 |
'addEmptyOption' => true,
|
131 |
);
|
131 |
);
|
132 |
$formtemplate->addElement('date', $nom_bdd, constant($label), $optiondate) ;
|
132 |
$formtemplate->addElement('date', $nom_bdd, $label, $optiondate) ;
|
133 |
//gestion des valeurs par défaut (date du jour)
|
133 |
//gestion des valeurs par défaut (date du jour)
|
134 |
if (isset($defaut)) $formtemplate->setDefaults(array($nom_bdd => $defaut));
|
134 |
if (isset($defaut)) $formtemplate->setDefaults(array($nom_bdd => $defaut));
|
135 |
else {
|
135 |
else {
|
136 |
$defauts=array($nom_bdd => array ('d'=>date('d'), 'm'=>date('m'), 'Y'=>date('Y')));
|
136 |
$defauts=array($nom_bdd => array ('d'=>date('d'), 'm'=>date('m'), 'Y'=>date('Y')));
|
137 |
$formtemplate->setDefaults($defauts);
|
137 |
$formtemplate->setDefaults($defauts);
|
138 |
}
|
138 |
}
|
139 |
//gestion du champs obligatoire
|
139 |
//gestion du champs obligatoire
|
140 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, constant($label.'_REQUIS'), 'required', '', 'client') ;}
|
140 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;}
|
141 |
}
|
141 |
}
|
Line 142... |
Line 142... |
142 |
|
142 |
|
143 |
/** listedatefin() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de fin
|
143 |
/** listedatefin() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de fin
|
144 |
*
|
144 |
*
|
Line 169... |
Line 169... |
169 |
* @param string ce champs est il obligatoire? (required)
|
169 |
* @param string ce champs est il obligatoire? (required)
|
170 |
* @return void
|
170 |
* @return void
|
171 |
*/
|
171 |
*/
|
172 |
function texte(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
172 |
function texte(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
173 |
$option=array('size'=>$limite1,'maxlength'=>$limite2);
|
173 |
$option=array('size'=>$limite1,'maxlength'=>$limite2);
|
174 |
$formtemplate->addElement('text', $nom_bdd, constant($label), $option) ;
|
174 |
$formtemplate->addElement('text', $nom_bdd, $label, $option) ;
|
175 |
//gestion des valeurs par défaut
|
175 |
//gestion des valeurs par défaut
|
176 |
$defauts=array($nom_bdd=>$defaut);
|
176 |
$defauts=array($nom_bdd=>$defaut);
|
177 |
$formtemplate->setDefaults($defauts);
|
177 |
$formtemplate->setDefaults($defauts);
|
178 |
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
|
178 |
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
|
179 |
//gestion du champs obligatoire
|
179 |
//gestion du champs obligatoire
|
180 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, constant($label.'_REQUIS'), 'required', '', 'client') ;}
|
180 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;}
|
181 |
}
|
181 |
}
|
Line 182... |
Line 182... |
182 |
|
182 |
|
183 |
|
183 |
|
Line 192... |
Line 192... |
192 |
* @param string table source pour les valeurs du texte (inutile)
|
192 |
* @param string table source pour les valeurs du texte (inutile)
|
193 |
* @param string ce champs est il obligatoire? (required)
|
193 |
* @param string ce champs est il obligatoire? (required)
|
194 |
* @return void
|
194 |
* @return void
|
195 |
*/
|
195 |
*/
|
196 |
function textelong(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
196 |
function textelong(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
197 |
$formtexte= new HTML_QuickForm_textarea($nom_bdd, constant($label), array('style'=>'white-space: normal;'));
|
197 |
$formtexte= new HTML_QuickForm_textarea($nom_bdd, $label, array('style'=>'white-space: normal;'));
|
198 |
$formtexte->setCols($limite1);
|
198 |
$formtexte->setCols($limite1);
|
199 |
$formtexte->setRows($limite2);
|
199 |
$formtexte->setRows($limite2);
|
200 |
$formtemplate->addElement($formtexte) ;
|
200 |
$formtemplate->addElement($formtexte) ;
|
201 |
//gestion des valeurs par défaut
|
201 |
//gestion des valeurs par défaut
|
202 |
$defauts=array($nom_bdd=>$defaut);
|
202 |
$defauts=array($nom_bdd=>$defaut);
|
203 |
$formtemplate->setDefaults($defauts);
|
203 |
$formtemplate->setDefaults($defauts);
|
204 |
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
|
204 |
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
|
205 |
//gestion du champs obligatoire
|
205 |
//gestion du champs obligatoire
|
206 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, constant($label.'_REQUIS'), 'required', '', 'client') ;}
|
206 |
if (isset($obligatoire)and($obligatoire==1)) {$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;}
|
207 |
}
|
207 |
}
|
Line 208... |
Line 208... |
208 |
|
208 |
|
209 |
/** url() - Ajoute un élément de type url internet au formulaire
|
209 |
/** url() - Ajoute un élément de type url internet au formulaire
|
210 |
*
|
210 |
*
|
Line 267... |
Line 267... |
267 |
* @param string table source pour les valeurs du texte (inutile)
|
267 |
* @param string table source pour les valeurs du texte (inutile)
|
268 |
* @param string ce champs est il obligatoire? (required)
|
268 |
* @param string ce champs est il obligatoire? (required)
|
269 |
* @return void
|
269 |
* @return void
|
270 |
*/
|
270 |
*/
|
271 |
function image(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
271 |
function image(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
|
272 |
$html.='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
|
272 |
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
|
273 |
$formtemplate->addElement('html', $html) ;
|
273 |
$formtemplate->addElement('html', $html) ;
|
274 |
$formtemplate->addElement('file', 'image'.$nom_bdd, BAZ_IMAGE) ;
|
274 |
$formtemplate->addElement('file', 'image'.$nom_bdd, BAZ_IMAGE) ;
|
275 |
//TODO: controler si c'est une image
|
275 |
//TODO: controler si c'est une image
|
276 |
$formtemplate->setMaxFileSize($limite1);
|
276 |
$formtemplate->setMaxFileSize($limite1);
|
277 |
//gestion du champs obligatoire
|
277 |
//gestion du champs obligatoire
|
Line 301... |
Line 301... |
301 |
}
|
301 |
}
|
Line 302... |
Line 302... |
302 |
|
302 |
|
303 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
303 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
304 |
*
|
304 |
*
|
- |
|
305 |
* $Log: not supported by cvs2svn $
|
- |
|
306 |
* Revision 1.18 2006/03/01 16:01:46 florian
|
- |
|
307 |
* correction bug déclaration variable $html
|
305 |
* $Log: not supported by cvs2svn $
|
308 |
*
|
306 |
* Revision 1.17 2006/01/30 10:27:03 florian
|
309 |
* Revision 1.17 2006/01/30 10:27:03 florian
|
307 |
* - ajout des entrées de formulaire fichier, url, et image
|
310 |
* - ajout des entrées de formulaire fichier, url, et image
|
308 |
* - correction bug d'affichage du mode de saisie
|
311 |
* - correction bug d'affichage du mode de saisie
|
309 |
*
|
312 |
*
|