Ignore:
Timestamp:
Jan 20, 2012, 3:05:24 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Testována instalace čisté databáze na základě definic modulů a jejich modelů.
  • Opraveno: Doplněny definice modelů pro FinanceMonthlyOverall a FinanceCharge.
  • Přidáno: Podpora pro nastavitelnost NULL hodnoty u vlastností modelů.
  • Opraveno: Řešení správného kaskádového načítání závislostí modulů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Module.php

    r374 r377  
    2727  function Install()
    2828  {
     29    if($this->Installed) return;
    2930    DebugLog('Installing module '.$this->Name.'...');
     31    $this->Installed = true;
     32    foreach($this->Dependencies as $Dependency) 
     33      $this->System->Modules[$Dependency]->Install();
     34    $this->LoadModels();
    3035    foreach($this->Models as $ModelName)
    3136    {
    32       $Model = new $ModelName($this->Database, $this->System);
    33       $Model->Module = &$this;
    34       $Model->Install();
    35       unset($Model);
     37      $this->System->Models[$ModelName]->Install();
    3638    }
    3739    $this->Database->query('UPDATE SystemModule SET Installed=1 WHERE Name="'.$this->Name.'"');
     
    5254  function Init()
    5355  {
     56    if($this->Initialized) return;
    5457    $this->Initialized = true;
    5558    foreach($this->Dependencies as $Dependency) 
    56       if(!$this->System->Modules[$Dependency]->Initialized)
    57         $this->System->Modules[$Dependency]->Init();
     59      $this->System->Modules[$Dependency]->Init();
     60  }
     61 
     62  function LoadModels()
     63  {
     64    foreach($this->Models as $ModelName)
     65    {
     66      $this->System->Models[$ModelName] = new $ModelName($this->Database, $this->System);
     67      $this->System->Models[$ModelName]->Module = &$this;
     68    }       
    5869  }
    5970}
     
    7586  }
    7687
    77   function Init($Installed = true)
     88  function LoadModules($Installed = true)
    7889  {
    7990    $Query = 'SELECT `Id`, `Name` FROM `SystemModule`';
     
    8899      $this->Modules[$Module['Name']]->Id = $Module['Id'];
    89100    }     
     101  }
     102 
     103  function Init()
     104  {
    90105    foreach($this->Modules as $Index => $Module)
    91106      $this->Modules[$Index]->Init();
     
    103118  `Installed` int(11) NOT NULL,
    104119  `Description` text COLLATE utf8_czech_ci NOT NULL,
    105   `Dependecies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
     120  `Dependencies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
    106121  PRIMARY KEY (`Id`)
    107122) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     
    122137) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    123138    $this->ReloadList();
    124     $this->Init(false);
     139    $this->LoadModules(false);
    125140    foreach($this->Modules as $Index => $Module)
    126141    {
Note: See TracChangeset for help on using the changeset viewer.