System = &$System; $this->Database = &$System->Database; $this->Installed = false; $this->Dependencies = array(); $this->Type = ModuleType::Normal; } function Install() { } function Uninstall() { } function Start() { } function Stop() { } } class AppModuleManager { var $Modules; var $System; var $OnLoadModules; function __construct($System) { $this->Modules = array(); $this->System = &$System; } function StartAll() { foreach($this->Modules as $Index => $Module) { //DebugLog('Init module '.$Module->Name); $this->Modules[$Index]->Start(); } } function StopAll() { foreach($this->Modules as $Index => $Module) { //DebugLog('Init module '.$Module->Name); $this->Modules[$Index]->Stop(); } } function ModulePresent($Name) { return(array_key_exists($Name, $this->Modules)); } function RegisterModule(AppModule $Module) { $this->Modules[$Module->Name] = &$Module; $Module->Manager = &$this; $Module->OnChange = &$this->OnModuleChange; } function UnregisterModule($Module) { unset($this->Modules[array_search($Module, $this->Modules)]); } /* @return Module */ function SearchModuleById($Id) { foreach($this->Modules as $Module) { //DebugLog($Module->Name.' '.$Module->Id); if($Module->Id == $Id) return($Module->Name); } return(''); } function LoadModulesFromDir($Directory) { $List = scandir($Directory); foreach($List as $Item) { if(is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..')) { include_once($Directory.'/'.$Item.'/'.$Item.'.php'); $ModuleName = 'Module'.$Item; $this->RegisterModule(new $ModuleName($this->System)); } } } function LoadModules() { if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1])) $this->OnLoadModules(); else $this->LoadModulesFromDir(dirname(__FILE__).'/../Modules'); } }