fixes gh-68 where the wrong name is used in searching for the alias, it must be the table name, and this is not always the same as the view.

This commit is contained in:
Llewellyn van der Merwe 2017-04-08 19:52:09 +01:00
parent 6bba258fec
commit 7afbb131ce
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5

View File

@ -4117,6 +4117,7 @@ class Interpretation extends Fields
public function routerParseSwitch(&$view, $viewArray = null, $aliasView = true, $idView = true) public function routerParseSwitch(&$view, $viewArray = null, $aliasView = true, $idView = true)
{ {
$isCategory = ''; $isCategory = '';
$viewTable = false;
if ($viewArray && ComponentbuilderHelper::checkArray($viewArray)) if ($viewArray && ComponentbuilderHelper::checkArray($viewArray))
{ {
if (isset($viewArray['settings']->main_get->db_table_main) && $viewArray['settings']->main_get->db_table_main === 'categories') if (isset($viewArray['settings']->main_get->db_table_main) && $viewArray['settings']->main_get->db_table_main === 'categories')
@ -4128,29 +4129,25 @@ class Interpretation extends Fields
// $idView = false; // TODO we will keep an eye on this.... // $idView = false; // TODO we will keep an eye on this....
// $aliasView = false; // $aliasView = false;
// } // }
// elseif (isset($viewArray['settings']->main_get->main_get) && ComponentbuilderHelper::checkArray($viewArray['settings']->main_get->main_get)) elseif (isset($viewArray['settings']->main_get->main_get) && ComponentbuilderHelper::checkArray($viewArray['settings']->main_get->main_get))
// { {
// $aliasView = false; foreach ($viewArray['settings']->main_get->main_get as $get)
// foreach ($viewArray['settings']->main_get->main_get as $get) {
// { if ($get['as'] === 'a')
// if ($get['as'] === 'a') {
// { if (isset($get['selection']) && ComponentbuilderHelper::checkArray($get['selection'])
// if (isset($get['selection']) && ComponentbuilderHelper::checkArray($get['selection']) && isset($get['selection']['select_gets'])
// && isset($get['selection']['select_gets']) && ComponentbuilderHelper::checkArray($get['selection']['select_gets']))
// && ComponentbuilderHelper::checkArray($get['selection']['select_gets'])) {
// { if (isset($get['selection']['table']))
// foreach ($get['selection']['select_gets'] as $checkAlias) {
// { $viewTable = str_replace('#__'.$this->fileContentStatic['###component###'].'_', '', $get['selection']['table']);
// if ($checkAlias === "'a.alias'") }
// { }
// $aliasView = true;
// } }
// } }
// } }
//
// }
// }
// }
} }
// add if tags is added, also for all front item views // add if tags is added, also for all front item views
if ($aliasView) if ($aliasView)
@ -4166,7 +4163,15 @@ class Interpretation extends Fields
$routerSwitch[] = "\t\t\t\t}"; $routerSwitch[] = "\t\t\t\t}";
$routerSwitch[] = "\t\t\t\telseif (\$segments[\$count-1])"; $routerSwitch[] = "\t\t\t\telseif (\$segments[\$count-1])";
$routerSwitch[] = "\t\t\t\t{"; $routerSwitch[] = "\t\t\t\t{";
// we need to get from the table of this views main get the alias so we need the table name
if ($viewTable)
{
$routerSwitch[] = "\t\t\t\t\t\$id = \$this->getVar('".$viewTable."', \$segments[\$count-1], 'alias', 'id'".$isCategory.");";
}
else
{
$routerSwitch[] = "\t\t\t\t\t\$id = \$this->getVar('".$view."', \$segments[\$count-1], 'alias', 'id'".$isCategory.");"; $routerSwitch[] = "\t\t\t\t\t\$id = \$this->getVar('".$view."', \$segments[\$count-1], 'alias', 'id'".$isCategory.");";
}
$routerSwitch[] = "\t\t\t\t\tif(\$id)"; $routerSwitch[] = "\t\t\t\t\tif(\$id)";
$routerSwitch[] = "\t\t\t\t\t{"; $routerSwitch[] = "\t\t\t\t\t{";
$routerSwitch[] = "\t\t\t\t\t\t\$vars['id'] = \$id;"; $routerSwitch[] = "\t\t\t\t\t\t\$vars['id'] = \$id;";