ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrDef_HTML_MultiLength Class Reference

Validates a MultiLength as defined by the HTML spec. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_HTML_MultiLength:
+ Collaboration diagram for HTMLPurifier_AttrDef_HTML_MultiLength:

Public Member Functions

 validate ($string, $config, $context)
 Validates and cleans passed string according to a definition.

Additional Inherited Members

- 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.
- 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.
- Protected Attributes inherited from HTMLPurifier_AttrDef_HTML_Pixels
 $max

Detailed Description

Validates a MultiLength as defined by the HTML spec.

A multilength is either a integer (pixel count), a percentage, or a relative number.

Definition at line 9 of file MultiLength.php.

Member Function Documentation

HTMLPurifier_AttrDef_HTML_MultiLength::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_HTML_Length.

Definition at line 12 of file MultiLength.php.

{
$string = trim($string);
if ($string === '') return false;
$parent_result = parent::validate($string, $config, $context);
if ($parent_result !== false) return $parent_result;
$length = strlen($string);
$last_char = $string[$length - 1];
if ($last_char !== '*') return false;
$int = substr($string, 0, $length - 1);
if ($int == '') return '*';
if (!is_numeric($int)) return false;
$int = (int) $int;
if ($int < 0) return false;
if ($int == 0) return '0';
if ($int == 1) return '*';
return ((string) $int) . '*';
}

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