Validates shorthand CSS property font.
More...
Validates shorthand CSS property font.
Definition at line 6 of file Font.php.
◆ __construct()
HTMLPurifier_AttrDef_CSS_Font::__construct |
( |
|
$config | ) |
|
- Parameters
-
Definition at line 22 of file Font.php.
References $config.
24 $def =
$config->getCSSDefinition();
25 $this->info[
'font-style'] = $def->info[
'font-style'];
26 $this->info[
'font-variant'] = $def->info[
'font-variant'];
27 $this->info[
'font-weight'] = $def->info[
'font-weight'];
28 $this->info[
'font-size'] = $def->info[
'font-size'];
29 $this->info[
'line-height'] = $def->info[
'line-height'];
30 $this->info[
'font-family'] = $def->info[
'font-family'];
◆ validate()
HTMLPurifier_AttrDef_CSS_Font::validate |
( |
|
$string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
- Parameters
-
- Returns
- bool|string
Definition at line 39 of file Font.php.
References $config, $r, $size, array, and HTMLPurifier_AttrDef\parseCDATA().
41 static $system_fonts =
array(
45 'message-box' =>
true,
46 'small-caption' =>
true,
57 $lowercase_string = strtolower($string);
58 if (isset($system_fonts[$lowercase_string])) {
59 return $lowercase_string;
62 $bits = explode(
' ', $string);
65 $stage_1 =
array(
'font-style',
'font-variant',
'font-weight');
68 for ($i = 0,
$size = count($bits); $i <
$size; $i++) {
69 if ($bits[$i] ===
'') {
74 foreach ($stage_1 as $validator_name) {
75 if (isset($caught[$validator_name])) {
78 $r = $this->info[$validator_name]->validate(
85 $caught[$validator_name] =
true;
90 if (count($caught) >= 3) {
98 if (strpos($bits[$i],
'/') !==
false) {
99 list($font_size, $line_height) =
100 explode(
'/', $bits[$i]);
101 if ($line_height ===
'') {
103 $line_height =
false;
107 $font_size = $bits[$i];
108 $line_height =
false;
110 $r = $this->info[
'font-size']->validate(
118 if ($line_height ===
false) {
120 for ($j = $i + 1; $j <
$size; $j++) {
121 if ($bits[$j] ===
'') {
124 if ($bits[$j] ===
'/') {
132 $line_height = $bits[$j];
142 $r = $this->info[
'line-height']->validate(
158 implode(
' ', array_slice($bits, $i, $size - $i));
159 $r = $this->info[
'font-family']->validate(
167 return rtrim($final);
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Create styles array
The data for the language used.
◆ $info
HTMLPurifier_AttrDef_CSS_Font::$info = array() |
|
protected |
Local copy of validators HTMLPurifier_AttrDef[].
- 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:
- libs/composer/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php