<?php
class PageNavigator_AutoScroll_FormButtons extends PageNavigator_AutoScroll
{
/**
* Form method.
*
* @var string
* @access private
*/
var $method = "get";
function setMethod($method)
{
$this->method = ($method == 'post' ? 'post' : 'get');
}
function getMethod()
{
return ($this->method == 'post' ? 'post' : 'get');
}
function PageNavigator_AutoScroll_FormButtons($current_page=0, $records_per_page=15, $total_records=0, $min_pages_per_set=10, $max_pages_per_set=20, $show_side_pages=-1, $query_vars='')
{
PageNavigator_AutoScroll::PageNavigator_AutoScroll($current_page, $records_per_page, $total_records, $min_pages_per_set, $max_pages_per_set, $show_side_pages, $query_vars);
}
function formatActivePage($pagenum)
{
return '<td width="30" align="center"><strong>'.$pagenum.'</strong></td>'."\n";
}
function formatPage($pagenum)
{
return '<td width="30" align="center"><input type="submit" '.$this->prepareQueryVars($pagenum).' class="buttons"></td>'."\n";
}
function formatMovePrevious($pagenum)
{
return $this->empty_cell;
}
function formatMoveNext($pagenum)
{
return $this->empty_cell;
}
function formatHeader()
{
global $PHP_SELF;
return '<form method="get" action="'.$PHP_SELF.'"><table bgcolor="#FFFFFF" border="0" cellpadding="2" cellspacing="0" bgcolor="#000000">
<tr valign="middle">';
}
function formatFooter()
{
// get all variables from $HTTP_GET_VARS or $HTTP_POST_VARS
$query_var_container = 'HTTP_'.strtoupper($this->getMethod()).'_VARS';
global $$query_var_container;
$query_vars = $$query_var_container;
// strip control variables from query string
foreach ($this->query_vars as $v)
{
unset($query_vars[$v]);
}
// get all variables into hidden form elements
$hidden = '';
foreach ($query_vars as $k=>$v)
{
$hidden .= "<input type=\"hidden\" name=\"$k\" value=\"".addslashes($v)."\">\n";
}
if (isset($this->query_vars['from']))
{
$from = ($pagenum * $this->records_per_page) - $this->records_per_page + 1;
$hidden .= "<input type=\"hidden\" name=\"".$this->query_vars['from']."\" value=\"$from\">\n";
if (isset($this->query_vars['to']))
{
$hidden .= "<input type=\"hidden\" name=\"".
$this->query_vars['to'].
"\" value=\"".
($pagenum * $this->records_per_page)."\">\n";
}
elseif (isset($this->query_vars['count']))
{
$hidden .= "<input type=\"hidden\" name=\"".
$this->query_vars['count'].
"\" value=\"".
$this->records_per_page."\">\n";
}
}
return $hidden."</form></tr>\n</table>\n";
}
function prepareQueryVars($pagenum)
{
$ret = '';
if (!isset($this->query_vars['page'])) $this->query_vars['page'] = 'page';
$ret = 'name="'.$this->query_vars['page'].'" value="'.$pagenum.'"';
return $ret;
} // end func prepareQueryVars
}
?> |