Refactor generic tables and page index classes #26

Merged
Roflin merged 9 commits from refactor-tables into master 2021-05-17 20:19:18 +02:00
2 changed files with 7 additions and 11 deletions
Showing only changes of commit 96937b6952 - Show all commits

View File

@ -42,7 +42,7 @@ class GenericTable extends PageIndex
// Should we create a page index?
$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->index_class = isset($options['index_class']) ? $options['index_class'] : '';
$this->index_class = $options['index_class'] ?? '';
// Figure out where to 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...
$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.
$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']))
@ -77,18 +73,18 @@ class GenericTable extends PageIndex
// Not a single row in sight?
if (empty($rows))
$this->body = $options['no_items_label'];
$this->body = $options['no_items_label'] ?? '';
// Otherwise, parse it all!
else
$this->parseAllRows($rows, $options);
// Got a title?
$this->title = isset($options['title']) ? htmlentities($options['title']) : '';
$this->title_class = isset($options['title_class']) ? $options['title_class'] : '';
$this->title = $options['title'] ?? '';
$this->title_class = $options['title_class'] ?? '';
// Maybe even a form or two?
$this->form_above = isset($options['form_above']) ? $options['form_above'] : (isset($options['form']) ? $options['form'] : null);
$this->form_below = isset($options['form_below']) ? $options['form_below'] : (isset($options['form']) ? $options['form'] : null);
$this->form_above = $options['form_above'] ?? $options['form'] ?? null;
$this->form_below = $options['form_below'] ?? $options['form'] ?? null;
}
private function generateColumnHeaders($options)

View File

@ -25,7 +25,7 @@ class FormView extends SubTemplate
if (!empty($this->title))
echo '
<div class="admin_box">
<h2>', $this->title, '</h2>';
<h2>', htmlspecialchars($this->title), '</h2>';
foreach ($this->_subtemplates as $template)
$template->html_main();