diff options
author | Christian Stocker <chregu@php.net> | 2002-04-13 10:23:46 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2002-04-13 10:23:46 +0000 |
commit | 67292ee205e17db603827c02b2d26c07f9f4416c (patch) | |
tree | 16c7e17cab2a655b8dace8caedfec6bcb7089a45 | |
parent | 83719f5cd8ac008683c9c29f80b9cd7d4c2d1212 (diff) | |
download | php-git-67292ee205e17db603827c02b2d26c07f9f4416c.tar.gz |
@- old $node->append_child() is now $node->append_sibling(), since
@ new append_child() now behaves like excepted (= W3C standard) (chregu, uwe)
-rw-r--r-- | ext/domxml/php_domxml.c | 39 | ||||
-rw-r--r-- | ext/domxml/php_domxml.h | 1 |
2 files changed, 40 insertions, 0 deletions
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); |