30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-03 15:00:48 +00:00

Merge pull request #15 from chmst/adapt-module

Adapt module layout to changes component frontend
This commit is contained in:
Tuan Pham Ngoc 2021-08-16 17:53:49 +07:00 committed by GitHub
commit 10bdf18875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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