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

Last change on this file was 9, checked in by chronos, 19 months ago
  • Fixed: Modules initialization.
File size: 22.4 KB
Line 
1<?php
2
3class ModuleAdmin extends Module
4{
5 public UpdateManager $UpdateManager;
6
7 function __construct(System $System)
8 {
9 parent::__construct($System);
10 $this->Name = 'Admin';
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->Version = 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 Core::Cast($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 Core::Cast($this->System)->FormManager->RegisterFormType('TModule', array(
52 'Type' => 'Reference',
53 'Table' => 'Module',
54 'Id' => 'Id',
55 'Name' => 'Title',
56 'Filter' => '1',
57 ));
58 Core::Cast($this->System)->FormManager->RegisterFormType('TModelListModule', array(
59 'Type' => 'ManyToOne',
60 'Table' => 'Model',
61 'Id' => 'Id',
62 'Ref' => 'Module',
63 'Filter' => '1',
64 ));
65 Core::Cast($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 Core::Cast($this->System)->FormManager->RegisterFormType('TModel', array(
79 'Type' => 'Reference',
80 'Table' => 'Model',
81 'Id' => 'Id',
82 'Name' => 'Title',
83 'Filter' => '1',
84 ));
85 Core::Cast($this->System)->FormManager->RegisterFormType('TModelFieldListModel', array(
86 'Type' => 'ManyToOne',
87 'Table' => 'ModelField',
88 'Id' => 'Id',
89 'Ref' => 'Model',
90 'Filter' => '1',
91 ));
92 Core::Cast($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 Core::Cast($this->System)->FormManager->RegisterFormType('TModuleLink', array(
107 'Type' => 'Reference',
108 'Table' => 'ModuleLink',
109 'Id' => 'Id',
110 'Name' => 'Module',
111 'Filter' => '1',
112 ));
113 Core::Cast($this->System)->FormManager->RegisterFormType('TModuleLinkListModule', array(
114 'Type' => 'ManyToOne',
115 'Table' => 'ModuleLink',
116 'Id' => 'Id',
117 'Ref' => 'Module',
118 'Filter' => '1',
119 ));
120 Core::Cast($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 Core::Cast($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 if ($ModelDesc->DefaultValuesMethod != null)
253 {
254 $Values = call_user_func('self::'.$ModelDesc->DefaultValuesMethod);
255 foreach ($Values as $Value)
256 {
257 $this->Database->insert($ModelDesc->Name, $Value);
258 }
259 }
260 }
261
262 function UninstallModel(ModelDesc $ModelDesc, Module $Module)
263 {
264 $DbResult = $this->Database->select('Model', 'Id', '(Name="'.$ModelDesc->Name.'") AND (Module='.$Module->Id.')');
265 if ($DbResult->num_rows > 0)
266 {
267 $DbRow = $DbResult->fetch_assoc();
268 $ModelId = $DbRow['Id'];
269 $DbResult = $this->Database->delete('ModelField', '(Model='.$ModelId.')');
270 $this->Database->delete('Model', '(Id='.$ModelId.')');
271 } else echo('Can\'t remove model '.$ModelDesc->Name.'<br/>');
272 $this->RemoveModelDatabase($ModelDesc);
273 }
274
275 function InstallModule(Module $Module)
276 {
277 $this->Database->insert('Module', array(
278 'Id' => $Module->Id,
279 'Name' => $Module->Name,
280 'Title' => $Module->Title,
281 'Creator' => $Module->Creator,
282 'Version' => $Module->Version,
283 'License' => $Module->License,
284 'Installed' => (int)$Module->Installed,
285 'Description' => $Module->Description,
286 'InstalledVersion' => $Module->InstalledVersion
287 ));
288 }
289
290 function UninstallModule(Module $Module)
291 {
292 $this->Database->delete('Module', 'Name="'.$Module->Name.'"');
293 }
294
295 function ModuleChange(Module $Module): void
296 {
297 if ($Module->Installed) $Installed = 1;
298 else $Installed = 0;
299 $this->Database->query('UPDATE `Module` SET `Installed`='.$Installed.' WHERE `Name`="'.$Module->Name.'"');
300 }
301
302 function LoadFromDatabase(): void
303 {
304 //DebugLog('Loading modules...');
305 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`';
306 $DbResult = $this->Database->query($Query);
307 while ($Module = $DbResult->fetch_array())
308 {
309 include_once('Modules/'.$Module['Name'].'/'.$Module['Name'].'.php');
310 $ModuleClassName = 'Module'.$Module['Name'];
311 $NewModule = new $ModuleClassName($this->Database, $this->Manager);
312 $NewModule->Id = $Module['Id'];
313 $NewModule->Installed = $Module['Installed'];
314 $this->Manager->RegisterModule($NewModule);
315 }
316 }
317
318 function SaveToDatabase(): string
319 {
320 $Output = '';
321 $Modules = array();
322 $DbResult = $this->Database->query('SELECT * FROM `Module`');
323 while ($DbRow = $DbResult->fetch_assoc())
324 {
325 $Modules[$DbRow['Name']] = $DbRow;
326 if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))
327 $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id'];
328 }
329
330 // Add missing
331 foreach ($this->System->ModuleManager->Modules as $Module)
332 {
333 if (!array_key_exists($Module->Name, $Modules))
334 {
335 $this->Database->insert('Module', array('Name' => $Module->Name,
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 $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id;
341 }
342 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array(
343 'Version' => $Module->Version, 'Creator' => $Module->Creator,
344 'HomePage' => $Module->HomePage, 'Title' => $Module->Title,
345 'Description' => $Module->Description, 'License' => $Module->License,
346 'Installed' => $Module->Installed));
347 }
348
349 // Remove exceeding
350 foreach ($Modules as $Module)
351 if (!$this->System->ModuleManager->ModulePresent($Module['Name']))
352 {
353 $Output .= 'Removing module '.$Module['Name'].' from list</br/>';
354 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.$Module['Id']);
355 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']);
356 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
357 while ($DbRow = $DbResult->fetch_assoc())
358 {
359 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
360 $this->Database->query('DELETE FROM `PermissionUserAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
361 }
362 $this->Database->query('DELETE FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
363 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']);
364 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']);
365 while ($DbRow = $DbResult->fetch_assoc())
366 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']);
367 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']);
368 }
369
370 // Reload dependencies
371 $DbDependency = array();
372 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`');
373 while ($DbRow = $DbResult->fetch_assoc())
374 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule'];
375
376 foreach ($this->System->ModuleManager->Modules as $Module)
377 {
378 // Add missing
379 foreach ($Module->Dependencies as $Dependency)
380 {
381 if (!array_key_exists($Module->Id, $DbDependency) or
382 !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id]))
383 {
384 if ($this->System->ModuleManager->ModulePresent($Dependency))
385 $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id;
386 else throw new Exception('Dependent module '.$Dependency.' not found');
387 $this->Database->insert('ModuleLink', array('Module' => $Module->Id,
388 'LinkedModule' => $DependencyId, 'Type' => 'DependOn'));
389 }
390 }
391
392 // Remove exceeding
393 if (array_key_exists($Module->Id, $DbDependency))
394 foreach ($DbDependency[$Module->Id] as $Dep)
395 {
396 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep);
397 if (!in_array($DepModName, $Module->Dependencies))
398 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.
399 $Module->Id.' AND LinkedModule='.$Dep);
400 }
401 }
402 return $Output;
403 }
404}
405
406class PageModules extends Page
407{
408 public array $YesNo;
409
410 function __construct(System $System)
411 {
412 parent::__construct($System);
413 $this->Title = T('Modules');
414 $this->ParentClass = 'PageSetup';
415 $this->YesNo = array(false => T('No'), true => T('Yes'));
416 }
417
418 function Show(): string
419 {
420 $Output = '';
421 if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];
422 else $Operation = '';
423 if ($Operation == 'install')
424 {
425 $this->System->ModuleManager->GetModule($_GET['name'])->Install();
426 $this->System->ModuleManager->SaveState();
427 $Output .= 'Modul '.$_GET['name'].' instalován.<br/>';
428 } else
429 if ($Operation == 'uninstall')
430 {
431 $this->System->ModuleManager->GetModule($_GET['name'])->Uninstall();
432 $this->System->ModuleManager->SaveState();
433 $Output .= 'Modul '.$_GET['name'].' odinstalován.<br/>';
434 } else
435 if ($Operation == 'enable')
436 {
437 $this->System->ModuleManager->GetModule($_GET['name'])->Enable();
438 $this->System->ModuleManager->SaveState();
439 $Output .= 'Modul '.$_GET['name'].' povolen.<br/>';
440 } else
441 if ($Operation == 'disable')
442 {
443 $this->System->ModuleManager->GetModule($_GET['name'])->Disable();
444 $this->System->ModuleManager->SaveState();
445 $Output .= 'Modul '.$_GET['name'].' zakázán.<br/>';
446 } else
447 if ($Operation == 'upgrade')
448 {
449 $this->System->ModuleManager->GetModule($_GET['name'])->Upgrade();
450 $this->System->ModuleManager->SaveState();
451 $Output .= 'Modul '.$_GET['name'].' povýšen.<br/>';
452 } else
453 if ($Operation == 'install-all')
454 {
455 $this->System->ModuleManager->InstallAll();
456 $this->System->ModuleManager->SaveState();
457 $Output .= 'Všechny moduly instalovány.<br/>';
458 } else
459 if ($Operation == 'uninstall-all')
460 {
461 $this->System->ModuleManager->UninstallAll(array(ModuleCondition::Application));
462 $this->System->ModuleManager->UninstallAll(array(ModuleCondition::Library));
463 $this->System->ModuleManager->SaveState();
464 $Output .= 'Všechny moduly odinstalovány.<br/>';
465 } else
466 if ($Operation == 'enable-all')
467 {
468 $this->System->ModuleManager->EnableAll();
469 $this->System->ModuleManager->SaveState();
470 $Output .= 'Všechny moduly povoleny.<br/>';
471 } else
472 if ($Operation == 'disable-all')
473 {
474 $this->System->ModuleManager->DisableAll();
475 $this->System->ModuleManager->SaveState();
476 $Output .= 'Všechny moduly zakázány.<br/>';
477 } else
478 if ($Operation == 'upgrade-all')
479 {
480 $this->System->ModuleManager->UpgradeAll();
481 $this->System->ModuleManager->SaveState();
482 $Output .= 'Všechny moduly povýšeny.<br/>';
483 }
484 $Output .= '<h3>Správa modulů</h3>';
485 $Output .= $this->ShowList();
486 return $Output;
487 }
488
489 function ShowList(): string
490 {
491 $Output = '';
492
493 $Pageing = new Paging($this->System);
494 $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
495 $Table = new VisualTable($this->System);
496 $Table->SetColumns(array(
497 array('Name' => 'Name', 'Title' => T('Name')),
498 array('Name' => 'Creator', 'Title' => T('Creator')),
499 array('Name' => 'Version', 'Title' => T('Version')),
500 array('Name' => 'InstalledVersion', 'Title' => T('Installed version')),
501 array('Name' => 'Type', 'Title' => T('Type')),
502 array('Name' => 'License', 'Title' => T('License')),
503 array('Name' => 'Installed', 'Title' => T('Installed')),
504 array('Name' => 'Enabled', 'Title' => T('Enabled')),
505 array('Name' => 'Description', 'Title' => T('Description')),
506 array('Name' => 'Dependencies', 'Title' => T('Dependencies')),
507 array('Name' => '', 'Title' => 'Akce'),
508 ));
509 $ModuleType = array(T('System'), T('Library'), T('Application'));
510 foreach ($this->System->ModuleManager->Modules as $Module)
511 {
512 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
513 else $Dependencies = '&nbsp;';
514 $Actions = '';
515 if ($Module->Type != ModuleType::System)
516 {
517 if ($Module->Installed == true)
518 {
519 $Actions .= ' <a href="?op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
520 if ($Module->Enabled == true) $Actions .= ' <a href="?op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
521 else $Actions .= ' <a href="?op=enable&amp;name='.$Module->Name.'">Povolit</a>';
522 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
523 } else $Actions .= ' <a href="?op=install&amp;name='.$Module->Name.'">Instalovat</a>';
524 }
525
526 $Table->Table->Cells[] = array($Module->Name,
527 $Module->Creator, $Module->Version, $Module->InstalledVersion, $ModuleType[$Module->Type],
528 $Module->License, $this->YesNo[$Module->Installed],
529 $this->YesNo[$Module->Enabled], $Module->Description,
530 $Dependencies, $Actions);
531 }
532 $Output .= $Pageing->Show();
533 $Output .= $Table->Show();
534 $Output .= $Pageing->Show();
535
536 $Output .= '<div>'.
537 '<a href="?op=install-all">Instalovat vše</a> '.
538 '<a href="?op=uninstall-all">Odinstalovat vše</a> '.
539 '<a href="?op=disable-all">Zakázat vše</a> '.
540 '<a href="?op=enable">Povolit vše</a> '.
541 '<a href="?op=upgrade">Povýšit vše</a> '.
542 '</div>';
543
544 return $Output;
545 }
546}
547
548class ModelField extends Model
549{
550 static function GetModelDesc(): ModelDesc
551 {
552 $Desc = new ModelDesc(self::GetClassName());
553 $Desc->AddString('Name');
554 $Desc->AddReference('Model', Model::GetClassName());
555 $Desc->AddString('Type');
556 $Desc->AddBoolean('Nullable');
557 return $Desc;
558 }
559}
560
561class ModuleDependency extends Model
562{
563 static function GetModelDesc(): ModelDesc
564 {
565 $Desc = new ModelDesc(self::GetClassName());
566 $Desc->AddReference('Module', Module::GetClassName());
567 $Desc->AddReference('Dependency', Module::GetClassName());
568 return $Desc;
569 }
570}
Note: See TracBrowser for help on using the repository browser.