ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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
$attrString attribute name to transform from
$enumToCSSLookup array of attribute values to CSS
$case_sensitiveBoolean case sensitivity indicator, default false

Definition at line 31 of file EnumToCSS.php.

References $attr.

31  {
32  $this->attr = $attr;
33  $this->enumToCSS = $enum_to_css;
34  $this->caseSensitive = (bool) $case_sensitive;
35  }
$attr
Name of attribute to transform from.
Definition: EnumToCSS.php:12

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_EnumToCSS::transform (   $attr,
  $config,
  $context 
)

Definition at line 37 of file EnumToCSS.php.

References $attr, and HTMLPurifier_AttrTransform\prependCSS().

37  {
38 
39  if (!isset($attr[$this->attr])) return $attr;
40 
41  $value = trim($attr[$this->attr]);
42  unset($attr[$this->attr]);
43 
44  if (!$this->caseSensitive) $value = strtolower($value);
45 
46  if (!isset($this->enumToCSS[$value])) {
47  return $attr;
48  }
49 
50  $this->prependCSS($attr, $this->enumToCSS[$value]);
51 
52  return $attr;
53 
54  }
$attr
Name of attribute to transform from.
Definition: EnumToCSS.php:12
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.

Definition at line 12 of file EnumToCSS.php.

Referenced by __construct(), and transform().

◆ $caseSensitive

HTMLPurifier_AttrTransform_EnumToCSS::$caseSensitive = false
protected

Case sensitivity of the matching.

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

Definition at line 24 of file EnumToCSS.php.

◆ $enumToCSS

HTMLPurifier_AttrTransform_EnumToCSS::$enumToCSS = array()
protected

Lookup array of attribute values to CSS.

Definition at line 17 of file EnumToCSS.php.


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