From fdd1cf73905167a00423ca8b7054aaa54af69e18 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 29 Sep 2018 02:57:11 +0200 Subject: [PATCH] Added the option to random order the dynamic get result set. gh-348 --- README.md | 4 ++-- admin/README.txt | 4 ++-- admin/helpers/compiler/e_Interpretation.php | 14 +++++++++++--- .../language/en-GB/en-GB.com_componentbuilder.ini | 1 + admin/models/ajax.php | 2 +- admin/models/forms/custom_code.js | 2 +- admin/models/forms/dynamic_get.xml | 2 ++ admin/models/joomla_components.php | 2 +- componentbuilder.xml | 2 +- 9 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cd404d761..56b14d5aa 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,11 @@ 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*: 28th September, 2018 ++ *Last Build*: 29th September, 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 -+ *Line count*: **195702** ++ *Line count*: **195705** + *Field count*: **1087** + *File count*: **1278** + *Folder count*: **201** diff --git a/admin/README.txt b/admin/README.txt index cd404d761..56b14d5aa 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,11 +125,11 @@ 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*: 28th September, 2018 ++ *Last Build*: 29th September, 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 -+ *Line count*: **195702** ++ *Line count*: **195705** + *Field count*: **1087** + *File count*: **1278** + *Folder count*: **201** diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index ac1ccca3c..d496e21a2 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -2075,9 +2075,17 @@ class Interpretation extends Fields foreach ($order as $or) { list($as, $field) = array_map('trim', explode('.', $or['table_key'])); - - // set the string - $string = "\$query->order('" . $or['table_key'] . " " . $or['direction'] . "');"; + // check if random + if ('RAND' === $or['direction']) + { + // set the string + $string = "\$query->order('RAND()');"; + } + else + { + // set the string + $string = "\$query->order('" . $or['table_key'] . " " . $or['direction'] . "');"; + } // sort where if ($as === 'a' || (isset($this->siteMainGet[$this->target][$code][$as]) && ComponentbuilderHelper::checkString($this->siteMainGet[$this->target][$code][$as]))) { diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index bafe285c1..d3afb9103 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -4045,6 +4045,7 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_PUBLISHING="Publishing" COM_COMPONENTBUILDER_DYNAMIC_GET_Q="q" COM_COMPONENTBUILDER_DYNAMIC_GET_QQ="qq" COM_COMPONENTBUILDER_DYNAMIC_GET_R="r" +COM_COMPONENTBUILDER_DYNAMIC_GET_RANDOM="Random" COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE="Repeatable Value" COM_COMPONENTBUILDER_DYNAMIC_GET_ROW_TYPE_DESCRIPTION="Single row or Multiple rows" COM_COMPONENTBUILDER_DYNAMIC_GET_ROW_TYPE_LABEL="Return Row Type" diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 1af46d2b6..e53bd52f8 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -2233,7 +2233,7 @@ class ComponentbuilderModelAjax extends JModelList /** * Get the keys of the values to search custom code in * - * @param string $targe The table targeted + * @param string $target The table targeted * @param string $type The type of get * * @return array The query options diff --git a/admin/models/forms/custom_code.js b/admin/models/forms/custom_code.js index 7e167de0f..bab3cf26a 100644 --- a/admin/models/forms/custom_code.js +++ b/admin/models/forms/custom_code.js @@ -243,7 +243,7 @@ function setCustomCodePlaceholder() { jQuery('#jcb-placeholder').html('[not ready]'); jQuery('#jcb-placeholder-arg').html('[not ready]'); } else if (functioName.length > 2) { - jQuery('#jcb-placeholder').html('[CUSTO'+'MCODE='+functioName+']'); + jQuery('#jcb-placeholder').html('[CUSTO'+'MCODE='+functioName+']'); jQuery('#jcb-placeholder-arg').html('[CUSTO'+'MCODE='+functioName+'+value1,value2]'); } else { jQuery('#jcb-placeholder').html('[save to see]'); diff --git a/admin/models/forms/dynamic_get.xml b/admin/models/forms/dynamic_get.xml index bc46c83ba..04221907e 100644 --- a/admin/models/forms/dynamic_get.xml +++ b/admin/models/forms/dynamic_get.xml @@ -954,6 +954,8 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_ASCENDING + diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index 6f44c182a..b554fe9e7 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -1680,7 +1680,7 @@ class ComponentbuilderModelJoomla_components extends JModelList /** * Get the keys of the values to search custom code in * - * @param string $targe The table targeted + * @param string $target The table targeted * @param string $type The type of get * * @return array The query options diff --git a/componentbuilder.xml b/componentbuilder.xml index 6952f9fbc..2986d9b12 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 28th September, 2018 + 29th September, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com