Skip to content

Commit

Permalink
Added correct behavior to Tweaking Joint relationships in the dynamic…
Browse files Browse the repository at this point in the history
…Get compiler method setGetData. gh-500
  • Loading branch information
Llewellynvdm committed Dec 16, 2019
1 parent 9f6e0c4 commit 2ed53b2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TODO
+ *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*: 13th December, 2019
+ *Last Build*: 16th December, 2019
+ *Version*: 2.10.9
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
Expand Down
2 changes: 1 addition & 1 deletion admin/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TODO
+ *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*: 13th December, 2019
+ *Last Build*: 16th December, 2019
+ *Version*: 2.10.9
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
Expand Down
60 changes: 49 additions & 11 deletions admin/helpers/compiler/a_Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -3603,6 +3603,26 @@ public function setGetData($ids, $view_code, $context)
$result->join_view_table = json_decode($result->join_view_table, true);
if (ComponentbuilderHelper::checkArray($result->join_view_table))
{
// start the part of a table bucket
$_part_of_a = array();
// build relationship
$_relationship = array_map(function($op) use(&$_part_of_a){
$bucket = array();
// array(on_field_as, on_field)
$bucket['on_field'] = array_map('trim', explode('.', $op['on_field']));
// array(join_field_as, join_field)
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
// triget filed that has table a relationship
if ($bucket['on_field'][0] === 'a' ||
isset($_part_of_a[$bucket['on_field'][0]]) ||
isset($_part_of_a[$bucket['join_field'][0]]))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $result->join_view_table);

// loop joints
foreach ($result->join_view_table as $nr => &$option)
{
if (ComponentbuilderHelper::checkString($option['selection']))
Expand All @@ -3612,19 +3632,18 @@ public function setGetData($ids, $view_code, $context)
// 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']));
$on_field = $_relationship[$nr]['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']));
$join_field = $_relationship[$nr]['join_field'];
// set selection
$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)
{
$result->main_get[] = $option;
if ($on_field[0] === 'a')
if ($on_field[0] === 'a' || isset($_part_of_a[$join_field[0]]) || isset($_part_of_a[$on_field[0]]))
{
$this->siteMainGet[$this->target][$view_code][$option['as']] = $option['as'];
}
Expand All @@ -3650,6 +3669,26 @@ public function setGetData($ids, $view_code, $context)
$result->join_db_table = json_decode($result->join_db_table, true);
if (ComponentbuilderHelper::checkArray($result->join_db_table))
{
// start the part of a table bucket
$_part_of_a = array();
// build relationship
$_relationship = array_map(function($op) use(&$_part_of_a){
$bucket = array();
// array(on_field_as, on_field)
$bucket['on_field'] = array_map('trim', explode('.', $op['on_field']));
// array(join_field_as, join_field)
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
// triget filed that has table a relationship
if ($bucket['on_field'][0] === 'a' ||
isset($_part_of_a[$bucket['on_field'][0]]) ||
isset($_part_of_a[$bucket['join_field'][0]]))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $result->join_db_table);

// loop joints
foreach ($result->join_db_table as $nr => &$option1)
{
if (ComponentbuilderHelper::checkString($option1['selection']))
Expand All @@ -3659,19 +3698,18 @@ public function setGetData($ids, $view_code, $context)
// 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']));
$on_field = $_relationship[$nr]['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']));
$join_field = $_relationship[$nr]['join_field'];
// set selection
$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')
if ($on_field[0] === 'a' || isset($_part_of_a[$join_field[0]]) || isset($_part_of_a[$on_field[0]]))
{
$this->siteMainGet[$this->target][$view_code][$option1['as']] = $option1['as'];
}
Expand Down Expand Up @@ -5001,7 +5039,7 @@ public function setDataSelection($method_key, $view_code, $string, $asset, $as,
if (ComponentbuilderHelper::checkArray($gets) && ComponentbuilderHelper::checkArray($keys))
{
// single joined selection needs the prefix to the values to avoid conflict in the names
// so we most still add then AS
// so we must still add then AS
if ($string == '*' && 1 != $row_type)
{
$querySelect = "\$query->select('" . $as . ".*');";
Expand Down
2 changes: 1 addition & 1 deletion componentbuilder.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>13th December, 2019</creationDate>
<creationDate>16th December, 2019</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
Expand Down

0 comments on commit 2ed53b2

Please sign in to comment.