1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/Update.php');
|
---|
4 | include_once(dirname(__FILE__).'/DefaultConfig.php');
|
---|
5 | include_once(dirname(__FILE__).'/FullInstall.php');
|
---|
6 | include_once(dirname(__FILE__).'/Updates.php');
|
---|
7 |
|
---|
8 | class PageSetup extends Page
|
---|
9 | {
|
---|
10 | function __construct($System)
|
---|
11 | {
|
---|
12 | parent::__construct($System);
|
---|
13 | $this->FullTitle = 'Instalace aplikace';
|
---|
14 | $this->ShortTitle = 'Instalátor';
|
---|
15 | //$this->ParentClass = 'PagePortal';
|
---|
16 | }
|
---|
17 |
|
---|
18 | function Show()
|
---|
19 | {
|
---|
20 | global $ConfigDefinition, $DatabaseRevision, $Config, $Updates;
|
---|
21 |
|
---|
22 | $UpdateInterface = new UpdateInterface();
|
---|
23 | $DefaultConfig = new DefaultConfig();
|
---|
24 | $UpdateInterface->Database = $this->Database;
|
---|
25 | $UpdateInterface->ConfigDefinition = $DefaultConfig->Get();
|
---|
26 | $UpdateInterface->DatabaseRevision = $DatabaseRevision;
|
---|
27 | $UpdateInterface->Config = &$Config;
|
---|
28 | $UpdateInterface->Updates = &$Updates;
|
---|
29 | return($UpdateInterface->Show());
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | class PageSetupRedirect extends Page
|
---|
34 | {
|
---|
35 | function Show()
|
---|
36 | {
|
---|
37 | echo('s');
|
---|
38 | $Output = '';
|
---|
39 | if(!$this->Database->Connected()) $Output .= 'Nelze se připojit k databázi.<br>';
|
---|
40 | else {
|
---|
41 | if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsInstalled()) $Output .= 'Systém vyžaduje instalaci databáze.<br>';
|
---|
42 | if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsUpToDate()) $Output .= 'Systém vyžaduje aktualizaci databáze.<br>';
|
---|
43 | }
|
---|
44 | $Output .= 'Pokračujte <a href="'.$this->System->Link('/setup/').'">zde</a>';
|
---|
45 | return($Output);
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | class ModuleSetup extends AppModule
|
---|
50 | {
|
---|
51 | var $UpdateManager;
|
---|
52 |
|
---|
53 | function __construct($System)
|
---|
54 | {
|
---|
55 | parent::__construct($System);
|
---|
56 | $this->Name = 'Setup';
|
---|
57 | $this->Version = '1.0';
|
---|
58 | $this->Creator = 'Chronos';
|
---|
59 | $this->License = 'GNU/GPL';
|
---|
60 | $this->Description = 'Basic setup and application installation';
|
---|
61 | $this->Dependencies = array();
|
---|
62 | }
|
---|
63 |
|
---|
64 | function DoStart()
|
---|
65 | {
|
---|
66 | global $DatabaseRevision;
|
---|
67 |
|
---|
68 | $this->System->RegisterPage('', 'PageSetupRedirect');
|
---|
69 | $this->System->RegisterPage('setup', 'PageSetup');
|
---|
70 |
|
---|
71 | // Check database persistence structure
|
---|
72 | $this->UpdateManager = new UpdateManager();
|
---|
73 | $this->UpdateManager->Database = &$this->Database;
|
---|
74 | $this->UpdateManager->Revision = $DatabaseRevision;
|
---|
75 | }
|
---|
76 |
|
---|
77 | function CheckState()
|
---|
78 | {
|
---|
79 | return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and
|
---|
80 | $this->UpdateManager->IsUpToDate());
|
---|
81 | }
|
---|
82 | }
|
---|