Use a template for the edit list widget
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 26 Feb 2008 02:28:38 +0000 (02:28 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 26 Feb 2008 02:28:38 +0000 (02:28 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12964 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/options.php
templates/default/edit_list_widget.tpl [new file with mode: 0644]

index f7b208bdc3c7b3b7efb2444ae28810b29c3cb843..41922b553862087ab9f1ccce070051816f8ca4d4 100644 (file)
@@ -569,7 +569,7 @@ class SquirrelOption {
      */
     function createWidget_EditList() {
 
      */
     function createWidget_EditList() {
 
-        global $br, $nbsp;
+        global $oTemplate;
 
         switch ($this->size) {
 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
 
         switch ($this->size) {
 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
@@ -590,14 +590,13 @@ class SquirrelOption {
                 $height = 5;
         }
 
                 $height = 5;
         }
 
-//FIXME: $this->aExtraAttribs and $this->trailing_text probably should only be used in one place
-//FIXME: might be nice to have this in a template file instead of creating layout here
-        return create_label(_("Add"), '')
-             . $nbsp . addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs) . htmlspecialchars($this->trailing_text)
-             . $br . addSelect('new_' . $this->name, $this->possible_values, $this->value, FALSE, !checkForJavascript() ? $this->aExtraAttribs : array_merge(array('onchange' => 'if (typeof(window.addinput) == \'undefined\') { var f = document.forms.length; var i = 0; var pos = -1; while( pos == -1 && i < f ) { var e = document.forms[i].elements.length; var j = 0; while( pos == -1 && j < e ) { if ( document.forms[i].elements[j].type == \'text\' && document.forms[i].elements[j].name == \'add_' . $this->name . '\' ) { pos = j; } j++; } i++; } if( pos >= 0 ) { window.addinput = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { window.addinput.value = this.options[x].value; break; } }'), $this->aExtraAttribs), TRUE, $height) . htmlspecialchars($this->trailing_text)
-             . $br
-             . addCheckBox('delete_' . $this->name, FALSE, SMPREF_YES, array_merge(array('id' => 'delete_' . $this->name), $this->aExtraAttribs))
-             . $nbsp . create_label(_("Delete Selected"), 'delete_' . $this->name);
+//FIXME: $this->aExtraAttribs probably should only be used in one place
+        $oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs));
+        $oTemplate->assign('trailing_text', $this->trailing_text);
+        $oTemplate->assign('select_widget', addSelect('new_' . $this->name, $this->possible_values, $this->value, FALSE, !checkForJavascript() ? $this->aExtraAttribs : array_merge(array('onchange' => 'if (typeof(window.addinput) == \'undefined\') { var f = document.forms.length; var i = 0; var pos = -1; while( pos == -1 && i < f ) { var e = document.forms[i].elements.length; var j = 0; while( pos == -1 && j < e ) { if ( document.forms[i].elements[j].type == \'text\' && document.forms[i].elements[j].name == \'add_' . $this->name . '\' ) { pos = j; } j++; } i++; } if( pos >= 0 ) { window.addinput = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { window.addinput.value = this.options[x].value; break; } }'), $this->aExtraAttribs), TRUE, $height));
+        $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name, FALSE, SMPREF_YES, array_merge(array('id' => 'delete_' . $this->name), $this->aExtraAttribs)));
+        $oTemplate->assign('name', $this->name);
+        return $oTemplate->fetch('edit_list_widget.tpl');
 
     }
 
 
     }
 
diff --git a/templates/default/edit_list_widget.tpl b/templates/default/edit_list_widget.tpl
new file mode 100644 (file)
index 0000000..46d0f0b
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+/**
+  * edit_list_widget.tpl
+  *
+  * Template for constructing an edit list.
+  *
+  * The following variables are available in this template:
+  *
+  * string  $name            The name of the edit list
+  * string  $input_widget    A preconstructed input text box used
+  *                          for adding new elements to the edit list
+  * string  $select_widget   A preconstructed input text box used
+  * string  $checkbox_widget A preconstructed input text box used
+  * string  $trailing_text   Any text given by the caller to be displayed
+  *                          after the edit list input
+  *
+  * @copyright &copy; 1999-2008 The SquirrelMail Project Team
+  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+  * @version $Id: select.tpl 12961 2008-02-24 22:35:08Z pdontthink $
+  * @package squirrelmail
+  * @subpackage templates
+  */
+
+
+// retrieve the template vars
+//
+extract($t);
+
+
+echo _("Add") . '&nbsp;' . $input_widget . '<br />' . $select_widget 
+   . '<br />' . $checkbox_widget . '&nbsp;<label for="delete_' . $name . '">' 
+   . _("Delete Selected") . '</label>';