From a5de53c5fa96e491d9855b0eddad23e9362c366c Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 5 Mar 2019 09:51:52 +0200 Subject: [PATCH] Resolved gh-384 to enable category and any other field that inherit from the basic list type to be able to have options added. --- README.md | 4 +-- admin/README.txt | 4 +-- admin/config.xml | 2 -- admin/helpers/compiler/a_Get.php | 38 +++++++++++++++++------- admin/helpers/compiler/c_Fields.php | 9 ++++-- admin/helpers/componentbuilder.php | 46 +++++++++++++---------------- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 46 +++++++++++++---------------- 8 files changed, 79 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 4001ccf31..e9f4ab0ba 100644 --- a/README.md +++ b/README.md @@ -146,11 +146,11 @@ 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 March, 2019 ++ *Last Build*: 5th March, 2019 + *Version*: 2.9.13 + *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*: **203595** ++ *Line count*: **203581** + *Field count*: **1114** + *File count*: **1337** + *Folder count*: **209** diff --git a/admin/README.txt b/admin/README.txt index 4001ccf31..e9f4ab0ba 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -146,11 +146,11 @@ 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 March, 2019 ++ *Last Build*: 5th March, 2019 + *Version*: 2.9.13 + *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*: **203595** ++ *Line count*: **203581** + *Field count*: **1114** + *File count*: **1337** + *Folder count*: **209** diff --git a/admin/config.xml b/admin/config.xml index cc23481cf..53a28c3b9 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -57,8 +57,6 @@ folder="editors" filter="cmd" /> - - diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 9b95dfada..c4afa32ce 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -1992,17 +1992,24 @@ class Get { if (isset($view->{'add_' . $scripter}) && $view->{'add_' . $scripter} == 1 && ComponentbuilderHelper::checkString($view->$scripter)) { - $view->$scripter = $this->setDynamicValues(base64_decode($view->$scripter)); + $view->{$scripter} = $this->setDynamicValues(base64_decode($view->{$scripter})); $scripter_target = str_replace('javascript_', '', $scripter); - if (!isset($this->customScriptBuilder[$scripter_target][$name_single])) + if (!isset($this->customScriptBuilder[$scripter_target]) || !isset($this->customScriptBuilder[$scripter_target][$name_single])) { + // check if the script is set if (!isset($this->customScriptBuilder[$scripter_target])) { $this->customScriptBuilder[$scripter_target] = array(); } - $this->customScriptBuilder[$scripter_target][$name_single] = ''; + // check if the script view is set + if (!isset($this->customScriptBuilder[$scripter_target][$name_single])) + { + $this->customScriptBuilder[$scripter_target][$name_single] = ''; + } } - $this->customScriptBuilder[$scripter_target][$name_single] .= PHP_EOL . $view->$scripter; + // load the script to class array + $this->customScriptBuilder[$scripter_target][$name_single] .= PHP_EOL . $view->{$scripter}; + // check if a token must be set if (strpos($view->$scripter, "token") !== false || strpos($view->$scripter, "task=ajax") !== false) { if (!$this->customScriptBuilder['token'][$name_single]) @@ -2010,21 +2017,32 @@ class Get $this->customScriptBuilder['token'][$name_single] = true; } } - unset($view->$scripter); + unset($view->{$scripter}); } } // add_css $addArrayC = array('css_view', 'css_views'); foreach ($addArrayC as $scripter) { - if (isset($view->{'add_' . $scripter}) && $view->{'add_' . $scripter} == 1) + if (isset($view->{'add_' . $scripter}) && $view->{'add_' . $scripter} == 1 && ComponentbuilderHelper::checkString($view->{$scripter})) { - if (!isset($this->customScriptBuilder[$scripter][$name_single])) + $view->{$scripter} = $this->setDynamicValues(base64_decode($view->{$scripter})); + if (!isset($this->customScriptBuilder[$scripter]) || !isset($this->customScriptBuilder[$scripter][$name_single])) { - $this->customScriptBuilder[$scripter][$name_single] = ''; + // check if the script is set + if (!isset($this->customScriptBuilder[$scripter])) + { + $this->customScriptBuilder[$scripter] = array(); + } + // check if the script view is set + if (!isset($this->customScriptBuilder[$scripter][$name_single])) + { + $this->customScriptBuilder[$scripter][$name_single] = ''; + } } - $this->customScriptBuilder[$scripter][$name_single] .= PHP_EOL . base64_decode($view->$scripter); - unset($view->$scripter); + // load the script to class array + $this->customScriptBuilder[$scripter][$name_single] .= PHP_EOL . $view->{$scripter}; + unset($view->{$scripter}); } } // add_php diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 0016638ab..1a12752fd 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -1274,6 +1274,7 @@ class Fields extends Structure } } } + // if options were found if (ComponentbuilderHelper::checkString($optionSet)) { $field .= '>'; @@ -1281,16 +1282,17 @@ class Fields extends Structure $field .= $optionSet; $field .= PHP_EOL . $this->_t(2) . $taber . ""; } - elseif ($typeName === 'sql') + // if no options found and must have a list of options + elseif (ComponentbuilderHelper::fieldCheck($typeName, 'list')) { $optionArray = false; $field .= PHP_EOL . $this->_t(2) . $taber . "/>"; + $field .= PHP_EOL . $this->_t(2) . $taber . "" . PHP_EOL; } else { $optionArray = false; $field .= PHP_EOL . $this->_t(2) . $taber . "/>"; - $field .= PHP_EOL . $this->_t(2) . $taber . "" . PHP_EOL; } } elseif ($setType === 'plain') @@ -1663,7 +1665,8 @@ class Fields extends Structure } } } - if (!$field->fieldXML->count()) + // if no options found and must have a list of options + if (!$field->fieldXML->count() && ComponentbuilderHelper::fieldCheck($typeName, 'list')) { ComponentbuilderHelper::xmlComment($field->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings."); } diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index a4f722bd1..4c6e0095e 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -2545,42 +2545,36 @@ abstract class ComponentbuilderHelper **/ protected static $fieldGroups = array( 'default' => array( - 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', - 'checkboxes', 'color', 'combo', 'componentlayout', 'contentlanguage', 'editor', - 'chromestyle', 'contenttype', 'databaseconnection', 'editors', 'email', 'file', - 'filelist', 'folderlist', 'groupedlist', 'hidden', 'file', 'headertag', 'helpsite', - 'imagelist', 'integer', 'language', 'list', 'media', 'menu', 'note', 'number', 'password', - 'plugins', 'radio', 'repeatable', 'range', 'rules', 'subform', 'sessionhandler', 'spacer', 'sql', 'tag', - 'tel', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', 'moduletag', - 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle', + 'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB + 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', + 'integer', 'language', 'list', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', + 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', + 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' ), 'plain' => array( - 'accesslevel', 'checkbox', 'cachehandler', 'calendar', 'category', 'chromestyle', 'color', - 'contenttype', 'combo', 'componentlayout', 'databaseconnection', 'editor', 'editors', - 'email', 'file', 'filelist', 'folderlist', 'headertag', 'helpsite', - 'hidden', 'imagelist', 'integer', 'language', 'media', 'menu', - 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', - 'sessionhandler', 'tag', 'tel', 'text', 'textarea', - 'timezone', 'url', 'user', 'usergroup' - ), + 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', + 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', + 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + ), + 'option' => array( + 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB + 'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql' + ), 'text' => array( - 'calendar','color','editor','email','password','tel','text','textarea','url','number','range' - ), + 'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url' + ), 'list' => array( - 'checkboxes','checkbox','list','radio' - ), + 'checkbox', 'checkboxes', 'list', 'radio' + ), 'dynamic' => array( - 'category','headertag','tag','rules','user','file','filelist','folderlist','imagelist','integer','timezone','media','meter' + 'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user' ), 'spacer' => array( 'note', 'spacer' ), - 'option' => array( - 'plugins', 'checkboxes', 'contentlanguage', 'list', 'radio', 'sql' - ), 'special' => array( - 'contentlanguage', 'groupedlist', 'moduleposition', 'plugin', - 'repeatable', 'templatestyle', 'subform' + 'contentlanguage', 'groupedlist', 'moduleposition', 'plugin', 'repeatable', 'subform', 'templatestyle' ) ); diff --git a/componentbuilder.xml b/componentbuilder.xml index 82f983921..7f859c5fb 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 4th March, 2019 + 5th March, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 3baf8e4d4..942207647 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -2545,42 +2545,36 @@ abstract class ComponentbuilderHelper **/ protected static $fieldGroups = array( 'default' => array( - 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', - 'checkboxes', 'color', 'combo', 'componentlayout', 'contentlanguage', 'editor', - 'chromestyle', 'contenttype', 'databaseconnection', 'editors', 'email', 'file', - 'filelist', 'folderlist', 'groupedlist', 'hidden', 'file', 'headertag', 'helpsite', - 'imagelist', 'integer', 'language', 'list', 'media', 'menu', 'note', 'number', 'password', - 'plugins', 'radio', 'repeatable', 'range', 'rules', 'subform', 'sessionhandler', 'spacer', 'sql', 'tag', - 'tel', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', 'moduletag', - 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle', + 'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB + 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', + 'integer', 'language', 'list', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', + 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', + 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' ), 'plain' => array( - 'accesslevel', 'checkbox', 'cachehandler', 'calendar', 'category', 'chromestyle', 'color', - 'contenttype', 'combo', 'componentlayout', 'databaseconnection', 'editor', 'editors', - 'email', 'file', 'filelist', 'folderlist', 'headertag', 'helpsite', - 'hidden', 'imagelist', 'integer', 'language', 'media', 'menu', - 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', - 'sessionhandler', 'tag', 'tel', 'text', 'textarea', - 'timezone', 'url', 'user', 'usergroup' - ), + 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', + 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', + 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + ), + 'option' => array( + 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB + 'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql' + ), 'text' => array( - 'calendar','color','editor','email','password','tel','text','textarea','url','number','range' - ), + 'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url' + ), 'list' => array( - 'checkboxes','checkbox','list','radio' - ), + 'checkbox', 'checkboxes', 'list', 'radio' + ), 'dynamic' => array( - 'category','headertag','tag','rules','user','file','filelist','folderlist','imagelist','integer','timezone','media','meter' + 'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user' ), 'spacer' => array( 'note', 'spacer' ), - 'option' => array( - 'plugins', 'checkboxes', 'contentlanguage', 'list', 'radio', 'sql' - ), 'special' => array( - 'contentlanguage', 'groupedlist', 'moduleposition', 'plugin', - 'repeatable', 'templatestyle', 'subform' + 'contentlanguage', 'groupedlist', 'moduleposition', 'plugin', 'repeatable', 'subform', 'templatestyle' ) );