adding some strings
[moodle-linuxchix.git] / lib / pear / HTML / QuickForm / xbutton.php
blobdd01995b21299000c83229ab11d35b17f77f4f09
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 // +----------------------------------------------------------------------+
19 // $Id$
21 require_once 'HTML/QuickForm/element.php';
23 /**
24 * Class for HTML 4.0 <button> element
26 * @author Alexey Borzov <avb@php.net>
27 * @since 3.2.3
28 * @access public
30 class HTML_QuickForm_xbutton extends HTML_QuickForm_element
32 /**
33 * Contents of the <button> tag
34 * @var string
35 * @access private
37 var $_content;
39 /**
40 * Class constructor
42 * @param string Button name
43 * @param string Button content (HTML to add between <button></button> tags)
44 * @param mixed Either a typical HTML attribute string or an associative array
45 * @access public
47 function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
49 $this->HTML_QuickForm_element($elementName, null, $attributes);
50 $this->setContent($elementContent);
51 $this->setPersistantFreeze(false);
52 $this->_type = 'xbutton';
56 function toHtml()
58 return '<button' . $this->getAttributes(true) . '>' . $this->_content . '</button>';
62 function getFrozenHtml()
64 return $this->toHtml();
68 function freeze()
70 return false;
74 function setName($name)
76 $this->updateAttributes(array(
77 'name' => $name
78 ));
82 function getName()
84 return $this->getAttribute('name');
88 function setValue($value)
90 $this->updateAttributes(array(
91 'value' => $value
92 ));
96 function getValue()
98 return $this->getAttribute('value');
103 * Sets the contents of the button element
105 * @param string Button content (HTML to add between <button></button> tags)
107 function setContent($content)
109 $this->_content = $content;
113 function onQuickFormEvent($event, $arg, &$caller)
115 if ('updateValue' != $event) {
116 return parent::onQuickFormEvent($event, $arg, $caller);
117 } else {
118 $value = $this->_findValue($caller->_constantValues);
119 if (null === $value) {
120 $value = $this->_findValue($caller->_defaultValues);
122 if (null !== $value) {
123 $this->setValue($value);
126 return true;
131 * Returns a 'safe' element's value
133 * The value is only returned if the button's type is "submit" and if this
134 * particlular button was clicked
136 function exportValue(&$submitValues, $assoc = false)
138 if ('submit' == $this->getAttribute('type')) {
139 return $this->_prepareValue($this->_findValue($submitValues), $assoc);
140 } else {
141 return null;