MDL-14237: Removing all remaining tag-related uses of html_entity_decode

This commit is contained in:
scyrma
2008-07-07 07:40:35 +00:00
parent 347579d364
commit c2efdd7624
5 changed files with 17 additions and 12 deletions
+13 -7
View File
@@ -47,7 +47,6 @@ define('TAG_RELATED_ALL', 0);
define('TAG_RELATED_MANUAL', 1);
define('TAG_RELATED_CORRELATED', 2);
require_once($CFG->dirroot .'/tag/locallib.php');
///////////////////////////////////////////////////////
@@ -299,7 +298,7 @@ function tag_get_tags_csv($record_type, $record_id, $html=TAG_RETURN_HTML, $type
$tags_names = array();
foreach(tag_get_tags($record_type, $record_id, $type) as $tag) {
if ($html == TAG_RETURN_TEXT) {
$tags_names[] = tag_display_name($tag);
$tags_names[] = tag_display_name($tag, TAG_RETURN_TEXT);
} else { // TAG_RETURN_HTML
$tags_names[] = '<a href="'. $CFG->wwwroot .'/tag/index.php?tag='. rawurlencode($tag->name) .'">'. tag_display_name($tag) .'</a>';
}
@@ -439,7 +438,7 @@ function tag_get_related_tags_csv($related_tags, $html=TAG_RETURN_HTML) {
$tags_names = array();
foreach($related_tags as $tag) {
if ( $html == TAG_RETURN_TEXT) {
$tags_names[] = tag_display_name($tag);
$tags_names[] = tag_display_name($tag, TAG_RETURN_TEXT);
} else {
// TAG_RETURN_HTML
$tags_names[] = '<a href="'. $CFG->wwwroot .'/tag/index.php?tag='. rawurlencode($tag->name) .'">'. tag_display_name($tag) .'</a>';
@@ -544,24 +543,31 @@ function tag_delete_instance($record_type, $record_id, $tagid) {
* Function that returns the name that should be displayed for a specific tag
*
* @param object $tag_object a line out of tag table, as returned by the adobd functions
* @param int $html TAG_RETURN_HTML (default) will return htmlspecialchars encoded string, TAG_RETURN_TEXT will not encode.
* @return string
*/
function tag_display_name($tag_object) {
function tag_display_name($tagobject, $html=TAG_RETURN_HTML) {
global $CFG;
if(!isset($tag_object->name)) {
if(!isset($tagobject->name)) {
return '';
}
if (empty($CFG->keeptagnamecase)) {
//this is the normalized tag name
$textlib = textlib_get_instance();
return htmlspecialchars($textlib->strtotitle($tag_object->name));
$tagname = $textlib->strtotitle($tagobject->name);
} else {
//original casing of the tag name
return htmlspecialchars($tag_object->rawname);
$tagname = $tagobject->rawname;
}
if ($html == TAG_RETURN_TEXT) {
return $tagname;
} else { // TAG_RETURN_HTML
return htmlspecialchars($tagname);
}
}
/**