Changeset 343 for trunk/Modules/Module.php
- Timestamp:
- Jan 17, 2012, 1:00:26 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Module.php
r342 r343 14 14 var $Database; 15 15 var $Installed; 16 var $System; 16 17 17 function __construct($Database )18 function __construct($Database, $System) 18 19 { 19 20 $this->Database = &$Database; 21 $this->System = &$System; 20 22 } 21 23 … … 25 27 foreach($this->Models as $ModelName) 26 28 { 27 $Model = new $ModelName($this->Database );29 $Model = new $ModelName($this->Database, $this->System); 28 30 $Model->Install(); 29 31 unset($Model); … … 37 39 foreach($this->Models as $ModelName) 38 40 { 39 $Model = new $ModelName($this->Database );41 $Model = new $ModelName($this->Database, $this->System); 40 42 $Model->UnInstall(); 41 43 unset($Model); 42 44 } 43 45 $this->Database->query('UPDATE Module SET Installed=0 WHERE Name="'.$this->Name.'"'); 46 } 47 48 function Init() 49 { 44 50 } 45 51 } … … 49 55 var $Database; 50 56 var $Modules = array(); 57 var $Models = array(); 51 58 52 59 function __construct($Database) … … 55 62 } 56 63 64 function ModulePresent($Name) 65 { 66 return(array_key_exists($Name, $this->Modules)); 67 } 68 57 69 function Init($Installed = true) 58 70 { … … 63 75 while($Module = $DbResult->fetch_array()) 64 76 { 65 include_once( 'Modules/'.$Module['Name'].'/'.$Module['Name'].'.php');77 include_once(dirname(__FILE__).'/'.$Module['Name'].'/'.$Module['Name'].'.php'); 66 78 $ModuleClassName = 'Module'.$Module['Name']; 67 $this->Modules[$Module['Name']] = new $ModuleClassName($this->Database); 79 $this->Modules[$Module['Name']] = new $ModuleClassName($this->Database, $this); 80 $this->Modules[$Module['Name']]->Init(); 68 81 } 69 82 } … … 108 121 // Load list of modules on disk 109 122 $ModulesOnDisk = array(); 110 $Files = scandir( 'Modules');123 $Files = scandir(dirname(__FILE__)); 111 124 foreach($Files as $File) 112 if(is_dir( 'Modules/'.$File) and ($File != '.') and ($File != '..'))125 if(is_dir(dirname(__FILE__).'/'.$File) and ($File != '.') and ($File != '..')) 113 126 { 114 127 $ModulesOnDisk[] = $File; … … 120 133 { 121 134 DebugLog('Adding module '.$ModuleName.' to list'); 122 include_once( 'Modules/'.$ModuleName.'/'.$ModuleName.'.php');135 include_once(dirname(__FILE__).'/'.$ModuleName.'/'.$ModuleName.'.php'); 123 136 $ModuleClassName = 'Module'.$ModuleName; 124 137 if(class_exists($ModuleClassName)) 125 138 { 126 $Module = new $ModuleClassName($this->Database );139 $Module = new $ModuleClassName($this->Database, $this); 127 140 $this->Database->insert('Module', array('Name' => $Module->Name, 128 141 'Version' => $Module->Version, 'Creator' => $Module->Creator,
Note:
See TracChangeset
for help on using the changeset viewer.