00001 <?php 00002 00011 class HTMLPurifier_ElementDef 00012 { 00013 00018 public $standalone = true; 00019 00031 public $attr = array(); 00032 00036 public $attr_transform_pre = array(); 00037 00041 public $attr_transform_post = array(); 00042 00046 public $child; 00047 00055 public $content_model; 00056 00064 public $content_model_type; 00065 00066 00067 00074 public $descendants_are_inline = false; 00075 00080 public $required_attr = array(); 00081 00093 public $excludes = array(); 00094 00098 public $autoclose = array(); 00099 00104 public $formatting; 00105 00109 public static function create($content_model, $content_model_type, $attr) { 00110 $def = new HTMLPurifier_ElementDef(); 00111 $def->content_model = $content_model; 00112 $def->content_model_type = $content_model_type; 00113 $def->attr = $attr; 00114 return $def; 00115 } 00116 00122 public function mergeIn($def) { 00123 00124 // later keys takes precedence 00125 foreach($def->attr as $k => $v) { 00126 if ($k === 0) { 00127 // merge in the includes 00128 // sorry, no way to override an include 00129 foreach ($v as $v2) { 00130 $this->attr[0][] = $v2; 00131 } 00132 continue; 00133 } 00134 if ($v === false) { 00135 if (isset($this->attr[$k])) unset($this->attr[$k]); 00136 continue; 00137 } 00138 $this->attr[$k] = $v; 00139 } 00140 $this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre); 00141 $this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post); 00142 $this->_mergeAssocArray($this->excludes, $def->excludes); 00143 00144 if(!empty($def->content_model)) { 00145 $this->content_model = 00146 str_replace("#SUPER", $this->content_model, $def->content_model); 00147 $this->child = false; 00148 } 00149 if(!empty($def->content_model_type)) { 00150 $this->content_model_type = $def->content_model_type; 00151 $this->child = false; 00152 } 00153 if(!is_null($def->child)) $this->child = $def->child; 00154 if(!is_null($def->formatting)) $this->formatting = $def->formatting; 00155 if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline; 00156 00157 } 00158 00164 private function _mergeAssocArray(&$a1, $a2) { 00165 foreach ($a2 as $k => $v) { 00166 if ($v === false) { 00167 if (isset($a1[$k])) unset($a1[$k]); 00168 continue; 00169 } 00170 $a1[$k] = $v; 00171 } 00172 } 00173 00174 } 00175 00176 // vim: et sw=4 sts=4
| Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|
