Ignore:
Timestamp:
Sep 11, 2013, 10:37:54 PM (11 years ago)
Author:
chronos
Message:
  • Modified: Moved some code from global to system file. System class is now serving as main application class. Now old files which still use ShowPage function need system initialization with $InitSystem = true; before global.php inclusion.
  • Modified: Get rid of some global reference to $System, $Config and $User variables.
  • Modified: Search result functionality moved to application module from action.php file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/global.php

    r573 r577  
    2929include_once(dirname(__FILE__).'/../Modules/News/News.php');
    3030include_once(dirname(__FILE__).'/../Modules/Wiki/Wiki.php');
     31include_once(dirname(__FILE__).'/../Modules/Search/Search.php');
    3132include_once(dirname(__FILE__).'/../Modules/FrontPage/FrontPage.php');
    3233
    33 GlobalInit();
    34 $User = &$System->User; // Back compatibility
    35 
    36 function GlobalInit()
    37 {
    38   global $System, $ScriptStartTime, $TranslationTree, $User, $StopAfterUpdateManager,
    39         $UpdateManager, $Config, $DatabaseRevision;
    40 
    41   $ScriptStartTime = GetMicrotime();
    42 
    43   if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    44 
    45   if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
    46   date_default_timezone_set($Config['Web']['Timezone']);
    47  
     34
     35// Back compatibility, will be removed
     36if(isset($InitSystem) and $InitSystem)
     37{
    4838  $System = new System();
    49   $System->Init();
    50 
    51   // Check database persistence structure
    52   $UpdateManager = new UpdateManager();
    53   $UpdateManager->Database = $System->Database;
    54   $UpdateManager->Revision = $DatabaseRevision;
    55   if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
    56   if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
    57 
    58   // SQL injection hack protection
    59   foreach($_POST as $Index => $Item)
    60   {
    61         if(is_array($_POST[$Index]))
    62                 foreach($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2);
    63         else $_POST[$Index] = addslashes($_POST[$Index]);
    64   }
    65   foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
    66    
    67   // TODO: Global initialized variable should be removed
    68   $TranslationTree = GetTranslationTree();
    69  
    70   // Initialize application modules
    71   $System->ModuleManager->RegisterModule(new ModuleError($System));
    72   $System->ModuleManager->Modules['Error']->ShowError = $Config['Web']['ShowPHPError'];
    73   $System->ModuleManager->RegisterModule(new ModuleLog($System));
    74   $System->ModuleManager->RegisterModule(new ModuleUser($System));
    75   $System->ModuleManager->RegisterModule(new ModuleAoWoW($System));
    76   $System->ModuleManager->RegisterModule(new ModuleReferrer($System));
    77   $System->ModuleManager->Modules['Referrer']->Excluded[] = $System->Config['Web']['Host'];
    78   $System->ModuleManager->RegisterModule(new ModuleTeam($System));
    79   $System->ModuleManager->RegisterModule(new ModuleDictionary($System));
    80   $System->ModuleManager->RegisterModule(new ModuleTranslation($System));
    81   $System->ModuleManager->RegisterModule(new ModuleImport($System));
    82   $System->ModuleManager->RegisterModule(new ModuleExport($System));
    83   $System->ModuleManager->RegisterModule(new ModuleServer($System));
    84   $System->ModuleManager->RegisterModule(new ModuleClientVersion($System));
    85   $System->ModuleManager->RegisterModule(new ModuleShoutBox($System));
    86   $System->ModuleManager->RegisterModule(new ModuleNews($System));
    87   $System->ModuleManager->RegisterModule(new ModuleWiki($System));
    88   $System->ModuleManager->RegisterModule(new ModuleFrontPage($System));
    89   $System->ModuleManager->StartAll(); 
    90 }
     39  $System->DoNotShowPage = true;
     40        $System->Run();
     41}
     42
     43class TempPage extends Page
     44{
     45        function Show()
     46        {
     47                global $TempPageContent;
     48                return($TempPageContent);
     49        }
     50}
     51function ShowPage($Content)
     52{
     53        global $TempPageContent, $System;
     54
     55        $TempPage = new TempPage($System);
     56        $System->Pages['temporary-page'] = 'TempPage';
     57        $_SERVER['REDIRECT_QUERY_STRING'] = 'temporary-page';
     58        $TempPageContent = $Content;
     59        $System->PathItems = ProcessURL();
     60        $System->ShowPage();
     61}
     62
    9163
    9264function GetMicrotime()
     
    634606 
    635607  $IconName = array(
    636         MESSAGE_INFORMATION => 'information',
     608          MESSAGE_INFORMATION => 'information',
    637609    MESSAGE_WARNING => 'warning',
    638610    MESSAGE_CRITICAL => 'critical'
Note: See TracChangeset for help on using the changeset viewer.