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_TEXT
); //alpha, date or popularity
13 $show = optional_param('show', 'all', PARAM_TEXT
); //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 $tagslang = 'block_tags';
50 $title = get_string('moretitle', $tagslang);
51 $link1 = get_string('moreshow', $tagslang);
52 $link2 = get_string('moreorder', $tagslang);
53 $showalltags = get_string('moreshowalltags', $tagslang);
54 $showofficialtags = get_string('moreshowofficialtags', $tagslang);
55 $showmytags = get_string('moreshowmytags', $tagslang);
56 $showcommtags = get_string('moreshowcommtags', $tagslang);
57 $orderalpha = get_string('moreorderalpha', $tagslang);
58 $orderdate = get_string('moreorderdate', $tagslang);
59 $orderpop = get_string('moreorderpop', $tagslang);
60 $welcome = get_string('morewelcome', $tagslang);
62 // The title and breadcrumb
64 $PAGE->navbar
->add(format_string($course->shortname
), new moodle_url('/course/view.php', array('id'=>$courseid)));
66 $PAGE->navbar
->add($title);
67 $PAGE->set_title($title);
68 echo $OUTPUT->header();
69 echo $OUTPUT->heading($title, 2, 'centre');
71 // Prepare data for tags
73 if ($courseid) { $courselink = '&courseid='.$courseid; }
74 $myurl = $CFG->wwwroot
.'/tag/coursetags_more.php';
75 $myurl2 = $CFG->wwwroot
.'/tag/coursetags_more.php?show='.$show;
78 if ($show == 'course' and $courseid) {
80 if ($sort == 'popularity') {
81 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'popularity'), true, 200, 90);
82 } else if ($sort == 'date') {
83 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'timemodified'), true, 200, 90);
85 $tags = coursetag_print_cloud(coursetag_get_tags($courseid, 0, '', 0, 'name'), true, 200, 90);
89 } else if ($show == 'my' and $loggedin) {
91 if ($sort == 'popularity') {
92 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'popularity'), true, 200, 90);
93 } else if ($sort == 'date') {
94 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'timemodified'), true, 200, 90);
96 $tags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id
, 'default', 0, 'name'), true, 200, 90);
99 // Official course tags
100 } else if ($show == 'official') {
102 if ($sort == 'popularity') {
103 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'popularity'), true, 200, 90);
104 } else if ($sort == 'date') {
105 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'timemodified'), true, 200, 90);
107 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', 0, 'name'), true, 200, 90);
110 // Community (official and personal together) also called user tags
111 } else if ($show == 'community') {
113 if ($sort == 'popularity') {
114 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'popularity'), true, 200, 90);
115 } else if ($sort == 'date') {
116 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'timemodified'), true, 200, 90);
118 $tags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', 0, 'name'), true, 200, 90);
121 // All tags for courses and blogs and any thing else tagged - the fallback default ($show == all)
124 $subtitle = $showalltags;
125 if ($sort == 'popularity') {
126 $tags = coursetag_print_cloud(coursetag_get_all_tags('popularity'), true, 200, 90);
127 } else if ($sort == 'date') {
128 $tags = coursetag_print_cloud(coursetag_get_all_tags('timemodified'), true, 200, 90);
130 $tags = coursetag_print_cloud(coursetag_get_all_tags('name'), true, 200, 90);
135 // Prepare the links for the show and order lines
136 if ($show == 'all') {
137 $link1 .= '<b>'.$showalltags.'</b>';
139 $link1 .= '<a href="'.$myurl.'?show=all'.$courselink.'">'.$showalltags.'</a>';
141 //if ($show == 'official') { //add back in if you start to use official course tags
142 // $link1 .= ' | <b>'.$showofficialtags.'</b>';
144 // $link1 .= ' | <a href="'.$myurl.'?show=official'.$courselink.'">'.$showofficialtags.'</a>';
146 if ($show == 'community') {
147 $link1 .= ' | <b>'.$showcommtags.'</b>';
149 $link1 .= ' | <a href="'.$myurl.'?show=community'.$courselink.'">'.$showcommtags.'</a>';
153 $link1 .= ' | <b>'.$showmytags.'</b>';
155 $link1 .= ' | <a href="'.$myurl.'?show=my'.$courselink.'">'.$showmytags.'</a>';
159 if ($show == 'course') {
160 $link1 .= ' | <b>'.get_string('moreshowcoursetags', $tagslang, $course->fullname
).'</b>';
162 $link1 .= ' | <a href="'.$myurl.'?show=course'.$courselink.'">'.get_string('moreshowcoursetags', $tagslang, $course->fullname
).'</a>';
165 if ($sort == 'alpha') {
166 $link2 .= '<b>'.$orderalpha.'</b> | ';
168 $link2 .= '<a href="'.$myurl2.'&sort=alpha'.$courselink.'">'.$orderalpha.'</a> | ';
170 if ($sort == 'popularity') {
171 $link2 .= '<b>'.$orderpop.'</b> | ';
173 $link2 .= '<a href="'.$myurl2.'&sort=popularity'.$courselink.'">'.$orderpop.'</a> | ';
175 if ($sort == 'date') {
176 $link2 .= '<b>'.$orderdate.'</b>';
178 $link2 .= '<a href="'.$myurl2.'&sort=date'.$courselink.'">'.$orderdate.'</a>';
183 // make the tags larger when there are not so many
184 if (strlen($tags) < 10000) { $fclass = 'coursetag_more_large'; }
186 <div class="coursetag_more_title">
187 <div style="padding-bottom:5px">'.$welcome.
188 $OUTPUT->old_help_icon('usingtags', 'using tags', $tagslang).'
190 <div class="coursetag_more_link">'.$link1.'</div>
191 <div class="coursetag_more_link">'.$link2.'</div>
193 <div class="coursetag_more_tags '.$fclass.'">'.
198 echo $OUTPUT->footer();