ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
HTMLPurifier_AttrTypes Class Reference

Provides lookup array of attribute types to HTMLPurifier_AttrDef objects. More...

+ Collaboration diagram for HTMLPurifier_AttrTypes:

Public Member Functions

 __construct ()
 Constructs the info array, supplying default implementations for attribute types. More...
 
 get ($type)
 Retrieves a type. More...
 
 set ($type, $impl)
 Sets a new implementation for a type. More...
 

Protected Attributes

 $info = array()
 Lookup array of attribute string identifiers to concrete implementations. More...
 

Static Private Member Functions

static makeEnum ($in)
 

Detailed Description

Provides lookup array of attribute types to HTMLPurifier_AttrDef objects.

Definition at line 6 of file AttrTypes.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrTypes::__construct ( )

Constructs the info array, supplying default implementations for attribute types.

Definition at line 18 of file AttrTypes.php.

19  {
20  // XXX This is kind of poor, since we don't actually /clone/
21  // instances; instead, we use the supplied make() attribute. So,
22  // the underlying class must know how to deal with arguments.
23  // With the old implementation of Enum, that ignored its
24  // arguments when handling a make dispatch, the IAlign
25  // definition wouldn't work.
26 
27  // pseudo-types, must be instantiated via shorthand
28  $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum();
29  $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool();
30 
31  $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
32  $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID();
33  $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length();
34  $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();
35  $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();
36  $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels();
37  $this->info['Text'] = new HTMLPurifier_AttrDef_Text();
38  $this->info['URI'] = new HTMLPurifier_AttrDef_URI();
39  $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();
40  $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color();
41  $this->info['IAlign'] = self::makeEnum('top,middle,bottom,left,right');
42  $this->info['LAlign'] = self::makeEnum('top,bottom,left,right');
43  $this->info['FrameTarget'] = new HTMLPurifier_AttrDef_HTML_FrameTarget();
44 
45  // unimplemented aliases
46  $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();
47  $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text();
48  $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text();
49  $this->info['Character'] = new HTMLPurifier_AttrDef_Text();
50 
51  // "proprietary" types
52  $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class();
53 
54  // number is really a positive integer (one or more digits)
55  // FIXME: ^^ not always, see start and value of list items
56  $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true);
57  }
Validates the HTML attribute lang, effectively a language code.
Definition: Lang.php:7
Validates an integer representation of pixels according to the HTML spec.
Definition: Pixels.php:6
Validates contents based on NMTOKENS attribute type.
Definition: Nmtokens.php:6
Implements special behavior for class attribute (normally NMTOKENS)
Definition: Class.php:6
Validates a color according to the HTML spec.
Definition: Color.php:6
Validates a boolean attribute.
Definition: Bool.php:6
Special-case enum attribute definition that lazy loads allowed frame targets.
Definition: FrameTarget.php:6
Validates a MultiLength as defined by the HTML spec.
Definition: MultiLength.php:9
Validates the HTML attribute ID.
Definition: ID.php:12
Validates arbitrary text according to the HTML spec.
Definition: Text.php:6
Validates the HTML type length (not to be confused with CSS's length).
Definition: Length.php:10
Validates a keyword against a list of valid values.
Definition: Enum.php:10
Validates a URI as defined by RFC 3986.
Definition: URI.php:7
Validates an integer.
Definition: Integer.php:10

Member Function Documentation

◆ get()

HTMLPurifier_AttrTypes::get (   $type)

Retrieves a type.

Parameters
string$typeString type name
Returns
HTMLPurifier_AttrDef Object AttrDef for type

Definition at line 69 of file AttrTypes.php.

70  {
71  // determine if there is any extra info tacked on
72  if (strpos($type, '#') !== false) {
73  list($type, $string) = explode('#', $type, 2);
74  } else {
75  $string = '';
76  }
77 
78  if (!isset($this->info[$type])) {
79  trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
80  return;
81  }
82  return $this->info[$type]->make($string);
83  }

◆ makeEnum()

static HTMLPurifier_AttrTypes::makeEnum (   $in)
staticprivate

Definition at line 59 of file AttrTypes.php.

References $in.

60  {
61  return new HTMLPurifier_AttrDef_Clone(new HTMLPurifier_AttrDef_Enum(explode(',', $in)));
62  }
Validates a keyword against a list of valid values.
Definition: Enum.php:10
Dummy AttrDef that mimics another AttrDef, BUT it generates clones with make.
Definition: Clone.php:7

◆ set()

HTMLPurifier_AttrTypes::set (   $type,
  $impl 
)

Sets a new implementation for a type.

Parameters
string$typeString type name
HTMLPurifier_AttrDef$implObject AttrDef for type

Definition at line 90 of file AttrTypes.php.

91  {
92  $this->info[$type] = $impl;
93  }

Field Documentation

◆ $info

HTMLPurifier_AttrTypes::$info = array()
protected

Lookup array of attribute string identifiers to concrete implementations.

HTMLPurifier_AttrDef[]

Definition at line 12 of file AttrTypes.php.


The documentation for this class was generated from the following file: