3 require_once 'HTMLPurifier/AttrTransform.php';
6 * Post-transform that copies lang's value to xml:lang (and vice-versa)
7 * @note Theoretically speaking, this could be a pre-transform, but putting
8 * post is more efficient.
10 class HTMLPurifier_AttrTransform_Lang
extends HTMLPurifier_AttrTransform
13 function transform($attr, $config, &$context) {
15 $lang = isset($attr['lang']) ?
$attr['lang'] : false;
16 $xml_lang = isset($attr['xml:lang']) ?
$attr['xml:lang'] : false;
18 if ($lang !== false && $xml_lang === false) {
19 $attr['xml:lang'] = $lang;
20 } elseif ($xml_lang !== false) {
21 $attr['lang'] = $xml_lang;