3 * The application selector main include file
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * @todo We should minimize these includes
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 // Try to load these includes in the given order
28 $configAppIncludes = array(
29 'class_' . FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class
30 'debug', // Some debugging stuff
31 'exceptions', // The application's own exception handler
32 'loader', // The application's class loader
33 'config', // The application's own configuration
34 'data', // Application data
35 'init', // The application initializer
36 'starter', // The application starter (calls entryPoint(), etc.)
39 // Cache base path/file here
40 $basePathFile = FrameworkConfiguration::getInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getInstance()->getConfigEntry('app_name');
42 // Is the directory there?
43 if (!is_dir($basePathFile)) {
45 trigger_error('Application ' . FrameworkConfiguration::getInstance()->getConfigEntry('app_name') . ' not found.');
48 // Load them all (try only)
49 foreach ($configAppIncludes as $appInc) {
50 // Skip starter in test mode
51 if (($appInc == 'starter') && (defined('TEST'))) {
56 // Generate a FQFN for the helper class
57 $appFqFn = $basePathFile . '/' . $appInc . '.php';
59 // Does the include file exists?
60 if ((file_exists($appFqFn)) && (is_file($appFqFn)) && (is_readable($appFqFn))) {
62 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - START\n";
64 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - END\n";
65 } elseif (FrameworkConfiguration::getInstance()->getConfigEntry('verbose_level') > 0) {
67 trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.",
73 // Remove variables from namespace, which we don't need
74 unset($appInc, $configAppIncludes, $appFqFn, $basePathFile);