XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
ElementDef.php
Go to the documentation of this file.
1 <?php
2 
12 {
13 
18  public $standalone = true;
19 
31  public $attr = array();
32 
36  public $attr_transform_pre = array();
37 
41  public $attr_transform_post = array();
42 
46  public $child;
47 
56 
65 
66 
67 
74  public $descendants_are_inline = false;
75 
80  public $required_attr = array();
81 
93  public $excludes = array();
94 
98  public $autoclose = array();
99 
105  public $wrap;
106 
111  public $formatting;
112 
116  public static function create($content_model, $content_model_type, $attr) {
117  $def = new HTMLPurifier_ElementDef();
118  $def->content_model = $content_model;
119  $def->content_model_type = $content_model_type;
120  $def->attr = $attr;
121  return $def;
122  }
123 
129  public function mergeIn($def) {
130 
131  // later keys takes precedence
132  foreach($def->attr as $k => $v) {
133  if ($k === 0) {
134  // merge in the includes
135  // sorry, no way to override an include
136  foreach ($v as $v2) {
137  $this->attr[0][] = $v2;
138  }
139  continue;
140  }
141  if ($v === false) {
142  if (isset($this->attr[$k])) unset($this->attr[$k]);
143  continue;
144  }
145  $this->attr[$k] = $v;
146  }
147  $this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre);
148  $this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post);
149  $this->_mergeAssocArray($this->excludes, $def->excludes);
150 
151  if(!empty($def->content_model)) {
152  $this->content_model =
153  str_replace("#SUPER", $this->content_model, $def->content_model);
154  $this->child = false;
155  }
156  if(!empty($def->content_model_type)) {
157  $this->content_model_type = $def->content_model_type;
158  $this->child = false;
159  }
160  if(!is_null($def->child)) $this->child = $def->child;
161  if(!is_null($def->formatting)) $this->formatting = $def->formatting;
162  if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline;
163 
164  }
165 
171  private function _mergeAssocArray(&$a1, $a2) {
172  foreach ($a2 as $k => $v) {
173  if ($v === false) {
174  if (isset($a1[$k])) unset($a1[$k]);
175  continue;
176  }
177  $a1[$k] = $v;
178  }
179  }
180 
181 }
182 
183 // vim: et sw=4 sts=4