File indexing completed on 2025-02-02 05:43:42
0001 <?php 0002 0003 /** 0004 * Definition that allows a set of elements, and allows no children. 0005 * @note This is a hack to reuse code from HTMLPurifier_ChildDef_Required, 0006 * really, one shouldn't inherit from the other. Only altered behavior 0007 * is to overload a returned false with an array. Thus, it will never 0008 * return false. 0009 */ 0010 class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required 0011 { 0012 /** 0013 * @type bool 0014 */ 0015 public $allow_empty = true; 0016 0017 /** 0018 * @type string 0019 */ 0020 public $type = 'optional'; 0021 0022 /** 0023 * @param array $children 0024 * @param HTMLPurifier_Config $config 0025 * @param HTMLPurifier_Context $context 0026 * @return array 0027 */ 0028 public function validateChildren($children, $config, $context) 0029 { 0030 $result = parent::validateChildren($children, $config, $context); 0031 // we assume that $children is not modified 0032 if ($result === false) { 0033 if (empty($children)) { 0034 return true; 0035 } elseif ($this->whitespace) { 0036 return $children; 0037 } else { 0038 return array(); 0039 } 0040 } 0041 return $result; 0042 } 0043 } 0044 0045 // vim: et sw=4 sts=4