From 5c6e8ada0881e37f0b115199ff91fd5e2fd0e29d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 15 Oct 2008 18:54:05 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSattr=5Fhtml=20:=20=20=20->=20Ajout=20d'un?= =?UTF-8?q?e=20m=C3=A9thode=20addToForm()=20standardise=20utilisant=20le?= =?UTF-8?q?=20param=C3=A8tre=20=20=20=20=20=20$LSformElement=5Ftype=20=20?= =?UTF-8?q?=20->=20Utilisatation=20de=20cette=20m=C3=A9thode=20standardis?= =?UTF-8?q?=C3=A9e=20pour=20les=20types=20d'attributs=20=20=20=20=20=20sui?= =?UTF-8?q?vants=20:=20=20=20=20=20=20=20-=20text=20=20=20=20=20=20=20-=20?= =?UTF-8?q?textarea=20=20=20=20=20=20=20-=20date=20=20=20=20=20=20=20-=20m?= =?UTF-8?q?ail=20=20=20=20=20=20=20-=20url=20=20=20=20=20=20=20-=20rss=20?= =?UTF-8?q?=20=20=20=20=20=20-=20xmpp=20=20=20=20=20=20=20-=20ssh=5Fkey=20?= =?UTF-8?q?=20=20=20=20=20=20-=20boolean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSattr_html.php | 15 +++++++++++- .../class/class.LSattr_html_boolean.php | 23 ++----------------- .../includes/class/class.LSattr_html_date.php | 11 +++------ .../includes/class/class.LSattr_html_mail.php | 21 +---------------- .../includes/class/class.LSattr_html_rss.php | 21 +---------------- .../class/class.LSattr_html_ssh_key.php | 22 +----------------- .../includes/class/class.LSattr_html_text.php | 21 +---------------- .../class/class.LSattr_html_textarea.php | 22 +----------------- .../includes/class/class.LSattr_html_url.php | 21 +---------------- .../includes/class/class.LSattr_html_xmpp.php | 21 +---------------- 10 files changed, 26 insertions(+), 172 deletions(-) diff --git a/trunk/includes/class/class.LSattr_html.php b/trunk/includes/class/class.LSattr_html.php index 7c557dca..5a81a64b 100644 --- a/trunk/includes/class/class.LSattr_html.php +++ b/trunk/includes/class/class.LSattr_html.php @@ -30,6 +30,7 @@ class LSattr_html { var $name; var $config; var $attribute; + var $LSformElement_type = false; /** * Constructeur @@ -78,7 +79,19 @@ class LSattr_html { * @retval LSformElement L'element du formulaire ajouté */ function addToForm (&$form,$idForm,$data=NULL) { - $GLOBALS['LSerror'] -> addErrorCode(101,$this -> name); + if (!$this -> LSformElement_type) { + $GLOBALS['LSerror'] -> addErrorCode(101,$this -> name); + return; + } + $element=$form -> addElement($this -> LSformElement_type, $this -> name, $this -> config['label'],$this -> config, $this); + if(!$element) { + $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); + return; + } + if ($data) { + $element -> setValue($data); + } + return $element; } /** diff --git a/trunk/includes/class/class.LSattr_html_boolean.php b/trunk/includes/class/class.LSattr_html_boolean.php index 953b8a9e..9f9bb694 100644 --- a/trunk/includes/class/class.LSattr_html_boolean.php +++ b/trunk/includes/class/class.LSattr_html_boolean.php @@ -27,27 +27,8 @@ */ class LSattr_html_boolean extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('boolean', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } - + var $LSformElement_type = 'boolean'; + } ?> diff --git a/trunk/includes/class/class.LSattr_html_date.php b/trunk/includes/class/class.LSattr_html_date.php index 8ddf87b5..7a9eecf6 100644 --- a/trunk/includes/class/class.LSattr_html_date.php +++ b/trunk/includes/class/class.LSattr_html_date.php @@ -27,6 +27,8 @@ */ class LSattr_html_date extends LSattr_html { + var $LSformElement_type = 'date'; + /** * Ajoute l'attribut au formualaire passer en paramètre * @@ -37,15 +39,8 @@ class LSattr_html_date extends LSattr_html { * @retval LSformElement L'element du formulaire ajouté */ function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('date', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } + $element = parent::addToForm($form,$idForm,$data); $form -> addRule($this -> name, 'date', array('format' => $element -> getFormat()) ); - if ($data) { - $element -> setValue($data); - } return $element; } diff --git a/trunk/includes/class/class.LSattr_html_mail.php b/trunk/includes/class/class.LSattr_html_mail.php index b8a6251f..5da984a7 100644 --- a/trunk/includes/class/class.LSattr_html_mail.php +++ b/trunk/includes/class/class.LSattr_html_mail.php @@ -27,26 +27,7 @@ */ class LSattr_html_mail extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('mail', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'mail'; } diff --git a/trunk/includes/class/class.LSattr_html_rss.php b/trunk/includes/class/class.LSattr_html_rss.php index 6f505427..924ea0cb 100644 --- a/trunk/includes/class/class.LSattr_html_rss.php +++ b/trunk/includes/class/class.LSattr_html_rss.php @@ -27,26 +27,7 @@ */ class LSattr_html_rss extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('rss', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'rss'; } diff --git a/trunk/includes/class/class.LSattr_html_ssh_key.php b/trunk/includes/class/class.LSattr_html_ssh_key.php index 1e4d4dde..56b3cbeb 100644 --- a/trunk/includes/class/class.LSattr_html_ssh_key.php +++ b/trunk/includes/class/class.LSattr_html_ssh_key.php @@ -27,27 +27,7 @@ */ class LSattr_html_ssh_key extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('ssh_key', $this -> name, $this -> config['label'], $this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'ssh_key'; } diff --git a/trunk/includes/class/class.LSattr_html_text.php b/trunk/includes/class/class.LSattr_html_text.php index 80984768..f84a6927 100644 --- a/trunk/includes/class/class.LSattr_html_text.php +++ b/trunk/includes/class/class.LSattr_html_text.php @@ -27,26 +27,7 @@ */ class LSattr_html_text extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('text', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'text'; } diff --git a/trunk/includes/class/class.LSattr_html_textarea.php b/trunk/includes/class/class.LSattr_html_textarea.php index 6f052f53..e7b1830a 100644 --- a/trunk/includes/class/class.LSattr_html_textarea.php +++ b/trunk/includes/class/class.LSattr_html_textarea.php @@ -27,27 +27,7 @@ */ class LSattr_html_textarea extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('textarea', $this -> name, $this -> config['label'], $this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'textarea'; } diff --git a/trunk/includes/class/class.LSattr_html_url.php b/trunk/includes/class/class.LSattr_html_url.php index b7ba0ada..787965c7 100644 --- a/trunk/includes/class/class.LSattr_html_url.php +++ b/trunk/includes/class/class.LSattr_html_url.php @@ -27,26 +27,7 @@ */ class LSattr_html_url extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('url', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'url'; } diff --git a/trunk/includes/class/class.LSattr_html_xmpp.php b/trunk/includes/class/class.LSattr_html_xmpp.php index b14b256c..f5731420 100644 --- a/trunk/includes/class/class.LSattr_html_xmpp.php +++ b/trunk/includes/class/class.LSattr_html_xmpp.php @@ -27,26 +27,7 @@ */ class LSattr_html_xmpp extends LSattr_html { - /** - * Ajoute l'attribut au formualaire passer en paramètre - * - * @param[in] &$form LSform Le formulaire - * @param[in] $idForm L'identifiant du formulaire - * @param[in] $data Valeur du champs du formulaire - * - * @retval LSformElement L'element du formulaire ajouté - */ - function addToForm (&$form,$idForm,$data=NULL) { - $element=$form -> addElement('xmpp', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - $GLOBALS['LSerror'] -> addErrorCode(206,$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - return $element; - } + var $LSformElement_type = 'xmpp'; }