MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / filter / censor / filter.php
blob6b8c8d1689d7b55fcc56c347f849d72c3766b8d6
1 <?php // $id$
2 //////////////////////////////////////////////////////////////
3 // Censorship filtering
4 //
5 // This very simple example of a Text Filter will parse
6 // printed text, blacking out words perceived to be bad
7 //
8 // The list of words is in the lang/xx/moodle.php
9 //
10 //////////////////////////////////////////////////////////////
12 /// This is the filtering function itself. It accepts the
13 /// courseid and the text to be filtered (in HTML form).
15 function censor_filter($courseid, $text) {
17 static $words;
18 global $CFG;
20 if (!isset($CFG->filter_censor_badwords)) {
21 set_config( 'filter_censor_badwords','' );
24 if (empty($words)) {
25 $words = array();
26 // if no user-specified words, use default list from language pack
27 if (empty($CFG->filter_censor_badwords)) {
28 $badwords = explode(',',get_string('badwords','censor') );
30 else {
31 $badwords = explode(',', $CFG->filter_censor_badwords );
33 foreach ($badwords as $badword) {
34 $badword = trim($badword);
35 $words[] = new filterobject($badword, '<span class="censoredtext" title="'.$badword.'">', '</span>',
36 false, false, str_pad('',strlen($badword),'*'));
40 return filter_phrases($text, $words); // Look for all these words in the text