Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / index.php
index 9b8626a1a3f50c23ed1ee34f20d79ff82a988e52..bd85cddffca5bb6997ff55b80ecff9539395f2a3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,12 +1,12 @@
 <?php
 /*=====================================================================*\
 || ###################################################################
-|| # Bugdar [#]version[#]
-|| # Copyright ©2002-[#]year[#] Blue Static
+|| # Bugdar
+|| # 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
-|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| # the Free Software Foundation; version 2 of the License.
 || #
 || # This program is distributed in the hope that it will be useful, but
 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 $fetchtemplates = array(
        'trackerhome',
        'trackerhome_bits',
+       'list_head',
        'pagenav',
        'pagenav_bit'
 );
 
-define('SVN', '$Id$');
 
 $focus['index'] = 'focus';
 
 require_once('./global.php');
-require_once('./includes/class_pagination.php');
 require_once('./includes/class_sort.php');
 
 if (!can_perform('canviewbugs'))
 {
-       $message->error_permission();
+       $message->errorPermission();
 }
 
 $sort = new ListSorter('index');
 
+require_once 'includes/pagination.php';
+$pagination = new Pagination();
+$pagination->processIncomingData();
+
 // ###################################################################
 
-$pagination = new Pagination('p', 'pp');
-$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']) . ")" : "")
 );
 
-$pagination->total = $count['count'];
-$pagination->split_pages();
+if (!$count['count'])
+{
+       $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.'));
+}
 
-$bugs_fetch = $db->query($sort->fetch_sql_query(null, $pagination->fetch_limit($pagination->page - 1) . ", " . $pagination->perpage));
+$pagination->setTotal($count['count']);
+$pagination->splitPages();
 
-while ($bug = $db->fetch_array($bugs_fetch))
+$bugs_fetch = $db->query($sort->fetchSqlQuery(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
+
+foreach ($bugs_fetch as $bug)
 {
-       $funct->exec_swap_bg($stylevar['alt_color'], '');       
-       ProcessBugDataForDisplay(&$bug, $funct->bgcolour);
-       eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
+       BSFunctions::swap_css_classes('altcolor', '');  
+       $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
+       $bugs .= $sort->constructRow($bug);
 }
 
-$db->free_result($bugs_fetch);
+$bugs_fetch->free();
 
-$order = $sort->fetch_display_array('p=' . $pagination->page . '&amp;pp=' . $pagination->perpage);
-$show['pagenav'] = (($pagination->pagecount > 1) ? true : false);
-$pagenav = $pagination->construct_page_nav($sort->fetch_sort_link($sort->sortkey));
+$columnHeads = $sort->constructColumnHeaders(true, 'p=' . $pagination->page . '&amp;pp=' . $pagination->perpage);
+$show['pagenav'] = ($pagination->getPageCount() > 1);
 
-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