]> granicus.if.org Git - php/commitdiff
Adding new function tidy_get_opt_doc() to return option documentation at runtime...
authorJohn Coggeshall <john@php.net>
Mon, 25 Apr 2005 20:46:16 +0000 (20:46 +0000)
committerJohn Coggeshall <john@php.net>
Mon, 25 Apr 2005 20:46:16 +0000 (20:46 +0000)
ext/tidy/config.m4
ext/tidy/php_tidy.def
ext/tidy/php_tidy.h
ext/tidy/tidy.c

index bd6e018e127249898826f619ee6eab7e105a8dd1..aec1ee3fff09525cf277846c5afd13546abbc623 100644 (file)
@@ -32,6 +32,12 @@ if test "$PHP_TIDY" != "no"; then
   PHP_ADD_LIBRARY_WITH_PATH(tidy, $TIDY_LIBDIR, TIDY_SHARED_LIBADD)
   PHP_ADD_INCLUDE($TIDY_INCDIR)
 
+  PHP_CHECK_LIBRARY(tidy,tidyOptGetDoc,
+  [
+  AC_DEFINE(HAVE_TIDYOPTGETDOC,1,[ ])
+  ],[],[])
+
+
   PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared)
   PHP_SUBST(TIDY_SHARED_LIBADD)
   AC_DEFINE(HAVE_TIDY,1,[ ])
index 1c17276de6dfd53fb0e7d14263444d5ed5182dde..0caabc01f340fdd3a4f5aeb7373731e1ba6e928b 100644 (file)
@@ -45,6 +45,7 @@ tidyOptGetCategory
 tidyOptGetDefault
 tidyOptGetDefaultInt
 tidyOptGetDefaultBool
+tidyOptGetDoc
 tidyOptGetPickList
 tidyOptGetNextPick
 tidyOptGetValue
index 7ca065936d39183c65eda91156bebdbc0c07cb53..48b8e6efce3c41c72ad6fb859daf21ee4a6ab030 100644 (file)
@@ -57,6 +57,9 @@ PHP_FUNCTION(tidy_reset_config);
 PHP_FUNCTION(tidy_get_config);
 PHP_FUNCTION(tidy_get_status);
 PHP_FUNCTION(tidy_get_html_ver);
+#if HAVE_TIDYOPTGETDOC
+PHP_FUNCTION(tidy_get_opt_doc);
+#endif
 PHP_FUNCTION(tidy_is_xhtml);
 PHP_FUNCTION(tidy_is_xml);
 PHP_FUNCTION(tidy_error_count);
index 136410f3ed745299ded10e71274e241f10e7a725..060b37ccb7ecbb6b145ab4974061ed2cbafa36f4 100644 (file)
@@ -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)