mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- LSformElement :
-> Suppression des méthodes : - getTitle() - getMultipleData() - displayLabel() - LSformElement_select_objet -> Refonte avec utilisation des templates
This commit is contained in:
parent
63ee400598
commit
6cbdccbec2
5 changed files with 39 additions and 66 deletions
|
@ -179,21 +179,6 @@ class LSformElement {
|
||||||
return $this -> _required;
|
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
|
* 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() {
|
function isMultiple() {
|
||||||
return ($this -> params['multiple'] == true);
|
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
|
* Retournne un template Smarty compilé dans le contexte d'un LSformElement
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
|
|
||||||
class LSformElement_select_object extends LSformElement {
|
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
|
* 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();
|
$this -> values = $this -> attr_html -> getValuesFromSession();
|
||||||
}
|
}
|
||||||
$return = $this -> getLabelInfos();
|
$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']="<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."&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()) {
|
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_field.js');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_select_object.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_select_object.js');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
||||||
|
@ -80,7 +69,9 @@ class LSformElement_select_object extends LSformElement {
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js');
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css');
|
$GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$return['html'] = $this -> fetchTemplate(NULL,array('selectableObject' => $this -> selectableObject));
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,10 @@ var LSformElement_select_object_field = new Class({
|
||||||
initialize: function(ul){
|
initialize: function(ul){
|
||||||
this.ul=ul;
|
this.ul=ul;
|
||||||
this.dd=ul.getParent();
|
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 ($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 = {
|
var data = {
|
||||||
template: 'LSform',
|
template: 'LSform',
|
||||||
action: 'refreshField',
|
action: 'refreshField',
|
||||||
attribute: this.params['attr_name'],
|
attribute: this.name,
|
||||||
objecttype: $('LSform_objecttype').value,
|
objecttype: $('LSform_objecttype').value,
|
||||||
objectdn: $('LSform_objectdn').value,
|
objectdn: $('LSform_objectdn').value,
|
||||||
idform: $('LSform_idform').value
|
idform: $('LSform_idform').value
|
||||||
|
@ -119,7 +118,7 @@ var LSformElement_select_object_field = new Class({
|
||||||
var a = li.getFirst('a');
|
var a = li.getFirst('a');
|
||||||
var input = li.getFirst('input');
|
var input = li.getFirst('input');
|
||||||
if (a.hasClass('LSformElement_select_object_deleted')) {
|
if (a.hasClass('LSformElement_select_object_deleted')) {
|
||||||
input.name=this.params['attr_name']+'[]';
|
input.name=this.name+'[]';
|
||||||
a.addClass('LSformElement_select_object');
|
a.addClass('LSformElement_select_object');
|
||||||
a.removeClass('LSformElement_select_object_deleted');
|
a.removeClass('LSformElement_select_object_deleted');
|
||||||
}
|
}
|
||||||
|
|
7
trunk/templates/default/LSformElement_select_object.tpl
Normal file
7
trunk/templates/default/LSformElement_select_object.tpl
Normal 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>
|
|
@ -0,0 +1,9 @@
|
||||||
|
{if $freeze}
|
||||||
|
{if $dn}
|
||||||
|
<a href='view.php?LSobject={$selectableObject}&dn={$dn}' class='LSformElement_select_object'>{$txt}</a>
|
||||||
|
{else}
|
||||||
|
{$noValueTxt}
|
||||||
|
{/if}
|
||||||
|
{else}
|
||||||
|
<a href='view.php?LSobject={$selectableObject}&dn={$dn}' class='LSformElement_select_object'>{$txt}</a><input type='hidden' class='LSformElement_select_object' name='{$attr_name}[]' value='{$dn}' />
|
||||||
|
{/if}
|
Loading…
Reference in a new issue