From 54e4f96edf08be50408f76745aac05cec2e6d8a5 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 26 Oct 2020 22:30:51 +0200 Subject: [PATCH] Added the needed changes to the core compiler to manage dynamic headers per/controller via pro-member-plugin. gh-548 --- README.md | 2 +- admin/README.txt | 2 +- admin/compiler/joomla_3/JControllerAdmin.php | 2 +- .../JControllerAdmin_custom_admin.php | 2 +- admin/compiler/joomla_3/JControllerForm.php | 2 +- .../joomla_3/JControllerForm_custom_site.php | 2 +- .../joomla_3/JControllerForm_site.php | 2 +- .../JControllerLegacy_custom_admin.php | 2 +- admin/helpers/compiler/e_Interpretation.php | 16 +++--- admin/helpers/compiler/f_Infusion.php | 56 +++++++++++++++++++ componentbuilder.xml | 2 +- 11 files changed, 74 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 19ff4bbdb..afca3a6dc 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ 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*: 21st October, 2020 ++ *Last Build*: 26th October, 2020 + *Version*: 2.11.6 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/README.txt b/admin/README.txt index 19ff4bbdb..afca3a6dc 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -144,7 +144,7 @@ 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*: 21st October, 2020 ++ *Last Build*: 26th October, 2020 + *Version*: 2.11.6 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/compiler/joomla_3/JControllerAdmin.php b/admin/compiler/joomla_3/JControllerAdmin.php index 868d6561b..3234d7262 100644 --- a/admin/compiler/joomla_3/JControllerAdmin.php +++ b/admin/compiler/joomla_3/JControllerAdmin.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###ADMIN_VIEWS_CONTROLLER_HEADER### /** * ###Views### Controller diff --git a/admin/compiler/joomla_3/JControllerAdmin_custom_admin.php b/admin/compiler/joomla_3/JControllerAdmin_custom_admin.php index ab6775c93..84605cda6 100644 --- a/admin/compiler/joomla_3/JControllerAdmin_custom_admin.php +++ b/admin/compiler/joomla_3/JControllerAdmin_custom_admin.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER### /** * ###SViews### Controller diff --git a/admin/compiler/joomla_3/JControllerForm.php b/admin/compiler/joomla_3/JControllerForm.php index 1dca102af..f26fea732 100644 --- a/admin/compiler/joomla_3/JControllerForm.php +++ b/admin/compiler/joomla_3/JControllerForm.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###ADMIN_VIEW_CONTROLLER_HEADER### /** * ###View### Controller diff --git a/admin/compiler/joomla_3/JControllerForm_custom_site.php b/admin/compiler/joomla_3/JControllerForm_custom_site.php index ef0d3102a..5f6385bfb 100644 --- a/admin/compiler/joomla_3/JControllerForm_custom_site.php +++ b/admin/compiler/joomla_3/JControllerForm_custom_site.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###SITE_VIEW_CONTROLLER_HEADER### /** * ###Component### ###SView### Controller diff --git a/admin/compiler/joomla_3/JControllerForm_site.php b/admin/compiler/joomla_3/JControllerForm_site.php index 87686d985..946c418c4 100644 --- a/admin/compiler/joomla_3/JControllerForm_site.php +++ b/admin/compiler/joomla_3/JControllerForm_site.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###SITE_ADMIN_VIEW_CONTROLLER_HEADER### /** * ###View### Controller diff --git a/admin/compiler/joomla_3/JControllerLegacy_custom_admin.php b/admin/compiler/joomla_3/JControllerLegacy_custom_admin.php index b148b5c56..c82375ff2 100644 --- a/admin/compiler/joomla_3/JControllerLegacy_custom_admin.php +++ b/admin/compiler/joomla_3/JControllerLegacy_custom_admin.php @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Utilities\ArrayHelper; +###CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER### /** * ###Component### ###SView### Controller diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d87aa30fa..d5b22de90 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -20937,26 +20937,28 @@ class Interpretation extends Fields public function setClassHeaders($context, $viewName) { - // set the default + // set the defaults + $headers = array(); switch($context) { case 'admin.view.model': case 'site.admin.view.model': - $header = 'use Joomla\Registry\Registry;'; - $header .= PHP_EOL . 'use Joomla\String\StringHelper;'; - $header .= PHP_EOL . 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; break; default: - $header = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; break; } // Trigger Event: jcb_ce_setClassHeader $this->triggerEvent( 'jcb_ce_setClassHeader', array(&$this->componentContext, &$context, &$viewName, - &$header) + &$headers) ); - return $header; + // return the headers + return implode(PHP_EOL, $headers); } protected function setModelFieldRelation($item, $viewName_list, $tab) diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 10cde3f16..c2afe4063 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -614,6 +614,12 @@ class Infusion extends Interpretation $viewName_single, $view ); } + // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$viewName_single][$this->hhh + . 'SITE_ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'site.admin.view.controller', $viewName_single + ); // SITE_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$viewName_single][$this->hhh . 'SITE_ADMIN_VIEW_MODEL_HEADER' . $this->hhh] @@ -627,6 +633,12 @@ class Infusion extends Interpretation . 'TABLAYOUTFIELDSARRAY' . $this->hhh] = $this->getTabLayoutFieldsArray($viewName_single); + // ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$viewName_single][$this->hhh + . 'ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'admin.view.controller', $viewName_single + ); // ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$viewName_single][$this->hhh . 'ADMIN_VIEW_MODEL_HEADER' . $this->hhh] @@ -909,6 +921,12 @@ class Infusion extends Interpretation = ''; } + // ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$viewName_list][$this->hhh + . 'ADMIN_VIEWS_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'admin.views.controller', $viewName_list + ); // ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_VIEWS_MODEL_HEADER' . $this->hhh] @@ -1346,6 +1364,12 @@ class Infusion extends Interpretation // set headers based on the main get type if ($view['settings']->main_get->gettype == 1) { + // CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$view['settings']->code][$this->hhh + . 'CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'custom.admin.view.controller', $view['settings']->code + ); // CUSTOM_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'CUSTOM_ADMIN_VIEW_MODEL_HEADER' . $this->hhh] @@ -1355,6 +1379,12 @@ class Infusion extends Interpretation } elseif ($view['settings']->main_get->gettype == 2) { + // CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$view['settings']->code][$this->hhh + . 'CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'custom.admin.views.controller', $view['settings']->code + ); // CUSTOM_ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'CUSTOM_ADMIN_VIEWS_MODEL_HEADER' . $this->hhh] @@ -1797,6 +1827,19 @@ class Infusion extends Interpretation // set headers based on the main get type if ($view['settings']->main_get->gettype == 1) { + // insure the controller headers are added + if (ComponentbuilderHelper::checkString( + $view['settings']->php_controller + ) + && $view['settings']->php_controller != '//') + { + // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$view['settings']->code][$this->hhh + . 'SITE_VIEW_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'site.view.controller', $view['settings']->code + ); + } // SITE_VIEW_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_VIEW_MODEL_HEADER' . $this->hhh] @@ -1806,6 +1849,19 @@ class Infusion extends Interpretation } elseif ($view['settings']->main_get->gettype == 2) { + // insure the controller headers are added + if (ComponentbuilderHelper::checkString( + $view['settings']->php_controller + ) + && $view['settings']->php_controller != '//') + { + // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + $this->fileContentDynamic[$view['settings']->code][$this->hhh + . 'SITE_VIEW_CONTROLLER_HEADER' . $this->hhh] + = $this->setClassHeaders( + 'site.views.controller', $view['settings']->code + ); + } // SITE_VIEWS_MODEL_HEADER <<>> add the header details for the model $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_VIEWS_MODEL_HEADER' . $this->hhh] diff --git a/componentbuilder.xml b/componentbuilder.xml index f15845e71..be2ba9686 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 21st October, 2020 + 26th October, 2020 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com