4 * Validates shorthand CSS property list-style.
5 * @warning Does not support url tokens that have internal spaces.
7 class HTMLPurifier_AttrDef_CSS_ListStyle
extends HTMLPurifier_AttrDef
11 * Local copy of validators.
12 * @type HTMLPurifier_AttrDef[]
13 * @note See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl.
18 * @param HTMLPurifier_Config $config
20 public function __construct($config)
22 $def = $config->getCSSDefinition();
23 $this->info
['list-style-type'] = $def->info
['list-style-type'];
24 $this->info
['list-style-position'] = $def->info
['list-style-position'];
25 $this->info
['list-style-image'] = $def->info
['list-style-image'];
29 * @param string $string
30 * @param HTMLPurifier_Config $config
31 * @param HTMLPurifier_Context $context
34 public function validate($string, $config, $context)
36 // regular pre-processing
37 $string = $this->parseCDATA($string);
42 // assumes URI doesn't have spaces in it
43 $bits = explode(' ', strtolower($string)); // bits to process
46 $caught['type'] = false;
47 $caught['position'] = false;
48 $caught['image'] = false;
50 $i = 0; // number of catches
53 foreach ($bits as $bit) {
60 foreach ($caught as $key => $status) {
61 if ($status !== false) {
64 $r = $this->info
['list-style-' . $key]->validate($bit, $config, $context);
74 if ($key == 'image') {
91 if ($caught['type']) {
92 $ret[] = $caught['type'];
96 if ($caught['image']) {
97 $ret[] = $caught['image'];
100 // construct position
101 if ($caught['position']) {
102 $ret[] = $caught['position'];
108 return implode(' ', $ret);
112 // vim: et sw=4 sts=4