2007-03-29 18:10:14 +02:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formulaire pour LdapSaisie
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Cette classe gère les formulaires
|
2007-03-29 18:10:14 +02:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class LSform {
|
2007-11-15 19:07:24 +01:00
|
|
|
var $ldapObject;
|
2007-03-29 18:10:14 +02:00
|
|
|
var $idForm;
|
2007-11-15 19:07:24 +01:00
|
|
|
var $can_validate = true;
|
|
|
|
var $elements = array();
|
|
|
|
var $_rules = array();
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
var $_postData = array();
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
var $_elementsErrors = array();
|
|
|
|
var $_isValidate = false;
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
var $_notUpdate = array();
|
2008-02-26 18:40:05 +01:00
|
|
|
|
|
|
|
var $maxFileSize = NULL;
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2007-03-29 18:10:14 +02:00
|
|
|
* Constructeur
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Cette methode construit l'objet et définis la configuration.
|
2007-03-29 18:10:14 +02:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @param[in] $idForm [<b>required</b>] string L'identifiant du formulaire
|
|
|
|
* @param[in] $submit string La valeur du bouton submit
|
|
|
|
*
|
|
|
|
* @retval void
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
2007-11-15 19:07:24 +01:00
|
|
|
function LSform (&$ldapObject,$idForm,$submit="Envoyer"){
|
2007-03-29 18:10:14 +02:00
|
|
|
$this -> idForm = $idForm;
|
|
|
|
$this -> submit = $submit;
|
2008-02-08 18:39:24 +01:00
|
|
|
$this -> ldapObject = $ldapObject;
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSformElement');
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Affiche le formualaire
|
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @retval void
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
2007-03-29 18:10:14 +02:00
|
|
|
function display(){
|
2008-02-08 18:39:24 +01:00
|
|
|
if ($this -> idForm == 'view') {
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
|
|
|
}
|
|
|
|
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_action',$_SERVER['PHP_SELF']);
|
|
|
|
$LSform_header = "\t<input type='hidden' name='validate' value='LSform'/>\n
|
|
|
|
\t<input type='hidden' name='idForm' id='LSform_idform' value='".$this -> idForm."'/>\n
|
|
|
|
\t<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='".$this -> ldapObject -> getType()."'/>\n
|
2008-02-26 18:40:05 +01:00
|
|
|
\t<input type='hidden' name='LSform_objectdn' id='LSform_objectdn' value='".$this -> ldapObject -> getValue('dn')."'/>\n";
|
|
|
|
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
$LSform_object = array(
|
|
|
|
'type' => $this -> ldapObject -> getType(),
|
2008-02-12 18:59:44 +01:00
|
|
|
'dn' => $this -> ldapObject -> getValue('dn')
|
2008-02-08 18:39:24 +01:00
|
|
|
);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
|
|
|
|
$fields = array();
|
|
|
|
foreach($this -> elements as $element) {
|
|
|
|
$field = array();
|
|
|
|
$field = $element -> getDisplay();
|
|
|
|
if (isset($this -> _elementsErrors[$element -> name])) {
|
|
|
|
$field['errors']= $this -> _elementsErrors[$element -> name];
|
|
|
|
}
|
|
|
|
$fields[] = $field;
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
|
|
|
|
if ($this -> maxFileSize) {
|
|
|
|
$LSform_header.="\t<input type='hidden' name='MAX_FILE_SIZE' value='".$this -> maxFileSize."'/>\n";
|
|
|
|
}
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
|
|
|
if($this -> can_validate) {
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
|
|
|
|
}
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
|
|
|
* Affiche la vue
|
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @retval void
|
|
|
|
*/
|
|
|
|
function displayView(){
|
|
|
|
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
|
|
|
$LSform_object = array(
|
|
|
|
'type' => $this -> ldapObject -> getType(),
|
|
|
|
'dn' => $this -> ldapObject -> getDn()
|
|
|
|
);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
|
|
|
|
$fields = array();
|
|
|
|
foreach($this -> elements as $element) {
|
|
|
|
$field = $element -> getDisplay();
|
|
|
|
$fields[] = $field;
|
|
|
|
}
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
|
|
|
}
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Défini l'erreur sur un champ
|
2007-03-29 18:10:14 +02:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @param[in] $attr [<b>required</b>] string Le nom du champ
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $msg Le format du message d'erreur à afficher (pouvant comporter
|
|
|
|
* des valeurs %{[n'importe quoi]} qui seront remplacé par le label
|
|
|
|
* du champs concerné.
|
2007-03-29 18:10:14 +02:00
|
|
|
*
|
|
|
|
* @retval void
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
2007-03-29 18:10:14 +02:00
|
|
|
function setElementError($attr,$msg=NULL) {
|
|
|
|
if($msg!='') {
|
|
|
|
$msg_error=getFData($msg,$attr->getLabel());
|
|
|
|
}
|
|
|
|
else {
|
2008-04-25 16:09:27 +02:00
|
|
|
$msg_error=getFData(_("Les données pour l'attribut %{label} ne sont pas valides."),$attr->getLabel());
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
$this -> _elementsErrors[$attr->name][]=$msg_error;
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Savoir si des erreurs son définie pour un élement du formulaire
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $element [<b>required</b>] string Le nom de l'élement
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
|
|
|
* @retval boolean
|
|
|
|
*/
|
|
|
|
function definedError($element) {
|
|
|
|
return isset($this -> _elementsErrors[$element]);
|
|
|
|
}
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Verifie si le formulaire a été validé et que les données sont valides.
|
2007-03-29 18:10:14 +02:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si le formulaire a été validé et que les données ont été validées, false sinon
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
2007-03-29 18:10:14 +02:00
|
|
|
function validate(){
|
2007-11-15 19:07:24 +01:00
|
|
|
if(!$this -> can_validate)
|
|
|
|
return;
|
|
|
|
if ($this -> isSubmit()) {
|
2008-02-08 18:39:24 +01:00
|
|
|
if (!$this -> getPostData()) {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(201);
|
|
|
|
return;
|
|
|
|
}
|
2008-07-18 16:02:46 +02:00
|
|
|
$this -> setValuesFromPostData();
|
2008-04-25 16:09:27 +02:00
|
|
|
//Validation des données ici !!! ///
|
2008-02-08 18:39:24 +01:00
|
|
|
if (!$this -> checkData()) {
|
|
|
|
return;
|
|
|
|
}
|
2008-04-25 16:09:27 +02:00
|
|
|
debug("les données sont checkées");
|
2008-02-08 18:39:24 +01:00
|
|
|
$this -> _isValidate = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Vérifier les données du formulaire à partir des régles définis sur les champs
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @retval boolean true si toutes la saisie est OK, false sinon
|
|
|
|
*/
|
|
|
|
function checkData() {
|
|
|
|
$retval=true;
|
|
|
|
foreach ($this -> _postData as $element => $values) {
|
|
|
|
if(!is_array($values)) {
|
|
|
|
$values=array($values);
|
|
|
|
}
|
|
|
|
if ($this -> elements[$element] -> isRequired()) {
|
|
|
|
if (!$this -> checkRequired($values)) {
|
|
|
|
$this -> setElementError($this -> elements[$element],_("Champ obligatoire"));
|
|
|
|
$retval=false;
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
foreach($values as $value) {
|
|
|
|
if (empty($value)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!is_array($this -> _rules[$element]))
|
|
|
|
continue;
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
|
|
|
foreach($this -> _rules[$element] as $rule) {
|
|
|
|
$ruleType="LSformRule_".$rule['name'];
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass($ruleType);
|
2008-02-26 18:40:05 +01:00
|
|
|
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'], $this -> getElement($element))) {
|
2008-02-08 18:39:24 +01:00
|
|
|
$retval=false;
|
|
|
|
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $retval;
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Vérifie si au moins une valeur est présente dans le tableau
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @param[in] $data array tableau de valeurs
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si au moins une valeur est présente, false sinon
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function checkRequired($data) {
|
|
|
|
foreach($data as $val) {
|
|
|
|
if (!empty($val))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Verifie si la saisie du formulaire est présente en POST
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si la saisie du formulaire est présente en POST, false sinon
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
2007-11-15 19:07:24 +01:00
|
|
|
function isSubmit() {
|
|
|
|
if( (isset($_POST['validate']) && ($_POST['validate']=='LSform')) && (isset($_POST['idForm']) && ($_POST['idForm'] == $this -> idForm)) )
|
|
|
|
return true;
|
2008-02-08 18:39:24 +01:00
|
|
|
return;
|
2007-11-15 19:07:24 +01:00
|
|
|
}
|
|
|
|
|
2008-06-05 15:21:18 +02:00
|
|
|
/**
|
|
|
|
* Défini arbitrairement des données en POST
|
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
|
|
|
* @param[in] $data array('attr' => array(values)) Tableau des données du formulaire
|
|
|
|
* @param[in] $consideredAsSubmit Définie si on force le formualaire comme envoyer
|
|
|
|
*
|
|
|
|
* @retval boolean true si les données ont été définies, false sinon
|
|
|
|
*/
|
|
|
|
function setPostData($data,$consideredAsSubmit=false) {
|
|
|
|
if (is_array($data)) {
|
|
|
|
foreach($data as $key => $values) {
|
|
|
|
if (!is_array($values)) {
|
|
|
|
$values = array($values);
|
|
|
|
}
|
|
|
|
$_POST[$key] = $values;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($consideredAsSubmit) {
|
|
|
|
$_POST['validate']='LSform';
|
|
|
|
$_POST['idForm']=$this -> idForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Récupère les valeurs postées dans le formulaire
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si les valeurs ont bien été récupérées, false sinon.
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function getPostData() {
|
|
|
|
foreach($this -> elements as $element_name => $element) {
|
|
|
|
if( !($element -> getPostData($this -> _postData)) ) {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(202,$element_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-05-15 12:56:55 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Ajoute un élément au formulaire
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Ajoute un élément au formulaire et définis les informations le concernant.
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $type string Le type de l'élément
|
|
|
|
* @param[in] $name string Le nom de l'élément
|
|
|
|
* @param[in] $label string Le label de l'élément
|
|
|
|
* @param[in] $param mixed Paramètres supplémentaires
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @retval LSformElement
|
|
|
|
*/
|
2008-05-14 16:43:23 +02:00
|
|
|
function addElement($type,$name,$label,$params=array(),&$attr_html) {
|
2008-02-08 18:39:24 +01:00
|
|
|
$elementType='LSformElement_'.$type;
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass($elementType);
|
|
|
|
if (!class_exists($elementType)) {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(205,array('type' => $type));
|
|
|
|
return;
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
$element=$this -> elements[$name] = new $elementType($this,$name,$label,$params,$attr_html);
|
2008-02-08 18:39:24 +01:00
|
|
|
if ($element) {
|
|
|
|
return $element;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
unset ($this -> elements[$name]);
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(206,array('element' => $name));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-05-15 12:56:55 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Ajoute une règle sur un élément du formulaire
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $element string Le nom de l'élément conserné
|
|
|
|
* @param[in] $rule string Le nom de la règle à ajouter
|
2008-02-08 18:39:24 +01:00
|
|
|
* @param[in] $options array Options (facultative)
|
|
|
|
*
|
|
|
|
* @retval boolean
|
|
|
|
*/
|
|
|
|
function addRule($element, $rule, $options=array()) {
|
|
|
|
if ( isset($this ->elements[$element]) ) {
|
|
|
|
if ($this -> isRuleRegistered($rule)) {
|
|
|
|
$this -> _rules[$element][]=array(
|
|
|
|
'name' => $rule,
|
|
|
|
'options' => $options
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(43,array('attr' => $element,'rule'=>$rule));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(204,array('element' => $element));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-15 12:56:55 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Définis comme requis un élément
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $element string Le nom de l'élément conserné
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @retval boolean
|
|
|
|
*/
|
|
|
|
function setRequired($element) {
|
|
|
|
if (isset( $this -> elements[$element] ) )
|
|
|
|
return $this -> elements[$element] -> setRequired();
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-05-15 12:56:55 +02:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Détermine la valider de la règle
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* Devra déterminer si la règle passez en paramètre est correcte
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] $element string Le nom de l'élément conserné
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function isRuleRegistered($rule) {
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_'.$rule);
|
|
|
|
return class_exists('LSformRule_'.$rule);
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Retourne les valeurs validés du formulaire
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval mixed Les valeurs validés du formulaire, ou false si elles ne le sont pas
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function exportValues() {
|
|
|
|
if ($this -> _isValidate) {
|
2008-07-18 16:02:46 +02:00
|
|
|
$retval=array();
|
|
|
|
foreach($this -> _postData as $element => $values) {
|
|
|
|
$retval[$element] = $this -> elements[$element] -> exportValues();
|
|
|
|
}
|
|
|
|
return $retval;
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Retourn un élement du formulaire
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @param[in] string $element Nom de l'élement voulu
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval LSformElement L'élement du formulaire voulu
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function getElement($element) {
|
|
|
|
return $this -> elements[$element];
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Défini les valeurs des élements à partir des valeurs postées
|
2008-02-08 18:39:24 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean True si les valeurs ont été définies, false sinon.
|
2008-02-08 18:39:24 +01:00
|
|
|
*/
|
|
|
|
function setValuesFromPostData() {
|
|
|
|
if (empty($this -> _postData)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
foreach($this -> _postData as $element => $values) {
|
2008-05-14 16:43:23 +02:00
|
|
|
$this -> elements[$element] -> setValueFromPostData($values);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
/**
|
|
|
|
* Retourne le code HTML d'un champ vide.
|
|
|
|
*
|
|
|
|
* @param[in] string Le nom du champ du formulaire
|
|
|
|
*
|
|
|
|
* @retval string Le code HTML du champ vide.
|
|
|
|
*/
|
|
|
|
function getEmptyField($element) {
|
|
|
|
$element = $this -> getElement($element);
|
|
|
|
if ($element) {
|
|
|
|
return $element -> getEmptyField();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
|
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Défini la taille maximal pour les fichiers envoyés par le formualaire
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
|
|
|
* @param[in] $size La taille maximal en octets
|
|
|
|
*
|
|
|
|
* @retval void
|
|
|
|
**/
|
|
|
|
function setMaxFileSize($size) {
|
|
|
|
$this -> maxFileSize = $size;
|
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
}
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
?>
|