From: Michael M Slusarz Date: Wed, 3 Feb 2010 09:41:27 +0000 (-0700) Subject: Remove Horde_DOM package X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=be7b1b7393f8d6e0bb8f548792fc72d9a615a992;p=horde.git Remove Horde_DOM package --- diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index f24d44460..77365dfea 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -125,25 +125,25 @@ class Horde_Config } /* Load the DOM object. */ - include_once 'Horde/DOM.php'; - $doc = Horde_DOM_Document::factory(array('filename' => $path . '/conf.xml')); + $dom = new DOMDocument(); + $dom->load($path . '/conf.xml'); /* Check if there is a CVS/Git version tag and store it. */ - $node = $doc->first_child(); + $node = $dom->firstChild; while (!empty($node)) { - if (($node->type == XML_COMMENT_NODE) && - ($vers_tag = $this->getVersion($node->node_value()))) { + if (($node->nodeType == XML_COMMENT_NODE) && + ($vers_tag = $this->getVersion($node->nodeValue))) { $this->_versionTag = $vers_tag . "\n"; break; } - $node = $node->next_sibling(); + $node = $node->nextSibling; } /* Parse the config file. */ $this->_xmlConfigTree = array(); - $root = $doc->root(); - if ($root->has_child_nodes()) { - $this->_parseLevel($this->_xmlConfigTree, $root->child_nodes(), ''); + $root = $dom->documentElement; + if ($root->hasChildNodes()) { + $this->_parseLevel($this->_xmlConfigTree, $root->childNodes, ''); } return $this->_xmlConfigTree; @@ -353,31 +353,31 @@ class Horde_Config * Parses one level of the configuration XML tree into the associative * array containing the traversed configuration tree. * - * @param array &$conf The already existing array where the processed - * XML tree portion should be appended to. - * @param array $children An array containing the XML nodes of the level - * that should be parsed. - * @param string $ctx A string representing the current position - * (context prefix) inside the configuration XML - * file. + * @param array &$conf The already existing array where the + * processed XML tree portion should be + * appended to. + * @param DOMNodeList $children The XML nodes of the level that should + * be parsed. + * @param string $ctx A string representing the current + * position (context prefix) inside the + * configuration XML file. */ protected function _parseLevel(&$conf, $children, $ctx) { - reset($children); - while (list(,$node) = each($children)) { - if ($node->type != XML_ELEMENT_NODE) { + foreach ($children as $node) { + if ($node->nodeType != XML_ELEMENT_NODE) { continue; } - $name = $node->get_attribute('name'); - $desc = Horde_Text_Filter::filter($node->get_attribute('desc'), 'linkurls', array('callback' => 'Horde::externalUrl')); - $required = !($node->get_attribute('required') == 'false'); - $quote = !($node->get_attribute('quote') == 'false'); + $name = $node->getAttribute('name'); + $desc = Horde_Text_Filter::filter($node->getAttribute('desc'), 'linkurls', array('callback' => 'Horde::externalUrl')); + $required = !($node->getAttribute('required') == 'false'); + $quote = !($node->getAttribute('quote') == 'false'); $curctx = empty($ctx) ? $name : $ctx . '|' . $name; - switch ($node->tagname) { + switch ($node->tagName) { case 'configdescription': if (empty($name)) { $name = hash('md5', uniqid(mt_rand(), true)); @@ -530,7 +530,7 @@ class Horde_Config 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node)) ); - if ($node->get_attribute('octal') == 'true' && + if ($node->getAttribute('octal') == 'true' && $conf[$name]['default'] != '') { $conf[$name]['_type'] = 'octal'; $conf[$name]['default'] = sprintf('0%o', $this->_default($curctx, octdec($this->_getNodeOnlyText($node)))); @@ -538,7 +538,7 @@ class Horde_Config break; case 'configldap': - $conf[$node->get_attribute('switchname')] = $this->_configLDAP($ctx, $node); + $conf[$node->getAttribute('switchname')] = $this->_configLDAP($ctx, $node); break; case 'configphp': @@ -563,18 +563,18 @@ class Horde_Config break; case 'configsql': - $conf[$node->get_attribute('switchname')] = $this->_configSQL($ctx, $node); + $conf[$node->getAttribute('switchname')] = $this->_configSQL($ctx, $node); break; case 'configvfs': - $conf[$node->get_attribute('switchname')] = $this->_configVFS($ctx, $node); + $conf[$node->getAttribute('switchname')] = $this->_configVFS($ctx, $node); break; case 'configsection': $conf[$name] = array(); $cur = &$conf[$name]; - if ($node->has_child_nodes()) { - $this->_parseLevel($cur, $node->child_nodes(), $curctx); + if ($node->hasChildNodes()) { + $this->_parseLevel($cur, $node->childNodes, $curctx); } break; @@ -586,8 +586,8 @@ class Horde_Config 'desc' => $desc ); - if ($node->has_child_nodes()) { - $this->_parseLevel($conf, $node->child_nodes(), $ctx); + if ($node->hasChildNodes()) { + $this->_parseLevel($conf, $node->childNodes, $ctx); } break; @@ -598,8 +598,8 @@ class Horde_Config default: $conf[$name] = array(); $cur = &$conf[$name]; - if ($node->has_child_nodes()) { - $this->_parseLevel($cur, $node->child_nodes(), $curctx); + if ($node->hasChildNodes()) { + $this->_parseLevel($cur, $node->childNodes, $curctx); } break; } @@ -721,12 +721,12 @@ class Horde_Config 'writedn' => $writedn, 'ca' => $ca ); - - if (isset($node) && $node->get_attribute('baseconfig') == 'true') { + + if (isset($node) && $node->getAttribute('baseconfig') == 'true') { return $custom_fields; } - list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->get_attribute('switchname') : $switchname), 'horde'); + list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde'); $config = array( 'desc' => 'Driver configuration', 'default' => $default, @@ -743,9 +743,9 @@ class Horde_Config ) ); - if (isset($node) && $node->has_child_nodes()) { + if (isset($node) && $node->hasChildNodes()) { $cur = array(); - $this->_parseLevel($cur, $node->child_nodes(), $ctx); + $this->_parseLevel($cur, $node->childNodes, $ctx); $config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur); $config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur); } @@ -1160,11 +1160,11 @@ class Horde_Config ) ); - if (isset($node) && $node->get_attribute('baseconfig') == 'true') { + if (isset($node) && $node->getAttribute('baseconfig') == 'true') { return $custom_fields; } - list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->get_attribute('switchname') : $switchname), 'horde'); + list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde'); $config = array( 'desc' => 'Driver configuration', 'default' => $default, @@ -1183,9 +1183,9 @@ class Horde_Config ) ); - if (isset($node) && $node->has_child_nodes()) { + if (isset($node) && $node->hasChildNodes()) { $cur = array(); - $this->_parseLevel($cur, $node->child_nodes(), $ctx); + $this->_parseLevel($cur, $node->childNodes, $ctx); $config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur); $config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur); } @@ -1208,9 +1208,9 @@ class Horde_Config protected function _configVFS($ctx, $node) { $sql = $this->_configSQL($ctx . '|params'); - $default = $node->get_attribute('default'); + $default = $node->getAttribute('default'); $default = empty($default) ? 'horde' : $default; - list($default, $isDefault) = $this->__default($ctx . '|' . $node->get_attribute('switchname'), $default); + list($default, $isDefault) = $this->__default($ctx . '|' . $node->getAttribute('switchname'), $default); $config = array( 'desc' => 'What VFS driver should we use?', @@ -1244,7 +1244,7 @@ class Horde_Config ) ); - if (isset($node) && $node->get_attribute('baseconfig') != 'true') { + if (isset($node) && $node->getAttribute('baseconfig') != 'true') { $config['switch']['horde'] = array( 'desc' => 'Horde defaults', 'fields' => array() @@ -1409,13 +1409,13 @@ class Horde_Config { $text = ''; - if (!$node->has_child_nodes()) { - return $node->get_content(); + if (!$node->hasChildNodes()) { + return $node->textContent; } - foreach ($node->child_nodes() as $tnode) { - if ($tnode->type == XML_TEXT_NODE) { - $text .= $tnode->content; + foreach ($node->childNodes as $tnode) { + if ($tnode->nodeType == XML_TEXT_NODE) { + $text .= $tnode->textContent; } } @@ -1438,24 +1438,24 @@ class Horde_Config { $values = array(); - if (!$node->has_child_nodes()) { + if (!$node->hasChildNodes()) { return $values; } - foreach ($node->child_nodes() as $vnode) { - if ($vnode->type == XML_ELEMENT_NODE && - $vnode->tagname == 'values') { - if (!$vnode->has_child_nodes()) { + foreach ($node->childNodes as $vnode) { + if ($vnode->nodeType == XML_ELEMENT_NODE && + $vnode->tagName == 'values') { + if (!$vnode->hasChildNodes()) { return array(); } - foreach ($vnode->child_nodes() as $value) { - if ($value->type == XML_ELEMENT_NODE) { - if ($value->tagname == 'configspecial') { + foreach ($vnode->childNodes as $value) { + if ($value->nodeType == XML_ELEMENT_NODE) { + if ($value->tagName == 'configspecial') { return $this->_handleSpecials($value); - } elseif ($value->tagname == 'value') { - $text = $value->get_content(); - $desc = $value->get_attribute('desc'); + } elseif ($value->tagName == 'value') { + $text = $value->textContent; + $desc = $value->getAttribute('desc'); $values[$text] = empty($desc) ? $text : $desc; } } @@ -1479,19 +1479,19 @@ class Horde_Config { $values = array(); - if (!$node->has_child_nodes()) { + if (!$node->hasChildNodes()) { return $values; } - foreach ($node->child_nodes() as $case) { - if ($case->type == XML_ELEMENT_NODE) { - $name = $case->get_attribute('name'); + foreach ($node->childNodes as $case) { + if ($case->nodeType == XML_ELEMENT_NODE) { + $name = $case->getAttribute('name'); $values[$name] = array( - 'desc' => $case->get_attribute('desc'), + 'desc' => $case->getAttribute('desc'), 'fields' => array() ); - if ($case->has_child_nodes()) { - $this->_parseLevel($values[$name]['fields'], $case->child_nodes(), $curctx); + if ($case->hasChildNodes()) { + $this->_parseLevel($values[$name]['fields'], $case->childNodes, $curctx); } } } @@ -1510,7 +1510,7 @@ class Horde_Config */ protected function _handleSpecials($node) { - switch ($node->get_attribute('name')) { + switch ($node->getAttribute('name')) { case 'list-horde-apps': $apps = Horde_Array::valuesToKeys($GLOBALS['registry']->listApps(array('hidden', 'notoolbar', 'active'))); asort($apps); diff --git a/framework/Core/package.xml b/framework/Core/package.xml index 7be9a426d..6dd556097 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -37,7 +37,8 @@ Application Framework. beta LGPL - * Added Horde_Registry_Api:: and Horde_Registry_Application:: classes. + * Remove dependency on Horde_DOM package. + * Added Horde_Registry_Api:: and Horde_Registry_Application:: classes. * Moved Horde_Exception to Exception package. * Renamed Menu:: as Horde_Menu::. * Renamed Help:: as Horde_Help::. @@ -112,10 +113,6 @@ Application Framework. pear.horde.org - DOM - pear.horde.org - - Exception pear.horde.org diff --git a/framework/DOM/DOM.php b/framework/DOM/DOM.php deleted file mode 100644 index a711e52ab..000000000 --- a/framework/DOM/DOM.php +++ /dev/null @@ -1,587 +0,0 @@ - - * @author Michael J. Rubinsky - * @package Horde_DOM - */ - -/** Validate against the DTD */ -define('HORDE_DOM_LOAD_VALIDATE', 1); - -/** Recover from load errors */ -define('HORDE_DOM_LOAD_RECOVER', 2); - -/** Remove redundant whitespace */ -define('HORDE_DOM_LOAD_REMOVE_BLANKS', 4); - -/** Substitute XML entities */ -define('HORDE_DOM_LOAD_SUBSTITUTE_ENTITIES', 8); - -class Horde_DOM_Document extends Horde_DOM_Node { - - /** - * Creates an appropriate object based on the version of PHP that is - * running and the requested xml source. This function should be passed an - * array containing either 'filename' => $filename | 'xml' => $xmlstring - * depending on the source of the XML document. - * - * You can pass an optional 'options' parameter to enable extra - * features like DTD validation or removal of whitespaces. - * For a list of available features see the HORDE_DOM_LOAD defines. - * Multiple options are added by bitwise OR. - * - * @param array $params Array containing either 'filename' | 'xml' keys. - * You can specify an optional 'options' key. - * - * @return mixed Horde_DOM_Document | PEAR_Error - */ - function factory($params = array()) - { - if (!isset($params['options'])) { - $params['options'] = 0; - } - - $doc = new Horde_DOM_Document($params); - if (isset($doc->error)) { - return $doc->error; - } - - return $doc; - } - - /** - * Constructor. Determine if we are trying to load a file or xml string - * based on the parameters. - * - * @param array $params Array with key 'filename' | 'xml' - */ - function Horde_DOM_Document($params = array()) - { - $this->node = new DOMDocument(); - - // Load mode - if ($params['options'] & HORDE_DOM_LOAD_VALIDATE) { - $this->node->validateOnParse = true; - } elseif ($params['options'] & HORDE_DOM_LOAD_RECOVER) { - $this->node->recover = true; - } - - // Load options - if ($params['options'] & HORDE_DOM_LOAD_REMOVE_BLANKS) { - $this->node->preserveWhiteSpace = false; - } - if ($params['options'] & HORDE_DOM_LOAD_SUBSTITUTE_ENTITIES) { - $this->node->substituteEntities = true; - } - - if (isset($params['xml'])) { - $result = @$this->node->loadXML($params['xml']); - if (!$result) { - $this->error = PEAR::raiseError('Failed loading XML document.'); - return; - } - } elseif (isset($params['filename'])) { - $this->node->load($params['filename']); - } - $this->document = $this; - } - - /** - * Return the root document element. - */ - function root() - { - return new Horde_DOM_Element($this->node->documentElement, $this); - } - - /** - * Return the document element. - */ - function document_element() - { - return $this->root(); - } - - /** - * Return the node represented by the requested tagname. - * - * @param string $name The tagname requested. - * - * @return array The nodes matching the tag name - */ - function get_elements_by_tagname($name) - { - $list = $this->node->getElementsByTagName($name); - $nodes = array(); - $i = 0; - if (isset($list)) { - while ($node = $list->item($i)) { - $nodes[] = $this->_newDOMElement($node, $this); - ++$i; - } - return $nodes; - } - } - - /** - * Return the document as a text string. - * - * @param bool $format Specifies whether the output should be - * neatly formatted, or not - * @param string $encoding Sets the encoding attribute in line - * - * - * @return string The xml document as a string - */ - function dump_mem($format = false, $encoding = false) - { - $format0 = $this->node->formatOutput; - $this->node->formatOutput = $format; - - $encoding0 = $this->node->encoding; - if ($encoding) { - $this->node->encoding=$encoding; - } - - $dump = $this->node->saveXML(); - - $this->node->formatOutput = $format0; - - // UTF-8 is the default encoding for XML. - if ($encoding) { - $this->node->encoding = $encoding0 == '' ? 'UTF-8' : $encoding0; - } - - return $dump; - } - - /** - * Create a new element for this document - * - * @param string $name Name of the new element - * - * @return Horde_DOM_Element New element - */ - function create_element($name) - { - return new Horde_DOM_Element($this->node->createElement($name), $this); - } - - /** - * Create a new text node for this document - * - * @param string $content The content of the text element - * - * @return Horde_DOM_Node New node - */ - function create_text_node($content) - { - return new Horde_DOM_Text($this->node->createTextNode($content), $this); - } - - /** - * Create a new attribute for this document - * - * @param string $name The name of the attribute - * @param string $value The value of the attribute - * - * @return Horde_DOM_Attribute New attribute - */ - function create_attribute($name, $value) - { - $attr = $this->node->createAttribute($name); - $attr->value = $value; - return new Horde_DOM_Attribute($attr, $this); - } - - function xpath_new_context() - { - return Horde_DOM_XPath::factory($this->node); - } -} - -/** - * @package Horde_DOM - */ -class Horde_DOM_Node { - - var $node; - var $document; - - /** - * Wrap a DOMNode into the Horde_DOM_Node class. - * - * @param DOMNode $node The DOMXML node - * @param Horde_DOM_Document $document The parent document - * - * @return Horde_DOM_Node The wrapped node - */ - function Horde_DOM_Node($domNode, $domDocument = null) - { - $this->node = $domNode; - $this->document = $domDocument; - } - - function __get($name) - { - switch ($name) { - case 'type': - return $this->node->nodeType; - - case 'tagname': - return $this->node->tagName; - - case 'content': - return $this->node->textContent; - - default: - return false; - } - } - - /** - * Set the content of this node. - * - * @param string $text The new content of this node. - * - * @return DOMNode The modified node. - */ - function set_content($text) - { - return $this->node->appendChild($this->node->ownerDocument->createTextNode($text)); - } - - /** - * Return the type of this node. - * - * @return integer Type of this node. - */ - function node_type() - { - return $this->node->nodeType; - } - - function child_nodes() - { - $nodes = array(); - - $nodeList = $this->node->childNodes; - if (isset($nodeList)) { - $i = 0; - while ($node = $nodeList->item($i)) { - $nodes[] = $this->_newDOMElement($node, $this->document); - ++$i; - } - } - - return $nodes; - } - - /** - * Return the attributes of this node. - * - * @return array Attributes of this node. - */ - function attributes() - { - $attributes = array(); - - $attrList = $this->node->attributes; - if (isset($attrList)) { - $i = 0; - while ($attribute = $attrList->item($i)) { - $attributes[] = new Horde_DOM_Attribute($attribute, $this->document); - ++$i; - } - } - - return $attributes; - } - - function first_child() - { - return $this->_newDOMElement($this->node->firstChild, $this->document); - } - - /** - * Return the content of this node. - * - * @return string Text content of this node. - */ - function get_content() - { - return $this->node->textContent; - } - - function has_child_nodes() - { - return $this->node->hasChildNodes(); - } - - function next_sibling() - { - if ($this->node->nextSibling === null) { - return null; - } - - return $this->_newDOMElement($this->node->nextSibling, $this->document); - } - - function node_value() - { - return $this->node->nodeValue; - } - - function node_name() - { - if ($this->node->nodeType == XML_ELEMENT_NODE) { - return $this->node->localName; - } else { - return $this->node->nodeName; - } - } - - function clone_node() - { - return new Horde_DOM_Node($this->node->cloneNode()); - } - - /** - * Append a new node - * - * @param Horde_DOM_Node $newnode The child to be added - * - * @return Horde_DOM_Node The resulting node - */ - function append_child($newnode) - { - return $this->_newDOMElement($this->node->appendChild($this->_importNode($newnode)), $this->document); - } - - /** - * Remove a child node - * - * @param Horde_DOM_Node $oldchild The child to be removed - * - * @return Horde_DOM_Node The resulting node - */ - function remove_child($oldchild) - { - return $this->_newDOMElement($this->node->removeChild($oldchild->node), $this->document); - } - - /** - * Return a node of this class type. - * - * @param DOMNode $node The DOMXML node - * @param Horde_DOM_Document $document The parent document - * - * @return Horde_DOM_Node The wrapped node - */ - function _newDOMElement($node, $document) - { - if ($node == null) { - return null; - } - - switch ($node->nodeType) { - case XML_ELEMENT_NODE: - return new Horde_DOM_Element($node, $document); - case XML_TEXT_NODE: - return new Horde_DOM_Text($node, $document); - case XML_ATTRIBUTE_NODE: - return new Horde_DOM_Attribute($node, $document); - // case XML_PI_NODE: - // return new Horde_DOM_ProcessingInstruction($node, $document); - default: - return new Horde_DOM_Node($node, $document); - } - } - - /** - * Private function to import DOMNode from another DOMDocument. - * - * @param Horde_DOM_Node $newnode The node to be imported - * - * @return Horde_DOM_Node The wrapped node - */ - function _importNode($newnode) - { - if ($this->document === $newnode->document) { - return $newnode->node; - } else { - return $this->document->node->importNode($newnode->node, true); - } - } - -} - -/** - * @package Horde_DOM - */ -class Horde_DOM_Element extends Horde_DOM_Node { - - /** - * Get the value of specified attribute. - * - * @param string $name Name of the attribute - * - * @return string Indicates if the attribute was set. - */ - function get_attribute($name) - { - return $this->node->getAttribute($name); - } - - /** - * Determine if an attribute of this name is present on the node. - * - * @param string $name Name of the attribute - * - * @return bool Indicates if such an attribute is present. - */ - function has_attribute($name) - { - return $this->node->hasAttribute($name); - } - - /** - * Set the specified attribute on this node. - * - * @param string $name Name of the attribute - * @param string $value The new value of this attribute. - * - * @return mixed Indicates if the attribute was set. - */ - function set_attribute($name, $value) - { - return $this->node->setAttribute($name, $value); - } - - /** - * Return the node represented by the requested tagname. - * - * @param string $name The tagname requested. - * - * @return array The nodes matching the tag name - */ - function get_elements_by_tagname($name) - { - $list = $this->node->getElementsByTagName($name); - $nodes = array(); - $i = 0; - if (isset($list)) { - while ($node = $list->item($i)) { - $nodes[] = $this->_newDOMElement($node, $this->document); - $i++; - } - } - - return $nodes; - } - -} - -/** - * @package Horde_DOM - */ -class Horde_DOM_Attribute extends Horde_DOM_Node { - - /** - * Return a node of this class type. - * - * @param DOMNode $node The DOMXML node - * @param Horde_DOM_Document $document The parent document - * - * @return Horde_DOM_Attribute The wrapped attribute - */ - function _newDOMElement($node, $document) - { - return new Horde_DOM_Attribute($node, $document); - } - -} - -/** - * @package Horde_DOM - */ -class Horde_DOM_Text extends Horde_DOM_Node { - - function __get($name) - { - if ($name == 'tagname') { - return '#text'; - } else { - return parent::__get($name); - } - } - - function tagname() - { - return '#text'; - } - - /** - * Set the content of this node. - * - * @param string $text The new content of this node. - */ - function set_content($text) - { - $this->node->nodeValue = $text; - } - -} - -/** - * @package Horde_DOM - */ -class Horde_DOM_XPath { - - /** - * @var DOMXPath - */ - var $_xpath; - - function factory($dom) - { - return new Horde_DOM_XPath($dom); - } - - function Horde_DOM_XPath($dom) - { - $this->_xpath = new DOMXPath($dom); - } - - function xpath_register_ns($prefix, $uri) - { - $this->_xpath->registerNamespace($prefix, $uri); - } - - function xpath_eval($expression, $context = null) - { - if (is_null($context)) { - $nodeset = $this->_xpath->query($expression); - } else { - $nodeset = $this->_xpath->query($expression, $context); - } - $result = new stdClass(); - $result->nodeset = array(); - for ($i = 0; $i < $nodeset->length; $i++) { - $result->nodeset[] = new Horde_DOM_Element($nodeset->item($i)); - } - return $result; - } - -} diff --git a/framework/DOM/package.xml b/framework/DOM/package.xml deleted file mode 100644 index b62beb3fa..000000000 --- a/framework/DOM/package.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - DOM - pear.horde.org - Wrapper classes for PHP4 domxml compatibility using PHP5's dom functions. - These classes allow the use of code written for PHP4's domxml -implementation to work using PHP5's dom implementation. - - - Chuck Hagenbuch - chuck - chuck@horde.org - yes - - - Jan Schneider - jan - jan@horde.org - yes - - - Michael Rubinsky - mrubinsk - mrubinsk@horde.org - yes - - 2008-12-31 - - 0.2.0 - 0.2.0 - - - beta - beta - - LGPL - * Add Horde_DOM_Text class. -* Add Horde_DOM_XPath class for XPath wrapping. -* Return correct object types when iterating through child nodes. -* Pass unit test with PHP 4. - - - - - - - - - 4.0.0 - - - 1.4.0b1 - - - - - - - - 0.1.0 - 0.1.0 - - - alpha - alpha - - 2008-01-21 - LGPL - * Allow creation of empty documents -* Add Horde_DOM_Document::document_element() -* Add Horde_DOM_Node::clone_node() -* Add configuration options (Request #5370, Thomas Jarosch <thomas.jarosch@intra2net.com>) - - - - 0.0.2 - 0.0.2 - - - alpha - alpha - - 2006-05-08 - LGPL - * Converted to package.xml 2.0 for pear.horde.org - - - - 0.0.1 - 0.0.1 - - - alpha - alpha - - 2006-01-30 - LGPL - Move out of Horde_Config and added DOM_Node::getElementsByTagName, -and DOM_Node::Node_Name methods. - - - - diff --git a/framework/DOM/tests/dom_load_error.phpt b/framework/DOM/tests/dom_load_error.phpt deleted file mode 100644 index 9116d5fb6..000000000 --- a/framework/DOM/tests/dom_load_error.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Check that Horde::DOM handles load errors gracefully. ---FILE-- - $xml, 'options' => HORDE_DOM_LOAD_REMOVE_BLANKS); - -$dom = Horde_DOM_Document::factory($params); - -// Check that the xml loading elicits an error -var_dump(is_a($dom, 'PEAR_Error')); - -// Load XML -$xml = file_get_contents(dirname(__FILE__) . '/fixtures/load_ok.xml'); - -$params = array('xml' => $xml, 'options' => HORDE_DOM_LOAD_REMOVE_BLANKS); - -$dom = Horde_DOM_Document::factory($params); - -// Check that the xml loading elicits an error -var_dump(is_a($dom, 'PEAR_Error')); - ---EXPECT-- -bool(true) -bool(false) diff --git a/framework/DOM/tests/fixtures/load_error.xml b/framework/DOM/tests/fixtures/load_error.xml deleted file mode 100644 index 50e397eb9..000000000 --- a/framework/DOM/tests/fixtures/load_error.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 0 - Abständen führen wirþedback - diff --git a/framework/DOM/tests/fixtures/load_ok.xml b/framework/DOM/tests/fixtures/load_ok.xml deleted file mode 100644 index 42d0bf2ad..000000000 --- a/framework/DOM/tests/fixtures/load_ok.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 0 - Abständen führen wir Feedback - diff --git a/horde/admin/setup/index.php b/horde/admin/setup/index.php index 5caf6bb8f..bfd992425 100644 --- a/horde/admin/setup/index.php +++ b/horde/admin/setup/index.php @@ -66,23 +66,22 @@ if (Horde_Util::getFormData('check_versions')) { } elseif ($http->getResponseCode() != 200) { $notification->push(_("Unexpected response from server, try again later."), 'horde.error'); } else { - $dom = Horde_DOM_Document::factory(array('xml' => $http->getResponseBody())); - $stable = $dom->get_elements_by_tagname('stable'); - if (!count($stable) || !$stable[0]->has_child_nodes()) { + $dom = DOMDocument::loadXML($http->getResponseBody()); + $stable = $dom->getElementsByTagName('stable'); + if (!count($stable) || !$stable[0]->hasChildNodes()) { $notification->push(_("Invalid response from server."), 'horde.error'); } else { - for ($app = $stable[0]->first_child(); + for ($app = $stable[0]->firstChild; !empty($app); - $app = $app->next_sibling()) { - if (!is_a($app, 'domelement') && - !is_a($app, 'Horde_DOM_Element')) { + $app = $app->nextSibling) { + if (!($app instanceof DOMElement)) { continue; } - $version = $app->get_elements_by_tagname('version'); - $url = $app->get_elements_by_tagname('url'); - $versions[$app->get_attribute('name')] = array( - 'version' => $version[0]->get_content(), - 'url' => $url[0]->get_content()); + $version = $app->getElementsByTagName('version'); + $url = $app->getElementsByTagName('url'); + $versions[$app->getAttribute('name')] = array( + 'version' => $version[0]->textContent, + 'url' => $url[0]->textContent); } } } diff --git a/horde/po/translation.php b/horde/po/translation.php index 0df7212b4..f94ed46e2 100755 --- a/horde/po/translation.php +++ b/horde/po/translation.php @@ -1204,69 +1204,75 @@ function update_help() if (preg_match('/encoding=(["\'])([^\\1]+)\\1/', $line, $match)) { $encoding = $match[2]; } - $doc_en = Horde_DOM_Document::factory(array('filename' => $file_en)); - if (!is_object($doc_en)) { + + if (!($doc_en = DOMDocument::load($file_en))) { $c->message(sprintf('There was an error opening the file %s. Try running translation.php with the flag -d to see any error messages from the xml parser.', $file_en), 'cli.warning'); $c->writeln(); continue 2; } - $doc_loc = Horde_DOM_Document::factory(array('filename' => $file_loc)); - if (!is_object($doc_loc)) { + + if (!($doc_loc = DOMDocument::load($file_loc))) { $c->message(sprintf('There was an error opening the file %s. Try running translation.php with the flag -d to see any error messages from the xml parser.', $file_loc), 'cli.warning'); $c->writeln(); continue; } - $doc_new = Horde_DOM_Document::factory(); - $help_en = $doc_en->document_element(); - $help_loc = $doc_loc->document_element(); - $help_new = $help_loc->clone_node(); + $doc_new = new DOMDocument(); + $help_en = $doc_en->documentElement; + $help_loc = $doc_loc->documentElement; + $help_new = $help_loc->cloneNode(); $entries_loc = array(); $entries_new = array(); $count_uptodate = 0; $count_new = 0; $count_changed = 0; $count_unknown = 0; - foreach ($doc_loc->get_elements_by_tagname('entry') as $entry) { - $entries_loc[$entry->get_attribute('id')] = $entry; + foreach ($doc_loc->getElementsByTagName('entry') as $entry) { + $entries_loc[$entry->getAttribute('id')] = $entry; } - foreach ($doc_en->get_elements_by_tagname('entry') as $entry) { - $id = $entry->get_attribute('id'); + foreach ($doc_en->getElementsByTagName('entry') as $entry) { + $id = $entry->getAttribute('id'); if (array_key_exists($id, $entries_loc)) { - if ($entries_loc[$id]->has_attribute('md5') && - md5($entry->get_content()) != $entries_loc[$id]->get_attribute('md5')) { + if ($entries_loc[$id]->hasAttribute('md5') && + md5($entry->textContent) != $entries_loc[$id]->getAttribute('md5')) { $comment = $doc_loc->create_comment(" English entry:\n" . str_replace('--', '--', $doc_loc->dump_node($entry))); - $entries_loc[$id]->append_child($comment); - $entry_new = $entries_loc[$id]->clone_node(true); - $entry_new->set_attribute('state', 'changed'); + $entries_loc[$id]->appendChild($comment); + $entry_new = $entries_loc[$id]->cloneNode(true); + $entry_new->setAttribute('state', 'changed'); $count_changed++; } else { - if (!$entries_loc[$id]->has_attribute('state')) { + if (!$entries_loc[$id]->hasAttribute('state')) { $comment = $doc_loc->create_comment(" English entry:\n" . str_replace('--', '--', $doc_loc->dump_node($entry))); - $entries_loc[$id]->append_child($comment); - $entry_new = $entries_loc[$id]->clone_node(true); - $entry_new->set_attribute('state', 'unknown'); + $entries_loc[$id]->appendChild($comment); + $entry_new = $entries_loc[$id]->cloneNode(true); + $entry_new->setAttribute('state', 'unknown'); $count_unknown++; } else { - $entry_new = $entries_loc[$id]->clone_node(true); + $entry_new = $entries_loc[$id]->cloneNode(true); $count_uptodate++; } } } else { - $entry_new = $entry->clone_node(true); - $entry_new->set_attribute('state', 'new'); + $entry_new = $entry->cloneNode(true); + $entry_new->setAttribute('state', 'new'); $count_new++; } $entries_new[] = $entry_new; } - $doc_new->append_child($doc_new->create_comment(' $' . 'Horde$ ')); + $doc_new->appendChild($doc_new->create_comment(' $' . 'Horde$ ')); foreach ($entries_new as $entry) { - $help_new->append_child($entry); + $help_new->appendChild($entry); } $c->writeln(wordwrap(sprintf('Entries: %d total, %d up-to-date, %d new, %d changed, %d unknown', $count_uptodate + $count_new + $count_changed + $count_unknown, $count_uptodate, $count_new, $count_changed, $count_unknown))); - $doc_new->append_child($help_new); - $output = $doc_new->dump_mem(true, $encoding); + $doc_new->appendChild($help_new); + + $doc_new->formatoutput = true; + if ($encoding) { + $doc_new->encoding = $encoding; + } + $output = $doc_new->savexml(); + if ($debug || $test) { $c->writeln(wordwrap(sprintf('Writing updated help file to %s.', $file_loc))); } @@ -1344,46 +1350,51 @@ function make_help() if (preg_match('/encoding=(["\'])([^\\1]+)\\1/', $line, $match)) { $encoding = $match[2]; } - $doc_en = Horde_DOM_Document::factory(array('filename' => $file_en)); - if (!is_object($doc_en)) { + + if (!($doc_en = DOMDocument::load($file_en))) { $c->message(sprintf('There was an error opening the file %s. Try running translation.php with the flag -d to see any error messages from the xml parser.', $file_en), 'cli.warning'); $c->writeln(); continue 2; } - $doc_loc = Horde_DOM_Document::factory(array('filename' => $file_loc)); - if (!is_object($doc_loc)) { + + if (!($doc_loc = DOMDocument::load($file_loc))) { $c->message(sprintf('There was an error opening the file %s. Try running translation.php with the flag -d to see any error messages from the xml parser.', $file_loc), 'cli.warning'); $c->writeln(); continue; } - $help_loc = $doc_loc->document_element(); + $help_loc = $doc_loc->documentElement; $md5_en = array(); $count_all = 0; $count = 0; - foreach ($doc_en->get_elements_by_tagname('entry') as $entry) { - $md5_en[$entry->get_attribute('id')] = md5($entry->get_content()); - } - foreach ($doc_loc->get_elements_by_tagname('entry') as $entry) { - foreach ($entry->child_nodes() as $child) { - if ($child->node_type() == XML_COMMENT_NODE && strstr($child->node_value(), 'English entry')) { - $entry->remove_child($child); + foreach ($doc_en->getElementsByTagName('entry') as $entry) { + $md5_en[$entry->getAttribute('id')] = md5($entry->textContent); + } + foreach ($doc_loc->getElementsByTagName('entry') as $entry) { + foreach ($entry->childNodes as $child) { + if ($child->nodeType == XML_COMMENT_NODE && + strstr($child->nodeValue, 'English entry')) { + $entry->removeChild($child); } } $count_all++; - $id = $entry->get_attribute('id'); + $id = $entry->getAttribute('id'); if (!array_key_exists($id, $md5_en)) { $c->message(sprintf('No entry with the id "%s" exists in the original help file.', $id), 'cli.warning'); } else { - $entry->set_attribute('md5', $md5_en[$id]); - $entry->set_attribute('state', 'uptodate'); + $entry->setAttribute('md5', $md5_en[$id]); + $entry->setAttribute('state', 'uptodate'); $count++; } } - $output = $doc_loc->dump_mem(true, $encoding); + + $doc_loc->formatoutput = true; + if ($encoding) { + $doc_loc->encoding = $encoding; + } + $output = $doc_loc->savexml(); + if (!$test) { - $fp = fopen($file_loc, 'w'); - $line = fwrite($fp, $output); - fclose($fp); + file_put_contents($file_loc, $output); } $c->writeln(sprintf('%d of %d entries marked as up-to-date', $count, $count_all)); $c->writeln();