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
|
|
|
/**
|
2013-07-16 11:56:14 +00:00
|
|
|
* List of objects that may process strings.
|
|
|
|
* @type HTMLPurifier_AttrDef[]
|
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
|
|
|
/**
|
2013-07-16 11:56:14 +00:00
|
|
|
* @param HTMLPurifier_AttrDef[] $defs List of HTMLPurifier_AttrDef objects
|
2006-08-20 21:47:15 +00:00
|
|
|
*/
|
2013-07-16 11:56:14 +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
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param string $string
|
|
|
|
* @param HTMLPurifier_Config $config
|
|
|
|
* @param HTMLPurifier_Context $context
|
|
|
|
* @return bool|string
|
|
|
|
*/
|
|
|
|
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);
|
2013-07-16 11:56:14 +00:00
|
|
|
if ($result !== false) {
|
|
|
|
return $result;
|
|
|
|
}
|
2006-08-13 18:16:30 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|