Resolved gh-379 to allow null and zero values to pass via ajax call/post

This commit is contained in:
Llewellyn van der Merwe 2019-04-28 00:16:06 +02:00
parent 2202157adc
commit b55d824e63
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
7 changed files with 77 additions and 17 deletions

View File

@ -150,8 +150,8 @@ TODO
+ *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*: **203733**
+ *Field count*: **1116**
+ *Line count*: **203769**
+ *Field count*: **1119**
+ *File count*: **1338**
+ *Folder count*: **209**

View File

@ -150,8 +150,8 @@ TODO
+ *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*: **203733**
+ *Field count*: **1116**
+ *Line count*: **203769**
+ *Field count*: **1119**
+ *File count*: **1338**
+ *Folder count*: **209**

View File

@ -10528,16 +10528,21 @@ class Interpretation extends Fields
{
$input = array();
$valueArray = array();
$ifArray = array();
$getModel = array();
$userCheck = array();
foreach ($this->customScriptBuilder[$target]['ajax_controller'] as $view)
{
foreach ($view as $task)
{
$input[$task['task_name']][] = PHP_EOL . $this->_t(6) . "\$" . $task['value_name'] . "Value = \$jinput->get('" . $task['value_name'] . "', " . $task['input_default'] . ", '" . $task['input_filter'] . "');";
$input[$task['task_name']][] = "\$" . $task['value_name'] . "Value = \$jinput->get('" . $task['value_name'] . "', " . $task['input_default'] . ", '" . $task['input_filter'] . "');";
$valueArray[$task['task_name']][] = "\$" . $task['value_name'] . "Value";
$getModel[$task['task_name']] = PHP_EOL . $this->_t(7) . "\$result = \$this->getModel('ajax')->" . $task['method_name'] . "(" . $this->bbb . "valueArray" . $this->ddd . ");";
$getModel[$task['task_name']] = "\$result = \$this->getModel('ajax')->" . $task['method_name'] . "(" . $this->bbb . "valueArray" . $this->ddd . ");";
// check if null or zero is allowed
if (!isset($task['allow_zero']) || 1 != $task['allow_zero'])
{
$ifArray[$task['task_name']][] = "\$" . $task['value_name'] . "Value";
}
// see user check is needed
if (isset($task['user_check']) && 1 == $task['user_check'])
{
@ -10561,21 +10566,40 @@ class Interpretation extends Fields
$cases .= PHP_EOL . $this->_t(6) . "\$returnRaw = \$jinput->get('raw', false, 'BOOLEAN');";
foreach ($input[$task] as $string)
{
$cases .= $string;
$cases .= PHP_EOL . $this->_t(6) . $string;
}
// set the values
$values = implode(', ', $valueArray[$task]);
$ifvalues = implode(' && ', $valueArray[$task]);
// set the values to method
$getMethod = str_replace($this->bbb . 'valueArray' . $this->ddd, $values, $getMethod);
$cases .= PHP_EOL . $this->_t(6) . "if(" . $ifvalues . $userCheck[$task] . ")";
// check if we have some values to check
if (isset($ifArray[$task]) && ComponentbuilderHelper::checkArray($ifArray[$task]))
{
$ifvalues = implode(' && ', $ifArray[$task]);
}
else
{
$ifvalues = '';
}
// build the if string
$ifvalues = $ifvalues . $userCheck[$task];
// check if we have a if string
if (ComponentbuilderHelper::checkString($ifvalues))
{
$cases .= PHP_EOL . $this->_t(6) . "if(" . $ifvalues . ")";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= $getMethod;
$cases .= PHP_EOL . $this->_t(7) . $getMethod;
$cases .= PHP_EOL . $this->_t(6) . "}";
$cases .= PHP_EOL . $this->_t(6) . "else";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7) . "\$result = false;";
$cases .= PHP_EOL . $this->_t(6) . "}";
}
else
{
$cases .= PHP_EOL . $this->_t(6) . $getMethod;
}
// continue the build
$cases .= PHP_EOL . $this->_t(6) . "if(\$callback = \$jinput->get('callback', null, 'CMD'))";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7) . "echo \$callback . \"(\".json_encode(\$result).\");\";";

View File

@ -542,6 +542,8 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_LABEL="Alias Builder"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_TYPE="Alias Builder Type"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_TYPE_DESCRIPTION="How should the alias be build for this view"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALIAS_BUILDER_TYPE_LABEL="Alias Builder Type"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALLOW_ZERO_DESCRIPTION="null & zero values"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALLOW_ZERO_LABEL="Allow"
COM_COMPONENTBUILDER_ADMIN_VIEW_ALNUM="ALNUM"
COM_COMPONENTBUILDER_ADMIN_VIEW_ARCHIVE="Archive"
COM_COMPONENTBUILDER_ADMIN_VIEW_ARMSCIIEIGHT_ARMSCIIEIGHT_ARMENIAN_MOST_SUITABLE_COLLATION_ARMSCIIEIGHT_GENERAL_CI="armscii8 - ARMSCII-8 Armenian (most suitable collation = armscii8_general_ci)"
@ -3215,6 +3217,8 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_VIEW="Add Php View"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_VIEW_LABEL="Add PHP (custom view script)"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_AJAX_INPUT="Ajax Input"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_AJAX_INPUT_LABEL="Ajax Input"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALLOW_ZERO_DESCRIPTION="null & zero values"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALLOW_ZERO_LABEL="Allow"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALNUM="ALNUM"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ARCHIVE="Archive"
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ARRAY="ARRAY"
@ -6470,6 +6474,8 @@ COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_VIEW="Add Php View"
COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_VIEW_LABEL="Add PHP (custom view script)"
COM_COMPONENTBUILDER_SITE_VIEW_AJAX_INPUT="Ajax Input"
COM_COMPONENTBUILDER_SITE_VIEW_AJAX_INPUT_LABEL="Ajax Input"
COM_COMPONENTBUILDER_SITE_VIEW_ALLOW_ZERO_DESCRIPTION="null & zero values"
COM_COMPONENTBUILDER_SITE_VIEW_ALLOW_ZERO_LABEL="Allow"
COM_COMPONENTBUILDER_SITE_VIEW_ALNUM="ALNUM"
COM_COMPONENTBUILDER_SITE_VIEW_ARCHIVE="Archive"
COM_COMPONENTBUILDER_SITE_VIEW_ARRAY="ARRAY"

View File

@ -2619,6 +2619,16 @@
message="COM_COMPONENTBUILDER_ADMIN_VIEW_METHOD_NAME_MESSAGE"
hint="COM_COMPONENTBUILDER_ADMIN_VIEW_METHOD_NAME_HINT"
/>
<!-- Allow_zero Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"
name="allow_zero"
label="COM_COMPONENTBUILDER_ADMIN_VIEW_ALLOW_ZERO_LABEL"
value="1"
required="false"
description="COM_COMPONENTBUILDER_ADMIN_VIEW_ALLOW_ZERO_DESCRIPTION"
class="inputbox"
/>
<!-- User_check Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"

View File

@ -503,6 +503,16 @@
message="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_METHOD_NAME_MESSAGE"
hint="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_METHOD_NAME_HINT"
/>
<!-- Allow_zero Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"
name="allow_zero"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALLOW_ZERO_LABEL"
value="1"
required="false"
description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALLOW_ZERO_DESCRIPTION"
class="inputbox"
/>
<!-- User_check Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"

View File

@ -529,6 +529,16 @@
message="COM_COMPONENTBUILDER_SITE_VIEW_METHOD_NAME_MESSAGE"
hint="COM_COMPONENTBUILDER_SITE_VIEW_METHOD_NAME_HINT"
/>
<!-- Allow_zero Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"
name="allow_zero"
label="COM_COMPONENTBUILDER_SITE_VIEW_ALLOW_ZERO_LABEL"
value="1"
required="false"
description="COM_COMPONENTBUILDER_SITE_VIEW_ALLOW_ZERO_DESCRIPTION"
class="inputbox"
/>
<!-- User_check Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"