home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / Form.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  101.5 KB  |  2,679 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * HTML form utility functions
  7.  *
  8.  * Release 1.3.0 introduces very important security fixes.
  9.  * Please make sure you have upgraded.
  10.  *
  11.  * PHP versions 4 and 5
  12.  *
  13.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  14.  * that is available through the world-wide-web at the following URI:
  15.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  16.  * the PHP License and are unable to obtain it through the web, please
  17.  * send a note to license@php.net so we can mail you a copy immediately.
  18.  *
  19.  * @category   HTML
  20.  * @package    HTML_Form
  21.  * @author     Stig Bakken <ssb@fast.no>
  22.  * @author     Urs Gehrig <urs@circle.ch>
  23.  * @author     Daniel Convissor <danielc@php.net>
  24.  * @copyright  1997-2005 The PHP Group
  25.  * @license    http://www.php.net/license/3_0.txt  PHP License
  26.  * @version    $Id: Form.php,v 1.22 2005/10/16 18:57:35 danielc Exp $
  27.  * @link       http://pear.php.net/package/HTML_Form
  28.  */
  29.  
  30. if (!defined('HTML_FORM_TEXT_SIZE')) {
  31.     /**
  32.      * Default value for the $size parameter of most methods.
  33.      *
  34.      * You can set this in your scripts before including Form.php
  35.      * so you don't have to manually set the argument each time
  36.      * you call a method.
  37.      */
  38.     define('HTML_FORM_TEXT_SIZE', 20);
  39. }
  40.  
  41. if (!defined('HTML_FORM_MAX_FILE_SIZE')) {
  42.     /**
  43.      * Default value for the $maxsize parameter of some methods.
  44.      *
  45.      * You can set this in your scripts before including Form.php
  46.      * so you don't have to manually set the argument each time
  47.      * you call a method.
  48.      */
  49.     define('HTML_FORM_MAX_FILE_SIZE', 1048576); // 1 MB
  50. }
  51.  
  52. if (!defined('HTML_FORM_PASSWD_SIZE')) {
  53.     /**
  54.      * Default value for the $maxsize parameter of some methods.
  55.      *
  56.      * You can set this in your scripts before including Form.php
  57.      * so you don't have to manually set the argument each time
  58.      * you call a method.
  59.      */
  60.     define('HTML_FORM_PASSWD_SIZE', 8);
  61. }
  62.  
  63. if (!defined('HTML_FORM_TEXTAREA_WT')) {
  64.     /**
  65.      * Default value for the $width parameter of some methods.
  66.      *
  67.      * You can set this in your scripts before including Form.php
  68.      * so you don't have to manually set the argument each time
  69.      * you call a method.
  70.      */
  71.     define('HTML_FORM_TEXTAREA_WT', 40);
  72. }
  73.  
  74. if (!defined('HTML_FORM_TEXTAREA_HT')) {
  75.     /**
  76.      * Default value for the $height parameter of some methods.
  77.      *
  78.      * You can set this in your scripts before including Form.php
  79.      * so you don't have to manually set the argument each time
  80.      * you call a method.
  81.      */
  82.     define('HTML_FORM_TEXTAREA_HT', 5);
  83. }
  84.  
  85. if (!defined('HTML_FORM_TH_ATTR')) {
  86.     /**
  87.      * Default value for the $thattr parameter of most methods.
  88.      *
  89.      * You can set this in your scripts before including Form.php
  90.      * so you don't have to manually set the argument each time
  91.      * you call a method.
  92.      *
  93.      * @since Constant available since Release 1.1.0
  94.      */
  95.     define('HTML_FORM_TH_ATTR', 'align="right" valign="top"');
  96. }
  97.  
  98. if (!defined('HTML_FORM_TD_ATTR')) {
  99.     /**
  100.      * Default value for the $tdattr parameter of most methods.
  101.      *
  102.      * You can set this in your scripts before including Form.php
  103.      * so you don't have to manually set the argument each time
  104.      * you call a method.
  105.      *
  106.      * @since Constant available since Release 1.1.0
  107.      */
  108.     define('HTML_FORM_TD_ATTR', '');
  109. }
  110.  
  111.  
  112. /**
  113.  * HTML form utility functions
  114.  *
  115.  * Release 1.3.0 introduces very important security fixes.
  116.  * Please make sure you have upgraded.
  117.  *
  118.  * @category   HTML
  119.  * @package    HTML_Form
  120.  * @author     Stig Bakken <ssb@fast.no>
  121.  * @author     Urs Gehrig <urs@circle.ch>
  122.  * @author     Daniel Convissor <danielc@php.net>
  123.  * @copyright  1997-2005 The PHP Group
  124.  * @license    http://www.php.net/license/3_0.txt  PHP License
  125.  * @version    Release: @package_version@
  126.  * @link       http://pear.php.net/package/HTML_Form
  127.  */
  128. class HTML_Form
  129. {
  130.     // {{{ properties
  131.  
  132.     /**
  133.      * ACTION attribute of <form> tag
  134.      * @var string
  135.      */
  136.     var $action;
  137.  
  138.     /**
  139.      * METHOD attribute of <form> tag
  140.      * @var string
  141.      */
  142.     var $method;
  143.  
  144.     /**
  145.      * NAME attribute of <form> tag
  146.      * @var string
  147.      */
  148.     var $name;
  149.  
  150.     /**
  151.      * an array of entries for this form
  152.      * @var array
  153.      */
  154.     var $fields;
  155.  
  156.     /**
  157.      * DB_storage object, if tied to one
  158.      */
  159.     var $storageObject;
  160.  
  161.     /**
  162.      * TARGET attribute of <form> tag
  163.      * @var string
  164.      */
  165.     var $target;
  166.  
  167.     /**
  168.      * ENCTYPE attribute of <form> tag
  169.      * @var string
  170.      */
  171.     var $enctype;
  172.  
  173.     /**
  174.      * additional attributes for <form> tag
  175.      *
  176.      * @var string
  177.      * @since Property available since Release 1.1.0
  178.      */
  179.     var $attr;
  180.  
  181.     /**
  182.      * an array indicating which parameter to an add*Row() method contains
  183.      * the the field's $default value
  184.      *
  185.      * @var array
  186.      * @access private
  187.      * @since Property available since Release 1.3.0
  188.      */
  189.     var $_default_params = array(
  190.         'blank'       => false,
  191.         'checkbox'    => 3,
  192.         'file'        => false,
  193.         'hidden'      => false,
  194.         'image'       => false,
  195.         'password'    => 3,
  196.         'passwordOne' => 3,
  197.         'plaintext'   => false,
  198.         'radio'       => 4,
  199.         'reset'       => false,
  200.         'select'      => 4,
  201.         'submit'      => false,
  202.         'text'        => 3,
  203.         'textarea'    => 3,
  204.     );
  205.  
  206.     /**
  207.      * allow $_GET/$_POST data to show up in fields when a $default
  208.      * hasn't been set?
  209.      *
  210.      * @var boolean
  211.      * @access private
  212.      * @see HTML_Form::setDefaultFromInput()
  213.      * @since Property available since Release 1.3.0
  214.      */
  215.     var $_default_from_input = true;
  216.  
  217.     /**
  218.      * escape the $_GET/$_POST data that shows up in fields when a $default
  219.      * hasn't been set?
  220.      *
  221.      * @var boolean
  222.      * @access private
  223.      * @see HTML_Form::setEscapeDefaultFromInput()
  224.      * @since Property available since Release 1.3.0
  225.      */
  226.     var $_escape_default_from_input = true;
  227.  
  228.  
  229.     // }}}
  230.     // {{{ constructor
  231.  
  232.     /**
  233.      * Constructor
  234.      *
  235.      * @param string $action  the string naming file or URI to which the form
  236.      *                         should be submitted
  237.      * @param string $method  a string indicating the submission method
  238.      *                         ('get' or 'post')
  239.      * @param string $name    a string used in the <form>'s 'name' attribute
  240.      * @param string $target  a string used in the <form>'s 'target' attribute
  241.      * @param string $enctype a string indicating the submission's encoding
  242.      * @param string $attr    a string of additional attributes to be put
  243.      *                         in the element (example: 'id="foo"')
  244.      * @return void
  245.      *
  246.      * @access public
  247.      */
  248.     function HTML_Form($action, $method = 'get', $name = '', $target = '',
  249.                        $enctype = '', $attr = '')
  250.     {
  251.         $this->action  = $action;
  252.         $this->method  = $method;
  253.         $this->name    = $name;
  254.         $this->fields  = array();
  255.         $this->target  = $target;
  256.         $this->enctype = $enctype;
  257.         $this->attr    = $attr;
  258.     }
  259.  
  260.     /**
  261.      * Enables/Disables $_GET/$_POST user input data showing up in fields
  262.      * when a $default hasn't been set
  263.      *
  264.      * The default is TRUE.
  265.      *
  266.      * @param boolean $bool  TRUE to use $_GET/$_POST for the default,
  267.      *                        FALSE to default to an empty string
  268.      *
  269.      * @return void
  270.      *
  271.      * @see HTML_Form::setEscapeDefaultFromInput()
  272.      * @since Method available since Release 1.3.0
  273.      */
  274.     function setDefaultFromInput($bool) {
  275.         $this->_default_from_input = $bool;
  276.     }
  277.  
  278.     /**
  279.      * Enables/Disables escaping of the $_GET/$_POST data that shows up in
  280.      * fields when a $default hasn't been set
  281.      *
  282.      * The default is TRUE.
  283.      *
  284.      * Uses htmlspecialchars() for the escaping.
  285.      *
  286.      * @param boolean $bool  TRUE to escape, FALSE to disable escaping
  287.      *
  288.      * @return void
  289.      *
  290.      * @see HTML_Form::setDefaultFromInput()
  291.      * @since Method available since Release 1.3.0
  292.      */
  293.     function setEscapeDefaultFromInput($bool) {
  294.         $this->_escape_default_from_input = $bool;
  295.     }
  296.  
  297.     // ===========  ADD  ===========
  298.  
  299.     // }}}
  300.     // {{{ addText()
  301.  
  302.     /**
  303.      * Adds a text input to the list of fields to be processed by display()
  304.      *
  305.      * @param string $name      the string used in the 'name' attribute
  306.      * @param string $title     the string used as the label
  307.      * @param mixed  $default   a default value for the element
  308.      * @param int    $size      an integer used in the 'size' attribute
  309.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  310.      * @param string $attr      a string of additional attributes to be put
  311.      *                           in the element (example: 'id="foo"')
  312.      * @param string $thattr    a string of additional attributes to be put
  313.      *                           in the <th> element (example: 'class="foo"')
  314.      * @param string $tdattr    a string of additional attributes to be put
  315.      *                           in the <td> element (example: 'class="foo"')
  316.      * @return void
  317.      *
  318.      * @access public
  319.      * @see HTML_Form::display(),
  320.      *      HTML_Form::displayText(), HTML_Form::displayTextRow(),
  321.      *      HTML_Form::returnText(), HTML_Form::returnTextRow()
  322.      */
  323.     function addText($name, $title, $default = null,
  324.                      $size = HTML_FORM_TEXT_SIZE, $maxlength = 0,
  325.                      $attr = '', $thattr = HTML_FORM_TH_ATTR,
  326.                      $tdattr = HTML_FORM_TD_ATTR)
  327.     {
  328.         $this->fields[] = array('text', $name, $title, $default, $size,
  329.                                 $maxlength, $attr, $thattr, $tdattr);
  330.     }
  331.  
  332.     // }}}
  333.     // {{{ addPassword()
  334.  
  335.     /**
  336.      * Adds a combined password input and password confirmation input
  337.      * to the list of fields to be processed by display()
  338.      *
  339.      * @param string $name      the string used in the 'name' attribute
  340.      * @param string $title     the string used as the label
  341.      * @param mixed  $default   a default value for the element
  342.      * @param int    $size      an integer used in the 'size' attribute
  343.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  344.      * @param string $attr      a string of additional attributes to be put
  345.      *                           in the element (example: 'id="foo"')
  346.      * @param string $thattr    a string of additional attributes to be put
  347.      *                           in the <th> element (example: 'class="foo"')
  348.      * @param string $tdattr    a string of additional attributes to be put
  349.      *                           in the <td> element (example: 'class="foo"')
  350.      * @return void
  351.      *
  352.      * @access public
  353.      * @see HTML_Form::addPasswordOne(), HTML_Form::display(),
  354.      *      HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),
  355.      *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow(),
  356.      *      HTML_Form::displayPasswordOneRow(),
  357.      *      HTML_Form::returnPasswordOneRow()
  358.      */
  359.     function addPassword($name, $title, $default = null,
  360.                          $size = HTML_FORM_PASSWD_SIZE,
  361.                          $maxlength = 0, $attr = '', $thattr = HTML_FORM_TH_ATTR,
  362.                          $tdattr = HTML_FORM_TD_ATTR)
  363.     {
  364.         $this->fields[] = array('password', $name, $title, $default, $size,
  365.                                 $maxlength, $attr, $thattr, $tdattr);
  366.     }
  367.  
  368.     // }}}
  369.     // {{{ addPasswordOne()
  370.  
  371.     /**
  372.      * Adds a password input to the list of fields to be processed by display()
  373.      *
  374.      * @param string $name      the string used in the 'name' attribute
  375.      * @param string $title     the string used as the label
  376.      * @param mixed  $default   a default value for the element
  377.      * @param int    $size      an integer used in the 'size' attribute
  378.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  379.      * @param string $attr      a string of additional attributes to be put
  380.      *                           in the element (example: 'id="foo"')
  381.      * @param string $thattr    a string of additional attributes to be put
  382.      *                           in the <th> element (example: 'class="foo"')
  383.      * @param string $tdattr    a string of additional attributes to be put
  384.      *                           in the <td> element (example: 'class="foo"')
  385.      * @return void
  386.      *
  387.      * @access public
  388.      * @see HTML_Form::addPassword(), HTML_Form::display(),
  389.      *      HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),
  390.      *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow(),
  391.      *      HTML_Form::displayPasswordOneRow(),
  392.      *      HTML_Form::returnPasswordOneRow()
  393.      */
  394.     function addPasswordOne($name, $title, $default = null,
  395.                             $size = HTML_FORM_PASSWD_SIZE,
  396.                             $maxlength = 0, $attr = '', $thattr = HTML_FORM_TH_ATTR,
  397.                             $tdattr = HTML_FORM_TD_ATTR)
  398.     {
  399.         $this->fields[] = array('passwordOne', $name, $title, $default, $size,
  400.                                 $maxlength, $attr, $thattr, $tdattr);
  401.     }
  402.  
  403.     // }}}
  404.     // {{{ addCheckbox()
  405.  
  406.     /**
  407.      * Adds a checkbox input to the list of fields to be processed by display()
  408.      *
  409.      * @param string $name      the string used in the 'name' attribute
  410.      * @param string $title     the string used as the label
  411.      * @param bool   $default   a bool indicating if item should be checked
  412.      * @param string $attr      a string of additional attributes to be put
  413.      *                           in the element (example: 'id="foo"')
  414.      * @param string $thattr    a string of additional attributes to be put
  415.      *                           in the <th> element (example: 'class="foo"')
  416.      * @param string $tdattr    a string of additional attributes to be put
  417.      *                           in the <td> element (example: 'class="foo"')
  418.      * @return void
  419.      *
  420.      * @access public
  421.      * @see HTML_Form::display(),
  422.      *      HTML_Form::displayCheckbox(), HTML_Form::displayCheckboxRow(),
  423.      *      HTML_Form::returnCheckbox(), HTML_Form::returnCheckboxRow()
  424.      */
  425.     function addCheckbox($name, $title, $default = false, $attr = '',
  426.                          $thattr = HTML_FORM_TH_ATTR,
  427.                          $tdattr = HTML_FORM_TD_ATTR)
  428.     {
  429.         $this->fields[] = array('checkbox', $name, $title, $default, $attr,
  430.                                 $thattr, $tdattr);
  431.     }
  432.  
  433.     // }}}
  434.     // {{{ addTextarea()
  435.  
  436.     /**
  437.      * Adds a textarea input to the list of fields to be processed by display()
  438.      *
  439.      * @param string $name      the string used in the 'name' attribute
  440.      * @param string $title     the string used as the label
  441.      * @param mixed  $default   a default value for the element
  442.      * @param int    $width     an integer saying how many characters wide
  443.      *                           the item should be
  444.      * @param int    $height    an integer saying how many rows tall the
  445.      *                           item should be
  446.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  447.      * @param string $attr      a string of additional attributes to be put
  448.      *                           in the element (example: 'id="foo"')
  449.      * @param string $thattr    a string of additional attributes to be put
  450.      *                           in the <th> element (example: 'class="foo"')
  451.      * @param string $tdattr    a string of additional attributes to be put
  452.      *                           in the <td> element (example: 'class="foo"')
  453.      * @return void
  454.      *
  455.      * @access public
  456.      * @see HTML_Form::display(),
  457.      *      HTML_Form::displayTextarea(), HTML_Form::displayTextareaRow(),
  458.      *      HTML_Form::returnTextarea(), HTML_Form::returnTextareaRow()
  459.      */
  460.     function addTextarea($name, $title, $default = null,
  461.                          $width = HTML_FORM_TEXTAREA_WT,
  462.                          $height = HTML_FORM_TEXTAREA_HT, $maxlength = 0,
  463.                          $attr = '', $thattr = HTML_FORM_TH_ATTR,
  464.                          $tdattr = HTML_FORM_TD_ATTR)
  465.     {
  466.         $this->fields[] = array('textarea', $name, $title, $default, $width,
  467.                                 $height, $maxlength, $attr, $thattr, $tdattr);
  468.     }
  469.  
  470.     // }}}
  471.     // {{{ addSubmit()
  472.  
  473.     /**
  474.      * Adds a submit button to the list of fields to be processed by display()
  475.      *
  476.      * @param string $name      a string used in the 'name' attribute
  477.      * @param string $title     a string that appears on the button
  478.      * @param string $attr      a string of additional attributes to be put
  479.      *                           in the element (example: 'id="foo"')
  480.      * @param string $thattr    a string of additional attributes to be put
  481.      *                           in the <th> element (example: 'class="foo"')
  482.      * @param string $tdattr    a string of additional attributes to be put
  483.      *                           in the <td> element (example: 'class="foo"')
  484.      * @return void
  485.      *
  486.      * @access public
  487.      * @see HTML_Form::display(),
  488.      *      HTML_Form::displaySubmit(), HTML_Form::displaySubmitRow(),
  489.      *      HTML_Form::returnSubmit(), HTML_Form::returnSubmitRow()
  490.      */
  491.     function addSubmit($name = 'submit', $title = 'Submit Changes',
  492.                        $attr = '', $thattr = HTML_FORM_TH_ATTR,
  493.                        $tdattr = HTML_FORM_TD_ATTR)
  494.     {
  495.         $this->fields[] = array('submit', $name, $title, $attr, $thattr,
  496.                                 $tdattr);
  497.     }
  498.  
  499.     // }}}
  500.     // {{{ addReset()
  501.  
  502.     /**
  503.      * Adds a reset button to the list of fields to be processed by display()
  504.      *
  505.      * NOTE: Unusual parameter order.
  506.      *
  507.      * @param string $title     a string that appears on the button
  508.      * @param string $attr      a string of additional attributes to be put
  509.      *                           in the element (example: 'id="foo"')
  510.      * @param string $thattr    a string of additional attributes to be put
  511.      *                           in the <th> element (example: 'class="foo"')
  512.      * @param string $tdattr    a string of additional attributes to be put
  513.      *                           in the <td> element (example: 'class="foo"')
  514.      * @return void
  515.      *
  516.      * @access public
  517.      * @see HTML_Form::display(),
  518.      *      HTML_Form::displayReset(), HTML_Form::displayResetRow(),
  519.      *      HTML_Form::returnReset(), HTML_Form::returnResetRow()
  520.      */
  521.     function addReset($title = 'Discard Changes', $attr = '',
  522.                       $thattr = HTML_FORM_TH_ATTR,
  523.                       $tdattr = HTML_FORM_TD_ATTR)
  524.     {
  525.         $this->fields[] = array('reset', $title, $attr, $thattr, $tdattr);
  526.     }
  527.  
  528.     // }}}
  529.     // {{{ addSelect()
  530.  
  531.     /**
  532.      * Adds a select list to the list of fields to be processed by display()
  533.      *
  534.      * NOTE:  In order for defaults to be automatically selected in the
  535.      * output, the PHP data types of the $default must match the data types
  536.      * of the keys in the $entries array.
  537.      *
  538.      * @param string $name      the string used in the 'name' attribute
  539.      * @param string $title     the string used as the label
  540.      * @param array  $entries   an array containing the <options> to be listed.
  541.      *                           The array's keys become the option values and
  542.      *                           the array's values become the visible text.
  543.      * @param mixed  $default   a default value for the element
  544.      * @param int    $size      an integer saying how many rows should be
  545.      * @param string $blank     if this string is present, an <option> will be
  546.      *                           added to the top of the list that will contain
  547.      *                           the given text in the visible portion and an
  548.      *                           empty string as the value
  549.      * @param bool   $multiple  a bool saying if multiple choices are allowed
  550.      * @param string $attr      a string of additional attributes to be put
  551.      *                           in the element (example: 'id="foo"')
  552.      * @param string $thattr    a string of additional attributes to be put
  553.      *                           in the <th> element (example: 'class="foo"')
  554.      * @param string $tdattr    a string of additional attributes to be put
  555.      *                           in the <td> element (example: 'class="foo"')
  556.      * @return void
  557.      *
  558.      * @access public
  559.      * @see HTML_Form::display(),
  560.      *      HTML_Form::displaySelect(), HTML_Form::displaySelectRow(),
  561.      *      HTML_Form::returnSelect(), HTML_Form::returnSelectRow()
  562.      */
  563.     function addSelect($name, $title, $entries, $default = null, $size = 1,
  564.                        $blank = '', $multiple = false, $attr = '',
  565.                        $thattr = HTML_FORM_TH_ATTR,
  566.                        $tdattr = HTML_FORM_TD_ATTR)
  567.     {
  568.         $this->fields[] = array('select', $name, $title, $entries, $default,
  569.                                 $size, $blank, $multiple, $attr, $thattr,
  570.                                 $tdattr);
  571.     }
  572.  
  573.     // }}}
  574.     // {{{ addRadio()
  575.  
  576.     /**
  577.      * Adds a radio input to the list of fields to be processed by display()
  578.      *
  579.      * @param string $name      the string used in the 'name' attribute
  580.      * @param string $title     the string used as the label
  581.      * @param string $value     the string used for the item's value
  582.      * @param bool   $default   a bool indicating if item should be checked
  583.      * @param string $attr      a string of additional attributes to be put
  584.      *                           in the element (example: 'id="foo"')
  585.      * @param string $thattr    a string of additional attributes to be put
  586.      *                           in the <th> element (example: 'class="foo"')
  587.      * @param string $tdattr    a string of additional attributes to be put
  588.      *                           in the <td> element (example: 'class="foo"')
  589.      * @return void
  590.      *
  591.      * @access public
  592.      * @see HTML_Form::display(),
  593.      *      HTML_Form::displayRadio(), HTML_Form::displayRadioRow(),
  594.      *      HTML_Form::returnRadio(), HTML_Form::returnRadioRow()
  595.      */
  596.     function addRadio($name, $title, $value, $default = false, $attr = '',
  597.                       $thattr = HTML_FORM_TH_ATTR,
  598.                       $tdattr = HTML_FORM_TD_ATTR)
  599.     {
  600.         $this->fields[] = array('radio', $name, $title, $value, $default,
  601.                                 $attr, $thattr, $tdattr);
  602.     }
  603.  
  604.     // }}}
  605.     // {{{ addImage()
  606.  
  607.     /**
  608.      * Adds an image input to the list of fields to be processed by display()
  609.      *
  610.      * @param string $name      the string used in the 'name' attribute
  611.      * @param string $title     the string used as the label
  612.      * @param string $src       the string denoting the path to the image.
  613.      *                           Can be a relative path or full URI.
  614.      * @param string $attr      a string of additional attributes to be put
  615.      *                           in the element (example: 'id="foo"')
  616.      * @param string $thattr    a string of additional attributes to be put
  617.      *                           in the <th> element (example: 'class="foo"')
  618.      * @param string $tdattr    a string of additional attributes to be put
  619.      *                           in the <td> element (example: 'class="foo"')
  620.      * @return void
  621.      *
  622.      * @access public
  623.      * @see HTML_Form::display(),
  624.      *      HTML_Form::displayImage(), HTML_Form::displayImageRow(),
  625.      *      HTML_Form::returnImage(), HTML_Form::returnImageRow()
  626.      */
  627.     function addImage($name, $title, $src, $attr = '',
  628.                       $thattr = HTML_FORM_TH_ATTR,
  629.                       $tdattr = HTML_FORM_TD_ATTR)
  630.     {
  631.         $this->fields[] = array('image', $name, $title, $src, $attr, $thattr,
  632.                                 $tdattr);
  633.     }
  634.  
  635.     // }}}
  636.     // {{{ addHidden()
  637.  
  638.     /**
  639.      * Adds a hiden input to the list of fields to be processed by display()
  640.      *
  641.      * @param string $name      the string used in the 'name' attribute
  642.      * @param string $value     the string used for the item's value
  643.      * @param string $attr      a string of additional attributes to be put
  644.      *                           in the element (example: 'id="foo"')
  645.      * @return void
  646.      *
  647.      * @access public
  648.      * @see HTML_Form::display(),
  649.      *      HTML_Form::displayHidden(), HTML_Form::returnHidden()
  650.      */
  651.     function addHidden($name, $value, $attr = '')
  652.     {
  653.         $this->fields[] = array('hidden', $name, $value, $attr);
  654.     }
  655.  
  656.     // }}}
  657.     // {{{ addBlank()
  658.  
  659.     /**
  660.      * Adds a blank row to the list of fields to be processed by display()
  661.      *
  662.      * @param int    $i         the number of rows to create.  Ignored if
  663.      *                           $title is used.
  664.      * @param string $title     a string to be used as the label for the row
  665.      * @param string $thattr    a string of additional attributes to be put
  666.      *                           in the <th> element (example: 'class="foo"')
  667.      * @param string $tdattr    a string of additional attributes to be put
  668.      *                           in the <td> element (example: 'class="foo"')
  669.      * @return void
  670.      *
  671.      * @access public
  672.      * @see HTML_Form::display(),
  673.      *      HTML_Form::displayBlank(), HTML_Form::displayBlankRow(),
  674.      *      HTML_Form::returnBlank(), HTML_Form::returnBlankRow()
  675.      */
  676.     function addBlank($i, $title = '', $thattr = HTML_FORM_TH_ATTR,
  677.                       $tdattr = HTML_FORM_TD_ATTR)
  678.     {
  679.         $this->fields[] = array('blank', $i, $title, $thattr, $tdattr);
  680.     }
  681.  
  682.     // }}}
  683.     // {{{ addFile
  684.  
  685.     /**
  686.      * Adds a file upload input to the list of fields to be processed by display()
  687.      *
  688.      * @param string $name      the string used in the 'name' attribute
  689.      * @param string $title     the string used as the label
  690.      * @param int    $maxsize   an integer determining how large (in bytes) a
  691.      *                           submitted file can be.
  692.      * @param int    $size      an integer used in the 'size' attribute
  693.      * @param string $accept    a string saying which MIME types are allowed
  694.      * @param string $attr      a string of additional attributes to be put
  695.      *                           in the element (example: 'id="foo"')
  696.      * @param string $thattr    a string of additional attributes to be put
  697.      *                           in the <th> element (example: 'class="foo"')
  698.      * @param string $tdattr    a string of additional attributes to be put
  699.      *                           in the <td> element (example: 'class="foo"')
  700.      * @return void
  701.      *
  702.      * @access public
  703.      * @see HTML_Form::display(),
  704.      *      HTML_Form::displayFile(), HTML_Form::displayFileRow(),
  705.      *      HTML_Form::returnFile(), HTML_Form::returnFileRow(),
  706.      *      HTML_Form::returnMultipleFiles()
  707.      */
  708.     function addFile($name, $title, $maxsize = HTML_FORM_MAX_FILE_SIZE,
  709.                      $size = HTML_FORM_TEXT_SIZE, $accept = '', $attr = '',
  710.                      $thattr = HTML_FORM_TH_ATTR,
  711.                      $tdattr = HTML_FORM_TD_ATTR)
  712.     {
  713.         $this->enctype = "multipart/form-data";
  714.         $this->fields[] = array('file', $name, $title, $maxsize, $size,
  715.                                 $accept, $attr, $thattr, $tdattr);
  716.     }
  717.  
  718.     // }}}
  719.     // {{{ addPlaintext()
  720.  
  721.     /**
  722.      * Adds a row of text to the list of fields to be processed by display()
  723.      *
  724.      * @param string $title     the string used as the label
  725.      * @param string $text      a string to be displayed
  726.      * @param string $thattr    a string of additional attributes to be put
  727.      *                           in the <th> element (example: 'class="foo"')
  728.      * @param string $tdattr    a string of additional attributes to be put
  729.      *                           in the <td> element (example: 'class="foo"')
  730.      * @return void
  731.      *
  732.      * @access public
  733.      * @see HTML_Form::display(),
  734.      *      HTML_Form::displayPlaintext(), HTML_Form::displayPlaintextRow(),
  735.      *      HTML_Form::returnPlaintext(), HTML_Form::returnPlaintextRow()
  736.      */
  737.     function addPlaintext($title, $text = ' ',
  738.                           $thattr = HTML_FORM_TH_ATTR,
  739.                           $tdattr = HTML_FORM_TD_ATTR)
  740.     {
  741.         $this->fields[] = array('plaintext', $title, $text, $thattr, $tdattr);
  742.     }
  743.  
  744.  
  745.     // ===========  DISPLAY  ===========
  746.  
  747.     // }}}
  748.     // {{{ start()
  749.  
  750.     /**
  751.      * Prints the opening tags for the form and table
  752.      *
  753.      * NOTE: can NOT be called statically.
  754.      *
  755.      * @param bool $multipartformdata  a bool indicating if the form should
  756.      *                                  be submitted in multipart format
  757.      * @return void
  758.      *
  759.      * @access public
  760.      * @see HTML_Form::display(), HTML_Form::end(), HTML_Form::returnStart()
  761.      */
  762.     function start($multipartformdata = false)
  763.     {
  764.         print $this->returnStart($multipartformdata);
  765.     }
  766.  
  767.     // }}}
  768.     // {{{ end()
  769.  
  770.     /**
  771.      * Prints the ending tags for the table and form
  772.      *
  773.      * NOTE: can NOT be called statically.
  774.      *
  775.      * @return void
  776.      *
  777.      * @access public
  778.      * @see HTML_Form::display(), HTML_Form::start(), HTML_Form::returnEnd()
  779.      */
  780.     function end()
  781.     {
  782.         print $this->returnEnd();
  783.     }
  784.  
  785.     // }}}
  786.     // {{{ displayText()
  787.  
  788.     /**
  789.      * Prints a text input element
  790.      *
  791.      * @param string $name      the string used in the 'name' attribute
  792.      * @param mixed  $default   a default value for the element
  793.      * @param int    $size      an integer used in the 'size' attribute
  794.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  795.      * @param string $attr      a string of additional attributes to be put
  796.      *                           in the element (example: 'id="foo"')
  797.      * @return void
  798.      *
  799.      * @access public
  800.      * @static
  801.      * @see HTML_Form::displayTextRow(), HTML_Form::addText(),
  802.      *      HTML_Form::returnText(), HTML_Form::returnTextRow()
  803.      */
  804.     function displayText($name, $default = null, $size = HTML_FORM_TEXT_SIZE,
  805.                          $maxlength = 0, $attr = '')
  806.     {
  807.         print HTML_Form::returnText($name, $default, $size, $maxlength, $attr);
  808.     }
  809.  
  810.     // }}}
  811.     // {{{ displayTextRow()
  812.  
  813.     /**
  814.      * Prints a text input element inside a table row
  815.      *
  816.      * @param string $name      the string used in the 'name' attribute
  817.      * @param string $title     the string used as the label
  818.      * @param mixed  $default   a default value for the element
  819.      * @param int    $size      an integer used in the 'size' attribute
  820.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  821.      * @param string $attr      a string of additional attributes to be put
  822.      *                           in the element (example: 'id="foo"')
  823.      * @param string $thattr    a string of additional attributes to be put
  824.      *                           in the <th> element (example: 'class="foo"')
  825.      * @param string $tdattr    a string of additional attributes to be put
  826.      *                           in the <td> element (example: 'class="foo"')
  827.      * @return void
  828.      *
  829.      * @access public
  830.      * @static
  831.      * @see HTML_Form::displayText(), HTML_Form::addText(),
  832.      *      HTML_Form::returnText(), HTML_Form::returnTextRow()
  833.      */
  834.     function displayTextRow($name, $title, $default = null,
  835.                             $size = HTML_FORM_TEXT_SIZE, $maxlength = 0,
  836.                             $attr = '', $thattr = HTML_FORM_TH_ATTR,
  837.                             $tdattr = HTML_FORM_TD_ATTR)
  838.     {
  839.         print HTML_Form::returnTextRow($name, $title, $default, $size,
  840.                                        $maxlength, $attr, $thattr, $tdattr);
  841.     }
  842.  
  843.     // }}}
  844.     // {{{ displayPassword()
  845.  
  846.     /**
  847.      * Prints a password input
  848.      *
  849.      * @param string $name      the string used in the 'name' attribute
  850.      * @param mixed  $default   a default value for the element
  851.      * @param int    $size      an integer used in the 'size' attribute
  852.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  853.      * @param string $attr      a string of additional attributes to be put
  854.      *                           in the element (example: 'id="foo"')
  855.      * @return void
  856.      *
  857.      * @access public
  858.      * @static
  859.      * @see HTML_Form::displayPasswordRow(), HTML_Form::addPassword(),
  860.      *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow()
  861.      */
  862.     function displayPassword($name, $default = null,
  863.                              $size = HTML_FORM_PASSWD_SIZE,
  864.                              $maxlength = 0, $attr = '')
  865.     {
  866.         print HTML_Form::returnPassword($name, $default, $size, $maxlength,
  867.                                         $attr);
  868.     }
  869.  
  870.     // }}}
  871.     // {{{ displayPasswordRow()
  872.  
  873.     /**
  874.      * Prints a combined password input and password
  875.      * confirmation input inside a table row
  876.      *
  877.      * @param string $name      the string used in the 'name' attribute
  878.      * @param string $title     the string used as the label
  879.      * @param mixed  $default   a default value for the element
  880.      * @param int    $size      an integer used in the 'size' attribute
  881.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  882.      * @param string $attr      a string of additional attributes to be put
  883.      *                           in the element (example: 'id="foo"')
  884.      * @param string $thattr    a string of additional attributes to be put
  885.      *                           in the <th> element (example: 'class="foo"')
  886.      * @param string $tdattr    a string of additional attributes to be put
  887.      *                           in the <td> element (example: 'class="foo"')
  888.      * @return void
  889.      *
  890.      * @access public
  891.      * @static
  892.      * @see HTML_Form::displayPasswordOneRow(),
  893.      *      HTML_Form::displayPassword(), HTML_Form::addPassword(),
  894.      *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow()
  895.      */
  896.     function displayPasswordRow($name, $title, $default = null,
  897.                                 $size = HTML_FORM_PASSWD_SIZE,
  898.                                 $maxlength = 0, $attr = '',
  899.                                 $thattr = HTML_FORM_TH_ATTR,
  900.                                 $tdattr = HTML_FORM_TD_ATTR)
  901.     {
  902.         print HTML_Form::returnPasswordRow($name, $title, $default,
  903.                                            $size, $maxlength, $attr, $thattr,
  904.                                            $tdattr);
  905.     }
  906.  
  907.     // }}}
  908.     // {{{ displayPasswordOneRow()
  909.  
  910.     /**
  911.      * Prints a password input inside a table row
  912.      *
  913.      * @param string $name      the string used in the 'name' attribute
  914.      * @param string $title     the string used as the label
  915.      * @param mixed  $default   a default value for the element
  916.      * @param int    $size      an integer used in the 'size' attribute
  917.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  918.      * @param string $attr      a string of additional attributes to be put
  919.      *                           in the element (example: 'id="foo"')
  920.      * @param string $thattr    a string of additional attributes to be put
  921.      *                           in the <th> element (example: 'class="foo"')
  922.      * @param string $tdattr    a string of additional attributes to be put
  923.      *                           in the <td> element (example: 'class="foo"')
  924.      * @return void
  925.      *
  926.      * @access public
  927.      * @static
  928.      * @see HTML_Form::displayPasswordRow(),
  929.      *      HTML_Form::displayPassword(), HTML_Form::addPassword(),
  930.      *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow(),
  931.      *      HTML_Form::returnPasswordOneRow()
  932.      */
  933.     function displayPasswordOneRow($name, $title, $default = null,
  934.                                    $size = HTML_FORM_PASSWD_SIZE,
  935.                                    $maxlength = 0, $attr = '',
  936.                                    $thattr = HTML_FORM_TH_ATTR,
  937.                                    $tdattr = HTML_FORM_TD_ATTR)
  938.     {
  939.         print HTML_Form::returnPasswordOneRow($name, $title, $default,
  940.                                               $size, $maxlength, $attr, $thattr,
  941.                                               $tdattr);
  942.     }
  943.  
  944.     // }}}
  945.     // {{{ displayCheckbox()
  946.  
  947.     /**
  948.      * Prints a checkbox input
  949.      *
  950.      * @param string $name      the string used in the 'name' attribute
  951.      * @param bool   $default   a bool indicating if item should be checked
  952.      * @param string $attr      a string of additional attributes to be put
  953.      *                           in the element (example: 'id="foo"')
  954.      * @return void
  955.      *
  956.      * @access public
  957.      * @static
  958.      * @see HTML_Form::displayCheckboxRow(), HTML_Form::addCheckbox(),
  959.      *      HTML_Form::returnCheckbox(), HTML_Form::returnCheckboxRow()
  960.      */
  961.     function displayCheckbox($name, $default = false, $attr = '')
  962.     {
  963.         print HTML_Form::returnCheckbox($name, $default, $attr);
  964.     }
  965.  
  966.     // }}}
  967.     // {{{ displayCheckboxRow()
  968.  
  969.     /**
  970.      * Prints a checkbox input inside a table row
  971.      *
  972.      * @param string $name      the string used in the 'name' attribute
  973.      * @param string $title     the string used as the label
  974.      * @param bool   $default   a bool indicating if item should be checked
  975.      * @param string $attr      a string of additional attributes to be put
  976.      *                           in the element (example: 'id="foo"')
  977.      * @param string $thattr    a string of additional attributes to be put
  978.      *                           in the <th> element (example: 'class="foo"')
  979.      * @param string $tdattr    a string of additional attributes to be put
  980.      *                           in the <td> element (example: 'class="foo"')
  981.      * @return void
  982.      *
  983.      * @access public
  984.      * @static
  985.      * @see HTML_Form::displayCheckboxRow(), HTML_Form::addCheckbox(),
  986.      *      HTML_Form::returnCheckbox(), HTML_Form::returnCheckboxRow()
  987.      */
  988.     function displayCheckboxRow($name, $title, $default = false, $attr = '',
  989.                                 $thattr = HTML_FORM_TH_ATTR,
  990.                                 $tdattr = HTML_FORM_TD_ATTR)
  991.     {
  992.         print HTML_Form::returnCheckboxRow($name, $title, $default, $attr,
  993.                                            $thattr, $tdattr);
  994.     }
  995.  
  996.     // }}}
  997.     // {{{ displayTextarea()
  998.  
  999.     /**
  1000.      * Prints a textarea input
  1001.      *
  1002.      * @param string $name      the string used in the 'name' attribute
  1003.      * @param mixed  $default   a default value for the element
  1004.      * @param int    $width     an integer saying how many characters wide
  1005.      *                           the item should be
  1006.      * @param int    $height    an integer saying how many rows tall the
  1007.      *                           item should be
  1008.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1009.      * @param string $attr      a string of additional attributes to be put
  1010.      *                           in the element (example: 'id="foo"')
  1011.      * @return void
  1012.      *
  1013.      * @access public
  1014.      * @static
  1015.      * @see HTML_Form::displayTextareaRow(), HTML_Form::addTextarea(),
  1016.      *      HTML_Form::returnTextarea(), HTML_Form::returnTextareaRow()
  1017.      */
  1018.     function displayTextarea($name, $default = null, $width = 40,
  1019.                              $height = 5, $maxlength  = '', $attr = '')
  1020.     {
  1021.         print HTML_Form::returnTextarea($name, $default, $width, $height,
  1022.                                         $maxlength, $attr);
  1023.     }
  1024.  
  1025.     // }}}
  1026.     // {{{ displayTextareaRow()
  1027.  
  1028.     /**
  1029.      * Prints a textarea input inside a table row
  1030.      *
  1031.      * @param string $name      the string used in the 'name' attribute
  1032.      * @param string $title     the string used as the label
  1033.      * @param mixed  $default   a default value for the element
  1034.      * @param int    $width     an integer saying how many characters wide
  1035.      *                           the item should be
  1036.      * @param int    $height    an integer saying how many rows tall the
  1037.      *                           item should be
  1038.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1039.      * @param string $attr      a string of additional attributes to be put
  1040.      *                           in the element (example: 'id="foo"')
  1041.      * @param string $thattr    a string of additional attributes to be put
  1042.      *                           in the <th> element (example: 'class="foo"')
  1043.      * @param string $tdattr    a string of additional attributes to be put
  1044.      *                           in the <td> element (example: 'class="foo"')
  1045.      * @return void
  1046.      *
  1047.      * @access public
  1048.      * @static
  1049.      * @see HTML_Form::displayTextareaRow(), HTML_Form::addTextarea(),
  1050.      *      HTML_Form::returnTextarea(), HTML_Form::returnTextareaRow()
  1051.      */
  1052.     function displayTextareaRow($name, $title, $default = null, $width = 40,
  1053.                                 $height = 5, $maxlength = 0, $attr = '',
  1054.                                 $thattr = HTML_FORM_TH_ATTR,
  1055.                                 $tdattr = HTML_FORM_TD_ATTR)
  1056.     {
  1057.         print HTML_Form::returnTextareaRow($name, $title, $default, $width,
  1058.                                            $height, $maxlength, $attr, $thattr,
  1059.                                            $tdattr);
  1060.     }
  1061.  
  1062.     // }}}
  1063.     // {{{ displaySubmit()
  1064.  
  1065.     /**
  1066.      * Prints a submit button
  1067.      *
  1068.      * NOTE: Unusual parameter order.
  1069.      *
  1070.      * @param string $title     a string that appears on the button
  1071.      * @param string $name      a string used in the 'name' attribute
  1072.      * @param string $attr      a string of additional attributes to be put
  1073.      *                           in the element (example: 'id="foo"')
  1074.      * @return void
  1075.      *
  1076.      * @access public
  1077.      * @static
  1078.      * @see HTML_Form::displaySubmit(), HTML_Form::addSubmit(),
  1079.      *      HTML_Form::returnSubmit(), HTML_Form::returnSubmitRow()
  1080.      */
  1081.     function displaySubmit($title = 'Submit Changes', $name = 'submit',
  1082.                            $attr = '')
  1083.     {
  1084.         print HTML_Form::returnSubmit($title, $name, $attr);
  1085.     }
  1086.  
  1087.     // }}}
  1088.     // {{{ displaySubmitRow()
  1089.  
  1090.     /**
  1091.      * Prints a submit button inside a table row
  1092.      *
  1093.      * @param string $name      a string used in the 'name' attribute
  1094.      * @param string $title     a string that appears on the button
  1095.      * @param string $attr      a string of additional attributes to be put
  1096.      *                           in the element (example: 'id="foo"')
  1097.      * @param string $thattr    a string of additional attributes to be put
  1098.      *                           in the <th> element (example: 'class="foo"')
  1099.      * @param string $tdattr    a string of additional attributes to be put
  1100.      *                           in the <td> element (example: 'class="foo"')
  1101.      * @return void
  1102.      *
  1103.      * @access public
  1104.      * @static
  1105.      * @see HTML_Form::displaySubmit(), HTML_Form::addSubmit(),
  1106.      *      HTML_Form::returnSubmit(), HTML_Form::returnSubmitRow()
  1107.      */
  1108.     function displaySubmitRow($name = 'submit', $title = 'Submit Changes',
  1109.                               $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1110.                               $tdattr = HTML_FORM_TD_ATTR)
  1111.     {
  1112.         print HTML_Form::returnSubmitRow($name, $title, $attr, $thattr, $tdattr);
  1113.     }
  1114.  
  1115.     // }}}
  1116.     // {{{ displayReset()
  1117.  
  1118.     /**
  1119.      * Prints a reset button
  1120.      *
  1121.      * NOTE: Unusual parameter order.
  1122.      *
  1123.      * @param string $title     a string that appears on the button
  1124.      * @param string $attr      a string of additional attributes to be put
  1125.      *                           in the element (example: 'id="foo"')
  1126.      * @return void
  1127.      *
  1128.      * @access public
  1129.      * @static
  1130.      * @see HTML_Form::displayResetRow(), HTML_Form::addReset(),
  1131.      *      HTML_Form::returnReset(), HTML_Form::returnResetRow()
  1132.      */
  1133.     function displayReset($title = 'Clear contents', $attr = '')
  1134.     {
  1135.         print HTML_Form::returnReset($title, $attr);
  1136.     }
  1137.  
  1138.     // }}}
  1139.     // {{{ displayResetRow()
  1140.  
  1141.     /**
  1142.      * Prints a reset button inside a table row
  1143.      *
  1144.      * NOTE: Unusual parameter order.
  1145.      *
  1146.      * @param string $title     a string that appears on the button
  1147.      * @param string $attr      a string of additional attributes to be put
  1148.      *                           in the element (example: 'id="foo"')
  1149.      * @param string $thattr    a string of additional attributes to be put
  1150.      *                           in the <th> element (example: 'class="foo"')
  1151.      * @param string $tdattr    a string of additional attributes to be put
  1152.      *                           in the <td> element (example: 'class="foo"')
  1153.      * @return void
  1154.      *
  1155.      * @access public
  1156.      * @static
  1157.      * @see HTML_Form::displayReset(), HTML_Form::addReset(),
  1158.      *      HTML_Form::returnReset(), HTML_Form::returnResetRow()
  1159.      */
  1160.     function displayResetRow($title = 'Clear contents', $attr = '',
  1161.                              $thattr = HTML_FORM_TH_ATTR,
  1162.                              $tdattr = HTML_FORM_TD_ATTR)
  1163.     {
  1164.         print HTML_Form::returnResetRow($title, $attr, $thattr, $tdattr);
  1165.     }
  1166.  
  1167.     // }}}
  1168.     // {{{ displaySelect()
  1169.  
  1170.     /**
  1171.      * Prints a select list
  1172.      *
  1173.      * NOTE:  In order for defaults to be automatically selected in the
  1174.      * output, the PHP data types of the $default must match the data types
  1175.      * of the keys in the $entries array.
  1176.      *
  1177.      * @param string $name      the string used in the 'name' attribute
  1178.      * @param array  $entries   an array containing the <options> to be listed.
  1179.      *                           The array's keys become the option values and
  1180.      *                           the array's values become the visible text.
  1181.      * @param mixed  $default   a default value for the element
  1182.      * @param int    $size      an integer saying how many rows should be
  1183.      * @param string $blank     if this string is present, an <option> will be
  1184.      *                           added to the top of the list that will contain
  1185.      *                           the given text in the visible portion and an
  1186.      *                           empty string as the value
  1187.      * @param bool   $multiple  a bool saying if multiple choices are allowed
  1188.      * @param string $attr      a string of additional attributes to be put
  1189.      *                           in the element (example: 'id="foo"')
  1190.      * @return void
  1191.      *
  1192.      * @access public
  1193.      * @static
  1194.      * @see HTML_Form::displaySelectRow(), HTML_Form::addSelect(),
  1195.      *      HTML_Form::returnSelect(), HTML_Form::returnSelectRow()
  1196.      */
  1197.     function displaySelect($name, $entries, $default = null, $size = 1,
  1198.                            $blank = '', $multiple = false, $attr = '')
  1199.     {
  1200.         print HTML_Form::returnSelect($name, $entries, $default, $size,
  1201.                                       $blank, $multiple, $attr);
  1202.     }
  1203.  
  1204.     // }}}
  1205.     // {{{ displaySelectRow()
  1206.  
  1207.     /**
  1208.      * Prints a select list inside a table row
  1209.      *
  1210.      * NOTE:  In order for defaults to be automatically selected in the
  1211.      * output, the PHP data types of the $default must match the data types
  1212.      * of the keys in the $entries array.
  1213.      *
  1214.      * @param string $name      the string used in the 'name' attribute
  1215.      * @param string $title     the string used as the label
  1216.      * @param array  $entries   an array containing the <options> to be listed.
  1217.      *                           The array's keys become the option values and
  1218.      *                           the array's values become the visible text.
  1219.      * @param mixed  $default   a default value for the element
  1220.      * @param int    $size      an integer saying how many rows should be
  1221.      * @param string $blank     if this string is present, an <option> will be
  1222.      *                           added to the top of the list that will contain
  1223.      *                           the given text in the visible portion and an
  1224.      *                           empty string as the value
  1225.      * @param bool   $multiple  a bool saying if multiple choices are allowed
  1226.      * @param string $attr      a string of additional attributes to be put
  1227.      *                           in the element (example: 'id="foo"')
  1228.      * @param string $thattr    a string of additional attributes to be put
  1229.      *                           in the <th> element (example: 'class="foo"')
  1230.      * @param string $tdattr    a string of additional attributes to be put
  1231.      *                           in the <td> element (example: 'class="foo"')
  1232.      * @return void
  1233.      *
  1234.      * @access public
  1235.      * @static
  1236.      * @see HTML_Form::displaySelect(), HTML_Form::addSelect(),
  1237.      *      HTML_Form::returnSelect(), HTML_Form::returnSelectRow()
  1238.      */
  1239.     function displaySelectRow($name, $title, $entries, $default = null,
  1240.                               $size = 1, $blank = '', $multiple = false,
  1241.                               $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1242.                               $tdattr = HTML_FORM_TD_ATTR)
  1243.     {
  1244.         print HTML_Form::returnSelectRow($name, $title, $entries, $default,
  1245.                                          $size, $blank, $multiple, $attr,
  1246.                                          $thattr, $tdattr);
  1247.     }
  1248.  
  1249.     // }}}
  1250.     // {{{ displayImage()
  1251.  
  1252.     /**
  1253.      * Prints an image input
  1254.      *
  1255.      * @param string $name      the string used in the 'name' attribute
  1256.      * @param string $src       the string denoting the path to the image.
  1257.      *                           Can be a relative path or full URI.
  1258.      * @param string $attr      a string of additional attributes to be put
  1259.      *                           in the element (example: 'id="foo"')
  1260.      * @return void
  1261.      *
  1262.      * @access public
  1263.      * @static
  1264.      * @see HTML_Form::displayImageRow(), HTML_Form::addImage(),
  1265.      *      HTML_Form::returnImage(), HTML_Form::returnImageRow()
  1266.      * @since Method available since Release 1.1.0
  1267.      */
  1268.     function displayImage($name, $src, $attr = '')
  1269.     {
  1270.         print HTML_Form::returnImage($name, $src, $attr);
  1271.     }
  1272.  
  1273.     // }}}
  1274.     // {{{ displayImageRow()
  1275.  
  1276.     /**
  1277.      * Prints an image input inside a table row
  1278.      *
  1279.      * @param string $name      the string used in the 'name' attribute
  1280.      * @param string $title     the string used as the label
  1281.      * @param string $src       the string denoting the path to the image.
  1282.      *                           Can be a relative path or full URI.
  1283.      * @param string $attr      a string of additional attributes to be put
  1284.      *                           in the element (example: 'id="foo"')
  1285.      * @param string $thattr    a string of additional attributes to be put
  1286.      *                           in the <th> element (example: 'class="foo"')
  1287.      * @param string $tdattr    a string of additional attributes to be put
  1288.      *                           in the <td> element (example: 'class="foo"')
  1289.      * @return void
  1290.      *
  1291.      * @access public
  1292.      * @static
  1293.      * @see HTML_Form::displayImage(), HTML_Form::addImage(),
  1294.      *      HTML_Form::returnImage(), HTML_Form::returnImageRow()
  1295.      * @since Method available since Release 1.1.0
  1296.      */
  1297.     function displayImageRow($name, $title, $src, $attr = '',
  1298.                              $thattr = HTML_FORM_TH_ATTR,
  1299.                              $tdattr = HTML_FORM_TD_ATTR)
  1300.     {
  1301.         print HTML_Form::returnImageRow($name, $title, $src, $attr, $thattr,
  1302.                                         $tdattr);
  1303.     }
  1304.  
  1305.     // }}}
  1306.     // {{{ displayHidden()
  1307.  
  1308.     /**
  1309.      * Prints a hiden input
  1310.      *
  1311.      * @param string $name      the string used in the 'name' attribute
  1312.      * @param string $value     the string used for the item's value
  1313.      * @param string $attr      a string of additional attributes to be put
  1314.      *                           in the element (example: 'id="foo"')
  1315.      * @return void
  1316.      *
  1317.      * @access public
  1318.      * @static
  1319.      * @see HTML_Form::returnHidden(), HTML_Form::addHidden()
  1320.      */
  1321.     function displayHidden($name, $value, $attr = '')
  1322.     {
  1323.         print HTML_Form::returnHidden($name, $value, $attr);
  1324.     }
  1325.  
  1326.     // }}}
  1327.  
  1328.     // assuming that $default is the 'checked' attribut of the radio tag
  1329.  
  1330.     // {{{ displayRadio()
  1331.  
  1332.     /**
  1333.      * Prints a radio input
  1334.      *
  1335.      * @param string $name      the string used in the 'name' attribute
  1336.      * @param string $value     the string used for the item's value
  1337.      * @param bool   $default   a bool indicating if item should be checked
  1338.      * @param string $attr      a string of additional attributes to be put
  1339.      *                           in the element (example: 'id="foo"')
  1340.      * @return void
  1341.      *
  1342.      * @access public
  1343.      * @static
  1344.      * @see HTML_Form::displayRadioRow(), HTML_Form::addRadio(),
  1345.      *      HTML_Form::returnRadio(), HTML_Form::returnRadioRow()
  1346.      */
  1347.     function displayRadio($name, $value, $default = false, $attr = '')
  1348.     {
  1349.         print HTML_Form::returnRadio($name, $value, $default, $attr);
  1350.     }
  1351.  
  1352.     // }}}
  1353.     // {{{ displayRadioRow()
  1354.  
  1355.     /**
  1356.      * Prints a radio input inside a table row
  1357.      *
  1358.      * @param string $name      the string used in the 'name' attribute
  1359.      * @param string $title     the string used as the label
  1360.      * @param string $value     the string used for the item's value
  1361.      * @param bool   $default   a bool indicating if item should be checked
  1362.      * @param string $attr      a string of additional attributes to be put
  1363.      *                           in the element (example: 'id="foo"')
  1364.      * @param string $thattr    a string of additional attributes to be put
  1365.      *                           in the <th> element (example: 'class="foo"')
  1366.      * @param string $tdattr    a string of additional attributes to be put
  1367.      *                           in the <td> element (example: 'class="foo"')
  1368.      * @return void
  1369.      *
  1370.      * @access public
  1371.      * @static
  1372.      * @see HTML_Form::displayRadio(), HTML_Form::addRadio(),
  1373.      *      HTML_Form::returnRadio(), HTML_Form::returnRadioRow()
  1374.      */
  1375.     function displayRadioRow($name, $title, $value, $default = false,
  1376.                              $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1377.                              $tdattr = HTML_FORM_TD_ATTR)
  1378.     {
  1379.         print HTML_Form::returnRadioRow($name, $title, $value, $default,
  1380.                                         $attr, $thattr, $tdattr);
  1381.     }
  1382.  
  1383.     // }}}
  1384.     // {{{ displayBlank()
  1385.  
  1386.     /**
  1387.      * Prints  
  1388.      *
  1389.      * @return void
  1390.      *
  1391.      * @access public
  1392.      * @static
  1393.      * @see HTML_Form::displayBlankRow(), HTML_Form::addBlank(),
  1394.      *      HTML_Form::returnBlank(), HTML_Form::returnBlankRow()
  1395.      */
  1396.     function displayBlank()
  1397.     {
  1398.         print HTML_Form::returnBlank();
  1399.     }
  1400.  
  1401.     // }}}
  1402.     // {{{ displayBlankRow()
  1403.  
  1404.     /**
  1405.      * Prints a blank row in the table
  1406.      *
  1407.      * @param int    $i         the number of rows to create.  Ignored if
  1408.      *                           $title is used.
  1409.      * @param string $title     a string to be used as the label for the row
  1410.      * @param string $thattr    a string of additional attributes to be put
  1411.      *                           in the <th> element (example: 'class="foo"')
  1412.      * @param string $tdattr    a string of additional attributes to be put
  1413.      *                           in the <td> element (example: 'class="foo"')
  1414.      * @return void
  1415.      *
  1416.      * @access public
  1417.      * @static
  1418.      * @see HTML_Form::displayBlank(), HTML_Form::addBlank(),
  1419.      *      HTML_Form::returnBlank(), HTML_Form::returnBlankRow()
  1420.      */
  1421.     function displayBlankRow($i, $title= '', $thattr = HTML_FORM_TH_ATTR,
  1422.                              $tdattr = HTML_FORM_TD_ATTR)
  1423.     {
  1424.         print HTML_Form::returnBlankRow($i, $title, $thattr, $tdattr);
  1425.     }
  1426.  
  1427.     // }}}
  1428.     // {{{ displayFile()
  1429.  
  1430.     /**
  1431.      * Prints a file upload input
  1432.      *
  1433.      * @param string $name      the string used in the 'name' attribute
  1434.      * @param int    $maxsize   an integer determining how large (in bytes) a
  1435.      *                           submitted file can be.
  1436.      * @param int    $size      an integer used in the 'size' attribute
  1437.      * @param string $accept    a string saying which MIME types are allowed
  1438.      * @param string $attr      a string of additional attributes to be put
  1439.      *                           in the element (example: 'id="foo"')
  1440.      * @return void
  1441.      *
  1442.      * @access public
  1443.      * @static
  1444.      * @see HTML_Form::displayFileRow(), HTML_Form::addFile(),
  1445.      *      HTML_Form::returnFile(), HTML_Form::returnFileRow(),
  1446.      *      HTML_Form::returnMultipleFiles()
  1447.      */
  1448.     function displayFile($name, $maxsize = HTML_FORM_MAX_FILE_SIZE,
  1449.                          $size = HTML_FORM_TEXT_SIZE, $accept = '',
  1450.                          $attr = '')
  1451.     {
  1452.         print HTML_Form::returnFile($name, $maxsize, $size, $accept, $attr);
  1453.     }
  1454.  
  1455.     // }}}
  1456.     // {{{ displayFileRow()
  1457.  
  1458.     /**
  1459.      * Prints a file upload input inside a table row
  1460.      *
  1461.      * @param string $name      the string used in the 'name' attribute
  1462.      * @param string $title     the string used as the label
  1463.      * @param int    $maxsize   an integer determining how large (in bytes) a
  1464.      *                           submitted file can be.
  1465.      * @param int    $size      an integer used in the 'size' attribute
  1466.      * @param string $accept    a string saying which MIME types are allowed
  1467.      * @param string $attr      a string of additional attributes to be put
  1468.      *                           in the element (example: 'id="foo"')
  1469.      * @param string $thattr    a string of additional attributes to be put
  1470.      *                           in the <th> element (example: 'class="foo"')
  1471.      * @param string $tdattr    a string of additional attributes to be put
  1472.      *                           in the <td> element (example: 'class="foo"')
  1473.      * @return void
  1474.      *
  1475.      * @access public
  1476.      * @static
  1477.      * @see HTML_Form::displayFile(), HTML_Form::addFile(),
  1478.      *      HTML_Form::returnFile(), HTML_Form::returnFileRow(),
  1479.      *      HTML_Form::returnMultipleFiles()
  1480.      */
  1481.     function displayFileRow($name, $title, $maxsize = HTML_FORM_MAX_FILE_SIZE,
  1482.                             $size = HTML_FORM_TEXT_SIZE, $accept = '',
  1483.                             $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1484.                             $tdattr = HTML_FORM_TD_ATTR)
  1485.     {
  1486.         print HTML_Form::returnFileRow($name, $title, $maxsize,
  1487.                                        $size, $accept, $attr, $thattr, $tdattr);
  1488.     }
  1489.  
  1490.     // }}}
  1491.     // {{{ displayPlaintext()
  1492.  
  1493.     /**
  1494.      * Prints the text provided
  1495.      *
  1496.      * @param string $text      a string to be displayed
  1497.      *
  1498.      * @return void
  1499.      *
  1500.      * @access public
  1501.      * @static
  1502.      * @see HTML_Form::displayPlaintextRow(), HTML_Form::addPlaintext(),
  1503.      *      HTML_Form::returnPlaintext(), HTML_Form::returnPlaintextRow()
  1504.      */
  1505.     function displayPlaintext($text = ' ')
  1506.     {
  1507.         print $text;
  1508.     }
  1509.  
  1510.     // }}}
  1511.     // {{{ displayPlaintextRow()
  1512.  
  1513.     /**
  1514.      * Prints the text provided inside a table row
  1515.      *
  1516.      * @param string $title     the string used as the label
  1517.      * @param string $text      a string to be displayed
  1518.      * @param string $thattr    a string of additional attributes to be put
  1519.      *                           in the <th> element (example: 'class="foo"')
  1520.      * @param string $tdattr    a string of additional attributes to be put
  1521.      *                           in the <td> element (example: 'class="foo"')
  1522.      * @return void
  1523.      *
  1524.      * @access public
  1525.      * @static
  1526.      * @see HTML_Form::displayPlaintext(), HTML_Form::addPlaintext(),
  1527.      *      HTML_Form::returnPlaintext(), HTML_Form::returnPlaintextRow()
  1528.      */
  1529.     function displayPlaintextRow($title, $text = ' ',
  1530.                                  $thattr = 'align="right valign="top""',
  1531.                                  $tdattr = HTML_FORM_TD_ATTR)
  1532.     {
  1533.         print HTML_Form::returnPlaintextRow($title, $text, $thattr, $tdattr);
  1534.     }
  1535.  
  1536.  
  1537.     // ===========  RETURN  ===========
  1538.  
  1539.     // }}}
  1540.     // {{{ returnText()
  1541.  
  1542.     /**
  1543.      * Produce a string containing a text input
  1544.      *
  1545.      * @param string $name      the string used in the 'name' attribute
  1546.      * @param mixed  $default   a default value for the element
  1547.      * @param int    $size      an integer used in the 'size' attribute
  1548.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1549.      * @param string $attr      a string of additional attributes to be put
  1550.      *                           in the element (example: 'id="foo"')
  1551.      * @return string
  1552.      *
  1553.      * @access public
  1554.      * @static
  1555.      * @see HTML_Form::displayText(), HTML_Form::displayTextRow(),
  1556.      *      HTML_Form::returnTextRow(), HTML_Form::addText()
  1557.      */
  1558.     function returnText($name, $default = null, $size = HTML_FORM_TEXT_SIZE,
  1559.                         $maxlength = 0, $attr = '')
  1560.     {
  1561.         $str  = '<input type="text" name="' . $name . '" ';
  1562.         $str .= 'size="' . $size . '" value="' . $default . '" ';
  1563.         if ($maxlength) {
  1564.             $str .= 'maxlength="' . $maxlength. '" ';
  1565.         }
  1566.         return $str . $attr . "/>\n";
  1567.     }
  1568.  
  1569.     // }}}
  1570.     // {{{ returnTextRow()
  1571.  
  1572.     /**
  1573.      * Produce a string containing a text input inside a table row
  1574.      *
  1575.      * @param string $name      the string used in the 'name' attribute
  1576.      * @param string $title     the string used as the label
  1577.      * @param mixed  $default   a default value for the element
  1578.      * @param int    $size      an integer used in the 'size' attribute
  1579.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1580.      * @param string $attr      a string of additional attributes to be put
  1581.      *                           in the element (example: 'id="foo"')
  1582.      * @param string $thattr    a string of additional attributes to be put
  1583.      *                           in the <th> element (example: 'class="foo"')
  1584.      * @param string $tdattr    a string of additional attributes to be put
  1585.      *                           in the <td> element (example: 'class="foo"')
  1586.      * @return string
  1587.      *
  1588.      * @access public
  1589.      * @static
  1590.      * @see HTML_Form::displayText(), HTML_Form::displayTextRow(),
  1591.      *      HTML_Form::returnText(), HTML_Form::addText()
  1592.      */
  1593.     function returnTextRow($name, $title, $default = null,
  1594.                            $size = HTML_FORM_TEXT_SIZE, $maxlength = 0,
  1595.                            $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1596.                            $tdattr = HTML_FORM_TD_ATTR)
  1597.     {
  1598.         $str  = " <tr>\n";
  1599.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  1600.         $str .= '  <td ' . $tdattr . ">\n   ";
  1601.         $str .= HTML_Form::returnText($name, $default, $size, $maxlength,
  1602.                                       $attr);
  1603.         $str .= "  </td>\n";
  1604.         $str .= " </tr>\n";
  1605.  
  1606.         return $str;
  1607.     }
  1608.  
  1609.     // }}}
  1610.     // {{{ returnPassword()
  1611.  
  1612.     /**
  1613.      * Produce a string containing a password input
  1614.      *
  1615.      * @param string $name      the string used in the 'name' attribute
  1616.      * @param mixed  $default   a default value for the element
  1617.      * @param int    $size      an integer used in the 'size' attribute
  1618.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1619.      * @param string $attr      a string of additional attributes to be put
  1620.      *                           in the element (example: 'id="foo"')
  1621.      * @return string
  1622.      *
  1623.      * @access public
  1624.      * @static
  1625.      * @see HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),
  1626.      *      HTML_Form::returnPasswordRow(), HTML_Form::addPassword()
  1627.      */
  1628.     function returnPassword($name, $default = null,
  1629.                             $size = HTML_FORM_PASSWD_SIZE,
  1630.                             $maxlength = 0, $attr = '')
  1631.     {
  1632.         $str  = '<input type="password" name="' . $name . '" ';
  1633.         $str .= 'size="' . $size . '" value="' . $default . '" ';
  1634.         if ($maxlength) {
  1635.             $str .= 'maxlength="' . $maxlength. '" ';
  1636.         }
  1637.         return $str . $attr . "/>\n";
  1638.     }
  1639.  
  1640.     // }}}
  1641.     // {{{ returnPasswordRow()
  1642.  
  1643.     /**
  1644.      * Produce a string containing a combined password input and password
  1645.      * confirmation input inside a table row
  1646.      *
  1647.      * @param string $name      the string used in the 'name' attribute
  1648.      * @param string $title     the string used as the label
  1649.      * @param mixed  $default   a default value for the element
  1650.      * @param int    $size      an integer used in the 'size' attribute
  1651.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1652.      * @param string $attr      a string of additional attributes to be put
  1653.      *                           in the element (example: 'id="foo"')
  1654.      * @param string $thattr    a string of additional attributes to be put
  1655.      *                           in the <th> element (example: 'class="foo"')
  1656.      * @param string $tdattr    a string of additional attributes to be put
  1657.      *                           in the <td> element (example: 'class="foo"')
  1658.      * @return string
  1659.      *
  1660.      * @access public
  1661.      * @static
  1662.      * @see HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),
  1663.      *      HTML_Form::returnPassword(), HTML_Form::addPassword()
  1664.      */
  1665.     function returnPasswordRow($name, $title, $default = null,
  1666.                                $size = HTML_FORM_PASSWD_SIZE,
  1667.                                $maxlength = 0, $attr = '',
  1668.                                $thattr = HTML_FORM_TH_ATTR,
  1669.                                $tdattr = HTML_FORM_TD_ATTR)
  1670.     {
  1671.         $str  = " <tr>\n";
  1672.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  1673.         $str .= '  <td ' . $tdattr . ">\n   ";
  1674.         $str .= HTML_Form::returnPassword($name, $default, $size,
  1675.                                           $maxlength, $attr);
  1676.         $str .= "   repeat: ";
  1677.         $str .= HTML_Form::returnPassword($name.'2', $default, $size,
  1678.                                           $maxlength, $attr);
  1679.         $str .= "  </td>\n";
  1680.         $str .= " </tr>\n";
  1681.  
  1682.         return $str;
  1683.     }
  1684.  
  1685.     // }}}
  1686.     // {{{ returnPasswordOneRow()
  1687.  
  1688.     /**
  1689.      * Produce a string containing a password input inside a table row
  1690.      *
  1691.      * @param string $name      the string used in the 'name' attribute
  1692.      * @param string $title     the string used as the label
  1693.      * @param mixed  $default   a default value for the element
  1694.      * @param int    $size      an integer used in the 'size' attribute
  1695.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1696.      * @param string $attr      a string of additional attributes to be put
  1697.      *                           in the element (example: 'id="foo"')
  1698.      * @param string $thattr    a string of additional attributes to be put
  1699.      *                           in the <th> element (example: 'class="foo"')
  1700.      * @param string $tdattr    a string of additional attributes to be put
  1701.      *                           in the <td> element (example: 'class="foo"')
  1702.      * @return string
  1703.      *
  1704.      * @access public
  1705.      * @static
  1706.      * @see HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),
  1707.      *      HTML_Form::returnPassword(), HTML_Form::addPassword(),
  1708.      *      HTML_Form::displayPasswordOneRow()
  1709.      */
  1710.     function returnPasswordOneRow($name, $title, $default = null,
  1711.                                   $size = HTML_FORM_PASSWD_SIZE,
  1712.                                   $maxlength = 0, $attr = '',
  1713.                                   $thattr = HTML_FORM_TH_ATTR,
  1714.                                   $tdattr = HTML_FORM_TD_ATTR)
  1715.     {
  1716.         $str  = " <tr>\n";
  1717.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  1718.         $str .= '  <td ' . $tdattr . ">\n   ";
  1719.         $str .= HTML_Form::returnPassword($name, $default, $size,
  1720.                                           $maxlength, $attr);
  1721.         $str .= "  </td>\n";
  1722.         $str .= " </tr>\n";
  1723.  
  1724.         return $str;
  1725.     }
  1726.  
  1727.     // }}}
  1728.     // {{{ returnCheckbox()
  1729.  
  1730.     /**
  1731.      * Produce a string containing a checkbox input
  1732.      *
  1733.      * @param string $name      the string used in the 'name' attribute
  1734.      * @param bool   $default   a bool indicating if item should be checked
  1735.      * @param string $attr      a string of additional attributes to be put
  1736.      *                           in the element (example: 'id="foo"')
  1737.      * @return string
  1738.      *
  1739.      * @access public
  1740.      * @static
  1741.      * @see HTML_Form::displayCheckbox(), HTML_Form::displayCheckboxRow(),
  1742.      *      HTML_Form::returnCheckboxRow(), HTML_Form::addCheckbox()
  1743.      */
  1744.     function returnCheckbox($name, $default = false, $attr = '')
  1745.     {
  1746.         $str = "<input type=\"checkbox\" name=\"$name\"";
  1747.         if ($default && $default !== 'off') {
  1748.             $str .= ' checked="checked"';
  1749.         }
  1750.         return $str . ' ' . $attr . "/>\n";
  1751.     }
  1752.  
  1753.     // }}}
  1754.     // {{{ returnCheckboxRow()
  1755.  
  1756.     /**
  1757.      * Produce a string containing a checkbox input inside a table row
  1758.      *
  1759.      * @param string $name      the string used in the 'name' attribute
  1760.      * @param string $title     the string used as the label
  1761.      * @param bool   $default   a bool indicating if item should be checked
  1762.      * @param string $attr      a string of additional attributes to be put
  1763.      *                           in the element (example: 'id="foo"')
  1764.      * @param string $thattr    a string of additional attributes to be put
  1765.      *                           in the <th> element (example: 'class="foo"')
  1766.      * @param string $tdattr    a string of additional attributes to be put
  1767.      *                           in the <td> element (example: 'class="foo"')
  1768.      * @return string
  1769.      *
  1770.      * @access public
  1771.      * @static
  1772.      * @see HTML_Form::displayCheckbox(), HTML_Form::displayCheckboxRow(),
  1773.      *      HTML_Form::returnCheckbox(), HTML_Form::addCheckbox()
  1774.      */
  1775.     function returnCheckboxRow($name, $title, $default = false, $attr = '',
  1776.                                $thattr = HTML_FORM_TH_ATTR,
  1777.                                $tdattr = HTML_FORM_TD_ATTR)
  1778.     {
  1779.         $str  = " <tr>\n";
  1780.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  1781.         $str .= '  <td ' . $tdattr . ">\n   ";
  1782.         $str .= HTML_Form::returnCheckbox($name, $default, $attr);
  1783.         $str .= "  </td>\n";
  1784.         $str .= " </tr>\n";
  1785.  
  1786.         return $str;
  1787.     }
  1788.  
  1789.     // }}}
  1790.     // {{{ returnTextarea()
  1791.  
  1792.     /**
  1793.      * Produce a string containing a textarea input
  1794.      *
  1795.      * @param string $name      the string used in the 'name' attribute
  1796.      * @param mixed  $default   a default value for the element
  1797.      * @param int    $width     an integer saying how many characters wide
  1798.      *                           the item should be
  1799.      * @param int    $height    an integer saying how many rows tall the
  1800.      *                           item should be
  1801.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1802.      * @param string $attr      a string of additional attributes to be put
  1803.      *                           in the element (example: 'id="foo"')
  1804.      * @return string
  1805.      *
  1806.      * @access public
  1807.      * @static
  1808.      * @see HTML_Form::displayTextarea(), HTML_Form::displayTextareaRow(),
  1809.      *      HTML_Form::returnTextareaRow(), HTML_Form::addTextarea()
  1810.      */
  1811.     function returnTextarea($name, $default = null, $width = 40, $height = 5,
  1812.                             $maxlength = 0, $attr = '')
  1813.     {
  1814.         $str  = '<textarea name="' . $name . '" cols="' . $width . '"';
  1815.         $str .= ' rows="' . $height . '" ';
  1816.         if ($maxlength) {
  1817.             $str .= 'maxlength="' . $maxlength. '" ';
  1818.         }
  1819.         $str .=  $attr . '>';
  1820.         $str .= $default;
  1821.         $str .= "</textarea>\n";
  1822.  
  1823.         return $str;
  1824.     }
  1825.  
  1826.     // }}}
  1827.     // {{{ returnTextareaRow()
  1828.  
  1829.     /**
  1830.      * Produce a string containing a textarea input inside a table row
  1831.      *
  1832.      * @param string $name      the string used in the 'name' attribute
  1833.      * @param string $title     the string used as the label
  1834.      * @param mixed  $default   a default value for the element
  1835.      * @param int    $width     an integer saying how many characters wide
  1836.      *                           the item should be
  1837.      * @param int    $height    an integer saying how many rows tall the
  1838.      *                           item should be
  1839.      * @param int    $maxlength an integer used in the 'maxlength' attribute
  1840.      * @param string $attr      a string of additional attributes to be put
  1841.      *                           in the element (example: 'id="foo"')
  1842.      * @param string $thattr    a string of additional attributes to be put
  1843.      *                           in the <th> element (example: 'class="foo"')
  1844.      * @param string $tdattr    a string of additional attributes to be put
  1845.      *                           in the <td> element (example: 'class="foo"')
  1846.      * @return string
  1847.      *
  1848.      * @access public
  1849.      * @static
  1850.      * @see HTML_Form::displayTextarea(), HTML_Form::displayTextareaRow(),
  1851.      *      HTML_Form::returnTextareaRow(), HTML_Form::addTextarea()
  1852.      */
  1853.     function returnTextareaRow($name, $title, $default = null, $width = 40,
  1854.                                $height = 5, $maxlength = 0, $attr = '',
  1855.                                $thattr = HTML_FORM_TH_ATTR,
  1856.                                $tdattr = HTML_FORM_TD_ATTR)
  1857.     {
  1858.         $str  = " <tr>\n";
  1859.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  1860.         $str .= '  <td ' . $tdattr . ">\n   ";
  1861.         $str .= HTML_Form::returnTextarea($name, $default, $width, $height,
  1862.                                       $maxlength, $attr);
  1863.         $str .= "  </td>\n";
  1864.         $str .= " </tr>\n";
  1865.  
  1866.         return $str;
  1867.     }
  1868.  
  1869.     // }}}
  1870.     // {{{ returnSubmit()
  1871.  
  1872.     /**
  1873.      * Produce a string containing a submit button
  1874.      *
  1875.      * NOTE: Unusual parameter order.
  1876.      *
  1877.      * @param string $title     a string that appears on the button
  1878.      * @param string $name      a string used in the 'name' attribute
  1879.      * @param string $attr      a string of additional attributes to be put
  1880.      *                           in the element (example: 'id="foo"')
  1881.      * @return string
  1882.      *
  1883.      * @access public
  1884.      * @static
  1885.      * @see HTML_Form::displaySubmit(), HTML_Form::displaySubmitRow(),
  1886.      *      HTML_Form::returnSubmitRow(), HTML_Form::addSubmit()
  1887.      */
  1888.     function returnSubmit($title = 'Submit Changes', $name = 'submit',
  1889.                           $attr = '')
  1890.     {
  1891.         return '<input type="submit" name="' . $name . '"'
  1892.                . ' value="' . $title . '" ' . $attr . "/>\n";
  1893.     }
  1894.  
  1895.     // }}}
  1896.     // {{{ returnSubmitRow()
  1897.  
  1898.     /**
  1899.      * Produce a string containing a submit button inside a table row
  1900.      *
  1901.      * @param string $name      a string used in the 'name' attribute
  1902.      * @param string $title     a string that appears on the button
  1903.      * @param string $attr      a string of additional attributes to be put
  1904.      *                           in the element (example: 'id="foo"')
  1905.      * @param string $thattr    a string of additional attributes to be put
  1906.      *                           in the <th> element (example: 'class="foo"')
  1907.      * @param string $tdattr    a string of additional attributes to be put
  1908.      *                           in the <td> element (example: 'class="foo"')
  1909.      * @return string
  1910.      *
  1911.      * @access public
  1912.      * @static
  1913.      * @see HTML_Form::displaySubmit(), HTML_Form::displaySubmitRow(),
  1914.      *      HTML_Form::returnSubmit(), HTML_Form::addSubmit()
  1915.      */
  1916.     function returnSubmitRow($name = 'submit', $title = 'Submit Changes',
  1917.                              $attr = '', $thattr = HTML_FORM_TH_ATTR,
  1918.                              $tdattr = HTML_FORM_TD_ATTR)
  1919.     {
  1920.         $str  = " <tr>\n";
  1921.         $str .= '  <th ' . $thattr . "> </th>\n";
  1922.         $str .= '  <td ' . $tdattr . ">\n   ";
  1923.         $str .= HTML_Form::returnSubmit($title, $name, $attr);
  1924.         $str .= "  </td>\n";
  1925.         $str .= " </tr>\n";
  1926.  
  1927.         return $str;
  1928.     }
  1929.  
  1930.     // }}}
  1931.     // {{{ returnReset()
  1932.  
  1933.     /**
  1934.      * Produce a string containing a reset button
  1935.      *
  1936.      * NOTE: Unusual parameter order.
  1937.      *
  1938.      * @param string $title     a string that appears on the button
  1939.      * @param string $attr      a string of additional attributes to be put
  1940.      *                           in the element (example: 'id="foo"')
  1941.      * @return string
  1942.      *
  1943.      * @access public
  1944.      * @static
  1945.      * @see HTML_Form::displayReset(), HTML_Form::displayResetRow(),
  1946.      *      HTML_Form::returnResetRow(), HTML_Form::addReset()
  1947.      */
  1948.     function returnReset($title = 'Clear contents', $attr = '')
  1949.     {
  1950.         return '<input type="reset"'
  1951.                . ' value="' . $title . '" ' . $attr . "/>\n";
  1952.     }
  1953.  
  1954.     // }}}
  1955.     // {{{ returnResetRow()
  1956.  
  1957.     /**
  1958.      * Produce a string containing a reset button inside a table row
  1959.      *
  1960.      * NOTE: Unusual parameter order.
  1961.      *
  1962.      * @param string $title     a string that appears on the button
  1963.      * @param string $attr      a string of additional attributes to be put
  1964.      *                           in the element (example: 'id="foo"')
  1965.      * @param string $thattr    a string of additional attributes to be put
  1966.      *                           in the <th> element (example: 'class="foo"')
  1967.      * @param string $tdattr    a string of additional attributes to be put
  1968.      *                           in the <td> element (example: 'class="foo"')
  1969.      * @return string
  1970.      *
  1971.      * @access public
  1972.      * @static
  1973.      * @see HTML_Form::displayReset(), HTML_Form::displayResetRow(),
  1974.      *      HTML_Form::returnReset(), HTML_Form::addReset()
  1975.      */
  1976.     function returnResetRow($title = 'Clear contents', $attr = '',
  1977.                             $thattr = HTML_FORM_TH_ATTR,
  1978.                             $tdattr = HTML_FORM_TD_ATTR)
  1979.     {
  1980.         $str  = " <tr>\n";
  1981.         $str .= '  <th ' . $thattr . "> </th>\n";
  1982.         $str .= '  <td ' . $tdattr . ">\n   ";
  1983.         $str .= HTML_Form::returnReset($title, $attr);
  1984.         $str .= "  </td>\n";
  1985.         $str .= " </tr>\n";
  1986.  
  1987.         return $str;
  1988.     }
  1989.  
  1990.     // }}}
  1991.     // {{{ returnSelect()
  1992.  
  1993.     /**
  1994.      * Produce a string containing a select list
  1995.      *
  1996.      * NOTE:  In order for defaults to be automatically selected in the
  1997.      * output, the PHP data types of the $default must match the data types
  1998.      * of the keys in the $entries array.
  1999.      *
  2000.      * @param string $name      the string used in the 'name' attribute
  2001.      * @param array  $entries   an array containing the <options> to be listed.
  2002.      *                           The array's keys become the option values and
  2003.      *                           the array's values become the visible text.
  2004.      * @param mixed  $default   a default value for the element
  2005.      * @param int    $size      an integer saying how many rows should be
  2006.      * @param string $blank     if this string is present, an <option> will be
  2007.      *                           added to the top of the list that will contain
  2008.      *                           the given text in the visible portion and an
  2009.      *                           empty string as the value
  2010.      * @param bool   $multiple  a bool saying if multiple choices are allowed
  2011.      * @param string $attr      a string of additional attributes to be put
  2012.      *                           in the element (example: 'id="foo"')
  2013.      * @return string
  2014.      *
  2015.      * @access public
  2016.      * @static
  2017.      * @see HTML_Form::displaySelect(), HTML_Form::displaySelectRow(),
  2018.      *      HTML_Form::returnSelectRow(), HTML_Form::addSelect()
  2019.      */
  2020.     function returnSelect($name, $entries, $default = null, $size = 1,
  2021.                           $blank = '', $multiple = false, $attr = '')
  2022.     {
  2023.         if ($multiple && substr($name, -2) != '[]') {
  2024.             $name .= '[]';
  2025.         }
  2026.         $str = '   <select name="' . $name . '"';
  2027.         if ($size) {
  2028.             $str .= ' size="' . $size . '"';
  2029.         }
  2030.         if ($multiple) {
  2031.             $str .= ' multiple="multiple"';
  2032.         }
  2033.         $str .= ' ' . $attr . ">\n";
  2034.         if ($blank) {
  2035.             $str .= '    <option value="">' . $blank . '</option>' . "\n";
  2036.         }
  2037.  
  2038.         foreach ($entries as $val => $text) {
  2039.             $str .= '    <option ';
  2040.                 if (!is_null($default)) {
  2041.                     if ($multiple && is_array($default)) {
  2042.                         if ((is_string(key($default)) && $default[$val]) ||
  2043.                             (is_int(key($default)) && in_array($val, $default))) {
  2044.                             $str .= 'selected="selected" ';
  2045.                         }
  2046.                     } elseif ($default === $val) {
  2047.                         $str .= 'selected="selected" ';
  2048.                     }
  2049.                 }
  2050.             $str .= 'value="' . $val . '">' . $text . "</option>\n";
  2051.         }
  2052.         $str .= "   </select>\n";
  2053.  
  2054.         return $str;
  2055.     }
  2056.  
  2057.     // }}}
  2058.     // {{{ returnSelectRow()
  2059.  
  2060.     /**
  2061.      * Produce a string containing a select list inside a table row
  2062.      *
  2063.      * NOTE:  In order for defaults to be automatically selected in the
  2064.      * output, the PHP data types of the $default must match the data types
  2065.      * of the keys in the $entries array.
  2066.      *
  2067.      * @param string $name      the string used in the 'name' attribute
  2068.      * @param string $title     the string used as the label
  2069.      * @param array  $entries   an array containing the <options> to be listed.
  2070.      *                           The array's keys become the option values and
  2071.      *                           the array's values become the visible text.
  2072.      * @param mixed  $default   a default value for the element
  2073.      * @param int    $size      an integer saying how many rows should be
  2074.      * @param string $blank     if this string is present, an <option> will be
  2075.      *                           added to the top of the list that will contain
  2076.      *                           the given text in the visible portion and an
  2077.      *                           empty string as the value
  2078.      * @param bool   $multiple  a bool saying if multiple choices are allowed
  2079.      * @param string $attr      a string of additional attributes to be put
  2080.      *                           in the element (example: 'id="foo"')
  2081.      * @param string $thattr    a string of additional attributes to be put
  2082.      *                           in the <th> element (example: 'class="foo"')
  2083.      * @param string $tdattr    a string of additional attributes to be put
  2084.      *                           in the <td> element (example: 'class="foo"')
  2085.      * @return string
  2086.      *
  2087.      * @access public
  2088.      * @static
  2089.      * @see HTML_Form::displaySelect(), HTML_Form::displaySelectRow(),
  2090.      *      HTML_Form::returnSelect(), HTML_Form::addSelect()
  2091.      */
  2092.     function returnSelectRow($name, $title, $entries, $default = null, $size = 1,
  2093.                              $blank = '', $multiple = false, $attr = '',
  2094.                              $thattr = HTML_FORM_TH_ATTR,
  2095.                              $tdattr = HTML_FORM_TD_ATTR)
  2096.     {
  2097.         $str  = " <tr>\n";
  2098.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  2099.         $str .= '  <td ' . $tdattr . ">\n";
  2100.         $str .= HTML_Form::returnSelect($name, $entries, $default, $size,
  2101.                                         $blank, $multiple, $attr);
  2102.         $str .= "  </td>\n";
  2103.         $str .= " </tr>\n";
  2104.  
  2105.         return $str;
  2106.     }
  2107.  
  2108.     // }}}
  2109.     // {{{ returnRadio()
  2110.  
  2111.     /**
  2112.      * Produce a string containing a radio input
  2113.      *
  2114.      * @param string $name      the string used in the 'name' attribute
  2115.      * @param string $value     the string used for the item's value
  2116.      * @param bool   $default   a bool indicating if item should be checked
  2117.      * @param string $attr      a string of additional attributes to be put
  2118.      *                           in the element (example: 'id="foo"')
  2119.      * @return string
  2120.      *
  2121.      * @access public
  2122.      * @static
  2123.      * @see HTML_Form::displayRadio(), HTML_Form::displayRadioRow(),
  2124.      *      HTML_Form::returnRadioRow(), HTML_Form::addRadio()
  2125.      * @since Method available since Release 1.1.0
  2126.      */
  2127.     function returnRadio($name, $value, $default = false, $attr = '')
  2128.     {
  2129.         return '<input type="radio" name="' . $name . '"' .
  2130.                ' value="' . $value . '"' .
  2131.                ($default ? ' checked="checked"' : '') .
  2132.                ' ' . $attr . "/>\n";
  2133.     }
  2134.  
  2135.     // }}}
  2136.     // {{{ returnRadioRow()
  2137.  
  2138.     /**
  2139.      * Produce a string containing a radio input inside a table row
  2140.      *
  2141.      * @param string $name      the string used in the 'name' attribute
  2142.      * @param string $title     the string used as the label
  2143.      * @param string $value     the string used for the item's value
  2144.      * @param bool   $default   a bool indicating if item should be checked
  2145.      * @param string $attr      a string of additional attributes to be put
  2146.      *                           in the element (example: 'id="foo"')
  2147.      * @param string $thattr    a string of additional attributes to be put
  2148.      *                           in the <th> element (example: 'class="foo"')
  2149.      * @param string $tdattr    a string of additional attributes to be put
  2150.      *                           in the <td> element (example: 'class="foo"')
  2151.      * @return string
  2152.      *
  2153.      * @access public
  2154.      * @static
  2155.      * @see HTML_Form::displayRadio(), HTML_Form::displayRadioRow(),
  2156.      *      HTML_Form::returnRadio(), HTML_Form::addRadio()
  2157.      * @since Method available since Release 1.1.0
  2158.      */
  2159.     function returnRadioRow($name, $title, $value, $default = false,
  2160.                             $attr = '', $thattr = HTML_FORM_TH_ATTR,
  2161.                             $tdattr = HTML_FORM_TD_ATTR)
  2162.     {
  2163.         return " <tr>\n" .
  2164.                '  <th ' . $thattr . '>' . $title . "</th>\n" .
  2165.                '  <td ' . $tdattr . ">\n   " .
  2166.                HTML_Form::returnRadio($name, $value, $default, $attr) .
  2167.                "  </td>\n" .
  2168.                " </tr>\n";
  2169.     }
  2170.  
  2171.     // }}}
  2172.     // {{{ returnImage()
  2173.  
  2174.     /**
  2175.      * Produce a string containing an image input
  2176.      *
  2177.      * @param string $name      the string used in the 'name' attribute
  2178.      * @param string $src       the string denoting the path to the image.
  2179.      *                           Can be a relative path or full URI.
  2180.      * @param string $attr      a string of additional attributes to be put
  2181.      *                           in the element (example: 'id="foo"')
  2182.      * @return string
  2183.      *
  2184.      * @access public
  2185.      * @static
  2186.      * @see HTML_Form::displayImage(), HTML_Form::displayImageRow(),
  2187.      *      HTML_Form::returnImageRow(), HTML_Form::addImage()
  2188.      * @since Method available since Release 1.1.0
  2189.      */
  2190.     function returnImage($name, $src, $attr = '')
  2191.     {
  2192.         return '<input type="image" name="' . $name . '"' .
  2193.                ' src="' . $src . '" ' . $attr . "/>\n";
  2194.     }
  2195.  
  2196.     // }}}
  2197.     // {{{ returnImageRow()
  2198.  
  2199.     /**
  2200.      * Produce a string containing an image input inside a table row
  2201.      *
  2202.      * @param string $name      the string used in the 'name' attribute
  2203.      * @param string $title     the string used as the label
  2204.      * @param string $src       the string denoting the path to the image.
  2205.      *                           Can be a relative path or full URI.
  2206.      * @param string $attr      a string of additional attributes to be put
  2207.      *                           in the element (example: 'id="foo"')
  2208.      * @param string $thattr    a string of additional attributes to be put
  2209.      *                           in the <th> element (example: 'class="foo"')
  2210.      * @param string $tdattr    a string of additional attributes to be put
  2211.      *                           in the <td> element (example: 'class="foo"')
  2212.      * @return string
  2213.      *
  2214.      * @access public
  2215.      * @static
  2216.      * @see HTML_Form::displayImage(), HTML_Form::displayImageRow(),
  2217.      *      HTML_Form::returnImage(), HTML_Form::addImage()
  2218.      * @since Method available since Release 1.1.0
  2219.      */
  2220.     function returnImageRow($name, $title, $src, $attr = '',
  2221.                             $thattr = HTML_FORM_TH_ATTR,
  2222.                             $tdattr = HTML_FORM_TD_ATTR)
  2223.     {
  2224.         return " <tr>\n" .
  2225.                '  <th ' . $thattr . '>' . $title . "</th>\n" .
  2226.                '  <td ' . $tdattr . ">\n   " .
  2227.                HTML_Form::returnImage($name, $src, $attr) .
  2228.                "  </td>\n" .
  2229.                " </tr>\n";
  2230.     }
  2231.  
  2232.     // }}}
  2233.     // {{{ returnHidden()
  2234.  
  2235.     /**
  2236.      * Produce a string containing a hiden input
  2237.      *
  2238.      * @param string $name      the string used in the 'name' attribute
  2239.      * @param string $value     the string used for the item's value
  2240.      * @param string $attr      a string of additional attributes to be put
  2241.      *                           in the element (example: 'id="foo"')
  2242.      * @return string
  2243.      *
  2244.      * @access public
  2245.      * @static
  2246.      * @see HTML_Form::displayHidden(), HTML_Form::addHidden()
  2247.      */
  2248.     function returnHidden($name, $value, $attr = '')
  2249.     {
  2250.         return '<input type="hidden" name="' . $name . '"'
  2251.                . ' value="' . $value . '" ' . $attr . "/>\n";
  2252.     }
  2253.  
  2254.     // }}}
  2255.     // {{{ returnBlank()
  2256.  
  2257.     /**
  2258.      * Produce a string containing  
  2259.      *
  2260.      * @return string
  2261.      *
  2262.      * @access public
  2263.      * @static
  2264.      * @see HTML_Form::displayBlank(), HTML_Form::displayBlankRow(),
  2265.      *      HTML_Form::returnBlankRow(), HTML_Form::addBlank()
  2266.      * @since Method available since Release 1.1.0
  2267.      */
  2268.     function returnBlank()
  2269.     {
  2270.         return ' ';
  2271.     }
  2272.  
  2273.     // }}}
  2274.     // {{{ returnBlankRow()
  2275.  
  2276.     /**
  2277.      * Produce a string containing a blank row in the table
  2278.      *
  2279.      * @param int    $i         the number of rows to create.  Ignored if
  2280.      *                           $title is used.
  2281.      * @param string $title     a string to be used as the label for the row
  2282.      * @param string $thattr    a string of additional attributes to be put
  2283.      *                           in the <th> element (example: 'class="foo"')
  2284.      * @param string $tdattr    a string of additional attributes to be put
  2285.      *                           in the <td> element (example: 'class="foo"')
  2286.      * @return string
  2287.      *
  2288.      * @access public
  2289.      * @static
  2290.      * @see HTML_Form::displayBlank(), HTML_Form::displayBlankRow(),
  2291.      *      HTML_Form::returnBlank(), HTML_Form::addBlank()
  2292.      * @since Method available since Release 1.1.0
  2293.      */
  2294.     function returnBlankRow($i, $title= '', $thattr = HTML_FORM_TH_ATTR,
  2295.                             $tdattr = HTML_FORM_TD_ATTR)
  2296.     {
  2297.         if (!$title) {
  2298.             $str = '';
  2299.             for ($j = 0; $j < $i; $j++) {
  2300.                 $str .= " <tr>\n";
  2301.                 $str .= '  <th ' . $thattr . "> </th>\n";
  2302.                 $str .= '  <td ' . $tdattr . '>' . HTML_Form::returnBlank() . "</td>\n";
  2303.                 $str .= " </tr>\n";
  2304.             }
  2305.             return $str;
  2306.         } else {
  2307.             return " <tr>\n" .
  2308.                    '  <th ' . $thattr . '>' . $title . "</th>\n" .
  2309.                    '  <td ' . $tdattr . '>' . HTML_Form::returnBlank() . "</td>\n" .
  2310.                    " </tr>\n";
  2311.         }
  2312.     }
  2313.  
  2314.     // }}}
  2315.     // {{{ returnFile()
  2316.  
  2317.     /**
  2318.      * Produce a string containing a file upload input
  2319.      *
  2320.      * @param string $name      the string used in the 'name' attribute
  2321.      * @param int    $maxsize   an integer determining how large (in bytes) a
  2322.      *                           submitted file can be.
  2323.      * @param int    $size      an integer used in the 'size' attribute
  2324.      * @param string $accept    a string saying which MIME types are allowed
  2325.      * @param string $attr      a string of additional attributes to be put
  2326.      *                           in the element (example: 'id="foo"')
  2327.      * @return string
  2328.      *
  2329.      * @access public
  2330.      * @static
  2331.      * @see HTML_Form::displayFile(), HTML_Form::displayFileRow(),
  2332.      *      HTML_Form::returnFileRow(), HTML_Form::addFile(),
  2333.      *      HTML_Form::returnMultipleFiles()
  2334.      */
  2335.     function returnFile($name = 'userfile',
  2336.                         $maxsize = HTML_FORM_MAX_FILE_SIZE,
  2337.                         $size = HTML_FORM_TEXT_SIZE,
  2338.                         $accept = '', $attr = '')
  2339.     {
  2340.         $str  = '   <input type="hidden" name="MAX_FILE_SIZE" value="';
  2341.         $str .= $maxsize . "\" />\n";
  2342.         $str .= '   <input type="file" name="' . $name . '"';
  2343.         $str .= ' size="' . $size . '" ';
  2344.         if ($accept) {
  2345.             $str .= 'accept="' . $accept . '" ';
  2346.         }
  2347.         return $str . $attr . "/>\n";
  2348.     }
  2349.  
  2350.     // }}}
  2351.     // {{{ returnFileRow()
  2352.  
  2353.     /**
  2354.      * Produce a string containing a file upload input inside a table row
  2355.      *
  2356.      * @param string $name      the string used in the 'name' attribute
  2357.      * @param string $title     the string used as the label
  2358.      * @param int    $maxsize   an integer determining how large (in bytes) a
  2359.      *                           submitted file can be.
  2360.      * @param int    $size      an integer used in the 'size' attribute
  2361.      * @param string $accept    a string saying which MIME types are allowed
  2362.      * @param string $attr      a string of additional attributes to be put
  2363.      *                           in the element (example: 'id="foo"')
  2364.      * @param string $thattr    a string of additional attributes to be put
  2365.      *                           in the <th> element (example: 'class="foo"')
  2366.      * @param string $tdattr    a string of additional attributes to be put
  2367.      *                           in the <td> element (example: 'class="foo"')
  2368.      * @return string
  2369.      *
  2370.      * @access public
  2371.      * @static
  2372.      * @see HTML_Form::displayFile(), HTML_Form::displayFileRow(),
  2373.      *      HTML_Form::returnFile(), HTML_Form::addFile(),
  2374.      *      HTML_Form::returnMultipleFiles()
  2375.      */
  2376.     function returnFileRow($name, $title, $maxsize = HTML_FORM_MAX_FILE_SIZE,
  2377.                            $size = HTML_FORM_TEXT_SIZE,
  2378.                            $accept = '', $attr = '',
  2379.                            $thattr = HTML_FORM_TH_ATTR,
  2380.                            $tdattr = HTML_FORM_TD_ATTR)
  2381.     {
  2382.         $str  = " <tr>\n";
  2383.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  2384.         $str .= '  <td ' . $tdattr . ">\n";
  2385.         $str .= HTML_Form::returnFile($name, $maxsize, $size, $accept,
  2386.                                       $attr);
  2387.         $str .= "  </td>\n";
  2388.         $str .= " </tr>\n";
  2389.  
  2390.         return $str;
  2391.     }
  2392.  
  2393.     // }}}
  2394.     // {{{ returnMultipleFiles()
  2395.  
  2396.     /**
  2397.      * Produce a string containing a file upload input
  2398.      *
  2399.      * @param string $name      the string used in the 'name' attribute
  2400.      * @param int    $maxsize   an integer determining how large (in bytes) a
  2401.      *                           submitted file can be.
  2402.      * @param int    $files     an integer of how many file inputs to show
  2403.      * @param int    $size      an integer used in the 'size' attribute
  2404.      * @param string $accept    a string saying which MIME types are allowed
  2405.      * @param string $attr      a string of additional attributes to be put
  2406.      *                           in the element (example: 'id="foo"')
  2407.      * @return string
  2408.      *
  2409.      * @access public
  2410.      * @static
  2411.      * @see HTML_Form::displayFile(), HTML_Form::displayFileRow(),
  2412.      *      HTML_Form::returnFile(), HTML_Form::returnFileRow(),
  2413.      *      HTML_Form::addFile()
  2414.      */
  2415.     function returnMultipleFiles($name = 'userfile[]',
  2416.                                  $maxsize = HTML_FORM_MAX_FILE_SIZE,
  2417.                                  $files = 3,
  2418.                                  $size = HTML_FORM_TEXT_SIZE,
  2419.                                  $accept = '', $attr = '')
  2420.     {
  2421.         $str  = '<input type="hidden" name="MAX_FILE_SIZE" value="';
  2422.         $str .= $maxsize . "\" />\n";
  2423.  
  2424.         for($i=0; $i < $files; $i++) {
  2425.             $str .= '<input type="file" name="' . $name . '"';
  2426.             $str .= ' size="' . $size . '" ';
  2427.             if ($accept) {
  2428.                 $str .= 'accept="' . $accept . '" ';
  2429.             }
  2430.             $str .= $attr . "/><br />\n";
  2431.         }
  2432.         return $str;
  2433.     }
  2434.  
  2435.     // }}}
  2436.     // {{{ returnStart()
  2437.  
  2438.     /**
  2439.      * Produces a string containing the opening tags for the form and table
  2440.      *
  2441.      * NOTE: can NOT be called statically.
  2442.      *
  2443.      * @param bool $multipartformdata  a bool indicating if the form should
  2444.      *                                  be submitted in multipart format
  2445.      * @return string
  2446.      *
  2447.      * @access public
  2448.      * @see HTML_Form::display(), HTML_Form::returnEnd(), HTML_Form::start()
  2449.      */
  2450.     function returnStart($multipartformdata = false)
  2451.     {
  2452.         $str = "<form action=\"" . $this->action . "\" method=\"$this->method\"";
  2453.         if ($this->name) {
  2454.             $str .= " name=\"$this->name\"";
  2455.         }
  2456.         if ($this->target) {
  2457.             $str .= " target=\"$this->target\"";
  2458.         }
  2459.         if ($this->enctype) {
  2460.             $str .= " enctype=\"$this->enctype\"";
  2461.         }
  2462.         if ($multipartformdata) {
  2463.             $str .= " enctype=\"multipart/form-data\"";
  2464.         }
  2465.  
  2466.         return $str . ' ' . $this->attr . ">\n";
  2467.     }
  2468.  
  2469.     // }}}
  2470.     // {{{ returnEnd()
  2471.  
  2472.     /**
  2473.      * Produces a string containing the opening tags for the form and table
  2474.      *
  2475.      * NOTE: can NOT be called statically.
  2476.      *
  2477.      * @return string
  2478.      *
  2479.      * @access public
  2480.      * @see HTML_Form::display(), HTML_Form::returnStart(), HTML_Form::start()
  2481.      */
  2482.     function returnEnd()
  2483.     {
  2484.         $fields = array();
  2485.         foreach ($this->fields as $data) {
  2486.             switch ($data[0]) {
  2487.                 case 'reset':
  2488.                 case 'blank':
  2489.                 case 'plaintext':
  2490.                     continue 2;
  2491.             }
  2492.             $fields[$data[1]] = true;
  2493.         }
  2494.         $ret = HTML_Form::returnHidden('_fields',
  2495.                                        implode(':', array_keys($fields)));
  2496.         $ret .= "</form>\n\n";
  2497.         return $ret;
  2498.     }
  2499.  
  2500.     // }}}
  2501.     // {{{ returnPlaintext()
  2502.  
  2503.     /**
  2504.      * Produce a string containing the text provided
  2505.      *
  2506.      * @param string $text      a string to be displayed
  2507.      *
  2508.      * @return string
  2509.      *
  2510.      * @access public
  2511.      * @static
  2512.      * @see HTML_Form::displayPlaintext(), HTML_Form::displayPlaintextRow(),
  2513.      *      HTML_Form::returnPlaintextRow(), HTML_Form::addPlaintext()
  2514.      */
  2515.     function returnPlaintext($text = ' ')
  2516.     {
  2517.         return $text;
  2518.     }
  2519.  
  2520.     // }}}
  2521.     // {{{ returnPlaintextRow()
  2522.  
  2523.     /**
  2524.      * Produce a string containing the text provided inside a table row
  2525.      *
  2526.      * @param string $title     the string used as the label
  2527.      * @param string $text      a string to be displayed
  2528.      * @param string $thattr    a string of additional attributes to be put
  2529.      *                           in the <th> element (example: 'class="foo"')
  2530.      * @param string $tdattr    a string of additional attributes to be put
  2531.      *                           in the <td> element (example: 'class="foo"')
  2532.      * @return string
  2533.      *
  2534.      * @access public
  2535.      * @static
  2536.      * @see HTML_Form::displayPlaintext(), HTML_Form::displayPlaintextRow(),
  2537.      *      HTML_Form::returnPlaintext(), HTML_Form::addPlaintext()
  2538.      */
  2539.     function returnPlaintextRow($title, $text = ' ',
  2540.                                 $thattr = HTML_FORM_TH_ATTR,
  2541.                                 $tdattr = HTML_FORM_TD_ATTR)
  2542.     {
  2543.         $str  = " <tr>\n";
  2544.         $str .= '  <th ' . $thattr . '>' . $title . "</th>\n";
  2545.         $str .= '  <td ' . $tdattr . ">\n  ";
  2546.         $str .= HTML_Form::returnPlaintext($text) . "\n";
  2547.         $str .= "  </td>\n";
  2548.         $str .= " </tr>\n";
  2549.  
  2550.         return $str;
  2551.     }
  2552.  
  2553.     // }}}
  2554.     // {{{ display()
  2555.  
  2556.     /**
  2557.      * Prints a complete form with all fields you specified via
  2558.      * the add*() methods
  2559.      *
  2560.      * If you did not specify a field's default value (via the $default
  2561.      * parameter to the add*() method in question), this method will
  2562.      * automatically insert the user input found in $_GET/$_POST.  This
  2563.      * behavior can be disabled via setDefaultFromInput(false).
  2564.      *
  2565.      * The $_GET/$_POST input is automatically escaped via htmlspecialchars().
  2566.      * This behavior can be disabled via setEscapeDefaultFromInput(false).
  2567.      *
  2568.      * If the $_GET/$_POST superglobal doesn't exist, then
  2569.      * $HTTP_GET_VARS/$HTTP_POST_VARS is used.
  2570.      *
  2571.      * NOTE: can NOT be called statically.
  2572.      *
  2573.      * @param string $attr     a string of additional attributes to be put
  2574.      *                          in the <table> tag (example: 'class="foo"')
  2575.      * @param string $caption  if present, a <caption> is added to the table
  2576.      * @param string $capattr  a string of additional attributes to be put
  2577.      *                          in the <caption> tag (example: 'class="foo"')
  2578.      * @return void
  2579.      *
  2580.      * @access public
  2581.      * @see HTML_Form::end(), HTML_Form::returnEnd(),
  2582.      *      HTML_Form::setDefaultFromInput(),
  2583.      *      HTML_Form::setEscapeDefaultFromInput()
  2584.      */
  2585.     function display($attr = '', $caption = '', $capattr = '')
  2586.     {
  2587.         // Determine where to get the user input from.
  2588.  
  2589.         if (strtoupper($this->method) == 'POST') {
  2590.             if (!empty($_POST)) {
  2591.                 $input =& $_POST;
  2592.             } else {
  2593.                 if (!empty($HTTP_POST_VARS)) {
  2594.                     $input =& $HTTP_POST_VARS;
  2595.                 } else {
  2596.                     $input = array();
  2597.                 }
  2598.             }
  2599.         } else {
  2600.             if (!empty($_GET)) {
  2601.                 $input =& $_GET;
  2602.             } else {
  2603.                 if (!empty($HTTP_GET_VARS)) {
  2604.                     $input =& $HTTP_GET_VARS;
  2605.                 } else {
  2606.                     $input = array();
  2607.                 }
  2608.             }
  2609.         }
  2610.  
  2611.         $this->start();
  2612.         print '<table ' .  $attr . ">\n";
  2613.  
  2614.         if ($caption) {
  2615.             print ' <caption ' . $capattr . ">\n  " . $caption;
  2616.             print "\n </caption>\n";
  2617.         }
  2618.  
  2619.         /*
  2620.          * Go through each field created through the add*() methods
  2621.          * and pass their arguments on to the display*Row() methods.
  2622.          */
  2623.  
  2624.         $hidden = array();
  2625.         foreach ($this->fields as $field_index => $field) {
  2626.             $type = $field[0];
  2627.             $name = $field[1];
  2628.  
  2629.             switch ($type) {
  2630.                 case 'hidden':
  2631.                     // Deal with these later so they don't mess up layout.
  2632.                     $hidden[] = $field_index;
  2633.                     continue 2;
  2634.             }
  2635.  
  2636.             if ($this->_default_from_input
  2637.                 && $this->_default_params[$type]
  2638.                 && $field[$this->_default_params[$type]] === null
  2639.                 && array_key_exists($name, $input))
  2640.             {
  2641.                 // Grab the user input from $_GET/$_POST.
  2642.                 if ($this->_escape_default_from_input) {
  2643.                     $field[$this->_default_params[$type]] =
  2644.                             htmlspecialchars($input[$name]);
  2645.                 } else {
  2646.                     $field[$this->_default_params[$type]] = $input[$name];
  2647.                 }
  2648.             }
  2649.  
  2650.             array_shift($field);
  2651.             call_user_func_array(
  2652.                 array(&$this, 'display' . ucfirst($type) . 'Row'),
  2653.                 $field
  2654.             );
  2655.         }
  2656.  
  2657.         print "</table>\n";
  2658.  
  2659.         for ($i = 0; $i < sizeof($hidden); $i++) {
  2660.             $this->displayHidden($this->fields[$hidden[$i]][1],
  2661.                                  $this->fields[$hidden[$i]][2],
  2662.                                  $this->fields[$hidden[$i]][3]);
  2663.         }
  2664.  
  2665.         $this->end();
  2666.     }
  2667.  
  2668.     // }}}
  2669. }
  2670.  
  2671. /*
  2672.  * Local variables:
  2673.  * tab-width: 4
  2674.  * c-basic-offset: 4
  2675.  * End:
  2676.  */
  2677.  
  2678. ?>
  2679.