[ Index ] |
PHP Cross Reference of Unnamed Project |
[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 * searchable select type element 19 * 20 * Contains HTML class for a searchable select type element 21 * 22 * @package core_form 23 * @copyright 2009 Jerome Mouneyrac <jerome@mouneyrac.com> 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 require_once ('select.php'); 28 29 /** 30 * searchable select type element 31 * 32 * Display a select input with a search textfield input on the top 33 * The search textfield is created by the javascript file searchselector.js 34 * (so when javascript is not activated into the browser, the search field is not displayed) 35 * If ever the select can be reset/unselect/blank/nooption, you will have to add an option "noselected" 36 * and manage this special case when you get/set the form data (i.e. $mform->get_data()/$this->set_data($yourobject)). 37 * 38 * @package core_form 39 * @category form 40 * @copyright 2009 Jerome Mouneyrac 41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 42 */ 43 class MoodleQuickForm_searchableselector extends MoodleQuickForm_select{ 44 /** 45 * Constructor 46 * 47 * @param string $elementName Select name attribute 48 * @param mixed $elementLabel Label(s) for the select 49 * @param array $options additional options. 50 * @param mixed $attributes Either a typical HTML attribute string or an associative array 51 */ 52 public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { 53 //set size default to 12 54 if (empty($attributes) || empty($attributes['size'])) { 55 $attributes['size'] = 12; 56 } 57 parent::__construct($elementName, $elementLabel, $options, $attributes); 58 } 59 60 /** 61 * Old syntax of class constructor. Deprecated in PHP7. 62 * 63 * @deprecated since Moodle 3.1 64 */ 65 public function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) { 66 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); 67 self::__construct($elementName, $elementLabel, $options, $attributes); 68 } 69 70 /** 71 * Returns the select element in HTML 72 * 73 * @return string 74 */ 75 function toHtml(){ 76 global $OUTPUT; 77 if ($this->_hiddenLabel || $this->_flagFrozen) { 78 return parent::toHtml(); 79 } else { 80 // Javascript for the search/selection fields 81 global $PAGE; 82 $PAGE->requires->js('/lib/form/searchableselector.js'); 83 $PAGE->requires->js_function_call('selector.filter_init', array(get_string('search'),$this->getAttribute('id'))); 84 85 $strHtml = ''; 86 $strHtml .= parent::toHtml(); //the select input 87 return $strHtml; 88 } 89 } 90 91 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |