mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 07:38:41 +00:00
8a23710405
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@162 48356398-32a2-884e-a903-53898d9a118a
31 lines
829 B
PHP
31 lines
829 B
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/AttrTransform.php';
|
|
|
|
class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
|
|
{
|
|
|
|
function transform($token) {
|
|
|
|
$lang = isset($token->attributes['lang']) ?
|
|
$token->attributes['lang'] : false;
|
|
$xml_lang = isset($token->attributes['xml:lang']) ?
|
|
$token->attributes['xml:lang'] : false;
|
|
|
|
if ($lang === false && $xml_lang == false) return $token;
|
|
|
|
$new_token = $token->copy();
|
|
|
|
if ($lang !== false && $xml_lang === false) {
|
|
$new_token->attributes['xml:lang'] = $lang;
|
|
} elseif ($xml_lang !== false) {
|
|
$new_token->attributes['lang'] = $xml_lang;
|
|
}
|
|
|
|
return $new_token;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|