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 / xbutton.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  3.8 KB  |  154 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * Class for HTML 4.0 <button> 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      Alexey Borzov <avb@php.net>
  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: xbutton.php,v 1.2 2007/05/29 18:34:36 avb Exp $
  21.  * @link        http://pear.php.net/package/HTML_QuickForm
  22.  */
  23.  
  24. /**
  25.  * Base class for form elements
  26.  */ 
  27. require_once 'HTML/QuickForm/element.php';
  28.  
  29. /**
  30.  * Class for HTML 4.0 <button> element
  31.  * 
  32.  * @category    HTML
  33.  * @package     HTML_QuickForm
  34.  * @author      Alexey Borzov <avb@php.net>
  35.  * @version     Release: 3.2.10
  36.  * @since       3.2.3
  37.  */
  38. class HTML_QuickForm_xbutton extends HTML_QuickForm_element
  39. {
  40.    /**
  41.     * Contents of the <button> tag
  42.     * @var      string
  43.     * @access   private
  44.     */
  45.     var $_content; 
  46.  
  47.    /**
  48.     * Class constructor
  49.     * 
  50.     * @param    string  Button name
  51.     * @param    string  Button content (HTML to add between <button></button> tags)
  52.     * @param    mixed   Either a typical HTML attribute string or an associative array
  53.     * @access   public
  54.     */
  55.     function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
  56.     {
  57.         $this->HTML_QuickForm_element($elementName, null, $attributes);
  58.         $this->setContent($elementContent);
  59.         $this->setPersistantFreeze(false);
  60.         $this->_type = 'xbutton';
  61.     }
  62.  
  63.  
  64.     function toHtml()
  65.     {
  66.         return '<button' . $this->getAttributes(true) . '>' . $this->_content . '</button>';
  67.     }
  68.  
  69.  
  70.     function getFrozenHtml()
  71.     {
  72.         return $this->toHtml();
  73.     }
  74.  
  75.  
  76.     function freeze()
  77.     {
  78.         return false;
  79.     }
  80.  
  81.  
  82.     function setName($name)
  83.     {
  84.         $this->updateAttributes(array(
  85.             'name' => $name 
  86.         ));
  87.     }
  88.  
  89.  
  90.     function getName()
  91.     {
  92.         return $this->getAttribute('name');
  93.     }
  94.  
  95.  
  96.     function setValue($value)
  97.     {
  98.         $this->updateAttributes(array(
  99.             'value' => $value
  100.         ));
  101.     }
  102.  
  103.  
  104.     function getValue()
  105.     {
  106.         return $this->getAttribute('value');
  107.     }
  108.  
  109.  
  110.    /**
  111.     * Sets the contents of the button element
  112.     *
  113.     * @param    string  Button content (HTML to add between <button></button> tags)
  114.     */
  115.     function setContent($content)
  116.     {
  117.         $this->_content = $content;
  118.     }
  119.  
  120.  
  121.     function onQuickFormEvent($event, $arg, &$caller)
  122.     {
  123.         if ('updateValue' != $event) {
  124.             return parent::onQuickFormEvent($event, $arg, $caller);
  125.         } else {
  126.             $value = $this->_findValue($caller->_constantValues);
  127.             if (null === $value) {
  128.                 $value = $this->_findValue($caller->_defaultValues);
  129.             }
  130.             if (null !== $value) {
  131.                 $this->setValue($value);
  132.             }
  133.         }
  134.         return true;
  135.     }
  136.  
  137.  
  138.    /**
  139.     * Returns a 'safe' element's value
  140.     * 
  141.     * The value is only returned if the button's type is "submit" and if this
  142.     * particlular button was clicked
  143.     */
  144.     function exportValue(&$submitValues, $assoc = false)
  145.     {
  146.         if ('submit' == $this->getAttribute('type')) {
  147.             return $this->_prepareValue($this->_findValue($submitValues), $assoc);
  148.         } else {
  149.             return null;
  150.         }
  151.     }
  152. }
  153. ?>
  154.