2006-08-05 02:56:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrTransform.php';
|
|
|
|
|
2006-08-20 21:55:28 +00:00
|
|
|
/**
|
|
|
|
* Pre-transform that changes deprecated align attribute to text-align.
|
|
|
|
*/
|
2006-08-05 02:56:57 +00:00
|
|
|
class HTMLPurifier_AttrTransform_TextAlign
|
2007-03-29 21:20:44 +00:00
|
|
|
extends HTMLPurifier_AttrTransform {
|
2007-05-03 04:07:47 +00:00
|
|
|
|
2007-01-16 22:22:08 +00:00
|
|
|
function transform($attr, $config, &$context) {
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
if (!isset($attr['align'])) return $attr;
|
|
|
|
|
2007-05-05 02:25:55 +00:00
|
|
|
$align = $this->confiscateAttr($attr, 'align');
|
|
|
|
$align = strtolower(trim($align));
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
$values = array('left' => 1,
|
|
|
|
'right' => 1,
|
|
|
|
'center' => 1,
|
|
|
|
'justify' => 1);
|
|
|
|
|
|
|
|
if (!isset($values[$align])) {
|
|
|
|
return $attr;
|
|
|
|
}
|
|
|
|
|
2007-05-05 02:25:55 +00:00
|
|
|
$this->prependCSS($attr, "text-align:$align;");
|
2006-08-05 02:56:57 +00:00
|
|
|
|
|
|
|
return $attr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|