HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
00007 {
00008 
00012     protected $info = array();
00013 
00014     public function __construct($config) {
00015         $def = $config->getCSSDefinition();
00016         $this->info['border-width'] = $def->info['border-width'];
00017         $this->info['border-style'] = $def->info['border-style'];
00018         $this->info['border-top-color'] = $def->info['border-top-color'];
00019     }
00020 
00021     public function validate($string, $config, $context) {
00022         $string = $this->parseCDATA($string);
00023         $string = $this->mungeRgb($string);
00024         $bits = explode(' ', $string);
00025         $done = array(); // segments we've finished
00026         $ret = ''; // return value
00027         foreach ($bits as $bit) {
00028             foreach ($this->info as $propname => $validator) {
00029                 if (isset($done[$propname])) continue;
00030                 $r = $validator->validate($bit, $config, $context);
00031                 if ($r !== false) {
00032                     $ret .= $r . ' ';
00033                     $done[$propname] = true;
00034                     break;
00035                 }
00036             }
00037         }
00038         return rtrim($ret);
00039     }
00040 
00041 }
00042 
00043 // vim: et sw=4 sts=4