Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / index.php
index 71958bbff6374bde68ff65a16ca8d63f8bc12783..bd85cddffca5bb6997ff55b80ecff9539395f2a3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Bugdar
-|| # Copyright ©2002-2007 Blue Static
+|| # Copyright (c)2004-2009 Blue Static
 || #
 || # This program is free software; you can redistribute it and/or modify
 || # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@ $fetchtemplates = array(
        'pagenav_bit'
 );
 
-define('SVN', '$Id$');
 
 $focus['index'] = 'focus';
 
@@ -40,47 +39,49 @@ if (!can_perform('canviewbugs'))
 }
 
 $sort = new ListSorter('index');
-LoadPaginationFramework();
+
+require_once 'includes/pagination.php';
+$pagination = new Pagination();
+$pagination->processIncomingData();
 
 // ###################################################################
 
-$count = $db->query_first("
+$count = $db->queryFirst("
        SELECT COUNT(*) AS count
        FROM " . TABLE_PREFIX . "bug
-       WHERE (!hidden OR (hidden AND product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (hidden AND userid = " . $bugsys->userinfo['userid'] . " AND product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
-       AND product IN (" . fetch_on_bits('canviewbugs') . ")" . (($bugsys->options['hidestatuses'] OR isset($bugsys->userinfo['hidestatuses'])) ? "
-       AND status NOT IN (" . ($bugsys->userinfo['hidestatuses'] != '' ? $bugsys->userinfo['hidestatuses'] : $bugsys->options['hidestatuses']) . ")" : "")
+       WHERE (!hidden OR (hidden AND product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (hidden AND userid = " . bugdar::$userinfo['userid'] . " AND product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
+       AND product IN (" . fetch_on_bits('canviewbugs') . ")" . ((bugdar::$options['hidestatuses'] OR isset(bugdar::$userinfo['hidestatuses'])) ? "
+       AND status NOT IN (" . (bugdar::$userinfo['hidestatuses'] != '' ? bugdar::$userinfo['hidestatuses'] : bugdar::$options['hidestatuses']) . ")" : "")
 );
 
 if (!$count['count'])
 {
-       $message->error(_('There are no bugs to display. This could be because you do not have permission to view bugs, or there may be none in the database.'));
+       $message->error(T('There are no bugs to display. This could be because you do not have permission to view bugs, or there may be none in the database.'));
 }
 
 $pagination->setTotal($count['count']);
 $pagination->splitPages();
 
-$bugs_fetch = $db->query($sort->fetch_sql_query(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
+$bugs_fetch = $db->query($sort->fetchSqlQuery(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
 
-while ($bug = $db->fetch_array($bugs_fetch))
+foreach ($bugs_fetch as $bug)
 {
-       $funct->exec_swap_bg('altcolor', '');   
-       $bug = ProcessBugDataForDisplay($bug, $funct->bgcolour);
+       BSFunctions::swap_css_classes('altcolor', '');  
+       $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
        $bugs .= $sort->constructRow($bug);
 }
 
-$db->free_result($bugs_fetch);
+$bugs_fetch->free();
 
 $columnHeads = $sort->constructColumnHeaders(true, 'p=' . $pagination->page . '&pp=' . $pagination->perpage);
 $show['pagenav'] = ($pagination->getPageCount() > 1);
-$pagenav = $pagination->constructPageNav($sort->fetch_sort_link($sort->sortkey));
 
-eval('$template->flush("' . $template->fetch('trackerhome') . '");');
+$tpl = new BSTemplate('trackerhome');
+$tpl->vars = array(
+       'columnHeads'   => $columnHeads,
+       'bugs'                  => $bugs,
+       'pagenav'               => $pagination->constructPageNav($sort->fetchSortLink($sort->sortkey))
+);
+$tpl->evaluate()->flush();
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file