From f287e69c33888bcae05f1a79930a34a4c6062228 Mon Sep 17 00:00:00 2001 From: willcast Date: Tue, 18 Nov 2003 14:29:31 +0000 Subject: [PATCH] - Messing of A and IMG tags because of auto-linking fixed --- mod/glossary/lib.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index a594e6ec96..de6db25506 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -359,7 +359,42 @@ function glossary_print_entry_concept($entry) { } function glossary_print_entry_definition($entry) { - $definition = str_ireplace($entry->concept,"$entry->concept",$entry->definition); + $definition = $entry->definition; + + //getting ride of A tags + $links = array(); + preg_match_all('//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('//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,"$entry->concept",$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 "$alias->alias: "; -- 2.39.5