MDL-10870 Missed an instance of old nav in admin/lang.php
[moodle-pu.git] / filter / tidy / filter.php
blobc12778f8d43905e519b858f0ec5f6e4cc6ad34f7
1 <?php
3 // This function looks for text including markup and
4 // applies tidy's repair function to it.
5 // Tidy is a HTML clean and
6 // repair utility, which is currently available for PHP 4.3.x and PHP 5 as a
7 // PECL extension from http://pecl.php.net/package/tidy, in PHP 5 you need only
8 // to compile using the --with-tidy option.
9 // If you don't have the tidy extension installed or don't know, you can enable
10 // or disable this filter, it just won't have any effect.
11 // If you want to know what you can set in $tidyoptions and what their default
12 // values are, see http://php.net/manual/en/function.tidy-get-config.php.
14 /**
15 * @author Hannes Gassert <hannes at mediagonal dot ch>
16 * @param int course id
17 * @param string text to be filtered
19 function tidy_filter($courseid, $text) {
21 /// Configuration for tidy. Feel free to tune for your needs, e.g. to allow
22 /// proprietary markup.
23 $tidyoptions = array(
24 'output-xhtml' => true,
25 'show-body-only' => true,
26 'tidy-mark' => false,
27 'drop-proprietary-attributes' => true,
28 'drop-font-tags' => true,
29 'drop-empty-paras' => true,
30 'indent' => true,
31 'quiet' => true,
34 /// Do a quick check using strpos to avoid unnecessary work
35 if (strpos($text, '<') === false) {
36 return $text;
40 /// If enabled: run tidy over the entire string
41 if (function_exists('tidy_repair_string')){
42 $text = tidy_repair_string($text, $tidyoptions, 'utf8');
45 return $text;