File indexing completed on 2024-12-22 05:36:18
0001 <?php 0002 0003 /** 0004 * Validates the border property as defined by CSS. 0005 */ 0006 class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef 0007 { 0008 0009 /** 0010 * Local copy of properties this property is shorthand for. 0011 * @type HTMLPurifier_AttrDef[] 0012 */ 0013 protected $info = array(); 0014 0015 /** 0016 * @param HTMLPurifier_Config $config 0017 */ 0018 public function __construct($config) 0019 { 0020 $def = $config->getCSSDefinition(); 0021 $this->info['border-width'] = $def->info['border-width']; 0022 $this->info['border-style'] = $def->info['border-style']; 0023 $this->info['border-top-color'] = $def->info['border-top-color']; 0024 } 0025 0026 /** 0027 * @param string $string 0028 * @param HTMLPurifier_Config $config 0029 * @param HTMLPurifier_Context $context 0030 * @return bool|string 0031 */ 0032 public function validate($string, $config, $context) 0033 { 0034 $string = $this->parseCDATA($string); 0035 $string = $this->mungeRgb($string); 0036 $bits = explode(' ', $string); 0037 $done = array(); // segments we've finished 0038 $ret = ''; // return value 0039 foreach ($bits as $bit) { 0040 foreach ($this->info as $propname => $validator) { 0041 if (isset($done[$propname])) { 0042 continue; 0043 } 0044 $r = $validator->validate($bit, $config, $context); 0045 if ($r !== false) { 0046 $ret .= $r . ' '; 0047 $done[$propname] = true; 0048 break; 0049 } 0050 } 0051 } 0052 return rtrim($ret); 0053 } 0054 } 0055 0056 // vim: et sw=4 sts=4