First checkin of tag system from GSOC student Luiz Cruz
[moodle.git] / tag / index.php
CommitLineData
c933a060 1<?php // $Id$
2
3require_once('../config.php');
4require_once('lib.php');
5require_once($CFG->dirroot.'/lib/weblib.php');
6
7require_login();
8
9if (empty($CFG->usetags)) {
10 error(get_string('tagsaredisabled', 'tag'));
11}
12
13$tagid = optional_param('id', 0, PARAM_INT); // tag id
14$userpage = optional_param('userpage', 0, PARAM_INT); // which page to show
15$perpage = optional_param('perpage', 16, PARAM_INT);
16
17$tag = tag_by_id($tagid);
18
19if (!$tag) {
20 redirect($CFG->wwwroot.'/tag/search.php');
21}
22
23$tagname = mb_convert_case($tag->name, MB_CASE_TITLE, "UTF-8");
24
25$navlinks = array();
26$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
27$navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
28
29$navigation = build_navigation($navlinks);
30print_header_simple(get_string('tag', 'tag') . ' - ' . $tagname, '', $navigation);
31
32$systemcontext = get_context_instance(CONTEXT_SYSTEM);
33if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
34 $tagname = '<span class="flagged-tag">' . $tagname . '</span>';
35}
36
37print_heading($tagname, '', 2);
38
39print_tag_management_box($tag);
40
41print_tag_description_box($tag);
42
43
44$usercount = count_items_tagged_with($tagid,'user');
45
46if ($usercount > 0) {
47
48 print_heading(get_string('userstaggedwith', 'tag', $tagname) . ': ' . $usercount, '', 3);
49
50 $baseurl = $CFG->wwwroot.'/tag/index.php?id=' . $tagid;
51
52 print_paging_bar($usercount, $userpage, $perpage, $baseurl.'&amp;', 'userpage');
53
54 print_tagged_users_table($tag, 4, $userpage * $perpage, $perpage);
55
56}
57//print_box_start('generalbox', 'small-tag-cloud-box');
58// print_tag_cloud(15,170,80);
59//print_box_end();
60
61print_footer();
62
63
64
65
66?>