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

Tags: Fixing routing #5105

Closed
wants to merge 9 commits into from
Closed
Changes from all commits
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
45 changes: 17 additions & 28 deletions components/com_tags/helpers/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,11 @@ public static function getTagRoute($id)
}
else
{
if (!empty($needles) && $item = self::_findItem($needles))
{
$link = 'index.php?Itemid=' . $item;
}
else
$link = 'index.php?option=com_tags&view=tag&id=' . $id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Cause I'm an arse can we add a new line after above the if() statement please?


if ($item = self::_findItem($needles))
{
// Create the link
$link = 'index.php?option=com_tags&view=tag&id=' . $id;
$link .= '&Itemid=' . $item;
}
}

Expand Down Expand Up @@ -131,32 +128,24 @@ protected static function _findItem($needles = null)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
$lang = ($item->language != '' ? $item->language : '*');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a new line in between this line and the if statement please for code style

Copy link
Member Author

Choose a reason for hiding this comment

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

For you, I'd even add 2. 😉


if (!isset(self::$lookup[$view]))
if (!isset(self::$lookup[$lang]))
{
self::$lookup[$view] = array();
self::$lookup[$lang] = array();
}

// Only match menu items that list one tag
if (isset($item->query['id'][0]) && count($item->query['id']) == 1)
$view = $item->query['view'];

if (!isset(self::$lookup[$lang][$view]))
{
/*
* Here it will become a bit tricky
* language != * can override existing entries
* language == * cannot override existing entries
*/
if (!isset(self::$lookup[$language][$view][$item->query['id'][0]]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id'][0]] = $item->id;
}

self::$lookup[$view][$item->query['id'][0]] = $item->id;
self::$lookup[$lang][$view] = array();
}

if (isset($item->query["tag_list_language_filter"]) && $item->query["tag_list_language_filter"] != '')
// Only match menu items that list one tag
if (isset($item->query['id'][0]) && count($item->query['id']) == 1)
{
$language = $item->query["tag_list_language_filter"];
self::$lookup[$lang][$view][$item->query['id'][0]] = $item->id;
}
}
}
Expand All @@ -167,13 +156,13 @@ protected static function _findItem($needles = null)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$view]))
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$view][(int) $id]))
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$view][(int) $id];
return self::$lookup[$language][$view][(int) $id];
}
}
}
Expand Down