Subversion Repositories Applications.bazar

Rev

Rev 82 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 82 Rev 86
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.16 2006-01-24 14:11:44 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.formulaire.php,v 1.17 2006-01-30 10:27:03 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.16 $ $Date: 2006-01-24 14:11:44 $
34
*@version       $Revision: 1.17 $ $Date: 2006-01-30 10:27:03 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
Line 56... Line 56...
56
	$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
56
	$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
57
	if (DB::isError ($resultat)) {
57
	if (DB::isError ($resultat)) {
58
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
58
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
59
	}
59
	}
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, constant($label), $select, $option);
66
	$select->setSize($limite2); 
66
	$select->setSize($limite2); 
Line 103... Line 103...
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, constant($label), '<br />'."\n");
107
	if (isset($obligatoire)and($obligatoire==1)) {
107
	if (isset($obligatoire)and($obligatoire==1)) {
108
		//TODO: marches pas...
-
 
109
		$formtemplate->addGroupRule('checkbox'.$id_liste, constant($label.'_REQUIS'), 'required', null, 1, 'client');
108
		$formtemplate->addGroupRule('checkbox'.$id_liste, constant($label.'_REQUIS'), 'required', null, 1, 'client');
110
	}
109
	}
111
}
110
}
Line 205... Line 204...
205
	$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
204
	$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
206
	//gestion du champs obligatoire
205
	//gestion du champs obligatoire
207
	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, constant($label.'_REQUIS'), 'required', '', 'client') ;}
208
}
207
}
Line -... Line 208...
-
 
208
 
-
 
209
/** url() - Ajoute un élément de type url internet au formulaire
-
 
210
*
-
 
211
* @param    mixed   L'objet QuickForm du formulaire
-
 
212
* @param    string  numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
-
 
213
* @param    string  label à afficher dans le formulaire
-
 
214
* @param    string  taille des colonnes de l'élément
-
 
215
* @param    string  taille des lignes de l'élément
-
 
216
* @param    string  valeur par défaut du formulaire
-
 
217
* @param    string  table source pour les valeurs du texte (inutile)
-
 
218
* @param    string  ce champs est il obligatoire? (required)
-
 
219
* @return   void
-
 
220
*/
-
 
221
function url(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
-
 
222
	$html.='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
-
 
223
	$formtemplate->addElement('html', $html) ;
-
 
224
	$formtemplate->addElement('text', 'url_lien'.$nom_bdd, BAZ_URL_LIEN) ;
-
 
225
	$formtemplate->addElement('text', 'url_texte'.$nom_bdd, BAZ_URL_TEXTE) ;
-
 
226
	//gestion du champs obligatoire
-
 
227
	if (isset($obligatoire)and($obligatoire==1)) {
-
 
228
		$formtemplate->addRule('url_lien'.$nom_bdd, BAZ_URL_LIEN_REQUIS, 'required', '', 'client') ;
-
 
229
		$formtemplate->addRule('url_texte'.$nom_bdd, BAZ_URL_TEXTE_REQUIS, 'required', '', 'client') ;
-
 
230
	}
-
 
231
}		
-
 
232
 
-
 
233
/** fichier() - Ajoute un élément de type fichier au formulaire
-
 
234
*
-
 
235
* @param    mixed   L'objet QuickForm du formulaire
-
 
236
* @param    string  numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
-
 
237
* @param    string  label à afficher dans le formulaire
-
 
238
* @param    string  taille des colonnes de l'élément
-
 
239
* @param    string  taille des lignes de l'élément
-
 
240
* @param    string  valeur par défaut du formulaire
-
 
241
* @param    string  table source pour les valeurs du texte (inutile)
-
 
242
* @param    string  ce champs est il obligatoire? (required)
-
 
243
* @return   void
-
 
244
*/
-
 
245
function fichier(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
-
 
246
	$html.='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
-
 
247
	$formtemplate->addElement('html', $html) ;
-
 
248
	$formtemplate->addElement('text', 'texte_fichier'.$nom_bdd, BAZ_FICHIER_DESCRIPTION) ;
-
 
249
	$formtemplate->addElement('file', 'fichier'.$nom_bdd, BAZ_FICHIER_JOINT) ;
-
 
250
	$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image
-
 
251
	$formtemplate->setMaxFileSize($limite1);
-
 
252
	//gestion du champs obligatoire
-
 
253
	if (isset($obligatoire)and($obligatoire==1)) {
-
 
254
		$formtemplate->addRule('texte_fichier'.$nom_bdd, BAZ_FICHIER_LABEL_REQUIS, 'required', '', 'client') ;
-
 
255
		$formtemplate->addRule('fichier'.$nom_bdd, BAZ_FICHIER_JOINT_REQUIS, 'required', '', 'client') ;
-
 
256
	}
-
 
257
}		
-
 
258
 
-
 
259
/** image() - Ajoute un élément de type image au formulaire
-
 
260
*
-
 
261
* @param    mixed   L'objet QuickForm du formulaire
-
 
262
* @param    string  numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
-
 
263
* @param    string  label à afficher dans le formulaire
-
 
264
* @param    string  taille maximum du fichier colonnes de l'élément
-
 
265
* @param    string  taille des lignes de l'élément
-
 
266
* @param    string  valeur par défaut du formulaire
-
 
267
* @param    string  table source pour les valeurs du texte (inutile)
-
 
268
* @param    string  ce champs est il obligatoire? (required)
-
 
269
* @return   void
-
 
270
*/
-
 
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";
-
 
273
	$formtemplate->addElement('html', $html) ;
-
 
274
	$formtemplate->addElement('file', 'image'.$nom_bdd, BAZ_IMAGE) ;
-
 
275
	//TODO: controler si c'est une image
-
 
276
	$formtemplate->setMaxFileSize($limite1);
-
 
277
	//gestion du champs obligatoire
-
 
278
	if (isset($obligatoire)and($obligatoire==1)) {
-
 
279
		$formtemplate->addRule('image'.$nom_bdd, BAZ_IMAGE_VALIDE_REQUIS, 'required', '', 'client') ;
-
 
280
	}
-
 
281
}		
-
 
282
 
Line 209... Line 283...
209
 
283
 
210
 
284
 
211
/** labelhtml() - Ajoute un élément de type textearea au formulaire
285
/** labelhtml() - Ajoute un élément de type textearea au formulaire
212
*
286
*
Line 227... Line 301...
227
}
301
}
Line 228... Line 302...
228
 
302
 
229
/* +--Fin du code ----------------------------------------------------------------------------------------+
303
/* +--Fin du code ----------------------------------------------------------------------------------------+
230
*
304
*
-
 
305
* $Log: not supported by cvs2svn $
-
 
306
* Revision 1.16  2006/01/24 14:11:44  alexandre_tb
-
 
307
* ajout du paramètre emptyOptionValue dans les champs de date
231
* $Log: not supported by cvs2svn $
308
*
232
* Revision 1.15  2006/01/23 16:57:03  alexandre_tb
309
* Revision 1.15  2006/01/23 16:57:03  alexandre_tb
233
* correction d'un notice
310
* correction d'un notice
234
*
311
*
235
* Revision 1.14  2006/01/19 17:42:11  florian
312
* Revision 1.14  2006/01/19 17:42:11  florian