File indexing completed on 2024-12-22 05:36:21
0001 <?php 0002 0003 /** 0004 * Represents a pre or post processing filter on HTML Purifier's output 0005 * 0006 * Sometimes, a little ad-hoc fixing of HTML has to be done before 0007 * it gets sent through HTML Purifier: you can use filters to acheive 0008 * this effect. For instance, YouTube videos can be preserved using 0009 * this manner. You could have used a decorator for this task, but 0010 * PHP's support for them is not terribly robust, so we're going 0011 * to just loop through the filters. 0012 * 0013 * Filters should be exited first in, last out. If there are three filters, 0014 * named 1, 2 and 3, the order of execution should go 1->preFilter, 0015 * 2->preFilter, 3->preFilter, purify, 3->postFilter, 2->postFilter, 0016 * 1->postFilter. 0017 * 0018 * @note Methods are not declared abstract as it is perfectly legitimate 0019 * for an implementation not to want anything to happen on a step 0020 */ 0021 0022 class HTMLPurifier_Filter 0023 { 0024 0025 /** 0026 * Name of the filter for identification purposes. 0027 * @type string 0028 */ 0029 public $name; 0030 0031 /** 0032 * Pre-processor function, handles HTML before HTML Purifier 0033 * @param string $html 0034 * @param HTMLPurifier_Config $config 0035 * @param HTMLPurifier_Context $context 0036 * @return string 0037 */ 0038 public function preFilter($html, $config, $context) 0039 { 0040 return $html; 0041 } 0042 0043 /** 0044 * Post-processor function, handles HTML after HTML Purifier 0045 * @param string $html 0046 * @param HTMLPurifier_Config $config 0047 * @param HTMLPurifier_Context $context 0048 * @return string 0049 */ 0050 public function postFilter($html, $config, $context) 0051 { 0052 return $html; 0053 } 0054 } 0055 0056 // vim: et sw=4 sts=4