32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-26 01:57:30 +00:00

Quick change to weblinks list

This commit is contained in:
Tuan Pham Ngoc 2021-06-20 16:16:01 +07:00
parent b7fe535a17
commit 02f9811d37

View File

@ -9,26 +9,25 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route; use Joomla\CMS\Router\Route;
/** @var \Joomla\Component\Weblinks\Administrator\View\Weblinks\HtmlView $this */ /** @var \Joomla\Component\Weblinks\Administrator\View\Weblinks\HtmlView $this */
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect'); JHtml::_('behavior.multiselect');
//JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser(); $user = Factory::getApplication()->getIdentity();
$userId = $user->get('id'); $userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering')); $listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction')); $listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
$saveOrder = $listOrder == 'a.ordering'; $saveOrder = $listOrder == 'a.ordering';
$assoc = JLanguageAssociations::isEnabled(); $assoc = JLanguageAssociations::isEnabled();
if ($saveOrder) if ($saveOrder && !empty($this->items))
{ {
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component'; $saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
HTMLHelper::_('draggablelist.draggable'); HTMLHelper::_('draggablelist.draggable');
@ -48,7 +47,7 @@ if ($saveOrder)
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div> </div>
<?php else : ?> <?php else : ?>
<table class="table" id="articleList"> <table class="table" id="weblinkList">
<caption class="visually-hidden"> <caption class="visually-hidden">
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>, <?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
@ -56,33 +55,35 @@ if ($saveOrder)
</caption> </caption>
<thead> <thead>
<tr> <tr>
<th width="1%" class="nowrap center hidden-phone"> <td class="w-1 text-center">
<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> <?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col" class="w-1 text-center d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th> </th>
<th width="1%" class="nowrap center"> <th scope="col" style="min-width:85px" class="w-1 text-center">
<?php echo JHtml::_('grid.checkall'); ?> <?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th> </th>
<th width="1%" class="nowrap center"> <th scope="col">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th> </th>
<th width="10%" class="nowrap hidden-phone"> <th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
</th> </th>
<th width="5%" class="nowrap center hidden-phone"> <th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th> </th>
<?php if ($assoc) : ?> <?php if ($assoc) : ?>
<th width="5%" class="nowrap hidden-phone hidden-tablet"> <th scope="col" class="w-10">
<?php echo JHtml::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
</th> </th>
<?php endif; ?> <?php endif; ?>
<th width="10%" class="nowrap hidden-phone"> <?php if (Multilanguage::isEnabled()) : ?>
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?> <th scope="col" class="w-10 d-none d-md-table-cell">
</th> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
<th width="1%" class="nowrap center hidden-phone"> </th>
<?php endif; ?>
<th scope="col" class="w-5 d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th> </th>
</tr> </tr>
@ -96,56 +97,56 @@ if ($saveOrder)
<?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; ?> <?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; ?>
<?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?> <?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?>
<?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?> <?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid; ?>"> <tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
<td class="order nowrap center hidden-phone"> <td class="text-center">
<?php $iconClass = ''; ?> <?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
<?php if (!$canChange) : ?>
<?php $iconClass = ' inactive'; ?>
<?php elseif (!$saveOrder) : ?>
<?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?>
<?php endif; ?>
<span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu" aria-hidden="true"></i>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
<?php endif; ?>
</td> </td>
<td class="center"> <td class="text-center d-none d-md-table-cell">
<?php echo JHtml::_('grid.id', $i, $item->id); ?> <?php
$iconClass = '';
if (!$canChange)
{
$iconClass = ' inactive';
}
elseif (!$saveOrder)
{
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass; ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" name="order[]" size="5"
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden">
<?php endif; ?>
</td> </td>
<td class="center"> <td class="text-center">
<div class="btn-group"> <?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?> </td>
<?php // Create dropdown items and render the dropdown list. ?> <th scope="row" class="has-context">
<?php if ($canChange) : ?> <div>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'weblinks'); ?> <?php if ($item->checked_out) : ?>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'weblinks'); ?> <?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php echo JHtml::_('actionsdropdown.render', $this->escape($item->title)); ?> <?php endif; ?>
<?php endif; ?> <?php if ($canEdit || $canEditOwn) : ?>
<a href="<?php echo Route::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->name); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<span class="small">
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<div class="small">
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</div> </div>
</td> </th>
<td class="nowrap has-context"> <td class="small d-none d-md-table-cell">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit || $canEditOwn) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<span class="small">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?> <?php echo $this->escape($item->access_level); ?>
</td> </td>
<td class="center hidden-phone"> <td class="d-none d-md-table-cell">
<?php echo $item->hits; ?> <?php echo $item->hits; ?>
</td> </td>
<?php if ($assoc) : ?> <?php if ($assoc) : ?>
@ -155,10 +156,12 @@ if ($saveOrder)
<?php endif; ?> <?php endif; ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<td class="small hidden-phone"> <?php if (Multilanguage::isEnabled()) : ?>
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?> <td class="small d-none d-md-table-cell">
</td> <?php echo LayoutHelper::render('joomla.content.language', $item); ?>
<td class="center hidden-phone"> </td>
<?php endif; ?>
<td class="d-none d-md-table-cell">
<?php echo (int) $item->id; ?> <?php echo (int) $item->id; ?>
</td> </td>
</tr> </tr>