MDL-39888 mnet: Removal of an old sql statement invloving the mdl_log table.
[moodle.git] / lib / form / cancel.php
blob6674377e911f694ff0453f92889040892596817e
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Button form element
21 * Contains HTML class for a button type element
23 * @package core_form
24 * @copyright 2007 Jamie Pratt <me@jamiep.org>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 if (!defined('MOODLE_INTERNAL')) {
29 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
32 global $CFG;
33 require_once($CFG->libdir.'/form/submit.php');
35 /**
36 * HTML class for a submit cancel type element
38 * Overloaded {@link MoodleQuickForm_submit} with default behavior modified to cancel a form.
40 * @package core_form
41 * @category form
42 * @copyright 2007 Jamie Pratt <me@jamiep.org>
43 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45 class MoodleQuickForm_cancel extends MoodleQuickForm_submit
47 /**
48 * constructor
50 * @param string $elementName (optional) name of the checkbox
51 * @param string $value (optional) value for the button
52 * @param mixed $attributes (optional) Either a typical HTML attribute string
53 * or an associative array
55 function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null)
57 if ($elementName==null){
58 $elementName='cancel';
60 if ($value==null){
61 $value=get_string('cancel');
63 MoodleQuickForm_submit::MoodleQuickForm_submit($elementName, $value, $attributes);
64 $this->updateAttributes(array('onclick'=>'skipClientValidation = true; return true;'));
66 // Add the class btn-cancel.
67 $class = $this->getAttribute('class');
68 if (empty($class)) {
69 $class = '';
71 $this->updateAttributes(array('class' => $class . ' btn-cancel'));
74 /**
75 * Called by HTML_QuickForm whenever form event is made on this element
77 * @param string $event Name of event
78 * @param mixed $arg event arguments
79 * @param object $caller calling object
80 * @return bool
82 function onQuickFormEvent($event, $arg, &$caller)
84 switch ($event) {
85 case 'createElement':
86 $className = get_class($this);
87 $this->$className($arg[0], $arg[1], $arg[2]);
88 $caller->_registerCancelButton($this->getName());
89 return true;
90 break;
92 return parent::onQuickFormEvent($event, $arg, $caller);
95 /**
96 * Returns the value of field without HTML tags
98 * @return string
100 function getFrozenHtml(){
101 return HTML_QuickForm_submit::getFrozenHtml();
105 * Freeze the element so that only its value is returned
107 * @return bool
109 function freeze(){
110 return HTML_QuickForm_submit::freeze();