Bug 295394 reporter needs a next and previous navigation feature for incident lists.

This commit is contained in:
robert%accettura.com 2005-11-19 21:41:25 +00:00
Родитель cb0794d35f
Коммит 64ec2b59d0
5 изменённых файлов: 138 добавлений и 14 удалений

Просмотреть файл

@ -73,23 +73,37 @@ $result = $query->doQuery($query_input['selected'],
);
$continuity_params = $query->continuityParams($query_input);
$output = $query->outputHTML($result, $query_input, $continuity_params, $columnHeaders);
// disconnect database
$db->Close();
if (sizeof($output['data']) == 0){
$content->assign('error', 'No Results found');
displayPage($content, 'query', 'query.tpl');
exit;
}
$content->assign('continuity_params', $continuity_params);
$content->assign('column', $query->columnHeaders($query_input, $continuity_params));
$content->assign('row', $output['data']);
$content->assign('continuityParams', $continuity_params[1]);
$content->assign('count', $result['totalResults']);
$content->assign('show', $query_input['show']);
$content->assign('page', $query_input['page']);
// Start Next/Prev Navigation
/*******
* We cap the navigation at 2000 items because php sometimes acts wierd
* when sessions get to big. In most cases, this won't effect anyone.
*******/
if($result['totalResults'] < 2000){
$_SESSION['reportList'] = $result['reportList'];
} else {
unset($_SESSION['reportList']);
$content->assign('notice', 'This query returned too many reports for next/previous navigation to work');
}
$content->assign('continuity_params', $continuity_params);
$content->assign('column', $query->columnHeaders($query_input, $continuity_params));
$content->assign('row', $output['data']);
$content->assign('continuityParams', $continuity_params[1]);
$content->assign('count', $result['totalResults']);
$content->assign('show', $query_input['show']);
$content->assign('page', $query_input['page']);
displayPage($content, 'query', 'query.tpl');
// disconnect database
$db->Close();
?>

Просмотреть файл

@ -41,6 +41,8 @@ require_once($config['base_path'].'/includes/iolib.inc.php');
require_once($config['base_path'].'/includes/db.inc.php');
require_once($config['base_path'].'/includes/contrib/smarty/libs/Smarty.class.php');
require_once($config['base_path'].'/includes/security.inc.php');
require_once($config['base_path'].'/includes/query.inc.php');
// Start Session
session_name('reportSessID');
@ -88,6 +90,42 @@ $content->assign('report_email', $query->fields['report_email']);
$content->assign('report_ip', $query->fields['report_ip']);
$content->assign('report_description', $query->fields['report_description']);
// Last/Next Functionality
if(isset($_SESSION['reportList'])){
$query = new query;
$query_input = $query->getQueryInputs();
$continuity_params = $query->continuityParams($query_input);
$content->assign('continuity_params', $continuity_params[0]);
$reportIndex = array_search($_GET['report_id'], $_SESSION['reportList']);
$content->assign('index', $reportIndex);
$content->assign('total', sizeof($_SESSION['reportList']));
$content->assign('showReportNavigation', true);
if($reportIndex > 0){
$content->assign('first_report', $_SESSION['reportList'][0]);
$content->assign('previous_report', $_SESSION['reportList'][$reportIndex-1]);
} else {
$content->assign('first_report', 'disable');
$content->assign('previous_report', 'disable');
}
if($reportIndex < sizeof($_SESSION['reportList'])-1){
$content->assign('next_report', $_SESSION['reportList'][$reportIndex+1]);
$content->assign('last_report', $_SESSION['reportList'][sizeof($_SESSION['reportList'])-1]);
} else {
$content->assign('next_report', 'disable');
$content->assign('last_report', 'disable');
}
} else {
$content->assign('showReportNavigation', false);
}
$title = 'Mozilla Reporter: '.$query->fields['report_id'];
displayPage($content, 'report', 'report.tpl', $title);

Просмотреть файл

@ -288,6 +288,7 @@ class query
**************/
$dbQuery = $db->SelectLimit($sql,$show,$start,$inputarr=false);
$dbResult = array();
if ($dbQuery){
while (!$dbQuery->EOF) {
$dbResult[] = $dbQuery->fields;
@ -298,14 +299,19 @@ class query
* Count Total
**************/
if($dbQuery){
$totalQuery = $db->Execute("SELECT COUNT(*)
$totalQuery = $db->Execute("SELECT `report_id`
FROM `report`, `host`
$sql_where");
$totalResults = $totalQuery->fields['COUNT(*)'];
$totalResults = array();
if($totalQuery){
while(!$totalQuery->EOF){
$totalResults[] = $totalQuery->fields['report_id'];
$totalQuery->MoveNext();
}
}
}
return array('data' => $dbResult, 'totalResults' => $totalResults);
return array('data' => $dbResult, 'totalResults' => sizeof($totalResults), 'reportList' => $totalResults);
}
function continuityParams($query_input){

Просмотреть файл

@ -4,6 +4,12 @@
<p>{$error}. <a href="javascript:history.go(-1);">Back</a></p>
</div>
{else}
{if $notice != ''}
<div class="notice">
<h3>Notice:</h3>
<p>{$notice}</p>
</div>
{/if}
<table id="reporterQuery" class="fixedTable" cellspacing="0" cellpadding="0" style="width:100%">
<tr class="header">
{section name=mysec loop=$column}
@ -73,6 +79,8 @@ Show: {$show}
TotPage: {$totalPages}
</pre>
*}
<br />
<p><small>Your query returned {$count} reports</small></p>
</div>
{/if}
{/if}

Просмотреть файл

@ -64,5 +64,63 @@
<div class="title">Description:</div>
<div class="data">{$report_description}&nbsp; {*this space at the end fixes some formatting issues with no text in this optional field *}</div>
</div>
<div id="reportNavigation">
<p>
{if $showReportNavigation == true}
<strong>Report List ({$index+1} of {$total}):</strong> &nbsp;
{strip}
{if $first_report != 'disable'}
<a href="{$base_url}/app/report/?report_id={$first_report}&amp;{$continuity_params}" accesskey="f" title="First Report in List (Access Key 'F')">
{/if}
First
{if $first_report != 'disable'}
</a>
{/if}
{/strip}
|
{strip}
{if $previous_report != 'disable'}
<a href="{$base_url}/app/report/?report_id={$previous_report}&amp;{$continuity_params}" accesskey="p" title="Previous Report in List (Access Key 'p')">
{/if}
Previous
{if $previous_report != 'disable'}
</a>
{/if}
{/strip}
|
{strip}
{if $next_report != 'disable'}
<a href="{$base_url}/app/report/?report_id={$next_report}&amp;{$continuity_params}" accesskey="n" title="Next Report in List (Access Key 'N')">
{/if}
Next
{if $next_report != 'disable'}
</a>
{/if}
{/strip}
|
{strip}
{if $last_report != 'disable'}
<a href="{$base_url}/app/report/?report_id={$last_report}&amp;{$continuity_params}" accesskey="l" title="Last Report in List (Access Key 'L')">
{/if}
Last
{if $last_report != 'disable'}
</a>
{/if}
{/strip}
{/if}
|
<a href="{$base_url}/app/query/?{$continuity_params}" accesskey="b" title="Back to the Query List (Access Key 'B')">Back To List</a>
|
<a href="{$base_url}/app/" accesskey="q" title="New Search (Access Key 'Q')">New Search</a>
</p>
</div>
{/if}