ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
EnumToCSS.php
Go to the documentation of this file.
1 <?php
2 
8 {
13  protected $attr;
14 
19  protected $enumToCSS = array();
20 
27  protected $caseSensitive = false;
28 
34  public function __construct($attr, $enum_to_css, $case_sensitive = false)
35  {
36  $this->attr = $attr;
37  $this->enumToCSS = $enum_to_css;
38  $this->caseSensitive = (bool)$case_sensitive;
39  }
40 
47  public function transform($attr, $config, $context)
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  }
66 }
67 
68 // vim: et sw=4 sts=4
Processes an entire attribute array for corrections needing multiple values.
$attr
Name of attribute to transform from.
Definition: EnumToCSS.php:13
__construct($attr, $enum_to_css, $case_sensitive=false)
Definition: EnumToCSS.php:34
$caseSensitive
Case sensitivity of the matching.
Definition: EnumToCSS.php:27
transform($attr, $config, $context)
Definition: EnumToCSS.php:47
Generic pre-transform that converts an attribute with a fixed number of values (enumerated) to CSS...
Definition: EnumToCSS.php:7
Create styles array
The data for the language used.
prependCSS(&$attr, $css)
Prepends CSS properties to the style attribute, creating the attribute if it doesn&#39;t exist...
$enumToCSS
Lookup array of attribute values to CSS.
Definition: EnumToCSS.php:19