From 95b6a23159fe605b63e65f6dd315092f122e003b Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 4 Oct 2018 12:07:37 +0200 Subject: [PATCH] Fixed gh-349 to insure dynamic joined and other tweaks are not added when custom code is selected as main source with a dynamicGet --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/a_Get.php | 256 +++++++++++++++++-------------- componentbuilder.xml | 2 +- 4 files changed, 140 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index ccbbddcba..104fbe1c1 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 3rd October, 2018 ++ *Last Build*: 4th October, 2018 + *Version*: 2.9.6 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/README.txt b/admin/README.txt index ccbbddcba..104fbe1c1 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 3rd October, 2018 ++ *Last Build*: 4th October, 2018 + *Version*: 2.9.6 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 9e606c6ca..aa9873fae 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -3000,6 +3000,8 @@ class Get // reset buckets $result->main_get = array(); $result->custom_get = array(); + // should joineds and other weaks be added + $addDynamicTweaksJoints = true; // set source data switch ($result->main_source) { @@ -3044,149 +3046,165 @@ class Get $result->main_get[0]['as'] = 'a'; $result->main_get[0]['key'] = $result->key; $result->main_get[0]['context'] = $context; + // do not add + $addDynamicTweaksJoints = false; break; } - // set join_view_table details - $result->join_view_table = json_decode($result->join_view_table, true); - if (ComponentbuilderHelper::checkArray($result->join_view_table)) + // only add if main source is not custom + if ($addDynamicTweaksJoints) { - foreach ($result->join_view_table as $nr => &$option) + // set join_view_table details + $result->join_view_table = json_decode($result->join_view_table, true); + if (ComponentbuilderHelper::checkArray($result->join_view_table)) { - if (ComponentbuilderHelper::checkString($option['selection'])) + foreach ($result->join_view_table as $nr => &$option) { - // convert the type - $option['type'] = $typeArray[$option['type']]; - // convert the operator - $option['operator'] = $operatorArray[$option['operator']]; - // get the on field values - $on_field = array(); // array(on_field_as, on_field) - $on_field = array_map('trim', explode('.', $option['on_field'])); - // get the join field values - $join_field = array(); // array(join_field_as, join_field) - $join_field = array_map('trim', explode('.', $option['join_field'])); - $option['selection'] = $this->setDataSelection($result->key, $view_code, $option['selection'], $option['view_table'], $option['as'], $option['row_type'], 'view'); - $option['key'] = $result->key; - $option['context'] = $context; - // load to the getters - if ($option['row_type'] == 1) + if (ComponentbuilderHelper::checkString($option['selection'])) { - $result->main_get[] = $option; - if ($on_field[0] === 'a') + // convert the type + $option['type'] = $typeArray[$option['type']]; + // convert the operator + $option['operator'] = $operatorArray[$option['operator']]; + // get the on field values + $on_field = array(); // array(on_field_as, on_field) + $on_field = array_map('trim', explode('.', $option['on_field'])); + // get the join field values + $join_field = array(); // array(join_field_as, join_field) + $join_field = array_map('trim', explode('.', $option['join_field'])); + $option['selection'] = $this->setDataSelection($result->key, $view_code, $option['selection'], $option['view_table'], $option['as'], $option['row_type'], 'view'); + $option['key'] = $result->key; + $option['context'] = $context; + // load to the getters + if ($option['row_type'] == 1) { - $this->siteMainGet[$this->target][$view_code][$option['as']] = $option['as']; + $result->main_get[] = $option; + if ($on_field[0] === 'a') + { + $this->siteMainGet[$this->target][$view_code][$option['as']] = $option['as']; + } + else + { + $this->siteDynamicGet[$this->target][$view_code][$option['as']][$join_field[1]] = $on_field[0]; + } } - else + elseif ($option['row_type'] == 2) { - $this->siteDynamicGet[$this->target][$view_code][$option['as']][$join_field[1]] = $on_field[0]; + $result->custom_get[] = $option; + if ($on_field[0] != 'a') + { + $this->siteDynamicGet[$this->target][$view_code][$option['as']][$join_field[1]] = $on_field[0]; + } } } - elseif ($option['row_type'] == 2) - { - $result->custom_get[] = $option; - if ($on_field[0] != 'a') - { - $this->siteDynamicGet[$this->target][$view_code][$option['as']][$join_field[1]] = $on_field[0]; - } - } - } - unset($result->join_view_table[$nr]); - } - } - unset($result->join_view_table); - // set join_db_table details - $result->join_db_table = json_decode($result->join_db_table, true); - if (ComponentbuilderHelper::checkArray($result->join_db_table)) - { - foreach ($result->join_db_table as $nr => &$option1) - { - if (ComponentbuilderHelper::checkString($option1['selection'])) - { - // convert the type - $option1['type'] = $typeArray[$option1['type']]; - // convert the operator - $option1['operator'] = $operatorArray[$option1['operator']]; - // get the on field values - $on_field = array(); // array(on_field_as, on_field) - $on_field = array_map('trim', explode('.', $option1['on_field'])); - // get the join field values - $join_field = array(); // array(join_field_as, join_field) - $join_field = array_map('trim', explode('.', $option1['join_field'])); - $option1['selection'] = $this->setDataSelection($result->key, $view_code, $option1['selection'], $option1['db_table'], $option1['as'], $option1['row_type'], 'db'); - $option1['key'] = $result->key; - $option1['context'] = $context; - // load to the getters - if ($option1['row_type'] == 1) - { - $result->main_get[] = $option1; - if ($on_field[0] === 'a') - { - $this->siteMainGet[$this->target][$view_code][$option1['as']] = $option1['as']; - } - else - { - $this->siteDynamicGet[$this->target][$view_code][$option1['as']][$join_field[1]] = $on_field[0]; - } - } - elseif ($option1['row_type'] == 2) - { - $result->custom_get[] = $option1; - if ($on_field[0] != 'a') - { - $this->siteDynamicGet[$this->target][$view_code][$option1['as']][$join_field[1]] = $on_field[0]; - } - } - } - unset($result->join_db_table[$nr]); - } - } - unset($result->join_db_table); - // set filter details - $result->filter = json_decode($result->filter, true); - if (ComponentbuilderHelper::checkArray($result->filter)) - { - foreach ($result->filter as $nr => &$option2) - { - if (isset($option2['operator'])) - { - $option2['operator'] = $operatorArray[$option2['operator']]; - $option2['key'] = $result->key; - } - else - { - unset($result->filter[$nr]); + unset($result->join_view_table[$nr]); } } - } - // set where details - $result->where = json_decode($result->where, true); - if (ComponentbuilderHelper::checkArray($result->where)) - { - foreach ($result->where as $nr => &$option3) + unset($result->join_view_table); + // set join_db_table details + $result->join_db_table = json_decode($result->join_db_table, true); + if (ComponentbuilderHelper::checkArray($result->join_db_table)) { - if (isset($option3['operator'])) + foreach ($result->join_db_table as $nr => &$option1) { - $option3['operator'] = $operatorArray[$option3['operator']]; + if (ComponentbuilderHelper::checkString($option1['selection'])) + { + // convert the type + $option1['type'] = $typeArray[$option1['type']]; + // convert the operator + $option1['operator'] = $operatorArray[$option1['operator']]; + // get the on field values + $on_field = array(); // array(on_field_as, on_field) + $on_field = array_map('trim', explode('.', $option1['on_field'])); + // get the join field values + $join_field = array(); // array(join_field_as, join_field) + $join_field = array_map('trim', explode('.', $option1['join_field'])); + $option1['selection'] = $this->setDataSelection($result->key, $view_code, $option1['selection'], $option1['db_table'], $option1['as'], $option1['row_type'], 'db'); + $option1['key'] = $result->key; + $option1['context'] = $context; + // load to the getters + if ($option1['row_type'] == 1) + { + $result->main_get[] = $option1; + if ($on_field[0] === 'a') + { + $this->siteMainGet[$this->target][$view_code][$option1['as']] = $option1['as']; + } + else + { + $this->siteDynamicGet[$this->target][$view_code][$option1['as']][$join_field[1]] = $on_field[0]; + } + } + elseif ($option1['row_type'] == 2) + { + $result->custom_get[] = $option1; + if ($on_field[0] != 'a') + { + $this->siteDynamicGet[$this->target][$view_code][$option1['as']][$join_field[1]] = $on_field[0]; + } + } + } + unset($result->join_db_table[$nr]); } - else + } + unset($result->join_db_table); + // set filter details + $result->filter = json_decode($result->filter, true); + if (ComponentbuilderHelper::checkArray($result->filter)) + { + foreach ($result->filter as $nr => &$option2) { - unset($result->where[$nr]); + if (isset($option2['operator'])) + { + $option2['operator'] = $operatorArray[$option2['operator']]; + $option2['key'] = $result->key; + } + else + { + unset($result->filter[$nr]); + } } } + // set where details + $result->where = json_decode($result->where, true); + if (ComponentbuilderHelper::checkArray($result->where)) + { + foreach ($result->where as $nr => &$option3) + { + if (isset($option3['operator'])) + { + $option3['operator'] = $operatorArray[$option3['operator']]; + } + else + { + unset($result->where[$nr]); + } + } + } + else + { + unset($result->where); + } + // set order details + $result->order = json_decode($result->order, true); + if (!ComponentbuilderHelper::checkArray($result->order)) + { + unset($result->order); + } + // set global details + $result->global = json_decode($result->global, true); + if (!ComponentbuilderHelper::checkArray($result->global)) + { + unset($result->global); + } } else { + // when we have a custom query script we do not add the dynamic options + unset($result->join_view_table); + unset($result->join_db_table); + unset($result->filter); unset($result->where); - } - // set order details - $result->order = json_decode($result->order, true); - if (!ComponentbuilderHelper::checkArray($result->order)) - { unset($result->order); - } - // set global details - $result->global = json_decode($result->global, true); - if (!ComponentbuilderHelper::checkArray($result->global)) - { unset($result->global); } // load the events if any is set diff --git a/componentbuilder.xml b/componentbuilder.xml index a55914f6c..7d32f9cdd 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 3rd October, 2018 + 4th October, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com