mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-12-25 01:45:59 +00:00
Merge pull request #8 from chmst/mod-weblinks-first
First step to mod_weblinks 4.0 compatible
This commit is contained in:
commit
065f724ae3
@ -5,29 +5,17 @@
|
||||
|
||||
MOD_WEBLINKS="Web Links"
|
||||
MOD_WEBLINKS_FIELD_CATEGORY_DESC="Choose the Web Links category to display."
|
||||
MOD_WEBLINKS_FIELD_GROUPBY_DESC="If set to yes, web links will be grouped by subcategories."
|
||||
MOD_WEBLINKS_FIELD_GROUPBY_LABEL="Group By Subcategories"
|
||||
MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_DESC="If set to yes, will show groups titles (valid only if grouping)."
|
||||
MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_LABEL="Show Group Title"
|
||||
MOD_WEBLINKS_FIELD_GROUPBYORDERING_DESC="Ordering for the subcategories (valid only if grouping)."
|
||||
MOD_WEBLINKS_FIELD_GROUPBYORDERING_LABEL="Group Ordering"
|
||||
MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_DESC="Direction for the subcategories (valid only if grouping)."
|
||||
MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_LABEL="Group Ordering Direction"
|
||||
MOD_WEBLINKS_FIELD_COLUMNS_DESC="When grouping by subcategories, split into # columns."
|
||||
MOD_WEBLINKS_FIELD_COLUMNS_LABEL="Columns"
|
||||
MOD_WEBLINKS_FIELD_COUNT_DESC="Number of Web Links to display."
|
||||
MOD_WEBLINKS_FIELD_COUNT_LABEL="Count"
|
||||
MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
|
||||
MOD_WEBLINKS_FIELD_COUNT_LABEL="Count"MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
|
||||
MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL="Count Clicks"
|
||||
MOD_WEBLINKS_FIELD_DESCRIPTION_DESC="Display Web Link description."
|
||||
MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL="Description"
|
||||
MOD_WEBLINKS_FIELD_FOLLOW_DESC="Robots index - allow to follow or not."
|
||||
MOD_WEBLINKS_FIELD_FOLLOW_LABEL="Follow/No Follow"
|
||||
MOD_WEBLINKS_FIELD_HITS_DESC="Show hits."
|
||||
MOD_WEBLINKS_FIELD_HITS_LABEL="Hits"
|
||||
MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC="Set the ordering direction."
|
||||
MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL="Direction"
|
||||
MOD_WEBLINKS_FIELD_ORDERING_DESC="Ordering for the Web Links."
|
||||
MOD_WEBLINKS_FIELD_ORDERING_LABEL="Ordering"
|
||||
MOD_WEBLINKS_FIELD_TARGET_DESC="Target browser window when the link is selected."
|
||||
MOD_WEBLINKS_FIELD_TARGET_LABEL="Target Window"
|
||||
|
@ -14,7 +14,7 @@ use Joomla\Module\Weblinks\Site\Helper\WeblinksHelper;
|
||||
|
||||
$list = WeblinksHelper::getList($params, $app);
|
||||
|
||||
if (!count($list))
|
||||
if (empty($list))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
name="catid"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
description="MOD_WEBLINKS_FIELD_CATEGORY_DESC"
|
||||
extension="com_weblinks"
|
||||
required="true"
|
||||
/>
|
||||
@ -34,32 +33,29 @@
|
||||
name="groupby"
|
||||
type="radio"
|
||||
label="MOD_WEBLINKS_FIELD_GROUPBY_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_GROUPBY_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="groupby_showtitle"
|
||||
type="radio"
|
||||
label="MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
showon="groupby:1"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="groupby_ordering"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_GROUPBYORDERING_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_GROUPBYORDERING_DESC"
|
||||
default="c.lft"
|
||||
showon="groupby:1"
|
||||
>
|
||||
@ -71,7 +67,6 @@
|
||||
name="groupby_direction"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_DESC"
|
||||
default="asc"
|
||||
showon="groupby:1"
|
||||
>
|
||||
@ -83,7 +78,6 @@
|
||||
name="groupby_columns"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_COLUMNS_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_COLUMNS_DESC"
|
||||
default="3"
|
||||
>
|
||||
<option value="1">J1</option>
|
||||
@ -97,7 +91,6 @@
|
||||
name="count"
|
||||
type="text"
|
||||
label="MOD_WEBLINKS_FIELD_COUNT_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_COUNT_DESC"
|
||||
default="5"
|
||||
/>
|
||||
|
||||
@ -105,7 +98,6 @@
|
||||
name="ordering"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_ORDERING_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_ORDERING_DESC"
|
||||
default="title"
|
||||
>
|
||||
<option value="title">JGLOBAL_TITLE</option>
|
||||
@ -117,7 +109,6 @@
|
||||
name="direction"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC"
|
||||
default="asc"
|
||||
>
|
||||
<option value="asc">MOD_WEBLINKS_FIELD_VALUE_ASCENDING</option>
|
||||
@ -128,8 +119,7 @@
|
||||
name="follow"
|
||||
type="list"
|
||||
label="MOD_WEBLINKS_FIELD_FOLLOW_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_FOLLOW_DESC"
|
||||
default="0"
|
||||
default="follow"
|
||||
>
|
||||
<option value="follow">MOD_WEBLINKS_FIELD_VALUE_FOLLOW</option>
|
||||
<option value="nofollow">MOD_WEBLINKS_FIELD_VALUE_NOFOLLOW</option>
|
||||
@ -139,37 +129,33 @@
|
||||
name="description"
|
||||
type="radio"
|
||||
label="MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_DESCRIPTION_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="hits"
|
||||
type="radio"
|
||||
label="MOD_WEBLINKS_FIELD_HITS_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_HITS_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="count_clicks"
|
||||
type="list"
|
||||
type="radio"
|
||||
label="MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
|
||||
description="MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC"
|
||||
class="chzn-color"
|
||||
default="0"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
@ -178,22 +164,23 @@
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
description="JFIELD_ALT_MODULE_LAYOUT_DESC"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHING_DESC"
|
||||
default="1"
|
||||
>
|
||||
<option value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
@ -204,7 +191,6 @@
|
||||
name="cache_time"
|
||||
type="text"
|
||||
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHE_TIME_DESC"
|
||||
default="900"
|
||||
/>
|
||||
|
||||
|
@ -11,110 +11,126 @@ defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
if ($params->get('groupby', 0)) :
|
||||
$cats = [];
|
||||
$cols = $params->get('groupby_columns', 3);
|
||||
|
||||
<?php if ($params->get('groupby', 0)) : ?>
|
||||
<?php $cats = array(); ?>
|
||||
<?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 = array(); ?>
|
||||
<?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="span<?php echo (12 / $cols); ?>">
|
||||
<?php endif; ?>
|
||||
<?php if ($params->get('groupby_showtitle', 1)) : ?>
|
||||
<h4><?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8'); ?></h4>
|
||||
<?php endif; ?>
|
||||
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($items as $item) : ?>
|
||||
<li>
|
||||
<?php $link = $item->link; ?>
|
||||
<?php
|
||||
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;
|
||||
foreach ($list as $l) :
|
||||
$cats[] = array('catid' => $l->catid, 'title' => $l->category_title);
|
||||
endforeach;
|
||||
|
||||
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;
|
||||
$cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats))));
|
||||
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php if ($params->get('description', 0)) : ?>
|
||||
<?php echo nl2br($item->description); ?>
|
||||
<?php endif; ?>
|
||||
foreach ($cats as $k => $cat) :
|
||||
$items = [];
|
||||
|
||||
<?php if ($params->get('hits', 0)) : ?>
|
||||
<?php echo '(' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . ')'; ?>
|
||||
<?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="weblinks<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<li>
|
||||
<?php $link = $item->link; ?>
|
||||
<?php
|
||||
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;
|
||||
foreach ($list as $item) :
|
||||
if ($item->catid == $cat['catid']) :
|
||||
$items[] = $item;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
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;
|
||||
if ($cols > 1) :
|
||||
if ($k % $cols == 0) :
|
||||
echo '<div class="row row-fluid">';
|
||||
endif;
|
||||
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
echo '<div class="col-' . 12 / $cols . '">';
|
||||
endif;
|
||||
|
||||
<?php if ($params->get('description', 0)) : ?>
|
||||
<?php echo nl2br($item->description); ?>
|
||||
<?php endif; ?>
|
||||
if ($params->get('groupby_showtitle', 1)) :
|
||||
echo '<strong>' . htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8') . '</strong>';
|
||||
endif;
|
||||
|
||||
<?php if ($params->get('hits', 0)) : ?>
|
||||
<?php echo '(' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . ')'; ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php 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)) :
|
||||
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="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; ?>
|
||||
|
Loading…
Reference in New Issue
Block a user