Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/tag/ -> search.php (source)

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   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   * @package    core
  19   * @subpackage tag
  20   * @copyright  2007 Luiz Cruz <luiz.laydner@gmail.com>
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  require_once('../config.php');
  25  
  26  require_login();
  27  
  28  if (empty($CFG->usetags)) {
  29      print_error('tagsaredisabled', 'tag');
  30  }
  31  
  32  $query     = optional_param('query', '', PARAM_RAW);
  33  $tagcollid = optional_param('tc', 0, PARAM_INT);
  34  $edit      = optional_param('edit', -1, PARAM_BOOL);
  35  
  36  $params = array();
  37  if ($query !== '') {
  38      $params['query'] = $query;
  39  }
  40  if ($tagcollid) {
  41      $params['tc'] = $tagcollid;
  42  }
  43  
  44  $PAGE->set_url(new moodle_url('/tag/search.php', $params));
  45  $PAGE->set_context(context_system::instance());
  46  $PAGE->set_pagelayout('standard');
  47  
  48  $PAGE->set_title(get_string('tags', 'tag'));
  49  $PAGE->set_heading($SITE->fullname);
  50  
  51  $buttons = '';
  52  if (has_capability('moodle/tag:manage', context_system::instance())) {
  53      $buttons .= $OUTPUT->single_button(new moodle_url('/tag/manage.php'),
  54              get_string('managetags', 'tag'), 'GET');
  55  }
  56  if ($PAGE->user_allowed_editing()) {
  57      if ($edit != -1) {
  58          $USER->editing = $edit;
  59      }
  60      $buttons .= $OUTPUT->edit_button(clone($PAGE->url));
  61  }
  62  $PAGE->set_button($buttons);
  63  
  64  $tagrenderer = $PAGE->get_renderer('core', 'tag');
  65  $pagecontents = $tagrenderer->tag_search_page($query, $tagcollid);
  66  
  67  echo $OUTPUT->header();
  68  echo $pagecontents;
  69  echo $OUTPUT->footer();