File indexing completed on 2024-12-22 05:36:18
0001 <?php 0002 0003 /** 0004 * Allows multiple validators to attempt to validate attribute. 0005 * 0006 * Composite is just what it sounds like: a composite of many validators. 0007 * This means that multiple HTMLPurifier_AttrDef objects will have a whack 0008 * at the string. If one of them passes, that's what is returned. This is 0009 * especially useful for CSS values, which often are a choice between 0010 * an enumerated set of predefined values or a flexible data type. 0011 */ 0012 class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef 0013 { 0014 0015 /** 0016 * List of objects that may process strings. 0017 * @type HTMLPurifier_AttrDef[] 0018 * @todo Make protected 0019 */ 0020 public $defs; 0021 0022 /** 0023 * @param HTMLPurifier_AttrDef[] $defs List of HTMLPurifier_AttrDef objects 0024 */ 0025 public function __construct($defs) 0026 { 0027 $this->defs = $defs; 0028 } 0029 0030 /** 0031 * @param string $string 0032 * @param HTMLPurifier_Config $config 0033 * @param HTMLPurifier_Context $context 0034 * @return bool|string 0035 */ 0036 public function validate($string, $config, $context) 0037 { 0038 foreach ($this->defs as $i => $def) { 0039 $result = $this->defs[$i]->validate($string, $config, $context); 0040 if ($result !== false) { 0041 return $result; 0042 } 0043 } 0044 return false; 0045 } 0046 } 0047 0048 // vim: et sw=4 sts=4