Ignore:
Timestamp:
Apr 14, 2015, 10:16:16 PM (9 years ago)
Author:
chronos
Message:
  • Added: Experimental models internal database structure regeneration.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Setup.php

    r731 r737  
    1515  var $Updates;
    1616  var $ConfigDir;
    17  
     17
    1818  function __construct($System)
    1919  {
     
    2424    $this->ConfigDir = dirname(__FILE__).'/../..';
    2525  }
    26  
     26
    2727  function LoginPanel()
    2828  {
     
    3636    return($Output);
    3737  }
    38  
     38
    3939  function ControlPanel()
    4040  {
    4141    global $YesNo;
    4242    $Output = '';
    43  
     43
    4444    $Output .= 'Je připojení k databázi: '.$YesNo[$this->UpdateManager->Database->Connected()].'<br/>';
    4545    if($this->UpdateManager->Database->Connected())
     
    5858        $Output .= '<a href="?action=uninstall">Odinstalovat</a> ';
    5959        $Output .= '<a href="?action=modules">Správa modulů</a> ';
     60        $Output .= '<a href="?action=models">Přegenerovat modely</a> ';
    6061      } else $Output .= '<a href="?action=install">Instalovat</a> ';
    6162    }
     
    6566    return($Output);
    6667  }
    67  
     68
    6869  function Show()
    6970  {
    7071          global $ConfigDefinition, $DatabaseRevision, $Config, $Updates;
    71          
     72
    7273          $this->UpdateManager = $this->System->Setup->UpdateManager;
    7374          $DefaultConfig = new DefaultConfig();
    7475          $this->ConfigDefinition = $DefaultConfig->Get();
    7576          $this->DatabaseRevision = $DatabaseRevision;
    76           $this->Config = &$Config; 
     77          $this->Config = &$Config;
    7778
    7879          $Output = '';
     
    8586        $Output .= $this->LoginPanel();
    8687      } else
    87       { 
     88      {
    8889        if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
    8990          else $Action = '';
     
    9495          $Output .= $this->LoginPanel();
    9596        } else
     97        if($Action == 'models')
     98        {
     99          $this->System->FormManager->UpdateSQLMeta();
     100        } else
    96101        if($Action == 'upgrade')
    97102        {
    98103          $Output .= '<h3>Povýšení</h3>';
    99           try {   
     104          try {
    100105            $Output .= $this->System->Setup->Upgrade();
    101106          } catch (Exception $E) {
     
    134139        if($Action == 'modules')
    135140        {
    136           $Output .= $this->ShowModules(); 
     141          $Output .= $this->ShowModules();
    137142        } else
    138143        if($Action == 'configure_save')
     
    161166    return($Output);
    162167  }
    163  
     168
    164169  function ShowModules()
    165170  {
     
    201206    return($Output);
    202207  }
    203  
     208
    204209  function ShowList()
    205210  {
    206211    global $YesNo;
    207    
     212
    208213    $Output = '';
    209    
     214
    210215    $Pageing = new Paging();
    211216    $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
     
    227232       else $Dependencies = '&nbsp;';
    228233      $Actions = '';
    229       if($Module->Installed == true) 
     234      if($Module->Installed == true)
    230235      {
    231236        $Actions .= ' <a href="?action=modules&amp;op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
     
    234239        if($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
    235240      } else $Actions .= ' <a href="?action=modules&amp;op=install&amp;name='.$Module->Name.'">Instalovat</a>';
    236    
     241
    237242      $Table->Table->Cells[] = array($Module->Name,
    238         $Module->Creator, $Module->Version, 
     243        $Module->Creator, $Module->Version,
    239244        $Module->License, $YesNo[$Module->Installed],
    240245        $YesNo[$Module->Enabled], $Module->Description,
    241246        $Dependencies, $Actions);
    242247    }
    243     $Output .= $Pageing->Show(); 
     248    $Output .= $Pageing->Show();
    244249    $Output .= $Table->Show();
    245     $Output .= $Pageing->Show();   
     250    $Output .= $Pageing->Show();
    246251    //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    247252    return($Output);
    248253  }
    249  
     254
    250255  function PrepareConfig($Config)
    251256  {
     
    283288    return($Output);
    284289  }
    285  
     290
    286291  function ConfigSave($DefaultConfig)
    287292  {
     
    319324    return($Output);
    320325  }
    321  
     326
    322327  function CreateConfig($Config)
    323328  {
    324329    $Output = "<?php\n\n".
    325330        "\$IsDeveloper = in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n";
    326  
     331
    327332    foreach($this->ConfigDefinition as $Def)
    328333    {
     
    353358          if(!$this->Database->Connected()) $Output .= 'Nelze se připojit k databázi.<br>';
    354359          else {
    355             if(!$this->System->Setup->UpdateManager->IsInstalled()) 
     360            if(!$this->System->Setup->UpdateManager->IsInstalled())
    356361              $Output .= 'Systém vyžaduje instalaci databáze.<br>';
    357362            else
    358             if(!$this->System->Setup->UpdateManager->IsUpToDate()) 
     363            if(!$this->System->Setup->UpdateManager->IsUpToDate())
    359364              $Output .= 'Systém vyžaduje aktualizaci databáze.<br>';
    360365          }
     
    367372{
    368373  var $UpdateManager;
    369  
     374
    370375  function Start()
    371376  {
    372377    global $DatabaseRevision;
    373    
     378
    374379    $this->System->RegisterPage('', 'PageSetupRedirect');
    375380    $this->System->RegisterPage('setup', 'PageSetup');
     
    382387    $this->UpdateManager->Trace = $Updates->Get();
    383388    $this->UpdateManager->InstallMethod = 'FullInstall';
    384   } 
    385  
     389  }
     390
    386391  function Stop()
    387392  {
     
    390395    $this->System->UnregisterPage('setup');
    391396  }
    392  
     397
    393398  function CheckState()
    394399  {
     
    396401      $this->UpdateManager->IsUpToDate());
    397402  }
    398  
     403
    399404  function Install()
    400405  {
    401406        global $DatabaseRevision;
    402        
     407
    403408    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` (
    404409  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    415420) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
    416421  }
    417  
     422
    418423  function Uninstall()
    419424  {
     
    422427    $this->Database->query('DROP TABLE `SystemVersion`');
    423428  }
    424  
     429
    425430  function IsInstalled()
    426431  {
     
    428433    return($DbResult->num_rows > 0);
    429434  }
    430  
     435
    431436  function Upgrade()
    432437  {
Note: See TracChangeset for help on using the changeset viewer.