*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @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
+ * @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
*/
private $classCacheFQFN = "";
+ /**
+ * Counter for loaded include files
+ */
+ private $total = 0;
+
/**
* The *public* constructor
*
// If the basePath is false it is invalid
if ($basePath2 === false) {
- // TODO: Do not die here.
+ /* @todo: Do not die here. */
die("Cannot read {$basePath} !");
} else {
// Set base path
// Load all classes from the config directory
$this->loadClasses($basePath);
+ // Include these extra configs now
+ $this->includeExtraConfigs();
+
// Set the prefix back
$this->prefix = $oldPrefix;
$this->prefixLen = strlen($this->prefix);
+
}
/**
// Now look it up in our index
if (isset($this->classes[$fileName])) {
// File is found so load it only once
+ //* DEBUG: */ echo "LOAD: ".$fileName." - Start<br />\n";
require($this->classes[$fileName]);
+ //* DEBUG: */ echo "LOAD: ".$fileName." - End<br />\n";
+
+ // Count this include
+ $this->total++;
+
+ // Mark this class as loaded
+ $this->loadedClasses[] = $this->classes[$fileName];
// Developer mode excludes caching (better debugging)
if (!defined('DEVELOPER')) {
- // Mark this class as loaded
- $this->loadedClasses[] = $this->classes[$fileName];
-
// Reset cache
$this->classesCached = false;
} // END - if
} // END - if
}
+
+ /**
+ * Includes all extra config files
+ *
+ * @return void
+ */
+ private function includeExtraConfigs () {
+ // Run through all class names (should not be much)
+ foreach ($this->classes as $fileName=>$fqfn) {
+ // Is this a config?
+ if (substr($fileName, 0, $this->prefixLen) == $this->prefix) {
+ // Then include it
+ require($fqfn);
+
+ // Remove it from the list
+ unset($this->classes[$fileName]);
+ } // END - if
+ } // END - foreach
+ }
+
+ /**
+ * Getter for total include counter
+ *
+ * @return $total Total loaded include files
+ */
+ public final function getTotal () {
+ return $this->total;
+ }
+
+ /**
+ * Getter for a printable list of included classes/interfaces/exceptions
+ *
+ * @param $includeList A printable include list
+ */
+ public function getPrintableIncludeList () {
+ // Prepare the list
+ $includeList = "";
+ foreach ($this->loadedClasses as $classFile) {
+ $includeList .= basename($classFile)."<br />\n";
+ } // END - foreach
+
+ // And return it
+ return $includeList;
+ }
}
// [EOF]