Refactor generic tables and page index classes #26
@ -42,7 +42,7 @@ class GenericTable extends PageIndex
|
|||||||
// Should we create a page index?
|
// Should we create a page index?
|
||||||
$this->items_per_page = !empty($options['items_per_page']) ? $options['items_per_page'] : 30;
|
$this->items_per_page = !empty($options['items_per_page']) ? $options['items_per_page'] : 30;
|
||||||
$this->needsPageIndex = !empty($this->items_per_page) && $this->recordCount > $this->items_per_page;
|
$this->needsPageIndex = !empty($this->items_per_page) && $this->recordCount > $this->items_per_page;
|
||||||
$this->index_class = isset($options['index_class']) ? $options['index_class'] : '';
|
$this->index_class = $options['index_class'] ?? '';
|
||||||
|
|
||||||
// Figure out where to start.
|
// Figure out where to start.
|
||||||
$this->start = empty($options['start']) || !is_numeric($options['start']) || $options['start'] < 0 || $options['start'] > $this->recordCount ? 0 : $options['start'];
|
$this->start = empty($options['start']) || !is_numeric($options['start']) || $options['start'] < 0 || $options['start'] > $this->recordCount ? 0 : $options['start'];
|
||||||
@ -50,10 +50,6 @@ class GenericTable extends PageIndex
|
|||||||
// Let's bear a few things in mind...
|
// Let's bear a few things in mind...
|
||||||
$this->base_url = $options['base_url'];
|
$this->base_url = $options['base_url'];
|
||||||
|
|
||||||
// This should be set at all times, too.
|
|
||||||
if (empty($options['no_items_label']))
|
|
||||||
$options['no_items_label'] = '';
|
|
||||||
|
|
||||||
// Gather parameters for the data gather function first.
|
// Gather parameters for the data gather function first.
|
||||||
$parameters = [$this->start, $this->items_per_page, $options['sort_order'], $options['sort_direction']];
|
$parameters = [$this->start, $this->items_per_page, $options['sort_order'], $options['sort_direction']];
|
||||||
if (!empty($options['get_data_params']) && is_array($options['get_data_params']))
|
if (!empty($options['get_data_params']) && is_array($options['get_data_params']))
|
||||||
@ -77,18 +73,18 @@ class GenericTable extends PageIndex
|
|||||||
|
|
||||||
// Not a single row in sight?
|
// Not a single row in sight?
|
||||||
if (empty($rows))
|
if (empty($rows))
|
||||||
$this->body = $options['no_items_label'];
|
$this->body = $options['no_items_label'] ?? '';
|
||||||
// Otherwise, parse it all!
|
// Otherwise, parse it all!
|
||||||
else
|
else
|
||||||
$this->parseAllRows($rows, $options);
|
$this->parseAllRows($rows, $options);
|
||||||
|
|
||||||
// Got a title?
|
// Got a title?
|
||||||
$this->title = isset($options['title']) ? htmlentities($options['title']) : '';
|
$this->title = $options['title'] ?? '';
|
||||||
$this->title_class = isset($options['title_class']) ? $options['title_class'] : '';
|
$this->title_class = $options['title_class'] ?? '';
|
||||||
|
|
||||||
// Maybe even a form or two?
|
// Maybe even a form or two?
|
||||||
$this->form_above = isset($options['form_above']) ? $options['form_above'] : (isset($options['form']) ? $options['form'] : null);
|
$this->form_above = $options['form_above'] ?? $options['form'] ?? null;
|
||||||
$this->form_below = isset($options['form_below']) ? $options['form_below'] : (isset($options['form']) ? $options['form'] : null);
|
$this->form_below = $options['form_below'] ?? $options['form'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateColumnHeaders($options)
|
private function generateColumnHeaders($options)
|
||||||
|
@ -25,7 +25,7 @@ class FormView extends SubTemplate
|
|||||||
if (!empty($this->title))
|
if (!empty($this->title))
|
||||||
echo '
|
echo '
|
||||||
<div class="admin_box">
|
<div class="admin_box">
|
||||||
<h2>', $this->title, '</h2>';
|
<h2>', htmlspecialchars($this->title), '</h2>';
|
||||||
|
|
||||||
foreach ($this->_subtemplates as $template)
|
foreach ($this->_subtemplates as $template)
|
||||||
$template->html_main();
|
$template->html_main();
|
||||||
|
Loading…
Reference in New Issue
Block a user