4 * a full display of tags allowing some filtering and reordering
5 * @author j.beedell@open.ac.uk June07
8 require_once('../config.php');
9 require_once($CFG->dirroot
.'/tag/coursetagslib.php');
10 require_once($CFG->dirroot
.'/tag/lib.php');
12 $sort = optional_param('sort', 'alpha', PARAM_ALPHA
); //alpha, date or popularity
13 $show = optional_param('show', 'all', PARAM_ALPHA
); //all, my, official, community or course
14 $courseid = optional_param('courseid', 0, PARAM_INT
);
16 $url = new moodle_url('/tag/coursetags_more.php');
17 if ($sort !== 'alpha') {
18 $url->param('sort', $sort);
20 if ($show !== 'all') {
21 $url->param('show', $show);
23 if ($courseid !== 0) {
24 $url->param('courseid', $courseid);
28 if (empty($CFG->usetags
)) {
29 print_error('tagsaredisabled', 'tag');
32 // Some things require logging in
33 if ($CFG->forcelogin
or $show == 'my') {
38 $loggedin = isloggedin() && !isguestuser();
42 if (!($course = $DB->get_record('course', array('id'=>$courseid)))) {
45 if ($courseid == SITEID
) $courseid = 0;
49 $PAGE->set_context(get_context_instance(CONTEXT_COURSE
, $courseid));
51 $PAGE->set_context(get_system_context());
55 $tagslang = 'block_tags';
56 $title = get_string('moretitle', $tagslang);
57 $link1 = get_string('moreshow', $tagslang);
58 $link2 = get_string('moreorder', $tagslang);
59 $showalltags = get_string('moreshowalltags', $tagslang);
60 $showofficialtags = get_string('moreshowofficialtags', $tagslang);
61 $showmytags = get_string('moreshowmytags', $tagslang);
62 $showcommtags = get_string('moreshowcommtags', $tagslang);
63 $orderalpha = get_string('moreorderalpha', $tagslang);
64 $orderdate = get_string('moreorderdate', $tagslang);
65 $orderpop = get_string('moreorderpop', $tagslang);
66 $welcome = get_string('morewelcome', $tagslang);
68 // The title and breadcrumb
70 $PAGE->navbar
->add(format_string($course->shortname
), new moodle_url('/course/view.php', array('id'=>$courseid)));
72 $PAGE->navbar
->add($title);
73 $PAGE->set_title($title);
74 $PAGE->set_heading($COURSE->fullname
);
75 echo $OUTPUT->header();
76 echo $OUTPUT->heading($title, 2, 'centre');
78 // Prepare data for tags
80 if ($courseid) { $courselink = '&courseid='.$courseid; }
81 $myurl = $CFG->wwwroot
.'/tag/coursetags_more.php';
82 $myurl2 = $CFG->wwwroot
.'/tag/coursetags_more.php?show='.$show;
85 if ($show == 'course' and $courseid) {
87 if ($sort == 'popularity') {
88 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'popularity'), true, 200, 90);
89 } else if ($sort == 'date') {
90 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'timemodified'), true, 200, 90);
92 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'name'), true, 200, 90);
96 } else if ($show == 'my' and $loggedin) {
98 if ($sort == 'popularity') {
99 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'popularity'), true, 200, 90);
100 } else if ($sort == 'date') {
101 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'timemodified'), true, 200, 90);
103 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'name'), true, 200, 90);
106 // Official course tags
107 } else if ($show == 'official') {
109 if ($sort == 'popularity') {
110 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'popularity'), true, 200, 90);
111 } else if ($sort == 'date') {
112 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'timemodified'), true, 200, 90);
114 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'name'), true, 200, 90);
117 // Community (official and personal together) also called user tags
118 } else if ($show == 'community') {
120 if ($sort == 'popularity') {
121 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'popularity'), true, 200, 90);
122 } else if ($sort == 'date') {
123 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'timemodified'), true, 200, 90);
125 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'name'), true, 200, 90);
128 // All tags for courses and blogs and any thing else tagged - the fallback default ($show == all)
131 $subtitle = $showalltags;
132 if ($sort == 'popularity') {
133 $tags = coursetag_print_cloud(coursetag_get_all_tags('popularity'), true, 200, 90);
134 } else if ($sort == 'date') {
135 $tags = coursetag_print_cloud(coursetag_get_all_tags('timemodified'), true, 200, 90);
137 $tags = coursetag_print_cloud(coursetag_get_all_tags('name'), true, 200, 90);
142 // Prepare the links for the show and order lines
143 if ($show == 'all') {
144 $link1 .= '<b>'.$showalltags.'</b>';
146 $link1 .= '<a href="'.$myurl.'?show=all'.$courselink.'">'.$showalltags.'</a>';
148 //if ($show == 'official') { //add back in if you start to use official course tags
149 // $link1 .= ' | <b>'.$showofficialtags.'</b>';
151 // $link1 .= ' | <a href="'.$myurl.'?show=official'.$courselink.'">'.$showofficialtags.'</a>';
153 if ($show == 'community') {
154 $link1 .= ' | <b>'.$showcommtags.'</b>';
156 $link1 .= ' | <a href="'.$myurl.'?show=community'.$courselink.'">'.$showcommtags.'</a>';
160 $link1 .= ' | <b>'.$showmytags.'</b>';
162 $link1 .= ' | <a href="'.$myurl.'?show=my'.$courselink.'">'.$showmytags.'</a>';
166 if ($show == 'course') {
167 $link1 .= ' | <b>'.get_string('moreshowcoursetags', $tagslang, $course->fullname
).'</b>';
169 $link1 .= ' | <a href="'.$myurl.'?show=course'.$courselink.'">'.get_string('moreshowcoursetags', $tagslang, $course->fullname
).'</a>';
172 if ($sort == 'alpha') {
173 $link2 .= '<b>'.$orderalpha.'</b> | ';
175 $link2 .= '<a href="'.$myurl2.'&sort=alpha'.$courselink.'">'.$orderalpha.'</a> | ';
177 if ($sort == 'popularity') {
178 $link2 .= '<b>'.$orderpop.'</b> | ';
180 $link2 .= '<a href="'.$myurl2.'&sort=popularity'.$courselink.'">'.$orderpop.'</a> | ';
182 if ($sort == 'date') {
183 $link2 .= '<b>'.$orderdate.'</b>';
185 $link2 .= '<a href="'.$myurl2.'&sort=date'.$courselink.'">'.$orderdate.'</a>';
190 // make the tags larger when there are not so many
191 if (strlen($tags) < 10000) { $fclass = 'coursetag_more_large'; }
193 <div class="coursetag_more_title">
194 <div style="padding-bottom:5px">'.$welcome.'</div>
195 <div class="coursetag_more_link">'.$link1.'</div>
196 <div class="coursetag_more_link">'.$link2.'</div>
198 <div class="coursetag_more_tags '.$fclass.'">'.
203 echo $OUTPUT->footer();