Merge branch 'MDL-48255-28' of git://github.com/lameze/moodle into MOODLE_28_STABLE
[moodle.git] / tag / search.php
blobb399bac2d1279642eda11ebb563c572fb92736b3
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * @package core
20 * @subpackage tag
21 * @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require_once('../config.php');
26 require_once('lib.php');
27 require_once('locallib.php');
29 require_login();
31 if (empty($CFG->usetags)) {
32 print_error('tagsaredisabled', 'tag');
35 $query = optional_param('query', '', PARAM_RAW);
36 $page = optional_param('page', 0, PARAM_INT); // which page to show
37 $perpage = optional_param('perpage', 18, PARAM_INT);
39 $params = array();
40 if ($query !== '') {
41 $params['query'] = $query;
43 if ($page !== 0) {
44 $params['page'] = $page;
46 if ($perpage !== 18) {
47 $params['perpage'] = $perpage;
49 $PAGE->set_url(new moodle_url('/tag/search.php', $params));
50 $PAGE->set_context(context_system::instance());
51 $PAGE->set_pagelayout('standard');
53 $systemcontext = context_system::instance();
54 $manage_link = '&nbsp;';
56 $PAGE->set_title(get_string('tags', 'tag'));
57 $PAGE->set_heading($SITE->fullname.': '.$PAGE->title);
58 echo $OUTPUT->header();
60 if ( has_capability('moodle/tag:manage',$systemcontext) ) {
61 echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">' . get_string('managetags', 'tag') . '</a></div>' ;
64 echo $OUTPUT->heading(get_string('searchtags', 'tag'), 2);
66 tag_print_search_box();
68 if(!empty($query)) {
69 tag_print_search_results($query, $page, $perpage);
72 echo '<br/><br/>';
74 echo $OUTPUT->box_start('generalbox', 'big-tag-cloud-box');
75 tag_print_cloud(null, 150);
76 echo $OUTPUT->box_end();
78 echo $OUTPUT->footer();