Merge pull request #474 from joomdonation/parameters_improvement

Improve weblinks parameter handling in weblinks module
This commit is contained in:
Tuan Pham Ngoc 2021-10-29 16:25:54 +07:00 committed by GitHub
commit bfa420baa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 27 deletions

View File

@ -263,9 +263,9 @@
<field
name="count_clicks"
type="radio"
type="list"
label="COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
layout="joomla.form.field.radio.switcher"
useglobal="true"
>
<option value="0">JNO</option>
<option value="1">JYES</option>

View File

@ -146,17 +146,6 @@
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="count_clicks"
type="radio"
label="MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced">

View File

@ -41,8 +41,8 @@ class WeblinksHelper
->createModel('Category', 'Site', ['ignore_request' => true]);
// Set application parameters in model
$appParams = $app->getParams();
$model->setState('params', $appParams);
$cParams = ComponentHelper::getParams('com_weblinks');
$model->setState('params', $cParams);
// Set the filters based on the module params
$model->setState('list.start', 0);
@ -101,7 +101,11 @@ class WeblinksHelper
{
foreach ($items as $item)
{
if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1)
$temp = $item->params;
$item->params = clone $cParams;
$item->params->merge($temp);
if ($item->params->get('count_clicks', 1) == 1)
{
$item->link = Route::_('index.php?option=com_weblinks&task=weblink.go&catid=' . $item->catslug . '&id=' . $item->slug);
}

View File

@ -9,8 +9,9 @@
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
?>
<?php if ($params->get('groupby', 0)) : ?>
@ -36,22 +37,25 @@ use Joomla\CMS\HTML\HTMLHelper;
<?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 . '">
<ul class="weblinks<?php echo $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')))
$link = $item->link;
$width = (int) $item->params->get('width', 600);
$height = (int) $item->params->get('height', 500);
switch ($item->params->get('target'))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
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
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $width . ',height=' . $height;
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
@ -94,22 +98,25 @@ use Joomla\CMS\HTML\HTMLHelper;
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<ul class="mod-list weblinks ' . $moduleclass_sfx . '">
<ul class="weblinks<?php echo $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')))
$link = $item->link;
$width = (int) $item->params->get('width', 600);
$height = (int) $item->params->get('height', 500);
switch ($item->params->get('target'))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
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
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $width . ',height=' . $height;
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;