Fix for 'undefined variable cacheInstance', should be a field
[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, 2010 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  * @deprecated
11  * @todo                We should 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::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.)
37 );
38
39 // Cache base path/file here
40 $basePathFile = FrameworkConfiguration::getInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getInstance()->getConfigEntry('app_name');
41
42 // Is the directory there?
43 if (!is_dir($basePathFile)) {
44         // Not found.
45         trigger_error('Application ' . FrameworkConfiguration::getInstance()->getConfigEntry('app_name') . ' not found.');
46 } // END - if
47
48 // Load them all (try only)
49 foreach ($configAppIncludes as $appInc) {
50         // Skip starter in test mode
51         if (($appInc == 'starter') && (defined('TEST'))) {
52                 // Skip it here
53                 continue;
54         }
55
56         // Generate a FQFN for the helper class
57         $appFqFn = $basePathFile . '/' . $appInc . '.php';
58
59         // Does the include file exists?
60         if ((file_exists($appFqFn)) && (is_file($appFqFn)) && (is_readable($appFqFn))) {
61                 // Load it
62                 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - START\n";
63                 require($appFqFn);
64                 //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - END\n";
65         } elseif (FrameworkConfiguration::getInstance()->getConfigEntry('verbose_level') > 0) {
66                 // File is missing
67                 trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.",
68                         $appInc
69                 ));
70         }
71 }
72
73 // Remove variables from namespace, which we don't need
74 unset($appInc, $configAppIncludes, $appFqFn, $basePathFile);
75
76 // [EOF]
77 ?>