ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
EnumToCSS.php
Go to the documentation of this file.
1 <?php
2 
8 
12  protected $attr;
13 
17  protected $enumToCSS = array();
18 
24  protected $caseSensitive = false;
25 
31  public function __construct($attr, $enum_to_css, $case_sensitive = false) {
32  $this->attr = $attr;
33  $this->enumToCSS = $enum_to_css;
34  $this->caseSensitive = (bool) $case_sensitive;
35  }
36 
37  public function transform($attr, $config, $context) {
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  }
55 
56 }
57 
58 // vim: et sw=4 sts=4