Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / AttrTransform / Lang.php
blob899f5c8dc5307fee007737d714b618314ae68314
1 <?php
3 require_once 'HTMLPurifier/AttrTransform.php';
5 /**
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.
9 */
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;
24 return $attr;