From 3a5681ce4336c5658d3cabb9994e6eac718e6892 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 13 Jul 2020 04:52:06 +0200 Subject: [PATCH] Added option to dynamicly set the sub-form layout from global options. Fixed bug in compiler that caused index warning. --- README.md | 6 +- admin/README.txt | 6 +- admin/config.xml | 65 +++++++++++++++++++ admin/helpers/compiler.php | 8 +-- admin/helpers/compiler/a_Get.php | 8 +-- admin/helpers/compiler/c_Fields.php | 15 ++--- admin/helpers/compiler/e_Interpretation.php | 4 +- admin/helpers/compiler/f_Infusion.php | 8 +-- admin/helpers/componentbuilder.php | 41 ++++++++++++ .../en-GB/en-GB.com_componentbuilder.ini | 16 +++++ admin/models/admin_custom_tabs.php | 3 + admin/models/admin_fields.php | 3 + admin/models/admin_fields_conditions.php | 3 + admin/models/admin_fields_relations.php | 3 + admin/models/component_admin_views.php | 3 + admin/models/component_custom_admin_views.php | 3 + admin/models/component_site_views.php | 3 + admin/models/dynamic_get.php | 6 ++ componentbuilder.xml | 2 +- script.php | 2 +- site/helpers/componentbuilder.php | 41 ++++++++++++ 21 files changed, 219 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a6ac9c86c..c687a1110 100644 --- a/README.md +++ b/README.md @@ -144,12 +144,12 @@ 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*: 11th July, 2020 ++ *Last Build*: 13th July, 2020 + *Version*: 2.11.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **282509** -+ *Field count*: **1522** ++ *Line count*: **282699** ++ *Field count*: **1525** + *File count*: **1785** + *Folder count*: **295** diff --git a/admin/README.txt b/admin/README.txt index a6ac9c86c..c687a1110 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -144,12 +144,12 @@ 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*: 11th July, 2020 ++ *Last Build*: 13th July, 2020 + *Version*: 2.11.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **282509** -+ *Field count*: **1522** ++ *Line count*: **282699** ++ *Field count*: **1525** + *File count*: **1785** + *Folder count*: **295** diff --git a/admin/config.xml b/admin/config.xml index 7cc153967..0421e9f60 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -47,6 +47,71 @@ /> + + + + triggerEvent( 'jcb_ce_onBeforeUpdateFiles', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // now update the files if (!$this->updateFiles()) @@ -121,7 +121,7 @@ class Compiler extends Infusion // Trigger Event: jcb_ce_onBeforeGetCustomCode $this->triggerEvent( 'jcb_ce_onBeforeGetCustomCode', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // now insert into the new files if ($this->getCustomCode()) @@ -129,7 +129,7 @@ class Compiler extends Infusion // Trigger Event: jcb_ce_onBeforeAddCustomCode $this->triggerEvent( 'jcb_ce_onBeforeAddCustomCode', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); $this->addCustomCode(); @@ -137,7 +137,7 @@ class Compiler extends Infusion // Trigger Event: jcb_ce_onBeforeSetLangFileData $this->triggerEvent( 'jcb_ce_onBeforeSetLangFileData', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // set the lang data now $this->setLangFileData(); diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 3da405a7c..abac157a0 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -835,7 +835,7 @@ class Get } } // Trigger Event: jcb_ce_onBeforeGet - $this->triggerEvent('jcb_ce_onBeforeGet', array(&$config, $this)); + $this->triggerEvent('jcb_ce_onBeforeGet', array(&$config, &$this)); // set the Joomla version $this->joomlaVersion = $config['version']; // set the minfy switch of the JavaScript @@ -923,14 +923,14 @@ class Get // Trigger Event: jcb_ce_onBeforeGetComponentData $this->triggerEvent( 'jcb_ce_onBeforeGetComponentData', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // get the component data $this->componentData = $this->getComponentData(); // Trigger Event: jcb_ce_onAfterGetComponentData $this->triggerEvent( 'jcb_ce_onAfterGetComponentData', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // make sure we have a version if (strpos($this->componentData->component_version, '.') @@ -969,7 +969,7 @@ class Get // Trigger Event: jcb_ce_onBeforeGet $this->triggerEvent( - 'jcb_ce_onAfterGet', array(&$this->componentContext, $this) + 'jcb_ce_onAfterGet', array(&$this->componentContext, &$this) ); return true; diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index e70dc64d8..4f82d27e8 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -4194,7 +4194,7 @@ class Fields extends Structure = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; foreach ($phpTracker as $searchKey => $phpKey) { - // we must search for more code in the xml just incase + // we must search for more code in the xml just encase foreach (range(2, 30) as $phpLine) { $get_ = $searchKey . '_' . $phpLine; @@ -4953,17 +4953,16 @@ class Fields extends Structure $replace = array( $this->bbb . 'JPREFIX' . $this->ddd => $jprefix, $this->bbb . 'TABLE' - . $this->ddd => $data['custom']['table'], + . $this->ddd => (isset($data['custom']['table'])) ? $data['custom']['table'] :'', $this->bbb . 'ID' - . $this->ddd => $data['custom']['id'], + . $this->ddd => (isset($data['custom']['id'])) ? $data['custom']['id'] :'', $this->bbb . 'TEXT' - . $this->ddd => $data['custom']['text'], - $this->bbb . 'CODE_TEXT' . $this->ddd => $data['code'] . '_' - . $data['custom']['text'], - $this->bbb . 'CODE' . $this->ddd => $data['code'], + . $this->ddd => (isset($data['custom']['text'])) ? $data['custom']['text'] :'', + $this->bbb . 'CODE_TEXT' . $this->ddd => (isset($data['code'], $data['custom']['text'])) ? $data['code'] . '_' . $data['custom']['text'] :'', + $this->bbb . 'CODE' . $this->ddd => (isset($data['code'])) ? $data['code'] :'', $this->bbb . 'view_type' . $this->ddd => $view_name_single . '_' . $data['type'], - $this->bbb . 'type' . $this->ddd => $data['type'], + $this->bbb . 'type' . $this->ddd => (isset($data['type'])) ? $data['type'] :'', $this->bbb . 'com_component' . $this->ddd => (isset($data['custom']['component']) && ComponentbuilderHelper::checkString( diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index caf861940..b6f3f68b6 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -25193,7 +25193,7 @@ function vdm_dkim() { // Trigger Event: jcb_ce_onBeforeBuildAccessSections $this->triggerEvent( 'jcb_ce_onBeforeBuildAccessSections', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); $this->componentHead[] = '
'; @@ -25620,7 +25620,7 @@ function vdm_dkim() { // Trigger Event: jcb_ce_onAfterBuildAccessSections $this->triggerEvent( 'jcb_ce_onAfterBuildAccessSections', - array(&$this->componentContext, $this) + array(&$this->componentContext, &$this) ); // set the views permissions now diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index f0f9689f4..fa2ea1d98 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -1934,7 +1934,7 @@ class Infusion extends Interpretation // Trigger Event: jcb_ce_onBeforeInfuseModuleData $this->triggerEvent( 'jcb_ce_onBeforeInfuseModuleData', - array(&$this->componentContext, &$module, $this) + array(&$this->componentContext, &$module, &$this) ); $this->target = $module->key; $this->lang = $module->key; @@ -1998,7 +1998,7 @@ class Infusion extends Interpretation // Trigger Event: jcb_ce_onAfterInfuseModuleData $this->triggerEvent( 'jcb_ce_onAfterInfuseModuleData', - array(&$this->componentContext, &$module, $this) + array(&$this->componentContext, &$module, &$this) ); } } @@ -2013,7 +2013,7 @@ class Infusion extends Interpretation // Trigger Event: jcb_ce_onBeforeInfusePluginData $this->triggerEvent( 'jcb_ce_onBeforeInfusePluginData', - array(&$this->componentContext, &$plugin, $this) + array(&$this->componentContext, &$plugin, &$this) ); $this->target = $plugin->key; $this->lang = $plugin->key; @@ -2060,7 +2060,7 @@ class Infusion extends Interpretation // Trigger Event: jcb_ce_onAfterInfusePluginData $this->triggerEvent( 'jcb_ce_onAfterInfusePluginData', - array(&$this->componentContext, &$plugin, $this) + array(&$this->componentContext, &$plugin, &$this) ); } } diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 171b27dbd..8cafa3d41 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -5864,6 +5864,47 @@ abstract class ComponentbuilderHelper return $d && $d->format($format) == $date; } + + /** + * The subform layouts + **/ + protected static $subformLayouts = false; + + /** + * get the subform layout + * + * @input string The view name + * @input string The string name + * + * @returns string on success + **/ + public static function getSubformLayout($view, $field, $default = 'repeatablejcb') + { + // get global values + if (self::$subformLayouts === false) + { + self::$subformLayouts = JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false); + } + // check what we found (else) return default + if (self::checkObject(self::$subformLayouts)) + { + // looking for + $target = $view . '.' . $field; + foreach (self::$subformLayouts as $subform) + { + if ($target === $subform->view_field) + { + return $subform->layout; + } + elseif ('default' === $subform->view_field) + { + $default = $subform->layout; + } + } + } + return $default; + } + /** * Load the Composer Vendors diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 3d23dd41b..47c181c89 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -3235,6 +3235,10 @@ COM_COMPONENTBUILDER_CONDITIONS="Conditions" COM_COMPONENTBUILDER_CONFIG_ACTIVE="Active" COM_COMPONENTBUILDER_CONFIG_ADD_MENU_PREFIX_DESCRIPTION="Would you like to add a prefix to the Joomla menu name of your components" COM_COMPONENTBUILDER_CONFIG_ADD_MENU_PREFIX_LABEL="Add Menu Prefix" +COM_COMPONENTBUILDER_CONFIG_ADMIN_CUSTOM_TABS_TABS="Admin Custom Tabs (tabs)" +COM_COMPONENTBUILDER_CONFIG_ADMIN_FIELDS_ADDFIELDS="Admin Fields (addfields)" +COM_COMPONENTBUILDER_CONFIG_ADMIN_FIELDS_CONDITIONS_ADDCONDITIONS="Admin Fields Conditions (addconditions)" +COM_COMPONENTBUILDER_CONFIG_ADMIN_FIELDS_RELATIONS_ADDRELATIONS="Admin Fields Relations (addrelations)" COM_COMPONENTBUILDER_CONFIG_ALMOST_FLAT_LOAD="Almost Flat" COM_COMPONENTBUILDER_CONFIG_ALPHANUMERIC="Alphanumeric" COM_COMPONENTBUILDER_CONFIG_ALPHANUMERICDOT="Alphanumeric+dot" @@ -3336,7 +3340,10 @@ COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_MESSAGE="Error! Please add some COM_COMPONENTBUILDER_CONFIG_COMPILER_PLUGIN_DESCRIPTION="Select the plugin you would like to use in JCB's compiler" COM_COMPONENTBUILDER_CONFIG_COMPILER_PLUGIN_LABEL="Activate Compiler Plugins" COM_COMPONENTBUILDER_CONFIG_COMPONENT="Component" +COM_COMPONENTBUILDER_CONFIG_COMPONENT_ADMIN_VIEWS_ADDADMIN_VIEWS="Component Admin Views (addadmin_views)" +COM_COMPONENTBUILDER_CONFIG_COMPONENT_CUSTOM_ADMIN_VIEWS_ADDCUSTOM_ADMIN_VIEWS="Component Custom Admin Views (addcustom_admin_views)" COM_COMPONENTBUILDER_CONFIG_COMPONENT_LABEL="Component" +COM_COMPONENTBUILDER_CONFIG_COMPONENT_SITE_VIEWS_ADDSITE_VIEWS="Component Site Views (addsite_views)" COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_DESCRIPTION="Here you can set the path to where all components are backed up to." COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_HINT="/home/user/fullbackup" COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_LABEL="Cronjob Backup Folder Path" @@ -3379,6 +3386,8 @@ COM_COMPONENTBUILDER_CONFIG_DKIM_VALUE_DESCRIPTION="This is the TXT value to use COM_COMPONENTBUILDER_CONFIG_DKIM_VALUE_HINT="v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY" COM_COMPONENTBUILDER_CONFIG_DKIM_VALUE_LABEL="Value" COM_COMPONENTBUILDER_CONFIG_DONT_LOAD="Not" +COM_COMPONENTBUILDER_CONFIG_DYNAMIC_GET_JOIN_DB_TABLE="Dynamic Get (join_db_table)" +COM_COMPONENTBUILDER_CONFIG_DYNAMIC_GET_JOIN_VIEW_TABLE="Dynamic Get (join_view_table)" COM_COMPONENTBUILDER_CONFIG_EDITOR_DESCRIPTION="Select the editor you would like to use as the JCB global editor for all custom coding areas." COM_COMPONENTBUILDER_CONFIG_EDITOR_LABEL="Select an editor" COM_COMPONENTBUILDER_CONFIG_EMAILFROM_DESCRIPTION="The global email address that will be used to send system email." @@ -3486,6 +3495,7 @@ COM_COMPONENTBUILDER_CONFIG_JCB_COMMUNITY_PACKAGES="JCB Community Packages" COM_COMPONENTBUILDER_CONFIG_JCB_PACKAGE_DIRECTORIES_DESCRIPTION="Here you can manage what package directories show in the JCB package import area." COM_COMPONENTBUILDER_CONFIG_JCB_PACKAGE_DIRECTORIES_LABEL="Directories" COM_COMPONENTBUILDER_CONFIG_LANGUAGE_LABEL="Language" +COM_COMPONENTBUILDER_CONFIG_LAYOUT_LABEL="Layout" COM_COMPONENTBUILDER_CONFIG_LOCAL_FOLDER="Local Folder" COM_COMPONENTBUILDER_CONFIG_MAILER_DESCRIPTION="Select what mailer you would like to use to send emails." COM_COMPONENTBUILDER_CONFIG_MAILER_LABEL="Mailer" @@ -3568,6 +3578,9 @@ COM_COMPONENTBUILDER_CONFIG_PHP_MAIL="PHP Mail" COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_DESCRIPTION="Should JCB insert the custom code placeholders? This is only applicable if this component has custom code." COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_LABEL="Add Custom Code Placeholders" COM_COMPONENTBUILDER_CONFIG_REMOTE_SERVER="Remote Server" +COM_COMPONENTBUILDER_CONFIG_REPEATABLETABLE_JOOMLA="Repeatable-table (joomla)" +COM_COMPONENTBUILDER_CONFIG_REPEATABLE_JOOMLA="Repeatable (Joomla)" +COM_COMPONENTBUILDER_CONFIG_REPEATABLE_UIKIT="Repeatable (UIkit)" COM_COMPONENTBUILDER_CONFIG_REPLYNAME_DESCRIPTION="Text displayed in the header "Reply To:" field when replying to the site email. Usually the the person that receives the response. (leave blank for none)" COM_COMPONENTBUILDER_CONFIG_REPLYNAME_HINT="Reply Name Here" COM_COMPONENTBUILDER_CONFIG_REPLYNAME_LABEL="Reply to Name" @@ -3603,6 +3616,8 @@ COM_COMPONENTBUILDER_CONFIG_SSL="SSL" COM_COMPONENTBUILDER_CONFIG_STORAGE_TIME_TO_LIVE_DESCRIPTION="How long should the data that is stored in the browser memory remain unchanged before it is removed and updated." COM_COMPONENTBUILDER_CONFIG_STORAGE_TIME_TO_LIVE_LABEL="Update Cycle" COM_COMPONENTBUILDER_CONFIG_STRING_MANIPULATION="String Manipulation" +COM_COMPONENTBUILDER_CONFIG_SUBFORM_LAYOUTS_DESCRIPTION="Select the sub-form layouts you would like to use." +COM_COMPONENTBUILDER_CONFIG_SUBFORM_LAYOUTS_LABEL="Sub-form Layouts" COM_COMPONENTBUILDER_CONFIG_TLS="TLS" COM_COMPONENTBUILDER_CONFIG_TRUE="True" COM_COMPONENTBUILDER_CONFIG_TYPE_NAME_BUILDER_DESCRIPTION="The default option only uses alphabetical characters and converts all numbers in field names to the English equivalent like 1 becomes one.
Alphanumeric+dot keeps the numbers unconverted unless it is at the beginning of the field name, and allows for a dot (.) to be used in the type name for namespacing." @@ -3617,6 +3632,7 @@ COM_COMPONENTBUILDER_CONFIG_UIKIT_MIN_LABEL="Load Minified" COM_COMPONENTBUILDER_CONFIG_UIKIT_STYLE_DESC="Set the css style that should be used." COM_COMPONENTBUILDER_CONFIG_UIKIT_STYLE_LABEL="css Style" COM_COMPONENTBUILDER_CONFIG_VDM_PACKAGES="VDM Packages" +COM_COMPONENTBUILDER_CONFIG_VIEW_FIELD_LABEL="View & Field" COM_COMPONENTBUILDER_CONFIG_YES="Yes" COM_COMPONENTBUILDER_CONFIRMATION_STEP_BEFORE_IMPORTING="Confirmation Step Before Importing!" COM_COMPONENTBUILDER_CONTEXT="Context" diff --git a/admin/models/admin_custom_tabs.php b/admin/models/admin_custom_tabs.php index 0a4eb6efb..7d409ed04 100644 --- a/admin/models/admin_custom_tabs.php +++ b/admin/models/admin_custom_tabs.php @@ -225,6 +225,9 @@ class ComponentbuilderModelAdmin_custom_tabs extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the tabs (sub form) layout + $form->setFieldAttribute('tabs', 'layout', ComponentbuilderHelper::getSubformLayout('admin_custom_tabs', 'tabs')); return $form; } diff --git a/admin/models/admin_fields.php b/admin/models/admin_fields.php index 821abede9..9b8950388 100644 --- a/admin/models/admin_fields.php +++ b/admin/models/admin_fields.php @@ -246,6 +246,9 @@ class ComponentbuilderModelAdmin_fields extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addfields (sub form) layout + $form->setFieldAttribute('addfields', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields', 'addfields')); return $form; } diff --git a/admin/models/admin_fields_conditions.php b/admin/models/admin_fields_conditions.php index 082d0a4ee..4888089d9 100644 --- a/admin/models/admin_fields_conditions.php +++ b/admin/models/admin_fields_conditions.php @@ -246,6 +246,9 @@ class ComponentbuilderModelAdmin_fields_conditions extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addconditions (sub form) layout + $form->setFieldAttribute('addconditions', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields_conditions', 'addconditions')); return $form; } diff --git a/admin/models/admin_fields_relations.php b/admin/models/admin_fields_relations.php index 8da06e303..b24caee98 100644 --- a/admin/models/admin_fields_relations.php +++ b/admin/models/admin_fields_relations.php @@ -308,6 +308,9 @@ class ComponentbuilderModelAdmin_fields_relations extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addrelations (sub form) layout + $form->setFieldAttribute('addrelations', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields_relations', 'addrelations')); return $form; } diff --git a/admin/models/component_admin_views.php b/admin/models/component_admin_views.php index dd831be06..f143c1c35 100644 --- a/admin/models/component_admin_views.php +++ b/admin/models/component_admin_views.php @@ -257,6 +257,9 @@ class ComponentbuilderModelComponent_admin_views extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addadmin_views (sub form) layout + $form->setFieldAttribute('addadmin_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_admin_views', 'addadmin_views')); return $form; } diff --git a/admin/models/component_custom_admin_views.php b/admin/models/component_custom_admin_views.php index 3a8c06f90..47f3bbda9 100644 --- a/admin/models/component_custom_admin_views.php +++ b/admin/models/component_custom_admin_views.php @@ -257,6 +257,9 @@ class ComponentbuilderModelComponent_custom_admin_views extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addcustom_admin_views (sub form) layout + $form->setFieldAttribute('addcustom_admin_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_custom_admin_views', 'addcustom_admin_views')); return $form; } diff --git a/admin/models/component_site_views.php b/admin/models/component_site_views.php index 78df71326..5640efaa6 100644 --- a/admin/models/component_site_views.php +++ b/admin/models/component_site_views.php @@ -257,6 +257,9 @@ class ComponentbuilderModelComponent_site_views extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } + + // update the addsite_views (sub form) layout + $form->setFieldAttribute('addsite_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_site_views', 'addsite_views')); return $form; } diff --git a/admin/models/dynamic_get.php b/admin/models/dynamic_get.php index a5589053e..0eb24b6da 100644 --- a/admin/models/dynamic_get.php +++ b/admin/models/dynamic_get.php @@ -525,7 +525,13 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin { $form->setValue('guid', null, ComponentbuilderHelper::GUID()); } + + // update the join_view_table (sub form) layout + $form->setFieldAttribute('join_view_table', 'layout', ComponentbuilderHelper::getSubformLayout('dynamic_get', 'join_view_table')); + + // update the join_db_table (sub form) layout + $form->setFieldAttribute('join_db_table', 'layout', ComponentbuilderHelper::getSubformLayout('dynamic_get', 'join_db_table')); return $form; } diff --git a/componentbuilder.xml b/componentbuilder.xml index bd08cb429..6cdfa2c07 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 11th July, 2020 + 13th July, 2020 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/script.php b/script.php index 021103f47..a235d2fb2 100644 --- a/script.php +++ b/script.php @@ -6591,7 +6591,7 @@ class com_componentbuilderInstallerScript $query = $db->getQuery(true); // Field to update. $fields = array( - $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","editor":"none","manage_jcb_package_directories":"2","add_menu_prefix":"1","menu_prefix":"»","minify":"0","set_browser_storage":"1","storage_time_to_live":"global","language":"en-GB","percentagelanguageadd":"50","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'), + $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","subform_layouts":"default","editor":"none","manage_jcb_package_directories":"2","add_menu_prefix":"1","menu_prefix":"»","minify":"0","set_browser_storage":"1","storage_time_to_live":"global","language":"en-GB","percentagelanguageadd":"50","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'), ); // Condition. $conditions = array( diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 30406c90c..0c37a5b6a 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -5861,6 +5861,47 @@ abstract class ComponentbuilderHelper return $d && $d->format($format) == $date; } + + /** + * The subform layouts + **/ + protected static $subformLayouts = false; + + /** + * get the subform layout + * + * @input string The view name + * @input string The string name + * + * @returns string on success + **/ + public static function getSubformLayout($view, $field, $default = 'repeatablejcb') + { + // get global values + if (self::$subformLayouts === false) + { + self::$subformLayouts = JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false); + } + // check what we found (else) return default + if (self::checkObject(self::$subformLayouts)) + { + // looking for + $target = $view . '.' . $field; + foreach (self::$subformLayouts as $subform) + { + if ($target === $subform->view_field) + { + return $subform->layout; + } + elseif ('default' === $subform->view_field) + { + $default = $subform->layout; + } + } + } + return $default; + } + /** * Load the Composer Vendors