]> git.mxchange.org Git - shipsimu.git/blobdiff - application/selector/class_ApplicationSelector.php
Method constructor() removed, several small fixes
[shipsimu.git] / application / selector / class_ApplicationSelector.php
index cbfc91daa0c7be5a695017006b46f90d654bf34f..a7f3294d1f8458615fea5befad9c3cc703cf1ed7 100644 (file)
@@ -5,10 +5,24 @@
  * Please remember that this include file is being loaded *before* the class
  * loader is loading classes from "exceptions", "interfaces" and "main"!
  *
- * @todo       Extend a later BaseFrameworkApplication class
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
  *
- * @author     Roland Haeder <roland __NOSPAM__ [at] __REMOVE_ME__ mxchange [dot] org>
- * @version    0.1
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class ApplicationSelector extends BaseFrameworkSystem {
        /**
@@ -35,27 +49,17 @@ class ApplicationSelector extends BaseFrameworkSystem {
                ".htaccess"
        );
 
-       /**
-        * The language instance for the template loader
-        */
-       private $langInstance = null;
-
-       /**
-        * The file I/O instance for the template loader
-        */
-       private $fileIOInstance = null;
-
        /**
         * The private constructor. No direct instances can be created from this.
         *
         * @return      void
         */
-       private function __construct() {
+       protected function __construct() {
                // Call parent constructor
-               parent::constructor(__CLASS__);
+               parent::__construct(__CLASS__);
 
                // Set description
-               $this->setPartDescr("Applikationswechsler");
+               $this->setObjectDescription("Applikationswechsler");
 
                // Create unique ID number
                $this->createUniqueID();
@@ -76,7 +80,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         * @param               $fileIOInstance The file I/O instance
         * @return              $selInstance            An instance of ApplicationSelector
         */
-       public static function createApplicationSelector (ManageableLanguage $langInstance, FileIOHandler $fileIOInstance) {
+       public final static function createApplicationSelector (ManageableLanguage $langInstance, FileIOHandler $fileIOInstance) {
                // Get a new instance
                $selInstance = new ApplicationSelector();
 
@@ -109,84 +113,6 @@ class ApplicationSelector extends BaseFrameworkSystem {
                $this->loadedTemplates = new FrameworkArrayObject();
        }
 
-       /**
-        * Private getter for language instance
-        *
-        * @return      $langInstance   An instance to the language sub-system
-        */
-       private function getLanguageInstance () {
-               return $this->langInstance;
-       }
-
-       /**
-        * Private getter for file IO instance
-        *
-        * @return      $fileIOInstance An instance to the file I/O sub-system
-        */
-       private function getFileIOInstance () {
-               return $this->fileIOInstance;
-       }
-
-       /**
-        * Prepare the template engine (TemplateEngine by default) for a give
-        * application helper instance (ApplicationHelper by default).
-        *
-        * @param               $appInstance    An application helper instance
-        * @return              $tplEngine      The template engine instance
-        * @throws              NullPointerException    If the template engine could not
-        *                                                                              be initialized
-        * @throws              NoObjectException               If $tplEngine is not an object
-        * @throws              MissingMethodException  If $tplEngine misses a required
-        *                                                                              method 'loadWebTemplate()'
-        */
-       private function prepareTemplateEngine (BaseFrameworkSystem $appInstance) {
-               // Generate FQFN for all application templates
-               $fqfn = sprintf("%s%s/%s/%s",
-                       PATH,
-                       $this->getConfigInstance()->readConfig("application_path"),
-                       strtolower($appInstance->getAppShortName()),
-                       $this->getConfigInstance()->readConfig("tpl_base_path")
-               );
-
-               // Initialize the template engine
-               $tplEngine = null;
-               $eval = sprintf("\$tplEngine = %s::create%s(
-       \"%s\",
-       \$this->getLanguageInstance(),
-       \$this->getFileIOInstance()
-);",
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
-                       $fqfn
-               );
-
-               // Debug message
-               if ((!is_null($this->getDebugInstance())) && (defined('DEBUG_EVAL'))) {
-                       $this->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
-                               $this->__toString(),
-                               htmlentities($eval)
-                       ));
-               }
-
-               // Run the command
-               @eval($eval);
-
-               // Is it a valid instance?
-               if (is_null($tplEngine)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($tplEngine)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($tplEngine, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($tplEngine, 'loadWebTemplate')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($tplEngine, 'loadWebTemplate'), self::EXCEPTION_MISSING_METHOD);
-               }
-
-               // Return the prepared instance
-               return $tplEngine;
-       }
-
        /**
         * Load the init.php script of an application and append the application
         * instance to $foundApps
@@ -231,7 +157,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         *
         * @param               $tplEngine      An instance of TemplateEngine
         */
-       private function setSelectorTemplateEngine (CompileableTemplate $tplEngine) {
+       private final function setSelectorTemplateEngine (CompileableTemplate $tplEngine) {
                $this->selectorTplEngine = $tplEngine;
        }
 
@@ -240,7 +166,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         *
         * @return      $selectTplEngine        The selector's template engine
         */
-       private function getSelectorTemplateEngine () {
+       private final function getSelectorTemplateEngine () {
                return $this->selectorTplEngine;
        }
 
@@ -250,7 +176,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         * @return      $loadedTemplates        An array object holding all loaded
         *                                                      application templates
         */
-       private function getLoadedTemplates () {
+       private final function getLoadedTemplates () {
                return $this->loadedTemplates;
        }
 
@@ -259,7 +185,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         *
         * @return      $shortName      This selector's short name
         */
-       private function getAppShortName() {
+       public function getAppShortName() {
                $shortName = $this->getConfigInstance()->readConfig("selector_path");
                return $shortName;
        }
@@ -276,27 +202,6 @@ class ApplicationSelector extends BaseFrameworkSystem {
                $this->dirIgnoreList[] = $ignoreItem;
        }
 
-       /**
-        * Setter for language instance
-        *
-        * @param               $langInstance   An instance to the language sub-system
-        * @return      void
-        * @see         LanguageSystem
-        */
-       public final function setLanguageInstance (ManageableLanguage $langInstance) {
-               $this->langInstance = $langInstance;
-       }
-
-       /**
-        * Setter for file I/O instance
-        *
-        * @param               $fileIOInstance An instance to the file I/O sub-system
-        * @return      void
-        */
-       public final function setFileIOInstance (FileIOHandler $fileIOInstance) {
-               $this->fileIOInstance = $fileIOInstance;
-       }
-
        /**
         * Read the base path for all applications (application/) and create a
         * list of all found applications
@@ -381,7 +286,7 @@ class ApplicationSelector extends BaseFrameworkSystem {
         *
         * @return      void
         */
-       public function removeDirIgnoreList () {
+       public final function removeDirIgnoreList () {
                unset($this->dirIgnoreList);
        }