exsltRegisterAll();
#endif
+ xsltRegisterExtModuleFunction ((const xmlChar *) "functionString",
+ (const xmlChar *) "http://php.net/xsl",
+ xsl_ext_function_string_php);
+ xsltRegisterExtModuleFunction ((const xmlChar *) "function",
+ (const xmlChar *) "http://php.net/xsl",
+ xsl_ext_function_object_php);
+
REGISTER_LONG_CONSTANT("XSL_CLONE_AUTO", 0, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSL_CLONE_NEVER", -1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSL_CLONE_ALWAYS", 1, CONST_CS | CONST_PERSISTENT);
/* uncomment this line if you have INI entries
UNREGISTER_INI_ENTRIES();
*/
+
+ xsltUnregisterExtModuleFunction ((const xmlChar *) "functionString",
+ (const xmlChar *) "http://php.net/xsl");
+ xsltUnregisterExtModuleFunction ((const xmlChar *) "function",
+ (const xmlChar *) "http://php.net/xsl");
+
xsltCleanupGlobals();
return SUCCESS;
#include "php_xsl.h"
#include "ext/libxml/php_libxml.h"
-static void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs);
-static void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs);
-
/*
* class xsl_xsltprocessor
*
return (char *) value;
}
-static void php_xsl_unregister_php_functions() {
- xsltUnregisterExtModuleFunction ((const xmlChar *) "functionString",
- (const xmlChar *) "http://php.net/xsl");
- xsltUnregisterExtModuleFunction ((const xmlChar *) "function",
- (const xmlChar *) "http://php.net/xsl");
-}
-
/* {{{ php_xsl_xslt_make_params()
Translates a PHP array to a libxslt parameters array */
zval **args;
zval *retval;
int result, i, ret;
+ int error = 0;
zend_fcall_info fci;
zval handler;
xmlXPathObjectPtr obj;
TSRMLS_FETCH();
- tctxt = xsltXPathGetTransformContext(ctxt);
- if (tctxt == NULL) {
+ if (! zend_is_executing(TSRMLS_C)) {
xsltGenericError(xsltGenericErrorContext,
- "xsltExtFunctionTest: failed to get the transformation context\n");
+ "xsltExtFunctionTest: Function called from outside of PHP\n");
+ error = 1;
+ } else {
+ tctxt = xsltXPathGetTransformContext(ctxt);
+ if (tctxt == NULL) {
+ xsltGenericError(xsltGenericErrorContext,
+ "xsltExtFunctionTest: failed to get the transformation context\n");
+ error = 1;
+ } else {
+ intern = (xsl_object *) tctxt->_private;
+ if (intern == NULL) {
+ xsltGenericError(xsltGenericErrorContext,
+ "xsltExtFunctionTest: failed to get the internal object\n");
+ error = 1;
+ }
+ else if (intern->registerPhpFunctions == 0) {
+ xsltGenericError(xsltGenericErrorContext,
+ "xsltExtFunctionTest: PHP Object did not register PHP functions\n");
+ error = 1;
+ }
+ }
+ }
+
+ if (error == 1) {
+ for (i = nargs - 1; i >= 0; i--) {
+ obj = valuePop(ctxt);
+ xmlXPathFreeObject(obj);
+ }
return;
}
-
+
fci.param_count = nargs - 1;
if (fci.param_count > 0) {
fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0);
xmlFree(str);
} else if (type == 2) {
int j;
- dom_object *intern;
+ dom_object *domintern;
array_init(args[i]);
if (obj->nodesetval->nodeNr > 0) {
- intern = (dom_object *) php_dom_object_get_data((void *) obj->nodesetval->nodeTab[0]->doc);
+ domintern = (dom_object *) php_dom_object_get_data((void *) obj->nodesetval->nodeTab[0]->doc);
for (j = 0; j < obj->nodesetval->nodeNr; j++) {
xmlNodePtr node = obj->nodesetval->nodeTab[j];
zval *child;
node->parent = nsparent;
node->ns = curns;
}
- child = php_dom_create_object(node, &ret, NULL, child, intern TSRMLS_CC);
+ child = php_dom_create_object(node, &ret, NULL, child, domintern TSRMLS_CC);
add_next_index_zval(args[i], child);
}
}
if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) {
xmlNode *nodep;
dom_object *obj;
- intern = (xsl_object *) tctxt->_private;
if (intern->node_list == NULL) {
ALLOC_HASHTABLE(intern->node_list);
zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
}
}
-static void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs)
+void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs)
{
xsl_ext_function_php(ctxt, nargs, 1);
}
-static void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs)
+void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs)
{
xsl_ext_function_php(ctxt, nargs, 2);
}
FREE_HASHTABLE(intern->node_list);
intern->node_list = NULL;
}
-
- if (intern->registerPhpFunctions == 1) {
- php_xsl_unregister_php_functions();
- }
if (intern->hasKeys == 1) {
xmlFreeDoc(doc);
intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
intern->registerPhpFunctions = 1;
-
- xsltRegisterExtModuleFunction ((const xmlChar *) "functionString",
- (const xmlChar *) "http://php.net/xsl",
- xsl_ext_function_string_php);
- xsltRegisterExtModuleFunction ((const xmlChar *) "function",
- (const xmlChar *) "http://php.net/xsl",
- xsl_ext_function_object_php);
+
}
/* }}} end xsl_xsltprocessor_register_php_functions(); */