joomla-component/site/layouts/table.php

90 lines
3.4 KiB
PHP
Raw Normal View History

2023-07-26 09:09:42 +00:00
<?php
/*----------------------------------------------------------------------------------| io.vdm.dev |----/
Vast Development Method
/-------------------------------------------------------------------------------------------------------/
@package getBible.net
@created 3rd December, 2015
@author Llewellyn van der Merwe <https://getbible.net>
@git Get Bible <https://git.vdm.dev/getBible>
@github Get Bible <https://github.com/getBible>
@support Get Bible <https://git.vdm.dev/getBible/support>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
/------------------------------------------------------------------------------------------------------*/
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Layout\LayoutHelper;
use TrueChristianBible\Component\GetBible\Site\Helper\GetbibleHelper;
use TrueChristianBible\Joomla\Utilities\StringHelper;
2023-07-26 09:09:42 +00:00
// No direct access to this file
defined('JPATH_BASE') or die;
2023-07-26 09:09:42 +00:00
$table_id = (isset($displayData['id'])) ? $displayData['id'] : StringHelper::random(7);
$name = (isset($displayData['name'])) ? $displayData['name'] : false;
$table_class = (isset($displayData['table_class'])) ? $displayData['table_class'] : 'uk-table';
$table_container_class = (isset($displayData['table_container_class'])) ? $displayData['table_container_class'] : 'uk-overflow-auto';
$headers = (isset($displayData['headers'])) ? $displayData['headers'] : [Text::_('COM_GETBIBLE_NO'), Text::_('COM_GETBIBLE_HEADERS'), Text::_('COM_GETBIBLE_FOUND')];
2023-07-26 09:09:42 +00:00
$items = (isset($displayData['items'])) ? $displayData['items'] : 6;
?>
<div class="<?php echo $$table_container_class; ?>">
2023-07-26 09:09:42 +00:00
<table id="<?php echo $table_id; ?>" class="<?php echo $table_class; ?>">
<thead>
<?php if (is_array($headers)): ?>
<?php if ($name): ?>
<tr>
<th colspan="<?php echo count($headers); ?>" style="text-align:center"><b><?php echo $name; ?></b></th>
</tr>
<?php endif; ?>
<tr>
<?php foreach($headers as $code_name => $header): ?>
<?php
if (is_numeric($code_name))
{
$code_name = StringHelper::safe($header);
}
?>
<th data-name="<?php echo $code_name; ?>"><?php echo $header; ?></th>
<?php endforeach; ?>
</tr>
<?php elseif (is_numeric($headers)): ?>
<?php if ($name): ?>
<tr>
<th colspan="<?php echo (int) $headers; ?>" style="text-align:center"><b><?php echo $name; ?></b></th>
</tr>
<?php endif; ?>
<tr style="position: absolute; top: -9999px; left: -9999px;">
<?php for( $row = 0; $row < $headers; $row++): ?>
<th><?php echo StringHelper::safe($row); ?></th>
<?php endfor; ?>
</tr>
<?php endif; ?>
</thead>
<tbody>
<?php echo LayoutHelper::render('rows', ['headers' => $headers, 'items' => $items]); ?>
2023-07-26 09:09:42 +00:00
</tbody>
</table>
</div>
<?php
// Initialize the table if [init is not set], or [is true]
// To stop initialization set $displayData['init'] = false;
if (!isset($displayData['init']) || $displayData['init']) :
?>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var <?php echo $table_id; ?> = new DataTable('#<?php echo $table_id; ?>', {
2023-07-26 09:09:42 +00:00
paging: false,
select: true
});
});
</script>
<?php endif; ?>