From: Christian Stocker Date: Sat, 13 Apr 2002 10:23:46 +0000 (+0000) Subject: @- old $node->append_child() is now $node->append_sibling(), since X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~665 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67292ee205e17db603827c02b2d26c07f9f4416c;p=php @- old $node->append_child() is now $node->append_sibling(), since @ new append_child() now behaves like excepted (= W3C standard) (chregu, uwe) --- diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index f331e6e272..47bda16548 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -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) diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h index b48374a430..8da31fdc36 100644 --- a/ext/domxml/php_domxml.h +++ b/ext/domxml/php_domxml.h @@ -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);