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

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * Hidden select pseudo-element
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * LICENSE: This source file is subject to version 3.01 of the PHP license
  10.  * that is available through the world-wide-web at the following URI:
  11.  * http://www.php.net/license/3_01.txt If you did not receive a copy of
  12.  * the PHP License and are unable to obtain it through the web, please
  13.  * send a note to license@php.net so we can mail you a copy immediately.
  14.  *
  15.  * @category    HTML
  16.  * @package     HTML_QuickForm
  17.  * @author      Isaac Shepard <ishepard@bsiweb.com>
  18.  * @copyright   2001-2007 The PHP Group
  19.  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
  20.  * @version     CVS: $Id: hiddenselect.php,v 1.6 2007/05/29 18:34:36 avb Exp $
  21.  * @link        http://pear.php.net/package/HTML_QuickForm
  22.  */
  23.  
  24. /**
  25.  * Class for <select></select> elements
  26.  */
  27. require_once 'HTML/QuickForm/select.php';
  28.  
  29. /**
  30.  * Hidden select pseudo-element
  31.  *
  32.  * This class takes the same arguments as a select element, but instead
  33.  * of creating a select ring it creates hidden elements for all values
  34.  * already selected with setDefault or setConstant.  This is useful if
  35.  * you have a select ring that you don't want visible, but you need all
  36.  * selected values to be passed.
  37.  *
  38.  * @category    HTML
  39.  * @package     HTML_QuickForm
  40.  * @author      Isaac Shepard <ishepard@bsiweb.com>
  41.  * @version     Release: 3.2.10
  42.  * @since       2.1
  43.  */
  44. class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select
  45. {
  46.     // {{{ constructor
  47.         
  48.     /**
  49.      * Class constructor
  50.      * 
  51.      * @param     string    Select name attribute
  52.      * @param     mixed     Label(s) for the select (not used)
  53.      * @param     mixed     Data to be used to populate options
  54.      * @param     mixed     Either a typical HTML attribute string or an associative array (not used)
  55.      * @since     1.0
  56.      * @access    public
  57.      * @return    void
  58.      */
  59.     function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null)
  60.     {
  61.         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
  62.         $this->_persistantFreeze = true;
  63.         $this->_type = 'hiddenselect';
  64.         if (isset($options)) {
  65.             $this->load($options);
  66.         }
  67.     } //end constructor
  68.     
  69.     // }}}
  70.     // {{{ toHtml()
  71.  
  72.     /**
  73.      * Returns the SELECT in HTML
  74.      *
  75.      * @since     1.0
  76.      * @access    public
  77.      * @return    string
  78.      * @throws    
  79.      */
  80.     function toHtml()
  81.     {
  82.         if (empty($this->_values)) {
  83.             return '';
  84.         }
  85.  
  86.         $tabs    = $this->_getTabs();
  87.         $name    = $this->getPrivateName();
  88.         $strHtml = '';
  89.  
  90.         foreach ($this->_values as $key => $val) {
  91.             for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
  92.                 if ($val == $this->_options[$i]['attr']['value']) {
  93.                     $strHtml .= $tabs . '<input' . $this->_getAttrString(array(
  94.                         'type'  => 'hidden',
  95.                         'name'  => $name,
  96.                         'value' => $val
  97.                     )) . " />\n" ;
  98.                 }
  99.             }
  100.         }
  101.  
  102.         return $strHtml;
  103.     } //end func toHtml
  104.     
  105.     // }}}
  106.     // {{{ accept()
  107.  
  108.    /**
  109.     * This is essentially a hidden element and should be rendered as one  
  110.     */
  111.     function accept(&$renderer)
  112.     {
  113.         $renderer->renderHidden($this);
  114.     }
  115.  
  116.     // }}}
  117. } //end class HTML_QuickForm_hiddenselect
  118. ?>
  119.