#define TIDY_SET_DEFAULT_CONFIG(_doc) \
if (TG(default_config) && TG(default_config)[0]) { \
if (tidyLoadConfig(_doc, TG(default_config)) < 0) { \
- zend_error(E_ERROR, "Unable to load Tidy configuration file at '%s'.", TG(default_config)); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load Tidy configuration file at '%s'.", TG(default_config)); \
} \
}
/* }}} */
PHP_FE(tidy_error_count, NULL)
PHP_FE(tidy_warning_count, NULL)
PHP_FE(tidy_access_count, NULL)
- PHP_FE(tidy_config_count, NULL)
+ PHP_FE(tidy_config_count, NULL)
PHP_FE(tidy_get_root, NULL)
PHP_FE(tidy_get_head, NULL)
PHP_FE(tidy_get_html, NULL)
void php_tidy_panic(ctmbstr msg)
{
- zend_error(E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
}
static void _php_tidy_throw_exception(char *message, ...)
if(TG(inst)) {
zend_throw_exception(tidy_ce_exception, msg, 0 TSRMLS_CC);
} else {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, msg);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, msg);
}
va_end(ap);
opt = tidyGetOptionByName(doc, optname);
if (!opt) {
- TIDY_THROW("Unknown Tidy Configuration Option '%s'", optname);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname);
return FAILURE;
}
if (tidyOptIsReadOnly(opt)) {
- TIDY_THROW("Attempt to set read-only option '%s'", optname);
+
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Attempting to set read-only option '%s'", optname);
return FAILURE;
}
TidyBuffer *errbuf;
zval *config;
+ TIDY_SET_CONTEXT;
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) {
RETURN_FALSE;
}
tidyBufInit(errbuf);
if (tidySetErrorBuffer(doc, errbuf) != 0) {
- zend_error(E_ERROR, "Could not set Tidy error buffer");
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
}
tidyOptSetBool(doc, TidyForceOutput, yes);
convert_to_string_ex(&config);
TIDY_SAFE_MODE_CHECK(Z_STRVAL_P(config));
if (tidyLoadConfig(doc, Z_STRVAL_P(config)) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_P(config));
+ TIDY_THROW("Could not load configuration file '%s'", Z_STRVAL_P(config));
RETVAL_FALSE;
}
}
tidyBufInit(intern->ptdoc->errbuf);
if (tidySetErrorBuffer(intern->ptdoc->doc, intern->ptdoc->errbuf) != 0) {
- zend_error(E_ERROR, "Could not set Tidy error buffer");
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
}
tidyOptSetBool(intern->ptdoc->doc, TidyForceOutput, yes);
zend_hash_move_forward(ht_options)) {
if(zend_hash_get_current_key(ht_options, &opt_name, &opt_indx, FALSE) == FAILURE) {
- TIDY_THROW("Could not retrieve key from option array");
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not retrieve key from option array");
return FAILURE;
}
+
if(opt_name) {
_php_tidy_set_tidy_opt(doc, opt_name, *opt_val TSRMLS_CC);
}
{
if (INI_BOOL("tidy.clean_output") == TRUE) {
if (php_start_ob_buffer_named("ob_tidyhandler", 0, 1 TSRMLS_CC) == FAILURE) {
- zend_error(E_NOTICE, "Unable to use Tidy for output buffering.");
+ zend_error(E_NOTICE, "Failure installing Tidy output buffering.");
}
}
tidyRelease(doc);
tidyBufFree(&errbuf);
- zend_error(E_ERROR, "Could not set Tidy error buffer");
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
}
TIDY_SET_DEFAULT_CONFIG(doc);
zval *options = NULL;
PHPTidyObj *obj;
+
+ TIDY_SET_CONTEXT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) {
RETURN_FALSE;
zval *options = NULL;
PHPTidyObj *obj;
+ TIDY_SET_CONTEXT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zsb", &inputfile, &input_len,
&options, &enc, &enc_len, &use_include_path) == FAILURE) {
INIT_ZVAL(*return_value);
RETVAL_FALSE;
}
+
efree(contents);
}
/* }}} */
Repair a string using an optionally provided configuration file */
PHP_FUNCTION(tidy_repair_string)
{
+ TIDY_SET_CONTEXT;
php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
}
/* }}} */
Repair a file using an optionally provided configuration file */
PHP_FUNCTION(tidy_repair_file)
{
+ TIDY_SET_CONTEXT;
php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
}
/* }}} */
Get release date (version) for Tidy library */
PHP_FUNCTION(tidy_get_release)
{
+ TIDY_SET_CONTEXT;
+
if (ZEND_NUM_ARGS()) {
WRONG_PARAM_COUNT;
}
int optname_len;
TidyOption opt;
TidyOptionType optt;
- TIDY_SET_CONTEXT;
+
+ TIDY_SET_CONTEXT;
if (object) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &optname, &optname_len) == FAILURE) {
obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
+
if (!opt) {
TIDY_THROW("Unknown Tidy Configuration Option '%s'", optname);
RETURN_FALSE;
break;
default:
- TIDY_THROW("Unable to determine type of configuration constant");
+ TIDY_THROW("Unable to determine type of configuration option");
break;
}
Returns a TidyNode Object representing the root of the tidy parse tree */
PHP_FUNCTION(tidy_get_root)
{
+ TIDY_SET_CONTEXT;
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_root_node);
}
/* }}} */
Returns a TidyNode Object starting from the <HTML> tag of the tidy parse tree */
PHP_FUNCTION(tidy_get_html)
{
+ TIDY_SET_CONTEXT;
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_html_node);
}
/* }}} */
Returns a TidyNode Object starting from the <HEAD> tag of the tidy parse tree */
PHP_FUNCTION(tidy_get_head)
{
+ TIDY_SET_CONTEXT;
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_head_node);
}
/* }}} */
Returns a TidyNode Object starting from the <BODY> tag of the tidy parse tree */
PHP_FUNCTION(tidy_get_body)
{
+ TIDY_SET_CONTEXT;
php_tidy_create_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, is_body_node);
}
/* }}} */