From b65d1a0813429fe9e8e3193c18abb892f1bc35a9 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sat, 5 Jul 2003 21:16:51 +0000 Subject: [PATCH] script needs to be added inside the widgets git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5221 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/options.php | 70 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/functions/options.php b/functions/options.php index 85598f10..cb4fe820 100644 --- a/functions/options.php +++ b/functions/options.php @@ -139,31 +139,31 @@ class SquirrelOption { /* Get the widget for this option type. */ switch ($this->type) { case SMOPT_TYPE_STRING: - $result = $this->createWidget_String(); + $result = $this->createWidget_String($this->script); break; case SMOPT_TYPE_STRLIST: - $result = $this->createWidget_StrList(); + $result = $this->createWidget_StrList($this->script); break; case SMOPT_TYPE_TEXTAREA: - $result = $this->createWidget_TextArea(); + $result = $this->createWidget_TextArea($this->script); break; case SMOPT_TYPE_INTEGER: - $result = $this->createWidget_Integer(); + $result = $this->createWidget_Integer($this->script); break; case SMOPT_TYPE_FLOAT: - $result = $this->createWidget_Float(); + $result = $this->createWidget_Float($this->script); break; case SMOPT_TYPE_BOOLEAN: - $result = $this->createWidget_Boolean(); + $result = $this->createWidget_Boolean($this->script); break; case SMOPT_TYPE_HIDDEN: - $result = $this->createWidget_Hidden(); + $result = $this->createWidget_Hidden($this->script); break; case SMOPT_TYPE_COMMENT: - $result = $this->createWidget_Comment(); + $result = $this->createWidget_Comment($this->script); break; case SMOPT_TYPE_FLDRLIST: - $result = $this->createWidget_FolderList(); + $result = $this->createWidget_FolderList($this->script); break; default: $result = '' @@ -171,14 +171,11 @@ class SquirrelOption { . ''; } - /* Add the script for this option. */ - $result .= $this->script; - /* Now, return the created widget. */ return ($result); } - function createWidget_String() { + function createWidget_String($script) { switch ($this->size) { case SMOPT_SIZE_TINY: $width = 5; @@ -197,13 +194,13 @@ class SquirrelOption { $width = 25; } - $result = "name\" value=\"$this->value\" size=\"$width\">"; + $result = "name\" value=\"$this->value\" size=\"$width\" $script>"; return ($result); } - function createWidget_StrList() { + function createWidget_StrList($script) { /* Begin the select tag. */ - $result = "name\" $script>"; /* Add each possible value to the select list. */ foreach ($this->possible_values as $real_value => $disp_value) { @@ -227,11 +224,11 @@ class SquirrelOption { return ($result); } - function createWidget_FolderList() { + function createWidget_FolderList($script) { $selected = array(strtolower($this->value)); /* Begin the select tag. */ - $result = "name\" $script>"; /* Add each possible value to the select list. */ foreach ($this->possible_values as $real_value => $disp_value) { @@ -259,7 +256,7 @@ class SquirrelOption { } - function createWidget_TextArea() { + function createWidget_TextArea($script) { switch ($this->size) { case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break; case SMOPT_SIZE_SMALL: $rows = 4; $cols = 30; break; @@ -269,23 +266,40 @@ class SquirrelOption { default: $rows = 5; $cols = 50; } $result = ""; + . "cols=\"$cols\" $script>$this->value"; return ($result); } - function createWidget_Integer() { + function createWidget_Integer($script) { - return $this->createWidget_String(); + global $javascript_on; + // add onChange javascript handler to a regular string widget + // which will strip out all non-numeric chars + if ($javascript_on) + return preg_replace('/>/', ' onChange="origVal=this.value; newVal=\'\'; ' + . 'for (i=0;i=\'0\' ' + . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } ' + . 'this.value=newVal;">', $this->createWidget_String($script)); + else + return $this->createWidget_String($script); } - function createWidget_Float() { + function createWidget_Float($script) { - return $this->createWidget_String(); - + // add onChange javascript handler to a regular string widget + // which will strip out all non-numeric (period also OK) chars + if ($javascript_on) + return preg_replace('/>/', ' onChange="origVal=this.value; newVal=\'\'; ' + . 'for (i=0;i=\'0\' ' + . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') ' + . 'newVal += origVal.charAt(i); } this.value=newVal;">' + , $this->createWidget_String($script)); + else + return $this->createWidget_String($script); } - function createWidget_Boolean() { + function createWidget_Boolean($script) { /* Do the whole current value thing. */ if ($this->value != SMPREF_NO) { $yes_chk = ' checked'; @@ -310,13 +324,13 @@ class SquirrelOption { return ($result); } - function createWidget_Hidden() { + function createWidget_Hidden($script) { $result = ''; return ($result); } - function createWidget_Comment() { + function createWidget_Comment($script) { $result = $this->comment; return ($result); } -- 2.25.1