Files
conservatorio-tomadini/components/com_highlights/tmpl/highlights/default.php

161 lines
5.7 KiB
PHP

<?php
/**
* @version CVS: 1.0.0
* @package Com_Highlights
* @author Eddy Prosperi <eddy.prosperi@protocollicreativi.it>
* @copyright 2024 Eddy Prosperi
* @license GNU General Public License versione 2 o successiva; vedi LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\HTML\HTMLHelper;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Uri\Uri;
use \Joomla\CMS\Router\Route;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Layout\LayoutHelper;
use \Joomla\CMS\Session\Session;
use \Joomla\CMS\User\UserFactoryInterface;
HTMLHelper::_('bootstrap.tooltip');
HTMLHelper::_('behavior.multiselect');
HTMLHelper::_('formbehavior.chosen', 'select');
$user = Factory::getApplication()->getIdentity();
$userId = $user->get('id');
$listOrder = $this->state->get('list.ordering');
$listDirn = $this->state->get('list.direction');
$canCreate = $user->authorise('core.create', 'com_highlights') && file_exists(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'highlightform.xml');
$canEdit = $user->authorise('core.edit', 'com_highlights') && file_exists(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'highlightform.xml');
$canCheckin = $user->authorise('core.manage', 'com_highlights');
$canChange = $user->authorise('core.edit.state', 'com_highlights');
$canDelete = $user->authorise('core.delete', 'com_highlights');
// Import CSS
$wa = $this->document->getWebAssetManager();
$wa->useStyle('com_highlights.list');
?>
<?php if ($this->params->get('show_page_heading')) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif;?>
<form action="<?php echo htmlspecialchars(Uri::getInstance()->toString()); ?>" method="post"
name="adminForm" id="adminForm">
<?php if(!empty($this->filterForm)) { echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); } ?>
<div class="table-responsive">
<table class="table table-striped" id="highlightList">
<thead>
<tr>
<th class=''>
<?php echo HTMLHelper::_('grid.sort', 'COM_HIGHLIGHTS_HIGHLIGHTS_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
<th >
<?php echo HTMLHelper::_('grid.sort', 'JPUBLISHED', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class=''>
<?php echo HTMLHelper::_('grid.sort', 'COM_HIGHLIGHTS_HIGHLIGHTS_TITOLO', 'a.titolo', $listDirn, $listOrder); ?>
</th>
<th class=''>
<?php echo HTMLHelper::_('grid.sort', 'COM_HIGHLIGHTS_HIGHLIGHTS_ETICHETTA', 'a.etichetta', $listDirn, $listOrder); ?>
</th>
<?php if ($canEdit || $canDelete): ?>
<th class="center">
<?php echo Text::_('COM_HIGHLIGHTS_HIGHLIGHTS_ACTIONS'); ?>
</th>
<?php endif; ?>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo isset($this->items[0]) ? count(get_object_vars($this->items[0])) : 10; ?>">
<div class="pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $canEdit = $user->authorise('core.edit', 'com_highlights'); ?>
<?php if (!$canEdit && $user->authorise('core.edit.own', 'com_highlights')): ?>
<?php $canEdit = Factory::getApplication()->getIdentity()->id == $item->created_by; ?>
<?php endif; ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<?php echo $item->id; ?>
</td>
<td>
<?php $class = ($canChange) ? 'active' : 'disabled'; ?>
<a class="btn btn-micro <?php echo $class; ?>" href="<?php echo ($canChange) ? Route::_('index.php?option=com_highlights&task=highlight.publish&id=' . $item->id . '&state=' . (($item->state + 1) % 2), false, 2) : '#'; ?>">
<?php if ($item->state == 1): ?>
<i class="icon-publish"></i>
<?php else: ?>
<i class="icon-unpublish"></i>
<?php endif; ?>
</a>
</td>
<td>
<?php echo $item->titolo; ?>
</td>
<td>
<?php echo $item->etichetta; ?>
</td>
<?php if ($canEdit || $canDelete): ?>
<td class="center">
<?php $canCheckin = Factory::getApplication()->getIdentity()->authorise('core.manage', 'com_highlights.' . $item->id) || $item->checked_out == Factory::getApplication()->getIdentity()->id; ?>
<?php if($canEdit && $item->checked_out == 0): ?>
<a href="<?php echo Route::_('index.php?option=com_highlights&task=highlight.edit&id=' . $item->id, false, 2); ?>" class="btn btn-mini" type="button"><i class="icon-edit" ></i></a>
<?php endif; ?>
<?php if ($canDelete): ?>
<a href="<?php echo Route::_('index.php?option=com_highlights&task=highlightform.remove&id=' . $item->id, false, 2); ?>" class="btn btn-mini delete-button" type="button"><i class="icon-trash" ></i></a>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php if ($canCreate) : ?>
<a href="<?php echo Route::_('index.php?option=com_highlights&task=highlightform.edit&id=0', false, 0); ?>"
class="btn btn-success btn-small"><i
class="icon-plus"></i>
<?php echo Text::_('COM_HIGHLIGHTS_ADD_ITEM'); ?></a>
<?php endif; ?>
<input type="hidden" name="task" value=""/>
<input type="hidden" name="boxchecked" value="0"/>
<input type="hidden" name="filter_order" value=""/>
<input type="hidden" name="filter_order_Dir" value=""/>
<?php echo HTMLHelper::_('form.token'); ?>
</form>
<?php
if($canDelete) {
$wa->addInlineScript("
jQuery(document).ready(function () {
jQuery('.delete-button').click(deleteItem);
});
function deleteItem() {
if (!confirm(\"" . Text::_('COM_HIGHLIGHTS_DELETE_MESSAGE') . "\")) {
return false;
}
}
", [], [], ["jquery"]);
}
?>