summaryrefslogtreecommitdiff
path: root/ext/tidy/tidy.c
diff options
context:
space:
mode:
authorJohn Coggeshall <john@php.net>2005-04-25 20:46:16 +0000
committerJohn Coggeshall <john@php.net>2005-04-25 20:46:16 +0000
commit335742c2ef76adb349ad4ad9ab8ba994ccc93320 (patch)
treecee3c836378f1309ac29836d6df8508c8f0be9df /ext/tidy/tidy.c
parent53e3b0fcb8f878de63e3b3363b4de96766940193 (diff)
downloadphp-git-335742c2ef76adb349ad4ad9ab8ba994ccc93320.tar.gz
Adding new function tidy_get_opt_doc() to return option documentation at runtime. Thanks to nlopess for the patch
Diffstat (limited to 'ext/tidy/tidy.c')
-rw-r--r--ext/tidy/tidy.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 136410f3ed..060b37ccb7 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -245,6 +245,9 @@ function_entry tidy_functions[] = {
PHP_FE(tidy_warning_count, NULL)
PHP_FE(tidy_access_count, NULL)
PHP_FE(tidy_config_count, NULL)
+#if HAVE_TIDYOPTGETDOC
+ PHP_FE(tidy_get_opt_doc, NULL)
+#endif
PHP_FE(tidy_get_root, NULL)
PHP_FE(tidy_get_head, NULL)
PHP_FE(tidy_get_html, NULL)
@@ -265,6 +268,9 @@ function_entry tidy_funcs_doc[] = {
TIDY_METHOD_MAP(getConfig, tidy_get_config, NULL)
TIDY_METHOD_MAP(getStatus, tidy_get_status, NULL)
TIDY_METHOD_MAP(getHtmlVer, tidy_get_html_ver, NULL)
+#if HAVE_TIDYOPTGETDOC
+ TIDY_METHOD_MAP(getOptDoc, tidy_get_opt_doc, NULL)
+#endif
TIDY_METHOD_MAP(isXhtml, tidy_is_xhtml, NULL)
TIDY_METHOD_MAP(isXml, tidy_is_xml, NULL)
TIDY_METHOD_MAP(root, tidy_get_root, NULL)
@@ -1169,6 +1175,47 @@ PHP_FUNCTION(tidy_get_release)
}
/* }}} */
+
+#if HAVE_TIDYOPTGETDOC
+/* {{{ proto string tidy_get_opt_doc(tidy resource, string optname)
+ Returns the documentation for the given option name */
+PHP_FUNCTION(tidy_get_opt_doc)
+{
+ PHPTidyObj *obj;
+ char *optname, *optval;
+ int optname_len;
+ TidyOption opt;
+
+ TIDY_SET_CONTEXT;
+
+ if (object) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ } else {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, NULL, "Os", &object, tidy_ce_doc, &optname, &optname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
+
+ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ opt = tidyGetOptionByName(obj->ptdoc->doc, optname);
+
+ if (!opt) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname);
+ RETURN_FALSE;
+ }
+
+ if (optval = (char *) tidyOptGetDoc(obj->ptdoc->doc, opt))
+ RETURN_STRING(optval, 1);
+
+ RETURN_FALSE;
+}
+/* }}} */
+#endif
+
+
/* {{{ proto array tidy_get_config()
Get current Tidy configuarion */
PHP_FUNCTION(tidy_get_config)