Permalink
Browse files

- Adding slashes to [,] and other characters to allow autolinking.

  • Loading branch information...
1 parent 7c9c2a8 commit 229ed3b57c5efe13287d21043e6c4ad4c0643228 willcast committed Nov 20, 2003
Showing with 11 additions and 10 deletions.
  1. +11 −7 mod/glossary/dynalink.php
  2. +0 −3 mod/glossary/tabs.html
View
18 mod/glossary/dynalink.php
@@ -70,17 +70,13 @@ function glossary_dynamic_link($courseid, $text) {
$href_tag_begin = "<a target=\"entry\" class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concepttitle\" ".
"onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concepttitle', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
}
-
- $currentconcept = str_replace("|", "\|", $concept->concept);
- $currentconcept = str_replace("'", "\'", $currentconcept);
- $currentconcept = str_replace("*", "\*", $currentconcept);
+ $replace = "\\[]'\"*()";
+ $currentconcept = glossary_addslashes($replace,$concept->concept);
if ( $currentconcept = trim(strip_tags($currentconcept)) ) {
if ( !$concept->category ) {
if ( $aliases = get_records("glossary_alias","entryid",$concept->id, "alias") ) {
foreach ($aliases as $alias) {
- $currentalias = str_replace("|", "\|", $alias->alias);
- $currentalias = str_replace("'", "\'", $currentalias);
- $currentalias = str_replace("*", "\*", $currentalias);
+ $currentalias = glossary_addslashes($replace,$alias->alias);
$currentconcept .= "|" . trim($currentalias);
}
}
@@ -188,4 +184,12 @@ function glossary_sort_entries_by_lenght ( $entry0, $entry1 ) {
}
}
+ function glossary_addslashes ( $chars, $text ) {
+ if ( $chars ) {
+ for ($i = 0; $i < strlen($chars); $i++) {
+ $text = str_replace($chars[$i], "\\" . $chars[$i], $text);
+ }
+ }
+ return $text;
+ }
?>
View
3 mod/glossary/tabs.html
@@ -25,9 +25,6 @@
$data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary");
$data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
- $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=".GLOSSARY_CATEGORY_VIEW;
-
- $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
$data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&mode=$mode&hook=$hook";
}

0 comments on commit 229ed3b

Please sign in to comment.