]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/template/class_BaseXmlTemplateEngine.php
Better use isReadableFile() instead of plain is_readable() is the later will
[hub.git] / application / hub / main / template / class_BaseXmlTemplateEngine.php
index 2cb598f38bafa944ebc3d3535131b6771fe82ede..676e09b005dfcba3c5110e38a0143fc03b87f07f 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A generic XML template engine class
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  * @todo               This template engine does not make use of setTemplateType()
  *
  * This program is free software: you can redistribute it and/or modify
@@ -26,17 +26,17 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
        /**
         * Main nodes in the XML tree
         */
-       protected $mainNodes = array();
+       private $mainNodes = array();
 
        /**
         * Sub nodes in the XML tree
         */
-       protected $subNodes = array();
+       private $subNodes = array();
 
        /**
         * Current main node
         */
-       protected $curr = array();
+       private $curr = array();
 
        /**
         * XML template type
@@ -99,7 +99,7 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
-               } elseif (!is_readable($templateBasePath)) {
+               } elseif (!BaseFrameworkSystem::isReadableFile($templateBasePath)) {
                        // Is not readable
                        throw new BasePathReadProtectedException(array($this, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
@@ -115,16 +115,16 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                $this->setCompileOutputPath($this->getConfigInstance()->getConfigEntry('base_path') . $this->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Init a variable stacker
-               $stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
+               $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
 
                // Set name
                $this->stackerName = $typePrefix . '_' . $xmlTemplateType;
 
                // Init stacker
-               $stackerInstance->initStacker($this->stackerName);
+               $stackInstance->initStack($this->stackerName);
 
                // Set it
-               $this->setStackerInstance($stackerInstance);
+               $this->setStackInstance($stackInstance);
 
                // Set XML template type and prefix
                $this->xmlTemplateType = $xmlTemplateType;
@@ -191,6 +191,16 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                return $this->stackerName;
        }
 
+       /**
+        * Setter for sub node array
+        *
+        * @param       $subNodes       Array with valid sub node names
+        * @return      void
+        */
+       public final function setSubNodes (array $subNodes) {
+               $this->subNodes = $subNodes;
+       }
+
        /**
         * Getter for sub node array
         *
@@ -211,19 +221,25 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                // Read the variable
                $value = parent::readVariable($key, 'general');
 
+               // Is this null?
+               if (is_null($value)) {
+                       // Bah, needs fixing.
+                       $this->debugInstance('key=' . $key . ' returns NULL');
+               } // END - if
+
                // Return value
                return $value;
        }
 
        /**
-        * Handles the template dependency for given node
+        * Handles the template dependency for given XML node
         *
-        * @param       $node                                   The node we should load a dependency template
+        * @param       $node                                   The XML node we should load a dependency template
         * @param       $templateDependency             A template to load to satisfy dependencies
         * @return      void
         */
        protected function handleTemplateDependency ($node, $templateDependency) {
-               // Check that node is not empty
+               // Check that the XML node is not empty
                assert(!empty($node));
 
                // Is the template dependency set?