|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 // This class looks for text including markup and 00030 // applies tidy's repair function to it. 00031 // Tidy is a HTML clean and 00032 // repair utility, which is currently available for PHP 4.3.x and PHP 5 as a 00033 // PECL extension from http://pecl.php.net/package/tidy, in PHP 5 you need only 00034 // to compile using the --with-tidy option. 00035 // If you don't have the tidy extension installed or don't know, you can enable 00036 // or disable this filter, it just won't have any effect. 00037 // If you want to know what you can set in $tidyoptions and what their default 00038 // values are, see http://php.net/manual/en/function.tidy-get-config.php. 00039 00040 class filter_tidy extends moodle_text_filter { 00041 function filter($text, array $options = array()) { 00042 00045 $tidyoptions = array( 00046 'output-xhtml' => true, 00047 'show-body-only' => true, 00048 'tidy-mark' => false, 00049 'drop-proprietary-attributes' => true, 00050 'drop-font-tags' => true, 00051 'drop-empty-paras' => true, 00052 'indent' => true, 00053 'quiet' => true, 00054 ); 00055 00057 if (strpos($text, '<') === false) { 00058 return $text; 00059 } 00060 00061 00063 if (function_exists('tidy_repair_string')){ 00064 $text = tidy_repair_string($text, $tidyoptions, 'utf8'); 00065 } 00066 00067 return $text; 00068 } 00069 } 00070