Changeset 798 for trunk/includes/system.php
- Timestamp:
- Feb 12, 2014, 9:19:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/system.php
r765 r798 12 12 var $Menu; 13 13 var $DoNotShowPage; 14 14 15 15 function __construct() 16 16 { … … 20 20 $this->DoNotShowPage = false; 21 21 } 22 22 23 23 function Init() 24 24 { 25 25 global $Config, $LocaleManager; 26 26 27 27 $this->Config = $Config; 28 28 $this->Database = new Database(); … … 35 35 $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery']; 36 36 $this->ModuleManager = new AppModuleManager(); 37 37 38 38 $this->PathItems = ProcessURL(); 39 39 // Initialize locale … … 45 45 ); 46 46 $Code = $Config['Web']['Locale']; 47 if (isset($_SESSION)) 47 if (isset($_SESSION)) 48 48 if(array_key_exists('Locale', $_SESSION)) $Code = $_SESSION['Locale']; 49 if (isset($_GET)) 49 if (isset($_GET)) 50 50 if(array_key_exists('locale', $_GET)) $Code = $_GET['locale']; 51 51 52 52 //echo(phpinfo()); 53 53 if(!array_key_exists($Code, $LocaleManager->Available)) $Code = 'en'; 54 54 $_SESSION['Locale'] = $Code; 55 $LocaleManager->LoadLocale($Code); 56 55 $LocaleManager->LoadLocale($Code); 56 57 57 $this->Menu = array 58 ( 58 ( 59 59 /* array( 60 60 'Title' => T('Files'), … … 85 85 'Permission' => LICENCE_ANONYMOUS, 86 86 'Icon' => '', 87 ), 87 ), 88 88 array( 89 89 'Title' => T('IRC chat'), … … 100 100 'Icon' => '', 101 101 ), 102 ); 103 } 104 102 ); 103 } 104 105 105 function Run() 106 106 { … … 114 114 if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.'); 115 115 date_default_timezone_set($Config['Web']['Timezone']); 116 116 117 117 $this->Init(); 118 118 … … 132 132 } 133 133 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 134 134 135 135 // TODO: Global initialized variable should be removed 136 136 $TranslationTree = GetTranslationTree(); 137 137 138 138 // Initialize application modules 139 139 $this->ModuleManager->RegisterModule(new ModuleError($System)); … … 159 159 $this->ModuleManager->RegisterModule(new ModuleForum($System)); 160 160 $this->ModuleManager->StartAll(); 161 162 $this->BaseView = new BaseView($this); 161 162 $this->BaseView = new BaseView($this); 163 163 if($this->DoNotShowPage == false) 164 164 { 165 165 $this->ShowPage(); 166 } 167 } 168 166 } 167 } 168 169 169 function GetMicrotime() 170 170 { … … 172 172 return ((float)$Usec + (float)$Sec); 173 173 } 174 174 175 175 function Link($Target) 176 176 { 177 177 return($this->Config['Web']['BaseURL'].$Target); 178 } 179 178 } 179 180 180 function RegisterPage($Path, $Handler) 181 181 { … … 186 186 foreach($Path as $PathItem) 187 187 { 188 $Page = &$Page[$PathItem]; 188 $Page = &$Page[$PathItem]; 189 189 } 190 190 if(!is_array($Page)) $Page = array('' => $Page); … … 192 192 } else $this->Pages[$Path] = $Handler; 193 193 } 194 194 195 195 function RegisterMenuItem($MenuItem, $Pos = NULL) 196 196 { … … 200 200 } 201 201 } 202 202 203 203 function SearchPage($PathItems, $Pages) 204 204 { … … 207 207 if(array_key_exists($PathItem, $Pages)) 208 208 { 209 if(is_array($Pages[$PathItem])) 209 if(is_array($Pages[$PathItem])) 210 210 { 211 211 array_shift($PathItems); 212 212 return($this->SearchPage($PathItems, $Pages[$PathItem])); 213 } else 213 } else 214 214 { 215 if(count($PathItems) == 1) return($Pages[$PathItem]); 215 if(count($PathItems) == 1) return($Pages[$PathItem]); 216 216 else return(''); // Unexpected subpages 217 217 } 218 218 } else return(''); 219 219 } 220 220 221 221 function PageNotFound() 222 222 { … … 225 225 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 226 226 if(array_key_exists('HTTP_REFERER', $_SERVER)) $Referer = ' Referer: '.$_SERVER['HTTP_REFERER']; 227 else $Referer = ''; 228 if(isset($this->ModuleManager->Modules['Log'])) 227 else $Referer = ''; 228 if(isset($this->ModuleManager->Modules['Log'])) 229 229 $this->ModuleManager->Modules['Log']->WriteLog('Stránka "'. 230 230 implode('/', $this->PathItems).'" nenalezena'.$Referer, LOG_TYPE_PAGE_NOT_FOUND); 231 231 return(ShowMessage(sprintf(T('Page "%s" not found'), implode('/', $this->PathItems)), MESSAGE_CRITICAL)); 232 232 } 233 233 234 234 function ShowPage() 235 235 { … … 237 237 /* @var $Page Page */ 238 238 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 239 if($ClassName != '') 239 if($ClassName != '') 240 240 { 241 241 $Page = new $ClassName($this); 242 242 $Output = $Page->GetOutput(); 243 243 $this->BaseView->Title = $Page->Title; 244 if($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output); 244 if($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output); 245 245 } else { 246 246 $Output = $this->PageNotFound(); … … 250 250 echo($Output); 251 251 } 252 } 252 } 253 253 254 254 class BaseView extends View 255 255 { 256 var $Title; 257 256 var $Title; 257 258 258 function ShowTopBar() 259 259 { 260 260 global $LocaleManager; 261 261 262 262 $Output = '<div class="Menu">'; 263 263 if(!$this->System->User->Licence(LICENCE_USER)) … … 291 291 $Output .= '<option title="" value="'.$Locale['Code'].'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>'; 292 292 } 293 $Output .= '</select><noscript><input type="submit" value="Submit" ></noscript></form>';293 $Output .= '</select><noscript><input type="submit" value="Submit"/></noscript></form>'; 294 294 $Output .= '</span></div>'; 295 295 return($Output); 296 296 } 297 297 298 298 function ShowLoginBox() 299 299 { … … 321 321 return($Output); 322 322 } 323 323 324 324 function ShowSearchBox() 325 325 { 326 326 $Output = '<strong>'.T('Search').':</strong>'. 327 '<form action="'.$this->System->Link('/search/').'" method="get"><div>'. 327 '<form action="'.$this->System->Link('/search/').'" method="get"><div>'. 328 328 '<table>'. 329 329 '<tr>'. … … 337 337 return($Output); 338 338 } 339 339 340 340 function ShowMainMenu() 341 341 { … … 355 355 return($Output); 356 356 } 357 357 358 358 function ShowTranslatedMenu() 359 359 { 360 360 global $TranslationTree; 361 361 362 362 $Output = '<strong>'.T('Translate groups').':</strong><br /><div id="TranslationMenu">'; 363 363 $DbResult = $this->System->Database->select('Group', '`Id`, `Name`', '1 ORDER BY `Name`'); … … 380 380 return($Output); 381 381 } 382 382 383 383 function ShowHeader() 384 384 { … … 399 399 $Output .= '<title>'.$Title.'</title>'. 400 400 '</head><body>'; 401 401 402 402 $Output .= $this->ShowTopBar(); 403 403 $Output .= '<table class="page"><tr><td class="menu">'; … … 410 410 return($Output); 411 411 } 412 412 413 413 function ShowFooter() 414 414 { 415 415 global $ScriptStartTime, $Revision, $ReleaseTime; 416 416 417 417 $ScriptGenerateDuration = round(GetMicrotime() - $ScriptStartTime, 2); 418 418 419 419 $Output = '</td>'. 420 420 '<td class="menu2">'; … … 426 426 '<a href="http://svn.zdechov.net/trac/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> '. 427 427 $this->System->Config['Web']['WebCounter']; 428 428 429 429 $Output .= '</td></tr>'; 430 430 if($this->System->Config['Web']['ShowRuntimeInfo'] == true) … … 438 438 return($Output); 439 439 } 440 440 441 441 function ShowPage($Content) 442 442 { … … 445 445 return($Output); 446 446 } 447 447 448 448 function FormatOutput($s) 449 449 { … … 482 482 } 483 483 return($out); 484 } 484 } 485 485 }
Note:
See TracChangeset
for help on using the changeset viewer.