HTMLPurifier/AttrTransform/ImgSpace.php Quellcode

ImgSpace.php
gehe zur Dokumentation dieser Datei
1 <?php
2 
7 {
11  protected $attr;
12 
16  protected $css = array(
17  'hspace' => array('left', 'right'),
18  'vspace' => array('top', 'bottom')
19  );
20 
24  public function __construct($attr)
25  {
26  $this->attr = $attr;
27  if (!isset($this->css[$attr])) {
28  trigger_error(htmlspecialchars($attr) . ' is not valid space attribute');
29  }
30  }
31 
38  public function transform($attr, $config, $context)
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  }
59 }
60 
61 // vim: et sw=4 sts=4




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.