X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Ftemplate%2Fmenu%2Fclass_MenuTemplateEngine.php;h=7b638fbffeb1cdda9d2ef2ba9b18ee5a4bced7ba;hb=2e80331da79b13c3094f9039d4c584e3e4b89894;hp=59d1eeef2492e67db63051978e4aa31ab88e3bed;hpb=84e2207412d3c6ea9f940a83b2cdd4503509808a;p=core.git diff --git a/inc/classes/main/template/menu/class_MenuTemplateEngine.php b/inc/classes/main/template/menu/class_MenuTemplateEngine.php index 59d1eeef..7b638fbf 100644 --- a/inc/classes/main/template/menu/class_MenuTemplateEngine.php +++ b/inc/classes/main/template/menu/class_MenuTemplateEngine.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -60,7 +60,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla /** * Menu instance */ - private $menuInstance = null; + private $menuInstance = NULL; /** * Current main node @@ -85,9 +85,8 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla /** * Creates an instance of the class TemplateEngine and prepares it for usage * - * @param $appInstance A manageable application - * @param $menuInstance A RenderableMenu instance - * @return $templateInstance An instance of TemplateEngine + * @param $menuInstance A RenderableMenu instance + * @return $templateInstance An instance of TemplateEngine * @throws BasePathIsEmptyException If the provided $templateBasePath is empty * @throws InvalidBasePathStringException If $templateBasePath is no string * @throws BasePathIsNoDirectoryException If $templateBasePath is no @@ -95,16 +94,15 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @throws BasePathReadProtectedException If $templateBasePath is * read-protected */ - public final static function createMenuTemplateEngine (ManageableApplication $appInstance, RenderableMenu $menuInstance) { + public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) { // Get a new instance $templateInstance = new MenuTemplateEngine(); - // Get language and file I/O instances from application - $langInstance = $appInstance->getLanguageInstance(); - $ioInstance = $appInstance->getFileIoInstance(); + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/'; + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; // Is the base path valid? if (empty($templateBasePath)) { @@ -121,22 +119,15 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); } - // Get configuration instance - $configInstance = FrameworkConfiguration::getInstance(); - // Set the base path $templateInstance->setTemplateBasePath($templateBasePath); - // Set the language and IO instances - $templateInstance->setLanguageInstance($langInstance); - $templateInstance->setFileIoInstance($ioInstance); - // Set template extensions - $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('menu_template_extension')); + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('menu_template_extension')); // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path')); + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); // Set the menu instance $templateInstance->setMenuInstance($menuInstance); @@ -248,7 +239,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @return void * @throws XmlNodeMismatchException If current main node mismatches the closing one */ - public function endElement ($resource, $nodeName) { + public function finishElement ($resource, $nodeName) { // Make all lower-case $nodeName = strtolower($nodeName); @@ -282,7 +273,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla // Is this string empty? if (empty($characters)) { // Then skip it silently - return false; + return; } // END - if // Assign the found characters to variable and use the last entry from @@ -301,15 +292,15 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla // Is the template dependency set? if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { // Get a temporay menu template instance - $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getApplicationInstance(), $this->getMenuInstance())); + $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getMenuInstance())); // Then load it $templateInstance->loadMenuTemplate($templateDependency); - // Get an XmlParser instance + // Parse the XML content $templateInstance->renderXmlContent(); - // Parse the template's content contents + // Save the parsed raw content in our dependency array $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); } // END - if } @@ -335,7 +326,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla /** * Starts the menu entries * - * @param $templateDependency A template to load to satisfy dependencies + * @param $templateDependency A template to load to satisfy dependencies * @return void */ private function startEntryList () {