Some cleanup to query class, as well as fix an issue with continuity params being used incorrectly when displaying a report. Some small optimizations as well.
git-svn-id: svn://10.0.0.236/trunk@190331 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
71dde5ebcd
commit
df3cb76a15
@ -59,27 +59,12 @@ $db = NewDBConnection($config['db_dsn']);
|
||||
$db->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
|
||||
$query = new query;
|
||||
$query_input = $query->getQueryInputs();
|
||||
|
||||
$continuityParams = $query->continuityParams($query_input, null);
|
||||
|
||||
$columnHeaders = $query->columnHeaders($query_input, $continuityParams);
|
||||
|
||||
$result = $query->doQuery($query_input['selected'],
|
||||
$query_input['where'],
|
||||
$query_input['orderby'],
|
||||
$query_input['show'],
|
||||
$query_input['page'],
|
||||
$query_input['product_family'],
|
||||
$query_input['count']
|
||||
);
|
||||
|
||||
$output = $query->outputHTML($result, $query_input, $continuityParams, $columnHeaders);
|
||||
$query->doQuery();
|
||||
|
||||
// disconnect database
|
||||
$db->Close();
|
||||
|
||||
if (sizeof($output['data']) == 0){
|
||||
if ($query->totalResults == 0){
|
||||
$content->assign('error', 'No Results found');
|
||||
displayPage($content, 'query', 'query.tpl');
|
||||
exit;
|
||||
@ -88,43 +73,45 @@ if (sizeof($output['data']) == 0){
|
||||
// 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.
|
||||
* when sessions get to big. In most cases, this won't effect anyone. Note
|
||||
* that reportList won't ever return more than max_nav_count by design.
|
||||
*******/
|
||||
if($result['totalResults'] < $config['max_nav_count']){
|
||||
$_SESSION['reportList'] = $result['reportList'];
|
||||
if($query->totalResults < $config['max_nav_count']){
|
||||
$_SESSION['reportList'] = $query->reportList;
|
||||
} else {
|
||||
unset($_SESSION['reportList']);
|
||||
$content->assign('notice', 'This query returned too many reports for next/previous navigation to work');
|
||||
}
|
||||
|
||||
$content->assign('column', $columnHeaders);
|
||||
$content->assign('row', $output['data']);
|
||||
$content->assign('column', $query->columnHeaders());
|
||||
$content->assign('row', $query->outputHTML());
|
||||
|
||||
/* this particular continuity_params is for pagination (it doesn't include 'page') */
|
||||
$content->assign('continuity_params', $query->continuityParams($query_input, array('page')));
|
||||
$content->assign('continuity_params', $query->continuityParams(array('page')));
|
||||
|
||||
/* Pagination */
|
||||
$pages = ceil($result['totalResults']/$query_input['show']);
|
||||
$pages = ceil($query->totalResults/$query->show);
|
||||
|
||||
/* These variables are also used for pagination purposes */
|
||||
$content->assign('count', $result['totalResults']);
|
||||
$content->assign('show', $query_input['show']);
|
||||
$content->assign('page', $query_input['page']);
|
||||
$content->assign('count', $query->totalResults);
|
||||
$content->assign('show', $query->show);
|
||||
$content->assign('page', $query->page);
|
||||
$content->assign('pages', $pages);
|
||||
|
||||
if($query_input['page'] > 10){
|
||||
$start = $query_input['page']-10;
|
||||
if($query->page > 10){
|
||||
$start = $query->page-10;
|
||||
}
|
||||
if($query_input['page'] < 10){
|
||||
if($query->page < 10){
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
$content->assign('start', $start);
|
||||
$content->assign('step', 1);
|
||||
if(ceil($result['totalResults']/$query_input['show']) < 20){
|
||||
$content->assign('amt', ceil($result['totalResults']/$query_input['show']));
|
||||
if(ceil($query->totalResults/$query->show) < 20){
|
||||
$content->assign('amt', ceil($query->totalResults/$query->show));
|
||||
} else {
|
||||
$content->assign('amt', 20);
|
||||
}
|
||||
|
||||
displayPage($content, 'query', 'query.tpl');
|
||||
?>
|
||||
@ -85,10 +85,19 @@ if (!$reportQuery->fields){
|
||||
exit;
|
||||
}
|
||||
|
||||
// We need this for continuity params in particular
|
||||
$query = new query;
|
||||
$query_input = $query->getQueryInputs();
|
||||
|
||||
|
||||
$title = "Report for ".$reportQuery->fields['host_hostname']." - ".$reportQuery->fields['report_id'];
|
||||
$content->assign('report_id', $reportQuery->fields['report_id']);
|
||||
$content->assign('report_url', $reportQuery->fields['report_url']);
|
||||
$content->assign('host_url', $config['base_url'].'/app/query/?host_hostname='.$reportQuery->fields['host_hostname'].'&submit_query=Query');
|
||||
|
||||
$host_continuity_params = $query->continuityParams(array('report_id', 'report_product', 'report_file_date', 'product_family', 'page'));
|
||||
$content->assign('host_continuity_params', $host_continuity_params);
|
||||
|
||||
$content->assign('host_url', $config['base_url'].'/app/query/?host_hostname='.$reportQuery->fields['host_hostname'].'&'.$host_continuity_params.'submit_query=Query');
|
||||
$content->assign('host_hostname', $reportQuery->fields['host_hostname']);
|
||||
$content->assign('report_problem_type', resolveProblemTypes($reportQuery->fields['report_problem_type']));
|
||||
$content->assign('report_behind_login', resolveBehindLogin($reportQuery->fields['report_behind_login']));
|
||||
@ -110,15 +119,13 @@ if($screenshot){
|
||||
|
||||
// Last/Next Functionality
|
||||
if(isset($_SESSION['reportList'])){
|
||||
$query = new query;
|
||||
$query_input = $query->getQueryInputs();
|
||||
$nav_continuity_params = $query->continuityParams(array('report_id'));
|
||||
|
||||
$continuity_params = $query->continuityParams($query_input, null);
|
||||
|
||||
$content->assign('continuity_params', $continuity_params);
|
||||
$content->assign('nav_continuity_params', $nav_continuity_params);
|
||||
|
||||
$reportIndex = array_search($_GET['report_id'], $_SESSION['reportList']);
|
||||
|
||||
//print $reportIndex.$_SESSION['reportList'][$reportIndex];
|
||||
//die();
|
||||
$content->assign('index', $reportIndex);
|
||||
$content->assign('total', sizeof($_SESSION['reportList']));
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ function show(aItem){
|
||||
<strong>Report List ({$index+1} of {$total}):</strong>
|
||||
{strip}
|
||||
{if $first_report != 'disable'}
|
||||
<a href="{$base_url}/app/report/?report_id={$first_report}&{$continuity_params}" accesskey="f" title="First Report in List (Access Key 'F')">
|
||||
<a href="{$base_url}/app/report/?report_id={$first_report}&{$nav_continuity_params}" accesskey="f" title="First Report in List (Access Key 'F')">
|
||||
{/if}
|
||||
First
|
||||
{if $first_report != 'disable'}
|
||||
@ -131,7 +131,7 @@ function show(aItem){
|
||||
|
||||
{strip}
|
||||
{if $previous_report != 'disable'}
|
||||
<a href="{$base_url}/app/report/?report_id={$previous_report}&{$continuity_params}" accesskey="p" title="Previous Report in List (Access Key 'p')">
|
||||
<a href="{$base_url}/app/report/?report_id={$previous_report}&{$nav_continuity_params}" accesskey="p" title="Previous Report in List (Access Key 'p')">
|
||||
{/if}
|
||||
Previous
|
||||
{if $previous_report != 'disable'}
|
||||
@ -143,7 +143,7 @@ function show(aItem){
|
||||
|
||||
{strip}
|
||||
{if $next_report != 'disable'}
|
||||
<a href="{$base_url}/app/report/?report_id={$next_report}&{$continuity_params}" accesskey="n" title="Next Report in List (Access Key 'N')">
|
||||
<a href="{$base_url}/app/report/?report_id={$next_report}&{$nav_continuity_params}" accesskey="n" title="Next Report in List (Access Key 'N')">
|
||||
{/if}
|
||||
Next
|
||||
{if $next_report != 'disable'}
|
||||
@ -155,7 +155,7 @@ function show(aItem){
|
||||
|
||||
{strip}
|
||||
{if $last_report != 'disable'}
|
||||
<a href="{$base_url}/app/report/?report_id={$last_report}&{$continuity_params}" accesskey="l" title="Last Report in List (Access Key 'L')">
|
||||
<a href="{$base_url}/app/report/?report_id={$last_report}&{$nav_continuity_params}" accesskey="l" title="Last Report in List (Access Key 'L')">
|
||||
{/if}
|
||||
Last
|
||||
{if $last_report != 'disable'}
|
||||
@ -166,7 +166,7 @@ function show(aItem){
|
||||
|
|
||||
|
||||
{/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/query/?{$nav_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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user