30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-09 09:42:24 +00:00

Adapt weblinks modal to J4

This commit is contained in:
chmst 2021-07-21 15:19:00 +02:00
parent 89554eea66
commit d5512492f0

View File

@ -6,6 +6,7 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
@ -14,31 +15,29 @@ 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;
use Joomla\CMS\Session\Session;
use Joomla\Component\Weblinks\Site\Helper\RouteHelper; use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
$app = Factory::getApplication(); $app = Factory::getApplication();
if ($app->isClient('site')) if ($app->isClient('site'))
{ {
JSession::checkToken('get') or die(Text::_('JINVALID_TOKEN')); Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
} }
// Include the component HTML helpers. HTMLHelper::_('behavior.multiselect');
HTMLHelper::_('behavior.core'); /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
HTMLHelper::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true)); $wa = $this->document->getWebAssetManager();
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom')); $wa->useScript('core')
HTMLHelper::_('formbehavior.chosen', 'select'); ->useScript('com_weblinks.admin-weblinks-modal');
// Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter');
HTMLHelper::_('bootstrap.tooltip', '#filter_search', array('title' => Text::_($searchFilterDesc), 'placement' => 'bottom'));
$function = $app->input->getCmd('function', 'jSelectWeblink'); $function = $app->input->getCmd('function', 'jSelectWeblink');
$editor = $app->input->getCmd('editor', ''); $editor = $app->input->getCmd('editor', '');
$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'));
$onclick = $this->escape($function); $onclick = $this->escape($function);
$multilang = Multilanguage::isEnabled();
if (!empty($editor)) if (!empty($editor))
{ {
@ -57,48 +56,49 @@ $iconStates = array(
?> ?>
<div class="container-popup"> <div class="container-popup">
<form action="<?php echo Route::_('index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1&editor=' . $editor); ?>" method="post" name="adminForm" id="adminForm" class="form-inline"> <form action="<?php echo Route::_('index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&function=' . $function . '&' . Session::getFormToken() . '=1&editor=' . $editor); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<div class="clearfix"></div> <?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if (empty($this->items)) : ?> <?php if (empty($this->items)) : ?>
<div class="alert alert-no-items"> <div class="alert alert-no-items">
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div> </div>
<?php else : ?> <?php else : ?>
<table class="table table-striped table-condensed"> <table class="table table-sm">
<caption class="visually-hidden">
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
</caption>
<thead> <thead>
<tr> <tr>
<th width="1%" class="center nowrap"> <th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th> </th>
<th class="title"> <th scope="col" class="title">
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('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 HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th> </th>
<th width="15%" class="nowrap"> <?php if ($multilang) : ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?> <th scope="col" class="w-15">
</th> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
<th width="5%" class="nowrap hidden-phone"> </th>
<?php endif; ?>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
</th> </th>
<th width="1%" class="nowrap hidden-phone"> <th scope="col" class="w-1 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th> </th>
</tr> </tr>
</thead> </thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody> <tbody>
<?php foreach ($this->items as $i => $item) : ?> <?php foreach ($this->items as $i => $item) : ?>
<?php $lang = ''; ?> <?php $lang = ''; ?>
<?php if ($item->language && Multilanguage::isEnabled()) : ?> <?php if ($item->language && $multilang) : ?>
<?php $tag = strlen($item->language); ?> <?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) : ?> <?php if ($tag == 5) : ?>
<?php $lang = substr($item->language, 0, 2); ?> <?php $lang = substr($item->language, 0, 2); ?>
@ -110,7 +110,7 @@ $iconStates = array(
<td class="center"> <td class="center">
<span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span> <span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span>
</td> </td>
<td> <th scope="row">
<?php $attribs = 'data-function="' . $this->escape($onclick) . '"' <?php $attribs = 'data-function="' . $this->escape($onclick) . '"'
. ' data-id="' . $item->id . '"' . ' data-id="' . $item->id . '"'
. ' data-title="' . $this->escape(addslashes($item->title)) . '"' . ' data-title="' . $this->escape(addslashes($item->title)) . '"'
@ -124,17 +124,19 @@ $iconStates = array(
<div class="small"> <div class="small">
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?> <?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div> </div>
</td> </th>
<td class="small hidden-phone"> <td class="small d-none d-md-table-cell">
<?php echo $this->escape($item->access_level); ?> <?php echo $this->escape($item->access_level); ?>
</td> </td>
<td class="small"> <?php if ($multilang) : ?>
<?php echo LayoutHelper::render('joomla.content.language', $item); ?> <td class="small">
</td> <?php echo LayoutHelper::render('joomla.content.language', $item); ?>
<td class="nowrap small hidden-phone"> </td>
<?php endif; ?>
<td class="small d-none d-md-table-cell">
<?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?> <?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?>
</td> </td>
<td class="nowrap small hidden-phone"> <td class="small d-none d-md-table-cell">
<?php echo (int) $item->id; ?> <?php echo (int) $item->id; ?>
</td> </td>
</tr> </tr>
@ -143,6 +145,9 @@ $iconStates = array(
</table> </table>
<?php endif; ?> <?php endif; ?>
<?php // load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" /> <input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />