--- wiki.module	2005-05-14 15:37:41.000000000 -0600
+++ ../update/wiki.module	2006-01-24 10:13:47.000000000 -0700
@@ -6,16 +6,24 @@
 * Handle filtering of Wiki Text
 */
 
-define('WIKI_FILTER_HTML_ENABLE', 1);
-define('WIKI_FILTER_HTML_DISABLE', 2);
-
 /**
 * Implementation of hook_help().
 */
-function wiki_help($section) {
+function wiki_help($section='admin/help#wiki') {
   switch ($section) {
-    case 'admin/modules#description':
-      return t('Enables users to use simple WikiText markup to format content.');
+  case 'admin/modules#description':
+    return t('Enables users to use simple WikiText markup to format content.');
+  case 'admin/help#wiki':
+    return t('
+<p>
+  The Wiki module allows users to enter content using <a
+  href="http://phpwiki.sf.net/" title="PhpWiki">PhpWiki</a>,
+  a simple, plain text syntax that is filtered into valid HTML.
+  The <a href="' . url('filter/tips') .'" title="WikiText help">
+  filter tips page</a> provides syntax descriptions and
+  examples.
+</p>
+ ');
   }
 }
 
@@ -39,7 +47,7 @@
       return t('Converts WikiText to HTML.');
 
     case 'process':
-      return _wiki_filter($text);
+      return _wiki_filter($text, $format);
 
     case 'settings':
       return _wiki_filter_settings($format);
@@ -68,13 +76,23 @@
 * Settings for the WikiText filter.
 */
 function _wiki_filter_settings($format) {
-  $group = form_radios(t('Support Escaped HTML'), "wiki_filter_html", variable_get("wiki_filter_html", WIKI_FILTER_HTML_DISABLE), array(WIKI_FILTER_HTML_ENABLE => t('Enable HTML'), WIKI_FILTER_HTML_DISABLE => t('Disable HTML')), t('Whether to allow |&gt;-escaped HTML.  If set to "enable", then any HTML goes on each line after the |&gt; escape marker.  If set to "disable", then any HTML tags will be shown as is, unless the HTML Filter has been separately enabled.  It is recommended that this be disabled.  Turn on the HTML Filter to support HTML, but make sure the HTML filter applies <em>after</em> the WikiText filter.'));
-  $output .= form_group(t('WikiText filter'), $group);
 
-  return $output;
+  $the_form = array();
+  $the_form['wiki_settings'] =
+    array('#type' => 'fieldset',
+          '#title' => t('WikiText filter'),
+          '#collapsible' => TRUE,
+          '#collapsed' => TRUE);
+  $the_form['wiki_settings']['enable_html_${format}'] =
+    array(
+          '#type' => 'checkbox',
+          '#title' => t('Enable HTML'),
+          '#default_value' => variable_get("enable_html_${format}", 0),
+          '#description' => t('Whether to allow |&gt;-escaped HTML.  If enabled, then any HTML goes on each line after the |&gt; escape marker.  If disabled, then any HTML tags will be shown as is, unless the HTML Filter has been separately enabled.  It is recommended that this be disabled.  Turn on the HTML Filter to support HTML, but make sure the HTML filter applies <em>after</em> the WikiText filter.'));
+  
+  return $the_form;
 }
 
-
 define("WIKI_ZERO_LEVEL", 0);
 define("WIKI_NESTED_LEVEL", 1);
 define("WIKI_FIELD_SEPARATOR", "\263");
@@ -354,7 +372,7 @@
 /**
 * WikiText filter. Provides filtering of input into accepted HTML.
 */
-function _wiki_filter($text) {
+function _wiki_filter($text, $format) {
   $html = '';
   $isprotect = FALSE;  // whether we're within a {{{ }}} protection block
   $istable = FALSE;  // whether we're currently in a table
@@ -407,7 +425,7 @@
       $html .= _wiki_set_output_mode('', WIKI_ZERO_LEVEL, 0);
       continue;
     } 
-    elseif (variable_get("wiki_filter_html", WIKI_FILTER_HTML_DISABLE) == WIKI_FILTER_HTML_ENABLE) {
+    elseif (variable_get("enable_html_${format}", 0)) {
       // We protect HTML by having lines start with |>  php-wiki way is just |
       // this change is to prevent wiki table from being skipped
       if (preg_match("/(^\|>)(.*)/", $tmpline, $matches)) {
@@ -645,10 +663,11 @@
 /**
 * Implementation of hook_filter_tips().
 */
-function wiki_filter_tips($delta = 0, $format = -1, $long = false) {
-  if ($long) {
-    // orig. from <http://phpwiki.sourceforge.net/phpwiki/TextFormattingRules>
-    // but has since been enhanced with other WikiText support.
+function wiki_filter_tips($delta, $format, $long = false) {
+  global $base_url;
+  if (!$long) {
+    return t('WikiText is converted to HTML (supported WikiText formatting will show in the long tip format).');
+  } else {
     $output = t('WikiText is converted to HTML according to the following formatting guidelines:
 <h4>Paragraphs</h4>
   <ul>
@@ -722,7 +741,7 @@
   <li>&lt; and &gt; are themselves</li>
   <li>Entities (e.g. &amp;amp;) will not convert to characters</li>');
   
-    if (variable_get("wiki_filter_html", WIKI_FILTER_HTML_DISABLE) == WIKI_FILTER_HTML_ENABLE) {
+    if (variable_get("enable_html_${format}", 0)) {
       $output .= t('<li>If you really must use HTML, the system administrator has enabled this feature. Start each line with a bar-greater-than (|>).<!--Note that this feature is disabled by default.--></li>');
     }
     
@@ -755,11 +774,15 @@
   <p>Footnotes:</p>
   <p><br /><a name="footnote-1" href="'. $_SERVER['REQUEST_URI'] .'#footrev-1-0" class="footnote-rev">[1]</a><a name="footnote-1" href="'. $_SERVER['REQUEST_URI'] .'#footrev-1-1" class="footnote-rev">+</a> By using [1] a second time (in the first column) the footnote itself is <em>defined</em>.  You may refer to a footnote as many times as you want, but you may only define it once on the page.  Note the the [1] in the footnote links back to the first reference, if there are multiple references there will be one or more plus symbols (+) after the [1] which will link to the other references.  (References which come <em>after</em> the footnote <em>definition</em> will not be linked to.)</p>';
   */
-  
     return $output;
-  } else {
-    return t('WikiText is converted to HTML (supported WikiText formatting will show in the long tip format).');
   }
 }
 
+// Local Variables:
+// mode: php
+// tab-width: 8
+// c-basic-offset: 2
+// c-hanging-comment-ender-p: nil
+// indent-tabs-mode: nil
+// End:
 ?>
