instance() public static method

Retrieves sole instance of the object.
public static instance ( boolean | HTMLPurifier_EntityLookup $prototype = false ) : HTMLPurifier_EntityLookup
$prototype boolean | HTMLPurifier_EntityLookup Optional prototype of custom lookup table to overload with.
return HTMLPurifier_EntityLookup
コード例 #1
0
ファイル: EntityParser.php プロジェクト: hasshy/sahana-tw
 /**
  * Callback function for substituteNonSpecialEntities() that does the work.
  * 
  * @warning Though this is public in order to let the callback happen,
  *          calling it directly is not recommended.
  * @param $matches  PCRE matches array, with 0 the entire match, and
  *                  either index 1, 2 or 3 set with a hex value, dec value,
  *                  or string (respectively).
  * @returns Replacement string.
  */
 function nonSpecialEntityCallback($matches)
 {
     // replaces all but big five
     $entity = $matches[0];
     $is_num = @$matches[0][1] === '#';
     if ($is_num) {
         $is_hex = @$entity[2] === 'x';
         $code = $is_hex ? hexdec($matches[1]) : (int) $matches[2];
         // abort for special characters
         if (isset($this->_special_dec2str[$code])) {
             return $entity;
         }
         return HTMLPurifier_Encoder::unichr($code);
     } else {
         if (isset($this->_special_ent2dec[$matches[3]])) {
             return $entity;
         }
         if (!$this->_entity_lookup) {
             $this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
         }
         if (isset($this->_entity_lookup->table[$matches[3]])) {
             return $this->_entity_lookup->table[$matches[3]];
         } else {
             return $entity;
         }
     }
 }
コード例 #2
0
ファイル: EntityLookupTest.php プロジェクト: sebbie42/casebox
 public function test()
 {
     $lookup = HTMLPurifier_EntityLookup::instance();
     // latin char
     $this->assertIdentical('â', $lookup->table['acirc']);
     // special char
     $this->assertIdentical('"', $lookup->table['quot']);
     $this->assertIdentical('“', $lookup->table['ldquo']);
     $this->assertIdentical('<', $lookup->table['lt']);
     // expressed strangely in source file
     // symbol char
     $this->assertIdentical('θ', $lookup->table['theta']);
 }
コード例 #3
0
ファイル: GeneratorTest.php プロジェクト: Jaaviieer/PrograWeb
 public function __construct()
 {
     parent::__construct();
     $this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
 }
コード例 #4
0
ファイル: EncoderTest.php プロジェクト: ajnok/yii2book
 public function setUp()
 {
     $this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
     parent::setUp();
 }
コード例 #5
0
ファイル: EntityParserTest.php プロジェクト: sebbie42/casebox
 public function setUp()
 {
     $this->EntityParser = new HTMLPurifier_EntityParser();
     $this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
 }