From 812857da813d5863a8043b2b73e0fdc2fd780127 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 23 Jul 2018 04:53:59 +0200 Subject: [PATCH] Fixed gh-324 that had a typo with the storing of the PHPx values. Improved the safeString helper method --- README.md | 4 ++-- admin/README.txt | 4 ++-- admin/compiler/joomla_3/Helper.php | 13 +++++++++++-- admin/compiler/joomla_3/Helper_site.php | 13 +++++++++++-- admin/helpers/compiler/a_Get.php | 2 +- admin/helpers/componentbuilder.php | 13 +++++++++++-- admin/models/field.php | 2 +- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 13 +++++++++++-- 9 files changed, 51 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7a1832736..9aba28545 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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 July, 2018 ++ *Last Build*: 23rd July, 2018 + *Version*: 2.8.4 + *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*: **186347** ++ *Line count*: **186365** + *Field count*: **1059** + *File count*: **1239** + *Folder count*: **197** diff --git a/admin/README.txt b/admin/README.txt index 7a1832736..9aba28545 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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 July, 2018 ++ *Last Build*: 23rd July, 2018 + *Version*: 2.8.4 + *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*: **186347** ++ *Line count*: **186365** + *Field count*: **1059** + *File count*: **1239** + *Folder count*: **197** diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index 01ec957b5..51e07c462 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -979,7 +979,7 @@ abstract class ###Component###Helper * * @returns string on success **/ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) { if ($replaceNumbers === true) { @@ -1008,7 +1008,16 @@ abstract class ###Component###Helper $string = trim($string); $string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } // select final adaptations if ($type === 'L' || $type === 'strtolower') { diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index f12faa37d..9cced568a 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -971,7 +971,7 @@ abstract class ###Component###Helper * * @returns string on success **/ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) { if ($replaceNumbers === true) { @@ -1000,7 +1000,16 @@ abstract class ###Component###Helper $string = trim($string); $string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } // select final adaptations if ($type === 'L' || $type === 'strtolower') { diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 604e10958..ddcc9fe3d 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -2341,7 +2341,7 @@ class Get if ($this->validationRules[$validationRule] = ComponentbuilderHelper::getVar('validation_rule', $validationRule, 'name', 'php')) { // open and set the validation rule - $this->validationRules[$validationRule] = $this->setDynamicValues(base64_decode($this->validationRules[$validationRule])); + $this->validationRules[$validationRule] = $this->setPlaceholders($this->setDynamicValues(base64_decode($this->validationRules[$validationRule])), $this->placeholders); } else { diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index a263c9289..12b4dbf1a 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -4957,7 +4957,7 @@ abstract class ComponentbuilderHelper * * @returns string on success **/ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) { if ($replaceNumbers === true) { @@ -4986,7 +4986,16 @@ abstract class ComponentbuilderHelper $string = trim($string); $string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } // select final adaptations if ($type === 'L' || $type === 'strtolower') { diff --git a/admin/models/field.php b/admin/models/field.php index 857610325..1c8789469 100644 --- a/admin/models/field.php +++ b/admin/models/field.php @@ -930,7 +930,7 @@ class ComponentbuilderModelField extends JModelAdmin if (ComponentbuilderHelper::checkString($typephpx)) { // load the type_phpx property - $bucket[] = "\t".'type_phpx_1="'. str_replace('"', "'", $typephp).'"'; + $bucket[] = "\t".'type_phpx_1="'. str_replace('"', "'", $typephpx).'"'; } // if the bucket has been loaded if (ComponentbuilderHelper::checkArray($bucket)) diff --git a/componentbuilder.xml b/componentbuilder.xml index 94b22159d..6554c85e1 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 21st July, 2018 + 23rd July, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index de39c242e..224489707 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -4691,7 +4691,7 @@ abstract class ComponentbuilderHelper * * @returns string on success **/ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) { if ($replaceNumbers === true) { @@ -4720,7 +4720,16 @@ abstract class ComponentbuilderHelper $string = trim($string); $string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } // select final adaptations if ($type === 'L' || $type === 'strtolower') {