From 4a32d3d50e64bae28c49b6eaa2f5fb7036479389 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 3 Sep 2022 12:48:53 +0200 Subject: [PATCH] Adds interfaces to many classes. --- README.md | 8 +- admin/README.txt | 8 +- admin/helpers/compiler.php | 4 +- admin/helpers/compiler/a_Get.php | 104 +++++++++--------- admin/helpers/compiler/c_Fields.php | 4 +- componentbuilder.xml | 2 +- .../Compiler/Component/Placeholder.php | 5 +- .../Componentbuilder/Compiler/Customcode.php | 40 +++---- .../Compiler/Customcode/Dispenser.php | 7 +- .../Compiler/Customcode/External.php | 3 +- .../Compiler/Customcode/Extractor.php | 3 +- .../Compiler/Customcode/Extractor/Paths.php | 4 +- .../Compiler/Customcode/Gui.php | 3 +- .../Compiler/Customcode/Hash.php | 2 +- .../Compiler/Customcode/LockBase.php | 3 +- .../Extension/JoomlaThree/InstallScript.php | 2 +- .../Component/PlaceholderInterface.php | 29 +++++ .../Compiler/Interfaces/Component/index.html | 1 + .../Customcode/DispenserInterface.php | 60 ++++++++++ .../Customcode/ExternalInterface.php | 31 ++++++ .../Customcode/ExtractorInterface.php | 28 +++++ .../Interfaces/Customcode/GuiInterface.php | 44 ++++++++ .../Customcode/LockBaseInterface.php | 30 +++++ .../Compiler/Interfaces/Customcode/index.html | 1 + .../Interfaces/CustomcodeInterface.php | 59 ++++++++++ .../{ => Extension}/InstallInterface.php | 2 +- .../Compiler/Interfaces/Extension/index.html | 1 + .../Compiler/Interfaces/LanguageInterface.php | 89 +++++++++++++++ .../Interfaces/PlaceholderInterface.php | 72 ++++++++++++ .../Compiler/Interfaces/PowerInterface.php | 43 ++++++++ .../Componentbuilder/Compiler/Language.php | 3 +- .../Componentbuilder/Compiler/Placeholder.php | 26 +---- .../src/Componentbuilder/Compiler/Power.php | 15 +-- .../Compiler/Service/Customcode.php | 5 +- 34 files changed, 613 insertions(+), 128 deletions(-) create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/PlaceholderInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/DispenserInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExternalInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExtractorInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/GuiInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/LockBaseInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/CustomcodeInterface.php rename libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/{ => Extension}/InstallInterface.php (90%) create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/LanguageInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PlaceholderInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PowerInterface.php diff --git a/README.md b/README.md index c881984d4..79fdd2705 100644 --- a/README.md +++ b/README.md @@ -140,14 +140,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 2nd September, 2022 ++ *Last Build*: 3rd September, 2022 + *Version*: 3.1.5 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **321348** ++ *Line count*: **321830** + *Field count*: **2002** -+ *File count*: **2094** -+ *Folder count*: **360** ++ *File count*: **2107** ++ *Folder count*: **363** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/README.txt b/admin/README.txt index c881984d4..79fdd2705 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -140,14 +140,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 2nd September, 2022 ++ *Last Build*: 3rd September, 2022 + *Version*: 3.1.5 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **321348** ++ *Line count*: **321830** + *Field count*: **2002** -+ *File count*: **2094** -+ *Folder count*: **360** ++ *File count*: **2107** ++ *Folder count*: **363** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php index 9a37ffa38..629b6c044 100644 --- a/admin/helpers/compiler.php +++ b/admin/helpers/compiler.php @@ -138,7 +138,7 @@ class Compiler extends Infusion array(&$this->componentContext, &$this) ); // now insert into the new files - if (CFactory::_('Customcode')->load()) + if (CFactory::_('Customcode')->get()) { // Trigger Event: jcb_ce_onBeforeAddCustomCode CFactory::_J('Event')->trigger( @@ -667,7 +667,7 @@ class Compiler extends Infusion // check if this file needs extra care :) if (isset($this->updateFileContent[$path])) { - $answer = CFactory::_('Customcode')->add($answer); + $answer = CFactory::_('Customcode')->update($answer); } // Trigger Event: jcb_ce_onBeforeSetFileContent CFactory::_J('Event')->trigger( diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 037d28d42..a19c91efb 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -1931,7 +1931,7 @@ class Get // README if ($component->addreadme) { - $component->readme = CFactory::_('Customcode')->add( + $component->readme = CFactory::_('Customcode')->update( base64_decode($component->readme) ); } @@ -1951,7 +1951,7 @@ class Get { $component->dashboard_tab = array_map( function ($array) { - $array['html'] = CFactory::_('Customcode')->add($array['html']); + $array['html'] = CFactory::_('Customcode')->update($array['html']); return $array; }, array_values($component->dashboard_tab) @@ -1969,7 +1969,7 @@ class Get { // load the php for the dashboard model $component->php_dashboard_methods = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($component->php_dashboard_methods) ), array( @@ -2336,7 +2336,7 @@ class Get $tab['view'] = $view->name_single_code; // load the dynamic data $tab['html'] = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($tab['html']), + CFactory::_('Customcode')->update($tab['html']), CFactory::_('Placeholder')->active ); // set the tab name @@ -2609,7 +2609,7 @@ class Get $tmpfield['settings'] = new stdClass(); // convert the xml json string to normal string $tmpfield['settings']->xml - = CFactory::_('Customcode')->add( + = CFactory::_('Customcode')->update( json_decode( $field['settings']->history->xml ) @@ -2841,7 +2841,7 @@ class Get $relationsValue['set'] )) { - $relationsValue['set'] = CFactory::_('Customcode')->add( + $relationsValue['set'] = CFactory::_('Customcode')->update( $relationsValue['set'] ); } @@ -3045,7 +3045,7 @@ class Get $guiMapper['field'] = $button_code_field; $view->{$button_code_field} = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($view->{$button_code_field}) ), $guiMapper @@ -3370,7 +3370,7 @@ class Get // set the default data $view->default = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add(base64_decode($view->default)), + CFactory::_('Customcode')->update(base64_decode($view->default)), $guiMapper ); // load context if not set @@ -3491,7 +3491,7 @@ class Get // set field $guiMapper['field'] = $scripter; $view->$scripter = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($view->$scripter) ), $guiMapper @@ -3499,7 +3499,7 @@ class Get } else { - $view->$scripter = CFactory::_('Customcode')->add( + $view->$scripter = CFactory::_('Customcode')->update( base64_decode($view->$scripter) ); } @@ -3631,7 +3631,7 @@ class Get // set field $guiMapper['field'] = $button_code_field; $view->{$button_code_field} = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($view->{$button_code_field}) ), $guiMapper @@ -3735,7 +3735,7 @@ class Get ); // load the values form params - $field->xml = CFactory::_('Customcode')->add(json_decode($field->xml)); + $field->xml = CFactory::_('Customcode')->update(json_decode($field->xml)); // check if we have validate (validation rule set) $validationRule = GetHelper::between( @@ -3774,7 +3774,7 @@ class Get $this->validationRules[$validationRule] = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $this->validationRules[$validationRule] ) @@ -3853,7 +3853,7 @@ class Get ); $field->initiator_save = explode( PHP_EOL, CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $field->initiator_on_save_model ) @@ -3870,7 +3870,7 @@ class Get ); $field->initiator_get = explode( PHP_EOL, CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $field->initiator_on_get_model ) @@ -3881,14 +3881,14 @@ class Get // set the field modeling $field->model_field['save'] = explode( PHP_EOL, CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($field->on_save_model_field) ), CFactory::_('Placeholder')->active ) ); $field->model_field['get'] = explode( PHP_EOL, CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($field->on_get_model_field) ), CFactory::_('Placeholder')->active ) @@ -4618,7 +4618,7 @@ class Get $guiMapper['field'] = 'php_calculation'; $result->php_calculation = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($result->php_calculation) ), $guiMapper @@ -4636,7 +4636,7 @@ class Get $guiMapper['field'] = 'php_router_parse'; $result->php_router_parse = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($result->php_router_parse) ), $guiMapper @@ -4692,7 +4692,7 @@ class Get // only for custom gets $result->{$script} = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($result->{$script}) ), $guiMapper @@ -4761,7 +4761,7 @@ class Get // get the custom query $customQueryString = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($result->php_custom_get) ), $guiMapper @@ -5029,7 +5029,7 @@ class Get = $operatorArray[$option2['operator']]; $option2['state_key'] = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( $option2['state_key'] ), CFactory::_('Placeholder')->active ); @@ -5844,7 +5844,7 @@ class Get && StringHelper::check($row->php_view)) { $php_view = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add(base64_decode($row->php_view)), + CFactory::_('Customcode')->update(base64_decode($row->php_view)), array( 'table' => $table, 'field' => 'php_view', @@ -5853,7 +5853,7 @@ class Get ); } $contnent = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add(base64_decode($row->{$table})), + CFactory::_('Customcode')->update(base64_decode($row->{$table})), array( 'table' => $table, 'field' => $table, @@ -6231,7 +6231,7 @@ class Get )) { $library->document = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($library->php_setdocument) ), array( @@ -6873,11 +6873,11 @@ class Get * dynamic build values if it gets broken * * @return string - * @deprecated 3.3 Use CFactory::_('Customcode')->add($string, $debug); + * @deprecated 3.3 Use CFactory::_('Customcode')->update($string, $debug); */ public function setDynamicValues($string, $debug = 0) { - return CFactory::_('Customcode')->add($string, $debug); + return CFactory::_('Customcode')->update($string, $debug); } /** @@ -7564,11 +7564,11 @@ class Get * @param int $debug The switch to debug the update * * @return void - * @deprecated 3.3 Use CFactory::_('Customcode')->load($ids, $setLang, $debug); + * @deprecated 3.3 Use CFactory::_('Customcode')->get($ids, $setLang, $debug); */ public function getCustomCode(?array $ids = null, bool $setLang = true, int $debug = 0) { - CFactory::_('Customcode')->load($ids, $setLang, $debug); + CFactory::_('Customcode')->get($ids, $setLang, $debug); } /** @@ -7766,7 +7766,7 @@ class Get 'id' => (int) $id, 'type' => 'php'); // update the name if it has dynamic values $module->name = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($module->name), CFactory::_('Placeholder')->active + CFactory::_('Customcode')->update($module->name), CFactory::_('Placeholder')->active ); // set safe class function name $module->code_name @@ -7835,7 +7835,7 @@ class Get else { $module->description = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($module->description), + CFactory::_('Customcode')->update($module->description), CFactory::_('Placeholder')->active ); CFactory::_('Language')->set( @@ -7864,7 +7864,7 @@ class Get if ($module->addreadme == 1 && !empty($module->readme)) { $module->readme = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add(base64_decode($module->readme)), + CFactory::_('Customcode')->update(base64_decode($module->readme)), CFactory::_('Placeholder')->active ); } @@ -7904,7 +7904,7 @@ class Get $module->class_helper_header = PHP_EOL . CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $module->class_helper_header ) @@ -7923,7 +7923,7 @@ class Get // base64 Decode code $module->class_helper_code = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($module->class_helper_code) ), CFactory::_('Placeholder')->active ), @@ -7953,7 +7953,7 @@ class Get $guiMapper['field'] = 'mod_code'; $module->mod_code = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($module->mod_code) ), CFactory::_('Placeholder')->active ), @@ -7981,7 +7981,7 @@ class Get $guiMapper['field'] = 'default_header'; $module->default_header = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($module->default_header) ), CFactory::_('Placeholder')->active ), @@ -8001,7 +8001,7 @@ class Get $guiMapper['type'] = 'html'; $module->default = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($module->default) ), CFactory::_('Placeholder')->active ), @@ -8348,7 +8348,7 @@ class Get $module->{$scriptMethod . '_' . $scriptType} = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $module->{$scriptMethod . '_' . $scriptType} @@ -8373,7 +8373,7 @@ class Get && StringHelper::check($module->sql)) { $module->sql = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add(base64_decode($module->sql)), + CFactory::_('Customcode')->update(base64_decode($module->sql)), CFactory::_('Placeholder')->active ); } @@ -8389,7 +8389,7 @@ class Get )) { $module->sql_uninstall = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($module->sql_uninstall) ), CFactory::_('Placeholder')->active ); @@ -8406,7 +8406,7 @@ class Get )) { $module->update_server_url = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($module->update_server_url), + CFactory::_('Customcode')->update($module->update_server_url), CFactory::_('Placeholder')->active ); } @@ -8683,7 +8683,7 @@ class Get 'id' => (int) $id, 'type' => 'php'); // update the name if it has dynamic values $plugin->name = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($plugin->name), CFactory::_('Placeholder')->active + CFactory::_('Customcode')->update($plugin->name), CFactory::_('Placeholder')->active ); // update the name if it has dynamic values $plugin->code_name @@ -8775,7 +8775,7 @@ class Get else { $plugin->description = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($plugin->description), + CFactory::_('Customcode')->update($plugin->description), CFactory::_('Placeholder')->active ); CFactory::_('Language')->set( @@ -8807,7 +8807,7 @@ class Get if ($plugin->addreadme == 1 && !empty($plugin->readme)) { $plugin->readme = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add(base64_decode($plugin->readme)), + CFactory::_('Customcode')->update(base64_decode($plugin->readme)), CFactory::_('Placeholder')->active ); } @@ -8824,7 +8824,7 @@ class Get // base64 Decode main_class_code. $plugin->main_class_code = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($plugin->main_class_code) ), CFactory::_('Placeholder')->active ), @@ -8839,7 +8839,7 @@ class Get // base64 Decode head. $plugin->head = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($plugin->head) ), CFactory::_('Placeholder')->active ), @@ -8851,7 +8851,7 @@ class Get // base64 Decode head. $plugin->head = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($plugin->class_head) ), CFactory::_('Placeholder')->active ), @@ -8869,7 +8869,7 @@ class Get // base64 Decode comment. $plugin->comment = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($plugin->comment) ), CFactory::_('Placeholder')->active ), @@ -9175,7 +9175,7 @@ class Get $plugin->{$scriptMethod . '_' . $scriptType} = CFactory::_('Customcode.Gui')->set( CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode( $plugin->{$scriptMethod . '_' . $scriptType} @@ -9200,7 +9200,7 @@ class Get && StringHelper::check($plugin->sql)) { $plugin->sql = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add(base64_decode($plugin->sql)), + CFactory::_('Customcode')->update(base64_decode($plugin->sql)), CFactory::_('Placeholder')->active ); } @@ -9216,7 +9216,7 @@ class Get )) { $plugin->sql_uninstall = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add( + CFactory::_('Customcode')->update( base64_decode($plugin->sql_uninstall) ), CFactory::_('Placeholder')->active ); @@ -9233,7 +9233,7 @@ class Get )) { $plugin->update_server_url = CFactory::_('Placeholder')->update( - CFactory::_('Customcode')->add($plugin->update_server_url), + CFactory::_('Customcode')->update($plugin->update_server_url), CFactory::_('Placeholder')->active ); } diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index a657d6ac7..9fe5377e4 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -4210,7 +4210,7 @@ class Fields extends Structure ); // load the php for the custom field file $fieldAttributes['custom'][$phpKey][$phpLine] - = CFactory::_('Customcode')->add( + = CFactory::_('Customcode')->update( ComponentbuilderHelper::openValidBase64( GetHelper::between( $field['settings']->xml, @@ -4504,7 +4504,7 @@ class Fields extends Structure )) !== $confirmation) { $fieldAttributes['custom'][$phpKey][$phpLine] - = CFactory::_('Customcode')->add( + = CFactory::_('Customcode')->update( ComponentbuilderHelper::openValidBase64($value) ); } diff --git a/componentbuilder.xml b/componentbuilder.xml index 6cc82960a..e86cbba2a 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 2nd September, 2022 + 3rd September, 2022 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php index f0c1320eb..7cd6a1281 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php @@ -20,6 +20,7 @@ use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\PlaceholderInterface; /** @@ -27,12 +28,12 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; * * @since 3.2.0 */ -class Placeholder +class Placeholder implements PlaceholderInterface { /** * Placeholders * - * @var arraya + * @var array * @since 3.2.0 **/ protected $placeholders = null; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php index 9777f1bac..921623952 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php @@ -22,6 +22,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor; use VDM\Joomla\Componentbuilder\Compiler\Customcode\External; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface; /** @@ -29,7 +30,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; * * @since 3.2.0 */ -class Customcode +class Customcode implements CustomcodeInterface { /** * The function name memory ids @@ -122,7 +123,7 @@ class Customcode * * @param Config|null $config The compiler config object. * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Extract|null $extractor The compiler language extractor object. + * @param Extractor|null $extractor The compiler language extractor object. * @param External|null $external The compiler external custom code object. * @param \JDatabaseDriver $db The Database Driver object. * @@ -139,7 +140,7 @@ class Customcode } /** - * Set the **ALL** dynamic values in a strings here + * Update **ALL** dynamic values in a strings here * * @param string $string The content to check * @param int $debug The switch to debug the update @@ -149,7 +150,7 @@ class Customcode * @return string * @since 3.2.0 */ - public function add(string $string, int $debug = 0): string + public function update(string $string, int $debug = 0): string { if (StringHelper::check($string)) { @@ -169,7 +170,7 @@ class Customcode } /** - * We start set the custom code data & can load it in to string + * Set the custom code data & can load it in to string * * @param string $string The content to check * @param int $debug The switch to debug the update @@ -212,9 +213,7 @@ class Customcode $id = (int) $key; } elseif (StringHelper::check($key) - && strpos( - $key, '+' - ) === false) + && strpos($key, '+') === false) { $getFuncName = trim($key); if (!isset($this->functionNameMemory[$getFuncName])) @@ -276,7 +275,7 @@ class Customcode { if (strpos($array[1], ',') !== false) { - // update the function values with the custom code key placholdres (this allow the use of [] + and , in the values) + // update the function values with the custom code key placeholders (this allow the use of [] + and , in the values) $this->data[$id]['args'][$key] = array_map( function ($_key) { @@ -328,7 +327,7 @@ class Customcode // insure we add the langs to both site and admin $this->config->lang_target = 'both'; // now load the code to memory - $loaded = $this->load($bucket, false, $debug); + $loaded = $this->get($bucket, false, $debug); // revert lang to current setting $this->config->lang_target = $_tmpLang; } @@ -364,7 +363,7 @@ class Customcode * @return bool * @since 3.2.0 */ - public function load(?array $ids = null, bool $setLang = true, $debug = 0): bool + public function get(?array $ids = null, bool $setLang = true, $debug = 0): bool { // should the result be stored in memory $loadInMemory = false; @@ -375,7 +374,7 @@ class Customcode ); if (ArrayHelper::check($ids)) { - if ($idArray = $this->check($ids)) + if (($idArray = $this->check($ids)) !== false) { $query->select( $this->db->quoteName( @@ -434,7 +433,8 @@ class Customcode $customCode['code'] = $this->external->set( $customCode['code'] ); - // set the lang only if needed + + // set the lang only if needed (we do the other later when we add it to the correct position) if ($setLang) { $customCode['code'] = $this->extractor->engine( @@ -448,6 +448,7 @@ class Customcode $customCode['code'], $debug, $nr ); } + // build the hash array if (isset($customCode['hashtarget'])) { @@ -456,20 +457,18 @@ class Customcode ); // is this a replace code, set end has array if ($customCode['type'] == 1 - && strpos( - $customCode['hashendtarget'], '__' - ) !== false) + && strpos($customCode['hashendtarget'], '__') !== false) { $customCode['hashendtarget'] = explode( "__", $customCode['hashendtarget'] ); + // NOW see if this is an end of page target (TODO not sure if the string is always d41d8cd98f00b204e9800998ecf8427e) // I know this fix is not air-tight, but it should work as the value of an empty line when md5'ed is ^^^^ // Then if the line number is only >>>one<<< it is almost always end of the page. // So I am using those two values to detect end of page replace ending, to avoid mismatching the ending target hash. if ($customCode['hashendtarget'][0] == 1 - && 'd41d8cd98f00b204e9800998ecf8427e' - === $customCode['hashendtarget'][1]) + && 'd41d8cd98f00b204e9800998ecf8427e' === $customCode['hashendtarget'][1]) { // unset since this will force the replacement unto end of page. unset($customCode['hashendtarget']); @@ -477,11 +476,14 @@ class Customcode } } } + // load this code into memory if needed if ($loadInMemory === true) { $this->memory = $this->memory + $bucket; } + + // add to active set $this->active = array_merge($this->active, $bucket); return true; @@ -500,7 +502,7 @@ class Customcode * @return string on success * @since 3.2.0 */ - protected function insert(array $ids, string $string, int $debug = 0) + protected function insert(array $ids, string $string, int $debug = 0): string { $code = array(); // load the code diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php index 37ca79134..4ec8c922b 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php @@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash; use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\DispenserInterface; /** @@ -26,7 +27,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase; * * @since 3.2.0 */ -class Dispenser +class Dispenser implements DispenserInterface { /** * Customcode Dispenser Hub @@ -159,7 +160,7 @@ class Dispenser // prep the script string if ($base64 && $dynamic) { - $script = $this->customcode->add(base64_decode($script)); + $script = $this->customcode->update(base64_decode($script)); } elseif ($base64) { @@ -167,7 +168,7 @@ class Dispenser } elseif ($dynamic) // this does not happen (just incase) { - $script = $this->customcode->add($script); + $script = $this->customcode->update($script); } // check if we still have a string if (StringHelper::check($script)) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php index 685c0baba..379a211cb 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php @@ -23,6 +23,7 @@ use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Utilities\FileHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExternalInterface; /** @@ -30,7 +31,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder; * * @since 3.2.0 */ -class External +class External implements ExternalInterface { /** * The external code/string to be added diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php index 3acc797f7..05c351baa 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php @@ -27,6 +27,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse; use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Path; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExtractorInterface; /** @@ -66,7 +67,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Path; * * @since 3.2.0 */ -class Extractor +class Extractor implements ExtractorInterface { /** * The placeholder keys diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php index 526e26399..f29c87fa9 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php @@ -273,7 +273,7 @@ class Paths $module = $this->db->loadObject(); // update the name if it has dynamic values $module->name = $this->placeholder->update( - $this->customcode->add($module->name), + $this->customcode->update($module->name), $this->componentPlaceholder ); @@ -397,7 +397,7 @@ class Paths // update the name if it has dynamic values $plugin->name = $this->placeholder->update( - $this->customcode->add($plugin->name), + $this->customcode->update($plugin->name), $this->componentPlaceholder ); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php index 808aabcdb..f0b69745c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php @@ -23,6 +23,7 @@ use VDM\Joomla\Utilities\String\FieldHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\GuiInterface; /** @@ -30,7 +31,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse; * * @since 3.2.0 */ -class Gui +class Gui implements GuiInterface { /** * Compiler Config diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Hash.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Hash.php index bca67e38d..b5cc8724d 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Hash.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Hash.php @@ -46,7 +46,7 @@ class Hash } /** - * Set the the MD5 hashed string or file or string + * Set the MD5 hashed string or file or string * * @param string $script The code string * diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/LockBase.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/LockBase.php index d7243967e..19d638af5 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/LockBase.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/LockBase.php @@ -16,6 +16,7 @@ use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\LockBaseInterface; /** @@ -23,7 +24,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder; * * @since 3.2.0 */ -class LockBase +class LockBase implements LockBaseInterface { /** * Compiler Placeholder diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php index f2a3843f3..73aa0f81a 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\InstallInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/PlaceholderInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/PlaceholderInterface.php new file mode 100644 index 000000000..ccb1c3d8d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/PlaceholderInterface.php @@ -0,0 +1,29 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component; + + +/** + * Component Placeholder Interface + */ +interface PlaceholderInterface +{ + /** + * get all System Placeholders + * + * @return array The global placeholders + * + * @since 3.2.0 + */ + public function get(); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/DispenserInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/DispenserInterface.php new file mode 100644 index 000000000..1b272ec19 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/DispenserInterface.php @@ -0,0 +1,60 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode; + + +/** + * Customcode Dispenser Interface + */ +interface DispenserInterface +{ + /** + * Set the script for the customcode dispenser + * + * @param string $script The script + * @param string $first The first key + * @param string|null $second The second key (if not set we use only first key) + * @param string|null $third The third key (if not set we use only first and second key) + * @param array $config The config options + * @param bool $base64 The switch to decode base64 the script + * default: true + * @param bool $dynamic The switch to dynamic update the script + * default: true + * @param bool $add The switch to add to exiting instead of replace + * default: false + * + * @return bool true on success + * @since 3.2.0 + */ + public function set(&$script, string $first, ?string $second = null, ?string $third = null, + array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool; + + /** + * Get the script from the customcode dispenser + * + * @param string $first The first key + * @param string $second The second key + * @param string $prefix The prefix to add in front of the script if found + * @param string|null $note The switch/note to add to the script + * @param bool $unset The switch to unset the value if found + * @param mixed|null $default The switch/string to use as default return if script not found + * @param string $suffix The suffix to add after the script if found + * + * @return mixed The string/script if found or the default value if not found + * + * @since 3.2.0 + */ + public function get(string $first, string $second, string $prefix = '', ?string $note = null, + bool $unset = false, $default = null, string $suffix = ''); + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExternalInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExternalInterface.php new file mode 100644 index 000000000..8b2d0297f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExternalInterface.php @@ -0,0 +1,31 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode; + + +/** + * Customcode External Interface + */ +interface ExternalInterface +{ + /** + * Set the external code string & load it in to string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * + * @return string + * @since 3.2.0 + */ + public function set(string $string, int $debug = 0): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExtractorInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExtractorInterface.php new file mode 100644 index 000000000..4cfde81c0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/ExtractorInterface.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode; + + +/** + * Customcode Extractor Interface + */ +interface ExtractorInterface +{ + /** + * get the custom code from the local files + * + * @return void + * @since 3.2.0 + */ + public function run(); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/GuiInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/GuiInterface.php new file mode 100644 index 000000000..7b4760040 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/GuiInterface.php @@ -0,0 +1,44 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode; + + +/** + * Customcode Gui Interface + */ +interface GuiInterface +{ + /** + * Set the JCB GUI code placeholder + * + * @param string $string The code string + * @param array $config The placeholder config values + * + * @return string + * @since 3.2.0 + */ + public function set(string $string, array $config): string; + + /** + * search a file for gui code blocks that were updated in the IDE + * + * @param string $file The file path to search + * @param array $placeholders The values to replace in the code being stored + * @param string $today The date for today + * @param string $target The target path type + * + * @return void + * @since 3.2.0 + */ + public function search(string &$file, array &$placeholders, string &$today, string &$target); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/LockBaseInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/LockBaseInterface.php new file mode 100644 index 000000000..fc5429d27 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/LockBaseInterface.php @@ -0,0 +1,30 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode; + + +/** + * Customcode LockBase Interface + */ +interface LockBaseInterface +{ + /** + * Set a string as bsae64 (basic) + * + * @param string $script The code string + * + * @return string + * @since 3.2.0 + */ + public function set(string $script): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Customcode/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/CustomcodeInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/CustomcodeInterface.php new file mode 100644 index 000000000..f79a20b22 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/CustomcodeInterface.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Compiler Customcode Interface + * + * @since 3.2.0 + */ +interface CustomcodeInterface +{ + /** + * Update **ALL** dynamic values in a strings here + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * We can now at any time debug the + * dynamic build values if it gets broken + * + * @return string + * @since 3.2.0 + */ + public function update(string $string, int $debug = 0): string; + + /** + * Set the custom code data & can load it in to string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * @param int|null $not The not switch + * + * @return string + * @since 3.2.0 + */ + public function set(string $string, int $debug = 0, ?int $not = null): string; + + /** + * Load the custom code from the system + * + * @param array|null $ids The custom code ides if known + * @param bool $setLang The set lang switch + * @param int $debug The switch to debug the update + * + * @return bool + * @since 3.2.0 + */ + public function get(?array $ids = null, bool $setLang = true, $debug = 0): bool; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/InstallInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/InstallInterface.php similarity index 90% rename from libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/InstallInterface.php rename to libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/InstallInterface.php index 3b0528273..b19945f23 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/InstallInterface.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/InstallInterface.php @@ -9,7 +9,7 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension; /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Extension/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/LanguageInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/LanguageInterface.php new file mode 100644 index 000000000..3c3090825 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/LanguageInterface.php @@ -0,0 +1,89 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Compiler Language Interface + * + * @since 3.2.0 + */ +interface LanguageInterface +{ + /** + * Get the language string key + * + * @param string $string The plan text string (English) + * + * @return string The key language string (all uppercase) + * @since 3.2.0 + */ + public function key($string): string; + + /** + * check if the language string exist + * + * @param string $target The target area for the language string + * @param string|null $language The language key string + * + * @return bool + * @since 3.2.0 + */ + public function exist(string $target, ?string $language = null): bool; + + /** + * get the language string + * + * @param string $target The target area for the language string + * @param string|null $language The language key string + * + * @return Mixed The language string found or empty string if none is found + * @since 3.2.0 + */ + public function get(string $target, string $language): string; + + /** + * get target array + * + * @param string $target The target area for the language string + * + * @return array The target array or empty array if none is found + * @since 3.2.0 + */ + public function getTarget(string $target): array; + + /** + * set target array + * + * @param string $target The target area for the language string + * @param array|null $content The language content string + * + * @return void + * @since 3.2.0 + */ + public function setTarget(string $target, ?array $content); + + /** + * set the language content values to language content array + * + * @param string $target The target area for the language string + * @param string $language The language key string + * @param string $string The language string + * @param bool $addPrefix The switch to add langPrefix + * + * @return void + * @since 3.2.0 + */ + public function set(string $target, string $language, string $string, bool $addPrefix = false); + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PlaceholderInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PlaceholderInterface.php new file mode 100644 index 000000000..f7163b3c0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PlaceholderInterface.php @@ -0,0 +1,72 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Compiler Placeholder Interface + * + * @since 3.2.0 + */ +interface PlaceholderInterface +{ + /** + * Set a type of placeholder with set of values + * + * @param string $key The main string for placeholder key + * @param array $values The values to add + * + * @return void + * @since 3.2.0 + */ + public function setType(string $key, array $values); + + /** + * Remove a type of placeholder by main key + * + * @param string $key The main string for placeholder key + * + * @return void + * @since 3.2.0 + */ + public function clearType(string $key); + + /** + * Update the data with the placeholders + * + * @param string $data The actual data + * @param array $placeholder The placeholders + * @param int $action The action to use + * + * THE ACTION OPTIONS ARE + * 1 -> Just replace (default) + * 2 -> Check if data string has placeholders + * 3 -> Remove placeholders not in data string + * + * @return string + * @since 3.2.0 + */ + public function update(string $data, array &$placeholder, int $action = 1): string; + + /** + * return the placeholders for inserted and replaced code + * + * @param int $type The type of placement + * @param int|null $id The code id in the system + * + * @return array with start and end keys + * @since 3.2.0 + */ + public function keys(int $type, ?int $id = null): array; + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PowerInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PowerInterface.php new file mode 100644 index 000000000..4dd0c954e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/PowerInterface.php @@ -0,0 +1,43 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Compiler Power Interface + * + * @since 3.2.0 + */ +interface PowerInterface +{ + /** + * load all the powers linked to this component + * + * @param array $guids The global unique ids of the linked powers + * + * @return void + * @since 3.2.0 + */ + public function load(array $guids); + + /** + * Get a power + * + * @param string $guid The global unique id of the power + * @param int $build Force build switch (to override global switch) + * + * @return mixed + * @since 3.2.0 + */ + public function get(string $guid, int $build = 0); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php index fc604ea5d..9da01d5c0 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php @@ -16,6 +16,7 @@ use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\LanguageInterface; /** @@ -23,7 +24,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config; * * @since 3.2.0 */ -class Language +class Language implements LanguageInterface { /** * The language content diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Placeholder.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Placeholder.php index ff1120415..a99bef647 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Placeholder.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Placeholder.php @@ -18,6 +18,7 @@ use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PlaceholderInterface; /** @@ -25,7 +26,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; * * @since 3.2.0 */ -class Placeholder +class Placeholder implements PlaceholderInterface { /** * The active placeholders @@ -181,10 +182,10 @@ class Placeholder * @param int $type The type of placement * @param int|null $id The code id in the system * - * @return array on success + * @return array with start and end keys * @since 3.2.0 */ - public function keys(int $type, ?int $id = null) + public function keys(int $type, ?int $id = null): array { switch ($type) { @@ -200,10 +201,6 @@ class Placeholder 'end' => '/***[/REPLACED$$$$]***/' ]; } - else - { - return [ 'start' => "", 'end' => ""]; - } break; case 12: //***[INSERTED$$$$]***//**1**/ @@ -214,10 +211,6 @@ class Placeholder 'end' => '/***[/INSERTED$$$$]***/' ]; } - else - { - return [ 'start' => "", 'end' => ""]; - } break; case 21: // @@ -228,10 +221,6 @@ class Placeholder 'end' => '' ]; } - else - { - return [ 'start' => "", 'end' => ""]; - } break; case 22: // @@ -242,10 +231,6 @@ class Placeholder 'end' => '' ]; } - else - { - return [ 'start' => "", 'end' => ""]; - } break; case 33: return ['start' => Placefix::h(), 'end' => Placefix::h()]; @@ -255,8 +240,9 @@ class Placeholder break; } - return false; + return [ 'start' => "", 'end' => ""]; } + } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php index 3afc35771..852ec1f5c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php @@ -26,6 +26,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface; /** @@ -33,7 +34,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; * * @since 3.2.0 */ -class Power +class Power implements PowerInterface { /** * All loaded powers @@ -207,7 +208,7 @@ class Power $this->active[$guid]->key = $this->active[$guid]->id . '_' . $this->active[$guid]->target_type; // now set the name $this->active[$guid]->name = $this->placeholder->update( - $this->customcode->add($this->active[$guid]->name), + $this->customcode->update($this->active[$guid]->name), $this->placeholder->active ); // now set the code_name and class name @@ -382,7 +383,7 @@ class Power && StringHelper::check($this->active[$guid]->implements_custom)) { $this->active[$guid]->implement_names[] = $this->placeholder->update( - $this->customcode->add($this->active[$guid]->implements_custom), + $this->customcode->update($this->active[$guid]->implements_custom), $this->placeholder->active ); // just add this once @@ -409,7 +410,7 @@ class Power && StringHelper::check($this->active[$guid]->extends_custom)) { $this->active[$guid]->extends_name = $this->placeholder->update( - $this->customcode->add($this->active[$guid]->extends_custom), + $this->customcode->update($this->active[$guid]->extends_custom), $this->placeholder->active ); // just add once @@ -437,7 +438,7 @@ class Power // base64 Decode code $this->active[$guid]->head = $this->gui->set( $this->placeholder->update( - $this->customcode->add( + $this->customcode->update( base64_decode( $this->active[$guid]->head ) @@ -472,7 +473,7 @@ class Power } // now set the description $this->active[$guid]->description = (StringHelper::check($this->active[$guid]->description)) ? $this->placeholder->update( - $this->customcode->add($this->active[$guid]->description), + $this->customcode->update($this->active[$guid]->description), $this->placeholder->active ) : ''; // add the main code if set @@ -483,7 +484,7 @@ class Power // base64 Decode code $this->active[$guid]->main_class_code = $this->gui->set( $this->placeholder->update( - $this->customcode->add( + $this->customcode->update( base64_decode( $this->active[$guid]->main_class_code ) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Customcode.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Customcode.php index 9273ae05b..c9364af28 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Customcode.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Customcode.php @@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\Componentbuilder\Compiler\Customcode as CompilerCustomcode; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface; use VDM\Joomla\Componentbuilder\Compiler\Customcode\External; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash; @@ -71,10 +72,10 @@ class Customcode implements ServiceProviderInterface * * @param Container $container The DI container. * - * @return CompilerCustomcode + * @return CustomcodeInterface * @since 3.2.0 */ - public function getCustomcode(Container $container): CompilerCustomcode + public function getCustomcode(Container $container): CustomcodeInterface { return new CompilerCustomcode( $container->get('Config'),