|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00025 require_once('../config.php'); 00026 require_once('lib.php'); 00027 require_once('locallib.php'); 00028 require_once($CFG->dirroot.'/lib/weblib.php'); 00029 require_once($CFG->dirroot.'/blog/lib.php'); 00030 00031 require_login(); 00032 00033 if (empty($CFG->usetags)) { 00034 print_error('tagsaredisabled', 'tag'); 00035 } 00036 00037 $tagid = optional_param('id', 0, PARAM_INT); // tag id 00038 $tagname = optional_param('tag', '', PARAM_TAG); // tag 00039 00040 $edit = optional_param('edit', -1, PARAM_BOOL); 00041 $userpage = optional_param('userpage', 0, PARAM_INT); // which page to show 00042 $perpage = optional_param('perpage', 24, PARAM_INT); 00043 00044 $systemcontext = get_context_instance(CONTEXT_SYSTEM); 00045 00046 if ($tagname) { 00047 $tag = tag_get('name', $tagname, '*'); 00048 } else if ($tagid) { 00049 $tag = tag_get('id', $tagid, '*'); 00050 } 00051 unset($tagid); 00052 if (empty($tag)) { 00053 redirect($CFG->wwwroot.'/tag/search.php'); 00054 } 00055 00056 $PAGE->set_url('/tag/index.php', array('id' => $tag->id)); 00057 $PAGE->set_subpage($tag->id); 00058 $PAGE->set_context($systemcontext); 00059 $PAGE->set_pagelayout('standard'); 00060 $PAGE->set_blocks_editing_capability('moodle/tag:editblocks'); 00061 00062 if (($edit != -1) and $PAGE->user_allowed_editing()) { 00063 $USER->editing = $edit; 00064 } 00065 00066 $tagname = tag_display_name($tag); 00067 $title = get_string('tag', 'tag') .' - '. $tagname; 00068 00069 $button = ''; 00070 if ($PAGE->user_allowed_editing() ) { 00071 $button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tag->id))); 00072 } 00073 00074 $PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php')); 00075 $PAGE->navbar->add($tagname); 00076 $PAGE->set_title($title); 00077 $PAGE->set_heading($COURSE->fullname); 00078 $PAGE->set_button($button); 00079 echo $OUTPUT->header(); 00080 00081 // Manage all tags links 00082 if (has_capability('moodle/tag:manage', $systemcontext)) { 00083 echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">'. get_string('managetags', 'tag') .'</a></div>' ; 00084 } 00085 00086 $tagname = tag_display_name($tag); 00087 00088 if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) { 00089 $tagname = '<span class="flagged-tag">' . $tagname . '</span>'; 00090 } 00091 00092 echo $OUTPUT->heading($tagname, 2, 'headingblock header tag-heading'); 00093 tag_print_management_box($tag); 00094 tag_print_description_box($tag); 00095 00096 echo '<div class="relatedpages"><p><a href="#course">'.get_string('courses'). 00097 '</a> | <a href="#blog">'.get_string('relatedblogs', 'tag'). 00098 '</a> | <a href="#user">'.get_string('users').'</a></p></div>'; 00099 00100 // Display courses tagged with the tag 00101 require_once($CFG->dirroot.'/tag/coursetagslib.php'); 00102 if ($courses = coursetag_get_tagged_courses($tag->id)) { 00103 00104 $totalcount = count( $courses ); 00105 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 00106 00107 $heading = get_string('courses') . ' ' . get_string('taggedwith', 'tag', $tagname) .': '. $totalcount; 00108 echo "<a name='course'></a>"; 00109 echo $OUTPUT->heading($heading, 3); 00110 00111 foreach ($courses as $course) { 00112 print_course($course); 00113 } 00114 00115 echo $OUTPUT->box_end(); 00116 } 00117 00118 // Print up to 10 previous blogs entries 00119 if (has_capability('moodle/blog:view', $systemcontext)) { 00120 require_once($CFG->dirroot.'/blog/lib.php'); 00121 require_once($CFG->dirroot.'/blog/locallib.php'); 00122 00123 $bloglisting = new blog_listing(array('tag' => $tag->id)); 00124 $limit = 10; 00125 $start = 0; 00126 00127 if ($blogs = $bloglisting->get_entries($start, $limit)) { 00128 00129 echo $OUTPUT->box_start('generalbox', 'tag-blogs'); 00130 $heading = get_string('relatedblogs', 'tag', $tagname). ' ' . get_string('taggedwith', 'tag', $tagname); 00131 echo "<a name='blog'></a>"; 00132 echo $OUTPUT->heading($heading, 3); 00133 00134 echo '<ul id="tagblogentries">'; 00135 foreach ($blogs as $blog) { 00136 if ($blog->publishstate == 'draft') { 00137 $class = 'class="dimmed"'; 00138 } else { 00139 $class = ''; 00140 } 00141 echo '<li '.$class.'>'; 00142 echo '<a '.$class.' href="'.$CFG->wwwroot.'/blog/index.php?entryid='.$blog->id.'">'; 00143 echo format_string($blog->subject); 00144 echo '</a>'; 00145 echo ' - '; 00146 echo '<a '.$class.' href="'.$CFG->wwwroot.'/user/view.php?id='.$blog->userid.'">'; 00147 echo fullname($blog); 00148 echo '</a>'; 00149 echo ', '. userdate($blog->lastmodified); 00150 echo '</li>'; 00151 } 00152 echo '</ul>'; 00153 00154 $allblogsurl = new moodle_url('/blog/index.php', array('tagid' => $tag->id)); 00155 echo '<p class="moreblogs"><a href="'.$allblogsurl->out().'">'.get_string('seeallblogs', 'tag', $tagname).'</a></p>'; 00156 00157 echo $OUTPUT->box_end(); 00158 } 00159 } 00160 00161 $usercount = tag_record_count('user', $tag->id); 00162 if ($usercount > 0) { 00163 00164 //user table box 00165 echo $OUTPUT->box_start('generalbox', 'tag-user-table'); 00166 00167 $heading = get_string('users'). ' ' . get_string('taggedwith', 'tag', $tagname) . ': ' . $usercount; 00168 echo "<a name='user'></a>"; 00169 echo $OUTPUT->heading($heading, 3); 00170 00171 $baseurl = new moodle_url('/tag/index.php', array('id' => $tag->id)); 00172 $pagingbar = new paging_bar($usercount, $userpage, $perpage, $baseurl); 00173 $pagingbar->pagevar = 'userpage'; 00174 echo $OUTPUT->render($pagingbar); 00175 tag_print_tagged_users_table($tag, $userpage * $perpage, $perpage); 00176 echo $OUTPUT->box_end(); 00177 } 00178 00179 echo $OUTPUT->footer();