Show
Ignore:
Timestamp:
05/23/08 04:34:59 (8 months ago)
Author:
azza-bazoo
Message:

[libraries] update - HTMLPurifier 2.1.4

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libs/HTMLPurifier.php

    r2 r243  
    2323 
    2424/* 
    25     HTML Purifier 2.0.1 - Standards Compliant HTML Filtering 
    26     Copyright (C) 2006 Edward Z. Yang 
     25    HTML Purifier 2.1.4 - Standards Compliant HTML Filtering 
     26    Copyright (C) 2006-2007 Edward Z. Yang 
    2727 
    2828    This library is free software; you can redistribute it and/or 
     
    4141 */ 
    4242 
    43 // almost every class has an undocumented dependency to these, so make sure 
    44 // they get included 
    45 require_once 'HTMLPurifier/ConfigSchema.php'; // important 
     43// constants are slow, but we'll make one exception 
     44define('HTMLPURIFIER_PREFIX', dirname(__FILE__)); 
     45 
     46// every class has an undocumented dependency to these, must be included! 
     47require_once 'HTMLPurifier/ConfigSchema.php'; // fatal errors if not included 
    4648require_once 'HTMLPurifier/Config.php'; 
    4749require_once 'HTMLPurifier/Context.php'; 
     
    5860    'Core', 'CollectErrors', false, 'bool', ' 
    5961Whether or not to collect errors found while filtering the document. This 
    60 is a useful way to give feedback to your users. CURRENTLY NOT IMPLEMENTED. 
    61 This directive has been available since 2.0.0. 
     62is a useful way to give feedback to your users. <strong>Warning:</strong> 
     63Currently this feature is very patchy and experimental, with lots of 
     64possible error messages not yet implemented. It will not cause any problems, 
     65but it may not help your users either. This directive has been available 
     66since 2.0.0. 
    6267'); 
    6368 
    6469/** 
    65  * Main library execution class. 
    66  *  
    67  * Facade that performs calls to the HTMLPurifier_Lexer, 
    68  * HTMLPurifier_Strategy and HTMLPurifier_Generator subsystems in order to 
    69  * purify HTML. 
     70 * Facade that coordinates HTML Purifier's subsystems in order to purify HTML. 
     71 *  
     72 * @note There are several points in which configuration can be specified  
     73 *       for HTML Purifier.  The precedence of these (from lowest to 
     74 *       highest) is as follows: 
     75 *          -# Instance: new HTMLPurifier($config) 
     76 *          -# Invocation: purify($html, $config) 
     77 *       These configurations are entirely independent of each other and 
     78 *       are *not* merged. 
    7079 *  
    7180 * @todo We need an easier way to inject strategies, it'll probably end 
     
    7584{ 
    7685     
    77     var $version = '2.0.1'; 
     86    var $version = '2.1.4'; 
    7887     
    7988    var $config; 
    80     var $filters
     89    var $filters = array()
    8190     
    8291    var $strategy, $generator; 
    8392     
    8493    /** 
    85      * Final HTMLPurifier_Context of last run purification. Might be an array. 
     94     * Resultant HTMLPurifier_Context of last run purification. Is an array 
     95     * of contexts if the last called method was purifyArray(). 
    8696     * @public 
    8797     */ 
     
    147157            $context->register('ErrorCollector', $error_collector); 
    148158        } 
     159         
     160        // setup id_accumulator context, necessary due to the fact that 
     161        // AttrValidator can be called from many places 
     162        $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); 
     163        $context->register('IDAccumulator', $id_accumulator); 
    149164         
    150165        $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context); 
     
    196211    /** 
    197212     * Singleton for enforcing just one HTML Purifier in your system 
    198      */ 
    199     function &getInstance($prototype = null) { 
     213     * @param $prototype Optional prototype HTMLPurifier instance to 
     214     *                   overload singleton with. 
     215     */ 
     216    function &instance($prototype = null) { 
    200217        static $htmlpurifier; 
    201218        if (!$htmlpurifier || $prototype) { 
     
    203220                $htmlpurifier = $prototype; 
    204221            } elseif ($prototype) { 
    205                 $htmlpurifier = new HTMLPurifier(HTMLPurifier_Config::create($prototype)); 
     222                $htmlpurifier = new HTMLPurifier($prototype); 
    206223            } else { 
    207224                $htmlpurifier = new HTMLPurifier(); 
     
    211228    } 
    212229     
     230    function &getInstance($prototype = null) { 
     231        return HTMLPurifier::instance($prototype); 
     232    } 
    213233     
    214234}