Minor adjustments to variable_orders & gpc_order checks. "Special thanks" to Tomas...
[squirrelmail.git] / functions / forms.php
index e94688a8610f8e8dcde0f427fb6d7815554cc352..059d6945668cea5829c0297eb7b8f52695890943 100644 (file)
@@ -25,7 +25,7 @@
  * @link http://www.section508.gov/ Section 508
  * @link http://www.w3.org/WAI/ Web Accessibility Initiative (WAI)
  * @link http://www.w3.org/TR/html4/ W3.org HTML 4.01 form specs
- * @copyright © 2004-2006 The SquirrelMail Project Team
+ * @copyright © 2004-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -164,6 +164,7 @@ function addInput($sName, $sValue = '', $iSize = 0, $iMaxlength = 0, $aAttribs=a
  * @param mixed $default the key that will be selected
  * @param boolean $bUsekeys use the keys of the array as option value or not
  * @param array $aAttribs (since 1.5.1) extra attributes
+ *
  * @return string html formated selection box
  * @todo add attributes argument for option tags and default css
  */
@@ -187,6 +188,31 @@ function addSelect($sName, $aValues, $default = null, $bUsekeys = false, $aAttri
     return $oTemplate->fetch('select.tpl');
 }
 
+/**
+ * Normal button
+ *
+ * Note the switched value/name parameters!
+ * Note also that regular buttons are not very useful unless
+ * used with onclick handlers, thus are only really appropriate
+ * if you use them after having checked if JavaScript is turned
+ * on by doing this:  if (checkForJavascript()) ...
+ *
+ * @param string $sValue button name
+ * @param string $sName key name
+ * @param array $aAttribs extra attributes
+ *
+ * @return string html formated submit input field
+ *
+ * @since 1.5.2
+ */
+function addButton($sValue, $sName = null, $aAttribs=array()) {
+    $aAttribs['value'] = $sValue;
+    if (! is_null($sName)) $aAttribs['name'] = $sName;
+    // add default css
+    if (! isset($aAttribs['class'])) $aAttribs['class'] = 'sqmsubmitfield';
+    return addInputField('button', $aAttribs);
+}
+
 /**
  * Form submission button
  * Note the switched value/name parameters!
@@ -202,6 +228,7 @@ function addSubmit($sValue, $sName = null, $aAttribs=array()) {
     if (! isset($aAttribs['class'])) $aAttribs['class'] = 'sqmsubmitfield';
     return addInputField('submit', $aAttribs);
 }
+
 /**
  * Form reset button
  * @param string $sValue button name
@@ -231,6 +258,7 @@ function addTextArea($sName, $sText = '', $iCols = 40, $iRows = 10, $aAttribs =
 
     // no longer accept string arguments for attribs; print 
     // backtrace to help people fix their code
+    //FIXME: throw error instead?
     if (!is_array($aAttribs)) {
         echo '$aAttribs argument to addTextArea() must be an array<br /><pre>';
         debug_print_backtrace();
@@ -238,7 +266,7 @@ function addTextArea($sName, $sText = '', $iCols = 40, $iRows = 10, $aAttribs =
         exit;
     }
 
-    // FIXME: should the template do this instead????
+    // add default css
     else if (!isset($aAttribs['class'])) $aAttribs['class'] = 'sqmtextarea';
 
     global $oTemplate;