ILIAS  release_4-4 Revision
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
 
 $css
 

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)

Definition at line 14 of file ImgSpace.php.

References $attr.

14  {
15  $this->attr = $attr;
16  if (!isset($this->css[$attr])) {
17  trigger_error(htmlspecialchars($attr) . ' is not valid space attribute');
18  }
19  }

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_ImgSpace::transform (   $attr,
  $config,
  $context 
)

Definition at line 21 of file ImgSpace.php.

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

21  {
22 
23  if (!isset($attr[$this->attr])) return $attr;
24 
25  $width = $this->confiscateAttr($attr, $this->attr);
26  // some validation could happen here
27 
28  if (!isset($this->css[$this->attr])) return $attr;
29 
30  $style = '';
31  foreach ($this->css[$this->attr] as $suffix) {
32  $property = "margin-$suffix";
33  $style .= "$property:{$width}px;";
34  }
35 
36  $this->prependCSS($attr, $style);
37 
38  return $attr;
39 
40  }
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...
+ Here is the call graph for this function:

Field Documentation

◆ $attr

HTMLPurifier_AttrTransform_ImgSpace::$attr
protected

Definition at line 8 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')
)

Definition at line 9 of file ImgSpace.php.


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