Skip to content

Commit

Permalink
Handle 404 when Fabrik is home menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Sep 6, 2016
1 parent 1939842 commit e577747
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions components/com_fabrik/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ function fabrikParseRoute($segments)
* and (dear reader) if you wanna do that be my guest.
*/

$viewFound = true;

switch ($view)
{
case 'form':
Expand All @@ -294,8 +296,66 @@ function fabrikParseRoute($segments)
$vars['format'] = ArrayHelper::getValue($segments, 2, 'html');
break;
default:
$viewFound = false;
break;
}

/*
* if a Fabrik view is home page, and this is a 404, no segments, but J! will still try and route com_fabrik
* So have a peek at the active menu, and break down the link
*/
if (!$viewFound)
{
$menus = JMenu::getInstance('site');
$menu = $menus->getActive();
$link = parse_url($menu->link);
$qs = array();
if (array_key_exists('query', $link))
{
parse_str($link['query'], $qs);
$option = ArrayHelper::getValue($qs, 'option', '');
if ($option == 'com_fabrik')
{
switch ($qs['view'])
{
case 'form':
case 'details':
case 'emailform':
$vars['view'] = $qs['view'];
$vars['formid'] = ArrayHelper::getValue($qs, 'formid', '');
$vars['rowid'] = ArrayHelper::getValue($qs, 'rowid', '');
$vars['format'] = ArrayHelper::getValue($qs, 'format', 'html');
$viewFound = true;
break;
case 'table':
case 'list':
$vars['view'] = $qs['view'];
$vars['listid'] = ArrayHelper::getValue($qs, 'listid', '');
$viewFound = true;
break;
case 'import':
$vars['view'] = 'import';
$vars['listid'] = ArrayHelper::getValue($qs, 'listid', '');
$vars['filetype'] = ArrayHelper::getValue($qs, 'filetype', '');
$viewFound = true;
break;
case 'visualization':
$vars['view'] = 'visualization';
$vars['id'] = ArrayHelper::getValue($qs, 'id', '');
$vars['format'] = ArrayHelper::getValue($qs, 'format', 'html');
$viewFound = true;
break;
default:
break;
}
}
}
}

if (!$viewFound)
{
JError::raiseError(404, JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
}

return $vars;
}

0 comments on commit e577747

Please sign in to comment.