Skip to content

Commit

Permalink
Rewriting com_tags router
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Mar 28, 2023
1 parent ad0feef commit 7e864ef
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions components/com_tags/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ public function preprocess($query)
if (isset($query['view']) && $query['view'] == 'tags') {
if (isset($query['parent_id']) && isset($this->lookup[$language]['tags'][$query['parent_id']])) {
$query['Itemid'] = $this->lookup[$language]['tags'][$query['parent_id']];

return $query;
} elseif (isset($this->lookup[$language]['tags'][0])) {
$query['Itemid'] = $this->lookup[$language]['tags'][0];

return $query;
}
} elseif (isset($query['view']) && $query['view'] == 'tag') {
if (isset($query['id'])) {
Expand All @@ -113,20 +117,16 @@ public function preprocess($query)

if (isset($this->lookup[$language]['tag'][implode(',', $id)])) {
$query['Itemid'] = $this->lookup[$language]['tag'][implode(',', $id)];

return $query;
} elseif (isset($this->lookup[$language]['tags'][0])) {
$query['Itemid'] = $this->lookup[$language]['tags'][0];

return $query;
}
}
}

// Check if the active menuitem matches the requested language
if (
!isset($query['Itemid']) && ($active && $active->component === 'com_tags'
&& ($language === '*' || \in_array($active->language, ['*', $language]) || !Multilanguage::isEnabled()))
) {
$query['Itemid'] = $active->id;
}

// If not found, return language specific home link
if (!isset($query['Itemid'])) {
$default = $this->menu->getDefault($language);
Expand All @@ -150,7 +150,7 @@ public function preprocess($query)
*/
public function build(&$query)
{
$segments = [];
$segments = array();

$menuItem = $this->menu->getItem($query['Itemid']);

Expand Down Expand Up @@ -193,8 +193,6 @@ public function build(&$query)
}
}

unset($query['layout']);

foreach ($segments as &$segment) {
if (strpos($segment, ':')) {
[$void, $segment] = explode(':', $segment, 2);
Expand Down

0 comments on commit 7e864ef

Please sign in to comment.