git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5221
7612ce4b-ef26-0410-bec9-
ea0150e637f0
/* Get the widget for this option type. */
switch ($this->type) {
case SMOPT_TYPE_STRING:
/* 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:
break;
case SMOPT_TYPE_STRLIST:
- $result = $this->createWidget_StrList();
+ $result = $this->createWidget_StrList($this->script);
break;
case SMOPT_TYPE_TEXTAREA:
break;
case SMOPT_TYPE_TEXTAREA:
- $result = $this->createWidget_TextArea();
+ $result = $this->createWidget_TextArea($this->script);
break;
case SMOPT_TYPE_INTEGER:
break;
case SMOPT_TYPE_INTEGER:
- $result = $this->createWidget_Integer();
+ $result = $this->createWidget_Integer($this->script);
break;
case SMOPT_TYPE_FLOAT:
break;
case SMOPT_TYPE_FLOAT:
- $result = $this->createWidget_Float();
+ $result = $this->createWidget_Float($this->script);
break;
case SMOPT_TYPE_BOOLEAN:
break;
case SMOPT_TYPE_BOOLEAN:
- $result = $this->createWidget_Boolean();
+ $result = $this->createWidget_Boolean($this->script);
break;
case SMOPT_TYPE_HIDDEN:
break;
case SMOPT_TYPE_HIDDEN:
- $result = $this->createWidget_Hidden();
+ $result = $this->createWidget_Hidden($this->script);
break;
case SMOPT_TYPE_COMMENT:
break;
case SMOPT_TYPE_COMMENT:
- $result = $this->createWidget_Comment();
+ $result = $this->createWidget_Comment($this->script);
break;
case SMOPT_TYPE_FLDRLIST:
break;
case SMOPT_TYPE_FLDRLIST:
- $result = $this->createWidget_FolderList();
+ $result = $this->createWidget_FolderList($this->script);
break;
default:
$result = '<font color="' . $color[2] . '">'
break;
default:
$result = '<font color="' . $color[2] . '">'
- /* Add the script for this option. */
- $result .= $this->script;
-
/* Now, return the created widget. */
return ($result);
}
/* Now, return the created widget. */
return ($result);
}
- function createWidget_String() {
+ function createWidget_String($script) {
switch ($this->size) {
case SMOPT_SIZE_TINY:
$width = 5;
switch ($this->size) {
case SMOPT_SIZE_TINY:
$width = 5;
- $result = "<input name=\"new_$this->name\" value=\"$this->value\" size=\"$width\">";
+ $result = "<input name=\"new_$this->name\" value=\"$this->value\" size=\"$width\" $script>";
- function createWidget_StrList() {
+ function createWidget_StrList($script) {
/* Begin the select tag. */
/* Begin the select tag. */
- $result = "<select name=\"new_$this->name\">";
+ $result = "<select name=\"new_$this->name\" $script>";
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
- function createWidget_FolderList() {
+ function createWidget_FolderList($script) {
$selected = array(strtolower($this->value));
/* Begin the select tag. */
$selected = array(strtolower($this->value));
/* Begin the select tag. */
- $result = "<select name=\"new_$this->name\">";
+ $result = "<select name=\"new_$this->name\" $script>";
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
- 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;
switch ($this->size) {
case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break;
case SMOPT_SIZE_SMALL: $rows = 4; $cols = 30; break;
default: $rows = 5; $cols = 50;
}
$result = "<textarea name=\"new_$this->name\" rows=\"$rows\" "
default: $rows = 5; $cols = 50;
}
$result = "<textarea name=\"new_$this->name\" rows=\"$rows\" "
- . "cols=\"$cols\">$this->value</textarea>";
+ . "cols=\"$cols\" $script>$this->value</textarea>";
- function createWidget_Integer() {
+ function createWidget_Integer($script) {
- return $this->createWidget_String();
+ // 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<origVal.length;i++) { if (origVal.charAt(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<origVal.length;i++) { if ((origVal.charAt(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';
/* Do the whole current value thing. */
if ($this->value != SMPREF_NO) {
$yes_chk = ' checked';
- function createWidget_Hidden() {
+ function createWidget_Hidden($script) {
$result = '<input type="hidden" name="new_' . $this->name
. '" value="' . $this->value . '">';
return ($result);
}
$result = '<input type="hidden" name="new_' . $this->name
. '" value="' . $this->value . '">';
return ($result);
}
- function createWidget_Comment() {
+ function createWidget_Comment($script) {
$result = $this->comment;
return ($result);
}
$result = $this->comment;
return ($result);
}