You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php /** * @copyright NetMonsters <team@netmonsters.ru> * @link http://netmonsters.ru * @package Majestic * @subpackage app * @since 2010-03-07 * @version SVN: $Id$ * @filesource $URL$ */
class PagerAction extends ViewAction { public $page; public $last_page; //protected $num_rows;
protected $offset = 0; protected $count = 0; protected $limit;
public function __construct($count, $limit = 20) { $this->count = $count; $this->limit = $limit; parent::__construct(); } protected function execute() { $page = (int) Env::Get('p'); $this->last_page = ceil($this->count/$this->limit); $this->page = ($page <= $this->last_page && $page > 0) ? $page : 1; $this->offset = $this->limit * ($this->page - 1); //$this->num_rows = ($this->limit + $this->offset) <= $this->count ? ($this->limit + $this->offset) : $this->count;
}
public function getOffset() { return $this->offset; }
public function getLimit() { return $this->limit; } protected function getTemplate() { $template = ($this->template) ? $this->template : substr(get_class($this), 0, -6/*strlen('Action')*/); return '/actions/' . $template; }
/* public function setNumRows($num_rows) { $this->num_rows = $num_rows; } */ /*function prepare() { $this->templater->assign('page', $this->page); $this->templater->assign('page_max', $this->max_page_num); }*/ }
|