56 |
|
|
57 |
/** |
/** |
58 |
* The constructor |
* The constructor |
59 |
|
* |
60 |
|
* {@source } |
61 |
|
* |
62 |
|
* @tutorial XMLTagClass.cls#example |
63 |
* |
* |
64 |
* @param string - the tag name |
* @param string - the tag name |
65 |
* @param array - the attributes array |
* @param array - the attributes array |
66 |
* can be in name => value |
* can be in name => value |
67 |
* or just value |
* or just value |
68 |
* @param mixed - n items of content to |
* @param mixed - n items of content to add |
|
* add |
|
69 |
* |
* |
70 |
*/ |
*/ |
71 |
function XMLTagClass($name, $attributes=array() ) { |
function XMLTagClass($name, $attributes=array() ) { |
85 |
* This function is responsible |
* This function is responsible |
86 |
* for rendering the tag and |
* for rendering the tag and |
87 |
* its contents |
* its contents |
88 |
|
* |
89 |
|
* {@source } |
90 |
* |
* |
91 |
* @param int - the current indentation |
* @param int - the current indentation |
92 |
* level for the tag |
* level for the tag |
114 |
* This method is used to set the bitmask |
* This method is used to set the bitmask |
115 |
* flags for this tag. It tells the |
* flags for this tag. It tells the |
116 |
* class how to render the tag. |
* class how to render the tag. |
117 |
|
* |
118 |
|
* @access private |
119 |
* |
* |
120 |
* NOTE: the child class can override this |
* NOTE: the child class can override this |
121 |
* to set the options |
* to set the options |
128 |
|
|
129 |
/** |
/** |
130 |
* This method sets the name of the tag |
* This method sets the name of the tag |
131 |
|
* |
132 |
|
* {@source } |
133 |
* |
* |
134 |
* @param string - the tag name |
* @param string - the tag name |
135 |
*/ |
*/ |
139 |
|
|
140 |
/** |
/** |
141 |
* This method gets the name of the tag |
* This method gets the name of the tag |
142 |
|
* |
143 |
|
* {@source } |
144 |
* |
* |
145 |
* @return string - the tag name |
* @return string - the tag name |
146 |
*/ |
*/ |
152 |
* This returns the tag declared for this class. |
* This returns the tag declared for this class. |
153 |
* This should be used in favor of |
* This should be used in favor of |
154 |
* accessing the $this->_tag directly. |
* accessing the $this->_tag directly. |
155 |
|
* |
156 |
|
* {@source } |
157 |
* |
* |
158 |
* @return string - the _tag var for this class. |
* @return string - the _tag var for this class. |
159 |
*/ |
*/ |
164 |
|
|
165 |
/** |
/** |
166 |
* add a single attribute (name="value") |
* add a single attribute (name="value") |
167 |
|
* |
168 |
|
* {@source } |
169 |
|
* |
170 |
* @param string $name attribute name |
* @param string $name attribute name |
171 |
* @param mixed $value the value. |
* @param mixed $value the value. |
172 |
* @access public |
* @return none |
173 |
*/ |
*/ |
174 |
function set_tag_attribute( $name, $value=NULL ) { |
function set_tag_attribute( $name, $value=NULL ) { |
175 |
$this->_attributes[$name] = $value; |
$this->_attributes[$name] = $value; |
177 |
|
|
178 |
/** |
/** |
179 |
* add multiple attributes (name="value") |
* add multiple attributes (name="value") |
180 |
|
* |
181 |
|
* {@source } |
182 |
|
* |
183 |
* @param array $attributes Associative array of name="value" pairs of |
* @param array $attributes Associative array of name="value" pairs of |
184 |
* tag atributes. |
* tag atributes. |
185 |
* ie array("border"=>"0", "class"=>"hover"); |
* ie array("border"=>"0", "class"=>"hover"); |
186 |
* @access public |
* @return none |
187 |
*/ |
*/ |
188 |
function set_tag_attributes( $attributes=array() ) { |
function set_tag_attributes( $attributes=array() ) { |
189 |
$this->_attributes = array_merge($this->_attributes, $attributes); |
$this->_attributes = array_merge($this->_attributes, $attributes); |
191 |
|
|
192 |
/** |
/** |
193 |
* clear all attributes and start with new attributes |
* clear all attributes and start with new attributes |
194 |
* @param array $attributes Associative array of name="value" pairs of |
* |
195 |
* tag atributes. |
* {@source } |
196 |
* ie array("border"=>"0", "class"=>"hover"); |
* |
197 |
* @access public |
* @param array Associative array of name="value" pairs of |
198 |
|
* tag atributes. |
199 |
|
* ie array("border"=>"0", "class"=>"hover"); |
200 |
|
* @return none |
201 |
*/ |
*/ |
202 |
function reset_attributes( $attributes=array() ) { |
function reset_attributes( $attributes=array() ) { |
203 |
$this->_attributes = array(); |
$this->_attributes = array(); |
206 |
|
|
207 |
/** |
/** |
208 |
* get the nth element from content array |
* get the nth element from content array |
209 |
|
* |
210 |
|
* NOTE: |
211 |
|
* This has been made public in the Container |
212 |
|
* |
213 |
|
* {@source } |
214 |
|
* @access private |
215 |
|
* |
216 |
* @param int $cell the cell to get |
* @param int $cell the cell to get |
217 |
* @return mixed |
* @return mixed |
218 |
*/ |
*/ |
219 |
function _get_element( $cell ) { |
function &_get_element( $cell ) { |
220 |
return $this->_content[$cell]; |
return $this->get_element($cell); |
221 |
} |
} |
222 |
|
|
223 |
|
|
228 |
|
|
229 |
/** |
/** |
230 |
* set the newline_after_opentag flag |
* set the newline_after_opentag flag |
231 |
* @param boolean $flag TRUE or FALSE |
* |
232 |
|
* {@source } |
233 |
|
* |
234 |
|
* @param boolean TRUE or FALSE |
235 |
|
* @return none |
236 |
*/ |
*/ |
237 |
function set_newline_after_opentag( $flag ) { |
function set_newline_after_opentag( $flag ) { |
238 |
if ($flag) { |
if ($flag) { |
244 |
|
|
245 |
/** |
/** |
246 |
* set the newline_after_content flag |
* set the newline_after_content flag |
247 |
* @param boolean $flag TRUE or FALSE |
* |
248 |
|
* {@source } |
249 |
|
* |
250 |
|
* @param boolean TRUE or FALSE |
251 |
|
* @return none |
252 |
*/ |
*/ |
253 |
function set_newline_after_closetag( $flag ) { |
function set_newline_after_closetag( $flag ) { |
254 |
if ($flag) { |
if ($flag) { |
263 |
* of the tag's content inside the CDATA wrapper |
* of the tag's content inside the CDATA wrapper |
264 |
* for XML |
* for XML |
265 |
* |
* |
266 |
|
* {@source } |
267 |
* @param boolean $flag TRUE or FALSE |
* @param boolean $flag TRUE or FALSE |
268 |
|
* @return none |
269 |
*/ |
*/ |
270 |
function set_cdata_flag($flag) { |
function set_cdata_flag($flag) { |
271 |
if ($flag) { |
if ($flag) { |
278 |
|
|
279 |
/** |
/** |
280 |
* This function turns on the collapse flag |
* This function turns on the collapse flag |
281 |
|
* |
282 |
|
* {@source } |
283 |
* |
* |
284 |
* @param boolean - the collapse flag |
* @param boolean - the collapse flag |
285 |
* @param boolean - the indent flag |
* @param boolean - the indent flag |
286 |
* DEFAULT: TRUE; |
* DEFAULT: TRUE; |
287 |
|
* @return none |
288 |
*/ |
*/ |
289 |
function set_collapse($collapse=TRUE, $indent=TRUE) { |
function set_collapse($collapse=TRUE, $indent=TRUE) { |
290 |
if ($collapse) { |
if ($collapse) { |
307 |
* there is only 1 content data, and |
* there is only 1 content data, and |
308 |
* its not an object, then it auto |
* its not an object, then it auto |
309 |
* sets some of the indentation flags |
* sets some of the indentation flags |
310 |
* |
* |
311 |
|
* {@source } |
312 |
|
* @access private |
313 |
|
* @return none |
314 |
*/ |
*/ |
315 |
function _prepare_flags() { |
function _prepare_flags() { |
316 |
if ($this->_flags & _CONTENTREQUIRED) { |
if ($this->_flags & _CONTENTREQUIRED) { |
337 |
/** |
/** |
338 |
* this function is responsible for |
* this function is responsible for |
339 |
* rendering the open tag. |
* rendering the open tag. |
340 |
|
* |
341 |
|
* {@source } |
342 |
|
* @access private |
343 |
* |
* |
344 |
* @param int - the indent level |
* @param int - the indent level |
345 |
* @param boolean - do we add the finish / if we have no |
* @param boolean - do we add the finish / if we have no |
346 |
* close tag and no content? |
* close tag and no content? |
347 |
|
* @return string |
348 |
*/ |
*/ |
349 |
function _render_open_tag( $indent_level, $finish_slash=TRUE ) { |
function _render_open_tag( $indent_level, $finish_slash=TRUE ) { |
350 |
//get the indent level |
//get the indent level |
357 |
$this->_tag = strtoupper($this->_tag); |
$this->_tag = strtoupper($this->_tag); |
358 |
} |
} |
359 |
//save on mem |
//save on mem |
360 |
$xml = $indent . (@$this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX) . $this->_tag; |
$xml = $indent . ((isset($this->_tag_prefix) && $this->_tag_prefix) ? $this->_tag_prefix : _TAG_PREFIX) . $this->_tag; |
361 |
|
|
362 |
foreach( $this->_attributes as $name => $value) { |
foreach( $this->_attributes as $name => $value) { |
363 |
$xml .= $this->_build_attribute_string($name, $value); |
$xml .= $this->_build_attribute_string($name, $value); |
383 |
* rendering the pcdata, or content |
* rendering the pcdata, or content |
384 |
* of the tag (if any) |
* of the tag (if any) |
385 |
* |
* |
386 |
|
* {@source } |
387 |
|
* @access private |
388 |
|
* |
389 |
* @param int - the indent level |
* @param int - the indent level |
390 |
|
* @return string |
391 |
*/ |
*/ |
392 |
function _render_content( $indent_level, $output_debug=0 ) { |
function _render_content( $indent_level, $output_debug=0 ) { |
393 |
|
|
444 |
* this function is reposnsible for |
* this function is reposnsible for |
445 |
* rendering the closing tag (if any) |
* rendering the closing tag (if any) |
446 |
* |
* |
447 |
|
* {@source } |
448 |
|
* @access private |
449 |
|
* |
450 |
* @param int - the indent level |
* @param int - the indent level |
451 |
|
* @return string |
452 |
*/ |
*/ |
453 |
function _render_close_tag( $indent_level ) { |
function _render_close_tag( $indent_level ) { |
454 |
if (!($this->_flags & _CLOSETAGREQUIRED)) { |
if (!($this->_flags & _CLOSETAGREQUIRED)) { |
472 |
* this builds an attribute for an XML tag. |
* this builds an attribute for an XML tag. |
473 |
* XML attributes MUST have a name AND a |
* XML attributes MUST have a name AND a |
474 |
* value. |
* value. |
475 |
|
* |
476 |
|
* {@source } |
477 |
|
* @access private |
478 |
* |
* |
479 |
* @param string - $name attribute name |
* @param string - $name attribute name |
480 |
* @param mixed - $value attribute value |
* @param mixed - $value attribute value |