HTML_Form
[ class tree: HTML_Form ] [ index: HTML_Form ] [ all elements ]

Source for file Form.php

Documentation is available at Form.php

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

Documentation generated on Mon, 11 Mar 2019 13:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.