[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/search/classes/output/form/ -> search.php (source)

   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   * Global search search form definition
  19   *
  20   * @package   core_search
  21   * @copyright Prateek Sachan {@link http://prateeksachan.com}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_search\output\form;
  26  
  27  defined('MOODLE_INTERNAL') || die;
  28  
  29  require_once($CFG->libdir . '/formslib.php');
  30  
  31  class search extends \moodleform {
  32  
  33      /**
  34       * Form definition.
  35       *
  36       * @return void
  37       */
  38      function definition() {
  39          global $CFG;
  40  
  41          $mform =& $this->_form;
  42          $mform->disable_form_change_checker();
  43          $mform->addElement('header', 'search', get_string('search', 'search'));
  44  
  45          // Help info depends on the selected search engine.
  46          $mform->addElement('text', 'q', get_string('enteryoursearchquery', 'search'));
  47          $mform->addHelpButton('q', 'searchinfo', $this->_customdata['searchengine']);
  48          $mform->setType('q', PARAM_TEXT);
  49          $mform->addRule('q', get_string('required'), 'required', null, 'client');
  50  
  51          $mform->addElement('header', 'filtersection', get_string('filterheader', 'search'));
  52          $mform->setExpanded('filtersection', false);
  53  
  54          $mform->addElement('text', 'title', get_string('title', 'search'));
  55          $mform->setType('title', PARAM_TEXT);
  56  
  57          $search = \core_search\manager::instance();
  58  
  59          $searchareas = \core_search\manager::get_search_areas_list(true);
  60          $areanames = array();
  61          foreach ($searchareas as $areaid => $searcharea) {
  62              $areanames[$areaid] = $searcharea->get_visible_name();
  63          }
  64  
  65          // Sort the array by the text.
  66          \core_collator::asort($areanames);
  67  
  68          $options = array(
  69              'multiple' => true,
  70              'noselectionstring' => get_string('allareas', 'search'),
  71          );
  72          $mform->addElement('autocomplete', 'areaids', get_string('searcharea', 'search'), $areanames, $options);
  73  
  74          $options = array(
  75              'multiple' => true,
  76              'limittoenrolled' => !is_siteadmin(),
  77              'noselectionstring' => get_string('allcourses', 'search'),
  78          );
  79          $mform->addElement('course', 'courseids', get_string('courses', 'core'), $options);
  80          $mform->setType('courseids', PARAM_INT);
  81  
  82          $mform->addElement('date_time_selector', 'timestart', get_string('fromtime', 'search'), array('optional' => true));
  83          $mform->setDefault('timestart', 0);
  84  
  85          $mform->addElement('date_time_selector', 'timeend', get_string('totime', 'search'), array('optional' => true));
  86          $mform->setDefault('timeend', 0);
  87  
  88          $this->add_action_buttons(false, get_string('search', 'search'));
  89      }
  90  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1