From 49bf8b382e56c6adb924fefd532399648f83cdf4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 12 Aug 2008 19:40:18 +0000 Subject: [PATCH] Content will now be added to previously opened sub/group. --- inc/classes/main/helper/class_BaseHelper.php | 40 +++++++++++++++++-- .../helper/web/forms/class_WebFormHelper.php | 18 ++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index af2a663..0e21d88 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -83,7 +83,7 @@ class BaseHelper extends BaseFrameworkSystem { } /** - * Add content + * Adds content directly * * @param $newContent New content to add * @return void @@ -92,6 +92,34 @@ class BaseHelper extends BaseFrameworkSystem { $this->content .= (string) trim($newContent) . "\r\n"; } + /** + * Adds content to the previously opened group or sub group. If a sub group + * was found it will be taken. If no group/sub group is opened at the moment + * the code will be passed to addContent(). + * + * @param $newContent New content to add + * @return void + */ + protected final function addContentToPreviousGroup ($newContent) { + // Check for sub/group + if ($this->ifSubGroupOpenedPreviously()) { + // Get sub group id + $subGroupId = $this->getPreviousSubGroupId(); + + // Add the content + $this->subGroups[$subGroupId]['content'] .= $newContent; + } elseif ($this->ifGroupOpenedPreviously()) { + // Get group id + $groupId = $this->getPreviousGroupId(); + + // Add the content + $this->groups[$groupId]['content'] .= $newContent; + } else { + // Add it directly + $this->addContent($newContent); + } + } + /** * Getter for content * @@ -184,7 +212,6 @@ class BaseHelper extends BaseFrameworkSystem { // Is the group already there? if (isset($this->groups[$groupId])) { // Then throw an exception here - $this->debugBackTrace(); throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND); } // END - if @@ -298,10 +325,14 @@ class BaseHelper extends BaseFrameworkSystem { // Is this a group and is it closed? if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) { // Then add it's content - $content .= $this->groups[$this->groups[$idx]]['content']; + $groupContent = $this->groups[$this->groups[$idx]]['content']; + //* DEBUG: */ echo "group={$this->groups[$idx]},content=
".htmlentities($groupContent)."

\n"; + $content .= $groupContent; } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) { // Then add it's content - $content .= $this->subGroups[$this->subGroups[$idx]]['content']; + $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content']; + //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=
".htmlentities($subGroupContent)."

\n"; + $content .= $subGroupContent; } else { // Something went wrong die("GROUP/SUB GROUP ERROR: {$idx}"); @@ -310,6 +341,7 @@ class BaseHelper extends BaseFrameworkSystem { } // END - for // Return it + //* DEBUG: */ echo "content=
".htmlentities($content)."
(".strlen($content).")
\n"; return $content; } diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index 4faaf74..1267520 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -174,7 +174,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it maybe with a "li" tag - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -216,7 +216,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -242,7 +242,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -304,7 +304,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -329,7 +329,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -355,7 +355,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -530,7 +530,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -564,7 +564,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -606,7 +606,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { $captchaInstance->renderCode(); // Get the content and add it to the helper - $this->addContent($captchaInstance->renderContent()); + $this->addContentToPreviousGroup($captchaInstance->renderContent()); } /** -- 2.39.2