Cleanup in comment
[squirrelmail.git] / functions / forms.php
index 3f20410134c9956d74e236e2ac51943687117fd3..710f962be1fbf843fc64457af4f303c09046e5e5 100644 (file)
@@ -8,8 +8,9 @@
  * Functions to build HTML forms in a safe and consistent manner.
  * All name, value attributes are htmlentitied.
  *
- * $Id$
+ * @version $Id$
  * @package squirrelmail
+ * @subpackage forms
  */
 
 /**
@@ -20,7 +21,7 @@ function addInputField($type, $name = null, $value = null, $attributes = '') {
     return '<input type="'.$type.'"'.
         ($name  !== null ? ' name="'.htmlspecialchars($name).'"'   : '').
         ($value !== null ? ' value="'.htmlspecialchars($value).'"' : '').
-        $attributes . ">\n";
+        $attributes . " />\n";
 }
 
 /**
@@ -34,17 +35,17 @@ function addPwField($name , $value = null) {
 /**
  * Form checkbox
  */
-function addCheckBox($name, $checked = false, $value='') {
+function addCheckBox($name, $checked = false, $value = null) {
     return addInputField('checkbox', $name, $value,
-        ($checked ? ' checked' : ''));
+        ($checked ? ' checked="checked"' : ''));
 }
 
 /**
  * Form radio box
  */
-function addRadioBox($name, $checked = false, $value='') {
-    return addInputField('radio', $name, $value, 
-        ($checked ? ' checked' : ''));
+function addRadioBox($name, $checked = false, $value = null) {
+    return addInputField('radio', $name, $value,
+        ($checked ? ' checked="checked"' : ''));
 }
 
 /**
@@ -75,7 +76,7 @@ function addInput($name, $value = '', $size = 0, $maxlength = 0) {
  * Function to create a selectlist from an array.
  * Usage:
  * name: html name attribute
- * values: array ( key => value )  ->     <option value="key">value
+ * values: array ( key => value )  ->     <option value="key">value</option>
  * default: the key that will be selected
  * usekeys: use the keys of the array as option value or not
  */
@@ -93,7 +94,7 @@ function addSelect($name, $values, $default = null, $usekeys = false)
         if(!$usekeys) $k = $v;
         $ret .= '<option value="' .
             htmlspecialchars( $k ) . '"' .
-            (($default == $k) ? ' selected':'') .
+            (($default == $k) ? ' selected="selected"' : '') .
             '>' . htmlspecialchars($v) ."</option>\n";
     }
     $ret .= "</select>\n";
@@ -120,14 +121,14 @@ function addReset($value) {
  */
 function addTextArea($name, $text = '', $cols = 40, $rows = 10, $attr = '') {
     return '<textarea name="'.htmlspecialchars($name).'" '.
-        'rows="'.(int)$rows .'" cols="'.(int)$cols.'"'.
-        $attr . '">'.htmlspecialchars($text) ."</textarea>\n";
+        'rows="'.(int)$rows .'" cols="'.(int)$cols.'" '.
+        $attr . '>'.htmlspecialchars($text) ."</textarea>\n";
 }
 
 /**
  * Make a <form> start-tag.
  */
-function addForm($action, $method = 'POST', $name = '', $enctype = '', $charset = '')
+function addForm($action, $method = 'post', $name = '', $enctype = '', $charset = '')
 {
     if($name) {
         $name = ' name="'.$name.'"';
@@ -140,7 +141,7 @@ function addForm($action, $method = 'POST', $name = '', $enctype = '', $charset
     }
 
     return '<form action="'. $action .'" method="'. $method .'"'.
-        $enctype . $name . $charset . "\">\n";
+        $enctype . $name . $charset . ">\n";
 }
 
-
+?>
\ No newline at end of file