Changeset 590
- Timestamp:
- Nov 2, 2013, 12:10:42 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/AppModule.php
r587 r590 64 64 function Install() 65 65 { 66 if($this->Installed) return; 67 $List = array(); 68 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled)); 69 $this->Manager->Perform($List, array(ModuleAction::Install), array(ModuleCondition::NotInstalled)); 70 $this->DoInstall(); 66 71 $this->Installed = true; 67 72 } … … 69 74 function Uninstall() 70 75 { 71 $this->Installed = false; 76 if(!$this->Installed) return; 77 $this->Stop(); 78 $this->Installed = false; 79 $List = array(); 80 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); 81 $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed)); 82 $this->DoUninstall(); 83 } 84 85 function Reinstall() 86 { 87 $this->Uninstall(); 88 $this->Install(); 72 89 } 73 90 74 91 function Start() 75 92 { 76 if($this->Running) return; 93 if($this->Running) return; 94 if(!$this->Installed) return; 77 95 $List = array(); 78 96 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning)); … … 119 137 { 120 138 var $Modules; 139 var $ModulesAvail; 121 140 var $System; 122 141 var $OnLoadModules; -
trunk/Common/Database.php
r589 r590 77 77 function query($Query) 78 78 { 79 if(!$this->Connected()) throw new Exception('Not connected to database'); 79 80 $this->LastQuery = $Query; 80 81 if($this->ShowSQLQuery == true) -
trunk/Common/Page.php
r578 r590 13 13 var $ShortTitle; 14 14 var $FullTitle; 15 var $Encoding; 16 var $Style; 15 17 16 18 function __construct($System) … … 18 20 parent::__construct($System); 19 21 20 $this->FormatHTML = $this->System->Config['Web']['FormatHTML']; 21 $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo']; 22 $this->FormatHTML = false; 23 $this->ShowRuntimeInfo = false; 24 $this->Encoding = 'utf-8'; 25 $this->Style = 'new'; 26 27 // TODO: Move to external code 28 if(isset($this->System->Config['Web']['FormatHTML'])) 29 $this->FormatHTML = $this->System->Config['Web']['FormatHTML']; 30 if(isset($this->System->Config['Web']['ShowRuntimeInfo'])) 31 $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo']; 32 if(isset($this->System->Config['Web']['Charset'])) 33 $this->Encoding = $this->System->Config['Web']['Charset']; 34 if(isset($this->System->Config['Web']['Style'])) 35 $this->Style = $this->System->Config['Web']['Style']; 22 36 } 23 37 … … 48 62 { 49 63 $Navigation = ' > <a href="'.$this->System->Link($ScriptName).'/">'.$Page->ShortTitle.'</a>'.$Navigation; 50 51 if( $Page->ParentClass != '')64 65 if(class_exists($Page->ParentClass)) 52 66 { 53 67 $PageClass = $Page->ParentClass; … … 61 75 if(isset($this->Load)) $BodyParam .= ' onload="'.$this->Load.'"'; 62 76 if(isset($this->Unload)) $BodyParam .= ' onunload="'.$this->Unload.'"'; 63 $Output = '<?xml version="1.0" encoding="'.$this-> System->Config['Web']['Charset'].'"?>'."\n".77 $Output = '<?xml version="1.0" encoding="'.$this->Encoding.'"?>'."\n". 64 78 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'. 65 79 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'. 66 '<head><link rel="stylesheet" href="'.$this->System->Link('/style/').$this->S ystem->Config['Web']['Style'].'/style.css" type="text/css" media="all" />'.67 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this-> System->Config['Web']['Charset'].'" />'.68 '<script type="text/javascript" src="'.$this->System->Link('/style/').$this->S ystem->Config['Web']['Style'].'/global.js"></script>'.80 '<head><link rel="stylesheet" href="'.$this->System->Link('/style/').$this->Style.'/style.css" type="text/css" media="all" />'. 81 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Encoding.'" />'. 82 '<script type="text/javascript" src="'.$this->System->Link('/style/').$this->Style.'/global.js"></script>'. 69 83 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title> 70 84 </head><body'.$BodyParam.'>'; … … 75 89 if($this->System->Config['Web']['UserSupport'] == 1) 76 90 { 77 if( $this->System->User->User['Id'] == null)91 if(isset($this->System->User) and ($this->System->User->User['Id'] == null)) 78 92 $Output .= '<a href="'.$this->System->Link('/?Action=LoginForm').'">Přihlášení</a> '. 79 93 '<a href="'.$this->System->Link('/?Action=UserRegister').'">Registrace</a>'; -
trunk/Common/System.php
r589 r590 27 27 $this->ShowPage = true; 28 28 $this->ConfigManager = new Config(); 29 $this->RootURLFolder = $_SERVER['SCRIPT_NAME']; 30 if(substr($this->RootURLFolder, -10, 10) == '/index.php') 31 $this->RootURLFolder = substr($this->RootURLFolder, 0, -10); 29 32 } 30 33 … … 42 45 $Page[$LastKey] = $Handler; 43 46 } else $this->Pages[$Path] = $Handler; 47 } 48 49 function UnregisterPage($Path) 50 { 51 unset($this->Pages[$Path]); 44 52 } 45 53 … … 129 137 //$Output .= 'Nelze se připojit k databázi.'; 130 138 } 131 $this->RootURLFolder = $this->Config['Web']['RootFolder']; 132 $this->FormManager->Root = $this->Config['Web']['RootFolder']; 139 if(isset($this->Config['Web']['RootFolder'])) 140 $this->RootURLFolder = $this->Config['Web']['RootFolder']; 141 $this->FormManager->Root = $this->RootURLFolder; 133 142 134 143 $Database = $this->Database; … … 138 147 include_once(dirname(__FILE__).'/../Modules/Setup/Setup.php'); 139 148 $this->ModuleManager->RegisterModule(new ModuleSetup($this)); 149 $this->ModuleManager->Modules['Setup']->Installed = true; 140 150 $this->ModuleManager->Modules['Setup']->Start(); 141 151 if($this->ModuleManager->Modules['Setup']->CheckState()) 142 152 { 143 153 $this->ModuleManager->LoadModules(); 154 $this->ModuleManager->Modules['Setup']->Installed = true; 144 155 $this->ModuleManager->Modules['Setup']->Start(); 145 156 $this->ModuleManager->StartAll(); -
trunk/Modules/Setup/DefaultConfig.php
r589 r590 8 8 return(array 9 9 ( 10 array('Name' => 'SystemPassword', 'Type' => 'Password ', 'Default' => '', 'Title' => 'Systémové heslo'),10 array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'Systémové heslo'), 11 11 array('Name' => 'Database/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Server'), 12 12 array('Name' => 'Database/User', 'Type' => 'String', 'Default' => 'root', 'Title' => 'Uživatel'), -
trunk/Modules/Setup/Setup.php
r589 r590 26 26 $UpdateInterface->DatabaseRevision = $DatabaseRevision; 27 27 $UpdateInterface->Config = &$Config; 28 $UpdateInterface->Updates = &$Updates; 28 $Updates = new Updates(); 29 $UpdateInterface->Updates = $Updates->Get(); 29 30 return($UpdateInterface->Show()); 30 31 } … … 35 36 function Show() 36 37 { 37 echo('s');38 38 $Output = ''; 39 39 if(!$this->Database->Connected()) $Output .= 'Nelze se připojit k databázi.<br>'; 40 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>'; 41 if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsInstalled()) 42 $Output .= 'Systém vyžaduje instalaci databáze.<br>'; 43 else 44 if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsUpToDate()) 45 $Output .= 'Systém vyžaduje aktualizaci databáze.<br>'; 43 46 } 44 47 $Output .= 'Pokračujte <a href="'.$this->System->Link('/setup/').'">zde</a>'; … … 75 78 } 76 79 80 function DoStop() 81 { 82 unset($this->UpdateManager); 83 $this->System->UnregisterPage(''); 84 $this->System->UnregisterPage('setup'); 85 } 86 77 87 function CheckState() 78 88 { 79 89 return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and 80 90 $this->UpdateManager->IsUpToDate()); 81 91 } 82 92 } -
trunk/Modules/Setup/Update.php
r589 r590 45 45 { 46 46 $TraceItem = $this->Trace[$DbRevision]; 47 $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>'; 47 $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>'; 48 echo($Output); 48 49 $RevUpdate = $TraceItem['Function']; 49 50 $RevUpdate($this); … … 58 59 $InstallMethod = $this->InstallMethod; 59 60 $InstallMethod($this); 61 $this->Update(); 60 62 } 61 63 … … 88 90 var $Updates; 89 91 var $Database; 92 var $ConfigDir; 90 93 91 94 function __construct() 92 95 { 96 $this->ConfigDir = dirname(__FILE__).'/../..'; 93 97 } 94 98 … … 124 128 $Output .= '<input type="submit" name="insert_sample_data" value="Vložit vzorová data"/> '; 125 129 $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/> '; 130 //$Output .= $this->ShowList(); 126 131 } else $Output .= '<input type="submit" name="install" value="Instalovat"/> '; 127 132 } … … 214 219 } 215 220 221 function ShowList() 222 { 223 $Output = ''; 224 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Module`'); 225 $DbRow = $DbResult->fetch_row(); 226 $PageList = GetPageList($DbRow[0]); 227 228 $Output .= $PageList['Output']; 229 $Output .= '<table class="WideTable" style="font-size: small;">'; 230 231 $TableColumns = array( 232 array('Name' => 'Name', 'Title' => 'Jméno'), 233 array('Name' => 'Creator', 'Title' => 'Tvůrce'), 234 array('Name' => 'Version', 'Title' => 'Verze'), 235 array('Name' => 'License', 'Title' => 'Licence'), 236 array('Name' => 'Installed', 'Title' => 'Instalováno'), 237 array('Name' => 'Description', 'Title' => 'Popis'), 238 array('Name' => 'Dependencies', 'Title' => 'Závislosti'), 239 array('Name' => '', 'Title' => 'Akce'), 240 ); 241 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 242 $Output .= $Order['Output']; 243 $Query = 'SELECT *, (SELECT GROUP_CONCAT(`T1`.`Name` SEPARATOR ", ") FROM `SystemModuleDependency` '. 244 'LEFT JOIN `SystemModule` AS `T1` ON `T1`.`Id` = `SystemModuleDependency`.`DependencyModule` '. 245 'WHERE `SystemModuleDependency`.`Module` = `SystemModule`.`Id`) AS `Dependencies` '. 246 'FROM `SystemModule` '.$Order['SQL'].$PageList['SQLLimit']; 247 248 $DbResult = $this->Database->query($Query); 249 while($Module = $DbResult->fetch_assoc()) 250 { 251 if($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies']; 252 else $Dependencies = ' '; 253 if($Module['Installed'] == 1) $Installed = 'Ano'; 254 else $Installed = 'Ne'; 255 if($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>'; 256 else $Actions = '<a href="?A=Install&Id='.$Module['Id'].'">Instalovat</a>'; 257 $Output .= '<tr><td>'.$Module['Name'].'</td>'. 258 '<td>'.$Module['Creator'].'</td>'. 259 '<td>'.$Module['Version'].'</td>'. 260 '<td>'.$Module['License'].'</td>'. 261 '<td>'.$Installed.'</td>'. 262 '<td>'.$Module['Description'].'</td>'. 263 '<td>'.$Dependencies.'</td>'. 264 '<td>'.$Actions.'</td></tr>'; 265 } 266 $Output .= '</table>'; 267 $Output .= $PageList['Output']; 268 $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 269 return($Output); 270 } 271 216 272 function PrepareConfig($Config) 217 273 { 218 274 $Output = ''; 219 if(!file_exists( '../config.php') and !is_writable('..'))275 if(!file_exists($this->ConfigDir.'/config.php') and !is_writable($this->ConfigDir)) 220 276 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka není povolená pro zápis!'; 221 if(file_exists( '../config.php') and !is_writable('../config.php'))277 if(file_exists($this->ConfigDir.'/config.php') and !is_writable($this->ConfigDir.'/config.php')) 222 278 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor config.php není povolen pro zápis!'; 223 279 $Output .= '<h3>Nastavení systému</h3>'. … … 238 294 if($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 239 295 if($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 296 if($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 240 297 if($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 241 298 if($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; … … 259 316 if($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 260 317 $Value = $_POST[$Def['Name']]; 318 if($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 319 $Value = sha1($_POST[$Def['Name']]); 261 320 if($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST)) 262 321 $Value = $_POST[$Def['Name']]; … … 278 337 } 279 338 $ConfigText = $this->CreateConfig($Config); 280 file_put_contents( '../config.php', $ConfigText);339 file_put_contents($this->ConfigDir.'/config.php', $ConfigText); 281 340 $Output .= 'Konfigurace nastavena<br/>'; 282 341 return($Output); -
trunk/Modules/Setup/Updates.php
r589 r590 441 441 } 442 442 443 444 $Updates = array( 443 class Updates 444 { 445 function Get() 446 { 447 return($Updates = array( 445 448 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'), 446 449 493 => array('Revision' => 494, 'Function' => 'UpdateTo494'), … … 465 468 571 => array('Revision' => 574, 'Function' => 'UpdateTo574'), 466 469 574 => array('Revision' => 584, 'Function' => 'UpdateTo584'), 467 ); 470 )); 471 } 472 }
Note:
See TracChangeset
for help on using the changeset viewer.