MDL-15310: moving capability checks out of the library + code formatting adjustments
[moodle.git] / tag / search.php
CommitLineData
c933a060 1<?php
2
3require_once('../config.php');
4require_once('lib.php');
48d56528 5require_once('locallib.php');
c933a060 6require_once($CFG->dirroot.'/lib/weblib.php');
7
8global $CFG;
9require_login();
10
11if( empty($CFG->usetags)) {
48d56528 12 print_error('tagsaredisabled', 'tag');
c933a060 13}
14
48d56528 15$query = optional_param('query', '', PARAM_RAW);
16$page = optional_param('page', 0, PARAM_INT); // which page to show
17$perpage = optional_param('perpage', 18, PARAM_INT);
c933a060 18
19$navlinks = array();
20$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
21$navigation = build_navigation($navlinks);
22
48d56528 23$systemcontext = get_context_instance(CONTEXT_SYSTEM);
3d535996 24$manage_link = '&nbsp;';
c933a060 25
03ce38cd 26print_header_simple(get_string('tags', 'tag'), '', $navigation);
27
5fc1ea54 28if ( has_capability('moodle/tag:manage',$systemcontext) ) {
29 echo '<div class="managelink"><a href='. $CFG->wwwroot .'/tag/manage.php>' . get_string('managetags', 'tag') . '</a></div>' ;
30}
03ce38cd 31
c933a060 32print_heading(get_string('searchtags', 'tag'), '', 2);
33
3d535996 34tag_print_search_box();
c933a060 35
36if(!empty($query)) {
3d535996 37 tag_print_search_results($query, $page, $perpage);
c933a060 38}
39
40echo '<br/><br/>';
41
42print_box_start('generalbox', 'big-tag-cloud-box');
cf79f661 43tag_print_cloud(150);
c933a060 44print_box_end();
45
46print_footer();
47
48?>