2006-08-27 00:49:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates the border property as defined by CSS.
|
|
|
|
*/
|
2007-02-14 20:38:51 +00:00
|
|
|
class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
|
2006-08-27 00:49:34 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 00:49:34 +00:00
|
|
|
/**
|
|
|
|
* Local copy of properties this property is shorthand for.
|
|
|
|
*/
|
2007-11-25 02:24:39 +00:00
|
|
|
protected $info = array();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-11-29 04:29:51 +00:00
|
|
|
public function __construct($config) {
|
2006-08-31 20:33:07 +00:00
|
|
|
$def = $config->getCSSDefinition();
|
2006-08-27 00:49:34 +00:00
|
|
|
$this->info['border-width'] = $def->info['border-width'];
|
|
|
|
$this->info['border-style'] = $def->info['border-style'];
|
|
|
|
$this->info['border-top-color'] = $def->info['border-top-color'];
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-05 00:10:43 +00:00
|
|
|
public function validate($string, $config, $context) {
|
2006-08-27 00:49:34 +00:00
|
|
|
$string = $this->parseCDATA($string);
|
2008-03-16 19:14:39 +00:00
|
|
|
$string = $this->mungeRgb($string);
|
2006-08-27 00:49:34 +00:00
|
|
|
$bits = explode(' ', $string);
|
|
|
|
$done = array(); // segments we've finished
|
|
|
|
$ret = ''; // return value
|
|
|
|
foreach ($bits as $bit) {
|
|
|
|
foreach ($this->info as $propname => $validator) {
|
|
|
|
if (isset($done[$propname])) continue;
|
2006-08-27 02:08:50 +00:00
|
|
|
$r = $validator->validate($bit, $config, $context);
|
2006-08-27 00:49:34 +00:00
|
|
|
if ($r !== false) {
|
|
|
|
$ret .= $r . ' ';
|
|
|
|
$done[$propname] = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rtrim($ret);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 00:49:34 +00:00
|
|
|
}
|
|
|
|
|