r67: - Upping template system to use ISSO
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 4 May 2005 06:19:55 +0000 (06:19 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 4 May 2005 06:19:55 +0000 (06:19 +0000)
- Removing old files that are now handled by frameworks

15 files changed:
editcomment.php
editreport.php
global.php
includes/db_mysql.php [deleted file]
includes/functions.php
includes/functions_mail.php [deleted file]
includes/functions_template.php [deleted file]
includes/init.php
index.php
login.php
newcomment.php
newreport.php
register.php
search.php
showreport.php

index 7823c396d5af89b2f2148fb6e2b7fe9b0fc8d66c..f15f6975ca16316d2e5451336c114d732b2e1af5 100644 (file)
@@ -98,7 +98,7 @@ if ($_REQUEST['do'] == 'edit')
        $comment['posttime'] = datelike('standard', $comment['dateline']);
        $comment['postby'] = construct_user_display($comment);
        $comment['comment'] = htmlspecialcharslike($comment['comment']);
-       eval('$tpl->flush("' . $tpl->fetch('editcomment') . '");');
+       eval('$template->flush("' . $template->fetch('editcomment') . '");');
 }
 
 /*=====================================================================*\
index c90fd10c56c48b8991d427ac6491eebfec1a6ea0..8bd307afe5daa30d81110910c1c1de59571f3d0d 100644 (file)
@@ -118,7 +118,7 @@ if ($_REQUEST['do'] == 'edit')
                $value = $severity['severityid'];
                $selected = iff($severity['severityid'] == $bug['severity'], true, false);
                $label = $severity['severity'];
-               eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
        }
        
        $show['changestatus'] = iff(can_perform('canchangestatus'), true, false);
@@ -129,7 +129,7 @@ if ($_REQUEST['do'] == 'edit')
                        $value = $priority['priorityid'];
                        $selected = iff($priority['priorityid'] == $bug['priority'], true, false);
                        $label = $priority['priority'];
-                       eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
                }
                
                foreach ($bugsys->datastore['status'] AS $status)
@@ -137,7 +137,7 @@ if ($_REQUEST['do'] == 'edit')
                        $value = $status['statusid'];
                        $selected = iff($status['statusid'] == $bug['status'], true, false);
                        $label = $status['status'];
-                       eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
                }
                
                foreach ($bugsys->datastore['resolution'] AS $resolution)
@@ -145,7 +145,7 @@ if ($_REQUEST['do'] == 'edit')
                        $value = $resolution['resolutionid'];
                        $selected = iff($resolution['resolutionid'] == $bug['resolution'], true, false);
                        $label = $resolution['resolution'];
-                       eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
                }
        }
        
@@ -157,13 +157,13 @@ if ($_REQUEST['do'] == 'edit')
                        $value = $dev['userid'];
                        $selected = iff($dev['userid'] == $bug['assignedto'], true, false);
                        $label = construct_user_display($dev, false);
-                       eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
                }
        }
        
        $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
        
-       eval('$tpl->flush("' . $tpl->fetch('editreport') . '");');
+       eval('$template->flush("' . $template->fetch('editreport') . '");');
 }
 
 /*=====================================================================*\
index 66c80632402f19ffd70cc0f39a8c8f93060afd24..bfa74d209d1ac49e83f742b3a4df6fdaf378564e 100755 (executable)
@@ -12,9 +12,6 @@
 
 require_once('./includes/init.php');
 
-require_once('./includes/functions.php');
-require_once('./includes/functions_mail.php');
-
 // ###################################################################
 
 if ($bugsys->userinfo['userid'])
@@ -23,8 +20,6 @@ if ($bugsys->userinfo['userid'])
 }
 
 // ###################################################################
-require_once('./includes/functions_template.php');
-$tpl = new Template();
 
 $globaltemplates = array(
        'doctype',
@@ -35,7 +30,7 @@ $globaltemplates = array(
        'selectoptgroup'
 );
 
-$tpl->cache(array_merge($globaltemplates, (array)$fetchtemplates));
+$template->cache(array_merge($globaltemplates, (array)$fetchtemplates));
 
 // ###################################################################
 // initialize template variables
diff --git a/includes/db_mysql.php b/includes/db_mysql.php
deleted file mode 100755 (executable)
index 2c114a5..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-/*=====================================================================*\
-|| ################################################################### ||
-|| # BugStrike [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
-|| # This file may not be reproduced in any way without permission.  # ||
-|| # --------------------------------------------------------------- # ||
-|| # User License Agreement at http://www.iris-studios.com/license/  # ||
-|| ################################################################### ||
-\*=====================================================================*/
-
-class DB_Sql
-{
-       var $database = '';
-       
-       var $errno = 0;
-       var $error = '';
-       
-       var $link_id = 0;
-       var $query_id = 0;
-       var $current_query = '';
-       var $query_history = array();
-       
-       var $appname = 'Databsase Abstraction Layer';
-       
-       function connect($server, $user, $password, $pconnect)
-       {
-               if ($this->link_id == 0)
-               {
-                       if ($pconnect)
-                       {
-                               $this->link_id = @mysql_pconnect($server, $user, $password);
-                       }
-                       else
-                       {
-                               $this->link_id = @mysql_connect($server, $user, $password);
-                       }
-                       
-                       if (!$this->link_id)
-                       {
-                               $this->throw('Link-Id == false, can not connect');
-                               return false;
-                       }
-                       
-                       $candb = @mysql_select_db($this->database, $this->link_id);
-                       if ($candb)
-                       {
-                               return true;
-                       }
-                       else
-                       {
-                               $this->throw('Cannot use the database ' . $this->database);
-                       }
-               }
-       }
-       
-       function query($qstring)
-       {
-               $this->query_id = mysql_query($qstring, $this->link_id);
-               $this->current_query = $qstring;
-               $this->query_history[] = $this->current_query;
-               
-               if (!$this->query_id)
-               {
-                       $this->throw('Invalid SQL query: ' . $this->current_query);
-               }
-               
-               return $this->query_id;
-       }
-       
-       function fetch_array($query_id)
-       {
-               return @mysql_fetch_array($query_id, MYSQL_ASSOC);
-       }
-       
-       function free_result($query_id)
-       {
-               @mysql_free_result($query_id);
-               $this->query_id = 0;
-       }
-       
-       function query_first($qstring)
-       {
-               $resource = $this->query($qstring);
-               $array = $this->fetch_array($resource);
-               $this->free_result($resource);
-               return $array;
-       }
-       
-       function insert_id()
-       {
-               return mysql_insert_id($this->link_id);
-       }
-       
-       function num_rows($query_id)
-       {
-               return @mysql_num_rows($query_id);
-       }
-       
-       function affected_rows()
-       {
-               return @mysql_affected_rows($this->link_id);
-       }
-       
-       function throw($message)
-       {
-               if ($this->link_id)
-               {
-                       $this->error = mysql_error($this->link_id);
-                       $this->errno = mysql_errno($this->link_id);
-               }
-               
-               echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r";
-               echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r<head>\r<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r<title>";
-               echo "{$this->appname} Error</title>\r<style type=\"text/css\">\r<!--\r.title\r{\r\tfont-family: Arial, Helvetica, sans-serif;\r\tfont-size: 12px;\r\tcolor: #990000;";
-               echo "\r}\rbody\r{\r\tfont-family: Arial, Helvetica, sans-serif;\r\tfont-size: 11px;\r}\r.code\r{\r\tfont-family: \"Courier New\", Courier, mono;\r\tfont-size: 11px;\r}";
-               echo "\r-->\r</style>\r</head>\r\r<body>\r<p class=\"title\"><strong>An error occured in <em>{$this->appname}</em></strong></p>\r\r<p>\r\t<blockquote>\r\t\t&raquo;";
-               echo "<strong>Query:</strong>\r\t\t<br />\r\t\t<pre class=\"code\">{$this->current_query}</pre>\r\t\t<br />\r\t\t&raquo;<strong>Error Number:</strong> ";
-               echo "<span class=\"code\">{$this->errno}</span>\r\t\t<br />\r\t\t<br />\r\t\t&raquo;<strong>Error Message:</strong> <span class=\"code\">{$this->error}</span>\r\t\t";
-               echo "<br />\r\t\t<br />\r\t\t&raquo;<strong>File:</strong> <span class=\"code\">$_SERVER[PHP_SELF]</span>\r\t</blockquote>\r</p>\r\r</body>\r</html>";
-               
-               exit;
-
-       }
-}
-
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
-?>
\ No newline at end of file
index 483f64b80794c1bd6d8bf2d0f71049e57cca58f7..7221bb9aabc1f558b5ba00a74fdab2e8cb1ef76e 100755 (executable)
@@ -115,7 +115,7 @@ function can_perform($bitmask, $userinfo = null)
 // NB: need to make sure we have the option to turn off just p/c selection without v
 function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')
 {
-       global $bugsys, $tpl;
+       global $bugsys;
        static $HTML;
        
        if ($HTML)
@@ -152,7 +152,7 @@ function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&
                $row['value'] = "{$valuepfx}c0v0";
                $row['title'] = "<strong>$product[title]</strong>";
                $row['description'] = '';
-               eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";');
+               eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";');
                $HTML .= construct_pcv_select_global_version($product['productid'], 0, $versions, $prefix, $select);
                if (is_array($versions["$product[productid]"]))
                {
@@ -162,7 +162,7 @@ function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&
                                $row['value'] = "{$valuepfx}c0v$version[versionid]";
                                $row['title'] = $version['version'];
                                $row['selected'] = iff($select == $row['value'], $selected, '');
-                               eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";');
+                               eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";');
                        }
                }
                
@@ -176,7 +176,7 @@ function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&
                                $row['selected'] = iff($select == $row['value'], $selected, '');
                                $row['title'] = $component['title'];
                                $row['description'] = '';
-                               eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";');
+                               eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";');
                                $HTML .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, $prefix, $select);
                                if (is_array($versions["$component[productid]"]))
                                {
@@ -187,7 +187,7 @@ function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&
                                                $row['selected'] = iff($select == $row['value'], $selected, '');
                                                $row['title'] = $version['version'];
                                                $row['description'] = '';
-                                               eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";');
+                                               eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";');
                                        }
                                }
                        }
@@ -200,7 +200,7 @@ function construct_pcv_select($select = '', $prefix = '&nbsp;&nbsp;&nbsp;&nbsp;&
 // ############ Start construct_pcv_select_global_version ############
 function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $prefix = '', $select = '')
 {
-       global $tpl;
+       global $bugsys;
        if (is_array($versions['0']))
        {
                foreach ($versions['0'] AS $version)
@@ -211,7 +211,7 @@ function construct_pcv_select_global_version($product = 0, $component = 0, $vers
                        $row['selected'] = iff($select == $row['value'], ' checked="checked"', '');
                        $row['title'] = $version['version'];
                        $row['description'] = '';
-                       eval('$global_versions_html .= "' . $tpl->fetch('pcv_select_row') . '";');
+                       eval('$global_versions_html .= "' . $bugsys->template->fetch('pcv_select_row') . '";');
                }
        }
        return $global_versions_html;
diff --git a/includes/functions_mail.php b/includes/functions_mail.php
deleted file mode 100755 (executable)
index c2fa0ee..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/*=====================================================================*\
-|| ################################################################### ||
-|| # BugStrike [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
-|| # This file may not be reproduced in any way without permission.  # ||
-|| # --------------------------------------------------------------- # ||
-|| # User License Agreement at http://www.iris-studios.com/license/  # ||
-|| ################################################################### ||
-\*=====================================================================*/
-
-// ########################### Start mymail ##########################
-function mymail($toemail, $subject, $message, $fromemail = '', $headers = '', $fparam = true)
-{
-       global $bugsys;
-       
-       // Make sure sendmail is at our disposal
-       if (!(@ini_get('sendmail_path')))
-       {
-               return false;
-       }
-       
-       // Work out our sender
-       $fromemail = fetch_first_line($fromemail);
-       if ($fromemail == -1 OR !$fromemail)
-       {
-               if ($bugsys->options['webmasteremail'])
-               {
-                       $fromemail = fetch_first_line($bugsys->options['webmasteremail']);
-               }
-               else
-               {
-                       // Do we want a sender?
-                       if ($fparam)
-                       {
-                               return false;
-                       }
-               }
-       }
-       
-       // Work out the recipient
-       $toemail = fetch_first_line($toemail);
-       if (!$toemail)
-       {
-               return false;
-       }
-       
-       // Work out the subject
-       $subject = fetch_first_line($subject);
-       if (!$subject)
-       {
-               $subject = $bugsys->options['trackertitle'] . ' Notification';
-       }
-       
-       // Work out the body
-       $message = convert_standard_line_breaks($message);
-       if (!$message)
-       {
-               return false;
-       }
-       
-       // Construct mail headers
-       $headers = convert_standard_line_breaks($headers, "\n");
-       $headers .= "From: \"$fromemail\" <" . $bugsys->options['webmasteremail'] . ">\n";
-       $headers .= "Return-Path: " . $bugsys->options['webmasteremail'] . "\n";
-       $headers .= "X-Mailer: BugStrike [#]version[#] Mail\n";
-       $headers .= "Content-Type: text/plain; charset=\"" . $bugsys->options['lang_charset'] . "\"\n";
-       $headers .= "Content-Transfer-Encoding: 7bit\n";
-       
-       if ($fparam)
-       {
-               mail($toemail, $subject, $message, trim($headers), "-f $fromemail");
-       }
-       else
-       {
-               mail($toemail, $subject, $message, trim($headers));
-       }
-}
-
-// ###################### Start fetch_first_line #####################
-function fetch_first_line($text)
-{
-       $broken = explode("\r\n", convert_standard_line_breaks($text));
-       return $broken[0];
-}
-
-// ################ Start convert_standard_line_breaks ###############
-function convert_standard_line_breaks($text, $convert_to = "\r\n")
-{
-       return preg_replace("#(\r|\n|\r\n)#s", $convert_to, trim($text));
-}
-
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
-?>
\ No newline at end of file
diff --git a/includes/functions_template.php b/includes/functions_template.php
deleted file mode 100644 (file)
index 05afa3a..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-<?php
-/*=====================================================================*\
-|| ################################################################### ||
-|| # BugStrike [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
-|| # This file may not be reproduced in any way without permission.  # ||
-|| # --------------------------------------------------------------- # ||
-|| # User License Agreement at http://www.iris-studios.com/license/  # ||
-|| ################################################################### ||
-\*=====================================================================*/
-
-class Template
-{
-       var $cache = array();
-       var $usage = array();
-       var $uncached = array();
-       
-       var $doneflush = false;
-       
-       // ###################### Start Template::cache ######################
-       function cache($namearray)
-       {
-               if (sizeof($this->cache) > 0)
-               {
-                       user_error('You cannot Template::cache() more than once per initialization', E_USER_WARNING);
-               }
-               else
-               {
-                       foreach ($namearray AS $name)
-                       {
-                               $template = $this->_load($name);
-                               $template = $this->_parse($template);
-                               $this->cache["$name"] = $template;
-                       }
-               }
-       }
-       
-       // ###################### Start Template::fetch ######################
-       function fetch($name)
-       {
-               if (isset($this->cache["$name"]))
-               {
-                       $template = $this->cache["$name"];
-               }
-               else
-               {
-                       $this->uncached[] = $name;
-                       $template = $this->_load($name);
-                       $template = $this->_parse($template);
-               }
-               
-               $this->usage["$name"]++;
-               
-               return $template;
-       }
-       
-       // ###################### Start Template::flush ######################
-       function flush($template)
-       {
-               global $db;
-               
-               ob_start();
-               
-               if (empty($template))
-               {
-                       user_error('Template::flush() produced no output', E_USER_WARNING);
-                       exit;
-               }
-               
-               if (DEVDEBUG AND $_GET['query'])
-               {
-                       if (is_array($db->query_history))
-                       {
-                               echo '<pre>';
-                               foreach ($db->query_history AS $query)
-                               {
-                                       echo $query . "\n\n<hr />\n\n";
-                               }
-                               echo '</pre>';
-                       }
-                       exit;
-               }
-               
-               if ($this->doneflush)
-               {
-                       user_error('You cannot Template::flush() more than once per initialization', E_USER_WARNING);
-                       exit;
-               }
-               
-               if (DEVDEBUG)
-               {
-                       foreach ($this->usage AS $name => $count)
-                       {
-                               $optlist[] = '<option>' . iff($this->uncached["$name"], ' -- [UNCACHED] ') . "$name ($count)</option>";
-                       }
-                       
-                       $debug .= "\r<hr /><br />\r<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" align=\"center\" width=\"99%\" class=\"tborder\">\r<tr>";
-                       $debug .= "\r\t<td width=\"33%\" align=\"center\" class=\"panelback\" style=\"text-align:center\">" . 'construct_debug_info_list()' . "</td>\r\t<td width=\"33%\" align=\"center\" class=\"panelback\" style=\"text-align:center\">$revision</td>";
-                       $debug .= "\r\t<td width=\"33%\" align=\"center\" class=\"panelback\" style=\"text-align:center\"><a href=\"" . SCRIPT_URI . iff(strpos(SCRIPT_URI, '?') !== false, '&amp;query=1', '?query=1') . "\">Total queries used: " . sizeof($db->query_history) . "</a>";
-                       $debug .= "</td>\r</tr>\r<tr>\r\t<td align=\"center\" class=\"panelback\" style=\"text-align:center\" colspan=\"3\">";
-                       $debug .= "\r" . iff(is_array($this->uncached), sizeof($uncached) . " Uncached Template(s)\r<br />\r") . "<select>\r\t<option>TEMPLATE USAGE</option>\r\t" . implode("\r\t", $optlist) . "\r</select>\r</td></tr></table><br />";
-                       
-                       $template = str_replace('</body>', "\r\r<!-- dev debug -->$debug\r<!-- / dev debug -->\r\r</body>", $template);
-               }
-               
-               print(stripslashes($template));
-       }
-       
-       // ###################### Start Template::_load ######################
-       function _load($name)
-       {
-               global $bugsys;
-               
-               if (($template = @file_get_contents("{$bugsys->options['ts_includepath']}$name.tpl")) !== false)
-               {
-                       return $template;
-               }
-               else
-               {
-                       echo "could not load template file {$bugsys->options['ts_includepath']}$name.tpl";
-                       exit;
-               }
-       }
-       
-       // ###################### Start Template::_parse #####################
-       function _parse($template)
-       {
-               $template = stripslashes($template);
-               $template = str_replace('"', '\"', $template);
-               $template = $this->_parse_phrases($template);
-               $template = $this->_parse_conditionals($template);
-               return $template;
-       }
-       
-       // ################## Start Template::_parse_phrases #################
-       function _parse_phrases($template)
-       {
-               $tag_start = '<lang ';
-               $tag_start_end = '">';
-               $tag_end = '</lang>';
-               
-               $location_start = -1;
-               $location_end = -1;
-               
-               // Process the empty phrase objects -- do this now so we don't have to worry about it when we're parsing later
-               $template = preg_replace('#\{lang\.(.*?)\}#i', '" . fetch_phrase(\'$1\') . "', $template);
-               
-               while (1)
-               {
-                       // Find the start language object tag
-                       $location_start = strpos($template, $tag_start, $location_end + 1);
-                       if ($location_start === false)
-                       {
-                               break;
-                       }
-               
-                       // Find the end tag
-                       $location_end = strpos($template, $tag_end, $location_end + strlen($tag_end));
-                       if ($location_end === false)
-                       {
-                               break;
-                       }
-                       
-                       // Extract the language object
-                       $phrase_bunch = substr($template, $location_start, ($location_end + strlen($tag_end)) - $location_start);
-                       
-                       // Find the close to the opening <lang>
-                       $close_of_open = strpos($phrase_bunch, $tag_start_end);
-                       if ($close_of_open === false)
-                       {
-                               break;
-                       }
-                       
-                       // Extract the opening tag so it can be parsed
-                       $init_tag = substr($phrase_bunch, 0, ($close_of_open + strlen($tag_start_end)));
-                       $init_tag = str_replace($tag_start, '', $init_tag);
-                       $init_tag = substr($init_tag, 0, strlen($init_tag) - 1);
-                       
-                       // Get the args out of the tag
-                       $args = preg_split('#([0-9].*?)=#', $init_tag);
-                       foreach ($args AS $arg)
-                       {
-                               if ($arg AND $arg != ' ')
-                               {
-                                       $arg = trim($arg);
-                                       $arg = substr($arg, 2);
-                                       $arg = substr($arg, 0, strlen($arg) - 2);
-                                       $arglist[] = $arg;
-                               }
-                       }
-                       
-                       // Just get the phrase name
-                       $phrase_name = preg_replace('#<lang(.*?)>(.*?)</lang>#i', '$2', $phrase_bunch);
-                       
-                       // Wrap the parsed data into the build function
-                       $function_wrap = '" . construct_phrase(\'' . $phrase_name . '\', "' . implode('", "', $arglist) . '") . "';
-                       
-                       // Replace the fully-parsed string back into the template
-                       $template = substr_replace($template, $function_wrap, $location_start, $location_end + strlen($tag_end) - $location_start);
-                       
-                       unset($arglist);
-               }
-                       
-               return $template;
-       }
-       
-       // ############### Start Template::_parse_conditionals ###############
-       function _parse_conditionals($template)
-       {
-               // Tag locations
-               $location_start = -1;
-               $location_end = -1;
-               
-               // Tag data
-               $tag_start = '<if condition=\\"';
-               $tag_start_end = '\\">';
-               $tag_else = '<else />';
-               $tag_end = '</if>';
-               
-               while (1)
-               {
-                       // Finds the start tag: starts looking through the haystack one position
-                       // after the old startpoint
-                       $location_start = strpos($template, $tag_start, $location_start + 1);
-                       if ($location_start === false)
-                       {       
-                               break;
-                       }
-                       
-                       // Finds the end tag: starts looking through the haystack after the old end
-                       // tag
-                       $location_end = strpos($template, $tag_end, $location_end + strlen($tag_end));
-                       if ($location_end === false)
-                       {
-                               break;
-                       }
-               
-                       // Split the template expression out of the template data
-                       $expression = substr($template, $location_start, ($location_end + strlen($tag_end)) - $location_start);
-                       
-                       // If we have a nested expression, work it out by setting
-                       // the search counters to be one and two after the current
-                       // start point
-                       if (substr_count($expression, $tag_end) > 1)
-                       {
-                               $location_start = $location_start + 1;
-                               $location_end = $location_start + 2;
-                       }
-                       
-                       // Strip out the opening '<if expression="' part of the tag
-                       $shell_removed = substr($expression, strlen($tag_start));
-                       
-                       // Get the position of the end of the '<if epxression="' tag
-                       $shell_end = strpos($shell_removed, $tag_start_end);
-                       
-                       // Take the condition out of the mix
-                       $expression_condition = stripslashes(substr($shell_removed, 0, $shell_end));
-                       
-                       // Now that we've safely stored the condition, parse out the rest of the data
-                       $shell_removed = substr($shell_removed, $shell_end + strlen($tag_start_end));
-                       
-                       // Find the end tag and then take out the iftrue data
-                       $parsed = str_replace($tag_end, '', $shell_removed);
-                       
-                       // Do we have an $tag_else
-                       $location_else = strpos($parsed, $tag_else);
-                       if ($location_else !== false)
-                       {
-                               $data = explode($tag_else, $parsed);
-                               
-                               // um... wtf?
-                               if (count($data) > 2)
-                               {
-                                       user_error('Multiple else statements encountered while parsing conditionals in template', E_USER_WARNING);
-                               }
-                               
-                               // Set the data
-                               $iftrue = $data[0];
-                               $iffalse = $data[1];
-                       }
-                       // Nope, reassign variables
-                       else
-                       {
-                               $iftrue = $parsed;
-                               $iffalse = null;
-                       }
-                       
-                       // Put the condition and iftrue in the iff() function
-                       $parsed_expression = '" . iff(' . stripslashes($expression_condition) . ',"' . $iftrue . '","' . $iffalse . '") . "';
-                       
-                       // Parse the iff()'d expression back into the template data
-                       $template = substr_replace($template, $parsed_expression, $location_start, $location_end + strlen($tag_end) - $location_start);
-               }
-               
-               // Repeat this process until it can't find any more
-               // expressions, then send back the parsed template data
-               // for final output
-               return $template;
-       }
-}
-
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
-?>
\ No newline at end of file
index b560b26993755c4dd35ed4a025027b002ebf0b63..ecae7e021015f15a1a700f667a192eae90e8eb2f 100755 (executable)
@@ -178,7 +178,9 @@ if (!$templatesetid)
 // load the template system
 if (file_exists("./templates/$templateset[shortname]/tsinfo.php"))
 {
-       $bugsys->options['ts_includepath'] = "./templates/$templateset[shortname]/";
+       $bugsys->load('template_fs');
+       $template->extension = 'tpl';
+       $template->templatedir = $bugsys->fetch_sourcepath("templates/$templateset[shortname]/");
 }
 else
 {
index fb4454532cb5a9479422f9fc52bff41813dc17a0..17a729decf995354a63a2d7e5ea0ef71d95971e2 100644 (file)
--- a/index.php
+++ b/index.php
@@ -44,14 +44,14 @@ while ($bug = $db->fetch_array($bugs_fetch))
        $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
        $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
        $bug['lastpostinfo'] = datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'];
-       eval('$bugs .= "' . $tpl->fetch('trackerhome_bits') . '";');
+       eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
 }
 
 $db->free_result($bugs_fetch);
 
 $show['newreport'] = iff(can_perform('cansubmitbugs'), true, false);
 
-eval('$tpl->flush("' . $tpl->fetch('TRACKERHOME') . '");');
+eval('$template->flush("' . $template->fetch('TRACKERHOME') . '");');
 
 /*=====================================================================*\
 || ###################################################################
index 387cb295fded153364ad13249ea9cca0f5069c78..a618faa655bf3f937935115749ca16a50c88b509 100755 (executable)
--- a/login.php
+++ b/login.php
@@ -28,7 +28,7 @@ if ($bugsys->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do']
 
 if (empty($_REQUEST['do']))
 {
-       eval('$tpl->flush("' . $tpl->fetch('login') . '");');
+       eval('$template->flush("' . $template->fetch('login') . '");');
 }
 
 // ###################################################################
index c5ae26b40e492c50f635b5a6f475f99ae73beec7..1ad78f7bf51e8b678c817992cbff3a1e4ed90156 100644 (file)
@@ -72,7 +72,7 @@ if ($_REQUEST['do'] == 'add')
                exit;
        }
        
-       eval('$tpl->flush("' . $tpl->fetch('newcomment') . '");');
+       eval('$template->flush("' . $template->fetch('newcomment') . '");');
 }
 
 /*=====================================================================*\
index 78a78ec09e08ec8bf93f933226d5f8934f7c0630..b240ee3eb165e46cadb11a3ef81e1325db67c952 100755 (executable)
@@ -154,7 +154,7 @@ if ($_REQUEST['do'] == 'add')
        {
                $value = $severity['severityid'];
                $label = $severity['severity'];
-               eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
        }
        
        $show['changestatus'] = iff(can_perform('canchangestatus'), true, false);
@@ -165,21 +165,21 @@ if ($_REQUEST['do'] == 'add')
                {
                        $value = $priority['priorityid'];
                        $label = $priority['priority'];
-                       eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
                }
                
                foreach ($bugsys->datastore['status'] AS $status)
                {
                        $value = $status['statusid'];
                        $label = $status['status'];
-                       eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
                }
                
                foreach ($bugsys->datastore['resolution'] AS $resolution)
                {
                        $value = $resolution['resolutionid'];
                        $label = $resolution['resolution'];
-                       eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";'); 
+                       eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";'); 
                }
        }
        
@@ -191,13 +191,13 @@ if ($_REQUEST['do'] == 'add')
                {
                        $value = $dev['userid'];
                        $label = construct_user_display($dev, false);
-                       eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";');
+                       eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
                }
        }
        
        $pcv_select = construct_pcv_select();
        
-       eval('$tpl->flush("' . $tpl->fetch('newreport') . '");');
+       eval('$template->flush("' . $template->fetch('newreport') . '");');
 }
 
 /*=====================================================================*\
index ae33eeeb3aeef9d20bc9e17f809c78be2065a02e..411c88f7b5941946a14371188cbd1083dfef055a 100755 (executable)
@@ -37,10 +37,10 @@ if (empty($_REQUEST['do']))
        foreach ($bugsys->datastore['language'] AS $value => $temp)
        {
                $label = $temp['title'];
-               eval('$opts .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$opts .= "' . $template->fetch('selectoption') . '";');
        }
        
-       eval('$tpl->flush("' . $tpl->fetch('register') . '");');
+       eval('$template->flush("' . $template->fetch('register') . '");');
 }
 
 // ###################################################################
index 5f0862a0315f0684aa694d3e6d75411c92917262..b7d6d93c9871583dbe30f93749e5a8871606ca83 100644 (file)
@@ -219,10 +219,10 @@ if ($_REQUEST['do'] == 'results')
                $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
                $bug['lastpostinfo'] = datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'];
                $bug['urladd'] = "&amp;hilight=$hilight";
-               eval('$bugs .= "' . $tpl->fetch('trackerhome_bits') . '";');
+               eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
        }
        
-       eval('$tpl->flush("' . $tpl->fetch('search_results') . '");');
+       eval('$template->flush("' . $template->fetch('search_results') . '");');
        
 //     print_r($querybuild);
 }
@@ -240,7 +240,7 @@ if ($_REQUEST['do'] == 'search')
        {
                $value = $severity['severityid'];
                $label = $severity['severity'];
-               eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
        }
        
        $select['priority'] = $blankselect;
@@ -248,7 +248,7 @@ if ($_REQUEST['do'] == 'search')
        {
                $value = $priority['priorityid'];
                $label = $priority['priority'];
-               eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
        }
        
        $select['status'] = $blankselect;
@@ -256,7 +256,7 @@ if ($_REQUEST['do'] == 'search')
        {
                $value = $status['statusid'];
                $label = $status['status'];
-               eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
        }
        
        $select['resolution'] = $blankselect;
@@ -264,7 +264,7 @@ if ($_REQUEST['do'] == 'search')
        {
                $value = $resolution['resolutionid'];
                $label = $resolution['resolution'];
-               eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";'); 
+               eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";'); 
        }
        
        $select['dev'] = $blankselect;
@@ -272,10 +272,10 @@ if ($_REQUEST['do'] == 'search')
        {
                $value = $dev['userid'];
                $label = construct_user_display($dev, false);
-               eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";');
+               eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
        }
        
-       eval('$tpl->flush("' . $tpl->fetch('search') . '");');
+       eval('$template->flush("' . $template->fetch('search') . '");');
 }
 
 /*=====================================================================*\
index 31dfb3646c818ca059256422b4f6dd6ece05ab29..94cd42750811a0c77d366bd6e39880087d4a79b0 100644 (file)
@@ -113,7 +113,7 @@ while ($comment = $db->fetch_array($comments_fetch))
                }
        }
        
-       eval('$comments .= "' . $tpl->fetch('showreport_comment') . '";');
+       eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
 }
 
 if (can_perform('canpostcomments'))
@@ -135,7 +135,7 @@ if (is_array($hilight))
        }
 }
 
-eval('$tpl->flush("' . $tpl->fetch('SHOWREPORT') . '");');
+eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
 
 /*=====================================================================*\
 || ###################################################################