diff options
author | Nuno Lopes <nlopess@php.net> | 2007-02-11 16:07:30 +0000 |
---|---|---|
committer | Nuno Lopes <nlopess@php.net> | 2007-02-11 16:07:30 +0000 |
commit | 8b9f475ac6f948adb0ef3dde8556b4c32238d643 (patch) | |
tree | 95e78955af75b117f5b3012e7a37f8b6e3285e5a | |
parent | 18e4a7aacbbe08914cc6915b58c4c74a9a5e41d4 (diff) | |
download | php-git-8b9f475ac6f948adb0ef3dde8556b4c32238d643.tar.gz |
merge the tidyNode::getParent() patch from HEAD
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/tidy/tests/028.phpt | 15 | ||||
-rw-r--r-- | ext/tidy/tidy.c | 25 |
3 files changed, 41 insertions, 0 deletions
@@ -4,6 +4,7 @@ PHP NEWS - Upgraded SQLite 3 to version 3.3.12 (Ilia) - Upgraded PCRE to version 7.0 (Nuno) - Add --ri switch to CLI which allows to check extension information. (Marcus) +- Added tidyNode::getParent() method (John, Nuno) - Fixed bug #40431 (dynamic properties may cause crash in ReflectionProperty methods). (Tony) - Fixed bug #40428, imagepstext() doesn't accept optional parameter (Pierre) diff --git a/ext/tidy/tests/028.phpt b/ext/tidy/tests/028.phpt new file mode 100644 index 0000000000..01f3fd1e1a --- /dev/null +++ b/ext/tidy/tests/028.phpt @@ -0,0 +1,15 @@ +--TEST-- +tidyNode::getParent() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +$x = tidy_parse_string("<body><div>Content</div></body>"); +var_dump($x->body()->child[0]->name); +var_dump($x->body()->child[0]->getParent()->name); +var_dump($x->root()->getParent()); +?> +--EXPECT-- +string(3) "div" +string(4) "body" +NULL diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 76a08ed915..94c711198d 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -267,6 +267,7 @@ static TIDY_NODE_METHOD(isText); static TIDY_NODE_METHOD(isJste); static TIDY_NODE_METHOD(isAsp); static TIDY_NODE_METHOD(isPhp); +static TIDY_NODE_METHOD(getParent); /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(tidy) @@ -341,6 +342,7 @@ static zend_function_entry tidy_funcs_node[] = { TIDY_NODE_ME(isJste, NULL) TIDY_NODE_ME(isAsp, NULL) TIDY_NODE_ME(isPhp, NULL) + TIDY_NODE_ME(getParent, NULL) {NULL, NULL, NULL} }; @@ -1659,6 +1661,29 @@ static TIDY_NODE_METHOD(isPhp) } /* }}} */ +/* {{{ proto tidyNode tidyNode::getParent() + Returns the parent node if available or NULL */ +static TIDY_NODE_METHOD(getParent) +{ + TidyNode parent_node; + PHPTidyObj *newobj; + TIDY_FETCH_ONLY_OBJECT; + + parent_node = tidyGetParent(obj->node); + if(parent_node) { + tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); + newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); + newobj->node = parent_node; + newobj->type = is_node; + newobj->ptdoc = obj->ptdoc; + newobj->ptdoc->ref_count++; + tidy_add_default_properties(newobj, is_node TSRMLS_CC); + } else { + ZVAL_NULL(return_value); + } +} +/* }}} */ + static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS) { TIDY_NODE_CONST(ROOT, Root); |