diff --git a/README.md b/README.md index c75e3758a..0851958d5 100644 --- a/README.md +++ b/README.md @@ -140,11 +140,11 @@ 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*: 17th September, 2022 ++ *Last Build*: 19th 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*: **331338** ++ *Line count*: **331435** + *Field count*: **2002** + *File count*: **2167** + *Folder count*: **375** diff --git a/admin/README.txt b/admin/README.txt index c75e3758a..0851958d5 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -140,11 +140,11 @@ 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*: 17th September, 2022 ++ *Last Build*: 19th 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*: **331338** ++ *Line count*: **331435** + *Field count*: **2002** + *File count*: **2167** + *Folder count*: **375** diff --git a/componentbuilder.xml b/componentbuilder.xml index 9e19b1461..2773d7b23 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 17th September, 2022 + 19th September, 2022 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Agent/Update.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Agent/Update.php index 635593ac0..902920c5d 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Agent/Update.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Agent/Update.php @@ -49,12 +49,12 @@ class Update * Update the value * * @param mixed $value The field value - * @param int $line The line to update (0 = all) + * @param mixed $line The line to update (0 = all) * * @return mixed * @since 3.2.0 */ - public function value($value, int $line = 0) + public function value($value, $line = 0) { // update the value $update = $this->updateValue($value, $line); @@ -72,26 +72,123 @@ class Update * Update all search-replace instances inside a value * * @param mixed $value The field value - * @param int $line The line to update (0 = all) + * @param mixed $line The line to update (0 = all) * * @return mixed * @since 3.2.0 */ - protected function updateValue($value, int $line = 0) + protected function updateValue($value, $line = 0) { + // I know this is a little crazy... TODO refactor into recursion functions + // the possibility of updating sub-forms in sub-forms if (ArrayHelper::check($value)) { - echo '
'; var_dump($value); exit;
+			if (strpos($line, '.') !== false)
+			{
+				$line = explode('.', $line);
+			}
+			// first layer
+			foreach ($value as $keys => &$rows)
+			{
+				if (ArrayHelper::check($rows))
+				{
+					// second layer
+					foreach ($rows as $key => &$row)
+					{
+						if (ArrayHelper::check($row))
+						{
+							// third layer
+							foreach ($row as $ke => &$ro)
+							{
+								if (ArrayHelper::check($ro))
+								{
+									// forth layer
+									foreach ($ro as $k => &$r)
+									{
+										if (StringHelper::check($r) &&
+											$this->validateUpdateKey($line, $keys, $key, $ke, $k))
+										{
+											$_line = (isset($line[4])) ? $line[4] : 0;
+												$r = $this->string($r, $_line);
+										}
+									}
+								}
+								elseif (StringHelper::check($ro) &&
+									$this->validateUpdateKey($line, $keys, $key, $ke))
+								{
+									$_line = (isset($line[3])) ? $line[3] : 0;
+									$ro = $this->string($ro, $_line);
+								}
+
+							}
+						}
+						elseif (StringHelper::check($row) &&
+							$this->validateUpdateKey($line, $keys, $key))
+						{
+							$_line = (isset($line[2])) ? $line[2] : 0;
+							$row  = $this->string($row, $_line);
+						}
+					}
+				}
+				elseif (StringHelper::check($rows) &&
+					$this->validateUpdateKey($line, $keys))
+				{
+					$_line = (isset($line[1])) ? $line[1] : 0;
+					$rows = $this->string($rows, $_line);
+				}
+			}
 		}
 		elseif (StringHelper::check($value))
 		{
-			return $this->string($value, $line);
+			$value = $this->string($value, $line);
 		}
-		else
+
+		return $value;
+	}
+
+	/**
+	 * Check if the keys are valid for search when working with arrays
+	 *
+	 * @param   int            $line     The lines array
+	 * @param   mixed      $keys   The line keys
+	 * @param   mixed      $key     The line key
+	 * @param   mixed      $k        The line ke
+	 * @param   mixed      $k        The line k
+	 *
+	 * @return  bool
+	 * @since 3.2.0
+	 */
+	protected function validateUpdateKey($line, $keys = null, $key = null, $ke = null, $k = null): bool
+	{
+		if (ArrayHelper::check($line))
 		{
-			// this should not happen
-			echo '
Error:
'; var_dump($value); exit; + $_keys = (isset($line[0])) ? $line[0] : null; + $_key = (isset($line[1])) ? $line[1] : null; + $_ke = (isset($line[2])) ? $line[2] : null; + $_k = (isset($line[3])) ? $line[3] : null; + + if ($keys && $_keys && $_keys !== $keys) + { + return false; + } + + if ($key && $_key && $_key !== $key) + { + return false; + } + + if ($ke && $_ke && $_ke !== $ke) + { + return false; + } + + if ($k && $_k && $_k !== $k) + { + return false; + } } + + return true; } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Type.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Type.php index cfaff6418..5ff80ad74 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Type.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Type.php @@ -42,10 +42,10 @@ abstract class Type /** * Replace Value * - * @var string|null + * @var string * @since 3.2.0 */ - protected ?string $replaceValue; + protected string $replaceValue; /** * Search Should Match Case @@ -82,7 +82,7 @@ abstract class Type /** * Constructor * - * @param Config|null $config The search config object. + * @param Config|null $config The search config object. * * @since 3.2.0 */