Ignore:
Timestamp:
Mar 13, 2012, 4:08:31 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Seznam závislostí modulů načítán do samostatné tabulky.
  • Upraveno: V základu načíst jen základní moduly a umožnit doinstalaci dalších.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Modular/Common/Module.php

    r383 r398  
    55class Module
    66{
     7  var $Id;
    78  var $Name;
    89  var $Version;
     
    127128  `Installed` int(11) NOT NULL,
    128129  `Description` text COLLATE utf8_czech_ci NOT NULL,
    129   `Dependencies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
    130130  PRIMARY KEY (`Id`)
    131131) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     132   
     133    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModuleDependency` (
     134  `Id` int(11) NOT NULL AUTO_INCREMENT,
     135  `Module` int(11) NOT NULL,
     136  `DependencyModule` int(11) NOT NULL,
     137  PRIMARY KEY (`Id`),
     138  KEY (`Module`),
     139  KEY (`DependencyModule`),
     140  UNIQUE (`Module` , `DependencyModule`)
     141) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     142    $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
     143    $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)');
     144   
    132145    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` (
    133146  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    137150  PRIMARY KEY (`Id`)
    138151) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     152    $this->Database->query('ALTER TABLE `SystemModel` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');
     153   
    139154    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` (
    140155  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    145160  PRIMARY KEY (`Id`)
    146161) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     162    $this->Database->query('ALTER TABLE `SystemModelProperty` ADD FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)');
     163   
    147164    $this->ReloadList();
    148165    $this->LoadModules(false);
    149     foreach($this->Modules as $Index => $Module)
    150     {     
    151       $this->Modules[$Index]->Install();
    152     }
     166    $this->Modules['System']->Install();
     167    //foreach($this->Modules as $Index => $Module)
     168    //{     
     169    //  $this->Modules[$Index]->Install();
     170    //}
    153171  }
    154172 
     
    162180    $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`');
    163181    $this->Database->query('DROP TABLE IF EXISTS `SystemModel`');
     182    $this->Database->query('DROP TABLE IF EXISTS `SystemModuleDependency`');
    164183    $this->Database->query('DROP TABLE IF EXISTS `SystemModule`');
    165184  }
     
    195214          'Version' => $Module->Version, 'Creator' => $Module->Creator,
    196215          'Description' => $Module->Description, 'License' => $Module->License,
    197           'Installed' => 0, 'Dependencies' => implode(',', $Module->Dependencies)));
     216          'Installed' => 0));
    198217        unset($Module);
    199218      } else throw new Exception('Missing class '.$ModuleClassName.' in module '.$ModuleName);
     
    207226      $this->Database->query('DELETE FROM `SystemModule` WHERE `Id` = '.$Module['Id']);
    208227    }
     228   
     229    // Reload dependencies
     230    $this->LoadModules(false);
     231    foreach($this->Modules as $Module)
     232    {
     233      foreach($Module->Dependencies as $Dependency)
     234      {
     235        $this->Database->insert('SystemModuleDependency', array('Module' => $Module->Id,
     236          'DependencyModule' => $this->Modules[$Dependency]->Id));
     237      }
     238    }
    209239  }
    210240}
Note: See TracChangeset for help on using the changeset viewer.