Rewrite CSS url() and font-family output logic.
[htmlpurifier.git] / library / HTMLPurifier / AttrDef / CSS / Border.php
blob42a1d1b4ae36290be99d29a24d7ee2c67a01abdc
1 <?php
3 /**
4 * Validates the border property as defined by CSS.
5 */
6 class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
9 /**
10 * Local copy of properties this property is shorthand for.
12 protected $info = array();
14 public function __construct($config) {
15 $def = $config->getCSSDefinition();
16 $this->info['border-width'] = $def->info['border-width'];
17 $this->info['border-style'] = $def->info['border-style'];
18 $this->info['border-top-color'] = $def->info['border-top-color'];
21 public function validate($string, $config, $context) {
22 $string = $this->parseCDATA($string);
23 $string = $this->mungeRgb($string);
24 $bits = explode(' ', $string);
25 $done = array(); // segments we've finished
26 $ret = ''; // return value
27 foreach ($bits as $bit) {
28 foreach ($this->info as $propname => $validator) {
29 if (isset($done[$propname])) continue;
30 $r = $validator->validate($bit, $config, $context);
31 if ($r !== false) {
32 $ret .= $r . ' ';
33 $done[$propname] = true;
34 break;
38 return rtrim($ret);
43 // vim: et sw=4 sts=4