ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HTMLPurifier_AttrDef_CSS_Multiple Class Reference

Framework class for strings that involve multiple values. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_CSS_Multiple:
+ Collaboration diagram for HTMLPurifier_AttrDef_CSS_Multiple:

Public Member Functions

 __construct ($single, $max=4)
 
 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...
 

Data Fields

 $single
 Instance of component definition to defer validation to. More...
 
 $max
 Max number of values allowed. More...
 
- 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...
 

Additional Inherited Members

- 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

Framework class for strings that involve multiple values.

Certain CSS properties such as border-width and margin allow multiple lengths to be specified. This class can take a vanilla border-width definition and multiply it, usually into a max of four.

Note
Even though the CSS specification isn't clear about it, inherit can only be used alone: it will never manifest as part of a multi shorthand declaration. Thus, this class does not allow inherit.

Definition at line 14 of file Multiple.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrDef_CSS_Multiple::__construct (   $single,
  $max = 4 
)
Parameters
HTMLPurifier_AttrDef$singleHTMLPurifier_AttrDef to multiply
int$maxMax number of values allowed (usually four)

Definition at line 33 of file Multiple.php.

References $max, and $single.

34  {
35  $this->single = $single;
36  $this->max = $max;
37  }
$single
Instance of component definition to defer validation to.
Definition: Multiple.php:21
$max
Max number of values allowed.
Definition: Multiple.php:27

Member Function Documentation

◆ validate()

HTMLPurifier_AttrDef_CSS_Multiple::validate (   $string,
  $config,
  $context 
)
Parameters
string$string
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Definition at line 45 of file Multiple.php.

References $config, $context, $i, $max, $result, HTMLPurifier_AttrDef\mungeRgb(), and HTMLPurifier_AttrDef\parseCDATA().

46  {
47  $string = $this->mungeRgb($this->parseCDATA($string));
48  if ($string === '') {
49  return false;
50  }
51  $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n
52  $length = count($parts);
53  $final = '';
54  for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) {
55  if (ctype_space($parts[$i])) {
56  continue;
57  }
58  $result = $this->single->validate($parts[$i], $config, $context);
59  if ($result !== false) {
60  $final .= $result . ' ';
61  $num++;
62  }
63  }
64  if ($final === '') {
65  return false;
66  }
67  return rtrim($final);
68  }
$context
Definition: webdav.php:25
$config
Definition: bootstrap.php:15
$result
$max
Max number of values allowed.
Definition: Multiple.php:27
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:60
mungeRgb($string)
Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
Definition: AttrDef.php:87
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

Field Documentation

◆ $max

HTMLPurifier_AttrDef_CSS_Multiple::$max

Max number of values allowed.

Todo:
Make protected

Definition at line 27 of file Multiple.php.

Referenced by __construct(), and validate().

◆ $single

HTMLPurifier_AttrDef_CSS_Multiple::$single

Instance of component definition to defer validation to.

HTMLPurifier_AttrDef

Todo:
Make protected

Definition at line 21 of file Multiple.php.

Referenced by __construct().


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