2006-08-05 01:50:13 +00:00
|
|
|
<?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
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param array $attr
|
|
|
|
* @param HTMLPurifier_Config $config
|
|
|
|
* @param HTMLPurifier_Context $context
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform($attr, $config, $context)
|
|
|
|
{
|
|
|
|
$lang = isset($attr['lang']) ? $attr['lang'] : false;
|
2006-08-05 02:16:28 +00:00
|
|
|
$xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|