From 2ce36117d470eaa18d4e56aa4f17bef2ba365c46 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Fri, 4 Feb 2022 12:50:24 +0200 Subject: [PATCH] Adds option to add more field paths or rule paths to both module or plugin forms. --- README.md | 6 +- admin/README.txt | 6 +- admin/helpers/compiler/a_Get.php | 52 +++++++++ admin/helpers/compiler/e_Interpretation.php | 109 +++++++++++++----- .../en-GB/en-GB.com_componentbuilder.ini | 12 ++ admin/models/forms/joomla_module.xml | 54 +++++++++ admin/models/forms/joomla_plugin.xml | 54 +++++++++ componentbuilder.xml | 2 +- 8 files changed, 259 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b7f8e89b1..641e5097e 100644 --- a/README.md +++ b/README.md @@ -143,12 +143,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*: 2nd February, 2022 ++ *Last Build*: 4th February, 2022 + *Version*: 2.12.15 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **286129** -+ *Field count*: **1572** ++ *Line count*: **286249** ++ *Field count*: **1580** + *File count*: **1829** + *Folder count*: **256** diff --git a/admin/README.txt b/admin/README.txt index b7f8e89b1..641e5097e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -143,12 +143,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*: 2nd February, 2022 ++ *Last Build*: 4th February, 2022 + *Version*: 2.12.15 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **286129** -+ *Field count*: **1572** ++ *Line count*: **286249** ++ *Field count*: **1580** + *File count*: **1829** + *Folder count*: **256** diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index da9328e2d..487f5267b 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -9389,6 +9389,8 @@ class Get $module->form_files = array(); $module->fieldsets_label = array(); $module->fieldsets_paths = array(); + $module->add_rule_path = array(); + $module->add_field_path = array(); // set global fields rule to default component path $module->fields_rules_paths = 1; // set the fields data @@ -9463,6 +9465,30 @@ class Get // set where to path is pointing $module->fieldsets_paths[$unique] = $form['fields_rules_paths']; + // check for extra rule paths + if (isset($form['addrulepath']) + && ComponentbuilderHelper::checkArray($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (ComponentbuilderHelper::checkString($add_rule_path['path'])) + { + $module->add_rule_path[$unique][] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ComponentbuilderHelper::checkArray($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (ComponentbuilderHelper::checkString($add_field_path['path'])) + { + $module->add_field_path[$unique][] = $add_field_path['path']; + } + } + } // add the label if set to lang if (isset($form['label']) && ComponentbuilderHelper::checkString( @@ -10297,6 +10323,8 @@ class Get $plugin->form_files = array(); $plugin->fieldsets_label = array(); $plugin->fieldsets_paths = array(); + $plugin->add_rule_path = array(); + $plugin->add_field_path = array(); // set global fields rule to default component path $plugin->fields_rules_paths = 1; // set the fields data @@ -10380,6 +10408,30 @@ class Get $plugin->fieldsets_label[$unique] = $this->setLang($form['label']); } + // check for extra rule paths + if (isset($form['addrulepath']) + && ComponentbuilderHelper::checkArray($form['addrulepath'])) + { + foreach ($form['addrulepath'] as $add_rule_path) + { + if (ComponentbuilderHelper::checkString($add_rule_path['path'])) + { + $plugin->add_rule_path[$unique][] = $add_rule_path['path']; + } + } + } + // check for extra field paths + if (isset($form['addfieldpath']) + && ComponentbuilderHelper::checkArray($form['addfieldpath'])) + { + foreach ($form['addfieldpath'] as $add_field_path) + { + if (ComponentbuilderHelper::checkString($add_field_path['path'])) + { + $plugin->add_field_path[$unique][] = $add_field_path['path']; + } + } + } // build the fields $form['fields'] = array_map( function ($field) use ($key, $unique) { diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index b879cebe8..646d2816c 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -28572,31 +28572,57 @@ function vdm_dkim() { && $module->fieldsets_paths[$field_name . $fieldset] == 2) { - $xml .= PHP_EOL . $this->_t(1) . ''; - $xml .= PHP_EOL . $this->_t(1) . '
target == 2) { - $xml .= PHP_EOL . $this->_t(2) - . 'addrulepath="/administrator/modules/' - . $module->file_name - . '/rules"'; - $xml .= PHP_EOL . $this->_t(2) - . 'addfieldpath="/administrator/modules/' - . $module->file_name - . '/fields"'; + $module->add_rule_path[$field_name . $fieldset][] = + '/administrator/modules/' + . $module->file_name . '/rules'; + + $module->add_field_path[$field_name . $fieldset][] = + '/administrator/modules/' + . $module->file_name . '/fields'; } else { - $xml .= PHP_EOL . $this->_t(2) - . 'addrulepath="/modules/' . $module->file_name - . '/rules"'; - $xml .= PHP_EOL . $this->_t(2) - . 'addfieldpath="/modules/' . $module->file_name - . '/fields"'; + $module->add_rule_path[$field_name . $fieldset][] = + '/modules/' . $module->file_name + . '/rules'; + + $module->add_field_path[$field_name . $fieldset][] = + '/modules/' . $module->file_name + . '/fields'; } + } + // add path to module rules and custom fields + if (isset($module->add_rule_path[$field_name . $fieldset]) + || isset($module->add_field_path[$field_name . $fieldset])) + { + + $xml .= PHP_EOL . $this->_t(1) . ''; + + $xml .= PHP_EOL . $this->_t(1) . '
add_rule_path[$field_name . $fieldset])) + { + foreach ($module->add_rule_path[$field_name . $fieldset] as $path) + { + $xml .= PHP_EOL . $this->_t(2) + . 'addrulepath="' . $path . '"'; + } + } + + if (isset($module->add_field_path[$field_name . $fieldset])) + { + foreach ($module->add_field_path[$field_name . $fieldset] as $path) + { + $xml .= PHP_EOL . $this->_t(2) + . 'addfieldpath="' . $path . '"'; + } + } + $xml .= PHP_EOL . $this->_t(1) . '>'; } else @@ -28931,26 +28957,51 @@ function vdm_dkim() { $label = $plugin->fieldsets_label[$field_name . $fieldset]; } + // add path to plugin rules and custom fields if (isset($plugin->fieldsets_paths[$field_name . $fieldset]) && $plugin->fieldsets_paths[$field_name . $fieldset] == 2) + { + $plugin->add_rule_path[$field_name . $fieldset][] = + '/plugins/' . strtolower($plugin->group + ) . '/' . strtolower($plugin->code_name) + . '/rules'; + + $plugin->add_field_path[$field_name . $fieldset][] = + '/plugins/' . strtolower($plugin->group + ) . '/' . strtolower($plugin->code_name) + . '/fields'; + } + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$field_name . $fieldset]) + || isset($plugin->add_field_path[$field_name . $fieldset])) { $xml .= PHP_EOL . $this->_t(1) . ''; + $xml .= PHP_EOL . $this->_t(1) . '
_t(2) - . 'addrulepath="/plugins/' . strtolower( - $plugin->group - ) . '/' . strtolower($plugin->code_name) - . '/rules"'; - $xml .= PHP_EOL . $this->_t(2) - . 'addfieldpath="/plugins/' . strtolower( - $plugin->group - ) . '/' . strtolower($plugin->code_name) - . '/fields"'; + + if (isset($plugin->add_rule_path[$field_name . $fieldset])) + { + foreach ($plugin->add_rule_path[$field_name . $fieldset] as $path) + { + $xml .= PHP_EOL . $this->_t(2) + . 'addrulepath="' . $path . '"'; + } + } + + if (isset($plugin->add_field_path[$field_name . $fieldset])) + { + foreach ($plugin->add_field_path[$field_name . $fieldset] as $path) + { + $xml .= PHP_EOL . $this->_t(2) + . 'addfieldpath="' . $path . '"'; + } + } + $xml .= PHP_EOL . $this->_t(1) . '>'; } else diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 40b556b65..edf9bec16 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -6237,7 +6237,11 @@ COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_UNFEATURED_1="%s Joomla Modu COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_UNPUBLISHED="%s Joomla Modules Updates unpublished." COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_UNPUBLISHED_1="%s Joomla Module Updates unpublished." COM_COMPONENTBUILDER_JOOMLA_MODULE_ABSTRACT_CLASS="abstract class" +COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDFIELDPATH_DESCRIPTION="Set extra field paths" +COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDFIELDPATH_LABEL="Extra Field Paths" COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDREADME_LABEL="Add README" +COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDRULEPATH_DESCRIPTION="Set extra rule paths" +COM_COMPONENTBUILDER_JOOMLA_MODULE_ADDRULEPATH_LABEL="Extra Rule Paths" COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_CLASS_HELPER_DESCRIPTION="You can add a helper class to your module." COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_CLASS_HELPER_HEADER_DESCRIPTION="You can add your own custom helper header script." COM_COMPONENTBUILDER_JOOMLA_MODULE_ADD_CLASS_HELPER_HEADER_LABEL="Add Class Helper Header" @@ -6462,6 +6466,8 @@ COM_COMPONENTBUILDER_JOOMLA_MODULE_NOTE_UPDATE_SERVER_NOTE_ZIP_LABEL="The ZIP Op COM_COMPONENTBUILDER_JOOMLA_MODULE_NOT_REQUIRED="Not Required" COM_COMPONENTBUILDER_JOOMLA_MODULE_ORDERING_LABEL="Ordering" COM_COMPONENTBUILDER_JOOMLA_MODULE_OTHER="Other" +COM_COMPONENTBUILDER_JOOMLA_MODULE_PATH_LABEL="Path" +COM_COMPONENTBUILDER_JOOMLA_MODULE_PATH_MESSAGE="Error! Please add extra field path here." COM_COMPONENTBUILDER_JOOMLA_MODULE_PERMISSION="Permissions" COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_METHOD_UNINSTALL_DESCRIPTION="PHP script that should run during uninstall." COM_COMPONENTBUILDER_JOOMLA_MODULE_PHP_METHOD_UNINSTALL_LABEL="PHP Method (uninstall)" @@ -6680,7 +6686,11 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_UNFEATURED="%s Joomla Plugin COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_UNFEATURED_1="%s Joomla Plugin Updates unfeatured." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_UNPUBLISHED="%s Joomla Plugins Updates unpublished." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_UNPUBLISHED_1="%s Joomla Plugin Updates unpublished." +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDFIELDPATH_DESCRIPTION="Set extra field paths" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDFIELDPATH_LABEL="Extra Field Paths" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDREADME_LABEL="Add README" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDRULEPATH_DESCRIPTION="Set extra rule paths" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADDRULEPATH_LABEL="Extra Rule Paths" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_HEAD_DESCRIPTION="You can add your own custom header script, combined with the default header script that make the extended class work." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_HEAD_LABEL="Add Custom Class Header" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_PHP_METHOD_UNINSTALL_LABEL="Add PHP Method (uninstall)" @@ -6935,6 +6945,8 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NOTE_UPDATE_SERVER_NOTE_ZIP_LABEL="The ZIP Op COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NOT_REQUIRED="Not Required" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ORDERING_LABEL="Ordering" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_OTHER="Other" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PATH_LABEL="Path" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PATH_MESSAGE="Error! Please add extra field path here." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PERMISSION="Permissions" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_METHOD_UNINSTALL_DESCRIPTION="PHP script that should run during uninstall." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_METHOD_UNINSTALL_LABEL="PHP Method (uninstall)" diff --git a/admin/models/forms/joomla_module.xml b/admin/models/forms/joomla_module.xml index 160b6db62..012447170 100644 --- a/admin/models/forms/joomla_module.xml +++ b/admin/models/forms/joomla_module.xml @@ -688,6 +688,60 @@ /> + + + + + + diff --git a/admin/models/forms/joomla_plugin.xml b/admin/models/forms/joomla_plugin.xml index 725a494d4..43893074e 100644 --- a/admin/models/forms/joomla_plugin.xml +++ b/admin/models/forms/joomla_plugin.xml @@ -567,6 +567,60 @@ /> + + + + + + diff --git a/componentbuilder.xml b/componentbuilder.xml index fd6c9fc35..53e07a584 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 2nd February, 2022 + 4th February, 2022 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com