HTMLPurifier/AttrDef/CSS/ImportantDecorator.php Quellcode

ImportantDecorator.php
gehe zur Dokumentation dieser Datei
1 <?php
2 
7 {
11  public $def;
15  public $allow;
16 
21  public function __construct($def, $allow = false)
22  {
23  $this->def = $def;
24  $this->allow = $allow;
25  }
26 
34  public function validate($string, $config, $context)
35  {
36  // test for ! and important tokens
37  $string = trim($string);
38  $is_important = false;
39  // :TODO: optimization: test directly for !important and ! important
40  if (strlen($string) >= 9 && substr($string, -9) === 'important') {
41  $temp = rtrim(substr($string, 0, -9));
42  // use a temp, because we might want to restore important
43  if (strlen($temp) >= 1 && substr($temp, -1) === '!') {
44  $string = rtrim(substr($temp, 0, -1));
45  $is_important = true;
46  }
47  }
48  $string = $this->def->validate($string, $config, $context);
49  if ($this->allow && $is_important) {
50  $string .= ' !important';
51  }
52  return $string;
53  }
54 }
55 
56 // vim: et sw=4 sts=4




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.