]> granicus.if.org Git - php/commitdiff
@- old $node->append_child() is now $node->append_sibling(), since
authorChristian Stocker <chregu@php.net>
Sat, 13 Apr 2002 10:23:46 +0000 (10:23 +0000)
committerChristian Stocker <chregu@php.net>
Sat, 13 Apr 2002 10:23:46 +0000 (10:23 +0000)
@  new append_child() now behaves like excepted (= W3C standard) (chregu, uwe)

ext/domxml/php_domxml.c
ext/domxml/php_domxml.h

index f331e6e272c7840a3d6b560eb51f5187f85265df..47bda16548fab5f001499dfd037e422a051f3df3 100644 (file)
@@ -326,6 +326,7 @@ static zend_function_entry php_domxmlnode_class_functions[] = {
        PHP_FALIAS(parent,                                      domxml_node_parent,                             NULL)
        PHP_FALIAS(parent_node,                         domxml_node_parent,                             NULL)
        PHP_FALIAS(insert_before,                       domxml_node_insert_before,              NULL)
+       PHP_FALIAS(append_sibling,                      domxml_node_append_sibling,             NULL)
        PHP_FALIAS(append_child,                        domxml_node_append_child,               NULL)
        PHP_FALIAS(remove_child,                        domxml_node_remove_child,               NULL)
        PHP_FALIAS(owner_document,                      domxml_node_owner_document,             NULL)
@@ -2058,6 +2059,44 @@ PHP_FUNCTION(domxml_node_append_child)
 }
 /* }}} */
 
+/* {{{ proto object domxml_node_append_sibling(object domnode)
+   Adds node to list of siblings */
+PHP_FUNCTION(domxml_node_append_sibling)
+{
+       zval *id, *rv, *node;
+       xmlNodePtr child, nodep, new_child;
+       int ret;
+
+       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
+               return;
+       }
+
+       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
+
+       if (child->type == XML_ATTRIBUTE_NODE) {
+               php_error(E_WARNING, "%s(): can't append attribute node", get_active_function_name(TSRMLS_C));
+               RETURN_FALSE;
+       }
+
+       if (NULL == (new_child = xmlCopyNode(child, 1))) {
+               php_error(E_WARNING, "%s(): unable to clone node", get_active_function_name(TSRMLS_C));
+               RETURN_FALSE;
+       }
+
+       // FIXME reverted xmlAddChildList; crashes
+       child = xmlAddSibling(nodep, new_child);
+
+       if (NULL == child) {
+               php_error(E_WARNING, "%s(): couldn't append node", get_active_function_name(TSRMLS_C));
+               RETURN_FALSE;
+       }
+
+       DOMXML_RET_OBJ(rv, child, &ret);
+}
+/* }}} */
+
 /* {{{ proto object domxml_node_insert_before(object newnode, object refnode)
    Adds node in list of nodes before given node */
 PHP_FUNCTION(domxml_node_insert_before)
index b48374a4309f2e11f8d1dd662cc079c75e3915c0..8da31fdc36169bd1b583e5aee7112bdb3d033292 100644 (file)
@@ -108,6 +108,7 @@ PHP_FUNCTION(domxml_node_next_sibling);
 PHP_FUNCTION(domxml_node_previous_sibling);
 PHP_FUNCTION(domxml_node_owner_document);
 PHP_FUNCTION(domxml_node_insert_before);
+PHP_FUNCTION(domxml_node_append_sibling);
 PHP_FUNCTION(domxml_node_append_child);
 PHP_FUNCTION(domxml_node_remove_child);
 PHP_FUNCTION(domxml_node_add_child);