From f691db17c33e77e2c96fe3f0b75ad45e4f25a0da Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 15 Oct 2008 18:29:14 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Fxmpp=20&=20LSformElement=5F?= =?UTF-8?q?url=20&=20LSformElement=5Frss=20=20=20->=20Refonte=20avec=20l'u?= =?UTF-8?q?tilisation=20de=20l'h=C3=A9ritage=20de=20LSformElement=5Ftext?= =?UTF-8?q?=20=20=20->=20Utilisation=20d'un=20fieldTemplate=20commum=20:?= =?UTF-8?q?=20LSformElement=5Furi=5Ffield.tpl=20-=20LSformElement=5Fmail?= =?UTF-8?q?=20=20=20->=20Utilisation=20du=20fieldTemplate=20commum=20:=20L?= =?UTF-8?q?SformElement=5Furi=5Ffield.tpl=20-=20LSformElement=20:=20Ajout?= =?UTF-8?q?=20du=20param=C3=A8tre=20$fetchVariables=20qui=20contient=20les?= =?UTF-8?q?=20variables=20=20=20ajouter=20au=20contexte=20de=20la=20m?= =?UTF-8?q?=C3=A9thode=20fetchTemplate()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSformElement.php | 2 + .../class/class.LSformElement_mail.php | 8 ++- .../class/class.LSformElement_rss.php | 61 +++--------------- .../class/class.LSformElement_url.php | 61 +++--------------- .../class/class.LSformElement_xmpp.php | 63 ++++--------------- trunk/includes/js/LSformElement_rss.js | 1 + trunk/includes/js/LSformElement_url.js | 3 +- trunk/includes/js/LSformElement_xmpp.js | 1 + .../default/LSformElement_mail_field.tpl | 5 -- .../default/LSformElement_uri_field.tpl | 12 ++++ 10 files changed, 56 insertions(+), 161 deletions(-) delete mode 100644 trunk/templates/default/LSformElement_mail_field.tpl create mode 100644 trunk/templates/default/LSformElement_uri_field.tpl diff --git a/trunk/includes/class/class.LSformElement.php b/trunk/includes/class/class.LSformElement.php index c4a3af89..31f63544 100644 --- a/trunk/includes/class/class.LSformElement.php +++ b/trunk/includes/class/class.LSformElement.php @@ -40,6 +40,7 @@ class LSformElement { var $attr_html; var $fieldTemplate = 'LSformElement_field.tpl'; var $template = 'LSformElement.tpl'; + var $fetchVariables = array(); /** * Constructeur @@ -303,6 +304,7 @@ class LSformElement { $template, array_merge_recursive( $variables, + $this -> fetchVariables, array( 'freeze' => $this -> isFreeze(), 'multiple'=> $this -> isMultiple(), diff --git a/trunk/includes/class/class.LSformElement_mail.php b/trunk/includes/class/class.LSformElement_mail.php index bc978d4c..f47cb6c6 100644 --- a/trunk/includes/class/class.LSformElement_mail.php +++ b/trunk/includes/class/class.LSformElement_mail.php @@ -42,7 +42,13 @@ class LSformElement_mail extends LSformElement_text { 'LSsmoothbox.css', 'LSconfirmBox.css' ); - var $fieldTemplate = 'LSformElement_mail_field.tpl'; + + var $fetchVariables = array( + 'uriClass' => 'LSformElement_mail', + 'uriPrefix' => 'mailto:' + ); + + var $fieldTemplate = 'LSformElement_uri_field.tpl'; } ?> diff --git a/trunk/includes/class/class.LSformElement_rss.php b/trunk/includes/class/class.LSformElement_rss.php index 53152992..c46ff8f3 100644 --- a/trunk/includes/class/class.LSformElement_rss.php +++ b/trunk/includes/class/class.LSformElement_rss.php @@ -30,58 +30,17 @@ * @author Benjamin Renard */ -class LSformElement_rss extends LSformElement { +class LSformElement_rss extends LSformElement_text { - /** - * Retourne les infos d'affichage de l'élément - * - * Cette méthode retourne les informations d'affichage de l'élement - * - * @retval array - */ - function getDisplay(){ - $return = $this -> getLabelInfos(); - // value - if (!$this -> isFreeze()) { - $return['html'] = "\n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_rss.js'); - } - else { - $return['html'] = "\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 "".$multiple; - } + var $JSscripts = array( + 'LSformElement_rss.js' + ); + var $fetchVariables = array( + 'uriClass' => 'LSformElement_rss' + ); + + var $fieldTemplate = 'LSformElement_uri_field.tpl'; + } ?> diff --git a/trunk/includes/class/class.LSformElement_url.php b/trunk/includes/class/class.LSformElement_url.php index 7156a17e..f510c3f0 100644 --- a/trunk/includes/class/class.LSformElement_url.php +++ b/trunk/includes/class/class.LSformElement_url.php @@ -30,58 +30,17 @@ * @author Benjamin Renard */ -class LSformElement_url extends LSformElement { +class LSformElement_url extends LSformElement_text { - /** - * Retourne les infos d'affichage de l'élément - * - * Cette méthode retourne les informations d'affichage de l'élement - * - * @retval array - */ - function getDisplay(){ - $return = $this -> getLabelInfos(); - // value - if (!$this -> isFreeze()) { - $return['html'] = "
    \n"; - if (empty($this -> values)) { - $return['html'] .= "
  • ".$this -> getEmptyField()."
  • \n"; - } - else { - foreach ($this -> values as $value) { - $multiple = $this -> getMultipleData(); - $id = "LSform_".$this -> name."_".rand(); - $return['html'] .= "
  • getTitle()."\">$multiple
  • \n"; - } - } - $return['html'] .= "
\n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_url.js'); - } - else { - $return['html'] = "
    \n"; - if (empty($this -> values)) { - $return['html'] .= "
  • "._('Aucune valeur definie')."
  • \n"; - } - else { - foreach ($this -> values as $value) { - $return['html'] .= "
  • getTitle()."\">".$value."
  • \n"; - } - $GLOBALS['LSsession'] -> addJSscript('LSformElement_url.js'); - } - $return['html'] .= "
\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 " getTitle()."\">".$multiple; - } + var $JSscripts = array( + 'LSformElement_url.js' + ); + + var $fetchVariables = array( + 'uriClass' => 'LSformElement_url' + ); + + var $fieldTemplate = 'LSformElement_uri_field.tpl'; } diff --git a/trunk/includes/class/class.LSformElement_xmpp.php b/trunk/includes/class/class.LSformElement_xmpp.php index d61ce4c5..f6a246bc 100644 --- a/trunk/includes/class/class.LSformElement_xmpp.php +++ b/trunk/includes/class/class.LSformElement_xmpp.php @@ -30,58 +30,17 @@ * @author Benjamin Renard */ -class LSformElement_xmpp extends LSformElement { - - /** - * Retourne les infos d'affichage de l'élément - * - * Cette méthode retourne les informations d'affichage de l'élement - * - * @retval array - */ - function getDisplay(){ - $return = $this -> getLabelInfos(); - // value - if (!$this -> isFreeze()) { - $return['html'] = "
    \n"; - if (empty($this -> values)) { - $return['html'] .= "
  • ".$this -> getEmptyField()."
  • \n"; - } - else { - foreach ($this -> values as $value) { - $multiple = $this -> getMultipleData(); - $id = "LSform_".$this -> name."_".rand(); - $return['html'] .= "
  • $multiple
  • \n"; - } - } - $return['html'] .= "
\n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js'); - } - else { - $return['html'] = "
    \n"; - if (empty($this -> values)) { - $return['html'] .= "
  • "._('Aucune valeur definie')."
  • \n"; - } - else { - foreach ($this -> values as $value) { - $return['html'] .= "
  • ".$value."
  • \n"; - $GLOBALS['LSsession'] -> addJSscript('LSformElement_xmpp.js'); - } - } - $return['html'] .= "
\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 "".$multiple; - } +class LSformElement_xmpp extends LSformElement_text { + var $JSscripts = array( + 'LSformElement_xmpp.js' + ); + + var $fetchVariables = array( + 'uriClass' => 'LSformElement_xmpp', + 'uriPrefix' => 'xmpp:' + ); + + var $fieldTemplate = 'LSformElement_uri_field.tpl'; } ?> diff --git a/trunk/includes/js/LSformElement_rss.js b/trunk/includes/js/LSformElement_rss.js index 3423d62f..1c0c728b 100644 --- a/trunk/includes/js/LSformElement_rss.js +++ b/trunk/includes/js/LSformElement_rss.js @@ -31,6 +31,7 @@ var LSformElement_rss = new Class({ }, reinitialize: function(el) { + varLSform.initializeModule('LSformElement_text',el); this.initialiseLSformElement_rss(el); }, diff --git a/trunk/includes/js/LSformElement_url.js b/trunk/includes/js/LSformElement_url.js index afa359fa..da459030 100644 --- a/trunk/includes/js/LSformElement_url.js +++ b/trunk/includes/js/LSformElement_url.js @@ -41,6 +41,7 @@ var LSformElement_url = new Class({ }, reinitialize: function(el) { + varLSform.initializeModule('LSformElement_text',el); this.initialiseLSformElement_url(el); }, @@ -59,8 +60,8 @@ var LSformElement_url = new Class({ if (typeof(href)=="undefined") { href = btn.getParent().getFirst().href; } - var name = btn.getParent().getFirst().title; if (href!="") { + var name = href; if (window.sidebar) { window.sidebar.addPanel(name,href,''); } diff --git a/trunk/includes/js/LSformElement_xmpp.js b/trunk/includes/js/LSformElement_xmpp.js index 32a92ec0..3b50cab4 100644 --- a/trunk/includes/js/LSformElement_xmpp.js +++ b/trunk/includes/js/LSformElement_xmpp.js @@ -31,6 +31,7 @@ var LSformElement_xmpp = new Class({ }, reinitialize: function(el) { + varLSform.initializeModule('LSformElement_text',el); this.initialiseLSformElement_xmpp(el); }, diff --git a/trunk/templates/default/LSformElement_mail_field.tpl b/trunk/templates/default/LSformElement_mail_field.tpl deleted file mode 100644 index 05af6024..00000000 --- a/trunk/templates/default/LSformElement_mail_field.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{if $freeze} -{if $value}{$value}{else}{$noValueTxt}{/if} -{else} - -{/if} diff --git a/trunk/templates/default/LSformElement_uri_field.tpl b/trunk/templates/default/LSformElement_uri_field.tpl new file mode 100644 index 00000000..e30ec28e --- /dev/null +++ b/trunk/templates/default/LSformElement_uri_field.tpl @@ -0,0 +1,12 @@ +{if $freeze} + + {if $value} + {$value} + {else} + {$noValueTxt} + {/if} + + +{else} + +{/if}