';
+ $coursetagdivs .= '"f_commtags", ';
+ }
+ // Tidy up the end of a javascript array and add javascript
+ $coursetagdivs = rtrim($coursetagdivs, ', ');
+ $this->content->text .= coursetag_get_jscript($coursetagdivs);
+
+ // Add the divs (containing the tags) to the block's content
+ if ($alltags) { $this->content->text .= $alltagscontent; }
+ if ($mytags) { $this->content->text .= $mytagscontent; }
+ if ($officialtags) { $this->content->text .= $officialtagscontent; }
+ if ($coursetags) { $this->content->text .= $coursetagscontent; }
+ if ($commtags) { $this->content->text .= $commtagscontent; }
+
+ // add the input form section (allowing a user to tag the current course) and navigation, or loggin message
+ if ($loggedin) {
+ // only show the input form on course pages for those allowed (or not barred)
+ if ($coursepage && $canedit) {
+ //$this->content->footer .= coursetag_get_jscript();
+ $tagthisunit = get_string('tagthisunit', $tagslang);
+ $buttonadd = get_string('add', $tagslang);
+ $arrowtitle = get_string('arrowtitle', $tagslang);
+ $coursetaghelpbutton = helpbutton('addtags', 'adding tags', $tagslang, TRUE, FALSE, '', TRUE);
+ $this->content->footer .= <<
+
+EOT;
+ // add the edit link
+ $this->content->footer .= '
+
';
+ }
+
+ // Navigation elements at the bottom of the block
+ // show the alternative displays options if available
+ if ($mytags or $officialtags or $commtags or $coursetags) {
+ $this->content->footer .= '';
+ }
+ if ($mytags) {
+ $this->content->footer .= '
+
+ '.get_string('mytags2', $tagslang).' |';
+ }
+ if ($alltags and ($mytags or $officialtags or $commtags or $coursetags)) {
+ $this->content->footer .= '
+
+ '.get_string('alltags1', $tagslang).' |';
+ }
+ if ($officialtags) {
+ $this->content->footer .= '
+
+ '.get_string('officialtags1', $tagslang).' |';
+ }
+ if ($commtags) {
+ $this->content->footer .= '
+
+ '.get_string('communitytags1', $tagslang).' |';
+ }
+ if ($coursetags) {
+ $this->content->footer .= '
+
+ '.get_string('coursetags1', $tagslang).' |';
+ }
+ $this->content->footer = rtrim($this->content->footer, '|');
+ $this->content->footer .= '';
+ } else {
+ //if not logged in
+ $this->content->footer = ''.get_string('please', $tagslang).'
+ '.get_string('login', $tagslang).'
+ '.get_string('tagunits', $tagslang).'';
+ }
+ }
+ // end of show course tags section
return $this->content;
}
@@ -81,6 +334,21 @@
notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me()));
}
}
-}
+ /*
+ * function removed until rsslib supports dc/cc
+ */
+ /*
+ function cron() {
+ if (SHOWCOURSETAGS) {
+ global $CFG;
+ require_once($CFG->dirroot.'/tag/coursetagslib.php');
+ return coursetag_rss_feeds();
+ } else {
+ return TRUE;
+ }
+ }
+ */
+
+}
?>
Index: course/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/course/lib.php,v
retrieving revision 1.594
diff -u -r1.594 lib.php
--- course/lib.php 21 May 2008 12:03:22 -0000 1.594
+++ course/lib.php 29 May 2008 09:15:32 -0000
@@ -40,6 +40,9 @@
case 'upload':
return $url;
break;
+ case 'coursetags':
+ return '/'.$url;
+ break;
case 'library':
case '':
return '/';
Index: lib/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/upgrade.php,v
retrieving revision 1.202
diff -u -r1.202 upgrade.php
--- lib/db/upgrade.php 23 May 2008 22:30:42 -0000 1.202
+++ lib/db/upgrade.php 29 May 2008 09:15:35 -0000
@@ -49,6 +49,29 @@
upgrade_main_savepoint($result, 2008030700);
}
+ if ($result && $oldversion < 2008031200) {
+
+ // table to be modified
+ $table = new XMLDBTable('tag_instance');
+ // add field
+ $field = new XMLDBField('tiuserid');
+ if (!field_exists($table, $field)) {
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'itemid');
+ $result = $result && add_field($table, $field);
+ }
+ // modify index
+ $index = new XMLDBIndex('itemtype-itemid-tagid');
+ $index->setAttributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
+ drop_index($table, $index);
+ $index = new XMLDBIndex('itemtype-itemid-tagid-tiuserid');
+ $index->setAttributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid', 'tiuserid'));
+ drop_index($table, $index); //should not be required, but better safe than sorry
+ $result = $result && add_index($table, $index);
+
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2008031200);
+ }
+
if ($result && $oldversion < 2008050100) {
// Update courses that used weekscss to weeks
$result = $DB->set_field('course', 'format', 'weeks', array('format' => 'weekscss'));
Index: lib/db/install.xml
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/install.xml,v
retrieving revision 1.150
diff -u -r1.150 install.xml
--- lib/db/install.xml 16 May 2008 02:15:23 -0000 1.150
+++ lib/db/install.xml 29 May 2008 09:15:35 -0000
@@ -1503,8 +1503,9 @@
-
-
+
+
+
@@ -1512,7 +1513,7 @@
-
+
Index: lang/en_utf8/tag.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/tag.php,v
retrieving revision 1.15
diff -u -r1.15 tag.php
--- lang/en_utf8/tag.php 29 Feb 2008 09:35:04 -0000 1.15
+++ lang/en_utf8/tag.php 29 May 2008 09:15:32 -0000
@@ -40,9 +40,11 @@
$string['tagtype'] = 'Tag type';
$string['tagtype_official'] = 'Official';
$string['tagtype_default'] = 'Default';
+$string['tagindex_coursetitle'] = 'Courses tagged with $a';
$string['tags'] = 'Tags';
$string['tagsaredisabled'] = 'Tags are disabled';
$string['thingstaggedwith'] = '$a->count things tagged with \"$a->name\"';
+$string['thingtaggedwith'] = '$a->count thing tagged with \"$a->name\"';
$string['thistaghasnodesc'] = 'This tag currently has no description.';
$string['timemodified'] = 'Modified';
$string['typechanged'] = 'Tag type changed';
Index: lib/moodlelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v
retrieving revision 1.1047
diff -u -r1.1047 moodlelib.php
--- lib/moodlelib.php 20 May 2008 02:53:46 -0000 1.1047
+++ lib/moodlelib.php 29 May 2008 09:15:34 -0000
@@ -154,8 +154,8 @@
define('PARAM_TAG', 0x0011);
/**
- * PARAM_TAGLIST - list of tags separated by commas (interests, blogs, etc.)
- */
+ * PARAM_TAGLIST - list of tags separated by commas (interests, blogs, etc.)
+ */
define('PARAM_TAGLIST', 0x0012);
/**
@@ -259,9 +259,9 @@
/**
* Tag constanst
*/
-//To prevent problems with multibytes strings, this should not exceed the
+//To prevent problems with multibytes strings, this should not exceed the
//length of "varchar(255) / 3 (bytes / utf-8 character) = 85".
-define('TAG_MAX_LENGTH', 50);
+define('TAG_MAX_LENGTH', 50);
/**
* Password policy constants
@@ -570,7 +570,7 @@
}
case PARAM_TAG:
- //as long as magic_quotes_gpc is used, a backslash will be a
+ //as long as magic_quotes_gpc is used, a backslash will be a
//problem, so remove *all* backslash.
$param = str_replace('\\', '', $param);
//convert many whitespace chars into one
@@ -580,19 +580,19 @@
return $param;
- case PARAM_TAGLIST:
- $tags = explode(',', $param);
- $result = array();
- foreach ($tags as $tag) {
- $res = clean_param($tag, PARAM_TAG);
- if ($res != '') {
- $result[] = $res;
- }
- }
- if ($result) {
- return implode(',', $result);
- } else {
- return '';
+ case PARAM_TAGLIST:
+ $tags = explode(',', $param);
+ $result = array();
+ foreach ($tags as $tag) {
+ $res = clean_param($tag, PARAM_TAG);
+ if ($res != '') {
+ $result[] = $res;
+ }
+ }
+ if ($result) {
+ return implode(',', $result);
+ } else {
+ return '';
}
default: // throw error, switched parameters in optional_param or another serious problem
@@ -1952,12 +1952,12 @@
// Fetch the course context, and prefetch its child contexts
if (!isset($COURSE->context)) {
if ( ! $COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id) ) {
- print_error('nocontext');
+ print_error('nocontext');
}
}
if ($COURSE->id == SITEID) {
/// Eliminate hidden site activities straight away
- if (!empty($cm) && !$cm->visible
+ if (!empty($cm) && !$cm->visible
&& !has_capability('moodle/course:viewhiddenactivities', $COURSE->context)) {
redirect($CFG->wwwroot, get_string('activityiscurrentlyhidden'));
}
@@ -1999,7 +1999,7 @@
switch ($COURSE->guest) { /// Check course policy about guest access
- case 1: /// Guests always allowed
+ case 1: /// Guests always allowed
if (!has_capability('moodle/course:view', $COURSE->context)) { // Prohibited by capability
print_header_simple();
notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), "$CFG->wwwroot/login/index.php");
@@ -2049,7 +2049,7 @@
/// Make sure they can read this activity too, if specified
- if (!empty($cm) and !$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $COURSE->context)) {
+ if (!empty($cm) and !$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $COURSE->context)) {
redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden'));
}
user_accesstime_log($COURSE->id); /// Access granted, update lastaccess times
@@ -3114,7 +3114,7 @@
* Call to complete the user login process after authenticate_user_login()
* has succeeded. It will setup the $USER variable and other required bits
* and pieces.
- *
+ *
* NOTE:
* - It will NOT log anything -- up to the caller to decide what to log.
*
@@ -3126,7 +3126,7 @@
*/
function complete_user_login($user) {
global $CFG, $USER;
-
+
$USER = $user; // this is required because we need to access preferences here!
reload_user_preferences();
@@ -3629,6 +3629,10 @@
remove_course_grades($courseid, $showfeedback);
remove_grade_letters($context, $showfeedback);
+/// Delete course tags
+ require_once($CFG->dirroot.'/tag/coursetagslib.php');
+ coursetag_delete_course_tags($course->id, $showfeedback);
+
return $result;
}
@@ -4479,7 +4483,7 @@
/// If you don't want a welcome message sent, then make the message string blank.
if (!empty($message)) {
$subject = get_string('welcometocourse', '', format_string($course->fullname));
-
+
if (! $teacher = get_teacher($course->id)) {
$teacher = get_admin();
}
@@ -4534,7 +4538,7 @@
// Generate a two-level path for the userid. First level groups them by slices of 1000 users, second level is userid
$level1 = floor($userid / 1000) * 1000;
-
+
$userdir = "user/$level1/$userid";
if ($test) {
return $CFG->dataroot . '/' . $userdir;
@@ -4548,20 +4552,20 @@
*
* @param bool $only_non_empty Only return directories that contain files
* @param bool $legacy Search for user directories in legacy location (dataroot/users/userid) instead of (dataroot/user/section/userid)
- * @return array An associative array: userid=>array(basedir => $basedir, userfolder => $userfolder)
+ * @return array An associative array: userid=>array(basedir => $basedir, userfolder => $userfolder)
*/
function get_user_directories($only_non_empty=true, $legacy=false) {
global $CFG;
$rootdir = $CFG->dataroot."/user";
-
+
if ($legacy) {
- $rootdir = $CFG->dataroot."/users";
+ $rootdir = $CFG->dataroot."/users";
}
$dirlist = array();
- //Check if directory exists
- if (check_dir_exists($rootdir, true)) {
+ //Check if directory exists
+ if (check_dir_exists($rootdir, true)) {
if ($legacy) {
if ($userlist = get_directory_list($rootdir, '', true, true, false)) {
foreach ($userlist as $userid) {
@@ -4569,7 +4573,7 @@
}
} else {
notify("no directories found under $rootdir");
- }
+ }
} else {
if ($grouplist =get_directory_list($rootdir, '', true, true, false)) { // directories will be in the form 0, 1000, 2000 etc...
foreach ($grouplist as $group) {
@@ -4579,7 +4583,7 @@
}
}
}
- }
+ }
}
} else {
notify("$rootdir does not exist!");
@@ -6146,7 +6150,7 @@
/**
* Determines if the HTML editor is enabled.
*
- * This depends on site and user settings, as well as the current browser being
+ * This depends on site and user settings, as well as the current browser being
* used. The current requirements are based on Tinymce's, which are available
* on http://wiki.moxiecode.com/index.php/TinyMCE:Compatiblity
*
@@ -6512,7 +6516,7 @@
* @param string $text - text to be shortened
* @param int $ideal - ideal string length
* @param boolean $exact if false, $text will not be cut mid-word
- * @return string $truncate - shortened string
+ * @return string $truncate - shortened string
*/
function shorten_text($text, $ideal=30, $exact = false) {
@@ -6524,7 +6528,7 @@
if (strlen(preg_replace('/<.*?>/', '', $text)) <= $ideal) {
return $text;
}
-
+
// splits all html-tags to scanable lines
preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER);
@@ -6580,7 +6584,7 @@
$truncate .= $line_matchings[2];
$total_length += $content_length;
}
-
+
// if the maximum length is reached, get off the loop
if($total_length >= $ideal) {
break;
@@ -6601,7 +6605,7 @@
}
}
}
-
+
if (isset($breakpos)) {
// ...and cut the text in this position
$truncate = substr($truncate, 0, $breakpos);
@@ -7990,7 +7994,7 @@
/**
* Returns the language string for the given plugin.
- *
+ *
* @param string $plugin the plugin code name
* @param string $type the type of plugin (mod, block, filter)
* @return string The plugin language string
@@ -7999,7 +8003,7 @@
$plugin_name = '';
switch ($type) {
- case 'mod':
+ case 'mod':
$plugin_name = get_string('modulename', $plugin);
break;
case 'blocks':
@@ -8010,14 +8014,14 @@
} else {
$plugin_name = "[[$plugin]]";
}
- }
+ }
break;
case 'filter':
$plugin_name = trim(get_string('filtername', $plugin));
if (empty($plugin_name) or ($plugin_name == '[[filtername]]')) {
$textlib = textlib_get_instance();
$plugin_name = $textlib->strtotitle($plugin);
- }
+ }
break;
default:
$plugin_name = $plugin;
@@ -8031,7 +8035,7 @@
* Is a userid the primary administrator?
*
* @param $userid int id of user to check
- * @return boolean
+ * @return boolean
*/
function is_primary_admin($userid){
$primaryadmin = get_admin();
Index: lang/en_utf8/block_tags.php
===================================================================
RCS file: lang/en_utf8/block_tags.php
diff -N lang/en_utf8/block_tags.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lang/en_utf8/block_tags.php 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,66 @@
+
Index: tag/coursetags_add.php
===================================================================
RCS file: tag/coursetags_add.php
diff -N tag/coursetags_add.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tag/coursetags_add.php 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+dirroot.'/tag/coursetagslib.php');
+
+ if ($courseid > 0 and $userid > 0) {
+ $myurl = 'tag/search.php';
+ $keywords = explode(',', $keyword);
+ try {
+ coursetag_store_keywords($keywords, $courseid, $userid, 'default', $myurl);
+ }
+ catch (Exception $e) {
+ error($e->getmessage());
+ }
+ }
+}
+
+// send back to originating page, where the new tag will be visible in the block
+if ($courseid > 0) {
+ $myurl = $CFG->wwwroot.'/course/view.php?id='.$courseid;
+} else {
+ $myurl = $CFG->wwwroot.'/';
+}
+redirect($myurl);
+?>
Index: lang/en_utf8/help/block_tags/deletetags.html
===================================================================
RCS file: lang/en_utf8/help/block_tags/deletetags.html
diff -N lang/en_utf8/help/block_tags/deletetags.html
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lang/en_utf8/help/block_tags/deletetags.html 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,9 @@
+
Deleting a tag for a course
+
+
You will only be able to delete a tag entry that you have previously created.
+This allows you to tidy up those mis-spelled, or out-dated tags. Please note that
+deletion will only delete the tag if no other user has tagged something else with it,
+otherwise deletion will just delete your association of that tag for the course.
+
+
Deleting is done by highlighting the tag you wish to delete under 'Select...',
+then clicking the 'Submit' button below.
Index: tag/coursetagslib.php
===================================================================
RCS file: tag/coursetagslib.php
diff -N tag/coursetagslib.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tag/coursetagslib.php 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,577 @@
+dirroot.'/tag/lib.php';
+
+/**
+ * Returns an ordered array of tags associated with visible courses
+ * (boosted replacement of get_all_tags() allowing association with user and tagtype).
+ *
+ * @uses $CFG
+ * @param int $courseid, a 0 will return all distinct tags for visible courses
+ * @param int $userid optional the user id, a default of 0 will return all users tags for the course
+ * @param string $tagtype optional 'official' or 'default', empty returns both tag types
+ * @param int $numtags optional number of tags to display, default of 80 is set in the block, 0 returns all
+ * @param string $sort optional selected sorting, default is alpha sort (name) also timemodified or popularity
+ * @return array
+ */
+function coursetag_get_tags($courseid, $userid=0, $tagtype='', $numtags=0, $sort='name') {
+
+ global $CFG;
+
+ // get visible course ids
+ if ($courseid === 0) {
+ $courselist = '(';
+ if ($courses = get_records_select('course', 'visible=1 AND category>0', '', 'id')) {
+ foreach ($courses as $key => $value) {
+ $courselist .= "$key, ";
+ }
+ $courselist = rtrim($courselist, ', ');
+ $courselist .= ')';
+ } else {
+ $courselist = '';
+ }
+ }
+
+ // get tags from the db ordered by highest count first
+ $sql = "SELECT id as key, name, id, tagtype, rawname, f.timemodified, flag, count
+ FROM {$CFG->prefix}tag t,
+ (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count
+ FROM {$CFG->prefix}tag_instance
+ WHERE itemtype = 'course' ";
+ if ($courseid > 0) {
+ $sql .= "AND itemid = $courseid ";
+ } else {
+ if ($courselist) {
+ $sql .= "AND itemid IN $courselist ";
+ }
+ }
+ if ($userid > 0) $sql .= "AND tiuserid = $userid ";
+ $sql .= "GROUP BY tagid) f
+ WHERE t.id = f.tagid ";
+ if ($tagtype != '') $sql .= "AND tagtype = '$tagtype' ";
+ $sql .= "ORDER BY count DESC, name ASC";
+
+ // limit the number of tags for output
+ if ($numtags == 0) {
+ $tags = get_records_sql($sql);
+ } else {
+ $tags = get_records_sql($sql, 0, $numtags);
+ }
+
+ // prepare the return
+ $return = array();
+ if ($tags) {
+ // sort the tag display order
+ if ($sort != 'popularity') {
+ $CFG->tagsort = $sort;
+ usort($tags, "coursetag_sort");
+ }
+ // avoid print_tag_cloud()'s ksort upsetting ordering by setting the key here
+ foreach ($tags as $value) {
+ $return[] = $value;
+ }
+ }
+
+ return $return;
+
+}
+
+/**
+ * Returns an ordered array of tags
+ * (replaces popular_tags_count() allowing sorting).
+ *
+ * @uses $CFG
+ * @param string $sort optional selected sorting, default is alpha sort (name) also timemodified or popularity
+ * @param int $numtags optional number of tags to display, default of 20 is set in the block, 0 returns all
+ * @return array
+ */
+function coursetag_get_all_tags($sort='name', $numtags=0) {
+
+ global $CFG;
+
+ // note that this selects all tags except for courses that are not visible
+ $sql = "SELECT id as key, name, id, tagtype, rawname, f.timemodified, flag, count
+ FROM {$CFG->prefix}tag t,
+ (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count
+ FROM {$CFG->prefix}tag_instance WHERE tagid NOT IN
+ (SELECT tagid FROM {$CFG->prefix}tag_instance ti, {$CFG->prefix}course c
+ WHERE c.visible = 0
+ AND ti.itemtype = 'course'
+ AND ti.itemid = c.id)
+ GROUP BY tagid) f
+ WHERE t.id = f.tagid
+ ORDER BY count DESC, name ASC";
+
+ if ($numtags == 0) {
+ $tags = get_records_sql($sql);
+ } else {
+ $tags = get_records_sql($sql, 0, $numtags);
+ }
+
+ $return = array();
+ if ($tags) {
+ if ($sort != 'popularity') {
+ $CFG->tagsort = $sort;
+ usort($tags, "coursetag_sort");
+ }
+ foreach ($tags as $value) {
+ $return[] = $value;
+ }
+ }
+
+ return $return;
+
+}
+
+/**
+ * Callback function for coursetag_get_tags() and coursetag_get_all_tags() only
+ * @uses $CFG
+ */
+function coursetag_sort($a, $b) {
+ // originally from block_blog_tags
+ global $CFG;
+
+ // set up the variable $tagsort as either 'name' or 'timemodified' only, 'popularity' does not need sorting
+ if (empty($CFG->tagsort)) {
+ $tagsort = 'name';
+ } else {
+ $tagsort = $CFG->tagsort;
+ }
+
+ if (is_numeric($a->$tagsort)) {
+ return ($a->$tagsort == $b->$tagsort) ? 0 : ($a->$tagsort < $b->$tagsort) ? 1 : -1;
+ } elseif (is_string($a->$tagsort)) {
+ return strcmp($a->$tagsort, $b->$tagsort);
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * Prints a tag cloud
+ *
+ * @param array $tagcloud array of tag objects (fields: id, name, rawname, count and flag)
+ * @param int $max_size maximum text size, in percentage
+ * @param int $min_size minimum text size, in percentage
+ * @param $return if true return html string
+ */
+function coursetag_print_cloud($tagcloud, $return=false, $max_size=180, $min_size=80) {
+
+ global $CFG;
+
+ if (empty($tagcloud)) {
+ return;
+ }
+
+ ksort($tagcloud);//////
+
+ $count = array();
+ foreach ($tagcloud as $key => $value){
+ if(!empty($value->count)) {
+ $count[$key] = log10($value->count);
+ }
+ else{
+ $count[$key] = 0;
+ }
+ }
+
+ $max = max($count);
+ $min = min($count);
+
+ $spread = $max - $min;
+ if (0 == $spread) { // we don't want to divide by zero
+ $spread = 1;
+ }
+
+ $step = ($max_size - $min_size)/($spread);
+
+ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $can_manage_tags = has_capability('moodle/tag:manage', $systemcontext);
+
+ //prints the tag cloud
+ $output = '
';
+ foreach ($tagcloud as $key => $tag) {
+
+ $size = $min_size + ((log10($tag->count) - $min) * $step);
+ $size = ceil($size);
+
+ $style = 'style="font-size: '.$size.'%"';
+
+ if ($tag->count > 1) {
+ $title = 'title="'.s(get_string('thingstaggedwith','tag', $tag)).'"';
+ } else {
+ $title = 'title="'.s(get_string('thingtaggedwith','tag', $tag)).'"';
+ }
+
+ $href = 'href="'.$CFG->wwwroot.'/tag/index.php?id='.$tag->id.'"';
+
+ //highlight tags that have been flagged as inappropriate for those who can manage them
+ $tagname = tag_display_name($tag);
+ if ($tag->flag > 0 && $can_manage_tags) {
+ $tagname = '' . tag_display_name($tag) . '';
+ }
+
+ $tag_link = '
A tag is a shortcut or way of navigating to your favourite things.
+
+
Not only can you tag courses, but you may also tag your blogs, or even your own profile.
+
+
Clicking on a tag will take you to a page listing all the things associated with that tag.
+If the tag is a popular one you will be able to see what other things other users have associated
+with that tag.
+
+
You may add as many tags as you like. While it is recommended to only add one tag at a time,
+more tags could be entered on one occasion by seperating the tags with a comma.
+As you are adding a tag you may notice a word appearing in the background where you are typing.
+If this word is what you want as your tag then you can click on the little
+arrow next to the entry box to save typing the that word (and don't forget to click submit to save).
+
+
Tags must be more than one character and may be up to 50 characters long.
+Please note that while extended characters are allowed (e.g. French acute
+accented characters or Chinese characters), special characters will be
+stripped (e.g. "',\,_,<,-,~,?").
+Also note that tags cannot be pure integers or float number (e.g. 1 or 1.11)
+but number and letter combinations are fine (e.g. 1a).
+Finally, commas cannot be used in tag names, as these are separators between tags entered.
+
+
Don't forget to click the 'Submit' button below to save your new tag.
A note about the tag count. Hovering the mouse over a tag will reveal a tag count message
+like '2 things tagged with ...'.
+This count (number) will vary depending on where the tag is being displayed at the time.
+
+
The 'More tags' page (and the tags block) can display several different selections of tags
+- for instance 'all tags' or 'my tags'.
+The count displayed for a tag under 'all tags' may be different to the count for the same tag
+displayed under the 'my tags' or one of the other selections.
+This is because when 'all tags' is showing, all tags for courses, blogs and user profiles
+are displayed and counted.
+Where as when 'my tags' is showing, only your own tags for courses you have tagged
+are displayed and counted.
+So the count could be quite different for one tag under different sections.
+
+
Of course the size of the tag is also a clue to the count. The bigger the font size for the tag the
+more popular the tag is.
+
+
In fact it is easy to re-order the tags displayed by popularity, using the link provided.
+And the tags may be re-ordered alphabetically or in date of creation order as well. Try it.