2006-08-05 01:50:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrTransform.php';
|
|
|
|
|
2006-08-20 21:55:28 +00:00
|
|
|
/**
|
|
|
|
* Post-transform that copies lang's value to xml:lang (and vice-versa)
|
|
|
|
* @note Theoretically speaking, this could be a pre-transform, but putting
|
|
|
|
* post is more efficient.
|
|
|
|
*/
|
2006-08-05 01:50:13 +00:00
|
|
|
class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
|
|
|
|
{
|
|
|
|
|
2006-08-14 23:11:28 +00:00
|
|
|
function transform($attr, $config) {
|
2006-08-05 01:50:13 +00:00
|
|
|
|
2006-08-05 02:16:28 +00:00
|
|
|
$lang = isset($attr['lang']) ? $attr['lang'] : false;
|
|
|
|
$xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false;
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
if ($lang !== false && $xml_lang === false) {
|
2006-08-05 02:16:28 +00:00
|
|
|
$attr['xml:lang'] = $lang;
|
2006-08-05 01:50:13 +00:00
|
|
|
} elseif ($xml_lang !== false) {
|
2006-08-05 02:16:28 +00:00
|
|
|
$attr['lang'] = $xml_lang;
|
2006-08-05 01:50:13 +00:00
|
|
|
}
|
|
|
|
|
2006-08-05 02:16:28 +00:00
|
|
|
return $attr;
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|