Skip to content

Commit

Permalink
Merge pull request #474 from joomdonation/parameters_improvement
Browse files Browse the repository at this point in the history
Improve weblinks parameter handling in weblinks module
  • Loading branch information
joomdonation authored Oct 29, 2021
2 parents 2b84808 + a261aa7 commit bfa420b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/administrator/components/com_weblinks/forms/weblink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
11 changes: 0 additions & 11 deletions src/modules/mod_weblinks/mod_weblinks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
10 changes: 7 additions & 3 deletions src/modules/mod_weblinks/src/Helper/WeblinksHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static function getList($params, $app)
->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);
Expand Down Expand Up @@ -101,7 +101,11 @@ public static function getList($params, $app)
{
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);
}
Expand Down
29 changes: 18 additions & 11 deletions src/modules/mod_weblinks/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) : ?>
Expand All @@ -36,22 +37,25 @@
<?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;
Expand Down Expand Up @@ -94,22 +98,25 @@
<?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;
Expand Down

0 comments on commit bfa420b

Please sign in to comment.