Validates shorthand CSS property font.
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 font.
Definition at line 6 of file Font.php.
◆ __construct()
HTMLPurifier_AttrDef_CSS_Font::__construct |
( |
|
$config | ) |
|
Definition at line 19 of file Font.php.
20 $def = $config->getCSSDefinition();
21 $this->info[
'font-style'] = $def->info[
'font-style'];
22 $this->info[
'font-variant'] = $def->info[
'font-variant'];
23 $this->info[
'font-weight'] = $def->info[
'font-weight'];
24 $this->info[
'font-size'] = $def->info[
'font-size'];
25 $this->info[
'line-height'] = $def->info[
'line-height'];
26 $this->info[
'font-family'] = $def->info[
'font-family'];
◆ validate()
HTMLPurifier_AttrDef_CSS_Font::validate |
( |
|
$string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
Definition at line 29 of file Font.php.
References $r, $size, and HTMLPurifier_AttrDef\parseCDATA().
31 static $system_fonts = array(
35 'message-box' =>
true,
36 'small-caption' =>
true,
42 if ($string ===
'')
return false;
45 $lowercase_string = strtolower($string);
46 if (isset($system_fonts[$lowercase_string])) {
47 return $lowercase_string;
50 $bits = explode(
' ', $string);
53 $stage_1 = array(
'font-style',
'font-variant',
'font-weight');
56 for ($i = 0,
$size = count($bits); $i <
$size; $i++) {
57 if ($bits[$i] ===
'')
continue;
62 foreach ($stage_1 as $validator_name) {
63 if (isset($caught[$validator_name]))
continue;
64 $r = $this->info[$validator_name]->validate(
65 $bits[$i], $config, $context);
68 $caught[$validator_name] =
true;
73 if (count($caught) >= 3) $stage = 1;
74 if (
$r !==
false)
break;
79 if (strpos($bits[$i],
'/') !==
false) {
80 list($font_size, $line_height) =
81 explode(
'/', $bits[$i]);
82 if ($line_height ===
'') {
88 $font_size = $bits[$i];
91 $r = $this->info[
'font-size']->validate(
92 $font_size, $config, $context);
96 if ($line_height ===
false) {
98 for ($j = $i + 1; $j <
$size; $j++) {
99 if ($bits[$j] ===
'')
continue;
100 if ($bits[$j] ===
'/') {
108 $line_height = $bits[$j];
118 $r = $this->info[
'line-height']->validate(
119 $line_height, $config, $context);
133 implode(
' ', array_slice($bits, $i, $size - $i));
134 $r = $this->info[
'font-family']->validate(
135 $font_family, $config, $context);
139 return rtrim($final);
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
◆ $info
HTMLPurifier_AttrDef_CSS_Font::$info = array() |
|
protected |
Local copy of component validators.
- Note
- If we moved specific CSS property definitions to their own classes instead of having them be assembled at run time by CSSDefinition, this wouldn't be necessary. We'd instantiate our own copies.
Definition at line 17 of file Font.php.
The documentation for this class was generated from the following file:
- Services/Html/HtmlPurifier/library/HTMLPurifier/AttrDef/CSS/Font.php