Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Filter will now not link within the head tags

  • Loading branch information...
commit 8af04b002d79611edbb10c0248e32b635861fda8 1 parent 7369657
moodler authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 mod/glossary/filter.php
View
14 mod/glossary/filter.php
@@ -155,6 +155,17 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
}
}
+ //Avoid searching within the document head
+ $head = array();
+ preg_match_all('/<head>(.+?)<\/head>/is',$text,$list_of_heads);
+ foreach (array_unique($list_of_heads[0]) as $key=>$value) {
+ $head['<~'.$key.'~>'] = $value;
+ }
+ if (!empty($head)) {
+ $text = str_replace($head,array_keys($head),$text);
+ }
+
+
//Now avoid searching inside the <nolink>tag
$excludes = array();
preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);
@@ -217,6 +228,9 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
if (!empty( $excludes)) {
$text = str_replace(array_keys($excludes),$excludes,$text);
}
+ if (!empty( $head)) {
+ $text = str_replace(array_keys($head),$head,$text);
+ }
if ($fullmatch and !empty($words)) {
$text = str_replace(array_keys($words),$words,$text);
}
Please sign in to comment.
Something went wrong with that request. Please try again.