HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number
00004 {
00005 
00006     public function __construct() {
00007         parent::__construct(false); // opacity is non-negative, but we will clamp it
00008     }
00009 
00010     public function validate($number, $config, $context) {
00011         $result = parent::validate($number, $config, $context);
00012         if ($result === false) return $result;
00013         $float = (float) $result;
00014         if ($float < 0.0) $result = '0';
00015         if ($float > 1.0) $result = '1';
00016         return $result;
00017     }
00018 
00019 }
00020 
00021 // vim: et sw=4 sts=4