Application init phase rewritten, data.php now sets app data
authorRoland Häder <roland@mxchange.org>
Fri, 3 Oct 2008 01:00:31 +0000 (01:00 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 3 Oct 2008 01:00:31 +0000 (01:00 +0000)
18 files changed:
.gitattributes
application/blog/data.php [new file with mode: 0644]
application/blog/init.php
application/selector/class_ApplicationSelector.php
application/selector/data.php [new file with mode: 0644]
application/selector/init.php
application/ship-simu/data.php [new file with mode: 0644]
application/ship-simu/init.php
application/shoutbox/data.php [new file with mode: 0644]
application/shoutbox/init.php
application/todo/data.php [new file with mode: 0644]
application/todo/init.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/factories/objects/class_ObjectFactory.php
inc/database.php
inc/file_io.php
inc/language.php
inc/selector.php

index 616fec235baa36391f471e551df6fc430534be4e..e57ab49e7955ef1018f98aa6c73e7cf3e4d4cbf4 100644 (file)
@@ -4,6 +4,7 @@ application/.htaccess -text
 application/blog/.htaccess -text
 application/blog/class_ApplicationHelper.php -text
 application/blog/config.php -text
+application/blog/data.php -text
 application/blog/debug.php -text
 application/blog/exceptions.php -text
 application/blog/exceptions/.htaccess -text
@@ -47,6 +48,7 @@ application/selector/.htaccess -text
 application/selector/class_ApplicationHelper.php -text
 application/selector/class_ApplicationSelector.php -text
 application/selector/config.php -text
+application/selector/data.php -text
 application/selector/debug.php -text
 application/selector/exceptions.php -text
 application/selector/init.php -text
@@ -60,6 +62,7 @@ application/selector/templates/de/code/selector_main.ctp -text
 application/ship-simu/.htaccess -text
 application/ship-simu/class_ApplicationHelper.php -text
 application/ship-simu/config.php -text
+application/ship-simu/data.php -text
 application/ship-simu/debug.php -text
 application/ship-simu/exceptions.php -text
 application/ship-simu/exceptions/.htaccess -text
@@ -236,6 +239,7 @@ application/ship-simu/templates/images/de/image/code_captcha.itp -text
 application/shoutbox/.htaccess -text
 application/shoutbox/class_ApplicationHelper.php -text
 application/shoutbox/config.php -text
+application/shoutbox/data.php -text
 application/shoutbox/debug.php -text
 application/shoutbox/exceptions.php -text
 application/shoutbox/exceptions/.htaccess -text
@@ -278,6 +282,7 @@ application/shoutbox/templates/images/de/image/code_captcha.itp -text
 application/todo/.htaccess -text
 application/todo/class_ApplicationHelper.php -text
 application/todo/config.php -text
+application/todo/data.php -text
 application/todo/debug.php -text
 application/todo/exceptions.php -text
 application/todo/exceptions/.htaccess -text
diff --git a/application/blog/data.php b/application/blog/data.php
new file mode 100644 (file)
index 0000000..e89cd58
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Application data
+ *
+ * Please remember that this include file is being loaded *before* the class
+ * loader is loading classes from "exceptions", "interfaces" and "main"!
+ *
+ * You can prevent adding this application to the selector by uncommenting the
+ * following line:
+ *
+ * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; }
+ *
+ * isset() is required to prevent a warning and is_object() is highly required
+ * when the application itself is requested in URL (hint: index.php?app=your_app)
+ *
+ * @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
+ *
+ * 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/>.
+ */
+
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// Get an instance of the helper
+$app = call_user_func_array(
+       array($cfg->readConfig('app_helper_class'), "getInstance"),
+       array()
+);
+
+// Set application name and version
+$app->setAppName("Nameless Blogging Software");
+$app->setAppVersion("0.0.0");
+$app->setAppShortName("blog");
+
+// [EOF]
+?>
index fa7aee2cfa0b057e2873aea05883a0645b6d8b62..39c5bed007acfcb599fb0edf378e27f513a2df07 100644 (file)
@@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php');
 // the inc/database.php script
 require($cfg->readConfig('base_path') . 'inc/database.php');
 
-// Generate call-back function
-$callback = sprintf("%s::getInstance",
-       FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
-);
-
-// Get an instance of the helper
-$app = call_user_func_array($callback, array());
-
-// Set application name and version
-$app->setAppName("Nameless Blogging Software");
-$app->setAppVersion("0.0.0");
-$app->setAppShortName("blog");
-
-// Set instances
-$app->setFileIoInstance($io);
-$app->setLanguageInstance($lang);
-$app->setDatabaseInstance($db);
-
 // [EOF]
 ?>
index 0d366b78a6b812b3f844369496b1690062cb8787..f52b50a8fe16b3debf369defca694a9318e0fbc5 100644 (file)
@@ -109,18 +109,18 @@ class ApplicationSelector extends BaseFrameworkSystem {
        }
 
        /**
-        * Load the init.php script of an application and append the application
+        * Load the data.php script of an application and append the application
         * instance to $foundApps
         *
-        * @param       $initScript     The FQFN of init.php
+        * @param       $appData                The FQFN of data.php
         * @param       $appName                The application's Uni* name
         * @return      void
         */
-       private function loadInitScript ($initScript, $appName) {
+       private function loadApplicationData ($appData, $appName) {
                // Is it a file and readable?
-               if ((is_file($initScript)) && (is_readable($initScript))) {
+               if ((is_file($appData)) && (is_readable($appData))) {
                        // Then include it
-                       include ($initScript);
+                       include ($appData);
 
                        // Add the current instance to the list
                        $this->foundApps->append($app);
@@ -206,15 +206,13 @@ class ApplicationSelector extends BaseFrameworkSystem {
 
                        // Is this a readable directory? (files will be ignored silently)
                        if ((is_dir($fqfn)) && (is_readable($fqfn))) {
-                               // Then get the init.php script for analyzing
-                               $initScript = sprintf("%s/init.php", $fqfn);
+                               // Then get the data.php script for analyzing
+                               $appData = sprintf("%s/data.php", $fqfn);
 
-                               // Load the application's init.php script and append the
+                               // Load the application's data.php script and append the
                                // application to the ArrayObject
-                               $this->loadInitScript($initScript, $appName);
-
-                       } // END - if ((is_dir(...
-
+                               $this->loadApplicationData($appData, $appName);
+                       } // END - if
                } // END - while
 
                // Close directory pointer
diff --git a/application/selector/data.php b/application/selector/data.php
new file mode 100644 (file)
index 0000000..29d47ef
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Application data
+ *
+ * Please remember that this include file is being loaded *before* the class
+ * loader is loading classes from "exceptions", "interfaces" and "main"!
+ *
+ * @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
+ *
+ * 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/>.
+ */
+
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// Get an instance of the helper
+$app = call_user_func_array(
+       array($cfg->readConfig('app_helper_class'), "getInstance"),
+       array()
+);
+
+// Set application name and version
+$app->setAppName("Applikationsausw&auml;hler");
+$app->setAppVersion("0.1a");
+$app->setAppShortName($cfg->readConfig('selector_name'));
+
+// [EOF]
+?>
index 71893f0d51b84dcae7c86ed88e2cf9ff36a68f2f..3b9e2db0a998a4b847a9d69f6aafd8845bbe6b27 100644 (file)
@@ -37,22 +37,5 @@ require($cfg->readConfig('base_path') . 'inc/file_io.php');
 // Include the language sub-system
 require($cfg->readConfig('base_path') . 'inc/language.php');
 
-// Generate call-back function
-$callback = sprintf("%s::getInstance",
-       FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
-);
-
-// Get an instance of the helper
-$app = call_user_func_array($callback, array());
-
-// Set application name and version
-$app->setAppName("Applikationsausw&auml;hler");
-$app->setAppVersion("0.1a");
-$app->setAppShortName(FrameworkConfiguration::getInstance()->readConfig('selector_name'));
-
-// Set instances
-$app->setFileIoInstance($io);
-$app->setLanguageInstance($lang);
-
 // [EOF]
 ?>
diff --git a/application/ship-simu/data.php b/application/ship-simu/data.php
new file mode 100644 (file)
index 0000000..0ec07a0
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Application data
+ *
+ * Please remember that this include file is being loaded *before* the class
+ * loader is loading classes from "exceptions", "interfaces" and "main"!
+ *
+ * You can prevent adding this application to the selector by uncommenting the
+ * following line:
+ *
+ * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; }
+ *
+ * isset() is required to prevent a warning and is_object() is highly required
+ * when the application itself is requested in URL (hint: index.php?app=your_app)
+ *
+ * @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
+ *
+ * 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/>.
+ */
+
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// Get an instance of the helper
+$app = call_user_func_array(
+       array($cfg->readConfig('app_helper_class'), "getInstance"),
+       array()
+);
+
+// Set application name and version
+$app->setAppName("Ship-Simu Schiffsimulator");
+$app->setAppVersion("0.0.0");
+$app->setAppShortName("ship-simu");
+
+// [EOF]
+?>
index 7b65cae15d40085de6d9e82e81395a42a75f9f79..39c5bed007acfcb599fb0edf378e27f513a2df07 100644 (file)
@@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php');
 // the inc/database.php script
 require($cfg->readConfig('base_path') . 'inc/database.php');
 
-// Generate call-back function
-$callback = sprintf("%s::getInstance",
-       FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
-);
-
-// Get an instance of the helper
-$app = call_user_func_array($callback, array());
-
-// Set application name and version
-$app->setAppName("Ship-Simu Schiffsimulator");
-$app->setAppVersion("0.0.0");
-$app->setAppShortName("ship-simu");
-
-// Set instances
-$app->setFileIoInstance($io);
-$app->setLanguageInstance($lang);
-$app->setDatabaseInstance($db);
-
 // [EOF]
 ?>
diff --git a/application/shoutbox/data.php b/application/shoutbox/data.php
new file mode 100644 (file)
index 0000000..d97c702
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Application data
+ *
+ * Please remember that this include file is being loaded *before* the class
+ * loader is loading classes from "exceptions", "interfaces" and "main"!
+ *
+ * You can prevent adding this application to the selector by uncommenting the
+ * following line:
+ *
+ * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; }
+ *
+ * isset() is required to prevent a warning and is_object() is highly required
+ * when the application itself is requested in URL (hint: index.php?app=your_app)
+ *
+ * @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
+ *
+ * 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/>.
+ */
+
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// Get an instance of the helper
+$app = call_user_func_array(
+       array($cfg->readConfig('app_helper_class'), "getInstance"),
+       array()
+);
+
+// Set application name and version
+$app->setAppName("Nameless Blogging Software");
+$app->setAppVersion("0.0.0");
+$app->setAppShortName("shoutbox");
+
+// [EOF]
+?>
index 117b295fa71168ce3e63d0621bdccc0ac3eaffe4..39c5bed007acfcb599fb0edf378e27f513a2df07 100644 (file)
@@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php');
 // the inc/database.php script
 require($cfg->readConfig('base_path') . 'inc/database.php');
 
-// Generate call-back function
-$callback = sprintf("%s::getInstance",
-       FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
-);
-
-// Get an instance of the helper
-$app = call_user_func_array($callback, array());
-
-// Set application name and version
-$app->setAppName("Nameless Blogging Software");
-$app->setAppVersion("0.0.0");
-$app->setAppShortName("shoutbox");
-
-// Set instances
-$app->setFileIoInstance($io);
-$app->setLanguageInstance($lang);
-$app->setDatabaseInstance($db);
-
 // [EOF]
 ?>
diff --git a/application/todo/data.php b/application/todo/data.php
new file mode 100644 (file)
index 0000000..df4b3bf
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Application data
+ *
+ * Please remember that this include file is being loaded *before* the class
+ * loader is loading classes from "exceptions", "interfaces" and "main"!
+ *
+ * You can prevent adding this application to the selector by uncommenting the
+ * following line:
+ *
+ * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; }
+ *
+ * isset() is required to prevent a warning and is_object() is highly required
+ * when the application itself is requested in URL (hint: index.php?app=your_app)
+ *
+ * @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
+ *
+ * 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/>.
+ */
+
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
+// Get an instance of the helper
+$app = call_user_func_array(
+       array($cfg->readConfig('app_helper_class'), "getInstance"),
+       array()
+);
+
+// Set application name and version
+$app->setAppName("OpenToDo");
+$app->setAppVersion("0.0.0");
+$app->setAppShortName("todo");
+
+// [EOF]
+?>
index c8d19e32ee8c750503426332405023da04dfd620..39c5bed007acfcb599fb0edf378e27f513a2df07 100644 (file)
@@ -49,23 +49,5 @@ require($cfg->readConfig('base_path') . 'inc/language.php');
 // the inc/database.php script
 require($cfg->readConfig('base_path') . 'inc/database.php');
 
-// Generate call-back function
-$callback = sprintf("%s::getInstance",
-       FrameworkConfiguration::getInstance()->readConfig('app_helper_class')
-);
-
-// Get an instance of the helper
-$app = call_user_func_array($callback, array());
-
-// Set application name and version
-$app->setAppName("OpenToDo");
-$app->setAppVersion("0.0.0");
-$app->setAppShortName("todo");
-
-// Set instances
-$app->setFileIoInstance($io);
-$app->setLanguageInstance($lang);
-$app->setDatabaseInstance($db);
-
 // [EOF]
 ?>
index 38e689b1666c3969da6b5627ba959fcfd8557a09..006a6b46673839b3d18b7be4386c6fca2cc300e7 100644 (file)
@@ -269,6 +269,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        private final function initInstance () {
                // Is this a system class?
                if (!in_array($this->__toString(), $this->systemClasses)) {
+                       // Set configuration instance
+                       $this->setConfigInstance(FrameworkConfiguration::getInstance());
+
                        // Add application helper to our class
                        $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class');
 
index 06c73d89c4e1e09a9143743ffdca642cbac5db8a..0848e79fabd832f0405555e47de65481b1629c57 100644 (file)
@@ -64,14 +64,13 @@ class ObjectFactory extends BaseFactory {
                        throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
-               // Then Prepare the call-back function
-               $callback = sprintf("%s::create%s",
-                       $className,
+               // Create method name
+               $methodName = sprintf("create%s",
                        $className
                );
 
                // Run the user function
-               $objectInstance = call_user_func_array($callback, $args);
+               $objectInstance = call_user_func_array(array($className, $methodName), $args);
 
                // Count generated objects up
                self::$total++;
index f274f6c65b2a0dd8857a5e0cc0b0ff28bb073b07..52d7506032cc4ae0fdb093a9334b7ae664fe9357 100644 (file)
@@ -77,6 +77,9 @@ try {
        ));
 }
 
+// Is the app variable there and valid?
+if (is_object($app)) $app->setDatabaseInstance($db);
+
 // Datenbankobjekt debuggen
 if (defined('DEBUG_DATABASE_OBJ')) {
        DebugMiddleware::getInstance()->output(sprintf("The database sub-system does now look like this:<br />
index 0a5ec9b4c36f4cd86e7c1d1343700a9c5f914a78..c141feabd932d109637b53179e53cdfb3ef88fdb 100644 (file)
@@ -27,5 +27,8 @@
 // Get the instance
 $io = ObjectFactory::createObjectByConfiguredName('file_io_class');
 
+// Is the app variable there and valid?
+if (is_object($app)) $app->setFileIoInstance($io);
+
 // [EOF]
 ?>
index 6db17c0ba7bb4ec55caf0da4b4ad868de3734dbf..b9250e59738f4b3b1921532b1facca6b7694ffcd 100644 (file)
@@ -43,5 +43,8 @@ try {
        ));
 }
 
+// Is the app variable there and valid?
+if (is_object($app)) $app->setLanguageInstance($lang);
+
 // [EOF]
 ?>
index 819485e26dcc0bedae9c96bd88cf0d851d340f8b..d20cbcb04abcd0c14fa5a5b6fa182142a5395d43 100644 (file)
@@ -29,6 +29,7 @@ $cfg = FrameworkConfiguration::getInstance();
 $configAppIncludes = array(
        sprintf("class_%s", $cfg->readConfig('app_helper_class')), // The ApplicationHelper class
        "config",               // The application's own configuration
+       "data",                 // Application data
        "init",                 // The application initializer
        "loader",               // The application's class loader
        "debug",                // Some debugging stuff