2006-08-13 18:16:30 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-20 21:47:15 +00:00
|
|
|
/**
|
|
|
|
* Allows multiple validators to attempt to validate attribute.
|
2008-12-06 07:28:20 +00:00
|
|
|
*
|
2006-08-20 21:47:15 +00:00
|
|
|
* Composite is just what it sounds like: a composite of many validators.
|
|
|
|
* This means that multiple HTMLPurifier_AttrDef objects will have a whack
|
|
|
|
* at the string. If one of them passes, that's what is returned. This is
|
|
|
|
* especially useful for CSS values, which often are a choice between
|
|
|
|
* an enumerated set of predefined values or a flexible data type.
|
|
|
|
*/
|
2007-02-14 20:38:51 +00:00
|
|
|
class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef
|
2006-08-13 18:16:30 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-20 21:47:15 +00:00
|
|
|
/**
|
|
|
|
* List of HTMLPurifier_AttrDef objects that may process strings
|
2007-11-25 02:24:39 +00:00
|
|
|
* @todo Make protected
|
2006-08-20 21:47:15 +00:00
|
|
|
*/
|
2007-11-25 02:24:39 +00:00
|
|
|
public $defs;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-20 21:47:15 +00:00
|
|
|
/**
|
|
|
|
* @param $defs List of HTMLPurifier_AttrDef objects
|
|
|
|
*/
|
2007-11-29 04:29:51 +00:00
|
|
|
public function __construct($defs) {
|
2006-08-13 21:23:57 +00:00
|
|
|
$this->defs = $defs;
|
2006-08-13 18:16:30 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-05 00:10:43 +00:00
|
|
|
public function validate($string, $config, $context) {
|
2006-08-13 18:16:30 +00:00
|
|
|
foreach ($this->defs as $i => $def) {
|
|
|
|
$result = $this->defs[$i]->validate($string, $config, $context);
|
|
|
|
if ($result !== false) return $result;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 18:16:30 +00:00
|
|
|
}
|
|
|
|
|