-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.php
28 lines (25 loc) · 975 Bytes
/
filter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
class filter_moodlefilterexample extends moodle_text_filter
{
public function filter($text, array $options = array())
{
global $CFG;
if (!isset($CFG->filter_moodlefilterexample_phrase))
{
set_config('filter_moodlefilterexample_phrase', get_string('phrase_default',
'filter_moodlefilterexample'));
}
if (!isset($CFG->filter_moodlefilterexample_link))
{
set_config('filter_moodlefilterexample_link', get_string('link_default',
'filter_moodlefilterexample'));
}
$searchphrase = $CFG->filter_moodlefilterexample_phrase;
$starttag = '<a href="' . $CFG->filter_moodlefilterexample_link . '" target="_blank">';
$endtag = '</a>';
$filterobjects = array();
$filterobjects[] = new filterobject($searchphrase, $starttag, $endtag);
$text = filter_phrases($text, $filterobjects);
return $text;
}
}