Source for file Element.php
Documentation is available at Element.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
require_once 'XML/Util2.php';
require_once 'XML/XUL/Exception.php';
* Base class for all elements
* @author Stephan Schmidt <schst@php.net>
define('XML_XUL_ERROR_ELEMENT_NOT_FOUND', 150 );
define('XML_XUL_ERROR_ATTRIBUTE_UNKNOWN', 200 );
* attribute is no integer
define('XML_XUL_ERROR_ATTRIBUTE_NO_INTEGER', 201 );
* attribute is no integer
define('XML_XUL_ERROR_ATTRIBUTE_NO_BOOLEAN', 202 );
* attribute contains invalid value
define('XML_XUL_ERROR_ATTRIBUTE_INVALID_VALUE', 203 );
* Base class for all elements
* @author Stephan Schmidt <schst@php.net>
* namespace for XUL elements
* namespace for HTML elements
* attributes of the element
* childNodes of the element
* stores a reference to the document that created the
* @var object XML_XUL_Document
* indicates whether the element is the root element
* These attributes are supported by all elements
var $_commonAttribs = array (
'values' => array ( 'baseline', 'center', 'end', 'start', 'stretch' )
'values' => array ( 'normal', 'reverse' )
'values' => array ( 'alwyys', 'never' )
'values' => array ( 'vertical', 'horizontal' )
'values' => array ( 'center', 'start', 'end' )
* flag to indicate whether xml entities should be replaced
* @param array attributes of the element
* @param string cdata of the element (used by caption, et al)
* @param boolean autobuild flag
function __construct( $attributes = array (), $cdata = null , $autoBuild = true )
* set the reference to the document
* @param object XML_XUL_Document document
* set the namespace for XHTML element
* @return string id of the element
* get the element's tag name
* @return string tag name of the element
* sets cdata of the element
* sets several attributes at once
* @param array attributes
* @param string attribute name
* @param mixed attribute value
* @param string attribute name
* @return mixed attribute value
* create a string representation of the element
* This is just an alias for serialize()
* @return string string representation of the element and all of its childNodes
* @return string string representation of the element and all of its childNodes
if ($this->cdata !== null ) {
$content = $util->replaceEntities ($content);
for ($i=0; $i< $cnt; $i++ ) {
$nsUri = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
if ($this->_htmlNs != null ) {
$this->attributes['xmlns:'. $this->_htmlNs] = 'http://www.w3.org/1999/xhtml';
* This method will return a copy of the element
* without the id and the childNodes
* @param boolean whether children should be cloned, too.
* @return object XML_XUL_Element
if ($recursive !== true ) {
for ($i = 0; $i < $cnt; $i++ ) {
$copy->appendChild ( $this->childNodes[$i]->cloneElement ( $recursive ) );
* get an element by its id
* You should not need to call this method directly
* @return object XML_XUL_Element or false if the element does not exist
if ($this->getId() == $id) {
for ($i=0; $i< $cnt; $i++ ) {
$result = $this->childNodes[$i]->getElementById ($id);
* get a nodelist of elements by their tagname
* @return array array containing XML_XUL_Element objects
for ($i=0; $i< $cnt; $i++ ) {
$tmp = $this->childNodes[$i]->getElementsByTagname ($tagname);
for($j=0; $j< $cnt2; $j++ ) {
* validate the element's attributes
* Uses the definitions of common attributes as well as the
* attribute definitions of the element.
* @return boolean true on success
* @throws XML_XUL_Exception
if (isset ($this->_commonAttribs[$name])) {
$def = $this->_commonAttribs[$name];
} elseif (isset ($this->_attribDefs[$name])) {
$def = $this->_attribDefs[$name];
if (!in_array($value, $def['values'])) {
if ($value != 'true' && $value != 'false') {
* get the first child of the element
* If the element has no childNodes, null will be returned.
* @return object XML_XUL_Element
* get last first child of the element
* If the element has no childNodes, null will be returned.
* @return object XML_XUL_Element
* add a description element
* This can be used by a lot of elements,
* thus it has been placed in the base class.
* @param string text for the description
* @param array additional attributes
* @return object XML_XUL_Element_Description
* @see XML_XUL_Element_Description
* get a debug info about the element as
* Use this instead of a print_r on the tree.
* @param integer nesting depth, no need to pass this
function getDebug( $indent = '', $last = false )
$name = $this->getElementName ();
$debug = sprintf("%s +-%s\n", $indent, $name);
$debug = sprintf("%s +-%s\n", $indent, $name);
$debug .= sprintf("%s+-attributes:\n", $indent);
$debug .= sprintf("%s| %s => %s\n", $indent, $key, $value);
if (!empty ($this->cdata)) {
$debug .= sprintf("%s+-cdata: %s\n", $indent, $this->cdata);
$debug .= sprintf("%s+-cdata: null\n", $indent);
$debug .= sprintf("%s+-childNodes:\n", $indent);
$debug .= $this->childNodes[$i]->getDebug ($indent, true );
$debug .= $this->childNodes[$i]->getDebug ($indent);
$debug .= sprintf("%s\n", $indent);
Documentation generated on Mon, 11 Mar 2019 15:49:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|