3 namespace CoreFramework\Menu;
5 // Import framework stuff
6 use CoreFramework\Object\BaseFrameworkSystem;
9 * A general menu system class
11 * @author Roland Haeder <webmaster@shipsimu.org>
13 * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software
14 * @license GNU GPL 3.0 or any newer version
15 * @link http://www.shipsimu.org
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class BaseMenu extends BaseFrameworkSystem {
32 * Protected constructor
34 * @param $className Name of the class
37 protected function __construct ($className) {
38 // Call parent constructor
39 parent::__construct($className);
43 * Renders the menu by loading the base template and a menu-specific
48 public function renderMenu () {
49 // Initialize the menu system by preparing it's template instance
50 $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this));
52 // Set it for later use
53 $this->setTemplateInstance($templateInstance);
55 // Load the menu template for all
56 $templateInstance->loadMenuTemplate('generic_menu_entries');
58 // Get the 'command' from request instance
59 $command = $this->getApplicationInstance()->getRequestInstance()->getRequestElement('command');
61 // If page is empty, choose default
62 if (empty($command)) {
63 // Use default page as none has been specified
64 $command = $this->getConfigInstance()->getConfigEntry('default_' . $this->getApplicationInstance()->getAppShortName() . '_' . self::getResponseTypeFromSystem() . '_command');
67 // Load the menu template for this page
69 $templateInstance->loadMenuTemplate($command . '_menu_entries');
70 } catch (FileNotFoundException $e) {
71 // Log exception @TODO Maybe to intrusive?
72 self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Exception caught: ' . $e->__toString() . ', with message: ' . $e->getMessage());
75 // Render template data here
76 $templateInstance->renderXmlContent();
77 //exit(__METHOD__ . ':!OK');
81 * Transfers the rendered menu to a given template engine by assigning
82 * the rendered content with a template variable.
84 * @param $templateInstance An instance of a CompileableTemplate class
87 public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) {
88 // Assign menu content to variable
89 $templateInstance->assignVariable('menu', $this->getTemplateInstance()->getMenuContent());
90 //* DEBUG */ $templateInstance->debugInstance();