|
Revision 21, 0.7 kB
(checked in by admin, 18 years ago)
|
|
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Post-transform that copies lang's value to xml:lang (and vice-versa) |
|---|
| 5 | * @note Theoretically speaking, this could be a pre-transform, but putting |
|---|
| 6 | * post is more efficient. |
|---|
| 7 | */ |
|---|
| 8 | class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform |
|---|
| 9 | { |
|---|
| 10 | |
|---|
| 11 | public function transform($attr, $config, $context) { |
|---|
| 12 | |
|---|
| 13 | $lang = isset($attr['lang']) ? $attr['lang'] : false; |
|---|
| 14 | $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false; |
|---|
| 15 | |
|---|
| 16 | if ($lang !== false && $xml_lang === false) { |
|---|
| 17 | $attr['xml:lang'] = $lang; |
|---|
| 18 | } elseif ($xml_lang !== false) { |
|---|
| 19 | $attr['lang'] = $xml_lang; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | return $attr; |
|---|
| 23 | |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | } |
|---|
| 27 | |
|---|