mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-16 15:33:02 +01:00
- LSformElement_xmpp & LSformElement_url & LSformElement_rss
-> Refonte avec l'utilisation de l'héritage de LSformElement_text -> Utilisation d'un fieldTemplate commum : LSformElement_uri_field.tpl - LSformElement_mail -> Utilisation du fieldTemplate commum : LSformElement_uri_field.tpl - LSformElement : Ajout du paramètre $fetchVariables qui contient les variables ajouter au contexte de la méthode fetchTemplate()
This commit is contained in:
parent
cc0a009b63
commit
f691db17c3
10 changed files with 56 additions and 161 deletions
|
@ -40,6 +40,7 @@ class LSformElement {
|
||||||
var $attr_html;
|
var $attr_html;
|
||||||
var $fieldTemplate = 'LSformElement_field.tpl';
|
var $fieldTemplate = 'LSformElement_field.tpl';
|
||||||
var $template = 'LSformElement.tpl';
|
var $template = 'LSformElement.tpl';
|
||||||
|
var $fetchVariables = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
|
@ -303,6 +304,7 @@ class LSformElement {
|
||||||
$template,
|
$template,
|
||||||
array_merge_recursive(
|
array_merge_recursive(
|
||||||
$variables,
|
$variables,
|
||||||
|
$this -> fetchVariables,
|
||||||
array(
|
array(
|
||||||
'freeze' => $this -> isFreeze(),
|
'freeze' => $this -> isFreeze(),
|
||||||
'multiple'=> $this -> isMultiple(),
|
'multiple'=> $this -> isMultiple(),
|
||||||
|
|
|
@ -42,7 +42,13 @@ class LSformElement_mail extends LSformElement_text {
|
||||||
'LSsmoothbox.css',
|
'LSsmoothbox.css',
|
||||||
'LSconfirmBox.css'
|
'LSconfirmBox.css'
|
||||||
);
|
);
|
||||||
var $fieldTemplate = 'LSformElement_mail_field.tpl';
|
|
||||||
|
var $fetchVariables = array(
|
||||||
|
'uriClass' => 'LSformElement_mail',
|
||||||
|
'uriPrefix' => 'mailto:'
|
||||||
|
);
|
||||||
|
|
||||||
|
var $fieldTemplate = 'LSformElement_uri_field.tpl';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -30,58 +30,17 @@
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LSformElement_rss extends LSformElement {
|
class LSformElement_rss extends LSformElement_text {
|
||||||
|
|
||||||
/**
|
var $JSscripts = array(
|
||||||
* Retourne les infos d'affichage de l'élément
|
'LSformElement_rss.js'
|
||||||
*
|
);
|
||||||
* Cette méthode retourne les informations d'affichage de l'élement
|
var $fetchVariables = array(
|
||||||
*
|
'uriClass' => 'LSformElement_rss'
|
||||||
* @retval array
|
);
|
||||||
*/
|
|
||||||
function getDisplay(){
|
var $fieldTemplate = 'LSformElement_uri_field.tpl';
|
||||||
$return = $this -> getLabelInfos();
|
|
||||||
// value
|
|
||||||
if (!$this -> isFreeze()) {
|
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
|
||||||
if (empty($this -> values)) {
|
|
||||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($this -> values as $value) {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
$id = "LSform_".$this -> name."_".rand();
|
|
||||||
$return['html'] .= "<li><input class='LSformElement_rss' type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>$multiple</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_rss.js');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$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><a class='LSformElement_rss' href='".$value."'>".$value."</a></li>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_rss.js');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
}
|
|
||||||
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 class='LSformElement_rss' type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$multiple;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -30,58 +30,17 @@
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LSformElement_url extends LSformElement {
|
class LSformElement_url extends LSformElement_text {
|
||||||
|
|
||||||
/**
|
var $JSscripts = array(
|
||||||
* Retourne les infos d'affichage de l'élément
|
'LSformElement_url.js'
|
||||||
*
|
);
|
||||||
* Cette méthode retourne les informations d'affichage de l'élement
|
|
||||||
*
|
|
||||||
* @retval array
|
|
||||||
*/
|
|
||||||
function getDisplay(){
|
|
||||||
$return = $this -> getLabelInfos();
|
|
||||||
// value
|
|
||||||
if (!$this -> isFreeze()) {
|
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
|
||||||
if (empty($this -> values)) {
|
|
||||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($this -> values as $value) {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
$id = "LSform_".$this -> name."_".rand();
|
|
||||||
$return['html'] .= "<li><input class='LSformElement_url' type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."' title=\"".$this -> getTitle()."\">$multiple</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_url.js');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$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><a class='LSformElement_url' href='".$value."' title=\"".$this -> getTitle()."\">".$value."</a></li>\n";
|
|
||||||
}
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_url.js');
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
}
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
var $fetchVariables = array(
|
||||||
* Retourne le code HTML d'un champ vide
|
'uriClass' => 'LSformElement_url'
|
||||||
*
|
);
|
||||||
* @retval string Code HTML d'un champ vide.
|
|
||||||
*/
|
var $fieldTemplate = 'LSformElement_uri_field.tpl';
|
||||||
function getEmptyField() {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
return "<input class='LSformElement_url' type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."' title=\"".$this -> getTitle()."\">".$multiple;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,58 +30,17 @@
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LSformElement_xmpp extends LSformElement {
|
class LSformElement_xmpp extends LSformElement_text {
|
||||||
|
var $JSscripts = array(
|
||||||
|
'LSformElement_xmpp.js'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
var $fetchVariables = array(
|
||||||
* Retourne les infos d'affichage de l'élément
|
'uriClass' => 'LSformElement_xmpp',
|
||||||
*
|
'uriPrefix' => 'xmpp:'
|
||||||
* Cette méthode retourne les informations d'affichage de l'élement
|
);
|
||||||
*
|
|
||||||
* @retval array
|
|
||||||
*/
|
|
||||||
function getDisplay(){
|
|
||||||
$return = $this -> getLabelInfos();
|
|
||||||
// value
|
|
||||||
if (!$this -> isFreeze()) {
|
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
|
||||||
if (empty($this -> values)) {
|
|
||||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($this -> values as $value) {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
$id = "LSform_".$this -> name."_".rand();
|
|
||||||
$return['html'] .= "<li><input class='LSformElement_xmpp' type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>$multiple</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$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><a class='LSformElement_xmpp' href='xmpp:".$value."'>".$value."</a></li>\n";
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return['html'] .= "</ul>\n";
|
|
||||||
}
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
var $fieldTemplate = 'LSformElement_uri_field.tpl';
|
||||||
* Retourne le code HTML d'un champ vide
|
|
||||||
*
|
|
||||||
* @retval string Code HTML d'un champ vide.
|
|
||||||
*/
|
|
||||||
function getEmptyField() {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
return "<input class='LSformElement_xmpp' type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$multiple;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -31,6 +31,7 @@ var LSformElement_rss = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
reinitialize: function(el) {
|
reinitialize: function(el) {
|
||||||
|
varLSform.initializeModule('LSformElement_text',el);
|
||||||
this.initialiseLSformElement_rss(el);
|
this.initialiseLSformElement_rss(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ var LSformElement_url = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
reinitialize: function(el) {
|
reinitialize: function(el) {
|
||||||
|
varLSform.initializeModule('LSformElement_text',el);
|
||||||
this.initialiseLSformElement_url(el);
|
this.initialiseLSformElement_url(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -59,8 +60,8 @@ var LSformElement_url = new Class({
|
||||||
if (typeof(href)=="undefined") {
|
if (typeof(href)=="undefined") {
|
||||||
href = btn.getParent().getFirst().href;
|
href = btn.getParent().getFirst().href;
|
||||||
}
|
}
|
||||||
var name = btn.getParent().getFirst().title;
|
|
||||||
if (href!="") {
|
if (href!="") {
|
||||||
|
var name = href;
|
||||||
if (window.sidebar) {
|
if (window.sidebar) {
|
||||||
window.sidebar.addPanel(name,href,'');
|
window.sidebar.addPanel(name,href,'');
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ var LSformElement_xmpp = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
reinitialize: function(el) {
|
reinitialize: function(el) {
|
||||||
|
varLSform.initializeModule('LSformElement_text',el);
|
||||||
this.initialiseLSformElement_xmpp(el);
|
this.initialiseLSformElement_xmpp(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{if $freeze}
|
|
||||||
<span class='LSformElement_text'>{if $value}<a class='LSformElement_mail' href='mailto:{$value}'>{$value}</a>{else}{$noValueTxt}{/if}</span><input type='hidden' name='{$attr_name}[]' class='LSformElement_text' value="{$value}"/>
|
|
||||||
{else}
|
|
||||||
<input type='text' name='{$attr_name}[]' class='LSformElement_text LSformElement_mail' value="{$value}"/>
|
|
||||||
{/if}
|
|
12
trunk/templates/default/LSformElement_uri_field.tpl
Normal file
12
trunk/templates/default/LSformElement_uri_field.tpl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{if $freeze}
|
||||||
|
<span class='LSformElement_text'>
|
||||||
|
{if $value}
|
||||||
|
<a class='{$uriClass}' href='{$uriPrefix}{$value}'>{$value}</a>
|
||||||
|
{else}
|
||||||
|
{$noValueTxt}
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
<input type='hidden' name='{$attr_name}[]' class='LSformElement_text' value="{$value}"/>
|
||||||
|
{else}
|
||||||
|
<input type='text' name='{$attr_name}[]' class='LSformElement_text {$uriClass}' value="{$value}"/>
|
||||||
|
{/if}
|
Loading…
Reference in a new issue