Changeset 887 for trunk/Modules/System/System.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/System/System.php
r874 r887 3 3 class PageModules extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function ShowList() 13 function ShowList(): string 14 14 { 15 15 $Output = ''; … … 62 62 } 63 63 64 function Show() 64 function Show(): string 65 65 { 66 66 $Output = ''; … … 69 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();71 $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else … … 78 78 if ($ModuleName != '') 79 79 { 80 $this->System->Modules[$ModuleName]->Install(); 81 $this->System->ModuleManager->Init(); 80 $this->System->ModuleManager->GetModule($ModuleName)->Install(); 82 81 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 83 82 … … 88 87 if ($ModuleName != '') 89 88 { 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); 91 $this->System->ModuleManager->Init(); 89 $this->System->ModuleManager->GetModule($ModuleName)->UnInstall(); 92 90 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 93 91 } else $Output .= 'Neplatná akce'; … … 100 98 class ModuleSystem extends AppModule 101 99 { 102 var$InstalledChecked;103 104 function __construct( $System)100 public bool $InstalledChecked; 101 102 function __construct(System $System) 105 103 { 106 104 parent::__construct($System); … … 113 111 } 114 112 115 function DoInstall() 113 function DoInstall(): void 116 114 { 117 115 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` ( … … 164 162 } 165 163 166 function DoUnInstall() 164 function DoUnInstall(): void 167 165 { 168 166 // Delete tables with reverse order … … 178 176 } 179 177 180 function DoStart() 181 { 182 $this->System->RegisterPage( 'module', 'PageModules');178 function DoStart(): void 179 { 180 $this->System->RegisterPage(['module'], 'PageModules'); 183 181 $this->System->FormManager->RegisterClass('Action', array( 184 182 'Title' => 'Akce', … … 402 400 } 403 401 404 function DoStop() 405 { 406 } 407 408 function IsInstalled() 402 function DoStop(): void 403 { 404 } 405 406 function IsInstalled(): bool 409 407 { 410 408 if ($this->InstalledChecked == false) … … 419 417 } 420 418 421 function ModuleChange($Module) 419 function ModuleChange($Module): void 422 420 { 423 421 //if ($this->IsInstalled()) … … 430 428 } 431 429 432 function LoadFromDatabase() 430 function LoadFromDatabase(): void 433 431 { 434 432 //DebugLog('Loading modules...'); … … 448 446 } 449 447 450 function SaveToDatabase() 448 function SaveToDatabase(): string 451 449 { 452 450 $Output = ''; … … 457 455 $Modules[$DbRow['Name']] = $DbRow; 458 456 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 $this->System->ModuleManager-> Modules[$DbRow['Name']]->Id = $DbRow['Id'];457 $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id']; 460 458 } 461 459 … … 470 468 'Description' => $Module->Description, 'License' => $Module->License, 471 469 'Installed' => $Module->Installed)); 472 $this->System->ModuleManager-> Modules[$Module->Name]->Id = $this->Database->insert_id;470 $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id; 473 471 } 474 472 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array( … … 512 510 { 513 511 if (!array_key_exists($Module->Id, $DbDependency) or 514 !in_array($this->System->ModuleManager-> Modules[$Dependency]->Id, $DbDependency[$Module->Id]))512 !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id])) 515 513 { 516 if ( array_key_exists($Dependency, $this->System->ModuleManager->Modules))517 $DependencyId = $this->System->ModuleManager-> Modules[$Dependency]->Id;514 if ($this->System->ModuleManager->ModulePresent($Dependency)) 515 $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id; 518 516 else throw new Exception('Dependent module '.$Dependency.' not found'); 519 517 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, … … 534 532 return $Output; 535 533 } 534 535 static function Cast(AppModule $AppModule): ModuleSystem 536 { 537 if ($AppModule instanceof ModuleSystem) 538 { 539 return $AppModule; 540 } 541 throw new Exception('Expected ModuleSystem type but got '.gettype($AppModule)); 542 } 536 543 }
Note:
See TracChangeset
for help on using the changeset viewer.