File indexing completed on 2025-02-02 05:43:44
0001 <?php 0002 0003 /** 0004 * Simple transformation, just change tag name to something else, 0005 * and possibly add some styling. This will cover most of the deprecated 0006 * tag cases. 0007 */ 0008 class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform 0009 { 0010 /** 0011 * @type string 0012 */ 0013 protected $style; 0014 0015 /** 0016 * @param string $transform_to Tag name to transform to. 0017 * @param string $style CSS style to add to the tag 0018 */ 0019 public function __construct($transform_to, $style = null) 0020 { 0021 $this->transform_to = $transform_to; 0022 $this->style = $style; 0023 } 0024 0025 /** 0026 * @param HTMLPurifier_Token_Tag $tag 0027 * @param HTMLPurifier_Config $config 0028 * @param HTMLPurifier_Context $context 0029 * @return string 0030 */ 0031 public function transform($tag, $config, $context) 0032 { 0033 $new_tag = clone $tag; 0034 $new_tag->name = $this->transform_to; 0035 if (!is_null($this->style) && 0036 ($new_tag instanceof HTMLPurifier_Token_Start || $new_tag instanceof HTMLPurifier_Token_Empty) 0037 ) { 0038 $this->prependCSS($new_tag->attr, $this->style); 0039 } 0040 return $new_tag; 0041 } 0042 } 0043 0044 // vim: et sw=4 sts=4