X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fclass_BaseHelper.php;h=b4e893f4bcee531260a179f4cf0b54fde375cbcc;hb=12dbc1af8f0bc2981711b17c7c955f270c440b35;hp=94f4ed5f1940e597282f0b9689b157f1dbc7d293;hpb=c59dccf46c5d0e3b7f2687370b2b15023b1ecdfe;p=hub.git
diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php
index 94f4ed5f1..b4e893f4b 100644
--- a/inc/classes/main/helper/class_BaseHelper.php
+++ b/inc/classes/main/helper/class_BaseHelper.php
@@ -226,11 +226,12 @@ class BaseHelper extends BaseFrameworkSystem {
*
* @param $groupId Group id to open
* @param $content Initial content to add to the group
+ * @param $tag HTML tag used to open this group
* @return void
* @throws HelperGroupAlreadyCreatedException If the group was already created before
*/
- protected function openGroupByIdContent ($groupId, $content) {
- //* DEBUG: */ echo "OPEN:groupId={$groupId}
\n";
+ protected function openGroupByIdContent ($groupId, $content, $tag) {
+ //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
".htmlentities($content)."\n"; // Is the group already there? if (isset($this->groups[$groupId])) { // Then throw an exception here @@ -243,7 +244,8 @@ class BaseHelper extends BaseFrameworkSystem { // Add the group to the stack $this->groups[$this->totalCounter] = $groupId; $this->groups[$groupId]['opened'] = true; - $this->groups[$groupId]['content'] = $content."\n"; + $this->groups[$groupId]['content'] = sprintf("%s\n", $groupId, strlen($content), $tag, $content); + $this->groups[$groupId]['tag'] = $tag; // Mark this group as previously opened $this->setPreviousGroupId($groupId); @@ -253,13 +255,19 @@ class BaseHelper extends BaseFrameworkSystem { * Closes the previously opened group by added given content to it or * throws an exception if no previous group was opened * - * @param $content Content for previously opened grouop + * @param $content Content for previously opened group, or empty to use tag of opener * @return void * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found */ - public function closePreviousGroupByContent ($content) { + public function closePreviousGroupByContent ($content = "") { + // Check if any sub group was opened before + if ($this->ifSubGroupOpenedPreviously()) { + // Close it automatically + $this->closePreviousSubGroupByContent(); + } // END - if + // Check if any group was opened before - if (!$this->ifGroupOpenedPreviously()) { + if ($this->ifGroupOpenedPreviously() === false) { // Then throw an exception throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); } // END - if @@ -267,8 +275,14 @@ class BaseHelper extends BaseFrameworkSystem { // Get previous group $groupId = $this->getPreviousGroupId(); + // Is the content empty? + if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { + // Get it from opener + $content = sprintf("%s>", $groupId, $this->groups[$groupId]['tag']); + } // END - if + // Add content to it and mark it as closed - $this->groups[$groupId]['content'] .= $content."\n"; + $this->groups[$groupId]['content'] .= sprintf("%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content); $this->groups[$groupId]['opened'] = false; // Mark previous group as closed @@ -283,10 +297,11 @@ class BaseHelper extends BaseFrameworkSystem { * * @param $subGroupId Sub group id to open * @param $content Initial content to add to the sub group + * @param $tag HTML tag used to open this group * @return void * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before */ - protected function openSubGroupByIdContent ($subGroupId, $content) { + protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
".htmlentities($groupContent)."
".htmlentities($subGroupContent)."