]> git.immae.eu Git - github/wallabag/wallabag.git/blame - inc/3rdparty/htmlpurifier/HTMLPurifier/TagTransform/Simple.php
remove autoload section in composer.json
[github/wallabag/wallabag.git] / inc / 3rdparty / htmlpurifier / HTMLPurifier / TagTransform / Simple.php
CommitLineData
d4949327
NL
1<?php\r
2\r
3/**\r
4 * Simple transformation, just change tag name to something else,\r
5 * and possibly add some styling. This will cover most of the deprecated\r
6 * tag cases.\r
7 */\r
8class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform\r
9{\r
10 /**\r
11 * @type string\r
12 */\r
13 protected $style;\r
14\r
15 /**\r
16 * @param string $transform_to Tag name to transform to.\r
17 * @param string $style CSS style to add to the tag\r
18 */\r
19 public function __construct($transform_to, $style = null)\r
20 {\r
21 $this->transform_to = $transform_to;\r
22 $this->style = $style;\r
23 }\r
24\r
25 /**\r
26 * @param HTMLPurifier_Token_Tag $tag\r
27 * @param HTMLPurifier_Config $config\r
28 * @param HTMLPurifier_Context $context\r
29 * @return string\r
30 */\r
31 public function transform($tag, $config, $context)\r
32 {\r
33 $new_tag = clone $tag;\r
34 $new_tag->name = $this->transform_to;\r
35 if (!is_null($this->style) &&\r
36 ($new_tag instanceof HTMLPurifier_Token_Start || $new_tag instanceof HTMLPurifier_Token_Empty)\r
37 ) {\r
38 $this->prependCSS($new_tag->attr, $this->style);\r
39 }\r
40 return $new_tag;\r
41 }\r
42}\r
43\r
44// vim: et sw=4 sts=4\r