Adapt module layout to changes component frontend

This commit is contained in:
chmst 2021-08-16 11:24:04 +02:00
parent 73b144fb48
commit daf0359558
1 changed files with 121 additions and 111 deletions

View File

@ -9,128 +9,138 @@
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
?>
if ($params->get('groupby', 0)) :
$cats = [];
$cols = $params->get('groupby_columns', 3);
foreach ($list as $l) :
$cats[] = array('catid' => $l->catid, 'title' => $l->category_title);
endforeach;
$cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats))));
foreach ($cats as $k => $cat) :
$items = [];
foreach ($list as $item) :
if ($item->catid == $cat['catid']) :
$items[] = $item;
endif;
endforeach;
if ($cols > 1) :
if ($k % $cols == 0) :
echo '<div class="row row-fluid">';
endif;
echo '<div class="col-' . 12 / $cols . '">';
endif;
if ($params->get('groupby_showtitle', 1)) :
echo '<strong>' . htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8') . '</strong>';
endif;
echo '<ul class="mod-list weblinks ' . $moduleclass_sfx . '">';
foreach ($items as $item) :
echo '<li><div class="d-flex flex-wrap">';
echo '<div class="col flex-sm-grow-1">';
$link = $item->link;
switch ($item->params->get('target', 3)) :
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
endswitch;
echo '</div>';
echo $params->get('description', 0) ? '<div class="colvflex-sm-grow-1">' . nl2br($item->description) . '</div>' : '';
if ($params->get('hits', 0)) :
echo '<div class="col flex-sm-grow-1">';
echo '<span class="badge bg-info float-md-end">' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . '</span>';
echo '</div>';
endif;
echo '</li>';
endforeach;
echo '</ul>';
if ($cols > 1) :
echo '</div>';
if (($k + 1) % $cols == 0 || $k == count($cats) - 1) :
echo '</div>';
endif;
endif;
endforeach;
else :
echo '<ul class="mod-list weblinks ' . $moduleclass_sfx . '">';
foreach ($list as $item) :
echo '<li><div class="d-flex flex-wrap">';
echo '<div class="col flex-sm-grow-1">';
$link = $item->link;
switch ($item->params->get('target', 3)) :
<?php if ($params->get('groupby', 0)) : ?>
<?php $cats = [] ?>
<?php $cols = $params->get('groupby_columns', 3); ?>
<?php foreach ($list as $l) : ?>
<?php $cats[] = array('catid' => $l->catid, 'title' => $l->category_title); ?>
<?php endforeach; ?>
<?php $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); ?>
<?php foreach ($cats as $k => $cat) : ?>
<?php $items = []; ?>
<?php foreach ($list as $item) : ?>
<?php if ($item->catid == $cat['catid']) : ?>
<?php $items[] = $item; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($cols > 1) :?>
<?php if ($k % $cols == 0) :?>
<div class="row row-fluid">
<?php endif; ?>
<div class="col-' . 12 / $cols . '">
<?php endif; ?>
<?php if ($params->get('groupby_showtitle', 1)) :?>
<strong> <?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8'); ?></strong>
<?php endif; ?>;
<ul class="mod-list weblinks ' . $moduleclass_sfx . '">
<?php foreach ($items as $item) :?>
<li><div class="d-flex flex-wrap">
<div class="col flex-sm-grow-1">
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', $params->get('target')))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 3:
// Open in a modal window
$modalId = 'weblink-item-modal-' . $item->id;
$modalParams['title'] = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8');
$modalParams['url'] = $link;
$modalParams['height'] = '100%';
$modalParams['width'] = '100%';
$modalParams['bodyHeight'] = 70;
$modalParams['modalWidth'] = 80;
echo HTMLHelper::_('bootstrap.renderModal', $modalId, $modalParams);
echo '<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#' . $modalId . '">
' . $item->title . '
</button>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
?>
</div>
<?php echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . $item->description . '</div>' : '';?>
<?php if ($params->get('hits', 0)) : ?>
<div class="col flex-sm-grow-1">
<span class="badge bg-info float-md-end"> <?php echo $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS'); ?></span>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if ($cols > 1) :?>
</div>
<?php if (($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<ul class="mod-list weblinks ' . $moduleclass_sfx . '">
<?php foreach ($list as $item) :?>
<li><div class="d-flex flex-wrap">
<div class="col flex-sm-grow-1">
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', $params->get('target')))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 3:
// Open in a modal window
$modalId = 'weblink-item-modal-' . $item->id;
$modalParams['title'] = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8');
$modalParams['url'] = $link;
$modalParams['height'] = '100%';
$modalParams['width'] = '100%';
$modalParams['bodyHeight'] = 70;
$modalParams['modalWidth'] = 80;
echo HTMLHelper::_('bootstrap.renderModal', $modalId, $modalParams);
echo '<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#' . $modalId . '">
' . $item->title . '
</button>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
endswitch;
echo '</div>';
echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . nl2br($item->description) . '</div>' : '';
if ($params->get('hits', 0)) :
echo '<div class="col flex-sm-grow-1">';
echo '<span class="badge bg-info float-md-end">' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . '</span>';
echo '</div>';
endif;
echo '</li>';
endforeach;
echo '</ul>';
endif; ?>
}
?>
</div>
<?php echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . $item->description . '</div>' : '';?>
<?php if ($params->get('hits', 0)) : ?>
<div class="col flex-sm-grow-1">
<span class="badge bg-info float-md-end"><?php echo $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS'); ?></span>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>