Validates shorthand CSS property background.
More...
|
| __construct ($config) |
|
| validate ($string, $config, $context) |
|
| 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...
|
|
|
| $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...
|
|
| 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...
|
|
Validates shorthand CSS property background.
- Warning
- Does not support url tokens that have internal spaces.
Definition at line 7 of file Background.php.
◆ __construct()
HTMLPurifier_AttrDef_CSS_Background::__construct |
( |
|
$config | ) |
|
Definition at line 16 of file Background.php.
17 $def = $config->getCSSDefinition();
18 $this->info[
'background-color'] = $def->info[
'background-color'];
19 $this->info[
'background-image'] = $def->info[
'background-image'];
20 $this->info[
'background-repeat'] = $def->info[
'background-repeat'];
21 $this->info[
'background-attachment'] = $def->info[
'background-attachment'];
22 $this->info[
'background-position'] = $def->info[
'background-position'];
◆ validate()
HTMLPurifier_AttrDef_CSS_Background::validate |
( |
|
$string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
Definition at line 25 of file Background.php.
References $r, $ret, HTMLPurifier_AttrDef\mungeRgb(), and HTMLPurifier_AttrDef\parseCDATA().
29 if ($string ===
'')
return false;
35 $bits = explode(
' ', $string);
38 $caught[
'color'] =
false;
39 $caught[
'image'] =
false;
40 $caught[
'repeat'] =
false;
41 $caught[
'attachment'] =
false;
42 $caught[
'position'] =
false;
47 foreach ($bits as $bit) {
48 if ($bit ===
'')
continue;
49 foreach ($caught as $key => $status) {
50 if ($key !=
'position') {
51 if ($status !==
false)
continue;
52 $r = $this->info[
'background-' . $key]->validate($bit, $config, $context);
56 if (
$r ===
false)
continue;
57 if ($key ==
'position') {
58 if ($caught[$key] ===
false) $caught[$key] =
'';
59 $caught[$key] .=
$r .
' ';
68 if (!$i)
return false;
69 if ($caught[
'position'] !==
false) {
70 $caught[
'position'] = $this->info[
'background-position']->
71 validate($caught[
'position'], $config, $context);
75 foreach ($caught as $value) {
76 if ($value ===
false)
continue;
80 if (empty(
$ret))
return false;
81 return implode(
' ',
$ret);
validate($string, $config, $context)
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
mungeRgb($string)
Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
◆ $info
HTMLPurifier_AttrDef_CSS_Background::$info |
|
protected |
Local copy of component validators.
- Note
- See HTMLPurifier_AttrDef_Font::$info for a similar impl.
Definition at line 14 of file Background.php.
The documentation for this class was generated from the following file:
- Services/Html/HtmlPurifier/library/HTMLPurifier/AttrDef/CSS/Background.php