ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
HTMLPurifier_AttrDef_CSS_ImportantDecorator Class Reference

Decorator which enables !important to be used in CSS values. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_CSS_ImportantDecorator:
+ Collaboration diagram for HTMLPurifier_AttrDef_CSS_ImportantDecorator:

Public Member Functions

 __construct ($def, $allow=false)
 
 validate ($string, $config, $context)
 Intercepts and removes !important if necessary. More...
 
- 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

 $def
 HTMLPurifier_AttrDef More...
 
 $allow
 bool 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

Decorator which enables !important to be used in CSS values.

Definition at line 6 of file ImportantDecorator.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrDef_CSS_ImportantDecorator::__construct (   $def,
  $allow = false 
)
Parameters
HTMLPurifier_AttrDef$defDefinition to wrap
bool$allowWhether or not to allow !important

Definition at line 21 of file ImportantDecorator.php.

References $allow, and $def.

22  {
23  $this->def = $def;
24  $this->allow = $allow;
25  }

Member Function Documentation

◆ validate()

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

Intercepts and removes !important if necessary.

Parameters
string$string
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Definition at line 34 of file ImportantDecorator.php.

References $config.

35  {
36  // test for ! and important tokens
37  $string = trim($string);
38  $is_important = false;
39  // :TODO: optimization: test directly for !important and ! important
40  if (strlen($string) >= 9 && substr($string, -9) === 'important') {
41  $temp = rtrim(substr($string, 0, -9));
42  // use a temp, because we might want to restore important
43  if (strlen($temp) >= 1 && substr($temp, -1) === '!') {
44  $string = rtrim(substr($temp, 0, -1));
45  $is_important = true;
46  }
47  }
48  $string = $this->def->validate($string, $config, $context);
49  if ($this->allow && $is_important) {
50  $string .= ' !important';
51  }
52  return $string;
53  }

Field Documentation

◆ $allow

HTMLPurifier_AttrDef_CSS_ImportantDecorator::$allow

bool

Definition at line 15 of file ImportantDecorator.php.

Referenced by __construct().

◆ $def

HTMLPurifier_AttrDef_CSS_ImportantDecorator::$def

HTMLPurifier_AttrDef

Definition at line 11 of file ImportantDecorator.php.

Referenced by __construct().


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