ILIAS  Release_5_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 {
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