2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
24 * Base d'un type d'attribut HTML
26 * @author Benjamin Renard <brenard@easter-eggs.com>
33 var $LSformElement_type = false;
38 * Cette methode construit l'objet et définis la configuration.
40 * @author Benjamin Renard <brenard@easter-eggs.com>
42 * @param[in] $name string Nom de l'attribut ldap
43 * @param[in] $config array Configuration de l'objet
44 * @param[in] &$attribute LSattribute L'objet LSattribut parent
46 * @retval boolean Retourne true.
48 function LSattr_html ($name,$config,&$attribute) {
49 $this -> name = $name;
50 $this -> config = $config;
51 $this -> attribute = $attribute;
56 * Retourne le label de l'attribut
58 * Retourne le label de l'attribut ou son nom si aucun label n'est défini
59 * dans la configuration.
61 * @retval string Le label de l'attribut.
64 if ( $this -> config['label'] != '' ) {
65 return __($this -> config['label']);
68 return __($this -> name);
73 * Ajoute l'attribut au formualaire passer en paramètre
75 * @param[in] &$form LSform Le formulaire
76 * @param[in] $idForm L'identifiant du formulaire
77 * @param[in] $data Valeur du champs du formulaire
79 * @retval LSformElement L'element du formulaire ajouté
81 function addToForm (&$form,$idForm,$data=NULL) {
82 if (!$this -> LSformElement_type) {
83 LSerror :: addErrorCode('LSattr_html_01',$this -> name);
86 $element=$form -> addElement($this -> LSformElement_type, $this -> name, $this -> config['label'],$this -> config, $this);
88 LSerror :: addErrorCode('LSform_06',$this -> name);
92 $element -> setValue($data);
98 * Effectue les tâches nécéssaires au moment du rafraichissement du formulaire
100 * @param[in] $data mixed La valeur de l'attribut
102 * @retval mixed La valeur formatée de l'attribut
104 function refreshForm($data) {
112 LSerror :: defineError('LSattr_html_01',
113 _("LSattr_html : The method addToForm() of the HTML type of the attribute %{attr} is not defined.")
116 LSerror :: defineError('LSattr_html_03',
117 _("LSattr_html_%{type} : Multiple data are not supported for this field type.")