source: trunk/Packages/Common/Modules/ModuleManager.php

Last change on this file was 95, checked in by chronos, 3 years ago
  • Modified: Updated Common package.
  • Added: Explicit types for better type checking.
  • Fixed: Support for php 8.0.
File size: 22.0 KB
Line 
1<?php
2
3class ModuleModuleManager extends Module
4{
5 public UpdateManager $UpdateManager;
6
7 function __construct(System $System)
8 {
9 parent::__construct($System);
10 $this->Name = 'ModuleManager';
11 $this->Version = '1.0';
12 $this->Creator = 'Chronos';
13 $this->License = 'GNU/GPLv3';
14 $this->Description = 'User interface for module management.';
15 $this->Dependencies = array(ModuleSetup::GetName());
16 $this->Revision = 1;
17 $this->Type = ModuleType::System;
18 $this->Models = array(ModelField::GetClassName(), ModuleDependency::GetClassName());
19 }
20
21 function DoStart(): void
22 {
23 $this->Manager->OnInstallModel = array($this, 'InstallModel');
24 $this->Manager->OnUninstallModel = array($this, 'UninstallModel');
25 $this->Manager->OnInstallModule = array($this, 'InstallModule');
26 $this->Manager->OnUninstallModule = array($this, 'UninstallModule');
27
28 Core::Cast($this->System)->RegisterPage(['modules'], 'PageModules');
29 //$this->Manager->OnModuleChange = array($this, 'ModuleChange');
30 //$this->LoadFromDatabase();
31
32 $this->System->FormManager->RegisterClass('Module', array(
33 'Title' => 'Moduly',
34 'Table' => 'Module',
35 'Items' => array(
36 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
37 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
38 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
39 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''),
40 'License' => array('Type' => 'String', 'Caption' => 'Licence', 'Default' => ''),
41 'Creator' => array('Type' => 'String', 'Caption' => 'Tvůrce', 'Default' => ''),
42 'HomePage' => array('Type' => 'Hyperlink', 'Caption' => 'Domovské stránky', 'Default' => ''),
43 'Installed' => array('Type' => 'Boolean', 'Caption' => 'Instalováno', 'Default' => '', 'ReadOnly' => true),
44 'Models' => array('Type' => 'TModelListModule', 'Caption' => 'Modely', 'Default' => ''),
45 'Links' => array('Type' => 'TModuleLinkListModule', 'Caption' => 'Vazby', 'Default' => ''),
46 ),
47 'Actions' => array(
48 array('Caption' => 'Aktualizovat z disku', 'URL' => '/module/?A=SaveToDb'),
49 ),
50 ));
51 $this->System->FormManager->RegisterFormType('TModule', array(
52 'Type' => 'Reference',
53 'Table' => 'Module',
54 'Id' => 'Id',
55 'Name' => 'Title',
56 'Filter' => '1',
57 ));
58 $this->System->FormManager->RegisterFormType('TModelListModule', array(
59 'Type' => 'ManyToOne',
60 'Table' => 'Model',
61 'Id' => 'Id',
62 'Ref' => 'Module',
63 'Filter' => '1',
64 ));
65 $this->System->FormManager->RegisterClass('Model', array(
66 'Title' => 'Modely',
67 'Table' => 'Model',
68 'Items' => array(
69 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
70 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
71 'Module' => array('Type' => 'TModule', 'Caption' => 'Module', 'Default' => ''),
72 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''),
73 'DefaultSortColumn' => array('Type' => 'String', 'Caption' => 'Výchozí sloupce řazení', 'Default' => ''),
74 'DefaultSortOrder' => array('Type' => 'Text', 'Caption' => 'Výchozí směr řazení', 'Default' => ''),
75 'Fields' => array('Type' => 'TModelFieldListModel', 'Caption' => 'Pole', 'Default' => ''),
76 ),
77 ));
78 $this->System->FormManager->RegisterFormType('TModel', array(
79 'Type' => 'Reference',
80 'Table' => 'Model',
81 'Id' => 'Id',
82 'Name' => 'Title',
83 'Filter' => '1',
84 ));
85 $this->System->FormManager->RegisterFormType('TModelFieldListModel', array(
86 'Type' => 'ManyToOne',
87 'Table' => 'ModelField',
88 'Id' => 'Id',
89 'Ref' => 'Model',
90 'Filter' => '1',
91 ));
92 $this->System->FormManager->RegisterClass('ModelField', array(
93 'Title' => 'Pole modelu',
94 'Table' => 'ModelField',
95 'Items' => array(
96 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
97 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
98 'Model' => array('Type' => 'TModel', 'Caption' => 'Model', 'Default' => ''),
99 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''),
100 'Type' => array('Type' => 'String', 'Caption' => 'Typ', 'Default' => ''),
101 'DefaultValue' => array('Type' => 'String', 'Caption' => 'Výchozí hodnota', 'Default' => ''),
102 'IsNull' => array('Type' => 'Boolean', 'Caption' => 'Také nulová hodnota', 'Default' => ''),
103 'Suffix' => array('Type' => 'String', 'Caption' => 'Text za', 'Default' => ''),
104 ),
105 ));
106 $this->System->FormManager->RegisterFormType('TModuleLink', array(
107 'Type' => 'Reference',
108 'Table' => 'ModuleLink',
109 'Id' => 'Id',
110 'Name' => 'Module',
111 'Filter' => '1',
112 ));
113 $this->System->FormManager->RegisterFormType('TModuleLinkListModule', array(
114 'Type' => 'ManyToOne',
115 'Table' => 'ModuleLink',
116 'Id' => 'Id',
117 'Ref' => 'Module',
118 'Filter' => '1',
119 ));
120 $this->System->FormManager->RegisterClass('ModuleLink', array(
121 'Title' => 'Vazby modulu',
122 'Table' => 'ModuleLink',
123 'Items' => array(
124 'Module' => array('Type' => 'TModule', 'Caption' => 'Modul', 'Default' => ''),
125 'LinkedModule' => array('Type' => 'TModule', 'Caption' => 'Vázaný modul', 'Default' => ''),
126 'Type' => array('Type' => 'String', 'Caption' => 'Typ vazby', 'Default' => ''),
127 ),
128 ));
129 $this->System->FormManager->RegisterFormType('TModule', array(
130 'Type' => 'Reference',
131 'Table' => 'Module',
132 'Id' => 'Id',
133 'Name' => 'Name',
134 'Filter' => '1',
135 ));
136 }
137
138 function DoStop(): void
139 {
140 Core::Cast($this->System)->UnregisterPage(['modules']);
141 }
142
143 function DoBeforeInstall(): void
144 {
145 $this->AddModelDatabase(Module::GetModelDesc());
146 $this->Manager->OnInstallModule = array($this, 'InstallModule');
147 $this->Manager->OnUninstallModule = array($this, 'UninstallModule');
148 $this->AddModelDatabase(Model::GetModelDesc());
149 $this->Manager->OnInstallModel = array($this, 'InstallModel');
150 $this->Manager->OnUninstallModel = array($this, 'UninstallModel');
151 }
152
153 function DoAfterUninstall(): void
154 {
155 $this->Manager->OnInstallModel = null;
156 $this->Manager->OnUninstallModel = null;
157 $this->RemoveModelDatabase(Model::GetModelDesc());
158 $this->Manager->OnInstallModule = null;
159 $this->Manager->OnUninstallModule = null;
160 $this->RemoveModelDatabase(Module::GetModelDesc());
161 }
162
163 function DoInstall(): void
164 {
165 $this->InstallModel(Module::GetModelDesc(), $this->System->GetModule($this::GetName()));
166 $this->InstallModel(Model::GetModelDesc(), $this->System->GetModule($this::GetName()));
167 }
168
169 function AddModelDatabase(ModelDesc $ModelDesc)
170 {
171 $Query = "CREATE TABLE IF NOT EXISTS `".$ModelDesc->Name."` (\n";
172 $Query .= ' `'.$ModelDesc->PrimaryKey.'` int(11) NOT NULL AUTO_INCREMENT,'."\n";
173 foreach ($ModelDesc->Columns as $Column)
174 {
175 $Query .= " `".$Column->Name."` ";
176 if ($Column->Type == ModelColumnType::Integer) $Query .= 'int(11)';
177 else if ($Column->Type == ModelColumnType::String) $Query .= 'varchar(255)';
178 else if ($Column->Type == ModelColumnType::Float) $Query .= 'varchar(255)';
179 else if ($Column->Type == ModelColumnType::Text) $Query .= 'text';
180 else if ($Column->Type == ModelColumnType::DateTime) $Query .= 'datetime';
181 else if ($Column->Type == ModelColumnType::Reference) $Query .= 'int(11)';
182 else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)';
183 else if ($Column->Type == ModelColumnType::Date) $Query .= 'date';
184 else if ($Column->Type == ModelColumnType::BigInt) $Query .= 'bigint(20)';
185 else if ($Column->Type == ModelColumnType::Enum)
186 {
187 $Query .= 'enum("'.implode('", "', $Column->States).'")';
188 }
189
190 if ($Column->Nullable) $Query .= '';
191 else $Query .= ' NOT NULL';
192
193 $Query .= ' COLLATE utf8_general_ci';
194
195 if ($Column->HasDefault)
196 {
197 if ($Column->Default == null)
198 $Query .= ' DEFAULT NULL';
199 else $Query .= ' DEFAULT '.$Column->GetDefault();
200 }
201 $Query .= ",\n";
202 }
203 $Query .= ' PRIMARY KEY (`'.$ModelDesc->PrimaryKey.'`)';
204 foreach ($ModelDesc->Columns as $Column)
205 {
206 if ($Column->Type == ModelColumnType::Reference)
207 $Query .= ','."\n".' KEY `'.$Column->Name.'` (`'.$Column->Name.'`)';
208 else if ($Column->Unique)
209 $Query .= ','."\n".' UNIQUE KEY `'.$Column->Name.'` (`'.$Column->Name.'`)';
210 }
211 $Query .= "\n";
212
213 if ($ModelDesc->Memory) $Engine = 'MEMORY';
214 else $Engine = 'InnoDB';
215 $Query .= ') ENGINE='.$Engine.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;';
216 foreach ($ModelDesc->Columns as $Column)
217 {
218 if ($Column->Type == ModelColumnType::Reference)
219 $Query .= "ALTER TABLE `".$ModelDesc->Name."` ".
220 "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$Column->Name."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);";
221 }
222 $this->Database->query($Query);
223 }
224
225 function RemoveModelDatabase(ModelDesc $ModelDesc)
226 {
227 /*$Query = '';
228 foreach ($ModelDesc->Columns as $Column)
229 {
230 if ($Column->Type == ModelColumnType::Reference)
231 $Query .= "ALTER TABLE `".$ModelDesc->Name."` ".
232 "DROP FOREIGN KEY `".$ModelDesc->Name."_ibfk_".$Column->Name."`;";
233 }
234 if (($Query != '') and $this->Database->TableExists($ModelDesc->Name))
235 {
236 $this->Database->query($Query);
237 }
238*/
239 $this->Database->query('SET foreign_key_checks = 0; DROP TABLE IF EXISTS `'.$ModelDesc->Name.'`');
240 }
241
242 function InstallModel(ModelDesc $ModelDesc, Module $Module)
243 {
244 $this->AddModelDatabase($ModelDesc);
245 $this->Database->insert('Model', array('Name' => $ModelDesc->Name, 'Module' => $Module->Id));
246 $ModelId = $this->Database->insert_id;
247 foreach ($ModelDesc->Columns as $Field)
248 {
249 $this->Database->insert('ModelField', array('Name' => $Field->Name, 'Model' => $ModelId,
250 'Type' => ModelColumnType::GetName($Field->Type), 'Nullable' => (int)$Field->Nullable));
251 }
252 }
253
254 function UninstallModel(ModelDesc $ModelDesc, Module $Module)
255 {
256 $DbResult = $this->Database->select('Model', 'Id', '(Name="'.$ModelDesc->Name.'") AND (Module='.$Module->Id.')');
257 if ($DbResult->num_rows > 0)
258 {
259 $DbRow = $DbResult->fetch_assoc();
260 $ModelId = $DbRow['Id'];
261 $DbResult = $this->Database->delete('ModelField', '(Model='.$ModelId.')');
262 $this->Database->delete('Model', '(Id='.$ModelId.')');
263 } else echo('Can\'t remove model '.$ModelDesc->Name.'<br/>');
264 $this->RemoveModelDatabase($ModelDesc);
265 }
266
267 function InstallModule(Module $Module)
268 {
269 $this->Database->insert('Module', array(
270 'Id' => $Module->Id,
271 'Name' => $Module->Name,
272 'Title' => $Module->Title,
273 'Creator' => $Module->Creator,
274 'Version' => $Module->Version,
275 'License' => $Module->License,
276 'Installed' => (int)$Module->Installed,
277 'Description' => $Module->Description,
278 'InstalledVersion' => $Module->InstalledVersion
279 ));
280 }
281
282 function UninstallModule(Module $Module)
283 {
284 $this->Database->delete('Module', 'Name="'.$Module->Name.'"');
285 }
286
287 function ModuleChange(Module $Module): void
288 {
289 if ($Module->Installed) $Installed = 1;
290 else $Installed = 0;
291 $this->Database->query('UPDATE `Module` SET `Installed`='.$Installed.' WHERE `Name`="'.$Module->Name.'"');
292 }
293
294 function LoadFromDatabase(): void
295 {
296 //DebugLog('Loading modules...');
297 $this->Modules = array();
298 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`';
299 $DbResult = $this->Database->query($Query);
300 while ($Module = $DbResult->fetch_array())
301 {
302 include_once('Modules/'.$Module['Name'].'/'.$Module['Name'].'.php');
303 $ModuleClassName = 'Module'.$Module['Name'];
304 $NewModule = new $ModuleClassName($this->Database, $this->Manager);
305 $NewModule->Id = $Module['Id'];
306 $NewModule->Installed = $Module['Installed'];
307 $this->Manager->RegisterModule($NewModule);
308 }
309 }
310
311 function SaveToDatabase(): string
312 {
313 $Output = '';
314 $Modules = array();
315 $DbResult = $this->Database->query('SELECT * FROM `Module`');
316 while ($DbRow = $DbResult->fetch_assoc())
317 {
318 $Modules[$DbRow['Name']] = $DbRow;
319 if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))
320 $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id'];
321 }
322
323 // Add missing
324 foreach ($this->System->ModuleManager->Modules as $Module)
325 {
326 if (!array_key_exists($Module->Name, $Modules))
327 {
328 $this->Database->insert('Module', array('Name' => $Module->Name,
329 'Version' => $Module->Version, 'Creator' => $Module->Creator,
330 'HomePage' => $Module->HomePage, 'Title' => $Module->Title,
331 'Description' => $Module->Description, 'License' => $Module->License,
332 'Installed' => $Module->Installed));
333 $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id;
334 }
335 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array(
336 'Version' => $Module->Version, 'Creator' => $Module->Creator,
337 'HomePage' => $Module->HomePage, 'Title' => $Module->Title,
338 'Description' => $Module->Description, 'License' => $Module->License,
339 'Installed' => $Module->Installed));
340 }
341
342 // Remove exceeding
343 foreach ($Modules as $Module)
344 if (!$this->System->ModuleManager->ModulePresent($Module['Name']))
345 {
346 $Output .= 'Removing module '.$Module['Name'].' from list</br/>';
347 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.$Module['Id']);
348 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']);
349 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
350 while ($DbRow = $DbResult->fetch_assoc())
351 {
352 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
353 $this->Database->query('DELETE FROM `PermissionUserAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
354 }
355 $this->Database->query('DELETE FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
356 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']);
357 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']);
358 while ($DbRow = $DbResult->fetch_assoc())
359 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']);
360 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']);
361 }
362
363 // Reload dependencies
364 $DbDependency = array();
365 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`');
366 while ($DbRow = $DbResult->fetch_assoc())
367 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule'];
368
369 foreach ($this->System->ModuleManager->Modules as $Module)
370 {
371 // Add missing
372 foreach ($Module->Dependencies as $Dependency)
373 {
374 if (!array_key_exists($Module->Id, $DbDependency) or
375 !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id]))
376 {
377 if ($this->System->ModuleManager->ModulePresent($Dependency))
378 $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id;
379 else throw new Exception('Dependent module '.$Dependency.' not found');
380 $this->Database->insert('ModuleLink', array('Module' => $Module->Id,
381 'LinkedModule' => $DependencyId, 'Type' => 'DependOn'));
382 }
383 }
384
385 // Remove exceeding
386 if (array_key_exists($Module->Id, $DbDependency))
387 foreach ($DbDependency[$Module->Id] as $Dep)
388 {
389 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep);
390 if (!in_array($DepModName, $Module->Dependencies))
391 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.
392 $Module->Id.' AND LinkedModule='.$Dep);
393 }
394 }
395 return $Output;
396 }
397}
398
399class PageModules extends Page
400{
401 public array $YesNo;
402
403 function __construct(System $System)
404 {
405 parent::__construct($System);
406 $this->Title = T('Modules');
407 $this->ParentClass = 'PageSetup';
408 $this->YesNo = array(false => T('No'), true => T('Yes'));
409 }
410
411 function Show(): string
412 {
413 $Output = '';
414 if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];
415 else $Operation = '';
416 if ($Operation == 'install')
417 {
418 $this->System->ModuleManager->GetModule($_GET['name'])->Install();
419 $this->System->ModuleManager->SaveState();
420 $Output .= 'Modul '.$_GET['name'].' instalován.<br/>';
421 } else
422 if ($Operation == 'uninstall')
423 {
424 $this->System->ModuleManager->GetModule($_GET['name'])->Uninstall();
425 $this->System->ModuleManager->SaveState();
426 $Output .= 'Modul '.$_GET['name'].' odinstalován.<br/>';
427 } else
428 if ($Operation == 'enable')
429 {
430 $this->System->ModuleManager->GetModule($_GET['name'])->Enable();
431 $this->System->ModuleManager->SaveState();
432 $Output .= 'Modul '.$_GET['name'].' povolen.<br/>';
433 } else
434 if ($Operation == 'disable')
435 {
436 $this->System->ModuleManager->GetModule($_GET['name'])->Disable();
437 $this->System->ModuleManager->SaveState();
438 $Output .= 'Modul '.$_GET['name'].' zakázán.<br/>';
439 } else
440 if ($Operation == 'upgrade')
441 {
442 $this->System->ModuleManager->GetModule($_GET['name'])->Upgrade();
443 $this->System->ModuleManager->SaveState();
444 $Output .= 'Modul '.$_GET['name'].' povýšen.<br/>';
445 } else
446 if ($Operation == 'install-all')
447 {
448 $this->System->ModuleManager->InstallAll();
449 $this->System->ModuleManager->SaveState();
450 $Output .= 'Všechny moduly instalovány.<br/>';
451 } else
452 if ($Operation == 'uninstall-all')
453 {
454 $this->System->ModuleManager->UninstallAll(array(ModuleCondition::Application));
455 $this->System->ModuleManager->UninstallAll(array(ModuleCondition::Library));
456 $this->System->ModuleManager->SaveState();
457 $Output .= 'Všechny moduly odinstalovány.<br/>';
458 } else
459 if ($Operation == 'enable-all')
460 {
461 $this->System->ModuleManager->EnableAll();
462 $this->System->ModuleManager->SaveState();
463 $Output .= 'Všechny moduly povoleny.<br/>';
464 } else
465 if ($Operation == 'disable-all')
466 {
467 $this->System->ModuleManager->DisableAll();
468 $this->System->ModuleManager->SaveState();
469 $Output .= 'Všechny moduly zakázány.<br/>';
470 } else
471 if ($Operation == 'upgrade-all')
472 {
473 $this->System->ModuleManager->UpgradeAll();
474 $this->System->ModuleManager->SaveState();
475 $Output .= 'Všechny moduly povýšeny.<br/>';
476 }
477 $Output .= '<h3>Správa modulů</h3>';
478 $Output .= $this->ShowList();
479 return $Output;
480 }
481
482 function ShowList(): string
483 {
484 $Output = '';
485
486 $Pageing = new Paging();
487 $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
488 $Table = new VisualTable();
489 $Table->SetColumns(array(
490 array('Name' => 'Name', 'Title' => T('Name')),
491 array('Name' => 'Creator', 'Title' => T('Creator')),
492 array('Name' => 'Version', 'Title' => T('Version')),
493 array('Name' => 'InstalledVersion', 'Title' => T('Installed version')),
494 array('Name' => 'Type', 'Title' => T('Type')),
495 array('Name' => 'License', 'Title' => T('License')),
496 array('Name' => 'Installed', 'Title' => T('Installed')),
497 array('Name' => 'Enabled', 'Title' => T('Enabled')),
498 array('Name' => 'Description', 'Title' => T('Description')),
499 array('Name' => 'Dependencies', 'Title' => T('Dependencies')),
500 array('Name' => '', 'Title' => 'Akce'),
501 ));
502 $ModuleType = array(T('System'), T('Library'), T('Application'));
503 foreach ($this->System->ModuleManager->Modules as $Module)
504 {
505 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
506 else $Dependencies = '&nbsp;';
507 $Actions = '';
508 if ($Module->Type != ModuleType::System)
509 {
510 if ($Module->Installed == true)
511 {
512 $Actions .= ' <a href="?op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
513 if ($Module->Enabled == true) $Actions .= ' <a href="?op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
514 else $Actions .= ' <a href="?op=enable&amp;name='.$Module->Name.'">Povolit</a>';
515 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
516 } else $Actions .= ' <a href="?op=install&amp;name='.$Module->Name.'">Instalovat</a>';
517 }
518
519 $Table->Table->Cells[] = array($Module->Name,
520 $Module->Creator, $Module->Version, $Module->InstalledVersion, $ModuleType[$Module->Type],
521 $Module->License, $this->YesNo[$Module->Installed],
522 $this->YesNo[$Module->Enabled], $Module->Description,
523 $Dependencies, $Actions);
524 }
525 $Output .= $Pageing->Show();
526 $Output .= $Table->Show();
527 $Output .= $Pageing->Show();
528
529 $Output .= '<div>'.
530 '<a href="?op=install-all">Instalovat vše</a> '.
531 '<a href="?op=uninstall-all">Odinstalovat vše</a> '.
532 '<a href="?op=disable-all">Zakázat vše</a> '.
533 '<a href="?op=enable">Povolit vše</a> '.
534 '<a href="?op=upgrade">Povýšit vše</a> '.
535 '</div>';
536
537 return $Output;
538 }
539}
540
541class ModelField extends Model
542{
543 static function GetModelDesc(): ModelDesc
544 {
545 $Desc = new ModelDesc(self::GetClassName());
546 $Desc->AddString('Name');
547 $Desc->AddReference('Model', Model::GetClassName());
548 $Desc->AddString('Type');
549 $Desc->AddBoolean('Nullable');
550 return $Desc;
551 }
552}
553
554class ModuleDependency extends Model
555{
556 static function GetModelDesc(): ModelDesc
557 {
558 $Desc = new ModelDesc(self::GetClassName());
559 $Desc->AddReference('Module', Module::GetClassName());
560 $Desc->AddReference('Dependency', Module::GetClassName());
561 return $Desc;
562 }
563}
Note: See TracBrowser for help on using the repository browser.