ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
HTMLPurifier_AttrDef_CSS_ListStyle Class Reference

Validates shorthand CSS property list-style. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_CSS_ListStyle:
+ Collaboration diagram for HTMLPurifier_AttrDef_CSS_ListStyle:

Public Member Functions

 __construct ($config)
 
 validate ($string, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef
 validate ($string, $config, $context)
 Validates and cleans passed string according to a definition. More...
 
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA. More...
 
 make ($string)
 Factory method for creating this class from a string. More...
 

Protected Attributes

 $info
 Local copy of component validators. More...
 

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_AttrDef
 $minimized = false
 Tells us whether or not an HTML attribute is minimized. More...
 
 $required = false
 Tells us whether or not an HTML attribute is required. More...
 
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 mungeRgb ($string)
 Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly. More...
 
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it. More...
 

Detailed Description

Validates shorthand CSS property list-style.

Warning
Does not support url tokens that have internal spaces.

Definition at line 7 of file ListStyle.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrDef_CSS_ListStyle::__construct (   $config)

Definition at line 16 of file ListStyle.php.

16  {
17  $def = $config->getCSSDefinition();
18  $this->info['list-style-type'] = $def->info['list-style-type'];
19  $this->info['list-style-position'] = $def->info['list-style-position'];
20  $this->info['list-style-image'] = $def->info['list-style-image'];
21  }

Member Function Documentation

◆ validate()

HTMLPurifier_AttrDef_CSS_ListStyle::validate (   $string,
  $config,
  $context 
)

Definition at line 23 of file ListStyle.php.

References $r, $ret, and HTMLPurifier_AttrDef\parseCDATA().

23  {
24 
25  // regular pre-processing
26  $string = $this->parseCDATA($string);
27  if ($string === '') return false;
28 
29  // assumes URI doesn't have spaces in it
30  $bits = explode(' ', strtolower($string)); // bits to process
31 
32  $caught = array();
33  $caught['type'] = false;
34  $caught['position'] = false;
35  $caught['image'] = false;
36 
37  $i = 0; // number of catches
38  $none = false;
39 
40  foreach ($bits as $bit) {
41  if ($i >= 3) return; // optimization bit
42  if ($bit === '') continue;
43  foreach ($caught as $key => $status) {
44  if ($status !== false) continue;
45  $r = $this->info['list-style-' . $key]->validate($bit, $config, $context);
46  if ($r === false) continue;
47  if ($r === 'none') {
48  if ($none) continue;
49  else $none = true;
50  if ($key == 'image') continue;
51  }
52  $caught[$key] = $r;
53  $i++;
54  break;
55  }
56  }
57 
58  if (!$i) return false;
59 
60  $ret = array();
61 
62  // construct type
63  if ($caught['type']) $ret[] = $caught['type'];
64 
65  // construct image
66  if ($caught['image']) $ret[] = $caught['image'];
67 
68  // construct position
69  if ($caught['position']) $ret[] = $caught['position'];
70 
71  if (empty($ret)) return false;
72  return implode(' ', $ret);
73 
74  }
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:58
$r
+ Here is the call graph for this function:

Field Documentation

◆ $info

HTMLPurifier_AttrDef_CSS_ListStyle::$info
protected

Local copy of component validators.

Note
See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl.

Definition at line 14 of file ListStyle.php.


The documentation for this class was generated from the following file: