[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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. 13 // 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/>. 16 17 18 /** 19 * Advanced checkbox type form element 20 * 21 * Contains HTML class for an advcheckbox type form element 22 * 23 * @package core_form 24 * @copyright 2007 Jamie Pratt <[email protected]> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 require_once('HTML/QuickForm/advcheckbox.php'); 29 30 /** 31 * HTML class for an advcheckbox type element 32 * 33 * Overloaded {@link HTML_QuickForm_advcheckbox} with default behavior modified for Moodle. 34 * This will return '0' if not checked and '1' if checked. 35 * 36 * @package core_form 37 * @category form 38 * @copyright 2007 Jamie Pratt <[email protected]> 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{ 42 /** @var string html for help button, if empty then no help will icon will be dispalyed. */ 43 var $_helpbutton=''; 44 45 /** @var string Group to which this checkbox belongs (for select all/select none button) */ 46 var $_group; 47 48 /** 49 * constructor 50 * 51 * @param string $elementName (optional) name of the checkbox 52 * @param string $elementLabel (optional) checkbox label 53 * @param string $text (optional) Text to put after the checkbox 54 * @param mixed $attributes (optional) Either a typical HTML attribute string 55 * or an associative array 56 * @param mixed $values (optional) Values to pass if checked or not checked 57 */ 58 function MoodleQuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) 59 { 60 if ($values === null){ 61 $values = array(0, 1); 62 } 63 64 if (!is_null($attributes['group'])) { 65 66 $this->_group = 'checkboxgroup' . $attributes['group']; 67 unset($attributes['group']); 68 if (is_null($attributes)) { 69 $attributes = array(); 70 $attributes['class'] .= " $this->_group"; 71 } elseif (is_array($attributes)) { 72 if (isset($attributes['class'])) { 73 $attributes['class'] .= " $this->_group"; 74 } else { 75 $attributes['class'] = $this->_group; 76 } 77 } elseif ($strpos = stripos($attributes, 'class="')) { 78 $attributes = str_ireplace('class="', 'class="' . $this->_group . ' ', $attributes); 79 } else { 80 $attributes .= ' class="' . $this->_group . '"'; 81 } 82 } 83 84 parent::HTML_QuickForm_advcheckbox($elementName, $elementLabel, $text, $attributes, $values); 85 } 86 87 /** 88 * get html for help button 89 * 90 * @return string html for help button 91 */ 92 function getHelpButton(){ 93 return $this->_helpbutton; 94 } 95 96 /** 97 * Returns HTML for advchecbox form element. 98 * 99 * @return string 100 */ 101 function toHtml() 102 { 103 return '<span>' . parent::toHtml() . '</span>'; 104 } 105 106 /** 107 * Returns the disabled field. Accessibility: the return "[ ]" from parent 108 * class is not acceptable for screenreader users, and we DO want a label. 109 * 110 * @return string 111 */ 112 function getFrozenHtml() 113 { 114 //$this->_generateId(); 115 $output = '<input type="checkbox" disabled="disabled" id="'.$this->getAttribute('id').'" '; 116 if ($this->getChecked()) { 117 $output .= 'checked="checked" />'.$this->_getPersistantData(); 118 } else { 119 $output .= '/>'; 120 } 121 return $output; 122 } 123 124 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |