From 6cbdccbec2e5ffde072f844f2e32a1c3f91759f9 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 16 Oct 2008 15:35:20 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=20:=20=20=20->=20Suppression?= =?UTF-8?q?=20des=20m=C3=A9thodes=20:=20=20=20=20=20-=20getTitle()=20=20?= =?UTF-8?q?=20=20=20-=20getMultipleData()=20=20=20=20=20-=20displayLabel()?= =?UTF-8?q?=20-=20LSformElement=5Fselect=5Fobjet=20=20=20->=20Refonte=20av?= =?UTF-8?q?ec=20utilisation=20des=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSformElement.php | 37 +---------------- .../class.LSformElement_select_object.php | 41 ++++++++----------- .../js/LSformElement_select_object_field.js | 11 +++-- .../default/LSformElement_select_object.tpl | 7 ++++ .../LSformElement_select_object_field.tpl | 9 ++++ 5 files changed, 39 insertions(+), 66 deletions(-) create mode 100644 trunk/templates/default/LSformElement_select_object.tpl create mode 100644 trunk/templates/default/LSformElement_select_object_field.tpl diff --git a/trunk/includes/class/class.LSformElement.php b/trunk/includes/class/class.LSformElement.php index 31f63544..bbdbe00d 100644 --- a/trunk/includes/class/class.LSformElement.php +++ b/trunk/includes/class/class.LSformElement.php @@ -179,21 +179,6 @@ class LSformElement { return $this -> _required; } - /** - * Affiche le label de l'élement - * - * @retval void - */ - function displayLabel() { - if ($this -> isRequired()) { - $required=" *"; - } - else { - $required=""; - } - echo "\t\t".$this -> getLabel()."$required\n"; - } - /** * Retourne le label de l'élement * @@ -262,32 +247,14 @@ class LSformElement { } /** - * Retourne l'HTML pour les boutons d'ajout et de suppression de champs du formulaire LSform + * Le champ est-il a valeur multiple * - * @retval string Le code HTML des boutons + * @retval boolean True si le champ est à valeur multiple, False sinon */ - function getMultipleData() { - if ($this -> params['multiple'] == true ) { - return ""._("._("; - } - else { - return ''; - } - } - function isMultiple() { return ($this -> params['multiple'] == true); } - /** - * Retourne le titre du champ - * - * @retval string Titre du champ - **/ - function getTitle() { - return $this -> form -> ldapObject -> getDisplayValue().' - '.$this -> getLabel(); - } - /** * Retournne un template Smarty compilé dans le contexte d'un LSformElement * diff --git a/trunk/includes/class/class.LSformElement_select_object.php b/trunk/includes/class/class.LSformElement_select_object.php index c415c3cf..694a49ed 100644 --- a/trunk/includes/class/class.LSformElement_select_object.php +++ b/trunk/includes/class/class.LSformElement_select_object.php @@ -32,6 +32,9 @@ class LSformElement_select_object extends LSformElement { + var $fieldTemplate = 'LSformElement_select_object_field.tpl'; + var $template = 'LSformElement_select_object.tpl'; + /** * Retourn les infos d'affichage de l'élément * @@ -45,32 +48,18 @@ class LSformElement_select_object extends LSformElement { $this -> values = $this -> attr_html -> getValuesFromSession(); } $return = $this -> getLabelInfos(); - // value - - $params=array(); - if (!$this -> isFreeze()) { - $params['attr_name'] = $this -> name; - $params['object_type'] = $this -> selectableObject; - $params['addBtn'] = _('Modifier'); - $params['deleteBtns'] = _('Supprimer'); - $params['multiple'] = ($this -> params['multiple'])?1:0; - } - - $ul_id="LSformElement_select_object_".$this -> name; - $params['freeze'] = $this -> isFreeze(); - $GLOBALS['LSsession'] -> addJSconfigParam($ul_id,$params); - - $return['html']="\n"; + if (!$this -> isFreeze()) { + $GLOBALS['LSsession'] -> addJSconfigParam( + $this -> name, + array( + 'object_type' => $this -> selectableObject, + 'addBtn' => _('Modifier'), + 'deleteBtns' => _('Supprimer'), + 'multiple' => (($this -> params['multiple'])?1:0) + ) + ); + $GLOBALS['LSsession'] -> addJSscript('LSformElement_select_object_field.js'); $GLOBALS['LSsession'] -> addJSscript('LSformElement_select_object.js'); $GLOBALS['LSsession'] -> addJSscript('LSform.js'); @@ -80,7 +69,9 @@ class LSformElement_select_object extends LSformElement { $GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css'); $GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js'); $GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css'); + } + $return['html'] = $this -> fetchTemplate(NULL,array('selectableObject' => $this -> selectableObject)); return $return; } diff --git a/trunk/includes/js/LSformElement_select_object_field.js b/trunk/includes/js/LSformElement_select_object_field.js index 47f4501a..f62a95de 100644 --- a/trunk/includes/js/LSformElement_select_object_field.js +++ b/trunk/includes/js/LSformElement_select_object_field.js @@ -2,11 +2,10 @@ var LSformElement_select_object_field = new Class({ initialize: function(ul){ this.ul=ul; this.dd=ul.getParent(); - this.params = varLSdefault.LSjsConfig[ul.id]; + this.name = ul.id; + this.params = varLSdefault.LSjsConfig[this.name]; if ($type(this.params)) { - if (!this.params.freeze) { - this.initializeLSformElement_select_object(); - } + this.initializeLSformElement_select_object(); } }, @@ -97,7 +96,7 @@ var LSformElement_select_object_field = new Class({ var data = { template: 'LSform', action: 'refreshField', - attribute: this.params['attr_name'], + attribute: this.name, objecttype: $('LSform_objecttype').value, objectdn: $('LSform_objectdn').value, idform: $('LSform_idform').value @@ -119,7 +118,7 @@ var LSformElement_select_object_field = new Class({ var a = li.getFirst('a'); var input = li.getFirst('input'); if (a.hasClass('LSformElement_select_object_deleted')) { - input.name=this.params['attr_name']+'[]'; + input.name=this.name+'[]'; a.addClass('LSformElement_select_object'); a.removeClass('LSformElement_select_object_deleted'); } diff --git a/trunk/templates/default/LSformElement_select_object.tpl b/trunk/templates/default/LSformElement_select_object.tpl new file mode 100644 index 00000000..570411ec --- /dev/null +++ b/trunk/templates/default/LSformElement_select_object.tpl @@ -0,0 +1,7 @@ + diff --git a/trunk/templates/default/LSformElement_select_object_field.tpl b/trunk/templates/default/LSformElement_select_object_field.tpl new file mode 100644 index 00000000..2bd555db --- /dev/null +++ b/trunk/templates/default/LSformElement_select_object_field.tpl @@ -0,0 +1,9 @@ +{if $freeze} + {if $dn} + {$txt} + {else} + {$noValueTxt} + {/if} +{else} + {$txt} +{/if}