]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14237: Removing all remaining tag-related uses of html_entity_decode (merge from...
authorscyrma <scyrma>
Mon, 7 Jul 2008 07:45:51 +0000 (07:45 +0000)
committerscyrma <scyrma>
Mon, 7 Jul 2008 07:45:51 +0000 (07:45 +0000)
blog/edit.php
tag/edit.php
tag/lib.php
tag/tag_autocomplete.php
user/editadvanced.php

index 21b863d8539740c7836e7c1afc372a1e4c4ab391..42b8944cad6211df68aa44bf0123e8f18a3cbadd 100755 (executable)
@@ -115,7 +115,7 @@ switch ($action) {
         $post->action       = $action;
         $strformheading = get_string('updateentrywithid', 'blog');
 
-        if ($itemptags = html_entity_decode(tag_get_tags_csv('post', $post->id, TAG_RETURN_TEXT, 'default'))) {
+        if ($itemptags = tag_get_tags_csv('post', $post->id, TAG_RETURN_TEXT, 'default')) {
             $post->ptags = $itemptags;
         }
         
index c17c29076647c54b9e9a748fb318c2b7cb90025b..e940ec830ad0ef14f40221d4aec64ea23dce19b7 100644 (file)
@@ -32,8 +32,7 @@ $systemcontext   = get_context_instance(CONTEXT_SYSTEM);
 require_capability('moodle/tag:edit', $systemcontext);
 
 // set the relatedtags field of the $tag object that will be passed to the form
-// need to use html_entity_decode because formslib does it for us later on.
-$tag->relatedtags = html_entity_decode(tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT));
+$tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
 
 if (can_use_html_editor()) {
     $options = new object();
index 0933f431d973c03399a2174278e80edc5d8bfb6f..80630cd4e384e102a29765acc59171339049d5fa 100644 (file)
@@ -313,7 +313,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>';
         }
@@ -460,7 +460,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>';
@@ -568,24 +568,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);
+    } 
 }
 
 /**
index 1d5cc7256a3f9eeac6fb221c4cae19b7d806fef9..60a648d3ad70d2c26a9b0df8156e0947992a80d3 100644 (file)
@@ -13,7 +13,7 @@ $query = optional_param('query', '', PARAM_RAW);
 
 if ($similar_tags = tag_autocomplete($query)) {
     foreach ($similar_tags as $tag) {
-        echo html_entity_decode(tag_display_name($tag)) . "\t" . tag_display_name($tag) . "\n";
+        echo $tag->name . "\t" . tag_display_name($tag) . "\n";
     }
 }
 
index 958d40bdce61f5500aaefa6cb0cb637f0e0d03bb..7d8d098184c59fb2ea42036cd9068d492205344f 100644 (file)
@@ -69,7 +69,7 @@
     //user interests separated by commas
     if (!empty($CFG->usetags)) {
         require_once($CFG->dirroot.'/tag/lib.php');
-        $user->interests = html_entity_decode(tag_get_tags_csv('user', $id, TAG_RETURN_TEXT)); // formslib uses htmlentities itself
+        $user->interests = tag_get_tags_csv('user', $id, TAG_RETURN_TEXT); // formslib uses htmlentities itself
     }
 
     //create form