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

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