]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/helper/class_BaseHelper.php
Deprecated methods removed/purged
[shipsimu.git] / inc / classes / main / helper / class_BaseHelper.php
index af2a663ff219bbae58119d76d17b2ea8cf863b78..94f4ed5f1940e597282f0b9689b157f1dbc7d293 100644 (file)
@@ -83,13 +83,63 @@ class BaseHelper extends BaseFrameworkSystem {
        }
 
        /**
-        * Add content
+        * Adds content directly
         *
         * @param       $newContent             New content to add
         * @return      void
         */
        protected final function addContent ($newContent) {
-               $this->content .= (string) trim($newContent) . "\r\n";
+               $this->content .= (string) trim($newContent)."\n";
+       }
+
+       /**
+        * Add header content to the helper
+        *
+        * @param       $content        Content to to the base
+        * @return      void
+        */
+       protected function addHeaderContent ($content) {
+               // Add the header content
+               $this->groups['header']['content'] = (string) trim($content);
+       }
+
+       /**
+        * Add footer content to the helper
+        *
+        * @param       $content        Content to to the base
+        * @return      void
+        */
+       protected function addFooterContent ($content) {
+               // Add the footer content
+               $this->groups['footer']['content'] = (string) trim($content);
+       }
+
+       /**
+        * 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);
+               }
        }
 
        /**
@@ -184,7 +234,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
 
@@ -290,26 +339,46 @@ class BaseHelper extends BaseFrameworkSystem {
         * @return      $content        Rendered HTML content
         */
        public function renderContent () {
+               // Initialize content
+               $content = "";
+
+               // Is header content there?
+               if (isset($this->groups['header'])) {
+                       // Then add it
+                       $content .= $this->groups['header']['content']."\n";
+               } // END - if
+
                // Initiate content
-               $content = $this->getContent();
+               $content .= $this->getContent();
 
                // Now "walk" through all groups and sub-groups
                for ($idx = 1; $idx <= $this->totalCounter; $idx++) {
                        // 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=<pre>".htmlentities($groupContent)."</pre><br />\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=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
+                               $content .= $subGroupContent;
                        } else {
                                // Something went wrong
-                               die("GROUP/SUB GROUP ERROR: {$idx}");
+                               $this->debugInstance();
                        }
 
                } // END - for
 
+               // Is footer content there?
+               if (isset($this->groups['footer'])) {
+                       // Then add it
+                       $content .= $this->groups['footer']['content']."\n";
+               } // END - if
+
                // Return it
+               //* DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
                return $content;
        }