Changeset 501


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
Files:
2 added
3 deleted
23 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Common/Database.php

    r486 r501  
    3838  var $ShowSQLQuery = false;
    3939 
    40   function __construct($Host, $User, $Password, $Database)
     40  function __construct()
     41  {   
     42  }
     43 
     44  function Connect($Host, $User, $Password, $Database)
    4145  {   
    4246    if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
     
    6670      $this->Error = $this->Error[2];
    6771      if(($this->Error != '') and ($this->ShowSQLError == true))
    68         echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     72        //echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     73        throw new Exception('SQL Error: </strong>'.$this->Error.', Query: '.$Query);
    6974    }
    7075    return($Result); 
  • trunk/Common/Error.php

    r476 r501  
    44{
    55  var $Encoding;
     6  var $ShowError;
     7  var $UserErrors;
    68   
    79  function __construct()
    810  {
    911    $this->Encoding = 'utf-8';
     12    $this->ShowError = false;
     13    $this->UserErrors = E_ALL;  //E_ERROR | E_WARNING | E_PARSE;
    1014  }
    1115 
     
    1721  function Handle($Number, $Message, $FileName, $LineNumber, $Variables)
    1822  {
    19   global $Config;
     23    $Date = date('Y-m-d H:i:s');                // časové razítko položky
     24    $ErrorType = array
     25    (
     26      1 => 'Error',
     27      2 => 'Warning',
     28      4 => 'Parsing Error',
     29      8 => 'Notice',
     30      16 => 'Core Error',
     31      32 => 'Core Warning',
     32      64 => 'Compile Error',
     33      128 => 'Compile Warning',
     34      256 => 'User Error',
     35      512 => 'User Warning',
     36      1024 => 'User Notice'
     37    );
    2038 
    21   $Date = date('Y-m-d H:i:s');          // časové razítko položky
    22   $ErrorType = array
    23   (
    24     1 => 'Error',
    25     2 => 'Warning',
    26     4 => 'Parsing Error',
    27     8 => 'Notice',
    28     16 => 'Core Error',
    29     32 => 'Core Warning',
    30     64 => 'Compile Error',
    31     128 => 'Compile Warning',
    32     256 => 'User Error',
    33     512 => 'User Warning',
    34     1024 => 'User Notice'
    35   );
    36   $UserErrors = E_ALL;  //E_ERROR | E_WARNING | E_PARSE;
    37  
    38   if(($UserErrors & $Number))
    39   {
    40     $Error = '# '.$Date."\n";
    41     $Backtrace = debug_backtrace();
    42     $Backtrace[0]['function'] = $Message;
    43     $Backtrace[0]['args'] = '';
    44     $Backtrace[0]['file'] = $FileName;
    45     $Backtrace[0]['line'] = $LineNumber;
    46     //$First = array_shift($Backtrace);
    47     //print_r($Backtrace);
     39    if(($this->UserErrors & $Number))
     40    {
     41      $Error = '# '.$Date."\n";
     42      $Backtrace = debug_backtrace();
     43      $Backtrace[0]['function'] = $Message;
     44      $Backtrace[0]['args'] = '';
     45      $Backtrace[0]['file'] = $FileName;
     46      $Backtrace[0]['line'] = $LineNumber;
     47      //$First = array_shift($Backtrace);
    4848   
    49     //array_unshift($Backtrace, $First);
    50     //array_shift($Backtrace);
    51     //print_r($Backtrace);
    52     foreach($Backtrace as $Item)
    53     {
    54       $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
    55       $Arguments = '';
    56       if(array_key_exists('args', $Item) and is_array($Item['args']))
     49      //array_unshift($Backtrace, $First);
     50      //array_shift($Backtrace);
     51      foreach($Backtrace as $Item)
     52      {
     53        $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
     54        $Arguments = '';
     55        if(array_key_exists('args', $Item) and is_array($Item['args']))
    5756        foreach($Item['args'] as $Item)
    5857        {
     
    6160          else $Arguments .= "'".$Item."',";
    6261        }
    63       if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
     62        if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
     63        $Error .= "\n";     
     64      }
    6465      $Error .= "\n";
    6566     
     67      $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error);   
     68   
     69      //if($Config['Web']['ErrorLogFile'] != '')
     70        // error_log($Error, 3, $Config['Web']['ErrorLogFile']);
     71            // Pošli mi zprávu (pokud je to kritická chyba)
     72         //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
     73          // Show error message
     74            if($this->ShowError == true)
     75          {
     76              echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
     77        '<meta http-equiv="Content-Language" content="cs">'."\n".
     78        '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".
     79        'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>');
     80            echo('<pre>'.$Error.'</pre><br/>');                 // V případě ladění chybu i zobraz
     81          echo('</body></html>');
     82            }
     83      if((E_ERROR | E_PARSE) & $Number) die();
    6684    }
    67     $Error .= "\n";
    68    
    69     $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error);   
    70    
    71     //if($Config['Web']['ErrorLogFile'] != '')
    72       //error_log($Error, 3, $Config['Web']['ErrorLogFile']);
    73         // Pošli mi zprávu (pokud je to kritická chyba)
    74         //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
    75         // Show error message
    76         if($Config['Web']['ShowPHPError'] == true)
    77         {
    78             echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
    79       '<meta http-equiv="Content-Language" content="cs">'."\n".
    80       '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".
    81       'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>');
    82           echo('<pre>'.$Error.'</pre><br/>');                   // V případě ladění chybu i zobraz
    83           echo('</body></html>');
    84         }
    85     if((E_ERROR | E_PARSE) & $Number) die();
    86   }
    8785  }
    8886}
  • trunk/Common/Form/Form.php

    r500 r501  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../form_classes.php');
    4 include_once(dirname(__FILE__).'/Database.php');
     3include_once(dirname(__FILE__).'/../Database.php');
     4include_once(dirname(__FILE__).'/Types/Type.php');
    55
    66class Form
    77{
    8   var $Definition = array();
    9   var $Values = array();
    10   var $OnSubmit = '';
    11  
    12   function __construct($ClassName)
    13   { 
    14     global $FormClasses;
    15 
    16     $this->Definition = &$FormClasses[$ClassName];
    17   }
     8  var $FormManager;
     9  var $Definition;
     10  var $Values;
     11  var $OnSubmit;
     12  var $Database;
     13 
     14  function __construct($FormManager)
     15  {     
     16    $this->FormManager = &$FormManager;
     17    $this->Database = $FormManager->Database;
     18    $this->Definition = array();
     19    $this->Values = array();   
     20    $this->OnSubmit = '';
     21  }
     22 
     23  function SetClass($Name)
     24  {
     25    $this->Definition = &$this->FormManager->Classes[$Name];   
     26  }
    1827
    1928  function ShowViewForm()
    2029  {
    21     global $Database, $FormTypes, $System;
    22 
    2330    $Table = array(
    2431      //'Header' => array('Položka', 'Hodnota'),
     
    2633    );
    2734    foreach($this->Definition['Items'] as $Index => $Item)
    28     if(!array_key_exists($Item['Type'], $FormTypes) or
    29     (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    30     {
    31       if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
    32         if(array_key_exists($Item['Type'], $FormTypes))
    33         {           
    34           if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList))
    35             $System->Type->RegisterType($Item['Type'], '', $FormTypes[$Item['Type']]);
    36           if($FormTypes[$Item['Type']]['Type'] == 'Reference')
    37             $UseType = 'OneToMany';
    38           else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     35    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     36    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     37    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     38    {
     39      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     40        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     41        {           
     42          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     43            $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]);
     44          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     45            $UseType = 'OneToMany';
     46          else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    3947            $UseType = 'Enumeration';
    4048        } else $UseType = $Item['Type'];           
    41       $Edit = $System->Type->ExecuteTypeEvent($UseType, 'OnView',
     49      $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
    4250        array('Value' => $this->Values[$Index], 'Name' => $Index,
    4351        'Type' => $Item['Type'], 'Values' => $this->Values));
    4452      if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
    45       if(!$System->Type->IsHidden($UseType))
     53      if(!$this->FormManager->Type->IsHidden($UseType))
    4654        array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    4755    }
     
    6270  function ShowEditBlock($Context = '')
    6371  {
    64     global $Database, $FormTypes, $System;
    65 
    6672    $Hidden = '';
    6773    $IsHidden = false;
     
    7581      if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
    7682    if($Item['ReadOnly'] == false)
    77     if(!array_key_exists($Item['Type'], $FormTypes) or
    78     (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     83    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     84    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     85    ($$this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    7986    {
    8087      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     
    8491          else unset($Parameters['Null']);
    8592
    86         if(array_key_exists($Item['Type'], $FormTypes))
    87         {           
    88           if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList))
    89             $System->Type->RegisterType($Item['Type'], '',
    90               $FormTypes[$Item['Type']]);
    91           if($FormTypes[$Item['Type']]['Type'] == 'Reference')
     93        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     94        {           
     95          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     96            $this->FormManager->Type->RegisterType($Item['Type'], '',
     97              $this->FormManager->FormTypes[$Item['Type']]);
     98          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    9299          {
    93100            $UseType = 'OneToMany';
    94           } else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    95             $UseType = 'Enumeration';
    96         } else $UseType = $Item['Type'];
    97         $Edit = $System->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters);
     101          } else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     102            $UseType = 'Enumeration';
     103        } else $UseType = $Item['Type'];
     104        $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters);
    98105        if(array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix'];
    99106
    100       if(!$System->Type->IsHidden($UseType))
     107      if(!$this->FormManager->Type->IsHidden($UseType))
    101108          array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    102109      else $Hidden .= $Edit;
     
    110117  function LoadValuesFromDatabase($Id)
    111118  {
    112     global $Database, $FormTypes, $System;
    113 
    114     $DbResult = $Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id);
     119    $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id);
    115120    $DbRow = $DbResult->fetch_array();
    116121    foreach($this->Definition['Items'] as $Index => $Item)
    117     if(!array_key_exists($Item['Type'], $FormTypes) or
    118     (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    119     {
    120       if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
    121         if(array_key_exists($Item['Type'], $FormTypes))
    122         {           
    123           if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList))
    124             $System->Type->RegisterType($Item['Type'], '',
    125               $FormTypes[$Item['Type']]);
    126           if($FormTypes[$Item['Type']]['Type'] == 'Reference')
    127             $UseType = 'OneToMany';
    128           else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    129             $UseType = 'Enumeration';
    130         } else $UseType = $Item['Type'];
    131         $this->Values[$Index] = $System->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
     122    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     123    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     124    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     125    {
     126      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     127        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     128        {           
     129          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     130            $this->FormManager->Type->RegisterType($Item['Type'], '',
     131              $this->FormManager->FormTypes[$Item['Type']]);
     132          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     133            $UseType = 'OneToMany';
     134          else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     135            $UseType = 'Enumeration';
     136        } else $UseType = $Item['Type'];
     137        $this->Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
    132138            array('Value' => $DbRow[$Index], 'Name' => $Index,
    133139            'Type' => $Item['Type'], 'Values' => $this->Values));
     
    139145  function SaveValuesToDatabase($Id)
    140146  {
    141     global $Database, $FormTypes, $System;
    142 
    143147    $Values = array();
    144148    foreach($this->Definition['Items'] as $Index => $Item)
     
    146150      if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
    147151      if($Item['ReadOnly'] == false)
    148     if(!array_key_exists($Item['Type'], $FormTypes) or
    149     (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     152    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     153    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     154    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    150155    {
    151156      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     
    153158          'Type' => $Item['Type'], 'Values' => $this->Values);
    154159     
    155         if(array_key_exists($Item['Type'], $FormTypes))
    156         {           
    157           if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList))
    158             $System->Type->RegisterType($Item['Type'], '',
    159               $FormTypes[$Item['Type']]);
    160           if($FormTypes[$Item['Type']]['Type'] == 'Reference')
     160        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     161        {           
     162          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     163            $this->FormManager->Type->RegisterType($Item['Type'], '',
     164              $this->FormManager->FormTypes[$Item['Type']]);
     165          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    161166          {
    162167            $UseType = 'OneToMany';
    163168          }
    164           else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    165             $UseType = 'Enumeration';
    166         } else $UseType = $Item['Type'];
    167         $Values[$Index] = $System->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);
     169          else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     170            $UseType = 'Enumeration';
     171        } else $UseType = $Item['Type'];
     172        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);
    168173        if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
    169174       
     
    174179    {
    175180      $Values['Id'] = $Id;
    176       $DbResult = $Database->insert($this->Definition['Table'], $Values);
     181      $DbResult = $this->Database->insert($this->Definition['Table'], $Values);
    177182    } else
    178       $DbResult = $Database->update($this->Definition['Table'], 'Id='.$Id, $Values);
     183      $DbResult = $this->Database->update($this->Definition['Table'], 'Id='.$Id, $Values);
    179184    //echo($Database->LastQuery);
    180185  }
     
    187192  function LoadValuesFromFormBlock($Context = '')
    188193  {
    189     global $Database, $FormTypes, $System;
    190 
    191194    if($Context != '') $Context = $Context.'-';
    192195    $Values = array();
    193196    foreach($this->Definition['Items'] as $Index => $Item)
    194     if((!array_key_exists($Item['Type'], $FormTypes) or
    195     (array_key_exists($Item['Type'], $FormTypes) and
    196     ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and
     197    if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     198    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     199    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and
    197200    (!array_key_exists('ReadOnly', $Item) or
    198201    (array_key_exists('ReadOnly', $Item) and
     
    200203    {
    201204      //if(array_key_exists($Context.$Index, $_POST))
    202         if(array_key_exists($Item['Type'], $FormTypes))
    203         {           
    204           if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList))
    205             $System->Type->RegisterType($Item['Type'], '',
    206               $FormTypes[$Item['Type']]);
    207           if($FormTypes[$Item['Type']]['Type'] == 'Reference')
    208             $UseType = 'OneToMany';
    209           else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    210             $UseType = 'Enumeration';
    211         } else $UseType = $Item['Type'];
    212         $Values[$Index] = $System->Type->ExecuteTypeEvent($UseType, 'OnLoad',
     205        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     206        {           
     207          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     208            $this->FormManager->Type->RegisterType($Item['Type'], '',
     209              $this->FormManager->FormTypes[$Item['Type']]);
     210          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     211            $UseType = 'OneToMany';
     212          else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     213            $UseType = 'Enumeration';
     214        } else $UseType = $Item['Type'];
     215        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad',
    213216          array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values));
    214217    }
     
    246249}
    247250
    248 function ShowEditTable($ClassName, $Values)
    249 {
     251class FormManager
     252{
     253  var $Classes;
     254  var $FormTypes;
     255  var $Database;
     256  var $Type;
     257 
     258  function __construct($Database)
     259  {
     260    $this->Database = &$Database;
     261    $this->Classes = array();
     262    $this->FormTypes = array();
     263    $this->Type = new Type($this);
     264  }
     265 
     266  function RegisterClass($Name, $Class)
     267  {
     268    $this->Classes[$Name] = $Class;
     269  }
     270 
     271  function UnregisterClass($Name)
     272  {
     273    unset($this->Classes[$Name]);
     274  }
    250275}
    251276
  • trunk/Common/Form/Types/Base.php

    r484 r501  
    33class TypeBase
    44{
    5   var $System;
     5  var $FormManager;
     6  var $Database;
    67  var $DatabaseCompareOperators = array();
    78  var $Hidden;
    89
    9   function __construct($System)
     10  function __construct($FormManager)
    1011  {
    11     $this->System = &$System;
     12    $this->FormManager = &$FormManager;
     13    $this->Database = &$FormManager->Database;
    1214    $this->Hidden = false;
    1315  }
  • trunk/Common/Form/Types/Enumeration.php

    r498 r501  
    77  function OnView($Item)
    88  {
    9     $Type = $this->System->Type->GetTypeDefinition($Item['Type']);
     9    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    1010    if(array_key_exists($Item['Value'], $Type['Parameters']['States']))
    1111      $Output = $Type['Parameters']['States'][$Item['Value']];
     
    1616  function OnEdit($Item)
    1717  {
    18     $Type = $this->System->Type->GetTypeDefinition($Item['Type']);
     18    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    1919    $Output = '<select name="'.$Item['Name'].'">';
    2020      if(array_key_exists('Null', $Item) and $Item['Null'])
  • trunk/Common/Form/Types/Hidden.php

    r484 r501  
    55class TypeHidden extends TypeBase
    66{
    7   function __construct($System)
     7  function __construct($FormManager)
    88  {
    9     parent::__construct($System);
     9    parent::__construct($FormManager);
    1010    $this->Hidden = true;
    1111  }
  • trunk/Common/Form/Types/OneToMany.php

    r483 r501  
    2525  {
    2626    $Output = '<select name="'.$Item['Name'].'">';
    27     $Type = $this->System->Type->TypeDefinitionList[$Item['Type']];
     27    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    2828    if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
    2929      else $Where = '';
     
    3535    if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    3636      else $Table = $Type['Parameters']['Table'];
    37     $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`');
     37    $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`');
    3838    while($DbRow = $DbResult->fetch_assoc())
    3939    {
  • trunk/Common/Form/Types/RandomHash.php

    r484 r501  
    55class TypeRandomHash extends TypeBase
    66{
    7   function __construct($System)
     7  function __construct($FormManager)
    88  {
    9     parent::__construct($System);
     9    parent::__construct($FormManager);
    1010    $this->Hidden = true;
    1111  }
  • trunk/Common/Form/Types/Type.php

    r500 r501  
    1616include(dirname(__FILE__).'/Hyperlink.php');
    1717include(dirname(__FILE__).'/Hidden.php');
    18 include(dirname(__FILE__).'/File/File.php');
     18include(dirname(__FILE__).'/File.php');
     19include(dirname(__FILE__).'/FileContent.php');
    1920include(dirname(__FILE__).'/GPS.php');
    2021include(dirname(__FILE__).'/IPv4Address.php');
     
    2425class Type
    2526{
    26   var $System;
     27  var $FormManager;
    2728  var $TypeDefinitionList;
    2829  var $Values;
    2930
    30   function __construct($System)
     31  function __construct($FormManager)
    3132  {
    32     $this->System = $System;
     33    $this->FormManager = &$FormManager;
    3334    $this->TypeDefinitionList = array
    3435    (
     
    5253      'Color' => array('Name' => 'Color', 'Class' => 'Color', 'ParentType' => '', 'Parameters' => array()),
    5354      'RandomHash' => array('Name' => 'RandomHash', 'Class' => 'RandomHash', 'ParentType' => '', 'Parameters' => array()),
     55      'FileContent' => array('Name' => 'FileContent', 'Class' => 'FileContent', 'ParentType' => '', 'Parameters' => array()),
    5456    );
    5557  }
     
    6163      $Type = $this->TypeDefinitionList[$TypeName];
    6264      $TypeClass = 'Type'.$Type['Class'];
    63       $TypeObject = new $TypeClass($this->System);
     65      $TypeObject = new $TypeClass($this->FormManager);
    6466      if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
    6567        else return($TypeName.'->'.$Event.'('.serialize($Parameters).')');
     
    7375      $Type = $this->TypeDefinitionList[$TypeName];
    7476      $TypeClass = 'Type'.$Type['Class'];
    75       $TypeObject = new $TypeClass($this->System);
     77      $TypeObject = new $TypeClass($this->FormManager);
    7678      return($TypeObject->Hidden);
    7779    } else return(false);
     
    9294  }
    9395
     96  function UnregisterType($Name)
     97  {
     98    unset($this->TypeDefinitionList[$Name]);
     99    // TODO: remove dependent types
     100  }
     101 
    94102  function GetTypeDefinition($TypeName)
    95103  {
  • trunk/Common/Global.php

    r500 r501  
    2121include_once(dirname(__FILE__).'/User.php');
    2222include_once(dirname(__FILE__).'/Page.php');
    23 include_once(dirname(__FILE__).'/Forms.php');
    24 include_once(dirname(__FILE__).'/Types/Type.php');
     23include_once(dirname(__FILE__).'/Form/Form.php');
    2524include_once(dirname(__FILE__).'/File.php');
    2625include_once(dirname(__FILE__).'/../aktuality/news.php');
    2726include_once(dirname(__FILE__).'/../finance/bills.php');
    2827include_once(dirname(__FILE__).'/../finance/finance.php');
     28include_once(dirname(__FILE__).'/../form_classes.php');
     29
    2930 
    3031// Application modules
     
    5758    parent::__construct();
    5859    $this->Modules = array();
    59     $this->Type = new Type($this);
    6060    $this->Pages = array();
    6161    $this->ModuleManager = new AppModuleManager();
    6262    $this->FilesDir = '';
     63    $this->Database = new Database();
     64    $this->FormManager = new FormManager($this->Database);
    6365  } 
    6466 
     
    101103  function AddModule($Module)
    102104  {
    103     global $Database;
    104 
    105105    //echo('Přidávám modul '.get_class($Module).'<br />');
    106106    $Module->System = &$this;
    107     $Module->Database = &$Database;
     107    $Module->Database = &$this->Database;
    108108    $this->Modules[get_class($Module)] = $Module;
    109109  }
     
    166166 
    167167  if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
    168  
    169168   
    170169  // SQL injection hack protection
     
    174173  if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    175174
    176   $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    177   $Database->Prefix = $Config['Database']['Prefix'];
    178   $Database->charset($Config['Database']['Charset']);
    179   $Database->ShowSQLError = $Config['Web']['ShowSQLError'];
    180   $Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];
     175  $System = new System();
     176  $System->Config = $Config;
     177  $System->FilesDir = dirname(__FILE__).'/../'.$Config['Web']['UploadFileFolder'].'/';
     178  $System->Database->Connect($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
     179  $System->Database->Prefix = $Config['Database']['Prefix'];
     180  $System->Database->charset($Config['Database']['Charset']);
     181  $System->Database->ShowSQLError = $Config['Web']['ShowSQLError'];
     182  $System->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];
    181183 
    182184  // Check database persistence structure
    183185  $UpdateManager = new UpdateManager();
    184   $UpdateManager->Database = &$Database;
     186  $UpdateManager->Database = &$System->Database;
    185187  $UpdateManager->Revision = $DatabaseRevision;
    186188  if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
    187189  if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
    188190 
    189   $System = new System();
    190   $System->Config = $Config;
    191   $System->FilesDir = dirname(__FILE__).'/../'.$Config['Web']['UploadFileFolder'].'/';
    192   $System->Database = &$Database;
     191  // Init old modules
    193192  $System->AddModule(new Log());
    194193  $System->AddModule(new ErrorHandler());
     194  $System->Modules['ErrorHandler']->ShowErrors = $Config['Web']['ShowPHPError'];
    195195  $System->Modules['ErrorHandler']->Init();
    196196  $System->AddModule(new User());
     
    200200  $System->AddModule(new Finance());
    201201  $System->Modules['Finance']->LoadMonthParameters(0);
     202  RegisterFormClasses($System->FormManager);
    202203 
    203204  // Register new modules
  • trunk/Common/Page.php

    r494 r501  
    125125    foreach($ScriptNameParts as $ScriptNamePart)
    126126    {
    127       //echo($ScriptNamePart.'<br />');
    128127      if(array_key_exists($ScriptNamePart, $PathTreeItem))
    129128      {
  • trunk/Common/Update.php

    r493 r501  
    153153        if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    154154   
    155         $Database = new Database($this->Config['Database']['Host'], $this->Config['Database']['User'],
     155        $Database = new Database();
     156        $Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'],
    156157           $this->Config['Database']['Password'], $this->Config['Database']['Database']);
    157158        $Database->Prefix = $this->Config['Database']['Prefix'];
  • trunk/Common/Version.php

    r500 r501  
    11<?php
    22
    3 $Revision = 500; // Subversion revision
    4 $DatabaseRevision = 500;
    5 $ReleaseTime = '2013-03-03';
     3$Revision = 501; // Subversion revision
     4$DatabaseRevision = 501;
     5$ReleaseTime = '2013-03-10';
    66
    77?>
  • 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
  • trunk/aktuality/news.php

    r500 r501  
    4444  function ShowNews($Category, $ItemCount, $DaysAgo)
    4545  {
    46     global $Database, $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder;
     46    global $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder;
    4747
    4848    $ItemCount = abs($ItemCount);
    4949    $DaysAgo = abs($DaysAgo);
    50     $DbResult = $Database->select('NewsCategory', '*', 'Id='.$Category);
     50    $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$Category);
    5151    $Row = $DbResult->fetch_array();
    5252    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];     
     
    5555      $Output .= ' <a href="aktuality/index.php?action=add&amp;category='.$Category.'">Přidat</a>';
    5656    $Output .= '</div></div><div class="Content">';
    57     $DbResult = $Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
    58     //echo('<table cellpadding="0" cellspacing="0" width="100%"><tr><td>');
     57    $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
    5958    $Index = 0;
    6059    $FontSize = 12;
  • trunk/finance/manage.php

    r500 r501  
    11<?php
    22
    3 include_once('../Common/Global.php');
     3include_once(dirname(__FILE__).'/../Common/Global.php');
    44
    55class FinanceManagePage extends Page
     
    190190  function ShowNewDeviceForm()
    191191  {
    192     $Form = new Form('NewNetworkDevice');
     192    $Form = new Form($this->System->FormManager);
     193    $Form->SetClass('NewNetworkDevice');
    193194    $Form->OnSubmit = '?Operation=NewDeviceInsert';
    194195    $Output = $Form->ShowEditForm();
     
    198199  function ShowNewDeviceInsert()
    199200  {
    200     $Form = new Form('NewNetworkDevice');
     201    $Form = new Form($this->System->FormManager);
     202    $Form->SetClass('NewNetworkDevice');
    201203    $Form->LoadValuesFromForm();
    202204    $Form->SaveValuesToDatabase(0);
     
    208210  function ShowNewDeviceHistoryForm()
    209211  {
    210     $Form = new Form('NewNetworkDeviceHistory');
     212    $Form = new Form($this->System->FormManager);
     213    $Form->SetClass('NewNetworkDeviceHistory');
    211214    $Form->OnSubmit = '?Operation=NewDeviceHistoryInsert';
    212215    $Output = $Form->ShowEditForm();
     
    216219  function ShowNewDeviceHistoryInsert()
    217220  {
    218     $Form = new Form('NewNetworkDeviceHistory');
     221    $Form = new Form($this->System->FormManager);
     222    $Form->SetClass('NewNetworkDeviceHistory');
    219223    $Form->LoadValuesFromForm();
    220224    $Form->SaveValuesToDatabase(0);
     
    226230  function ShowNewPaymentForm()
    227231  {
    228     $Form = new Form('NewPayment');
     232    $Form = new Form($this->System->FormManager);
     233    $Form->SetClass('NewPayment');
    229234    $Form->OnSubmit = '?Operation=NewPaymentInsert';
    230235    $Output = $Form->ShowEditForm();
     
    234239  function ShowNewPaymentInsert()
    235240  {
    236     $Form = new Form('NewPayment');
     241    $Form = new Form($this->System->FormManager);
     242    $Form->SetClass('NewPayment');
    237243    $Form->LoadValuesFromForm();
    238244    $this->InsertMoney($Form->Values['Subject'], $Form->Values['Value'], $Form->Values['Cash'], $Form->Values['Taxable'], $Form->Values['Time'], $Form->Values['Text'], $Form->Values['DocumentLine']);
     
    247253  function ShowNewInvoiceForm()
    248254  {
    249     $Form = new Form('NewInvoice');
     255    $Form = new Form($this->System->FormManager);
     256    $Form->SetClass('NewInvoice');
    250257    $Form->OnSubmit = '?Operation=NewInvoiceInsert';
    251258    $Output = $Form->ShowEditForm();
     
    255262  function ShowNewInvoiceInsert()
    256263  {
    257     $Form = new Form('NewInvoice');
     264    $Form = new Form($this->System->FormManager);
     265    $Form->SetClass('NewInvoice');
    258266    $Form->LoadvaluesFromForm();
    259267    $Items = array(array('Price' => $Form->Values['Value'],
  • trunk/form_classes.php

    r500 r501  
    1616*/
    1717
    18 $FormClasses = array(
     18function RegisterFormClasses($FormManager)
     19{
     20  $FormManager->Classes = array(
    1921  'ImportBankFile' => array(
    2022    'Title' => 'Import souborů s platbami',
     
    841843);
    842844
    843 $FormTypes = array(
     845$FormManager->FormTypes = array(
    844846  'TServiceCategory' => array(
    845847    'Type' => 'Reference',
     
    12851287  ),
    12861288);
    1287 
     1289}
    12881290
    12891291?>
Note: See TracChangeset for help on using the changeset viewer.