Changeset 372


Ignore:
Timestamp:
Jan 19, 2012, 1:58:03 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Jednotka Forms přetvořena na View. Namísto globální definice formulářů se nyní použije objektová definice odvozená z třídy View.
Location:
trunk
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r371 r372  
    99include_once('Error.php');
    1010include_once('Code.php');
    11 include_once('Forms.php');
    1211include_once('File.php');
    1312include_once('Page.php');
  • trunk/Common/View.php

    r370 r372  
    11<?php
    22
    3 define('ViewTypeDate', 'Date');
    4 define('ViewTypeTime', 'Time');
    5 define('ViewTypeDateTime', 'DateTime');
    6 define('ViewTypeText', 'Text');
    7 define('ViewTypeString', 'String');
    8 define('ViewTypeBoolean', 'Boolean');
    9 define('ViewTypeInteger', 'Integer');
    10 define('ViewTypeFloat', 'Float');
    11 define('ViewTypeOneToMany', 'OneToMany');
    12 define('ViewTypeManyToOne', 'ManyToOne');
    13 define('ViewTypeManyToMany', 'ManyToMany');
    14 define('ViewTypeIPv4', 'IPv4');
    15 define('ViewTypeIPv6', 'IPv6');
    16 define('ViewTypeMACAddrees', 'MACAddress');
    17 define('ViewTypeFileName', 'FileName');
    18 define('ViewTypePassword', 'Password');
    19 define('ViewTypeURL', 'URL');
    20 define('ViewTypeImage', 'Image');
     3define('ViewItemTypeDate', 'Date');
     4define('ViewItemTypeTime', 'Time');
     5define('ViewItemTypeDateTime', 'DateTime');
     6define('ViewItemTypeText', 'Text');
     7define('ViewItemTypeString', 'String');
     8define('ViewItemTypeBoolean', 'Boolean');
     9define('ViewItemTypeInteger', 'Integer');
     10define('ViewItemTypeFloat', 'Float');
     11define('ViewItemTypeOneToMany', 'OneToMany');
     12define('ViewItemTypeManyToOne', 'ManyToOne');
     13define('ViewItemTypeManyToMany', 'ManyToMany');
     14define('ViewItemTypeIPv4', 'IPv4');
     15define('ViewItemTypeIPv6', 'IPv6');
     16define('ViewItemTypeMACAddrees', 'MACAddress');
     17define('ViewItemTypeFileName', 'FileName');
     18define('ViewItemTypePassword', 'Password');
     19define('ViewItemTypeURL', 'URL');
     20define('ViewItemTypeImage', 'Image');
    2121
    2222class View
     
    2727  var $ModelName;
    2828  var $SubmitText;
     29  var $Values = array();
     30  var $OnSubmit = '';
     31  var $Database;
    2932   
     33  function __construct($Database)
     34  {
     35    $this->Database = &$Database;   
     36  }
     37 
    3038  function AddItemOneToMany($Name, $Title, $TargetModel, $Default)
    3139  {
    32     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeOneToMany, 'Default' => $Default,
     40    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeOneToMany, 'Default' => $Default,
    3341      'TargetModel' => $TargetModel);
    3442  }
     
    3644  function AddItemManyToOne($Name, $Title, $TargetModel, $Default)
    3745  {
    38     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeOneToMany, 'Default' => $Default,
     46    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeManyToOne, 'Default' => $Default,
    3947      'TargetModel' => $TargetModel);
    4048  }
     
    4250  function AddItemInteger($Name, $Title, $Default)
    4351  {
    44     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeInteger, 'Default' => $Default);
     52    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeInteger, 'Default' => $Default);
    4553  }
    4654
    4755  function AddItemFloat($Name, $Title, $Default)
    4856  {
    49     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeFloat, 'Default' => $Default);
     57    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeFloat, 'Default' => $Default);
    5058  }
    5159
    5260  function AddItemText($Name, $Title, $Default)
    5361  {
    54     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeText, 'Default' => $Default);
     62    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeText, 'Default' => $Default);
     63  }
     64
     65  function AddItemString($Name, $Title, $Default)
     66  {
     67    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeString, 'Default' => $Default);
    5568  }
    5669
    5770  function AddItemBoolean($Name, $Title, $Default)
    5871  {
    59     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeBoolean, 'Default' => $Default);
     72    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeBoolean, 'Default' => $Default);
    6073  }
    6174 
    6275  function AddItemDate($Name, $Title, $Default)
    6376  {
    64     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeDate, 'Default' => $Default);
     77    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeDate, 'Default' => $Default);
    6578  }
    6679
    6780  function AddItemTime($Name, $Title, $Default)
    6881  {
    69     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeTime, 'Default' => $Default);
     82    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeTime, 'Default' => $Default);
    7083  }
    7184 
    7285  function AddItemDateTime($Name, $Title, $Default)
    7386  {
    74     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeDateTime, 'Default' => $Default);
     87    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeDateTime, 'Default' => $Default);
    7588  }
    7689
    7790  function AddItemIPv4($Name, $Title, $Default)
    7891  {
    79     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeIPv4, 'Default' => $Default);
     92    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeIPv4, 'Default' => $Default);
    8093  }
    8194 
    8295  function AddItemIPv6($Name, $Title, $Default)
    8396  {
    84     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeIPv6, 'Default' => $Default);
     97    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeIPv6, 'Default' => $Default);
    8598  }
    8699
    87100  function AddItemMACAddress($Name, $Title, $Default)
    88101  {
    89     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeMACAddress, 'Default' => $Default);
     102    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeMACAddress, 'Default' => $Default);
    90103  }
    91104 
    92105  function AddItemFileName($Name, $Title, $Default)
    93106  {
    94     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeFileName, 'Default' => $Default);
     107    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeFileName, 'Default' => $Default);
    95108  }
    96109
    97110  function AddItemURL($Name, $Title, $Default)
    98111  {
    99     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeURL, 'Default' => $Default);
     112    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeURL, 'Default' => $Default);
    100113  }
    101114 
    102115  function AddItemPassword($Name, $Title, $Default)
    103116  {
    104     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypePassword, 'Default' => $Default);
     117    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypePassword, 'Default' => $Default);
    105118  }
    106119
    107120  function AddItemImage($Name, $Title, $Default)
    108121  {
    109     $this->Items[] = array('Name' => 'Name', 'Title' => $Title, 'Type' => ItemTypeImage, 'Default' => $Default);
     122    $this->Items[$Name] = array('Name' => $Name, 'Title' => $Title, 'Type' => ViewItemTypeImage, 'Default' => $Default);
    110123  } 
     124   
     125  function ShowEditForm()
     126  {
     127    if($this->SubmitText == '') $this->SubmitText = 'Uložit';
     128    $Output = '<form class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().'<div><input type="submit" value="'.$this->SubmitText.'" /></div></form>';
     129    return($Output);
     130  }
     131
     132  function ShowEditBlock($Context = '')
     133  {
     134    $Table = array(
     135      //'Header' => array('Položka', 'Hodnota'),
     136      'Rows' => array(),
     137    );
     138    if($Context != '') $Context = $Context.'-';
     139    foreach($this->Items as $Index => $Item)
     140    {
     141      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     142      switch($Item['Type'])
     143      {
     144        case ViewItemTypeBoolean:
     145          if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';
     146          $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.' />';
     147          break;
     148        case ViewItemTypeString:
     149          $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     150          break;
     151        case ViewItemTypeText:
     152          $Edit = '<textarea style="width: 98%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>';
     153          break;
     154        case ViewItemTypePassword:
     155          $Edit = '<input style="width: 98%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     156          break;
     157        case ViewItemTypeInteger:
     158          $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     159          break;
     160        case ViewItemTypeFloat:
     161          $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     162          break;
     163        case ViewItemTypeTime:
     164          if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y');
     165          $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';
     166          break;
     167        case ViewItemTypeOneToMany:
     168          $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';
     169          $DbResult = $this->Database->select($Item['TargetModel'], 'Id, Name', '1 ORDER BY Name');
     170          while($Row = $DbResult->fetch_assoc())
     171          {
     172            if($Row['Id'] == $this->Values[$Index]) $Selected = ' selected="selected"';
     173              else $Selected = '';
     174            $Edit .= '<option value="'.$Row['Id'].'"'.$Selected.'>'.$Row['Id'].': '.$Row['Name'].'</option>';
     175          }
     176          $Edit .= '</select>';
     177          break;
     178        case 'Array':
     179          $Form  = new Form($Item['ItemClass']);
     180          $Edit = '<script type="text/javascript" id="syndication">'.
     181            "var Count = 0;".
     182            "function AddItem() {".
     183            "Count = Count + 1;".
     184            "var newcontent = document.createElement('div');".
     185            "newcontent.id = '".$Context.$Item['ItemClass']."-' + Count;".
     186            "newcontent.innerHTML = '<input type=\"hidden\" name=\"".$Context.$Item['ItemClass']."-' + Count + '\">".$Form->ShowEditBlock($Context.$Item['ItemClass']."-' + Count + '")."';".
     187            "var scr = document.getElementById('syndication');".
     188            "scr.parentNode.insertBefore(newcontent, scr); }".
     189            '</script>';
     190            $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku" /></form>';
     191          break;
     192        default:
     193          if(array_key_exists($Item['Type'], $FormTypes))
     194          {
     195            // Custom types
     196            switch($FormTypes[$Item['Type']]['Type'])
     197            {
     198              case 'Enumeration':
     199                $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';
     200                foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName)
     201                {
     202                  if($this->Values[$Index] == $StateIndex) $Selected = 'selected="selected"';
     203                    else $Selected = '';
     204                  $Edit .= '<option value="'.$StateIndex.'"'.$Selected.'>'.$StateName.'</option>';
     205                }
     206                $Edit .= '</select>';
     207                break;
     208              default:
     209                $Edit = 'Neznámý typ';
     210            }
     211          } else $Edit = 'Neznámý typ';
     212      }
     213      array_push($Table['Rows'], array($Item['Title'].':', $Edit));
     214    }
     215    $Output = '<fieldset><legend>'.$this->Title.'</legend>'.Table($Table).
     216    '</fieldset>';
     217    return($Output);
     218  }
     219
     220  function LoadValuesFromDatabase($Id)
     221  {
     222    $DbResult = $this->Database->query('SELECT T.* FROM '.$this->ModelName.' AS T WHERE T.Id='.$Id);
     223    $DbRow = $DbResult->fetch_array();
     224    foreach($this->Items as $Index => $Item)
     225    {
     226      $this->Values[$Index] = $DbRow[$Index];
     227      switch($Item['Type'])
     228      {
     229        case ViewItemTypePassword:
     230          if($Item['Type'] == ViewItemTypePassword) $this->Values[$Index] = '';  // Dont show password
     231          break;
     232        case ViewItemTypeTime:
     233          $this->Values[$Index] == MysqlDateTimeToTime($this->Values[$Index]);
     234          break;
     235      }
     236    }
     237  }
     238
     239  function SaveValuesToDatabase($Id)
     240  {
     241    foreach($this->Items as $Index => $Item)
     242    {
     243      switch($Item['Type'])
     244      {
     245        case ViewItemTypePassword:
     246          if($this->Values[$Index] == '') unset($this->Values[$Index]); // Do not modify empty passwords
     247          else $this->Values[$Index] = sha1($this->Values[$Index]);
     248          break;
     249        case ViewItemTypeTime:
     250          $this->Values[$Index] = TimeToMysqlDateTime($this->Values[$Index]);
     251          break;
     252      }
     253    }
     254    if($Id == 0)
     255    {
     256      $this->Values['Id'] = $Id;
     257      $DbResult = $this->Database->replace($this->ModelName, $this->Values);
     258    } else
     259    $DbResult = $this->Database->update($this->ModelName, 'Id='.$Id, $this->Values);
     260    //echo($this->Database->LastQuery);
     261  }
     262
     263  function LoadValuesFromForm()
     264  {
     265    $this->Values = $this->LoadValuesFromFormBlock();
     266  }
     267
     268  function LoadValuesFromFormBlock($Context = '')
     269  {
     270    if($Context != '') $Context = $Context.'-';
     271    $Values = array();
     272    foreach($this->Items as $Index => $Item)
     273    {
     274      if(array_key_exists($Context.$Index, $_POST))
     275      switch($Item['Type'])
     276      {
     277        case ViewItemTypeBoolean:
     278          if(array_key_exists($Context.$Index, $_POST)) $Values[$Index] = 1;
     279          else $Values[$Index] = 0;
     280          break;
     281        case ViewItemTypeString:
     282          $Values[$Index] = $_POST[$Context.$Index];
     283          break;
     284        case ViewItemTypeText:
     285          $Values[$Index] = $_POST[$Context.$Index];
     286          break;
     287        case ViewItemTypePassword:
     288          $Values[$Index] = $_POST[$Context.$Index];
     289          break;
     290        case ViewItemTypeInteger:
     291          $Values[$Index] = $_POST[$Context.$Index];
     292          break;
     293        case ViewItemTypeFloat:
     294          $Values[$Index] = $_POST[$Context.$Index];
     295          break;
     296        case ViewItemTypeTime:
     297          $Values[$Index] = explode('.', $_POST[$Context.$Index]);
     298          $Values[$Index] = mktime(0, 0, 0, $Values[$Index][1], $Values[$Index][0], $Values[$Index][2]);
     299          break;
     300        case 'Array':
     301          $I = 1;
     302          //echo('Expect: '.$Context.$Item['ItemClass'].'-'.$I.'<br />');
     303          while(isset($_POST[$Context.$Item['ItemClass'].'-'.$I]))
     304          {
     305            $Form  = new Form($Item['ItemClass']);
     306            $Values[$Index][] = $Form->LoadValuesFromFormBlock($Context.$Item['ItemClass'].'-'.$I);
     307            $I++;
     308          }
     309          break;
     310        default:
     311          if(array_key_exists($Item['Type'], $FormTypes))
     312          {
     313            // Custom types
     314            switch($FormTypes[$Item['Type']]['Type'])
     315            {
     316              case 'Enumeration':
     317                $Values[$Index] = $_POST[$Context.$Index];
     318                break;
     319              case 'Reference':
     320                $Values[$Index] = $_POST[$Context.$Index];
     321                break;
     322              default:
     323            }
     324          }
     325      }
     326    }
     327    return($Values);
     328  }
    111329}
    112330
     331function MakeLink($Target, $Title)
     332{
     333  return('<a href="'.$Target.'">'.$Title.'</a>');
     334}
     335
     336function Table($Table)
     337{
     338  $Result = '<table class="BasicTable">';
     339  if(array_key_exists('Header', $Table))
     340  {
     341    $Result .= '<tr>';
     342    foreach($Table['Header'] as $Item)
     343      $Result .= '<th>'.$Item.'</th>';
     344    $Result .= '</tr>';
     345  }
     346  foreach($Table['Rows'] as $Row)
     347  {
     348    $Result .= '<tr>';
     349    foreach($Row as $Index => $Item)
     350    {
     351      if($Index == 0) $Class = ' class="Header"'; else $Class = '';
     352      $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>';
     353    }
     354    $Result .= '</tr>';
     355  }
     356  $Result .= '</table>';
     357  return($Result);
     358}
     359
     360function ShowEditTable($ClassName, $Values)
     361{
     362}
     363
    113364?>
  • trunk/Modules/FrontPage/FrontPage.php

    r366 r372  
    139139      if($_GET['Action'] == 'LoginForm')
    140140      {
    141         $Form = new Form('UserLogin');
     141        $Form = new UserLoginView($this->Database);
    142142        $Form->OnSubmit = '?Action=Login';
    143143        $Output .= $Form->ShowEditForm();
     
    147147      if($_GET['Action'] == 'Login')
    148148      {
    149         $Form = new Form('UserLogin');
     149        $Form = new UserLoginView($this->Database);
    150150        $Form->OnSubmit = '?Action=Login';
    151151        $Result = $this->System->Models['User']->Login($_POST['Username'], $_POST['Password']);
     
    166166      if($_GET['Action'] == 'UserOptions')
    167167      {
    168         $UserOptions = new Form('UserOptions');
     168        $UserOptions = new UserOptionsView($this->Database);
    169169        $UserOptions->LoadValuesFromDatabase($this->System->Models['User']->User['Id']);
    170170        $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     
    173173      if($_GET['Action'] == 'UserOptionsSave')
    174174      {
    175         $UserOptions = new Form('UserOptions', array());
     175        $UserOptions = new UserOptionsView($this->Dstabase, array());
    176176        $UserOptions->LoadValuesFromForm();
    177177        $UserOptions->SaveValuesToDatabase($this->System->Models['User']->User['Id']);
     
    184184      if($_GET['Action'] == 'UserRegister')
    185185      {
    186         $Form = new Form('UserRegister');
     186        $Form = new UserRegisterView($this->Database);
    187187        $Form->LoadValuesFromForm();
    188188        $Form->OnSubmit = '?Action=UserRegisterSave';
     
    195195      if($_GET['Action'] == 'PasswordRecovery')
    196196      {
    197         $Form = new Form('PasswordRecovery');
     197        $Form = new PasswordRecoveryView($this->Database);
    198198        $Form->OnSubmit = '?Action=PasswordRecovery2';
    199199        $Output .= $Form->ShowEditForm();
     
    201201      if($_GET['Action'] == 'PasswordRecovery2')
    202202      {
    203         $Form = new Form('PasswordRecovery');
     203        $Form = new PasswordRecoveryView($this->Database);
    204204        $Form->LoadValuesFromForm();
    205205        $Result = $this->System->Models['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     
    216216      if($_GET['Action'] == 'UserRegisterSave')
    217217      {
    218         $Form = new Form('UserRegister', array());
     218        $Form = new UserRegisterView($this->Database, array());
    219219        $Form->LoadValuesFromForm();
    220220        $Result = $this->System->Models['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     
    228228      if($_GET['Action'] == 'MemberOptions')
    229229      {
    230         $UserOptions = new Form('MemberOptions');
     230        $UserOptions = new MemberOptionsView($this->Database);
    231231        $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Models['User']->User['Member']);
    232232        $DbRow = $DbResult->fetch_array();
    233         foreach($UserOptions->Definition['Items'] as $Index => $Item)
     233        foreach($UserOptions->Items as $Index => $Item)
    234234        {
    235235          $UserOptions->Values[$Index] = $DbRow[$Index];
     
    240240      if($_GET['Action'] == 'MemberOptionsSave')
    241241      {
    242         $UserOptions = new Form('MemberOptions');
     242        $UserOptions = new MemberOptionsView($this->Database);
    243243        $UserOptions->LoadValuesFromForm();
    244244        if($UserOptions->Values['FamilyMemberCount'] < 0)
     
    255255        $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Models['User']->User['Member']);
    256256        $DbRow = $DbResult->fetch_array();
    257         foreach($UserOptions->Definition['Items'] as $Index => $Item)
     257        foreach($UserOptions->Items as $Index => $Item)
    258258        {
    259259          $UserOptions->Values[$Index] = $DbRow[$Index];
  • trunk/Modules/Member/Member.php

    r371 r372  
    33class MemberOptionsView extends View
    44{
    5   function __construct()
     5  function __construct($Database)
    66  {
     7    parent::__construct($Database);
    78    $this->Title = 'Nastavení domácnosti';
    8     $this->Table = '(SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject)';
    9     AddItemString('Name', 'Fakturační jméno', '');
    10     AddItemString('AddressStreet', 'Ulice', '');
    11     AddItemString('AddressTown', 'Město', '');
    12     AddItemString('PSC', 'PSČ', '');
    13     AddItemString('IC', 'IČ', '');
    14     AddItemString('DIC', 'DIČ', '');
    15     AddItemInteger('FamiltyMemberCount', 'Počet osob v domácnosti', '');
    16     AddItemOneToMany('BillingPeriodNext', 'Požadované fakturační období', '');
    17     AddItemOneToMany('InternetTariffNextMonth', 'Tarif internetu od dalšího období', 2);
     9    $this->ModelName = '(SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject)';
     10    $this->AddItemString('Name', 'Fakturační jméno', '');
     11    $this->AddItemString('AddressStreet', 'Ulice', '');
     12    $this->AddItemString('AddressTown', 'Město', '');
     13    $this->AddItemString('PSC', 'PSČ', '');
     14    $this->AddItemString('IC', 'IČ', '');
     15    $this->AddItemString('DIC', 'DIČ', '');
     16    $this->AddItemInteger('FamilyMemberCount', 'Počet osob v domácnosti', '');
     17    $this->AddItemOneToMany('BillingPeriodNext', 'Požadované fakturační období', 'FinanceBillingPeriod', '');
     18    $this->AddItemOneToMany('InternetTariffNextMonth', 'Tarif internetu od dalšího období', 'FinanceTariff', 2);
    1819  }
    1920}
  • trunk/Modules/Network/Network.php

    r371 r372  
    136136    parent::__construct($Database, $System);
    137137    $this->Name = 'NetworkSubnet';
     138    $this->ModelName = 'Subnet';
    138139    $this->AddPropertyString('Name');
    139140    $this->AddPropertyString('AddressRange');
     
    155156class EmailView extends View
    156157{
    157   function __construct()
    158   {
     158  function __construct($Database)
     159  {
     160    parent::__construct($Database);
    159161    $this->Name = 'NewEmail';
    160162    $this->Title = 'Nový email';
  • trunk/Modules/User/User.php

    r370 r372  
    323323class UserOptionsView extends View
    324324{
    325   function __construct()
    326   {
     325  function __construct($Database)
     326  {
     327    parent::__construct($Database);
    327328    $this->Name = 'UserOptions';
    328329    $this->Title = 'Nastavení uživatele';
    329     AddItemString('Login', 'Přihlašovací jméno', '');
    330     AddItemPassword('Password', 'Heslo', '');
    331     AddItemString('Name', 'Zobrazované jméno', '');
    332     AddItemString('Email', 'E-mail', '');
    333     AddItemString('PhoneNumber', 'Telefon', '');
    334     AddItemString('ICQ', 'ICQ', '');
     330    $this->ModelName = 'User';
     331    $this->AddItemString('Login', 'Přihlašovací jméno', '');
     332    $this->AddItemPassword('Password', 'Heslo', '');
     333    $this->AddItemString('Name', 'Zobrazované jméno', '');
     334    $this->AddItemString('Email', 'E-mail', '');
     335    $this->AddItemString('PhoneNumber', 'Telefon', '');
     336    $this->AddItemString('ICQ', 'ICQ', '');
    335337  }
    336338}
     
    338340class UserRegisterView extends View
    339341{
    340   function __construct()
    341   {
     342  function __construct($Database)
     343  {
     344    parent::__construct($Database);
    342345    $this->Name = 'UserRegister';
    343346    $this->Title = 'Registrace uživatele';
    344347    $this->SubmitText = 'Registrovat';
    345348    $this->ModelName = 'User';
    346     AddItemString('Login', 'Přihlašovací jméno', '');
    347     AddItemPassword('Password', 'Heslo', '');
    348     AddItemPassword('Password2', 'Potvrzení hesla', '');
    349     AddItemString('Name', 'Zobrazované jméno', '');
    350     AddItemString('Email', 'E-mail', '');
    351     AddItemString('PhoneNumber', 'Telefon', '');
    352     AddItemString('ICQ', 'ICQ', '');
     349    $this->AddItemString('Login', 'Přihlašovací jméno', '');
     350    $this->AddItemPassword('Password', 'Heslo', '');
     351    $this->AddItemPassword('Password2', 'Potvrzení hesla', '');
     352    $this->AddItemString('Name', 'Zobrazované jméno', '');
     353    $this->AddItemString('Email', 'E-mail', '');
     354    $this->AddItemString('PhoneNumber', 'Telefon', '');
     355    $this->AddItemString('ICQ', 'ICQ', '');
    353356  }
    354357}
     
    356359class PasswordRecoveryView extends View
    357360{
    358   function __construct()
    359   {
     361  function __construct($Database)
     362  {
     363    parent::__construct($Database);
    360364    $this->Name = 'PasswordRecovery';
    361365    $this->Title = 'Obnova hesla';
    362366    $this->SubmitText = 'Obnovit';
    363     AddItemString('Name', 'Přihlašovací jméno', '');
    364     AddItemString('Email', 'E-mail', '');
     367    $this->AddItemString('Name', 'Přihlašovací jméno', '');
     368    $this->AddItemString('Email', 'E-mail', '');
    365369  }
    366370}
     
    368372class UserLoginView extends View
    369373{
    370   function __construct()
    371   {
     374  function __construct($Database)
     375  {
     376    parent::__construct($Database);
    372377    $this->Name = 'UserLogin';
    373378    $this->Title = 'Přihlášení uživatele';
    374379    $this->SubmitText = 'Přihlásit';
    375     AddItemString('Username', 'Přihlašovací jméno', '');
    376     AddItemPassword('Password', 'Heslo', '');
     380    $this->AddItemString('Username', 'Přihlašovací jméno', '');
     381    $this->AddItemPassword('Password', 'Heslo', '');
    377382  }
    378383}
Note: See TracChangeset for help on using the changeset viewer.