Ignore:
Timestamp:
Jan 20, 2012, 3:32:02 PM (13 years ago)
Author:
chronos
Message:
  • Přidáno: Model pro NetworkSegment.
  • Upraveno: Přepracován model systém pro načítání modelů modulů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Module.php

    r377 r378  
    1212  var $Dependencies;
    1313  var $Models = array();
     14  var $SupportedModels = array();
    1415  var $Database;
    1516  var $Installed;
     
    3334      $this->System->Modules[$Dependency]->Install();
    3435    $this->LoadModels();
    35     foreach($this->Models as $ModelName)
    36     {
    37       $this->System->Models[$ModelName]->Install();
     36    foreach($this->Models as $Index => $Module)
     37    {
     38      $this->Models[$Index]->Install();
    3839    }
    3940    $this->Database->query('UPDATE SystemModule SET Installed=1 WHERE Name="'.$this->Name.'"');
     
    4344  {
    4445    DebugLog('Uninstalling module '.$this->Name.'...');
    45     foreach($this->Models as $ModelName)
    46     {
    47       $Model = new $ModelName($this->Database, $this->System);
    48       $Model->UnInstall();
    49       unset($Model);
     46    foreach($this->Models as $Index => $Model)
     47    {
     48      $this->Models[$Index]->UnInstall();
    5049    }
    5150    $this->Database->query('UPDATE SystemModule SET Installed=0 WHERE Name="'.$this->Name.'"');
     51    $this->Installed = false;
    5252  }
    5353 
     
    6262  function LoadModels()
    6363  {
    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;
     64    $this->Models = array();
     65    foreach($this->SupportedModels as $ModelName)
     66    {
     67      $NewModel = new $ModelName($this->Database, $this->System);
     68      $NewModel->Module = &$this;
     69      $this->Models[$ModelName] = $NewModel;
    6870    }       
    6971  }
Note: See TracChangeset for help on using the changeset viewer.