ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
HTMLPurifier_AttrTransform_ImgSpace Class Reference

Pre-transform that changes deprecated hspace and vspace attributes to CSS. More...

+ Inheritance diagram for HTMLPurifier_AttrTransform_ImgSpace:
+ Collaboration diagram for HTMLPurifier_AttrTransform_ImgSpace:

Public Member Functions

 __construct ($attr)
 
 transform ($attr, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrTransform
 transform ($attr, $config, $context)
 Abstract: makes changes to the attributes dependent on multiple values. More...
 
 prependCSS (&$attr, $css)
 Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist. More...
 
 confiscateAttr (&$attr, $key)
 Retrieves and removes an attribute. More...
 

Protected Attributes

 $attr
 @type string More...
 
 $css
 @type array More...
 

Detailed Description

Pre-transform that changes deprecated hspace and vspace attributes to CSS.

Definition at line 6 of file ImgSpace.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrTransform_ImgSpace::__construct (   $attr)
Parameters
string$attr

Definition at line 24 of file ImgSpace.php.

25 {
26 $this->attr = $attr;
27 if (!isset($this->css[$attr])) {
28 trigger_error(htmlspecialchars($attr) . ' is not valid space attribute');
29 }
30 }

References $attr.

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_ImgSpace::transform (   $attr,
  $config,
  $context 
)
Parameters
array$attr
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Reimplemented from HTMLPurifier_AttrTransform.

Definition at line 38 of file ImgSpace.php.

39 {
40 if (!isset($attr[$this->attr])) {
41 return $attr;
42 }
43
44 $width = $this->confiscateAttr($attr, $this->attr);
45 // some validation could happen here
46
47 if (!isset($this->css[$this->attr])) {
48 return $attr;
49 }
50
51 $style = '';
52 foreach ($this->css[$this->attr] as $suffix) {
53 $property = "margin-$suffix";
54 $style .= "$property:{$width}px;";
55 }
56 $this->prependCSS($attr, $style);
57 return $attr;
58 }
confiscateAttr(&$attr, $key)
Retrieves and removes an attribute.
prependCSS(&$attr, $css)
Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist.
$style
Definition: example_012.php:70

References $attr, $style, HTMLPurifier_AttrTransform\confiscateAttr(), and HTMLPurifier_AttrTransform\prependCSS().

+ Here is the call graph for this function:

Field Documentation

◆ $attr

HTMLPurifier_AttrTransform_ImgSpace::$attr
protected

@type string

Definition at line 11 of file ImgSpace.php.

Referenced by __construct(), and transform().

◆ $css

HTMLPurifier_AttrTransform_ImgSpace::$css
protected
Initial value:
= array(
'hspace' => array('left', 'right'),
'vspace' => array('top', 'bottom')
)

@type array

Definition at line 16 of file ImgSpace.php.


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