contributions/text.htmlpurifier/start.inc.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * @defgroup HtmlPurifier 00004 * @ingroup Text 00005 * 00006 * Cleans HTML and removes malicious code. 00007 * 00008 * @section Installation Installation 00009 * 00010 * On install, this module created directories 00011 * 00012 * - htmlpurifier/CSS 00013 * - htmlpurifier/HTML 00014 * - htmlpurifier/URI 00015 * 00016 * in the application's temp directory with permissions set to 777. These directories must 00017 * be writable by the web server. 00018 * 00019 * @section Usage Usage 00020 * 00021 * @code 00022 * $clean = ConverterFactory::encode($dirty, CONVERTER_HTMLPURIFIER); 00023 * @endcode 00024 * 00025 * You may pass HtmlPurifier specific parameters like this: 00026 * 00027 * @code 00028 * $clean = ConverterFactory::encode($dirty, CONVERTER_HTMLPURIFIER, array('HTML.TidyLevel' => 'heavy')); 00029 * @endcode 00030 * 00031 * For a list of possible values see http://htmlpurifier.org/live/configdoc/plain.html 00032 * 00033 * There is already a preconfigured converter solving the common problem to convert HTML without paragraphs 00034 * like created by most CMS into valid HTML. This not only uses the AutoFormat.AutoParagraph configuration 00035 * directive but tries to normalize line breaks before. This converter ias available as 00036 * CONVERTER_HTMLPURIFIER_AUTOPARAGRAPH. 00037 * 00038 * @code 00039 * $clean = ConverterFactory::encode($dirty, CONVERTER_HTMLPURIFIER_AUTOPARAGRAPH); 00040 * @endcode 00041 * 00042 * Of course you may also pass additional parameters. 00043 * 00044 * The module comes with a DBField that purifies its content before storing it in the database. This is deprecated 00045 * in favour of the more flexible DBFieldTextHtml that comes with the text.html package. 00046 * 00047 * The module sets the edit fallback conversion of HtmlRules to purifing without tidying, and 00048 * storage and output conversion to default Purifier. 00049 * 00050 * @section Notes Additional notes 00051 * 00052 * HTML Purifier is released under GNU Lesser General Public License. 00053 * 00054 * The version contained within this module is 4.2 00055 * 00056 * @see http://htmlpurifier.org/ 00057 * 00058 */ 00059 define ('CONVERTER_HTMLPURIFIER', 'htmlpurifier'); 00060 define ('CONVERTER_HTMLPURIFIER_AUTOPARAGRAPH', 'htmlpurifier_autoparagraph'); 00061 00062 require_once dirname(__FILE__) . '/lib/helpers/converters/htmlpurifier.converter.php'; 00063 require_once dirname(__FILE__) . '/lib/helpers/converters/htmlpurifier.autoparagraph.converter.php'; 00064 ConverterFactory::register_converter(CONVERTER_HTMLPURIFIER, new ConverterHtmlPurifier()); 00065 ConverterFactory::register_converter(CONVERTER_HTMLPURIFIER_AUTOPARAGRAPH, new ConverterHtmlPurifierAutoParagraph()); 00066 00067 HtmlText::set_conversion(HtmlText::EDIT, array(CONVERTER_HTMLPURIFIER => array('HTML.TidyLevel' => 'none'))); 00068 HtmlText::set_conversion(HtmlText::OUTPUT, CONVERTER_HTMLPURIFIER); 00069 HtmlText::set_conversion(HtmlText::STORAGE, CONVERTER_HTMLPURIFIER);