2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
|
|
|
$headersHtml = '';
|
|
|
|
foreach ($fields as $k => $header) {
|
|
|
|
if (!isset($header['requirement']) || $header['requirement']) {
|
|
|
|
$header_data = '';
|
2022-01-21 09:08:13 +01:00
|
|
|
$icon_html = '';
|
|
|
|
if (!empty($header['icon'])) {
|
|
|
|
$icon_html = $this->Bootstrap->icon($header['icon'], ['class' => ['d-inline me-1']]);
|
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
if (!empty($header['sort'])) {
|
|
|
|
if (!empty($header['name'])) {
|
2022-01-21 09:08:13 +01:00
|
|
|
$header_data = $paginator->sort(
|
|
|
|
$header['sort'],
|
|
|
|
sprintf('%s%s', $icon_html, h($header['name'])),
|
|
|
|
['escape' => false]
|
|
|
|
);
|
2020-05-29 13:41:58 +02:00
|
|
|
} else {
|
2022-01-21 09:08:13 +01:00
|
|
|
if (empty($icon_html)) {
|
|
|
|
$header_data = $paginator->sort($header['sort']);
|
|
|
|
} else {
|
|
|
|
$header_data = $paginator->sort(
|
|
|
|
$header['sort'],
|
|
|
|
$icon_html,
|
|
|
|
['escape' => false]
|
|
|
|
);
|
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!empty($header['element']) && $header['element'] === 'selector') {
|
|
|
|
$header_data = sprintf(
|
|
|
|
'<input id="select_all" class="%s" type="checkbox" %s>',
|
|
|
|
empty($header['select_all_class']) ? 'select_all' : $header['select_all_class'],
|
2021-06-23 11:15:22 +02:00
|
|
|
empty($header['select_all_function']) ? 'onclick="toggleAllAttributeCheckboxes(this);"' : 'onclick="' . $header['select_all_function'] . '"'
|
2020-05-29 13:41:58 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$header_data = h($header['name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-10-20 15:39:37 +02:00
|
|
|
if (!empty($header['element']) && $header['element'] === 'selector') {
|
|
|
|
$columnName = 'row-selector';
|
|
|
|
} else {
|
|
|
|
$columnName = h(\Cake\Utility\Inflector::variable(!empty($header['name']) ? $header['name'] : \Cake\Utility\Inflector::humanize($header['data_path'])));
|
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
$headersHtml .= sprintf(
|
2021-10-20 09:39:12 +02:00
|
|
|
'<th scope="col" data-columnname="%s">%s</th>',
|
2021-10-20 15:39:37 +02:00
|
|
|
$columnName,
|
2020-05-29 13:41:58 +02:00
|
|
|
$header_data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($actions) {
|
|
|
|
$headersHtml .= sprintf(
|
2021-09-17 13:04:37 +02:00
|
|
|
'<th class="actions text-end">%s</th>',
|
2020-05-29 13:41:58 +02:00
|
|
|
__('Actions')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$thead = '<thead>';
|
|
|
|
$thead .= $headersHtml;
|
|
|
|
$thead .= '</thead>';
|
|
|
|
echo $thead;
|
|
|
|
?>
|