forked from Public/pics
Refactor GenericTable to use PageIndex rather than inherit from it
This has on my todo list for years... I'm glad to finally get around to it.
This commit is contained in:
@@ -8,23 +8,35 @@
|
||||
|
||||
class PageIndex
|
||||
{
|
||||
protected $page_index = [];
|
||||
protected $base_url;
|
||||
protected $current_page = 1;
|
||||
protected $index_class = 'pagination';
|
||||
protected $items_per_page = 0;
|
||||
protected $needsPageIndex = false;
|
||||
protected $num_pages = 1;
|
||||
protected $recordCount = 0;
|
||||
protected $start = 0;
|
||||
protected $sort_order = null;
|
||||
protected $sort_direction = null;
|
||||
protected $base_url;
|
||||
protected $index_class = 'pagination';
|
||||
protected $page_index = [];
|
||||
protected $page_slug = '%AMP%page=%PAGE%';
|
||||
protected $recordCount = 0;
|
||||
protected $sort_direction = null;
|
||||
protected $sort_order = null;
|
||||
protected $start = 0;
|
||||
|
||||
public function __construct($options)
|
||||
{
|
||||
foreach ($options as $key => $value)
|
||||
$this->$key = $value;
|
||||
static $neededKeys = ['base_url', 'items_per_page', 'recordCount'];
|
||||
foreach ($neededKeys as $key)
|
||||
{
|
||||
if (!isset($options[$key]))
|
||||
throw new Exception('PageIndex: argument ' . $key . ' missing in options');
|
||||
|
||||
$this->$key = $options[$key];
|
||||
}
|
||||
|
||||
static $optionalKeys = ['index_class', 'page_slug', 'sort_direction', 'sort_order', 'start'];
|
||||
foreach ($optionalKeys as $key)
|
||||
if (isset($options[$key]))
|
||||
$this->$key = $options[$key];
|
||||
|
||||
$this->generatePageIndex();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user