Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mod_tags_similar] Link cleanup #20730

Merged
merged 2 commits into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the last item in the array did not have a comma

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per coding standards:

When splitting array definitions onto several lines, the last value should also have a trailing comma.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok - confused by line 159+ then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not an array, it's a set of method parameters. PHP doesn't allow trailing commas for those (well, maybe in PHP 7.2 but that't out of scope for a long time for us if that's true).

)
);
);

$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
4 changes: 1 addition & 3 deletions modules/mod_tags_similar/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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>
Expand All @@ -21,8 +20,7 @@
echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8');
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)); ?>">
<a href="<?php echo JRoute::_($item->link); ?>">
<?php if (!empty($item->core_title)) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider changing as follows for mixed language usage and above lines 19-21.

<?php if (!empty($item->core_title)) : ?>
	<?php echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8'); ?>
<?php endif; ?>

echo htmlspecialchars($item->core_title, ENT_COMPAT, 'UTF-8');
endif; ?>
Expand Down