summaryrefslogtreecommitdiff
path: root/ext/tidy/tidy.c
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2007-02-11 16:07:30 +0000
committerNuno Lopes <nlopess@php.net>2007-02-11 16:07:30 +0000
commit8b9f475ac6f948adb0ef3dde8556b4c32238d643 (patch)
tree95e78955af75b117f5b3012e7a37f8b6e3285e5a /ext/tidy/tidy.c
parent18e4a7aacbbe08914cc6915b58c4c74a9a5e41d4 (diff)
downloadphp-git-8b9f475ac6f948adb0ef3dde8556b4c32238d643.tar.gz
merge the tidyNode::getParent() patch from HEAD
Diffstat (limited to 'ext/tidy/tidy.c')
-rw-r--r--ext/tidy/tidy.c25
1 files changed, 25 insertions, 0 deletions
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);