Files
pkg_circolari/site/tmpl/circolari/default.php
2025-09-10 16:06:20 +02:00

90 lines
3.8 KiB
PHP

<?php
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
$app = Factory::getApplication();
$input = $app->getInput();
// Prendo dati dalla view con fallback ai getter
$items = $this->items ?? ($this->get('Items') ?? []);
$pagination = $this->pagination ?? ($this->get('Pagination') ?? null);
// Normalizzo items
if (!is_array($items)) {
$items = (array) $items;
}
$items = array_values(array_filter($items, static fn($it) => is_object($it) && !empty($it->id)));
$Itemid = (int) $input->getInt('Itemid', 0);
$params = $this->params ?? Factory::getApplication()->getParams();
$title = (string) $params->get('page_title', '');
$desc = (string) $params->get('page_description', '');
?>
<div class="com-content-category category-list">
<div class="content-category">
<h1><?php echo $title ? $title : ""; ?> </h1>
<div class="category-desc">
<p><span style="color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12.16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">
<?php echo $desc ? $desc : ""; ?> </span></p>
</div>
<?php if (!count($items)) : ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('COM_CIRCOLARI_NO_ITEMS') ?: 'Nessuna circolare'; ?>
</div>
<?php else : ?>
<table class="com-content-category__table category table table-striped table-bordered table-hover">
<caption class="visually-hidden"><?php echo Text::_('COM_CIRCOLARI_ELENCO') ?: 'Elenco circolari'; ?></caption>
<thead class="visually-hidden">
<tr>
<th scope="col">Titolo</th>
<th scope="col" class="text-end">Visite</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $i => $item) : ?>
<?php
$url = Route::_('index.php?option=com_circolari&view=circolare&id=' . (int) $item->id);
$title = $item->title ?? ('#' . (int) $item->id);
$hits = isset($item->hits) ? (int) $item->hits : null;
?>
<tr class="cat-list-row<?php echo $i % 2; ?>">
<th class="list-title text-start" scope="row">
<a href="<?php echo $url; ?>">
<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
</a>
</th>
<td class="list-hits">
<?php if ($hits !== null) : ?>
<span class="badge bg-info" aria-disabled="true">
<?php echo Text::_('JGLOBAL_HITS') ?: 'Visite'; ?>: <?php echo $hits; ?>
</span>
<?php else : ?>
<span class="text-muted">—</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if ($pagination && (int) $pagination->pagesTotal > 1) : ?>
<div class="com-content-category__navigation w-100">
<div class="d-flex align-items-center mt-2">
<div class="flex-grow-1 d-flex justify-content-center">
<?php echo $pagination->getPagesLinks(); ?>
</div>
<p class="com-content-category__counter counter mb-0 ps-3">
<?php echo $pagination->getPagesCounter(); ?>
</p>
</div>
</div>
<?php endif; ?>
</div>
</div>