mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- LSformElement_date
-> Refonte en utilisant les templates - LSformElement_ssh_key -> Correction du fieldTemplate qui ne prévoyait pas une valeur vide
This commit is contained in:
parent
7ee28a4a78
commit
f5bfa2e5e3
4 changed files with 26 additions and 57 deletions
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
class LSformElement_date extends LSformElement {
|
class LSformElement_date extends LSformElement {
|
||||||
|
|
||||||
|
var $fieldTemplate = 'LSformElement_date_field.tpl';
|
||||||
|
|
||||||
var $_php2js_format = array(
|
var $_php2js_format = array(
|
||||||
"a" => "a",
|
"a" => "a",
|
||||||
"A" => "A",
|
"A" => "A",
|
||||||
|
@ -132,18 +134,12 @@ class LSformElement_date extends LSformElement {
|
||||||
$return = $this -> getLabelInfos();
|
$return = $this -> getLabelInfos();
|
||||||
// value
|
// value
|
||||||
if (!$this -> isFreeze()) {
|
if (!$this -> isFreeze()) {
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
$params = array(
|
||||||
if (empty($this -> values)) {
|
'format' => $this -> php2js_format($this -> getFormat()),
|
||||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
'firstDayOfWeek' => $this -> getFirstDayOfWeek()
|
||||||
}
|
);
|
||||||
else {
|
$GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$params);
|
||||||
foreach ($this -> values as $value) {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
$id = "LSform_".$this -> name."_".rand();
|
|
||||||
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>".$this -> getBtnHTML().$multiple."</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addCssFile('theme.css',LS_LIB_DIR.'jscalendar/skins/aqua/');
|
$GLOBALS['LSsession'] -> addCssFile('theme.css',LS_LIB_DIR.'jscalendar/skins/aqua/');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('calendar.js',LS_LIB_DIR.'jscalendar/');
|
$GLOBALS['LSsession'] -> addJSscript('calendar.js',LS_LIB_DIR.'jscalendar/');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('calendar-en.js',LS_LIB_DIR.'jscalendar/lang/');
|
$GLOBALS['LSsession'] -> addJSscript('calendar-en.js',LS_LIB_DIR.'jscalendar/lang/');
|
||||||
|
@ -152,44 +148,9 @@ class LSformElement_date extends LSformElement {
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date_field.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date_field.js');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_date.js');
|
||||||
}
|
}
|
||||||
else {
|
$return['html'] = $this -> fetchTemplate();
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
|
||||||
if (empty($this -> values)) {
|
|
||||||
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($this -> values as $value) {
|
|
||||||
$return['html'] .= "<li>".$value."</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
}
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourne le code HTML d'un champ vide
|
|
||||||
*
|
|
||||||
* @retval string Code HTML d'un champ vide.
|
|
||||||
*/
|
|
||||||
function getEmptyField() {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$this -> getBtnHTML().$multiple;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Retour le code HTML du bouton
|
|
||||||
*
|
|
||||||
* @retval string Code HTML du bouton
|
|
||||||
*/
|
|
||||||
function getBtnHTML() {
|
|
||||||
$id = "LSformElement_data_calendar_btn_".rand();
|
|
||||||
$params = array(
|
|
||||||
'format' => $this -> php2js_format($this -> getFormat()),
|
|
||||||
'firstDayOfWeek' => $this -> getFirstDayOfWeek()
|
|
||||||
);
|
|
||||||
$GLOBALS['LSsession'] -> addJSconfigParam($id,$params);
|
|
||||||
return "<img id='$id' class='LSformElement_date_calendar_btn btn' src='".LS_IMAGES_DIR."/calendar.png' title='"._('Calendrier')."' alt='"._('Calendrier')."'/>";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne le nurméro du premier jour de la semaine
|
* Retourne le nurméro du premier jour de la semaine
|
||||||
|
|
|
@ -2,17 +2,19 @@ var LSformElement_date = new Class({
|
||||||
initialize: function(){
|
initialize: function(){
|
||||||
this.fields = [];
|
this.fields = [];
|
||||||
this.initialiseLSformElement_date();
|
this.initialiseLSformElement_date();
|
||||||
if (typeof(varLSform) != "undefined") {
|
if ($type(varLSform)) {
|
||||||
varLSform.addModule("LSformElement_date",this);
|
varLSform.addModule("LSformElement_date",this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
initialiseLSformElement_date: function(el) {
|
initialiseLSformElement_date: function(el) {
|
||||||
if (typeof(el) == 'undefined') {
|
if (!$type(el)) {
|
||||||
el = document;
|
el = document;
|
||||||
}
|
}
|
||||||
el.getElements('img.LSformElement_date_calendar_btn').each(function(btn) {
|
var getName = /^(.*)\[\]$/
|
||||||
this.fields[btn.id] = new LSformElement_date_field(btn);
|
el.getElements('input.LSformElement_date').each(function(input) {
|
||||||
|
var name = getName.exec(input.name)[1];
|
||||||
|
this.fields[name] = new LSformElement_date_field(name,input);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
var LSformElement_date_field = new Class({
|
var LSformElement_date_field = new Class({
|
||||||
initialize: function(calendarBtn){
|
initialize: function(name,input){
|
||||||
this.calendarBtn = calendarBtn;
|
this.name = name;
|
||||||
|
this.input = input;
|
||||||
|
this.calendarBtn = new Element('img');
|
||||||
|
this.calendarBtn.src = varLSdefault.imagePath('calendar.png');
|
||||||
|
this.calendarBtn.addClass('btn');
|
||||||
this.calendarBtn.addEvent('click',this.onCalendarBtnClick.bind(this));
|
this.calendarBtn.addEvent('click',this.onCalendarBtnClick.bind(this));
|
||||||
|
this.calendarBtn.injectAfter(this.input);
|
||||||
|
|
||||||
// Récupération des paramètres à partir de l'attribut 'rem' du bouton
|
// Récupération des paramètres à partir de l'attribut 'rem' du bouton
|
||||||
this.params = varLSdefault.LSjsConfig[this.calendarBtn.id];
|
this.params = varLSdefault.LSjsConfig[this.name];
|
||||||
if (!$type(this.params)) {
|
if (!$type(this.params)) {
|
||||||
this.params={};
|
this.params={};
|
||||||
}
|
}
|
||||||
|
@ -15,7 +20,6 @@ var LSformElement_date_field = new Class({
|
||||||
this.params.firstDayOfWeek=0;
|
this.params.firstDayOfWeek=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.input = calendarBtn.getParent().getFirst();
|
|
||||||
this.input.addEvent('click',this.onCalendarBtnClick.bind(this));
|
this.input.addEvent('click',this.onCalendarBtnClick.bind(this));
|
||||||
|
|
||||||
this.date = Date.parseDate(this.input.value,this.params.format);
|
this.date = Date.parseDate(this.input.value,this.params.format);
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
{if $freeze}
|
{if $freeze}
|
||||||
{if $value.type}
|
{if $value.type}
|
||||||
<span class='LSformElement_ssh_key_short_display' title='{$span_title}'>{$value.shortTxt}...</span> (Type : {$value.type}) <a href='mailto:{$value.mail}'>{$value.mail}</a><p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
<span class='LSformElement_ssh_key_short_display' title='{$span_title}'>{$value.shortTxt}...</span> (Type : {$value.type}) <a href='mailto:{$value.mail}'>{$value.mail}</a><p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
||||||
{else}
|
{elseif $value.shortTxt}
|
||||||
<span class='LSformElement_ssh_key_short_display'>{$value.shortTxt}...</span> ({$unknowTypeTxt})<p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
<span class='LSformElement_ssh_key_short_display'>{$value.shortTxt}...</span> ({$unknowTypeTxt})<p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
||||||
|
{else}
|
||||||
|
{$noValueTxt}
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
<textarea name='{$attr_name}[]' class='LSform LSformElement_ssh_key'>{$value}</textarea>
|
<textarea name='{$attr_name}[]' class='LSform LSformElement_ssh_key'>{$value}</textarea>
|
||||||
|
|
Loading…
Reference in a new issue