Skip to content

Commit

Permalink
Resolved gh-404 by adding the option to use grouping in dynamicGet qu…
Browse files Browse the repository at this point in the history
…ery.
  • Loading branch information
Llewellynvdm committed Apr 9, 2019
1 parent dd891ec commit fd154a8
Show file tree
Hide file tree
Showing 14 changed files with 733 additions and 592 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -12,7 +12,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo

Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have!

You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.9.14) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.9.15) with **ALL** its features and **ALL** concepts totally open-source and free!

> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
Expand Down Expand Up @@ -146,13 +146,13 @@ 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*: 4th April, 2019
+ *Version*: 2.9.14
+ *Last Build*: 9th April, 2019
+ *Version*: 2.9.15
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203650**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Line count*: **203724**
+ *Field count*: **1116**
+ *File count*: **1338**
+ *Folder count*: **209**

> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
Expand Down
12 changes: 6 additions & 6 deletions admin/README.txt
Expand Up @@ -12,7 +12,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo

Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have!

You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.9.14) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.9.15) with **ALL** its features and **ALL** concepts totally open-source and free!

> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)

Expand Down Expand Up @@ -146,13 +146,13 @@ 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*: 4th April, 2019
+ *Version*: 2.9.14
+ *Last Build*: 9th April, 2019
+ *Version*: 2.9.15
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203650**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Line count*: **203724**
+ *Field count*: **1116**
+ *File count*: **1338**
+ *Folder count*: **209**

> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
Expand Down
7 changes: 7 additions & 0 deletions admin/helpers/compiler/a_Get.php
Expand Up @@ -3283,6 +3283,12 @@ public function setGetData($ids, $view_code, $context)
{
unset($result->order);
}
// set grouping
$result->group = json_decode($result->group, true);
if (!ComponentbuilderHelper::checkArray($result->group))
{
unset($result->group);
}
// set global details
$result->global = json_decode($result->global, true);
if (!ComponentbuilderHelper::checkArray($result->global))
Expand All @@ -3298,6 +3304,7 @@ public function setGetData($ids, $view_code, $context)
unset($result->filter);
unset($result->where);
unset($result->order);
unset($result->group);
unset($result->global);
}
// load the events if any is set
Expand Down
72 changes: 66 additions & 6 deletions admin/helpers/compiler/e_Interpretation.php
Expand Up @@ -2067,6 +2067,30 @@ public function setCustomViewFilter(&$filter, &$code, $tab = '')
return $filters;
}

public function setCustomViewGroup(&$group, &$code, $tab = '')
{
$grouping = '';
if (ComponentbuilderHelper::checkArray($group))
{
foreach ($group as $gr)
{
list($as, $field) = array_map('trim', explode('.', $gr['table_key']));
// set the string
$string = "\$query->group('" . $gr['table_key'] . "');";
// sort where
if ($as === 'a' || (isset($this->siteMainGet[$this->target][$code][$as]) && ComponentbuilderHelper::checkString($this->siteMainGet[$this->target][$code][$as])))
{
$grouping .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . $string;
}
else
{
$this->otherGroup[$this->target][$code][$as][$field] = PHP_EOL . $this->_t(2) . $string;
}
}
}
return $grouping;
}

public function setCustomViewOrder(&$order, &$code, $tab = '')
{
$ordering = '';
Expand Down Expand Up @@ -2313,11 +2337,25 @@ public function setCustomViewGetItem(&$get, &$code, $tab = '', $type = 'main')
// set main get query
$getItem .= $this->setCustomViewQuery($get->main_get, $code, $tab);
// setup filters
$getItem .= $this->setCustomViewFilter($get->filter, $code, $tab);
if (isset($get->filter))
{
$getItem .= $this->setCustomViewFilter($get->filter, $code, $tab);
}
// setup Where
$getItem .= $this->setCustomViewWhere($get->where, $code, $tab);
if (isset($get->where))
{
$getItem .= $this->setCustomViewWhere($get->where, $code, $tab);
}
// setup ordering
$getItem .= $this->setCustomViewOrder($get->order, $code, $tab);
if (isset($get->order))
{
$getItem .= $this->setCustomViewOrder($get->order, $code, $tab);
}
// setup grouping
if (isset($get->group))
{
$getItem .= $this->setCustomViewGroup($get->group, $code, $tab);
}
// get ready to get query
$getItem .= PHP_EOL . PHP_EOL . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Reset the query using our newly populated query object.";
$getItem .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "\$db->setQuery(\$query);";
Expand Down Expand Up @@ -2798,6 +2836,14 @@ public function setCustomViewCustomItemMethods(&$main_get, $code)
$methods .= $string;
}
}
// add any other grouping that was set
if (isset($this->otherGroup[$this->target][$default['code']][$default['as']]) && ComponentbuilderHelper::checkArray($this->otherGroup[$this->target][$default['code']][$default['as']]))
{
foreach ($this->otherGroup[$this->target][$default['code']][$default['as']] as $field => $string)
{
$methods .= $string;
}
}
$methods .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Reset the query using our newly populated query object.";
$methods .= PHP_EOL . $this->_t(2) . "\$db->setQuery(\$query);";
$methods .= PHP_EOL . $this->_t(2) . "\$db->execute();";
Expand Down Expand Up @@ -3031,11 +3077,25 @@ public function setCustomViewListQuery(&$get, $code, $return = true)
// set main get query
$getItem .= $this->setCustomViewQuery($get->main_get, $code);
// setup filters
$getItem .= $this->setCustomViewFilter($get->filter, $code);
if (isset($get->filter))
{
$getItem .= $this->setCustomViewFilter($get->filter, $code);
}
// setup where
$getItem .= $this->setCustomViewWhere($get->where, $code);
if (isset($get->where))
{
$getItem .= $this->setCustomViewWhere($get->where, $code);
}
// setup ordering
$getItem .= $this->setCustomViewOrder($get->order, $code);
if (isset($get->order))
{
$getItem .= $this->setCustomViewOrder($get->order, $code);
}
// setup grouping
if (isset($get->group))
{
$getItem .= $this->setCustomViewGroup($get->group, $code);
}
if ($return)
{
// return the query object
Expand Down
5 changes: 4 additions & 1 deletion admin/language/en-GB/en-GB.com_componentbuilder.ini
Expand Up @@ -4018,6 +4018,9 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_GLOBAL_DESCRIPTION="Here you can add global var
COM_COMPONENTBUILDER_DYNAMIC_GET_GLOBAL_LABEL="Set Global"
COM_COMPONENTBUILDER_DYNAMIC_GET_GREATER_THAN="greater than"
COM_COMPONENTBUILDER_DYNAMIC_GET_GREATER_THAN_OR_EQUAL="greater than or equal"
COM_COMPONENTBUILDER_DYNAMIC_GET_GROUP="Group"
COM_COMPONENTBUILDER_DYNAMIC_GET_GROUP_DESCRIPTION="Here you can set the grouping per data set."
COM_COMPONENTBUILDER_DYNAMIC_GET_GROUP_LABEL="Grouping"
COM_COMPONENTBUILDER_DYNAMIC_GET_H="h"
COM_COMPONENTBUILDER_DYNAMIC_GET_HH="hh"
COM_COMPONENTBUILDER_DYNAMIC_GET_I="i"
Expand Down Expand Up @@ -4169,7 +4172,7 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS="Tags"
COM_COMPONENTBUILDER_DYNAMIC_GET_THIS="This"
COM_COMPONENTBUILDER_DYNAMIC_GET_TT="tt"
COM_COMPONENTBUILDER_DYNAMIC_GET_TWEAK="Tweak"
COM_COMPONENTBUILDER_DYNAMIC_GET_TYPE_LABEL="Type"
COM_COMPONENTBUILDER_DYNAMIC_GET_TYPE_LABEL="Set Type"
COM_COMPONENTBUILDER_DYNAMIC_GET_U="u"
COM_COMPONENTBUILDER_DYNAMIC_GET_USER="User"
COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS="User Groups"
Expand Down
1 change: 1 addition & 0 deletions admin/layouts/dynamic_get/tweak_fullwidth.php
Expand Up @@ -18,6 +18,7 @@
'filter',
'where',
'order',
'group',
'global'
);

Expand Down
63 changes: 42 additions & 21 deletions admin/models/dynamic_get.php
Expand Up @@ -134,6 +134,14 @@ public function getItem($pk = null)
$item->php_calculation = base64_decode($item->php_calculation);
}

if (!empty($item->join_view_table))
{
// Convert the join_view_table field to an array.
$join_view_table = new Registry;
$join_view_table->loadString($item->join_view_table);
$item->join_view_table = $join_view_table->toArray();
}

if (!empty($item->join_db_table))
{
// Convert the join_db_table field to an array.
Expand Down Expand Up @@ -166,6 +174,14 @@ public function getItem($pk = null)
$item->order = $order->toArray();
}

if (!empty($item->group))
{
// Convert the group field to an array.
$group = new Registry;
$group->loadString($item->group);
$item->group = $group->toArray();
}

if (!empty($item->global))
{
// Convert the global field to an array.
Expand All @@ -174,14 +190,6 @@ public function getItem($pk = null)
$item->global = $global->toArray();
}

if (!empty($item->join_view_table))
{
// Convert the join_view_table field to an array.
$join_view_table = new Registry;
$join_view_table->loadString($item->join_view_table);
$item->join_view_table = $join_view_table->toArray();
}

if (!empty($item->plugin_events))
{
// JSON Decode plugin_events.
Expand Down Expand Up @@ -986,6 +994,19 @@ public function save($data)
$data['metadata'] = (string) $metadata;
}

// Set the join_view_table items to data.
if (isset($data['join_view_table']) && is_array($data['join_view_table']))
{
$join_view_table = new JRegistry;
$join_view_table->loadArray($data['join_view_table']);
$data['join_view_table'] = (string) $join_view_table;
}
elseif (!isset($data['join_view_table']))
{
// Set the empty join_view_table to data
$data['join_view_table'] = '';
}

// Set the join_db_table items to data.
if (isset($data['join_db_table']) && is_array($data['join_db_table']))
{
Expand Down Expand Up @@ -1038,6 +1059,19 @@ public function save($data)
$data['order'] = '';
}

// Set the group items to data.
if (isset($data['group']) && is_array($data['group']))
{
$group = new JRegistry;
$group->loadArray($data['group']);
$data['group'] = (string) $group;
}
elseif (!isset($data['group']))
{
// Set the empty group to data
$data['group'] = '';
}

// Set the global items to data.
if (isset($data['global']) && is_array($data['global']))
{
Expand All @@ -1051,19 +1085,6 @@ public function save($data)
$data['global'] = '';
}

// Set the join_view_table items to data.
if (isset($data['join_view_table']) && is_array($data['join_view_table']))
{
$join_view_table = new JRegistry;
$join_view_table->loadArray($data['join_view_table']);
$data['join_view_table'] = (string) $join_view_table;
}
elseif (!isset($data['join_view_table']))
{
// Set the empty join_view_table to data
$data['join_view_table'] = '';
}

// Set the plugin_events string to JSON string.
if (isset($data['plugin_events']))
{
Expand Down
2 changes: 2 additions & 0 deletions admin/models/forms/dynamic_get.js
Expand Up @@ -657,6 +657,7 @@ function vvvvvzp(main_source_vvvvvzp)
{
jQuery('#jform_filter-lbl').closest('.control-group').show();
jQuery('#jform_global-lbl').closest('.control-group').show();
jQuery('#jform_group-lbl').closest('.control-group').show();
jQuery('#jform_order-lbl').closest('.control-group').show();
jQuery('#jform_where-lbl').closest('.control-group').show();
jQuery('#jform_join_db_table-lbl').closest('.control-group').show();
Expand All @@ -666,6 +667,7 @@ function vvvvvzp(main_source_vvvvvzp)
{
jQuery('#jform_filter-lbl').closest('.control-group').hide();
jQuery('#jform_global-lbl').closest('.control-group').hide();
jQuery('#jform_group-lbl').closest('.control-group').hide();
jQuery('#jform_order-lbl').closest('.control-group').hide();
jQuery('#jform_where-lbl').closest('.control-group').hide();
jQuery('#jform_join_db_table-lbl').closest('.control-group').hide();
Expand Down

0 comments on commit fd154a8

Please sign in to comment.