Changeset 63 for trunk/index.php
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 nbproject2 Config.php3 1 .settings 4 2 .project 5 3 .buildpath 4 .htaccess
-
- Property svn:ignore
-
trunk/index.php
r61 r63 5 5 require_once('Packages/Common/Common.php'); 6 6 require_once('View.php'); 7 8 7 9 8 require_once('Modules/Meet/Meet.php'); … … 18 17 if (isset($_SERVER['REMOTE_ADDR'])) session_start(); 19 18 20 class ApplicationTanec extends Application 21 { 22 var $Config; 23 var $Title; 24 var $Pages; 25 var $PathItems; 26 var $ShowPage; 27 var $MainMenu; 28 var $PageHeaders; 29 var $Bars; 19 class Core extends System 20 { 21 public array $Config; 22 public array $PathItems; 23 public bool $ShowPage; 24 public array $MainMenu; 25 public array $PageHeaders; 26 public array $Bars; 30 27 31 28 function __construct() … … 38 35 } 39 36 40 function IsAdmin() 37 function IsAdmin(): bool 41 38 { 42 39 return array_key_exists('IsAdmin', $_SESSION) and ($_SESSION['IsAdmin'] == 1); 43 40 } 44 41 45 function Link( $URL)42 function Link(string $URL): string 46 43 { 47 44 return $this->Config['BaseURL'].$URL; 48 45 } 49 46 50 function AbsoluteLink( $URL)47 function AbsoluteLink(string $URL): string 51 48 { 52 49 return $this->Config['HostName'].$this->Config['BaseURL'].$URL; 53 50 } 54 51 55 function ShowMenu() 52 function ShowMenu(): string 56 53 { 57 54 $Output = '<div>'; … … 64 61 } 65 62 66 function ProcessURL() 63 function ProcessURL(): array 67 64 { 68 65 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) … … 78 75 } 79 76 80 function RegisterPage($Path, $Handler) 77 function RegisterPage($Path, $Handler): void 81 78 { 82 79 if (is_array($Path)) … … 93 90 } 94 91 95 function RegisterMenuItem( $Link, $Title)92 function RegisterMenuItem(string $Link, string $Title): void 96 93 { 97 94 $this->MainMenu[] = array('Link' => $Link, 'Title' => $Title); 98 95 } 99 96 100 function RegisterPageHeader( $Name, $Callback)97 function RegisterPageHeader(string $Name, array $Callback): void 101 98 { 102 99 $this->PageHeaders[$Name] = $Callback; 103 100 } 104 101 105 function RegisterPageBar( $Name)102 function RegisterPageBar(string $Name): void 106 103 { 107 104 $this->Bars[$Name] = array(); 108 105 } 109 106 110 function UnregisterPageBar( $Name)107 function UnregisterPageBar(string $Name): void 111 108 { 112 109 unset($this->Bars[$Name]); 113 110 } 114 111 115 function SearchPage( $PathItems, $Pages)112 function SearchPage(array $PathItems, array $Pages): ?string 116 113 { 117 114 if (count($PathItems) > 0) $PathItem = $PathItems[0]; … … 127 124 } 128 125 129 function PageNotFound() 126 function PageNotFound(): string 130 127 { 131 128 return 'Page '.implode('/', $this->PathItems).' not found.'; 132 129 } 133 130 134 function ShowPage() 131 function ShowPage(): void 135 132 { 136 133 $this->BaseView = new BaseView($this); 137 134 138 /* @var $Page Page */139 135 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 140 136 if ($ClassName != '') 141 137 { 142 138 $Page = new $ClassName($this); 143 } else { 139 } else 140 { 144 141 $Page = new PageMissing($this); 145 142 } … … 147 144 } 148 145 149 function Run() 146 function Run(): void 150 147 { 151 148 $this->RunCommon(); … … 157 154 } 158 155 159 function RunCommon() 156 function RunCommon(): void 160 157 { 161 158 global $Config; … … 172 169 173 170 $this->RegisterPageBar('Top'); 174 $this->Title = 'Tanec'; 175 $Output = ''; 171 $this->Name = 'Tanec'; 172 } 173 174 static function Cast(System $System): Core 175 { 176 if ($System instanceof Core) 177 { 178 return $System; 179 } 180 throw new Exception('Expected Core type but '.gettype($System)); 176 181 } 177 182 } … … 179 184 class PageMissing extends Page 180 185 { 181 var $FullTitle = 'Stránka nenalezena';182 var $ShortTitle = 'Stránka nenalezena';183 184 186 function __construct($System) 185 187 { 186 188 parent::__construct($System); 189 $this->Title = 'Stránka nenalezena'; 187 190 $this->ParentClass = 'PagePortal'; 188 191 } 189 192 190 function Show() 193 function Show(): string 191 194 { 192 195 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); … … 202 205 } 203 206 204 function Show() 207 function Show(): string 205 208 { 206 209 $this->RawPage = true; … … 214 217 class PageSiteMap extends Page 215 218 { 216 function Show() 219 function Show(): string 217 220 { 218 221 $this->RawPage = true; … … 265 268 class PageLogin extends Page 266 269 { 267 function Show() 270 function __construct($System) 271 { 272 parent::__construct($System); 273 $this->Title = 'Přihlášení'; 274 $this->ParentClass = 'PagePortal'; 275 } 276 277 function Show(): string 268 278 { 269 279 global $Config; … … 296 306 $Output .= $this->ShowLoginForm(); 297 307 } 298 if ($this->System->IsAdmin()) $Output .= '<div>Jsi přihlášen jako správce. <a href="?logoff">Odhlásit</a></div>';308 if(Core::Cast($this->System)->IsAdmin()) $Output .= '<div>Jsi přihlášen jako správce. <a href="?logoff">Odhlásit</a></div>'; 299 309 return $Output; 300 310 } 301 311 302 function ShowLoginForm() 312 function ShowLoginForm(): string 303 313 { 304 314 return '<form method="post" action="?login">'. 305 306 307 308 } 309 } 310 311 $Revision = 51; // Subversion revision315 'Heslo: <input type="password" name="password" value=""/><br/>'. 316 '<input type="submit" value="Přihlásit"/>'. 317 '</form>'; 318 } 319 } 320 321 $Revision = 63; // Subversion revision 312 322 $DatabaseRevision = 51; // SQL structure revision 313 $ReleaseTime = strtotime('202 0-01-01');314 315 $Application = new ApplicationTanec();323 $ReleaseTime = strtotime('2021-08-03'); 324 325 $Application = new Core(); 316 326 $Application->ModuleManager->LoadModulesFromDir(dirname(__FILE__).'/Modules'); 317 327 $Application->Modules = $Application->ModuleManager->Modules; 318 328 $Application->ModuleManager->InstallAll(); 319 329 $Application->ModuleManager->StartAll(); 320 $Application->RegisterPage( '', 'PageDanceList');321 $Application->RegisterPage( 'robots.txt', 'PageRobots');322 $Application->RegisterPage( 'sitemap.xml', 'PageSiteMap');323 $Application->RegisterPage( 'admin', 'PageLogin');330 $Application->RegisterPage([''], 'PageDanceList'); 331 $Application->RegisterPage(['robots.txt'], 'PageRobots'); 332 $Application->RegisterPage(['sitemap.xml'], 'PageSiteMap'); 333 $Application->RegisterPage(['admin'], 'PageLogin'); 324 334 $Application->Run();
Note:
See TracChangeset
for help on using the changeset viewer.