コード例 #1
0
 /**
  * Load and initialize any modules from a list
  *
  * @param array $ModuleList List of modules. $key is name, $value is path
  */
 public static function loadModules()
 {
     global $NAVBAR;
     global $HTMLHead;
     self::$ModuleList = self::getModulesFromPath(CODON_MODULES_PATH);
     if (empty(self::$ModuleList)) {
         Debug::showCritical('No modules were found in module path! (' . CODON_MODULES_PATH . ')');
         return;
     }
     self::$listSize = sizeof(self::$ModuleList);
     self::$keys = array_keys(self::$ModuleList);
     for ($i = 0; $i < self::$listSize; $i++) {
         $ModuleName = self::$keys[$i];
         $ModuleController = self::$ModuleList[$ModuleName];
         if (file_exists($ModuleController)) {
             include_once $ModuleController;
             if (class_exists($ModuleName)) {
                 $ModuleName = strtoupper($ModuleName);
                 global ${$ModuleName};
                 ${$ModuleName} = new $ModuleName();
                 ${$ModuleName}->init($ModuleName);
                 // Call the parent constructor
                 if (self::$activeModule == $ModuleName) {
                     # Skip it for now, run it last since it's the active
                     #	one, and may overwrite some other parameters
                     continue;
                 } else {
                     ob_start();
                     self::Run($ModuleName, 'NavBar');
                     $NAVBAR .= ob_get_clean();
                     self::Run($ModuleName, 'HTMLHead');
                     $HTMLHead .= ob_get_clean();
                     @ob_end_clean();
                 }
             }
         }
     }
     # Run the init tasks
     ob_start();
     self::Run(self::$activeModule, 'NavBar');
     $NAVBAR .= ob_get_clean();
     self::Run(self::$activeModule, 'HTMLHead');
     $HTMLHead .= ob_get_clean();
     @ob_end_clean();
 }