]> git.mjollnir.org Git - moodle.git/commitdiff
- Messing of A and IMG tags because of auto-linking fixed
authorwillcast <willcast>
Tue, 18 Nov 2003 14:29:31 +0000 (14:29 +0000)
committerwillcast <willcast>
Tue, 18 Nov 2003 14:29:31 +0000 (14:29 +0000)
mod/glossary/lib.php

index a594e6ec9616f2442496aad85f9c11bb0d5e3924..de6db255060d2537829ebae5203d247a7140f145 100644 (file)
@@ -359,7 +359,42 @@ function  glossary_print_entry_concept($entry) {
 }
 
 function glossary_print_entry_definition($entry) {
-    $definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$entry->definition);
+    $definition = $entry->definition;
+
+    //getting ride of A tags
+    $links = array();
+    preg_match_all('/<img (.+?)>/is',$definition,$list_of_links);
+
+    foreach (array_unique($list_of_links[0]) as $key=>$value) {
+        $links['<@'.$key.'@>'] = $value;
+    }
+    if ( $links ) {
+        $definition = str_replace($links,array_keys($links),$definition);
+    }
+
+    //getting ride of IMG tags
+    $images = array();
+    preg_match_all('/<A (.+?)>/is',$definition,$list_of_images);
+
+    foreach (array_unique($list_of_images[0]) as $key=>$value) {
+        $images['<@'.$key.'@>'] = $value;
+    }
+    if ( $images ) {
+        $definition = str_replace($images,array_keys($images),$definition);
+    }
+        
+    $definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$definition);
+
+    //restoring A tags
+    if ( $links ) {
+        $definition = str_replace(array_keys($links),$links,$definition);
+    }
+
+    //restoring IMG tags
+    if ( $images ) {
+        $definition = str_replace(array_keys($images),$images,$definition);
+    }
+
 /*    if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) {
         foreach ($aliases as $alias) {
         echo "<small><font color=red>$alias->alias: ";