Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/pear/HTML/QuickForm/xbutton.php
Go to the documentation of this file.
00001 <?php
00002 /* vim: set expandtab tabstop=4 shiftwidth=4: */
00003 // +----------------------------------------------------------------------+
00004 // | PHP Version 4                                                        |
00005 // +----------------------------------------------------------------------+
00006 // | Copyright (c) 1997-2003 The PHP Group                                |
00007 // +----------------------------------------------------------------------+
00008 // | This source file is subject to version 2.0 of the PHP license,       |
00009 // | that is bundled with this package in the file LICENSE, and is        |
00010 // | available at through the world-wide-web at                           |
00011 // | http://www.php.net/license/2_02.txt.                                 |
00012 // | If you did not receive a copy of the PHP license and are unable to   |
00013 // | obtain it through the world-wide-web, please send a note to          |
00014 // | license@php.net so we can mail you a copy immediately.               |
00015 // +----------------------------------------------------------------------+
00016 // | Authors: Alexey Borzov <avb@php.net>                                 |
00017 // +----------------------------------------------------------------------+
00018 //
00019 // $Id: xbutton.php,v 1.2 2010/12/14 17:35:24 moodlerobot Exp $
00020 
00021 require_once 'HTML/QuickForm/element.php';
00022 
00030 class HTML_QuickForm_xbutton extends HTML_QuickForm_element
00031 {
00037     var $_content; 
00038 
00047     function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
00048     {
00049         $this->HTML_QuickForm_element($elementName, null, $attributes);
00050         $this->setContent($elementContent);
00051         $this->setPersistantFreeze(false);
00052         $this->_type = 'xbutton';
00053     }
00054 
00055 
00056     function toHtml()
00057     {
00058         return '<button' . $this->getAttributes(true) . '>' . $this->_content . '</button>';
00059     }
00060 
00061 
00062     function getFrozenHtml()
00063     {
00064         return $this->toHtml();
00065     }
00066 
00067 
00068     function freeze()
00069     {
00070         return false;
00071     }
00072 
00073 
00074     function setName($name)
00075     {
00076         $this->updateAttributes(array(
00077             'name' => $name 
00078         ));
00079     }
00080 
00081 
00082     function getName()
00083     {
00084         return $this->getAttribute('name');
00085     }
00086 
00087 
00088     function setValue($value)
00089     {
00090         $this->updateAttributes(array(
00091             'value' => $value
00092         ));
00093     }
00094 
00095 
00096     function getValue()
00097     {
00098         return $this->getAttribute('value');
00099     }
00100 
00101 
00107     function setContent($content)
00108     {
00109         $this->_content = $content;
00110     }
00111 
00112 
00113     function onQuickFormEvent($event, $arg, &$caller)
00114     {
00115         if ('updateValue' != $event) {
00116             return parent::onQuickFormEvent($event, $arg, $caller);
00117         } else {
00118             $value = $this->_findValue($caller->_constantValues);
00119             if (null === $value) {
00120                 $value = $this->_findValue($caller->_defaultValues);
00121             }
00122             if (null !== $value) {
00123                 $this->setValue($value);
00124             }
00125         }
00126         return true;
00127     }
00128 
00129 
00136     function exportValue(&$submitValues, $assoc = false)
00137     {
00138         if ('submit' == $this->getAttribute('type')) {
00139             return $this->_prepareValue($this->_findValue($submitValues), $assoc);
00140         } else {
00141             return null;
00142         }
00143     }
00144 }
00145 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations