ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
 Validates and cleans passed string according to a definition.
- Public Member Functions inherited from HTMLPurifier_AttrDef
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA.
 make ($string)
 Factory method for creating this class from a string.

Data Fields

 $single
 Instance of component definition to defer validation to.
 $max
 Max number of values allowed.
- Data Fields inherited from HTMLPurifier_AttrDef
 $minimized = false
 Tells us whether or not an HTML attribute is minimized.
 $required = false
 Tells us whether or not an HTML attribute is required.

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.
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it.

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

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

Definition at line 33 of file Multiple.php.

References $max, and $single.

{
$this->single = $single;
$this->max = $max;
}

Member Function Documentation

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

Validates and cleans passed string according to a definition.

Parameters
$stringString to be validated and cleaned.
$configMandatory HTMLPurifier_Config object.
$contextMandatory HTMLPurifier_AttrContext object.

Reimplemented from HTMLPurifier_AttrDef.

Definition at line 38 of file Multiple.php.

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

{
$string = $this->parseCDATA($string);
if ($string === '') return false;
$parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n
$length = count($parts);
$final = '';
for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) {
if (ctype_space($parts[$i])) continue;
$result = $this->single->validate($parts[$i], $config, $context);
if ($result !== false) {
$final .= $result . ' ';
$num++;
}
}
if ($final === '') return false;
return rtrim($final);
}

+ Here is the call graph for this function:

Field Documentation

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().

HTMLPurifier_AttrDef_CSS_Multiple::$single

Instance of component definition to defer validation to.

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: