Fix bugs in the help link system
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 26 Jun 2008 16:18:28 +0000 (12:18 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 26 Jun 2008 16:18:28 +0000 (12:18 -0400)
* includes/functions.php:
(isso_pre_parse_hook): Echo the value of fetch_help_link()
(fetch_help_link): Use the new template system

includes/functions.php

index 7b1dc432f68d36a958f14edfff5c546f1beb6e03..38f494289be961b311d4250c862bb081ad3186c4 100755 (executable)
@@ -541,36 +541,43 @@ function fetch_on_bits($mask, $userinfo = null)
        return implode(',', $onbits);
 }
 
-// #################### Start isso_pre_parse_hook ####################
-// the pre-parse hook for ISSO's template engine
+/**
+ * Pre-parse hook for BSTemplate class. This merely substitutes help links
+ * 
+ * @param      string  Template
+ * @return     string
+ */
 function isso_pre_parse_hook($template)
 {
-       $template = preg_replace('#\$help\[(.*)\]#', '" . fetch_help_link("\1") . "', $template);
+       $template = preg_replace('#\$help\[(.*)\]#', '<?php echo fetch_help_link("\1") ?>', $template);
        return $template;
 }
 
-// ###################### Start fetch_help_link ######################
-// returns a prepared link to insert into templates that opens up a 
-// help popup in the user-end
+/**
+ * Returns the HTML used to generate a help link for a given topic
+ * 
+ * @param      string  Topic name
+ * @return     string
+ */
 function fetch_help_link($topic)
 {
-       global $bugsys;
+       $tpl = new BSTemplate('help_link');
+       $tpl->vars = array('topic' => $topic);
        
        if (isset(bugdar::$datastore['help']["$topic"]))
        {
-               eval('$temp = "' . $bugsys->template->fetch('help_link') . '";');
-               return $temp;
+               return $tpl->evaluate()->getTemplate();
        }
        else
        {
-               if (BSApp::debug)
+               if (BSApp::get_debug())
                {
                        return "[[INVALID TOPIC: $topic]]";
                }
                // do we want this?
                else if (null == 1)
                {
-                       return eval('$temp = "' . $bugsys->template->fetch('help_link') . '";');
+                       return $tpl->evaluate()->getTemplate();
                }
        }
 }