summaryrefslogtreecommitdiff
path: root/ext/domxml/php_domxml.c
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2002-04-13 10:23:46 +0000
committerChristian Stocker <chregu@php.net>2002-04-13 10:23:46 +0000
commit67292ee205e17db603827c02b2d26c07f9f4416c (patch)
tree16c7e17cab2a655b8dace8caedfec6bcb7089a45 /ext/domxml/php_domxml.c
parent83719f5cd8ac008683c9c29f80b9cd7d4c2d1212 (diff)
downloadphp-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)
Diffstat (limited to 'ext/domxml/php_domxml.c')
-rw-r--r--ext/domxml/php_domxml.c39
1 files changed, 39 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)