From bebb98e915d945d4b1e906e5a48299802d0411ad Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 12 Feb 2019 18:42:16 +0200 Subject: [PATCH] Fixed gh-377 to avoid mismatching on replace eding target hash. Imporved the versioning feature so that once you change the version in the update mysql area, it also updates the Joomla component. --- README.md | 5 +++-- admin/README.txt | 5 +++-- admin/controllers/component_updates.php | 18 ++++++++++++++++++ admin/helpers/compiler/a_Get.php | 11 +++++++++++ componentbuilder.xml | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f230d9f2b..7eead2129 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Where can you get support and help? ==================== + [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE) ++ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7) + [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) + [The JCB! Wiki](https://github.com/vdm-io/Joomla-Component-Builder/wiki) + [JCB Google Group/forum](https://vdm.bz/jcb-forum) @@ -144,11 +145,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 6th February, 2019 ++ *Last Build*: 12th February, 2019 + *Version*: 2.9.11 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195865** ++ *Line count*: **195885** + *Field count*: **1089** + *File count*: **1277** + *Folder count*: **201** diff --git a/admin/README.txt b/admin/README.txt index f230d9f2b..7eead2129 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -103,6 +103,7 @@ Where can you get support and help? ==================== + [The JCB Tutorials](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE) ++ [German Basic Introduction](https://www.youtube.com/playlist?list=PLQRGFI8XZ_wu0tDFxJtZFwW7AxA4JHQV7) + [Hello World Tutorial](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) + [The JCB! Wiki](https://github.com/vdm-io/Joomla-Component-Builder/wiki) + [JCB Google Group/forum](https://vdm.bz/jcb-forum) @@ -144,11 +145,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 6th February, 2019 ++ *Last Build*: 12th February, 2019 + *Version*: 2.9.11 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195865** ++ *Line count*: **195885** + *Field count*: **1089** + *File count*: **1277** + *Folder count*: **201** diff --git a/admin/controllers/component_updates.php b/admin/controllers/component_updates.php index ab3308581..8846e7860 100644 --- a/admin/controllers/component_updates.php +++ b/admin/controllers/component_updates.php @@ -315,6 +315,24 @@ class ComponentbuilderControllerComponent_updates extends JControllerForm */ protected function postSaveHook(JModelLegacy $model, $validData = array()) { + // update the component version to match the updated last version + if (isset($validData['joomla_component']) && is_numeric($validData['joomla_component']) && $validData['joomla_component'] > 0) + { + $objectUpdate = new stdClass(); + $objectUpdate->id = (int) $validData['joomla_component']; + if (isset($validData['version_update']) && ComponentbuilderHelper::checkArray($validData['version_update']) + && ($component_version = end($validData['version_update'])['version']) + && ComponentbuilderHelper::checkString($component_version)) + { + $objectUpdate->component_version = $component_version; + } + // be sure to update the table if we have a value + if (isset($objectUpdate->component_version)) + { + JFactory::getDbo()->updateObject('#__componentbuilder_joomla_component', $objectUpdate, 'id'); + } + } + return; } diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 5e31b3e46..43ef444b7 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -5513,12 +5513,23 @@ class Get { $customCode['code'] = $this->setCustomCodeData($customCode['code'], $debug, $nr); } + // build the hash array if (isset($customCode['hashtarget'])) { $customCode['hashtarget'] = explode("__", $customCode['hashtarget']); + // is this a replace code, set end has array if ($customCode['type'] == 1 && 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]) + { + // unset since this will force the replacement unto end of page. + unset($customCode['hashendtarget']); + } } } } diff --git a/componentbuilder.xml b/componentbuilder.xml index a9b7da98c..7c1c0cbea 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 6th February, 2019 + 12th February, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com