function trusttext_after_edit(&$text, $context) { if (has_capability('moodle/site:trustcontent', $context)) { $text = trusttext_strip($text); $text = trusttext_mark($text); } else { $text = trusttext_strip($text); } }
$post->message = trusttext_strip($post->message); $message = str_replace('<fgw9sdpq4>', '<span class="highlight">', $message); $message = str_replace('</fgw9sdpq4>', '</span>', $message); if ($missing_terms) { $strmissingsearchterms = get_string('missingsearchterms', 'forum'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $message; $ttpresent = false; } else { $post->message = $message; } $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; //search terms already highlighted - fiedorow - 9/2/2005 $SESSION->forum_search = true; // reconstruct the TRUSTTEXT properly after processing if ($ttpresent) { $post->message = trusttext_mark($post->message); } else { $post->message = trusttext_strip($post->message); //make 100% sure TRUSTTEXT marker was not created during processing } forum_print_post($post, $course->id, false, false, false, false, $fulllink); unset($SESSION->forum_search); echo "<br />"; } print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode(stripslashes($search)) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); /** * @todo Document this function */ function forum_print_big_search_form($course) {
function glossary_print_entry_definition($entry) { $definition = $entry->definition; // always detect and strip TRUSTTEXT marker before processing and add+strip it afterwards! if (trusttext_present($definition)) { $ttpresent = true; $definition = trusttext_strip($definition); } else { $ttpresent = false; } global $GLOSSARY_EXCLUDECONCEPTS; //Calculate all the strings to be no-linked //First, the concept $GLOSSARY_EXCLUDECONCEPTS = array($entry->concept); //Now the aliases if ($aliases = get_records('glossary_alias', 'entryid', $entry->id)) { foreach ($aliases as $alias) { $GLOSSARY_EXCLUDECONCEPTS[] = trim($alias->alias); } } $options = new object(); $options->para = false; $options->trusttext = true; // reconstruct the TRUSTTEXT properly after processing if ($ttpresent) { $definition = trusttext_mark($definition); } else { $definition = trusttext_strip($definition); //make 100% sure TRUSTTEXT marker was not created } $text = format_text($definition, $entry->format, $options); // Stop excluding concepts from autolinking unset($GLOSSARY_EXCLUDECONCEPTS); if (!empty($entry->highlight)) { $text = highlight($entry->highlight, $text); } if (isset($entry->footer)) { // Unparsed footer info $text .= $entry->footer; } echo $text; }
function glossary_print_entry_definition($entry) { $definition = $entry->definition; // always detect and strip TRUSTTEXT marker before processing and add+strip it afterwards! if (trusttext_present($definition)) { $ttpresent = true; $definition = trusttext_strip($definition); } else { $ttpresent = false; } $links = array(); $tags = array(); $urls = array(); $addrs = array(); //Calculate all the strings to be no-linked //First, the concept $term = preg_quote(trim($entry->concept), '/'); $pat = '/(' . $term . ')/is'; $doNolinks[] = $pat; //Now the aliases if ($aliases = get_records('glossary_alias', 'entryid', $entry->id)) { foreach ($aliases as $alias) { $term = preg_quote(trim($alias->alias), '/'); $pat = '/(' . $term . ')/is'; $doNolinks[] = $pat; } } //Extract <a>..><a> tags from definition preg_match_all('/<a[^>]+?>(.*?)<\\/a>/is', $definition, $list_of_a); //Save them into links array to use them later foreach (array_unique($list_of_a[0]) as $key => $value) { $links['<#' . $key . '#>'] = $value; } //Take off every link from definition if ($links) { $definition = str_replace($links, array_keys($links), $definition); } //Extract all tags from definition preg_match_all('/(<.*?>)/is', $definition, $list_of_tags); //Save them into tags array to use them later foreach (array_unique($list_of_tags[0]) as $key => $value) { $tags['<@' . $key . '@>'] = $value; } //Take off every tag from definition if ($tags) { $definition = str_replace($tags, array_keys($tags), $definition); } //Extract all URLS with protocol (http://domain.com) from definition preg_match_all('/([[:space:]]|^|\\(|\\[)([[:alnum:]]+):\\/\\/([^[:space:]]*)([[:alnum:]#?\\/&=])/is', $definition, $list_of_urls); //Save them into urls array to use them later foreach (array_unique($list_of_urls[0]) as $key => $value) { $urls['<*' . $key . '*>'] = $value; } //Take off every url from definition if ($urls) { $definition = str_replace($urls, array_keys($urls), $definition); } //Extract all WEB ADDRESSES (www.domain.com) from definition preg_match_all('/([[:space:]]|^|\\(|\\[)www\\.([^[:space:]]*)([[:alnum:]#?\\/&=])/is', $definition, $list_of_addresses); //Save them into addrs array to use them later foreach (array_unique($list_of_addresses[0]) as $key => $value) { $addrs['<+' . $key . '+>'] = $value; } //Take off every addr from definition if ($addrs) { $definition = str_replace($addrs, array_keys($addrs), $definition); } //Put doNolinks (concept + aliases) enclosed by <nolink> tag $definition = preg_replace($doNolinks, '<span class="nolink">$1</span>', $definition); //Restore addrs if ($addrs) { $definition = str_replace(array_keys($addrs), $addrs, $definition); } //Restore urls if ($urls) { $definition = str_replace(array_keys($urls), $urls, $definition); } //Restore tags if ($tags) { $definition = str_replace(array_keys($tags), $tags, $definition); } //Restore links if ($links) { $definition = str_replace(array_keys($links), $links, $definition); } $options = new object(); $options->para = false; $options->trusttext = true; // reconstruct the TRUSTTEXT properly after processing if ($ttpresent) { $definition = trusttext_mark($definition); } else { $definition = trusttext_strip($definition); //make 100% sure TRUSTTEXT marker was not created } $text = format_text($definition, $entry->format, $options); if (!empty($entry->highlight)) { $text = highlight($entry->highlight, $text); } if (isset($entry->footer)) { // Unparsed footer info $text .= $entry->footer; } echo $text; }