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:
Aaron committed 2021-02-17 20:43:30 +01:00
1 parent 96937b6952
commit cba42a9129
3 files changed
+66 -28

No files matched your search

+21 -9
View File
@@ -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();
}