Changeset 501 for trunk/Modules


Ignore:
Timestamp:
Mar 10, 2013, 8:15:46 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: FormManager pro objektové řešení zrušení vazeb na třídu System. FormManager nyní obsluhuje existující formulářové typy a třídy formulářů.
  • Přidáno: Formulářový typ FileContent zajistí načtení obsahu souboru. Typ File pak zajistí i uložení do databáze a přiřazení Id do tabulky File.
  • Odstraněno: Adresář docs obsahoval staré dokumenty. Ty musí být přesunuty do adresáře files a registrovány do databáze.
  • Upraveno: Třídy Database nyní bude hlásit chyby přes výjimky PHP.
Location:
trunk/Modules
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r500 r501  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PageFileImport extends Page
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r500 r501  
    11<?php
    22
    3 include_once('FileImport.php');
     3include_once(dirname(__FILE__).'/FileImport.php');
    44
    55class ModuleFinanceBankAPI extends AppModule
  • trunk/Modules/IS/IS.php

    r498 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PageIS extends Page
     
    1111  function Show()
    1212  {
    13     global $FormClasses;
    14      
    1513    if(!$this->System->Modules['User']->CheckPermission('IS', 'Manage'))
    1614      return('Nemáte oprávnění');
     
    5553      if($_GET['o'] == 'save')
    5654      {
    57         $Form = new Form($Table);
     55        $Form = new Form($this->System->FormManager);
     56        $Form->SetClass($Table);
    5857        $Form->LoadValuesFromForm();
    5958        $Form->SaveValuesToDatabase($Id);
     
    6463    } else
    6564    {
    66       $Form = new Form($Table);
     65      $Form = new Form($this->System->FormManager);
     66      $Form->SetClass($Table);
    6767      $Form->LoadValuesFromDatabase($Id);
    6868      $Form->OnSubmit = '?a=edit&amp;o=save';
     
    9797      if($_GET['o'] == 'save')
    9898      {
    99         $Form = new Form($Table);
     99        $Form = new Form($this->System->FormManager);
     100        $Form->SetClass($Table);
    100101        $Form->LoadValuesFromForm();
    101102        $Form->SaveValuesToDatabase(0);
     
    111112    } else
    112113    {
    113       $Form = new Form($Table);
     114      $Form = new Form($this->System->FormManager);
     115      $Form->SetClass($Table);
    114116      $Form->OnSubmit = '?a=add&amp;o=save';
    115117      $Output .= $Form->ShowEditForm();
     
    124126  function ShowView($Table, $Id)
    125127  {
    126     global $FormTypes;
    127    
    128     $Form = new Form($Table);
     128    $Form = new Form($this->System->FormManager);
     129    $Form->SetClass($Table);
    129130    $Form->LoadValuesFromDatabase($Id);
    130131    $Form->OnSubmit = '?a=view';
     
    143144    // Show ManyToOne relations
    144145    foreach($Form->Definition['Items'] as $Index => $Item)
    145     if((array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
    146     {
    147       $Output .= $this->ShowList($FormTypes[$Item['Type']]['Table'], '`'.$FormTypes[$Item['Type']]['Ref'].'`='.$Id, $Item['Caption']).'<br/>';
     146    if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
     147    ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
     148    {
     149      $Output .= $this->ShowList($this->System->FormManager->FormTypes[$Item['Type']]['Table'], '`'.
     150        $this->System->FormManager->FormTypes[$Item['Type']]['Ref'].'`='.$Id, $Item['Caption']).'<br/>';
    148151    }   
    149152    return($Output);
     
    152155  function ShowList($Table, $Filter = '', $Title = '')
    153156  {   
    154     global $Type, $FormTypes, $FormClasses;
    155    
    156     if($Table != '') $FormClass = $FormClasses[$Table];
     157    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    157158      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    158159    if($Filter != '') $Filter = ' WHERE '.$Filter;
     
    166167   
    167168    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    168     if(!array_key_exists($FormItem['Type'], $FormTypes) or
    169       (array_key_exists($FormItem['Type'], $FormTypes) and ($FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     169    if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type) or
     170      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     171      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    170172      $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
    171173    $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
     
    182184      $Output .= '<tr>';
    183185      foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    184       if(!array_key_exists($FormItem['Type'], $FormTypes) or
    185       (array_key_exists($FormItem['Type'], $FormTypes) and ($FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     186      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     187      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     188      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    186189      {
    187190        //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
    188191        $UseType = $UseType = $FormItem['Type'];
    189         if(array_key_exists($FormItem['Type'], $FormTypes))
     192        if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
    190193        {
    191           if(!array_key_exists($FormItem['Type'], $this->System->Type->TypeDefinitionList))
    192             $this->System->Type->RegisterType($FormItem['Type'], '',
    193               $FormTypes[$FormItem['Type']]);
    194           if($FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     194          if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     195            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
     196              $this->System->FormManager->FormTypes[$FormItem['Type']]);
     197          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
    195198          $UseType = 'OneToMany';
    196199          else
    197           if($FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     200          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
    198201          $UseType = 'Enumeration';
    199202        }
    200         $Row[$ItemIndex] = $this->System->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
     203        $Row[$ItemIndex] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
    201204          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    202205          'Type' => $FormItem['Type']));
    203         $Value = $this->System->Type->ExecuteTypeEvent($UseType, 'OnView',
     206        $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
    204207          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    205208          'Type' => $FormItem['Type']));
  • trunk/Modules/Map/Map.php

    r482 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PageNetworkMap extends Page
  • trunk/Modules/Meteostation/Meteostation.php

    r479 r501  
    11<?php
    22
    3 include_once('Common/Image.php');
    4 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Image.php');
     4include_once(dirname(__FILE__).'/../../Common/Global.php');
    55
    66class PageMeteo extends Page
  • trunk/Modules/Network/HostList.php

    r470 r501  
    11<?php
    2 include_once('Common/Global.php');
     2
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    34
    45class PageHostList extends Page
  • trunk/Modules/OpeningHours/OpeningHours.php

    r473 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PageSubjectOpenTime extends Page
  • trunk/Modules/Portal/Portal.php

    r494 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PagePortal extends Page
     
    4545    $TotalUser = $DbRow[0];
    4646
    47     $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
     47    $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice '.
     48      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
     49      'WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
    4850    $DbRow = $DbResult->fetch_array();
    4951    $OnlineUser = $DbRow[0];
     
    132134  function Show()
    133135  {
    134     global $Database, $Config, $User;
     136    global $Config, $User;
    135137
    136138    $Output = '';
     
    143145      if($_GET['Action'] == 'LoginForm')
    144146      {
    145         $Form = new Form('UserLogin');
     147        $Form = new Form($this->System->FormManager);
     148        $Form->SetClass('UserLogin');
    146149        $Form->OnSubmit = '?Action=Login';
    147150        $Output .= $Form->ShowEditForm();
     
    153156        if(array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
    154157        {
    155         $Form = new Form('UserLogin');
     158        $Form = new Form($this->System->FormManager);
     159        $Form->SetClass('UserLogin');
    156160        $Form->OnSubmit = '?Action=Login';
    157161        $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     
    178182        if($this->System->Modules['User']->User['Id'] != null)
    179183        {
    180           $UserOptions = new Form('UserOptions');
     184          $UserOptions = new Form($this->System->FormManager);
     185          $UserOptions->SetClass('UserOptions');
    181186          $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
    182187          $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     
    186191      if($_GET['Action'] == 'UserOptionsSave')
    187192      {
    188         $UserOptions = new Form('UserOptions', array());
     193        $UserOptions = new Form($this->System->FormManager);
     194        $UserOptions->SetClass('UserOptions');
    189195        $UserOptions->LoadValuesFromForm();
    190196        $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']);
     
    197203      if($_GET['Action'] == 'UserRegister')
    198204      {
    199         $Form = new Form('UserRegister');
     205        $Form = new Form($this->System->FormManager);
     206        $Form->SetClass('UserRegister');
    200207        //$Form->LoadValuesFromForm();
    201208        $Form->OnSubmit = '?Action=UserRegisterSave';
     
    209216      if($_GET['Action'] == 'PasswordRecovery')
    210217      {
    211         $Form = new Form('PasswordRecovery');
     218        $Form = new Form($this->System->FormManager);
     219        $Form->SetClass('PasswordRecovery');
    212220        $Form->OnSubmit = '?Action=PasswordRecovery2';
    213221        $Output .= $Form->ShowEditForm();
     
    215223      if($_GET['Action'] == 'PasswordRecovery2')
    216224      {
    217         $Form = new Form('PasswordRecovery');
     225        $Form = new Form($this->System->FormManager);
     226        $Form->SetClass('PasswordRecovery');
    218227        $Form->LoadValuesFromForm();
    219228        $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     
    230239      if($_GET['Action'] == 'UserRegisterSave')
    231240      {
    232         $Form = new Form('UserRegister', array());
     241        $Form = new Form($this->System->FormManager);
     242        $Form->SetClass('UserRegister');
    233243        $Form->LoadValuesFromForm();
    234244        $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     
    242252      if($_GET['Action'] == 'MemberOptions')
    243253      {
    244         $UserOptions = new Form('MemberOptions');
     254        $Form = new Form($this->System->FormManager);
     255        $Form->SetClass('MemberOptions');
    245256        $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id']);
    246257        if($DbResult->num_rows > 0)
     
    252263           'ON Subject.Id = Member.Subject WHERE Member.Id='.$CustomerUserRel['Customer']);       
    253264          $DbRow = $DbResult->fetch_array();
    254           foreach($UserOptions->Definition['Items'] as $Index => $Item)
     265          foreach($Form->Definition['Items'] as $Index => $Item)
    255266          {
    256             $UserOptions->Values[$Index] = $DbRow[$Index];
     267            $Form->Values[$Index] = $DbRow[$Index];
    257268          }
    258           $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
    259           $Output .= $UserOptions->ShowEditForm();
     269          $Form->OnSubmit = '?Action=MemberOptionsSave';
     270          $Output .= $Form->ShowEditForm();
    260271        } else $Output .= $this->SystemMessage('Chyba', 'Nejste zákazníkem');
    261272      } else
    262273      if($_GET['Action'] == 'MemberOptionsSave')
    263274      {
    264         $UserOptions = new Form('MemberOptions');
    265         $UserOptions->LoadValuesFromForm();
    266         if($UserOptions->Values['FamilyMemberCount'] < 0)
    267           $UserOptions->Values['FamilyMemberCount'] = 0;
    268         if($UserOptions->Values['BillingPeriodNext'] < 2)
    269           $UserOptions->Values['BillingPeriodNext'] = 2;
     275        $Form = new Form($this->System->FormManager);
     276        $Form->SetClass('MemberOptions');
     277        $Form->LoadValuesFromForm();
     278        if($Form->Values['FamilyMemberCount'] < 0)
     279          $Form->Values['FamilyMemberCount'] = 0;
     280        if($Form->Values['BillingPeriodNext'] < 2)
     281          $Form->Values['BillingPeriodNext'] = 2;
    270282         
    271283        $DbResult = $this->Database->update('Member', 'Id='.$this->System->Modules['User']->User['Member'],
    272            array('FamilyMemberCount' => $UserOptions->Values['FamilyMemberCount'],
    273            'BillingPeriodNext' => $UserOptions->Values['BillingPeriodNext']));
     284           array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'],
     285           'BillingPeriodNext' => $Form->Values['BillingPeriodNext']));
    274286        $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Modules['User']->User['Member']);
    275287        $Member = $DbResult->fetch_assoc();
    276288        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
    277           array('Name' => $UserOptions->Values['Name'], 'AddressStreet' => $UserOptions->Values['AddressStreet'],
    278           'AddressTown' => $UserOptions->Values['AddressTown'], 'AddressCountry' => $UserOptions->Values['AddressCountry'],
    279           'AddressPSC' => $UserOptions->Values['AddressPSC'], 'IC' => $UserOptions->Values['IC'],
     289          array('Name' => $Form->Values['Name'], 'AddressStreet' => $Form->Values['AddressStreet'],
     290          'AddressTown' => $Form->Values['AddressTown'], 'AddressCountry' => $Form->Values['AddressCountry'],
     291          'AddressPSC' => $Form->Values['AddressPSC'], 'IC' => $Form->Values['IC'],
    280292          'DIC' => $UserOptions->Values['DIC']));
    281293        $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');
    282         $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno', $UserOptions->Values['Name']);
    283         $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
     294        $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno',
     295          $Form->Values['Name']);
     296        $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, Member.BillingPeriodNext, '.
     297          'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
     298          'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
     299          'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
    284300        $DbRow = $DbResult->fetch_array();
    285         foreach($UserOptions->Definition['Items'] as $Index => $Item)
    286         {
    287           $UserOptions->Values[$Index] = $DbRow[$Index];
     301        foreach($Form->Definition['Items'] as $Index => $Item)
     302        {
     303          $Form->Values[$Index] = $DbRow[$Index];
    288304        }
    289         $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
    290         $Output .= $UserOptions->ShowEditForm();
     305        $Form->OnSubmit = '?Action=MemberOptionsSave';
     306        $Output .= $Form->ShowEditForm();
    291307      }
    292308    }
    293309
    294     $Database->select_db($Config['Database']['Database']);
    295 
    296     $DbResult = $Database->query('SELECT * FROM `HyperlinkGroup`');
     310    $this->Database->select_db($Config['Database']['Database']);
     311
     312    $DbResult = $this->Database->query('SELECT * FROM `HyperlinkGroup`');
    297313    while($DbRow = $DbResult->fetch_assoc())
    298314      $HyperlinkGroups[$DbRow['Id']] = $DbRow;
     
    302318    //$Output .= $this->InfoBar();
    303319    $Output .= '<table id="MainTable"><tr>';
    304     $DbResult = $Database->select('PanelColumn', '*');
     320    $DbResult = $this->Database->select('PanelColumn', '*');
    305321    while($PanelColumn =  $DbResult->fetch_assoc())
    306322    {
     
    308324        else $Width = '';
    309325      $Output .= '<td valign="top"'.$Width.'>';
    310       $DbResult2 = $Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
     326      $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
    311327      while($Panel = $DbResult2->fetch_assoc())
    312328      {
  • trunk/Modules/TV/TV.php

    r494 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PageIPTV extends Page
Note: See TracChangeset for help on using the changeset viewer.