2007-12-16 23:16:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2007-12-16 23:16:45 +00:00
|
|
|
parent::__construct(false); // opacity is non-negative, but we will clamp it
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param string $number
|
|
|
|
* @param HTMLPurifier_Config $config
|
|
|
|
* @param HTMLPurifier_Context $context
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function validate($number, $config, $context)
|
|
|
|
{
|
2007-12-16 23:16:45 +00:00
|
|
|
$result = parent::validate($number, $config, $context);
|
2013-07-16 11:56:14 +00:00
|
|
|
if ($result === false) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
$float = (float)$result;
|
|
|
|
if ($float < 0.0) {
|
|
|
|
$result = '0';
|
|
|
|
}
|
|
|
|
if ($float > 1.0) {
|
|
|
|
$result = '1';
|
|
|
|
}
|
2007-12-16 23:16:45 +00:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|