|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once('select.php'); 00027 00035 class MoodleQuickForm_searchableselector extends MoodleQuickForm_select{ 00036 00037 00038 function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) { 00039 //set size default to 12 00040 if (empty($attributes) || empty($attributes['size'])) { 00041 $attributes['size'] = 12; 00042 } 00043 parent::MoodleQuickForm_select($elementName, $elementLabel, $options, $attributes); 00044 } 00045 00046 function toHtml(){ 00047 global $OUTPUT; 00048 if ($this->_hiddenLabel){ 00049 return parent::toHtml(); 00050 } else { 00051 // Javascript for the search/selection fields 00052 global $PAGE; 00053 $PAGE->requires->yui2_lib('event'); 00054 $PAGE->requires->js('/lib/form/searchableselector.js'); 00055 $PAGE->requires->js_function_call('selector.filter_init', array(get_string('search'),$this->getAttribute('id'))); 00056 00057 $strHtml = ''; 00058 $strHtml .= parent::toHtml(); //the select input 00059 return $strHtml; 00060 } 00061 } 00062 00063 }