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

Source for file xbutton.php

Documentation is available at xbutton.php

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

Documentation generated on Mon, 11 Mar 2019 14:16:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.