content disposition rfc
[squirrelmail.git] / functions / forms.php
index 3583a33fc3849405a325f80f8c75a87f46d3f651..24e00e9137fb00a6bc89e9a31fc2b7207df14d85 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * forms.php
  *
- * Copyright (c) 2004 The SquirrelMail Project Team
+ * Copyright (c) 2004-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Functions to build HTML forms in a safe and consistent manner.
  * Helper function to create form fields, not to be called directly,
  * only by other functions below.
  */
-function addInputField($type, $name = null, $value = null, $attributes = '') {
+function addInputField($type, $name = null, $value = null, $attributes = '', $id = null) {
     return '<input type="'.$type.'"'.
         ($name  !== null ? ' name="'.htmlspecialchars($name).'"'   : '').
+        ($id  !== null ? ' id="'.htmlspecialchars($id).'"'
+            : ($name  !== null ? ' id="'.htmlspecialchars($name).'"'   : '')).
         ($value !== null ? ' value="'.htmlspecialchars($value).'"' : '').
         $attributes . " />\n";
 }
@@ -35,9 +37,9 @@ function addPwField($name , $value = null) {
 /**
  * Form checkbox
  */
-function addCheckBox($name, $checked = false, $value = null) {
+function addCheckBox($name, $checked = false, $value = null, $xtra = '') {
     return addInputField('checkbox', $name, $value,
-        ($checked ? ' checked="checked"' : ''));
+        ($checked ? ' checked="checked"' : '') . ' ' . $xtra);
 }
 
 /**
@@ -45,7 +47,7 @@ function addCheckBox($name, $checked = false, $value = null) {
  */
 function addRadioBox($name, $checked = false, $value = null) {
     return addInputField('radio', $name, $value,
-        ($checked ? ' checked="checked"' : ''));
+        ($checked ? ' checked="checked"' : ''), $name . $value);
 }
 
 /**
@@ -76,7 +78,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
  */
@@ -94,7 +96,7 @@ function addSelect($name, $values, $default = null, $usekeys = false)
         if(!$usekeys) $k = $v;
         $ret .= '<option value="' .
             htmlspecialchars( $k ) . '"' .
-            (($default == $k) ? ' selected="selected"':'') .
+            (($default == $k) ? ' selected="selected"' : '') .
             '>' . htmlspecialchars($v) ."</option>\n";
     }
     $ret .= "</select>\n";
@@ -121,14 +123,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.'"';
@@ -144,4 +146,4 @@ function addForm($action, $method = 'POST', $name = '', $enctype = '', $charset
         $enctype . $name . $charset . ">\n";
 }
 
-?>
+?>
\ No newline at end of file