Strip HTML out of forms.php. Need to run through rest of core and use these function...
[squirrelmail.git] / functions / options.php
index 8175f0bf5368bfed9d53d9a1fb759a1cae41ec0f..24b094effe714a843a9a709a6e4bf3b4f430d4b4 100644 (file)
@@ -175,11 +175,11 @@ class SquirrelOption {
         $this->script = '';
         $this->post_script = '';
 
-        /* Check for a current value. */
-        if (!empty($initial_value)) {
-            $this->value = $initial_value;
-        } else if (isset($GLOBALS[$name])) {
+        //Check for a current value.  
+        if (isset($GLOBALS[$name])) {
             $this->value = $GLOBALS[$name];
+        } else if (!empty($initial_value)) {
+            $this->value = $initial_value;
         } else {
             $this->value = '';
         }
@@ -450,10 +450,9 @@ class SquirrelOption {
             case SMOPT_SIZE_NORMAL:
             default: $rows = 5; $cols =  50;
         }
-        $result = "<textarea name=\"new_$this->name\" rows=\"$rows\" "
-                . "cols=\"$cols\" $this->script>"
-                . htmlspecialchars($this->value) . "</textarea>\n";
-        return ($result);
+//FIXME: we need to change $this->script into $this->aExtraAttribs, and anyone who wants to add some javascript or other attributes to an options widget can put them in an array and pass them as extra attributes (key == attrib name, value == attrib value).... for now, this is the only place it is used, and there is no place in the code that text areas get extra attribs or javascript... in fact the only place that was using $this->script is include/options/display.php:200, so that's easy to change.... just have to go through this file and change all the places that use "script"
+$this->aExtraAttribs = array();
+        return addTextArea('new_' . $this->name, $this->value, $cols, $rows, $this->aExtraAttribs);
     }
 
     /**
@@ -463,11 +462,10 @@ class SquirrelOption {
      * @return string html formated option field
      */
     function createWidget_Integer() {
-        global $javascript_on;
 
         // add onChange javascript handler to a regular string widget
         // which will strip out all non-numeric chars
-        if ($javascript_on)
+        if (checkForJavascript())
            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); } '
@@ -482,11 +480,10 @@ class SquirrelOption {
      * @return string html formated option field
      */
     function createWidget_Float() {
-        global $javascript_on;
 
         // add onChange javascript handler to a regular string widget
         // which will strip out all non-numeric (period also OK) chars
-        if ($javascript_on)
+        if (checkForJavascript())
            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)==\'.\') '
@@ -689,49 +686,4 @@ function create_option_groups($optgrps, $optvals) {
     return ($result);
 }
 
-/**
- * @param array $option_groups
- */
-function print_option_groups($option_groups) {
-    /* Print each option group. */
-    foreach ($option_groups as $next_optgrp) {
-        /* If it is not blank, print the name for this option group. */
-        if ($next_optgrp['name'] != '') {
-            echo html_tag( 'tr', "\n".
-                        html_tag( 'td',
-                            '<b>' . $next_optgrp['name'] . '</b>' ,
-                        'center' ,'', 'valign="middle" colspan="2" style="white-space: nowrap;"' )
-                    ) ."\n";
-        }
-
-        /* Print each option in this option group. */
-        foreach ($next_optgrp['options'] as $option) {
-            if ($option->type != SMOPT_TYPE_HIDDEN) {
-                echo html_tag( 'tr', "\n".
-                           html_tag( 'td', $option->caption . ':', 'right' ,'', 'valign="middle"' ) .
-                           html_tag( 'td', $option->createHTMLWidget(), 'left' )
-                       ) ."\n";
-            } else {
-                echo $option->createHTMLWidget();
-            }
-        }
-
-        /* Print an empty row after this option group. */
-        echo html_tag( 'tr',
-                   html_tag( 'td', '&nbsp;', 'left', '', 'colspan="2"' )
-                ) . "\n";
-    }
-}
-
-/**
- * Create submit button inside table row.
- * @param string $name
- */
-function OptionSubmit( $name ) {
-        echo html_tag( 'tr',
-                   html_tag( 'td', '<input type="submit" value="' . _("Submit") . '" name="' . $name . '" />&nbsp;&nbsp;&nbsp;&nbsp;', 'right', '', 'colspan="2"' )
-                ) . "\n";
-}
-
 // vim: et ts=4
-?>
\ No newline at end of file