From cb606dfd0fab7fc745ac98477d619012f2fdcc1f Mon Sep 17 00:00:00 2001 From: pdontthink Date: Tue, 26 Feb 2008 02:28:38 +0000 Subject: [PATCH] Use a template for the edit list widget git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12964 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/options.php | 17 +++++++------ templates/default/edit_list_widget.tpl | 33 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 templates/default/edit_list_widget.tpl diff --git a/functions/options.php b/functions/options.php index f7b208bd..41922b55 100644 --- a/functions/options.php +++ b/functions/options.php @@ -569,7 +569,7 @@ class SquirrelOption { */ 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... @@ -590,14 +590,13 @@ class SquirrelOption { $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 index 00000000..46d0f0be --- /dev/null +++ b/templates/default/edit_list_widget.tpl @@ -0,0 +1,33 @@ +' . $select_widget + . '
' . $checkbox_widget . ' '; -- 2.25.1