Opps :(
[core.git] / inc / selector.php
1 <?php
2 /**
3  * The application selector main include file
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  * @deprecated
11  * @todo                Minimize these includes
12  *
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.
17  *
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.
22  *
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/>.
25  */
26
27 // Try to load these includes in the given order
28 $configAppIncludes = array(
29         'class_' . FrameworkConfiguration::getSelfInstance()->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         'config-local', // Local configuration file (optional)
35         'data',                 // Application data
36         'init',                 // The application initializer
37         'starter',              // The application starter (calls entryPoint(), etc.)
38 );
39
40 // Cache base path/file here
41 $basePathFile = FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name');
42
43 // Is the directory there?
44 if (!is_dir($basePathFile)) {
45         // Not found.
46         trigger_error('Application ' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name') . ' not found.');
47 } // END - if
48
49 // Load them all (try only)
50 foreach ($configAppIncludes as $appInc) {
51         // Skip starter in test mode
52         if (($appInc == 'starter') && (defined('TEST'))) {
53                 // Skip it here
54                 continue;
55         } // END - if
56
57         // Generate a FQFN for the helper class
58         $appFqFn = $basePathFile . '/' . $appInc . '.php';
59
60         // Does the include file exists?
61         if ((file_exists($appFqFn)) && (is_file($appFqFn)) && (is_readable($appFqFn))) {
62                 // Load it
63                 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - START\n";
64                 require($appFqFn);
65                 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - END\n";
66         } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('verbose_level') > 0) {
67                 // File is missing
68                 trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.",
69                         $appInc
70                 ));
71         }
72 }
73
74 // Remove variables from namespace, which we don't need
75 unset($appInc);
76 unset($configAppIncludes);
77 unset($appFqFn);
78 unset($basePathFile);
79
80 // [EOF]
81 ?>