weekly release 4.0dev
[moodle.git] / tag / search.php
CommitLineData
c933a060 1<?php
000ebd5c
DM
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
c933a060 24require_once('../config.php');
c933a060 25
c933a060 26require_login();
27
e562ecdc 28if (empty($CFG->usetags)) {
48d56528 29 print_error('tagsaredisabled', 'tag');
c933a060 30}
31
c026a28d
MG
32$query = optional_param('query', '', PARAM_RAW);
33$tagcollid = optional_param('tc', 0, PARAM_INT);
34$edit = optional_param('edit', -1, PARAM_BOOL);
c933a060 35
d4a03c00 36$params = array();
7c4efe3b 37if ($query !== '') {
d4a03c00 38 $params['query'] = $query;
39}
c026a28d
MG
40if ($tagcollid) {
41 $params['tc'] = $tagcollid;
d4a03c00 42}
c026a28d 43
7c4efe3b 44$PAGE->set_url(new moodle_url('/tag/search.php', $params));
43731030 45$PAGE->set_context(context_system::instance());
7c4efe3b 46$PAGE->set_pagelayout('standard');
d4a03c00 47
968583af 48$PAGE->set_title(get_string('tags', 'tag'));
4e1f6047 49$PAGE->set_heading($SITE->fullname);
03ce38cd 50
c026a28d
MG
51$buttons = '';
52if (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');
5fc1ea54 55}
c026a28d
MG
56if ($PAGE->user_allowed_editing()) {
57 if ($edit != -1) {
58 $USER->editing = $edit;
59 }
60 $buttons .= $OUTPUT->edit_button(clone($PAGE->url));
c933a060 61}
c026a28d 62$PAGE->set_button($buttons);
c933a060 63
c026a28d
MG
64$tagrenderer = $PAGE->get_renderer('core', 'tag');
65$pagecontents = $tagrenderer->tag_search_page($query, $tagcollid);
c933a060 66
c026a28d
MG
67echo $OUTPUT->header();
68echo $pagecontents;
1dd2ba54 69echo $OUTPUT->footer();