]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/template/menu/class_MenuTemplateEngine.php
Rewritten to stacker class, old lost methods removed
[core.git] / inc / classes / main / template / menu / class_MenuTemplateEngine.php
index 597b0149ef0a2b7cadb84ecd140f2690799fcf76..93382f9c8c2a4aa0249bdef3eaaebbd6dfe17121 100644 (file)
@@ -293,8 +293,8 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Handles the template dependency for given node
         *
-        * @param       $node   The node we should load a dependency template
-        * @param       $templateDependency     A template to load to satisfy dependencies
+        * @param       $node                                   The node we should load a dependency template
+        * @param       $templateDependency             A template to load to satisfy dependencies
         * @return      void
         */
        private function handleTemplateDependency ($node, $templateDependency) {
@@ -317,7 +317,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Intializes the menu
         *
-        * @param       $templateDependency     A template to load to satisfy dependencies
+        * @param       $templateDependency             A template to load to satisfy dependencies
         * @return      void
         * @todo        Add cache creation here
         */
@@ -328,66 +328,19 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                // Handle the dependency template
                $this->handleTemplateDependency('menu', $templateDependency);
 
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_global_start');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('menu_start', $this->getTemplateInstance()->getRawTemplateData());
-       }
-
-       /**
-        * Finishes the menu
-        *
-        * @return      void
-        */
-       private function finishMenu () {
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_global_end');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('menu_end', $this->getTemplateInstance()->getRawTemplateData());
+               // Push the node name on the stacker
+               $this->getStackerInstance()->pushNamed('current_node', 'menu');
        }
 
        /**
-        * Starts the menu entries by loading a (maybe) provided template dependency
+        * Starts the menu entries
         *
         * @param       $templateDependency     A template to load to satisfy dependencies
         * @return      void
         */
-       private function startEntryList ($templateDependency = '') {
-               // Handle the dependency template
-               $this->handleTemplateDependency('entries', $templateDependency);
-
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_entries_start');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('entries_start', $this->getTemplateInstance()->getRawTemplateData());
-       }
-
-       /**
-        * Finishes the menu entries
-        *
-        * @return      void
-        */
-       private function finishEntryList () {
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_entries_end');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('entries_end', $this->getTemplateInstance()->getRawTemplateData());
+       private function startEntryList () {
+               // Push the node name on the stacker
+               $this->getStackerInstance()->pushNamed('current_node', 'entry-list');
        }
 
        /**
@@ -396,39 +349,8 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         */
        private function startBlockHeader () {
-               // Do we have a template instance?
-               if (is_null($this->getTemplateInstance())) {
-                       // Init template instance for underlaying web templates
-                       $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
-
-                       // Set it in this template engine
-                       $this->setTemplateInstance($templateInstance);
-               } // END - if
-
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_header_start');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('header', $this->getTemplateInstance()->getRawTemplateData());
-       }
-
-       /**
-        * Finishes the menu block header
-        *
-        * @return      void
-        */
-       private function finishBlockHeader () {
-               // Load the header template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_header_end');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('header_end', $this->getTemplateInstance()->getRawTemplateData());
+               // Push the node name on the stacker
+               $this->getStackerInstance()->pushNamed('current_node', 'block-header');
        }
 
        /**
@@ -437,39 +359,8 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         */
        private function startBlockFooter () {
-               // Do we have a template instance?
-               if (is_null($this->getTemplateInstance())) {
-                       // Init template instance for underlaying web templates
-                       $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
-
-                       // Set it in this template engine
-                       $this->setTemplateInstance($templateInstance);
-               } // END - if
-
-               // Load the footer template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_footer_start');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('footer', $this->getTemplateInstance()->getRawTemplateData());
-       }
-
-       /**
-        * Finishes the menu block footer
-        *
-        * @return      void
-        */
-       private function finishBlockFooter () {
-               // Load the footer template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_footer_end');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('footer_end', $this->getTemplateInstance()->getRawTemplateData());
+               // Push the node name on the stacker
+               $this->getStackerInstance()->pushNamed('current_node', 'block-footer');
        }
 
        /**
@@ -793,44 +684,43 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        }
 
        /**
-        * Starts the menu text
+        * Finishes the menu entries
         *
         * @return      void
         */
-       private function startText () {
-               // Do we have a template instance?
-               if (is_null($this->getTemplateInstance())) {
-                       // Init template instance for underlaying web templates
-                       $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
-
-                       // Set it in this template engine
-                       $this->setTemplateInstance($templateInstance);
-               } // END - if
-
-               // Load the text template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_text_start');
-
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
-
-               // Set its content in this template instance
-               $this->assignVariable('text', $this->getTemplateInstance()->getRawTemplateData());
+       private function finishEntryList () {
+               // Pop the last entry
+               $this->getStackerInstance()->popNamed('current_node');
        }
 
        /**
-        * Finishes the menu text
+        * Finishes the menu block header
         *
         * @return      void
         */
-       private function finishText () {
-               // Load the text template for this page
-               $this->getTemplateInstance()->loadCodeTemplate('menu_text_end');
+       private function finishBlockHeader () {
+               // Pop the last entry
+               $this->getStackerInstance()->popNamed('current_node');
+       }
 
-               // Set the variable group to page
-               $this->setVariableGroup('menu');
+       /**
+        * Finishes the menu block footer
+        *
+        * @return      void
+        */
+       private function finishBlockFooter () {
+               // Pop the last entry
+               $this->getStackerInstance()->popNamed('current_node');
+       }
 
-               // Set its content in this template instance
-               $this->assignVariable('text_end', $this->getTemplateInstance()->getRawTemplateData());
+       /**
+        * Finishes the menu
+        *
+        * @return      void
+        */
+       private function finishMenu () {
+               // Pop the last entry
+               $this->getStackerInstance()->popNamed('current_node');
        }
 
        /**