- LSformElement :

-> Suppression des méthodes :
    - getTitle()
    - getMultipleData()
    - displayLabel()
- LSformElement_select_objet
  -> Refonte avec utilisation des templates
This commit is contained in:
Benjamin Renard 2008-10-16 15:35:20 +00:00
parent 63ee400598
commit 6cbdccbec2
5 changed files with 39 additions and 66 deletions

View file

@ -179,21 +179,6 @@ class LSformElement {
return $this -> _required;
}
/**
* Affiche le label de l'élement
*
* @retval void
*/
function displayLabel() {
if ($this -> isRequired()) {
$required=" <span class='required_elements'>*</span>";
}
else {
$required="";
}
echo "\t\t<td>".$this -> getLabel()."$required</td>\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 "<img src='".LS_IMAGES_DIR."/add.png' id='LSform_add_field_btn_".$this -> name."_".rand()."' class='LSform-add-field-btn' alt='"._('Ajouter')."'/><img src='".LS_IMAGES_DIR."/remove.png' class='LSform-remove-field-btn' alt='"._('Supprimer')."'/>";
}
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
*

View file

@ -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;
}
$GLOBALS['LSsession'] -> addJSconfigParam(
$this -> name,
array(
'object_type' => $this -> selectableObject,
'addBtn' => _('Modifier'),
'deleteBtns' => _('Supprimer'),
'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']="<ul class='LSform LSformElement_select_object' id='$ul_id'>\n";
if (empty($this -> values)) {
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value => $txt) {
$return['html'].="<li><a href='view.php?LSobject=".$this -> selectableObject."&amp;dn=".$value."' title='"._('Voir')." ' class='LSformElement_select_object'>".$txt."</a><input type='hidden' class='LSformElement_select_object' name='".$this -> name."[]' value='".$value."' /></li>\n";
}
}
$return['html'].="</ul>\n";
if (!$this -> isFreeze()) {
$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;
}

View file

@ -2,12 +2,11 @@ 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();
}
}
},
initializeLSformElement_select_object: function() {
@ -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');
}

View file

@ -0,0 +1,7 @@
<ul class='LSform LSformElement_select_object' id='{$attr_name}'>
{foreach from=$values item=txt key=dn}
<li>{include file=$fieldTemplate}</li>
{foreachelse}
<li>{include file=$fieldTemplate}</li>
{/foreach}
</ul>

View file

@ -0,0 +1,9 @@
{if $freeze}
{if $dn}
<a href='view.php?LSobject={$selectableObject}&amp;dn={$dn}' class='LSformElement_select_object'>{$txt}</a>
{else}
{$noValueTxt}
{/if}
{else}
<a href='view.php?LSobject={$selectableObject}&amp;dn={$dn}' class='LSformElement_select_object'>{$txt}</a><input type='hidden' class='LSformElement_select_object' name='{$attr_name}[]' value='{$dn}' />
{/if}