Skip to content

Commit

Permalink
[mod_tags_similar] Link cleanup (#20730)
Browse files Browse the repository at this point in the history
* [mod_tags_similar] Link cleanup

* CS
  • Loading branch information
SharkyKZ authored and Michael Babker committed Jun 16, 2018
1 parent f9bfcec commit 1fcf30c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
44 changes: 27 additions & 17 deletions modules/mod_tags_similar/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

use Joomla\Registry\Registry;

JLoader::register('TagsHelperRoute', JPATH_BASE . '/components/com_tags/helpers/route.php');

/**
* Helper for mod_tags_similar
*
Expand Down Expand Up @@ -61,19 +63,19 @@ public static function getList(&$params)

$query = $db->getQuery(true)
->select(
array(
$db->quoteName('m.core_content_id'),
$db->quoteName('m.content_item_id'),
$db->quoteName('m.type_alias'),
array(
$db->quoteName('m.core_content_id'),
$db->quoteName('m.content_item_id'),
$db->quoteName('m.type_alias'),
'COUNT( ' . $db->quoteName('tag_id') . ') AS ' . $db->quoteName('count'),
$db->quoteName('ct.router'),
$db->quoteName('cc.core_title'),
$db->quoteName('cc.core_alias'),
$db->quoteName('cc.core_catid'),
$db->quoteName('cc.core_language'),
$db->quoteName('cc.core_params')
$db->quoteName('ct.router'),
$db->quoteName('cc.core_title'),
$db->quoteName('cc.core_alias'),
$db->quoteName('cc.core_catid'),
$db->quoteName('cc.core_language'),
$db->quoteName('cc.core_params'),
)
);
);

$query->from($db->quoteName('#__contentitem_tag_map', 'm'));

Expand All @@ -87,14 +89,17 @@ public static function getList(&$params)

// Don't show current item
$query->where('(' . $db->quoteName('m.content_item_id') . ' <> ' . $id
. ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')');
. ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')'
);

// Only return published tags
$query->where($db->quoteName('cc.core_state') . ' = 1 ')
->where('(' . $db->quoteName('cc.core_publish_up') . '=' . $db->quote($nullDate) . ' OR '
. $db->quoteName('cc.core_publish_up') . '<=' . $db->quote($now) . ')')
. $db->quoteName('cc.core_publish_up') . '<=' . $db->quote($now) . ')'
)
->where('(' . $db->quoteName('cc.core_publish_down') . '=' . $db->quote($nullDate) . ' OR '
. $db->quoteName('cc.core_publish_down') . '>=' . $db->quote($now) . ')');
. $db->quoteName('cc.core_publish_down') . '>=' . $db->quote($now) . ')'
);

// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
Expand Down Expand Up @@ -150,9 +155,14 @@ public static function getList(&$params)

foreach ($results as $result)
{
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1]
. '&id=' . $result->content_item_id . '-' . $result->core_alias;
$result->link = TagsHelperRoute::getItemRoute(
$result->content_item_id,
$result->core_alias,
$result->core_catid,
$result->core_language,
$result->type_alias,
$result->router
);

$result->core_params = new Registry($result->core_params);
}
Expand Down
16 changes: 7 additions & 9 deletions modules/mod_tags_similar/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@
defined('_JEXEC') or die;

?>
<?php JLoader::register('TagsHelperRoute', JPATH_BASE . '/components/com_tags/helpers/route.php'); ?>
<div class="tagssimilar<?php echo $moduleclass_sfx; ?>">
<?php if ($list) : ?>
<ul>
<?php foreach ($list as $i => $item) : ?>
<li>
<?php if (($item->type_alias === 'com_users.category') || ($item->type_alias === 'com_banners.category')) : ?>
<?php if (!empty($item->core_title)) :
echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8');
endif; ?>
<?php if (!empty($item->core_title)) : ?>
<?php echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8'); ?>
<?php endif; ?>
<?php else : ?>
<?php $item->route = new JHelperRoute; ?>
<a href="<?php echo JRoute::_(TagsHelperRoute::getItemRoute($item->content_item_id, $item->core_alias, $item->core_catid, $item->core_language, $item->type_alias, $item->router)); ?>">
<?php if (!empty($item->core_title)) :
echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8');
endif; ?>
<a href="<?php echo JRoute::_($item->link); ?>">
<?php if (!empty($item->core_title)) : ?>
<?php echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8'); ?>
<?php endif; ?>
</a>
<?php endif; ?>
</li>
Expand Down

0 comments on commit 1fcf30c

Please sign in to comment.