root/afridex/plugins/Flutter/purifier_lib/HTMLPurifier/AttrTransform/BoolToCSS.php @ 23

Revision 21, 0.9 kB (checked in by admin, 18 years ago)
Line 
1<?php
2
3/**
4 * Pre-transform that changes converts a boolean attribute to fixed CSS
5 */
6class 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
Note: See TracBrowser for help on using the browser.