Fixed event and frame navigation.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1581 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-08 17:57:41 +00:00
parent 7257cb5f9d
commit bdc7931ee4
5 changed files with 70 additions and 30 deletions

View File

@ -759,7 +759,7 @@ function deScale( $dimension, $dummy )
return( $dimension ); return( $dimension );
} }
function parseSort( $save_to_session=false ) function parseSort( $save_to_session=false, $term_sep='&' )
{ {
global $sort_field, $sort_asc; // Inputs global $sort_field, $sort_asc; // Inputs
global $sort_query, $sort_column, $sort_order; // Outputs global $sort_query, $sort_column, $sort_order; // Outputs
@ -815,7 +815,7 @@ function parseSort( $save_to_session=false )
} }
$sort_order = $sort_asc?"asc":"desc"; $sort_order = $sort_asc?"asc":"desc";
if ( !$sort_asc ) $sort_asc = 0; if ( !$sort_asc ) $sort_asc = 0;
$sort_query = "&sort_field=$sort_field&sort_asc=$sort_asc"; $sort_query = $term_sep."sort_field=".$sort_field.$term_sep."sort_asc=".$sort_asc;
if ( $save_to_session ) if ( $save_to_session )
{ {
$_SESSION['sort_field'] = $sort_field; $_SESSION['sort_field'] = $sort_field;
@ -823,7 +823,7 @@ function parseSort( $save_to_session=false )
} }
} }
function parseFilter( $save_to_session=false ) function parseFilter( $save_to_session=false, $term_sep='&' )
{ {
global $trms; // Inputs global $trms; // Inputs
global $filter_query, $filter_sql, $filter_fields; // Outputs global $filter_query, $filter_sql, $filter_fields; // Outputs
@ -842,7 +842,7 @@ function parseFilter( $save_to_session=false )
{ {
$_SESSION['trms'] = $trms; $_SESSION['trms'] = $trms;
} }
$filter_query .= "&trms=$trms"; $filter_query .= $term_sep."trms=".$trms;
$filter_fields .= '<input type="hidden" name="trms" value="'.$trms.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="trms" value="'.$trms.'"/>'."\n";
for ( $i = 1; $i <= $trms; $i++ ) for ( $i = 1; $i <= $trms; $i++ )
@ -858,7 +858,7 @@ function parseFilter( $save_to_session=false )
if ( isset($$conjunction_name) ) if ( isset($$conjunction_name) )
{ {
$filter_query .= "&$conjunction_name=".$$conjunction_name; $filter_query .= $term_sep.$conjunction_name."=".$$conjunction_name;
$filter_sql .= " ".$$conjunction_name." "; $filter_sql .= " ".$$conjunction_name." ";
$filter_fields .= '<input type="hidden" name="'.$conjunction_name.'" value="'.$$conjunction_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$conjunction_name.'" value="'.$$conjunction_name.'"/>'."\n";
if ( $save_to_session ) if ( $save_to_session )
@ -868,7 +868,7 @@ function parseFilter( $save_to_session=false )
} }
if ( isset($$obracket_name) ) if ( isset($$obracket_name) )
{ {
$filter_query .= "&$obracket_name=".$$obracket_name; $filter_query .= $term_sep.$obracket_name."=".$$obracket_name;
$filter_sql .= str_repeat( "(", $$obracket_name ); $filter_sql .= str_repeat( "(", $$obracket_name );
$filter_fields .= '<input type="hidden" name="'.$obracket_name.'" value="'.$$obracket_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$obracket_name.'" value="'.$$obracket_name.'"/>'."\n";
if ( $save_to_session ) if ( $save_to_session )
@ -878,7 +878,7 @@ function parseFilter( $save_to_session=false )
} }
if ( isset($$attr_name) ) if ( isset($$attr_name) )
{ {
$filter_query .= "&$attr_name=".$$attr_name; $filter_query .= $term_sep.$attr_name."=".$$attr_name;
$filter_fields .= '<input type="hidden" name="'.$attr_name.'" value="'.$$attr_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$attr_name.'" value="'.$$attr_name.'"/>'."\n";
switch ( $$attr_name ) switch ( $$attr_name )
{ {
@ -972,9 +972,9 @@ function parseFilter( $save_to_session=false )
break; break;
} }
$filter_query .= "&$op_name=".urlencode($$op_name); $filter_query .= $term_sep.$op_name."=".urlencode($$op_name);
$filter_fields .= '<input type="hidden" name="'.$op_name.'" value="'.$$op_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$op_name.'" value="'.$$op_name.'"/>'."\n";
$filter_query .= "&$value_name=".urlencode($$value_name); $filter_query .= $term_sep.$value_name."=".urlencode($$value_name);
$filter_fields .= '<input type="hidden" name="'.$value_name.'" value="'.$$value_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$value_name.'" value="'.$$value_name.'"/>'."\n";
if ( $save_to_session ) if ( $save_to_session )
{ {
@ -985,7 +985,7 @@ function parseFilter( $save_to_session=false )
} }
if ( isset($$cbracket_name) ) if ( isset($$cbracket_name) )
{ {
$filter_query .= "&$cbracket_name=".$$cbracket_name; $filter_query .= $term_sep.$cbracket_name."=".$$cbracket_name;
$filter_sql .= str_repeat( ")", $$cbracket_name ); $filter_sql .= str_repeat( ")", $$cbracket_name );
$filter_fields .= '<input type="hidden" name="'.$cbracket_name.'" value="'.$$cbracket_name.'"/>'."\n"; $filter_fields .= '<input type="hidden" name="'.$cbracket_name.'" value="'.$$cbracket_name.'"/>'."\n";
if ( $save_to_session ) if ( $save_to_session )

View File

@ -268,9 +268,14 @@ function viewEvents( form, name )
if ( $page > 1 ) if ( $page > 1 )
{ {
if ( false && $page > 2 )
{
?> ?>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=1<?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&lt;&lt;</a> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=1<?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&lt;&lt;</a>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $page - 1 ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&lt;</a> <?php
}
?>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $page - 1 ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&lt;</a>
<?php <?php
$new_pages = array(); $new_pages = array();
$pages_used = array(); $pages_used = array();
@ -324,9 +329,14 @@ function viewEvents( form, name )
<?php <?php
} }
?> ?>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $page + 1 ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&gt;</a> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $page + 1 ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&gt;</a>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $pages ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&gt;&gt;</a>
<?php <?php
if ( false && $page < ($pages-1) )
{
?>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&page=<?= $pages ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>">&gt;&gt;</a>
<?php
}
} }
?> ?>
</td> </td>

View File

@ -1157,9 +1157,9 @@ div.zoom {
<div id="ImageNav"> <div id="ImageNav">
<div id="Image"><img id="ImageSrc" src="graphics/spacer.gif" height="<?= $chart['image']['height'] ?>"/></div> <div id="Image"><img id="ImageSrc" src="graphics/spacer.gif" height="<?= $chart['image']['height'] ?>"/></div>
<div id="RightNav"> <div id="RightNav">
<a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&mid_time=<?= urlencode($min_time) ?>&range=<?= $range ?>">&lt;&lt;</a>&nbsp;&nbsp; <a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&mid_time=<?= urlencode($min_time) ?>&range=<?= $range ?>">&lt;</a>&nbsp;&nbsp;
<a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&mid_time=<?= urlencode($mid_time) ?>&range=<?= (int)($range*$maj_x_scale['zoomout']) ?>">-</a>&nbsp;&nbsp; <a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&mid_time=<?= urlencode($mid_time) ?>&range=<?= (int)($range*$maj_x_scale['zoomout']) ?>">-</a>&nbsp;&nbsp;
<a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&min_time=<?= urlencode($mid_time) ?>&range=<?= $range ?>">&gt;&gt;</a> <a href="<?= $PHP_SELF ?>?view=<?= $view ?><?= $filter_query ?>&min_time=<?= urlencode($mid_time) ?>&range=<?= $range ?>">&gt;</a>
</div> </div>
<div id="ImageText">No Event</div> <div id="ImageText">No Event</div>
<div id="Key"> <div id="Key">

View File

@ -60,8 +60,8 @@ elseif ( isset( $fid ) )
$fid = $frame['FrameId']; $fid = $frame['FrameId'];
} }
parseSort(); parseSort( true, '&amp;' );
parseFilter(); parseFilter( true, '&amp;' );
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column ".($sort_order=='asc'?'<=':'>=')." '".$event[$sort_field]."'$filter_sql$mid_sql order by $sort_column ".($sort_order=='asc'?'desc':'asc'); $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column ".($sort_order=='asc'?'<=':'>=')." '".$event[$sort_field]."'$filter_sql$mid_sql order by $sort_column ".($sort_order=='asc'?'desc':'asc');
$result = mysql_query( $sql ); $result = mysql_query( $sql );
@ -127,8 +127,13 @@ if ( $paged && !empty($page) )
if ( $page > 1 ) if ( $page > 1 )
{ {
if ( false && $page > 2 )
{
?> ?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=1">&lt;&lt;</a></td> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=1">&lt;&lt;</a></td>
<?php
}
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page-1 ?>">&lt;</a></td> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page-1 ?>">&lt;</a></td>
<?php <?php
$new_pages = array(); $new_pages = array();
@ -183,8 +188,13 @@ if ( $paged && !empty($page) )
} }
?> ?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page+1 ?>">&gt;</a></td> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page+1 ?>">&gt;</a></td>
<?php
if ( false && $page < ($pages-1) )
{
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $pages ?>">&gt;&gt;</a></td> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=event&amp;mode=still&amp;eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $pages ?>">&gt;&gt;</a></td>
<?php <?php
}
} }
?> ?>
</tr> </tr>

View File

@ -69,8 +69,8 @@ else
$events_sql .= " 1"; $events_sql .= " 1";
} }
parseSort( true ); parseSort( true, '&amp;' );
parseFilter( true ); parseFilter( true, '&amp;' );
if ( $filter_sql ) if ( $filter_sql )
{ {
@ -127,14 +127,15 @@ if ( !empty($limit) && $n_events > $limit )
</table> </table>
<?php <?php
$pages = (int)ceil($n_events/$device_lines); $pages = (int)ceil($n_events/$device_lines);
$max_shortcuts = 3;
if ( $pages > 1 ) if ( $pages > 1 )
{ {
if ( $page )
{
?> ?>
<p align="center"> <table style="width:100%">
<tr>
<?php <?php
$max_shortcuts = 2; if ( !empty($page) )
{
if ( $page < 0 ) if ( $page < 0 )
$page = 1; $page = 1;
if ( $page > $pages ) if ( $page > $pages )
@ -142,6 +143,15 @@ if ( !empty($limit) && $n_events > $limit )
if ( $page > 1 ) if ( $page > 1 )
{ {
if ( false && $page > 2 )
{
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=1">&lt;&lt;</a></td>
<?php
}
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page-1 ?>">&lt;</a></td>
<?php
$new_pages = array(); $new_pages = array();
$pages_used = array(); $pages_used = array();
$lo_exp = max(2,log($page-1)/log($max_shortcuts)); $lo_exp = max(2,log($page-1)/log($max_shortcuts));
@ -161,12 +171,12 @@ if ( !empty($limit) && $n_events > $limit )
foreach ( $new_pages as $new_page ) foreach ( $new_pages as $new_page )
{ {
?> ?>
<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;page=<?= $new_page ?>&amp;limit=<?= $limit ?>"><?= $new_page ?></a>&nbsp; <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $new_page ?>"><?= $new_page ?></a></td>
<?php <?php
} }
} }
?> ?>
-&nbsp;<?= $page ?>&nbsp;- <td align="center" class="text"><?= $page ?></td>
<?php <?php
if ( $page < $pages ) if ( $page < $pages )
{ {
@ -189,14 +199,24 @@ if ( !empty($limit) && $n_events > $limit )
foreach ( $new_pages as $new_page ) foreach ( $new_pages as $new_page )
{ {
?> ?>
&nbsp;<a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;page=<?= $new_page ?>&amp;limit=<?= $limit ?>"><?= $new_page ?></a> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $new_page ?>"><?= $new_page ?></a></td>
<?php
}
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $page+1 ?>">&gt;</a></td>
<?php
if ( false && $page < ($pages-1) )
{
?>
<td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&amp;limit=<?= $limit ?><?= $filter_query ?><?= $sort_query ?>&amp;page=<?= $pages ?>">&gt;&gt;</a></td>
<?php <?php
} }
} }
?>
</p>
<?php
} }
?>
</tr>
</table>
<?php
} }
?> ?>
<table bgcolor="#7F7FB2"> <table bgcolor="#7F7FB2">