ILIAS  release_4-4 Revision
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 17 of file AttrTypes.php.

17  {
18  // XXX This is kind of poor, since we don't actually /clone/
19  // instances; instead, we use the supplied make() attribute. So,
20  // the underlying class must know how to deal with arguments.
21  // With the old implementation of Enum, that ignored its
22  // arguments when handling a make dispatch, the IAlign
23  // definition wouldn't work.
24 
25  // pseudo-types, must be instantiated via shorthand
26  $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum();
27  $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool();
28 
29  $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
30  $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID();
31  $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length();
32  $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();
33  $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();
34  $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels();
35  $this->info['Text'] = new HTMLPurifier_AttrDef_Text();
36  $this->info['URI'] = new HTMLPurifier_AttrDef_URI();
37  $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();
38  $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color();
39  $this->info['IAlign'] = self::makeEnum('top,middle,bottom,left,right');
40  $this->info['LAlign'] = self::makeEnum('top,bottom,left,right');
41  $this->info['FrameTarget'] = new HTMLPurifier_AttrDef_HTML_FrameTarget();
42 
43  // unimplemented aliases
44  $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();
45  $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text();
46  $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text();
47  $this->info['Character'] = new HTMLPurifier_AttrDef_Text();
48 
49  // "proprietary" types
50  $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class();
51 
52  // number is really a positive integer (one or more digits)
53  // FIXME: ^^ not always, see start and value of list items
54  $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true);
55  }
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
$typeString type name
Returns
Object AttrDef for type

Definition at line 66 of file AttrTypes.php.

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

◆ makeEnum()

static HTMLPurifier_AttrTypes::makeEnum (   $in)
staticprivate

Definition at line 57 of file AttrTypes.php.

References $in.

57  {
58  return new HTMLPurifier_AttrDef_Clone(new HTMLPurifier_AttrDef_Enum(explode(',', $in)));
59  }
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
$typeString type name
$implObject AttrDef for type

Definition at line 86 of file AttrTypes.php.

86  {
87  $this->info[$type] = $impl;
88  }

Field Documentation

◆ $info

HTMLPurifier_AttrTypes::$info = array()
protected

Lookup array of attribute string identifiers to concrete implementations.

Definition at line 11 of file AttrTypes.php.


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