00001 <?php
00002
00009 class HTMLPurifier_ElementDef
00010 {
00011
00016 public $standalone = true;
00017
00029 public $attr = array();
00030
00034 public $attr_transform_pre = array();
00035
00039 public $attr_transform_post = array();
00040
00044 public $child;
00045
00053 public $content_model;
00054
00062 public $content_model_type;
00063
00064
00065
00072 public $descendants_are_inline = false;
00073
00078 public $required_attr = array();
00079
00091 public $excludes = array();
00092
00096 public static function create($content_model, $content_model_type, $attr) {
00097 $def = new HTMLPurifier_ElementDef();
00098 $def->content_model = $content_model;
00099 $def->content_model_type = $content_model_type;
00100 $def->attr = $attr;
00101 return $def;
00102 }
00103
00109 public function mergeIn($def) {
00110
00111
00112 foreach($def->attr as $k => $v) {
00113 if ($k === 0) {
00114
00115
00116 foreach ($v as $v2) {
00117 $this->attr[0][] = $v2;
00118 }
00119 continue;
00120 }
00121 if ($v === false) {
00122 if (isset($this->attr[$k])) unset($this->attr[$k]);
00123 continue;
00124 }
00125 $this->attr[$k] = $v;
00126 }
00127 $this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre);
00128 $this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post);
00129 $this->_mergeAssocArray($this->excludes, $def->excludes);
00130
00131 if(!empty($def->content_model)) {
00132 $this->content_model .= ' | ' . $def->content_model;
00133 $this->child = false;
00134 }
00135 if(!empty($def->content_model_type)) {
00136 $this->content_model_type = $def->content_model_type;
00137 $this->child = false;
00138 }
00139 if(!is_null($def->child)) $this->child = $def->child;
00140 if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline;
00141
00142 }
00143
00149 private function _mergeAssocArray(&$a1, $a2) {
00150 foreach ($a2 as $k => $v) {
00151 if ($v === false) {
00152 if (isset($a1[$k])) unset($a1[$k]);
00153 continue;
00154 }
00155 $a1[$k] = $v;
00156 }
00157 }
00158
00159 }
00160
00161