2006-08-05 01:50:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrTransform.php';
|
|
|
|
|
2006-08-14 23:11:28 +00:00
|
|
|
// this transformation may be done pre or post validation, but post is
|
|
|
|
// preferred, since invalid languages then will have been dropped.
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|