forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
151 lines (106 loc) · 4.6 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php // $Id$
require_once('../config.php');
require_once('lib.php');
require_once('pagelib.php');
require_once($CFG->dirroot.'/lib/weblib.php');
require_once($CFG->dirroot.'/blog/lib.php');
require_login();
if (empty($CFG->usetags)) {
error(get_string('tagsaredisabled', 'tag'));
}
$tagid = optional_param('id', 0, PARAM_INT); // tag id
$tag_name = optional_param('tag', '', PARAM_TAG); // tag
if ($tag_name) {
$tag = tag_get_id($tag_name, TAG_RETURN_OBJECT);
} elseif ($tagid) {
$tag = tag_get_tag_by_id($tagid); // for backward compatibility
}
$edit = optional_param('edit', -1, PARAM_BOOL);
$userpage = optional_param('userpage', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', 24, PARAM_INT);
if (!isset($tag) || !$tag->id) {
redirect($CFG->wwwroot.'/tag/search.php');
}
//create a new page_tag object, defined in pagelib.php
$PAGE = page_create_object(PAGE_TAG_INDEX, $tag->id);
$pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
$PAGE->tag_object = $tag;
if (($edit != -1) and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
$PAGE->print_header();
// Manage all tags links
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/tag:manage', $systemcontext)) {
echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">'. get_string('managetags', 'tag') .'</a></div>' ;
}
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
echo '<tr valign="top">';
//----------------- left column -----------------
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
//----------------- middle column -----------------
echo '<td valign="top" id="middle-column">';
$tagname = tag_display_name($tag);
if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
$tagname = '<span class="flagged-tag">' . rawurlencode($tagname) . '</span>';
}
print_heading($tagname, '', 2, 'headingblock header tag-heading');
tag_print_management_box($tag);
tag_print_description_box($tag);
$usercount = tag_record_count('user', $tag->id);
if ($usercount > 0) {
//user table box
print_box_start('generalbox', 'tag-user-table');
$heading = get_string('userstaggedwith', 'tag', $tagname) . ': ' . $usercount;
print_heading($heading, '', 3);
$baseurl = $CFG->wwwroot.'/tag/index.php?id=' . $tag->id;
print_paging_bar($usercount, $userpage, $perpage, $baseurl.'&', 'userpage');
tag_print_tagged_users_table($tag, $userpage * $perpage, $perpage);
print_box_end();
}
// Print last 10 blogs
// I was not able to use get_items_tagged_with() because it automatically
// tries to join on 'blog' table, since the itemtype is 'blog'. However blogs
// uses the post table so this would not really work. - Yu 29/8/07
if ($blogs = blog_fetch_entries('', 10, 0, 'site', '', $tag->id)) {
print_box_start('generalbox', 'tag-blogs');
print_heading(get_string('relatedblogs', 'tag'), '', 3);
echo '<ul id="tagblogentries">';
foreach ($blogs as $blog) {
if ($blog->publishstate == 'draft') {
$class = 'class="dimmed"';
} else {
$class = '';
}
echo '<li '.$class.'>';
echo '<a '.$class.' href="'.$CFG->wwwroot.'/blog/index.php?postid='.$blog->id.'">';
echo format_string($blog->subject);
echo '</a>';
echo ' - ';
echo '<a '.$class.' href="'.$CFG->wwwroot.'/user/view.php?id='.$blog->userid.'">';
echo fullname($blog);
echo '</a>';
echo ', '. userdate($blog->lastmodified);
echo '</li>';
}
echo '</ul>';
echo '<p class="moreblogs"><a href="'.$CFG->wwwroot.'/blog/index.php?filtertype=site&filterselect=0&tagid='.$tag->id.'">'.get_string('seeallblogs', 'tag').'</a>...</p>';
print_box_end();
}
echo '</td>';
//----------------- right column -----------------
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
/// Finish the page
echo '</tr></table>';
$PAGE->print_footer();
?>