Changeset 593 for trunk/Common/Setup/Setup.php
- Timestamp:
- Nov 2, 2013, 11:00:41 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Setup/Setup.php
r592 r593 28 28 { 29 29 $Output = '<h3>Přihlášení k instalaci</h3>'. 30 '<form action=" " method="post">'.30 '<form action="?" method="post">'. 31 31 '<table>'. 32 32 '<tr><td>Systémové heslo:</td><td> <input type="password" name="SystemPassword" value=""/></td></tr>'. … … 39 39 function ControlPanel() 40 40 { 41 $YesNo = array(false => 'Ne', true => 'Ano');42 $Output = ' <form action="" method="post">';41 global $YesNo; 42 $Output = ''; 43 43 44 44 $Output .= 'Je připojení k databázi: '.$YesNo[$this->UpdateManager->Database->Connected()].'<br/>'; … … 53 53 { 54 54 if(!$this->UpdateManager->IsUpToDate()) 55 $Output .= '<input type="submit" name="update" value="Aktualizovat"/> '; 56 $Output .= '<input type="submit" name="insert_sample_data" value="Vložit vzorová data"/> '; 57 $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/><br/><br/>'; 58 $Output .= 'Nainstalované moduly'.$this->ShowList(); 59 $Output .= 'Dostupné moduly<br>'.$this->ShowListAvail(); 60 } else $Output .= '<input type="submit" name="install" value="Instalovat"/> '; 61 } 62 $Output .= '<input type="submit" name="configure" value="Nastavit"/> '; 63 $Output .= '<input type="submit" name="logout" value="Odhlásit"/> '; 64 $Output .= '</form>'; 55 $Output .= '<a href="?action=upgrade">Povýšit</a> '; 56 $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> '; 57 $Output .= '<a href="?action=uninstall">Odinstalovat</a> '; 58 $Output .= '<a href="?action=modules">Správa modulů</a> '; 59 } else $Output .= '<a href="?action=install">Instalovat</a> '; 60 } 61 $Output .= '<a href="?action=configure">Nastavit</a> '; 62 $Output .= '<a href="?action=logout">Odhlásit</a> '; 63 $Output .= ''; 65 64 return($Output); 66 65 } … … 93 92 $this->UpdateManager->InstallMethod = 'FullInstall'; 94 93 95 if(array_key_exists('logout', $_POST)) 94 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 95 else $Action = ''; 96 if($Action == 'logout') 96 97 { 97 98 $_SESSION['SystemPassword'] = ''; … … 99 100 $Output .= $this->LoginPanel(); 100 101 } else 101 if(array_key_exists('update', $_POST)) 102 { 103 $Output .= '<h3>Aktualizace</h3>'; 104 $Output .= $this->UpdateManager->Update(); 105 $Output .= $this->ControlPanel(); 106 } else 107 if(array_key_exists('install', $_POST)) 108 { 109 $Output .= '<h3>Instalace</h3>'; 110 $this->UpdateManager->Install(); 111 $Output .= $this->UpdateManager->Update(); 112 $Output .= $this->ControlPanel(); 113 } else 114 if(array_key_exists('uninstall', $_POST)) 115 { 116 $Output .= '<h3>Odinstalace</h3>'; 117 $this->UpdateManager->Uninstall(); 118 $Output .= $this->ControlPanel(); 119 } else 120 if(array_key_exists('insert_sample_data', $_POST)) 121 { 122 $Output .= '<h3>Vložení vzorových dat</h3>'; 123 $this->UpdateManager->InsertSampleData(); 124 $Output .= $this->ControlPanel(); 125 } else 126 if(array_key_exists('configure_save', $_POST)) 127 { 128 $Output .= $this->ConfigSave($this->Config); 129 $Output .= $this->ControlPanel(); 130 } else 131 if(array_key_exists('configure', $_POST)) 132 { 133 $Output .= $this->PrepareConfig($this->Config); 134 } else 135 { 136 $Output .= $this->ControlPanel(); 137 } 102 if($Action == 'upgrade') 103 { 104 $Output .= '<h3>Povýšení</h3>'; 105 $Output .= $this->System->Setup->Upgrade(); 106 $Output .= $this->ControlPanel(); 107 } else 108 if($Action == 'install') 109 { 110 $Output .= '<h3>Instalace</h3>'; 111 $this->System->Setup->Install(); 112 $Output .= $this->System->Setup->Upgrade(); 113 $Output .= $this->ControlPanel(); 114 } else 115 if($Action == 'uninstall') 116 { 117 $Output .= '<h3>Odinstalace</h3>'; 118 $this->System->Setup->Uninstall(); 119 $Output .= $this->ControlPanel(); 120 } else 121 if($Action == 'insert_sample_data') 122 { 123 $Output .= '<h3>Vložení vzorových dat</h3>'; 124 $this->System->Setup->InsertSampleData(); 125 $Output .= $this->ControlPanel(); 126 } else 127 if($Action == 'modules') 128 { 129 $Output .= $this->ShowModules(); 130 } else 131 if($Action == 'configure_save') 132 { 133 $Output .= $this->ConfigSave($this->Config); 134 $Output .= $this->ControlPanel(); 135 } else 136 if($Action == 'configure') 137 { 138 $Output .= $this->PrepareConfig($this->Config); 139 } else 140 { 141 $Output .= $this->ControlPanel(); 142 } 138 143 } 139 144 } else … … 150 155 } 151 156 157 function ShowModules() 158 { 159 $Output = ''; 160 if(array_key_exists('op', $_GET)) $Operation = $_GET['op']; 161 else $Operation = ''; 162 if($Operation == 'install') 163 { 164 $this->System->ModuleManager->Modules[$_GET['name']]->Install(); 165 $this->System->ModuleManager->SaveState(); 166 $Output .= 'Modul '.$_GET['name'].' instalován<br/>'; 167 } else 168 if($Operation == 'uninstall') 169 { 170 $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall(); 171 $this->System->ModuleManager->SaveState(); 172 $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>'; 173 } else 174 if($Operation == 'enable') 175 { 176 $this->System->ModuleManager->Modules[$_GET['name']]->Enable(); 177 $this->System->ModuleManager->SaveState(); 178 $Output .= 'Modul '.$_GET['name'].' povolen<br/>'; 179 } else 180 if($Operation == 'disable') 181 { 182 $this->System->ModuleManager->Modules[$_GET['name']]->Disable(); 183 $this->System->ModuleManager->SaveState(); 184 $Output .= 'Modul '.$_GET['name'].' zakázán<br/>'; 185 } else 186 if($Operation == 'upgrade') 187 { 188 $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade(); 189 $this->System->ModuleManager->SaveState(); 190 $Output .= 'Modul '.$_GET['name'].' povýšen<br/>'; 191 } 192 $Output .= '<h3>Správa modulů</h3>'; 193 $Output .= $this->ShowList(); 194 return($Output); 195 } 196 152 197 function ShowList() 153 198 { 199 global $YesNo; 200 154 201 $Output = ''; 155 202 $PageList = GetPageList(count($this->System->ModuleManager->Modules)); 156 157 $Output .= $PageList['Output'];158 $Output .= '<table class="WideTable" style="font-size: small;">';159 160 $TableColumns = array(161 array('Name' => 'Name', 'Title' => 'Jméno'),162 array('Name' => 'Creator', 'Title' => 'Tvůrce'),163 array('Name' => 'Version', 'Title' => 'Verze'),164 array('Name' => 'License', 'Title' => 'Licence'),165 array('Name' => 'Enabled', 'Title' => 'Povoleno'),166 array('Name' => 'Description', 'Title' => 'Popis'),167 array('Name' => 'Dependencies', 'Title' => 'Závislosti'),168 array('Name' => '', 'Title' => 'Akce'),169 );170 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);171 $Output .= $Order['Output'];172 173 foreach($this->System->ModuleManager->Modules as $Module)174 {175 if(($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);176 else $Dependencies = ' ';177 if($Module->Enabled == true) $Enabled = 'Ano';178 else $Enabled = 'Ne';179 $Actions = '<a href="?A=Uninstall&Name='.$Module->Name.'">Odinstalovat</a>';180 if($Module->Enabled == true) $Actions .= ' <a href="?A=Disable&Name='.$Module->Name.'">Zakázat</a>';181 else $Actions .= ' <a href="?A=Enable&Name='.$Module->Name.'">Povolit</a>';182 $Output .= '<tr><td>'.$Module->Name.'</td>'.183 '<td>'.$Module->Creator.'</td>'.184 '<td>'.$Module->Version.'</td>'.185 '<td>'.$Module->License.'</td>'.186 '<td>'.$Enabled.'</td>'.187 '<td>'.$Module->Description.'</td>'.188 '<td>'.$Dependencies.'</td>'.189 '<td>'.$Actions.'</td></tr>';190 }191 $Output .= '</table>';192 $Output .= $PageList['Output'];193 //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';194 return($Output);195 }196 197 function ShowListAvail()198 {199 $Output = '';200 $PageList = GetPageList(count($this->System->ModuleManager->Repository->Modules));201 203 202 204 $Output .= $PageList['Output']; … … 209 211 array('Name' => 'License', 'Title' => 'Licence'), 210 212 array('Name' => 'Installed', 'Title' => 'Instalováno'), 213 array('Name' => 'Enabled', 'Title' => 'Povoleno'), 211 214 array('Name' => 'Description', 'Title' => 'Popis'), 212 215 array('Name' => 'Dependencies', 'Title' => 'Závislosti'), … … 216 219 $Output .= $Order['Output']; 217 220 218 foreach($this->System->ModuleManager-> Repository->Modules as $Module)221 foreach($this->System->ModuleManager->Modules as $Module) 219 222 { 220 223 if(($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies); 221 else $Dependencies = ' '; 222 if($Module->Installed == true) $Installed = 'Ano'; 223 else $Installed = 'Ne'; 224 if($Module->Installed == true) $Actions = '<a href="?A=Uninstall&Name='.$Module->Name.'">Odinstalovat</a>'; 225 else $Actions = '<a href="?A=Install&Name='.$Module->Name.'">Instalovat</a>'; 224 else $Dependencies = ' '; 225 $Actions = ''; 226 if($Module->Installed == true) 227 { 228 $Actions .= ' <a href="?action=modules&op=uninstall&name='.$Module->Name.'">Odinstalovat</a>'; 229 if($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>'; 230 else $Actions .= ' <a href="?action=modules&op=enable&name='.$Module->Name.'">Povolit</a>'; 231 if($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>'; 232 } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>'; 233 226 234 $Output .= '<tr><td>'.$Module->Name.'</td>'. 227 235 '<td>'.$Module->Creator.'</td>'. 228 236 '<td>'.$Module->Version.'</td>'. 229 237 '<td>'.$Module->License.'</td>'. 230 '<td>'.$Installed.'</td>'. 238 '<td>'.$YesNo[$Module->Installed].'</td>'. 239 '<td>'.$YesNo[$Module->Enabled].'</td>'. 231 240 '<td>'.$Module->Description.'</td>'. 232 241 '<td>'.$Dependencies.'</td>'. … … 247 256 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor config.php není povolen pro zápis!'; 248 257 $Output .= '<h3>Nastavení systému</h3>'. 249 '<form action=" " method="post">'.258 '<form action="?action=configure_save" method="post">'. 250 259 '<table>'; 251 260 foreach($this->ConfigDefinition as $Def) … … 385 394 $this->UpdateManager->IsUpToDate()); 386 395 } 396 397 function Install() 398 { 399 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` ( 400 `Id` int(11) NOT NULL AUTO_INCREMENT, 401 `Revision` int(11) NOT NULL, 402 PRIMARY KEY (`Id`) 403 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); 404 $this->Database->query("INSERT INTO `SystemVersion` (`Id`, `Revision`) VALUES 405 (1, 591);"); 406 } 407 408 function Uninstall() 409 { 410 $this->Database->query('DROP TABLE `SystemVersion`'); 411 } 412 413 function IsInstalled() 414 { 415 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 416 return($DbResult->num_rows > 0); 417 } 418 419 function Upgrade() 420 { 421 $Output = $this->ModuleManager->Update(); 422 return($Output); 423 } 387 424 }
Note:
See TracChangeset
for help on using the changeset viewer.