1 : <?php
2 :
3 : /**
4 : * Post-transform that copies lang's value to xml:lang (and vice-versa)
5 : * @note Theoretically speaking, this could be a pre-transform, but putting
6 : * post is more efficient.
7 : */
8 1 : class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
9 : {
10 :
11 : public function transform($attr, $config, $context) {
12 :
13 2 : $lang = isset($attr['lang']) ? $attr['lang'] : false;
14 2 : $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false;
15 :
16 2 : if ($lang !== false && $xml_lang === false) {
17 0 : $attr['xml:lang'] = $lang;
18 2 : } elseif ($xml_lang !== false) {
19 0 : $attr['lang'] = $xml_lang;
20 0 : }
21 :
22 2 : return $attr;
23 :
24 : }
25 :
26 : }
27 :
|