dirroot.'/lib/weblib.php'); require_once($CFG->dirroot.'/blog/lib.php'); require_login(); if (empty($CFG->usetags)) { print_error('tagsaredisabled', 'tag'); } $tagid = optional_param('id', 0, PARAM_INT); // tag id $tagname = optional_param('tag', '', PARAM_TAG); // tag $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); $systemcontext = get_context_instance(CONTEXT_SYSTEM); if ($tagname) { $tag = tag_get('name', $tagname, '*'); } else if ($tagid) { $tag = tag_get('id', $tagid, '*'); } if (empty($tag)) { redirect($CFG->wwwroot.'/tag/search.php'); } $PAGE->set_url('tag/index.php', array('id' => $tag->id)); $PAGE->set_subpage($tag->id); $PAGE->set_context($systemcontext); $PAGE->set_blocks_editing_capability('moodle/tag:editblocks'); if (($edit != -1) and $PAGE->user_allowed_editing()) { $USER->editing = $edit; } $tagname = tag_display_name($tag); $title = get_string('tag', 'tag') .' - '. $tagname; $button = ''; if ($PAGE->user_allowed_editing() ) { $button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tagid))); } $PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url($CFG->wwwroot.'/tag/search.php')); $PAGE->navbar->add($tagname); $PAGE->set_title($title); $PAGE->set_button($button); echo $OUTPUT->header(); // Manage all tags links if (has_capability('moodle/tag:manage', $systemcontext)) { echo '
' ; } $tagname = tag_display_name($tag); if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) { $tagname = '' . $tagname . ''; } echo $OUTPUT->heading($tagname, 2, 'headingblock header tag-heading'); tag_print_management_box($tag); tag_print_description_box($tag); echo ''; // Display courses tagged with the tag require_once($CFG->dirroot.'/tag/coursetagslib.php'); if ($courses = coursetag_get_tagged_courses($tag->id)) { $totalcount = count( $courses ); echo $OUTPUT->box_start('generalbox', 'tag-blogs'); //could use an id separate from tag-blogs, but would have to copy the css style to make it look the same $heading = get_string('courses') . ' ' . get_string('taggedwith', 'tag', $tagname) .': '. $totalcount; echo ""; echo $OUTPUT->heading($heading, 3); foreach ($courses as $course) { print_course($course); } echo $OUTPUT->box_end(); } // Print up to 10 previous blogs entries // 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 (has_capability('moodle/blog:view', $systemcontext)) { // You have to see blogs obviously $count = 10; if ($blogs = blog_fetch_entries(array('tag'=>$tag->id), $count)) { echo $OUTPUT->box_start('generalbox', 'tag-blogs'); $heading = get_string('relatedblogs', 'tag', $tagname). ' ' . get_string('taggedwith', 'tag', $tagname); echo ""; echo $OUTPUT->heading($heading, 3); echo '