From: willcast Date: Wed, 15 Oct 2003 17:27:51 +0000 (+0000) Subject: - Link within link issue: Solved. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a9c4a830f77ec5dedb16989de5ceb4b982e6c222;p=moodle.git - Link within link issue: Solved. --- diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index 788096200e..010ef9b2e7 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -44,27 +44,27 @@ $ORDER_BY = "concept ASC"; } - $ownentries = get_records("glossary_entries", "glossaryid", $glossary->id,$ORDER_BY); - $importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id,$ORDER_BY); - - if ( $ownentries and $importedentries ) { - $entries = array_merge($ownentries, $importedentries); - usort($entries, glossary_sort_entries_by_lenght); - } elseif ( $importedentries ) { - $entries = $importedentries; - } elseif ( $ownentries ) { - $entries = $ownentries; - } + $ownentries = get_records("glossary_entries", "glossaryid", $glossary->id,$ORDER_BY); + $importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id,$ORDER_BY); + + if ( $ownentries and $importedentries ) { + $entries = array_merge($ownentries, $importedentries); + usort($entries, glossary_sort_entries_by_lenght); + } elseif ( $importedentries ) { + $entries = $importedentries; + } elseif ( $ownentries ) { + $entries = $ownentries; + } } if ( $entries ) { foreach ( $entries as $entry ) { $title = strip_tags("$glossary->name: $entry->concept"); - $href_tag_begin = "wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$entry->concept\" ". - "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid&concept=$entry->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">"; + $href_tag_begin = "wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$entry->concept\" ". + "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$entry->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">"; $concept = trim(strip_tags($entry->concept)); - $text = glossary_link_concepts($text,$concept,$href_tag_begin, ""); + $text = glossary_link_concepts($text,$concept,$href_tag_begin, ""); } } } @@ -73,16 +73,26 @@ } function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "") { - $list_of_words = $concept; - $list_of_words_cp = $list_of_words; + $list_of_words_cp = $concept; + // getting ride of "A" tags + $final = array(); + + preg_match_all('/(.+?)<\/A>/is',$text,$list_of_links); + + foreach (array_unique($list_of_links[0]) as $key=>$value) { + $links['<|*'.$key.'*|>'] = $value; + } + $text = str_replace($links,array_keys($links),$text); + + // getting ride of all other tahs $final = array(); preg_match_all('/<(.+?)>/is',$text,$list_of_words); foreach (array_unique($list_of_words[0]) as $key=>$value) { $final['<|'.$key.'|>'] = $value; } - + $text = str_replace($final,array_keys($final),$text); if ($list_of_words_cp{0}=="|") { @@ -95,6 +105,7 @@ $text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text); $text = str_replace(array_keys($final),$final,$text); + $text = str_replace(array_keys($links),$links,$text); return stripslashes($text); }