ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
HTMLPurifier_AttrTransform_EnumToCSS Class Reference

Generic pre-transform that converts an attribute with a fixed number of values (enumerated) to CSS. More...

+ Inheritance diagram for HTMLPurifier_AttrTransform_EnumToCSS:
+ Collaboration diagram for HTMLPurifier_AttrTransform_EnumToCSS:

Public Member Functions

 __construct ($attr, $enum_to_css, $case_sensitive=false)
 
 transform ($attr, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrTransform
 transform ($attr, $config, $context)
 Abstract: makes changes to the attributes dependent on multiple values. More...
 
 prependCSS (&$attr, $css)
 Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist. More...
 
 confiscateAttr (&$attr, $key)
 Retrieves and removes an attribute. More...
 

Protected Attributes

 $attr
 Name of attribute to transform from. More...
 
 $enumToCSS = array()
 Lookup array of attribute values to CSS. More...
 
 $caseSensitive = false
 Case sensitivity of the matching. More...
 

Detailed Description

Generic pre-transform that converts an attribute with a fixed number of values (enumerated) to CSS.

Definition at line 7 of file EnumToCSS.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrTransform_EnumToCSS::__construct (   $attr,
  $enum_to_css,
  $case_sensitive = false 
)
Parameters
string$attrAttribute name to transform from
array$enum_to_cssLookup array of attribute values to CSS
bool$case_sensitiveCase sensitivity indicator, default false

Definition at line 34 of file EnumToCSS.php.

References $attr.

35  {
36  $this->attr = $attr;
37  $this->enumToCSS = $enum_to_css;
38  $this->caseSensitive = (bool)$case_sensitive;
39  }
$attr
Name of attribute to transform from.
Definition: EnumToCSS.php:13

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_EnumToCSS::transform (   $attr,
  $config,
  $context 
)
Parameters
array$attr
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Definition at line 47 of file EnumToCSS.php.

References $attr, and HTMLPurifier_AttrTransform\prependCSS().

48  {
49  if (!isset($attr[$this->attr])) {
50  return $attr;
51  }
52 
53  $value = trim($attr[$this->attr]);
54  unset($attr[$this->attr]);
55 
56  if (!$this->caseSensitive) {
57  $value = strtolower($value);
58  }
59 
60  if (!isset($this->enumToCSS[$value])) {
61  return $attr;
62  }
63  $this->prependCSS($attr, $this->enumToCSS[$value]);
64  return $attr;
65  }
$attr
Name of attribute to transform from.
Definition: EnumToCSS.php:13
prependCSS(&$attr, $css)
Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist...
+ Here is the call graph for this function:

Field Documentation

◆ $attr

HTMLPurifier_AttrTransform_EnumToCSS::$attr
protected

Name of attribute to transform from.

string

Definition at line 13 of file EnumToCSS.php.

Referenced by __construct(), and transform().

◆ $caseSensitive

HTMLPurifier_AttrTransform_EnumToCSS::$caseSensitive = false
protected

Case sensitivity of the matching.

bool

Warning
Currently can only be guaranteed to work with ASCII values.

Definition at line 27 of file EnumToCSS.php.

◆ $enumToCSS

HTMLPurifier_AttrTransform_EnumToCSS::$enumToCSS = array()
protected

Lookup array of attribute values to CSS.

array

Definition at line 19 of file EnumToCSS.php.


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