]> git.mxchange.org Git - core.git/blob - framework/main/classes/template/menu/class_MenuTemplateEngine.php
Continued:
[core.git] / framework / main / classes / template / menu / class_MenuTemplateEngine.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Template\Engine;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
9 use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
10 use Org\Mxchange\CoreFramework\Parser\Xml\XmlParser;
11 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
12 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
13 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
14
15 // Import SPL stuff
16 use \SplFileInfo;
17 use \UnexpectedValueException;
18
19 /**
20  * A Menu template engine class
21  *
22  * @author              Roland Haeder <webmaster@shipsimu.org>
23  * @version             0.0.0
24  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
25  * @license             GNU GPL 3.0 or any newer version
26  * @link                http://www.shipsimu.org
27  *
28  * This program is free software: you can redistribute it and/or modify
29  * it under the terms of the GNU General Public License as published by
30  * the Free Software Foundation, either version 3 of the License, or
31  * (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program. If not, see <http://www.gnu.org/licenses/>.
40  */
41 class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTemplate {
42         /**
43          * Main nodes in the XML tree ('menu' is ignored)
44          */
45         private $mainNodes = array(
46                 'block-list',
47         );
48
49         /**
50          * Sub nodes in the XML tree
51          */
52         private $subNodes = array(
53                 'entry-list',
54                 'entry',
55                 'entry-id',
56                 'entries-content',
57                 'block-header',
58                 'block-footer',
59                 'footer-id',
60                 'footer-class',
61                 'footer-text',
62                 'block',
63                 'title',
64                 'title-id',
65                 'title-class',
66                 'title-text',
67                 'design',
68                 'text',
69                 'advert',
70                 'anchor',
71                 'anchor-id',
72                 'anchor-text',
73                 'anchor-title',
74                 'anchor-href',
75         );
76
77         /**
78          * Variables for a menu entry
79          */
80         private $menuEntryVariables = array(
81                 // List entry
82                 'entry_id',
83                 // Anchor
84                 'anchor-id',
85                 'anchor-text',
86                 'anchor-title',
87                 'anchor-href',
88         );
89
90         /**
91          * Variables for a menu block
92          */
93         private $menuBlockVariables = array(
94                 // Title
95                 'title_id',
96                 'title_class',
97                 'title_text',
98                 // Content is taken from menuEntries
99                 // Footer
100                 'footer_id',
101                 'footer_class',
102                 'footer_text',
103         );
104
105         /**
106          * Rendered menu entries
107          */
108         private $menuEntries = array();
109
110         /**
111          * Rendered menu blocks
112          */
113         private $menuBlocks = array();
114
115         /**
116          * Menu instance
117          */
118         private $menuInstance = NULL;
119
120         /**
121          * Current main node
122          */
123         private $curr = array();
124
125         /**
126          * Content from dependency
127          */
128         private $dependencyContent = array();
129
130         /**
131          * Protected constructor
132          *
133          * @return      void
134          */
135         protected function __construct () {
136                 // Call parent constructor
137                 parent::__construct(__CLASS__);
138         }
139
140         /**
141          * Creates an instance of the class TemplateEngine and prepares it for usage
142          *
143          * @param       $menuInstance                   A RenderableMenu instance
144          * @return      $templateInstance               An instance of TemplateEngine
145          * @throws      UnexpectedValueException                If the found $templateBasePath is empty or not a string
146          * @throws      InvalidDirectoryException       If $templateBasePath is no directory or not found
147          * @throws      BasePathReadProtectedException  If $templateBasePath is
148          *                                                                                      read-protected
149          */
150         public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) {
151                 // Get a new instance
152                 $templateInstance = new MenuTemplateEngine();
153
154                 // Get the application instance from registry
155                 $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
156
157                 // Determine base path
158                 $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
159
160                 // Is the base path valid?
161                 if (empty($templateBasePath)) {
162                         // Base path is empty
163                         throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
164                 } elseif (!is_string($templateBasePath)) {
165                         // Is not a string
166                         throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
167                 } elseif (!is_dir($templateBasePath)) {
168                         // Is not a path
169                         throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
170                 } elseif (!is_readable($templateBasePath)) {
171                         // Is not readable
172                         throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
173                 }
174
175                 // Set the base path
176                 $templateInstance->setTemplateBasePath($templateBasePath);
177
178                 // Set template extensions
179                 $templateInstance->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension'));
180                 $templateInstance->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_extension'));
181
182                 // Absolute output path for compiled templates
183                 $templateInstance->setCompileOutputPath(sprintf('%s%s/',
184                         $templateBasePath,
185                         FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path')
186                 ));
187
188                 // Set the menu instance
189                 $templateInstance->setMenuInstance($menuInstance);
190
191                 // Init a variable stacker
192                 $stackInstance = ObjectFactory::createObjectByConfiguredName('menu_stacker_class');
193
194                 // Set it
195                 $templateInstance->setStackInstance($stackInstance);
196
197                 // Return the prepared instance
198                 return $templateInstance;
199         }
200
201         /**
202          * Load a specified menu template into the engine
203          *
204          * @param       $template       The menu template we shall load which is
205          *                                              located in 'menu' by default
206          * @return      void
207          */
208         public function loadMenuTemplate ($template) {
209                 // Set template type
210                 $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_type'));
211
212                 // Load the special template
213                 $this->loadTemplate($template);
214         }
215
216         /**
217          * Getter for current main node
218          *
219          * @return      $currMainNode   Current main node
220          */
221         public final function getCurrMainNode () {
222                 return $this->curr['main_node'];
223         }
224
225         /**
226          * Setter for current main node
227          *
228          * @param       $element                Element name to set as current main node
229          * @return      $currMainNode   Current main node
230          */
231         private final function setCurrMainNode ($element) {
232                 $this->curr['main_node'] = (string) $element;
233         }
234
235         /**
236          * Getter for main node array
237          *
238          * @return      $mainNodes      Array with valid main node names
239          */
240         public final function getMainNodes () {
241                 return $this->mainNodes;
242         }
243
244         /**
245          * Getter for sub node array
246          *
247          * @return      $subNodes       Array with valid sub node names
248          */
249         public final function getSubNodes () {
250                 return $this->subNodes;
251         }
252
253         /**
254          * Handles the start element of an XML resource
255          *
256          * @param       $resource               XML parser resource (currently ignored)
257          * @param       $element                The element we shall handle
258          * @param       $attributes             All attributes
259          * @return      void
260          * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
261          */
262         public function startElement ($resource, $element, array $attributes) {
263                 // Initial method name which will never be called...
264                 $methodName = 'initMenu';
265
266                 // Make the element name lower-case
267                 $element = strtolower($element);
268
269                 // Is the element a main node?
270                 //* DEBUG: */ echo "START: &gt;".$element."&lt;<br />\n";
271                 if (in_array($element, $this->getMainNodes())) {
272                         // Okay, main node found!
273                         $methodName = 'start' . self::convertToClassName($element);
274
275                         // Set it
276                         $this->setCurrMainNode($element);
277                 } elseif (in_array($element, $this->getSubNodes())) {
278                         // Sub node found
279                         $methodName = 'start' . self::convertToClassName($element);
280                 } elseif ($element != 'menu') {
281                         // Invalid node name found
282                         throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
283                 }
284
285                 // Call method
286                 //* DEBUG: */ echo "call: ".$methodName."<br />\n";
287                 call_user_func_array(array($this, $methodName), $attributes);
288         }
289
290         /**
291          * Ends the main or sub node by sending out the gathered data
292          *
293          * @param       $resource       An XML resource pointer (currently ignored)
294          * @param       $nodeName       Name of the node we want to finish
295          * @return      void
296          * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
297          */
298         public function finishElement ($resource, $nodeName) {
299                 // Make all lower-case
300                 $nodeName = strtolower($nodeName);
301
302                 // Does this match with current main node?
303                 //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
304                 if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
305                         // Did not match!
306                         throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
307                 } // END - if
308
309                 // Construct method name
310                 $methodName = 'finish' . self::convertToClassName($nodeName);
311
312                 // Call the corresponding method
313                 //* DEBUG: */ echo "call: ".$methodName."<br />\n";
314                 call_user_func_array(array($this, $methodName), array());
315         }
316
317         /**
318          * Currently not used
319          *
320          * @param       $resource               XML parser resource (currently ignored)
321          * @param       $characters             Characters to handle
322          * @return      void
323          * @todo        Find something useful with this!
324          */
325         public function characterHandler ($resource, $characters) {
326                 // Trim all spaces away
327                 $characters = trim($characters);
328
329                 // Is this string empty?
330                 if (empty($characters)) {
331                         // Then skip it silently
332                         return;
333                 } // END - if
334
335                 // Assign the found characters to variable and use the last entry from
336                 // stack as the name
337                 parent::assignVariable($this->getStackInstance()->getNamed('current_node'), $characters);
338         }
339
340         /**
341          * Handles the template dependency for given node
342          *
343          * @param       $node                                   The node we should load a dependency template
344          * @param       $templateDependency             A template to load to satisfy dependencies
345          * @return      void
346          */
347         private function handleTemplateDependency ($node, $templateDependency) {
348                 // Is the template dependency set?
349                 if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
350                         // Get a temporay menu template instance
351                         $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getMenuInstance()));
352
353                         // Then load it
354                         $templateInstance->loadMenuTemplate($templateDependency);
355
356                         // Parse the XML content
357                         $templateInstance->renderXmlContent();
358
359                         // Save the parsed raw content in our dependency array
360                         $this->dependencyContent[$node] = $templateInstance->getRawTemplateData();
361                 } // END - if
362         }
363
364         /**
365          * Intializes the menu
366          *
367          * @param       $templateDependency             A template to load to satisfy dependencies
368          * @return      void
369          * @todo        Add cache creation here
370          */
371         private function initMenu ($templateDependency = '') {
372                 // Get web template engine
373                 $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application'))));
374
375                 // Handle the dependency template
376                 $this->handleTemplateDependency('menu', $templateDependency);
377
378                 // Push the node name on the stacker
379                 $this->getStackInstance()->pushNamed('current_node', 'menu');
380         }
381
382         /**
383          * Starts the menu entries
384          *
385          * @param       $templateDependency             A template to load to satisfy dependencies
386          * @return      void
387          */
388         private function startEntryList () {
389                 // Push the node name on the stacker
390                 $this->getStackInstance()->pushNamed('current_node', 'entry-list');
391         }
392
393         /**
394          * Starts the menu block header
395          *
396          * @return      void
397          */
398         private function startBlockHeader () {
399                 // Push the node name on the stacker
400                 $this->getStackInstance()->pushNamed('current_node', 'block-header');
401         }
402
403         /**
404          * Starts the menu block footer
405          *
406          * @return      void
407          */
408         private function startBlockFooter () {
409                 // Push the node name on the stacker
410                 $this->getStackInstance()->pushNamed('current_node', 'block-footer');
411         }
412
413         /**
414          * Starts the menu property 'block-list'
415          *
416          * @return      void
417          */
418         private function startBlockList () {
419                 // Push the node name on the stacker
420                 $this->getStackInstance()->pushNamed('current_node', 'block-list');
421         }
422
423         /**
424          * Starts the menu property 'block'
425          *
426          * @return      void
427          */
428         private function startBlock () {
429                 // Push the node name on the stacker
430                 $this->getStackInstance()->pushNamed('current_node', 'block');
431         }
432
433         /**
434          * Starts the menu property 'title'
435          *
436          * @return      void
437          */
438         private function startTitle () {
439                 // Push the node name on the stacker
440                 $this->getStackInstance()->pushNamed('current_node', 'title');
441         }
442
443         /**
444          * Starts the menu property 'title-id'
445          *
446          * @return      void
447          */
448         private function startTitleId () {
449                 // Push the node name on the stacker
450                 $this->getStackInstance()->pushNamed('current_node', 'title-id');
451         }
452
453         /**
454          * Starts the menu property 'title-class'
455          *
456          * @return      void
457          */
458         private function startTitleClass () {
459                 // Push the node name on the stacker
460                 $this->getStackInstance()->pushNamed('current_node', 'title-class');
461         }
462
463         /**
464          * Starts the menu property 'title-text'
465          *
466          * @return      void
467          */
468         private function startTitleText () {
469                 // Push the node name on the stacker
470                 $this->getStackInstance()->pushNamed('current_node', 'title-text');
471         }
472
473         /**
474          * Starts the menu property 'entry'
475          *
476          * @return      void
477          */
478         private function startEntry () {
479                 // Push the node name on the stacker
480                 $this->getStackInstance()->pushNamed('current_node', 'entry');
481         }
482
483         /**
484          * Starts the menu property 'entry-id'
485          *
486          * @return      void
487          */
488         private function startEntryId () {
489                 // Push the node name on the stacker
490                 $this->getStackInstance()->pushNamed('current_node', 'entry-id');
491         }
492
493         /**
494          * Starts the menu property 'anchor'
495          *
496          * @return      void
497          */
498         private function startAnchor () {
499                 // Push the node name on the stacker
500                 $this->getStackInstance()->pushNamed('current_node', 'anchor');
501         }
502
503         /**
504          * Starts the menu property 'anchor-id'
505          *
506          * @return      void
507          */
508         private function startAnchorId () {
509                 // Push the node name on the stacker
510                 $this->getStackInstance()->pushNamed('current_node', 'anchor-id');
511         }
512
513         /**
514          * Starts the menu property 'anchor-text'
515          *
516          * @return      void
517          */
518         private function startAnchorText () {
519                 // Push the node name on the stacker
520                 $this->getStackInstance()->pushNamed('current_node', 'anchor-text');
521         }
522
523         /**
524          * Starts the menu property 'anchor-title'
525          *
526          * @return      void
527          */
528         private function startAnchorTitle () {
529                 // Push the node name on the stacker
530                 $this->getStackInstance()->pushNamed('current_node', 'anchor-title');
531         }
532
533         /**
534          * Starts the menu property 'anchor-href'
535          *
536          * @return      void
537          */
538         private function startAnchorHref () {
539                 // Push the node name on the stacker
540                 $this->getStackInstance()->pushNamed('current_node', 'anchor-href');
541         }
542
543         /**
544          * Starts the menu property 'footer-id'
545          *
546          * @return      void
547          */
548         private function startFooterId () {
549                 // Push the node name on the stacker
550                 $this->getStackInstance()->pushNamed('current_node', 'footer-id');
551         }
552
553         /**
554          * Starts the menu property 'footer-class'
555          *
556          * @return      void
557          */
558         private function startFooterClass () {
559                 // Push the node name on the stacker
560                 $this->getStackInstance()->pushNamed('current_node', 'footer-class');
561         }
562
563         /**
564          * Starts the menu property 'footer-text'
565          *
566          * @return      void
567          */
568         private function startFooterText () {
569                 // Push the node name on the stacker
570                 $this->getStackInstance()->pushNamed('current_node', 'footer-text');
571         }
572
573         /**
574          * Finishes the title node by added another template to the menu
575          *
576          * @return      void
577          */
578         private function finishTitle () {
579                 // Pop the last entry
580                 $this->getStackInstance()->popNamed('current_node');
581         }
582
583         /**
584          * Finishes the title-id node by
585          *
586          * @return      void
587          */
588         private function finishTitleId () {
589                 // Pop the last entry
590                 $this->getStackInstance()->popNamed('current_node');
591         }
592
593         /**
594          * Finishes the title-class node
595          *
596          * @return      void
597          */
598         private function finishTitleClass () {
599                 // Pop the last entry
600                 $this->getStackInstance()->popNamed('current_node');
601         }
602
603         /**
604          * Finishes the title-class node
605          *
606          * @return      void
607          */
608         private function finishTitleText () {
609                 // Pop the last entry
610                 $this->getStackInstance()->popNamed('current_node');
611         }
612
613         /**
614          * Finishes the footer-text node
615          *
616          * @return      void
617          */
618         private function finishFooterText () {
619                 // Pop the last entry
620                 $this->getStackInstance()->popNamed('current_node');
621         }
622
623         /**
624          * Finishes the footer-class node
625          *
626          * @return      void
627          */
628         private function finishFooterClass () {
629                 // Pop the last entry
630                 $this->getStackInstance()->popNamed('current_node');
631         }
632
633         /**
634          * Finishes the footer-id node
635          *
636          * @return      void
637          */
638         private function finishFooterId () {
639                 // Pop the last entry
640                 $this->getStackInstance()->popNamed('current_node');
641         }
642
643         /**
644          * Finishes the anchor-href node
645          *
646          * @return      void
647          */
648         private function finishAnchorHref () {
649                 // Pop the last entry
650                 $this->getStackInstance()->popNamed('current_node');
651         }
652
653         /**
654          * Finishes the anchor-title node
655          *
656          * @return      void
657          */
658         private function finishAnchorTitle () {
659                 // Pop the last entry
660                 $this->getStackInstance()->popNamed('current_node');
661         }
662
663         /**
664          * Finishes the anchor-text node
665          *
666          * @return      void
667          */
668         private function finishAnchorText () {
669                 // Pop the last entry
670                 $this->getStackInstance()->popNamed('current_node');
671         }
672
673         /**
674          * Finishes the anchor-id node
675          *
676          * @return      void
677          */
678         private function finishAnchorId () {
679                 // Pop the last entry
680                 $this->getStackInstance()->popNamed('current_node');
681         }
682
683         /**
684          * Finishes the anchor node
685          *
686          * @return      void
687          */
688         private function finishAnchor () {
689                 // Pop the last entry
690                 $this->getStackInstance()->popNamed('current_node');
691         }
692
693         /**
694          * Finishes the entry-id node
695          *
696          * @return      void
697          */
698         private function finishEntryId () {
699                 // Pop the last entry
700                 $this->getStackInstance()->popNamed('current_node');
701         }
702
703         /**
704          * Finishes the entry node
705          *
706          * @return      void
707          */
708         private function finishEntry () {
709                 // Pop the last entry
710                 $this->getStackInstance()->popNamed('current_node');
711
712                 // Render this menu entry
713                 $this->renderMenuEntry();
714         }
715
716         /**
717          * Finishes the block node
718          *
719          * @return      void
720          */
721         private function finishBlock () {
722                 // Pop the last entry
723                 $this->getStackInstance()->popNamed('current_node');
724
725                 // Render this menu block
726                 $this->renderMenuBlock();
727         }
728
729         /**
730          * Finishes the block-list node
731          *
732          * @return      void
733          */
734         private function finishBlockList () {
735                 // Pop the last entry
736                 $this->getStackInstance()->popNamed('current_node');
737         }
738
739         /**
740          * Finishes the menu entries
741          *
742          * @return      void
743          */
744         private function finishEntryList () {
745                 // Pop the last entry
746                 $this->getStackInstance()->popNamed('current_node');
747         }
748
749         /**
750          * Finishes the menu block header
751          *
752          * @return      void
753          */
754         private function finishBlockHeader () {
755                 // Pop the last entry
756                 $this->getStackInstance()->popNamed('current_node');
757         }
758
759         /**
760          * Finishes the menu block footer
761          *
762          * @return      void
763          */
764         private function finishBlockFooter () {
765                 // Pop the last entry
766                 $this->getStackInstance()->popNamed('current_node');
767         }
768
769         /**
770          * Finishes the menu
771          *
772          * @return      void
773          */
774         private function finishMenu () {
775                 // Pop the last entry
776                 $this->getStackInstance()->popNamed('current_node');
777         }
778
779         /**
780          * Renders this menu entry, as every block all variables got overwritten
781          * with data from next entry.
782          *
783          * @return      void
784          */
785         private function renderMenuEntry () {
786                 // Prepare template engine
787                 $templateInstance = $this->prepareTemplateInstance();
788
789                 // Load menu entry template
790                 $templateInstance->loadCodeTemplate('menu_entry');
791
792                 // Copy all variables over to it
793                 foreach ($this->menuEntryVariables as $variableName) {
794                         // Copy variable
795                         $variableValue = $this->readVariable($variableName);
796
797                         // Is the key 'anchor-href'?
798                         if ($variableName == 'anchor-href') {
799                                 // Expand variable with URL then
800                                 $variableValue = '{?base_url?}/' . $variableValue;
801                         } // END - if
802
803                         // ... into the instance
804                         $templateInstance->assignVariable($variableName, $variableValue);
805                 } // END - foreach
806
807                 // Compile template + variables
808                 $templateInstance->compileTemplate();
809                 $templateInstance->compileVariables();
810
811                 // Remember it here
812                 $this->menuEntries[$this->readVariable('entry_id')] = $templateInstance->getRawTemplateData();
813         }
814
815         /**
816          * Renders this menu block, as next block all data is overwritten with
817          * next block.
818          *
819          * @return      void
820          */
821         private function renderMenuBlock () {
822                 // Init block content
823                 $blockContent = implode('', $this->menuEntries);
824
825                 // Prepare template engine
826                 $templateInstance = $this->prepareTemplateInstance();
827
828                 // Load menu entry template
829                 $templateInstance->loadCodeTemplate('menu_block');
830
831                 // Copy all variables over to it
832                 foreach ($this->menuBlockVariables as $variableName) {
833                         // Copy variable
834                         $variableValue = $this->readVariable($variableName);
835
836                         // ... into the instance
837                         $templateInstance->assignVariable($variableName, $variableValue);
838                 } // END - foreach
839
840                 // Assign block content
841                 $templateInstance->assignVariable('block_content', $blockContent);
842
843                 // Compile template + variables
844                 $templateInstance->compileTemplate();
845                 $templateInstance->compileVariables();
846
847                 // Remember it here
848                 array_push($this->menuBlocks, $templateInstance->getRawTemplateData());
849
850                 // Reset rendered menu entries array
851                 $this->menuEntries = array();
852         }
853
854         /**
855          * "Getter" for menu content
856          *
857          * @return      $menuContent    Returned menu content
858          */
859         public function getMenuContent () {
860                 // Implode menuBlocks
861                 $menuContent = implode('', $this->menuBlocks);
862
863                 // Clean variable
864                 $this->menuBlocks = array();
865
866                 // And return it
867                 return $menuContent;
868         }
869
870         /**
871          * Getter for menu cache file instance
872          *
873          * @return      $fileInstance   Full-qualified file name of the menu cache
874          */
875         public function getMenuCacheFile () {
876                 // Get the application instance from registry
877                 $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
878
879                 // Get the file instance ready
880                 $fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s',
881                         FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path'),
882                         $applicationInstance->getAppShortName(),
883                         md5(
884                                 $this->getMenuInstance()->getMenuName() . ':' .
885                                 $this->__toString() . ':' .
886                                 $this->getMenuInstance()->__toString()
887                         ),
888                         $this->getMenuInstance()->getMenuType()
889                 ));
890
891                 // Return it
892                 return $fileInstance;
893         }
894
895 }