]> git.mxchange.org Git - friendica.git/blob - library/HTMLPurifier/AttrTransform/BoolToCSS.php
Merge pull request #2258 from rabuzarus/1701_forumlist_profile
[friendica.git] / library / HTMLPurifier / AttrTransform / BoolToCSS.php
1 <?php
2
3 /**
4  * Pre-transform that changes converts a boolean attribute to fixed CSS
5  */
6 class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform {
7
8     /**
9      * Name of boolean attribute that is trigger
10      */
11     protected $attr;
12
13     /**
14      * CSS declarations to add to style, needs trailing semicolon
15      */
16     protected $css;
17
18     /**
19      * @param $attr string attribute name to convert from
20      * @param $css string CSS declarations to add to style (needs semicolon)
21      */
22     public function __construct($attr, $css) {
23         $this->attr = $attr;
24         $this->css  = $css;
25     }
26
27     public function transform($attr, $config, $context) {
28         if (!isset($attr[$this->attr])) return $attr;
29         unset($attr[$this->attr]);
30         $this->prependCSS($attr, $this->css);
31         return $attr;
32     }
33
34 }
35
36 // vim: et sw=4 sts=4