Changeset 469 for trunk/Common


Ignore:
Timestamp:
Dec 30, 2012, 9:13:55 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Hlavní stránka přetvořena jako aplikační modul.
Location:
trunk/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/AppModule.php

    r467 r469  
    1818  /** @var ModularSystem */
    1919  var $Manager;
     20  var $OnChange;
    2021 
    21   function __construct($Database, $System)
     22  function __construct($System)
    2223  {
    2324    $this->System = &$System;
    24     $this->Database = &$Database;
     25    $this->Database = &$System->Database;
    2526  }
    2627 
     
    3940  function Stop()
    4041  {
     42  }
     43}
     44
     45class AppModuleManager
     46{
     47  var $Modules;
     48 
     49  function __construct()
     50  {
     51    $this->Modules = array();     
    4152  }
    4253 
     54  function StartAll()
     55  {
     56    foreach($this->Modules as $Index => $Module)
     57    {
     58      //DebugLog('Init module '.$Module->Name);
     59      $this->Modules[$Index]->Start();
     60    }
     61  }
     62
     63  function StopAll()
     64  {
     65    foreach($this->Modules as $Index => $Module)
     66    {
     67      //DebugLog('Init module '.$Module->Name);
     68      $this->Modules[$Index]->Stop();
     69    }
     70  }
     71 
     72  function ModulePresent($Name)
     73  {
     74    return(array_key_exists($Name, $this->Modules));
     75  }
     76 
     77  function RegisterModule(AppModule $Module)
     78  {
     79    $this->Modules[$Module->Name] = &$Module; 
     80    $Module->Manager = &$this;
     81    $Module->OnChange = &$this->OnModuleChange;
     82  }
     83 
     84  function UnregisterModule($Module)
     85  {
     86    unset($this->Modules[array_search($Module, $this->Modules)]); 
     87  }
    4388}
    4489
  • trunk/Common/Error.php

    r445 r469  
    5757        foreach($Item['args'] as $Item)
    5858        {
    59           if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
     59          if(is_array($Item) || is_object($Item)) $Arguments .= "'".serialize($Item)."',";
    6060          else $Arguments .= "'".$Item."',";
    6161        }
  • trunk/Common/Global.php

    r463 r469  
    22
    33$ConfigFileName = dirname(__FILE__).'/../config.php';
     4/* @var $System System */
     5$System = NULL;
     6/* @var $Database Database */
     7$Database = NULL;
    48     
    59if(file_exists($ConfigFileName)) include_once($ConfigFileName);
     
    2327 
    2428include_once(dirname(__FILE__).'/../Modules/Meteostation/Meteostation.php');
     29include_once(dirname(__FILE__).'/../Modules/Portal/Portal.php');
    2530
    2631$PrefixMultipliers = array
     
    95100class System extends Module
    96101{
    97   var $Modules = array();
     102  var $Modules;
    98103  /** @var Type */
    99104  var $Type;
     105  var $Pages;
     106  /** @var AppModuleManager */
     107  var $ModuleManager;
    100108
    101109  function __construct()
    102110  {
    103111    parent::__construct();
     112    $this->Modules = array();
    104113    $this->Type = new Type($this);
     114    $this->Pages = array();
     115    $this->ModuleManager = new AppModuleManager();
     116  } 
     117 
     118  function RegisterPage($Path, $Handler)
     119  {
     120    $this->Pages[$Path] = $Handler;
     121  }
     122 
     123  function ShowPage($Path)
     124  {
     125    /* @var $Page Page */
     126    $ClassName = $this->Pages[$Path];
     127    $Page = new $ClassName();
     128    $Page->System = &$this;
     129    $Page->Database = &$this->Database;
     130    $Page->GetOutput();
    105131  }
    106132 
     
    209235   
    210236    return($Config['Web']['RootFolder'].$Target);
    211   }
     237  }  
    212238}
    213239
     
    243269  $System->AddModule(new Finance());
    244270  $System->Modules['Finance']->LoadMonthParameters(0);
     271 
     272  // Register new modules
     273  $System->ModuleManager->RegisterModule(new Meteostation($System));
     274  $System->ModuleManager->RegisterModule(new Portal($System));
     275  $System->ModuleManager->StartAll();
    245276}
    246277
Note: See TracChangeset for help on using the changeset viewer.