Changeset 815


Ignore:
Timestamp:
Feb 22, 2015, 11:05:49 PM (9 years ago)
Author:
chronos
Message:
  • Remove: Trailing spaces from end of lines from all files.
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/HTML/BBCodeParser2.php

    r760 r815  
    140140     */
    141141    var $_filters       = array();
    142    
     142
    143143    /**
    144144     * Constructor, initialises the options and filters
     
    146146     * Sets options to properly escape the tag
    147147     * characters in preg_replace() etc.
    148      * 
     148     *
    149149     * All the filters in the options are initialised and their defined tags
    150150     * are copied into the private variable _definedTags.
  • trunk/HTML/BBCodeParser2/Filter/Links.php

    r760 r815  
    156156            return $matches[1].$o.'url'.$c.$matches[2].$o.'/url'.$c.$trailing;
    157157        }
    158        
     158
    159159        return $matches[0];
    160160    }
     
    195195            return $o.'url='.$urlServ.$path.$c.$matches[6].$o.'/url'.$c;
    196196        }
    197        
     197
    198198        //Else remove url tag
    199199        return $matches[6];
  • trunk/HTML/BBCodeParser2/Filter/Lists.php

    r760 r815  
    2929
    3030/**
    31  * 
     31 *
    3232 */
    3333class HTML_BBCodeParser2_Filter_Lists extends HTML_BBCodeParser2_Filter
     
    8484        $oe = $options['open_esc'];
    8585        $ce = $options['close_esc'];
    86        
     86
    8787        $pattern = array(   "!".$oe."\*".$ce."!",
    8888                            "!".$oe."(u?)list=(?-i:A)(\s*[^".$ce."]*)".$ce."!i",
     
    9292                            "!".$oe."(u?)list=(?-i:1)(\s*[^".$ce."]*)".$ce."!i",
    9393                            "!".$oe."(u?)list([^".$ce."]*)".$ce."!i");
    94        
     94
    9595        $replace = array(   $o."li".$c,
    9696                            $o."\$1list=upper-alpha\$2".$c,
     
    100100                            $o."\$1list=decimal\$2".$c,
    101101                            $o."\$1list\$2".$c );
    102        
     102
    103103        $this->_preparsed = preg_replace($pattern, $replace, $this->_text);
    104104    }
  • trunk/Modules/AoWoW/AoWoW.php

    r626 r815  
    1313    $this->Dependencies = array();
    1414  }
    15  
     15
    1616  function Start()
    1717  {
  • trunk/Modules/Import/generatecodeXML.php

    r565 r815  
    33//$xml_buffer = array();
    44
    5 function startElement($parser, $name, $attrs) 
     5function startElement($parser, $name, $attrs)
    66{
    77  global $depth, $xml_buffer;
    8  
    9   for ($i = 0; $i < $depth[$parser]; $i++) 
     8
     9  for ($i = 0; $i < $depth[$parser]; $i++)
    1010  {
    1111    echo "  ";
     
    1414//    print_r( $attrs);
    1515   // generování proměných
    16    
     16
    1717   $xml_buffer[count($xml_buffer)+1] = array($depth[$parser],$attrs);
    1818 //  print_r($xml_buffer);
     
    2020}
    2121
    22 function endElement($parser, $name) 
     22function endElement($parser, $name)
    2323{
    2424  global $depth;
    25  
     25
    2626  $depth[$parser]--;
    2727}
     
    3030
    3131$files = scandir($verze);
    32 foreach($files as $file) 
     32foreach($files as $file)
    3333{
    3434  $end = substr($file, strlen($file) - 3);
     
    3636  {
    3737    echo('<br />--'.$file.'<br /><br />');
    38     $file = $verze.'/'.$file; 
     38    $file = $verze.'/'.$file;
    3939    $xml_buffer = array(); //mazání
    40  
     40
    4141    $xml_parser = xml_parser_create();
    4242    xml_set_element_handler($xml_parser, 'startElement', 'endElement');
    43     if (!($fp = fopen($file, 'r'))) 
     43    if (!($fp = fopen($file, 'r')))
    4444    {
    4545      die('could not open XML input');
    4646    }
    4747
    48     while ($data = fread($fp, 4096)) 
     48    while ($data = fread($fp, 4096))
    4949    {
    50       if (!xml_parse($xml_parser, $data, feof($fp))) 
     50      if (!xml_parse($xml_parser, $data, feof($fp)))
    5151      {
    5252        die(sprintf("XML error: %s at line %d",
     
    5656    }
    5757    xml_parser_free($xml_parser);
    58  
    59     for ($i = 0; $i < count($xml_buffer); $i++) 
     58
     59    for ($i = 0; $i < count($xml_buffer); $i++)
    6060    {
    6161      $line = $xml_buffer[$i];
    62        if (isset($line[1]['TEXT'])) 
     62       if (isset($line[1]['TEXT']))
    6363      {
    6464        $name = $line[1]['NAME'];
    6565
    66         if ($name == '') 
     66        if ($name == '')
    6767        { //u FontString
    6868          $j = 1;
    69           while (substr($name,0,1) == '') 
     69          while (substr($name,0,1) == '')
    7070          {
    71             if (isset($xml_buffer[$i-$j][1]['NAME'])) 
     71            if (isset($xml_buffer[$i-$j][1]['NAME']))
    7272            {
    73               $name = $xml_buffer[$i-$j][1]['NAME'].$name; 
     73              $name = $xml_buffer[$i-$j][1]['NAME'].$name;
    7474            }
    75             $j++;         
     75            $j++;
    7676          }
    7777        }
    7878
    79         if (substr($name,0,1) == '$') 
     79        if (substr($name,0,1) == '$')
    8080        { //zjišťování potomků
    8181          $j = 1;
    82           while (substr($name,0,1) == '$') 
     82          while (substr($name,0,1) == '$')
    8383          {
    84             if (($xml_buffer[$i-$j][0] < $line[0]) and (isset($xml_buffer[$i-$j][1]['NAME']))) 
     84            if (($xml_buffer[$i-$j][0] < $line[0]) and (isset($xml_buffer[$i-$j][1]['NAME'])))
    8585            {
    8686              $name = substr($name,strlen('$parent'));
    87               $name = $xml_buffer[$i-$j][1]['NAME'].$name; 
     87              $name = $xml_buffer[$i-$j][1]['NAME'].$name;
    8888            }
    89             $j++;         
     89            $j++;
    9090          }
    9191        }
  • trunk/Modules/News/News.php

    r765 r815  
    66{
    77  var $RSSChannels;
    8  
     8
    99  function __construct($System)
    1010  {
     
    1717    $this->Dependencies = array();
    1818  }
    19  
     19
    2020  function Start()
    2121  {
    2222        $this->System->RegisterPage('news', 'PageNews');
    2323        $this->System->RegisterPage('rss', 'PageRSS');
    24         $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news', 
     24        $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news',
    2525          'Callback' => array('PageNews', 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS));
    2626  }
    27  
     27
    2828  function ShowBox()
    2929  {
     
    3737        return($Output);
    3838  }
    39  
     39
    4040  function RegisterRSS($Channel, $Pos = NULL, $Callback = NULL)
    4141  {
     
    4747    }
    4848  }
    49  
     49
    5050  function ShowRSSHeader()
    5151  {
    52     $Output = ''; 
     52    $Output = '';
    5353    foreach($this->RSSChannels as $Channel)
    5454                {
     
    5656                          $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    5757                        $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
    58                 }               
     58                }
    5959    return($Output);
    6060  }
     
    7474                return($Output);
    7575        }
    76        
     76
    7777        function ShowList()
    7878        {
     
    8282               
    8383                $Output = '<h3>'.T('News').'</h3>'.$PageList['Output'];
    84                 if($this->System->User->Licence(LICENCE_ADMIN)) 
     84                if($this->System->User->Licence(LICENCE_ADMIN))
    8585                        $Output .= ' <a href="?a=add">'.T('Add').'</a>';
    8686                $Output .= '<div class="shoutbox">';
     
    9090                        $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>';
    9191                $Output .= '</div>'.$PageList['Output'];
    92                 return($Output);               
     92                return($Output);
    9393        }
    94        
     94
    9595        function ShowAddForm()
    9696        {
     
    124124                return($Output);
    125125        }
    126        
     126
    127127        function ShowRSS()
    128128        {
     
    149149            'Items' => $Items,
    150150          ));
    151           return($Output);       
     151          return($Output);
    152152        }
    153153}
  • trunk/Modules/ShoutBox/ShoutBox.php

    r805 r815  
    1313    $this->Dependencies = array('News');
    1414  }
    15  
     15
    1616  function Start()
    1717  {
    1818        $this->System->RegisterPage('shoutbox', 'PageShoutBox');
    1919        $this->System->ModuleManager->Modules['News']->RegisterRSS(array(
    20           'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'), 
    21           'Permission' => LICENCE_ANONYMOUS));           
     20          'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'),
     21          'Permission' => LICENCE_ANONYMOUS));
    2222    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
    2323      $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox',
    2424      T('Shoutbox'), array('UserName', 'Text'), '`ShoutBox`', $this->System->Link('/shoutbox/?search='));
    2525  }
    26  
     26
    2727  function ShowBox()
    2828  {
     
    3737        $Output .= '</table></div>';
    3838        return($Output);
    39   }   
     39  }
    4040}
    4141
     
    5353                return($Output);
    5454        }
    55        
     55
    5656        function ShowList()
    5757        {
     
    6464                        $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")';
    6565                        $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>';
    66                 } else $SearchQuery = '';                       
     66                } else $SearchQuery = '';
    6767
    6868        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ShoutBox` WHERE 1'.$SearchQuery);
     
    7171
    7272                $Output .= '<h3>'.T('Shoutbox').'</h3>'.$PageList['Output'];
    73                 if($this->System->User->Licence(LICENCE_USER)) 
     73                if($this->System->User->Licence(LICENCE_USER))
    7474                        $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    7575                $Output .= '<div class="shoutbox">';
     
    8080                return($Output);
    8181        }
    82        
     82
    8383        function ShowAddForm()
    8484        {
     
    9898                }       else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL);
    9999                $Output .= $this->ShowList();
    100           return($Output);     
     100          return($Output);
    101101        }
    102        
     102
    103103        function AddFinish()
    104104        {
     
    134134                $Output .= $this->ShowList();
    135135                return($Output);
    136         }       
    137        
     136        }
     137
    138138        function ShowRSS()
    139139        {
  • trunk/Modules/Translation/Translation.php

    r806 r815  
    2020    $this->Dependencies = array('News');
    2121  }
    22  
     22
    2323  function Start()
    2424  {
    2525        global $TranslationTree;
    26        
     26
    2727                $this->System->RegisterPage('comparison.php', 'PageTranslationComparison');
    2828        $this->System->RegisterPage('form.php', 'PageTranslationForm');
     
    3131    $this->System->RegisterPage('TranslationList.php', 'PageTranslationList');
    3232    $this->System->RegisterPage('LoadNames.php', 'PageLoadNames');
    33     $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Last translations'), 
     33    $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Last translations'),
    3434      'Channel' => 'translation', 'Callback' => array($this, 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS));
    3535    $this->System->RegisterMenuItem(array(
     
    3939        'Permission' => LICENCE_ANONYMOUS,
    4040        'Icon' => '',
    41     ), 1);   
     41    ), 1);
    4242    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
    4343    {
     
    4545                  {
    4646                          $Table = $Group['TablePrefix'];
    47        
     47
    4848                                $Columns = array('ID', 'Entry');
    4949                          foreach($Group['Items'] as $Item)
    5050                          {
    5151                                if($Item['Column'] != '') $Columns[] = $Item['Column'];
    52                           } 
     52                          }
    5353
    5454        $this->System->ModuleManager->Modules['Search']->RegisterSearch('group'.$Group['Id'],
    5555        sprintf(T('Translation group "%s"'), $Group['Name']), $Columns, '`'.$Table.'`', $this->System->Link('/TranslationList.php?group='.
    56         $Group['Id'].'&amp;user=0&amp;state=0&amp;entry=&amp;text='));                 
     56        $Group['Id'].'&amp;user=0&amp;state=0&amp;entry=&amp;text='));
    5757                }
    58     }     
     58    }
    5959  }
    60  
     60
    6161  function ShowRSS()
    6262  {
  • trunk/includes/Application.php

    r577 r815  
    55        var $Name;
    66        var $System;
    7        
     7
    88        function Run()
    99        {
    10                
     10
    1111        }
    1212}
  • trunk/includes/Base.php

    r573 r815  
    66  var $Config;
    77  var $System;
    8  
     8
    99  function __construct($System)
    1010  {
     
    1717class Model extends Base
    1818{
    19        
     19
    2020}
    2121
  • trunk/includes/FileStream.php

    r553 r815  
    77  private $Handle;
    88  private $FileName;
    9    
     9
    1010  function __construct()
    1111  {
    1212    $this->Handle = false;
    13   } 
    14    
    15   function __destruct() 
     13  }
     14
     15  function __destruct()
    1616  {
    1717    if($this->Handle)
    1818      fclose($this->Handle);
    1919  }
    20    
     20
    2121  public function OpenFile($FileName)
    2222  {
     
    2424    $this->CloseFile();
    2525    $this->Handle = fopen($FileName, 'rb');
    26     if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 
     26    if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND));
    2727  }
    2828
     
    3232    $this->CloseFile();
    3333    $this->Handle = fopen($FileName, 'wb+');
    34     if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 
     34    if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND));
    3535  }
    36  
     36
    3737  public function CloseFile()
    3838  {
    3939    if($this->Handle)
    40       fclose($this->Handle);   
     40      fclose($this->Handle);
    4141  }
    42    
     42
    4343  public function ReadBlock($Count)
    4444  {
    4545    return(fread($this->Handle, $Count));
    4646  }
    47  
     47
    4848  public function ReadByte()
    4949  {
    5050    return(fread($this->Handle, 1));
    51   } 
    52    
     51  }
     52
    5353  public function ReadUint()
    5454  {
     
    5656    return($val[1]);
    5757  }
    58    
     58
    5959  public function ReadInt()
    6060  {
    6161    $val = unpack('I*', fread($this->Handle, 4));
    6262    return($val[1]);
    63   } 
    64    
     63  }
     64
    6565  public function ReadFloat()
    6666  {
     
    6868    return($val[1]);
    6969  }
    70    
     70
    7171  public function ReadChar()
    7272  {
     
    7777  {
    7878    return(fgets($this->Handle));
    79   }   
     79  }
    8080
    8181  public function ReadTextLine()
    8282  {
    8383    return(fgets($this->Handle));
    84   }   
    85    
     84  }
     85
    8686  public function WriteBlock($Value, $Count)
    8787  {
    8888    fwrite($this->Handle, $Value, $Count);
    89   }       
    90    
     89  }
     90
    9191  public function WriteByte($Value)
    9292  {
    9393    fwrite($this->Handle, pack('C*', $Value), 1);
    94   } 
    95    
     94  }
     95
    9696  public function WriteUint($Value)
    9797  {
    9898    fwrite($this->Handle, pack('V*', $Value), 4);
    9999  }
    100    
     100
    101101  public function WriteInt($Value)
    102102  {
    103103    fwrite($this->Handle, pack('I*', $Value), 4);
    104   } 
    105    
     104  }
     105
    106106  public function WriteFloat($Value)
    107107  {
    108108    fwrite($this->Handle, pack('f*', $Value), 4);
    109109  }
    110    
     110
    111111  public function WriteChar($Value)
    112112  {
    113113    fwrite($this->Handle, $Value, 1);
    114   }   
    115  
     114  }
     115
    116116  public function WriteString($Value)
    117117  {
     
    128128    fseek($this->Handle, $Position, SEEK_SET);
    129129  }
    130  
     130
    131131  public function GetPosition()
    132132  {
    133133    return(ftell($this->Handle));
    134134  }
    135  
     135
    136136  public function GetSize()
    137137  {
  • trunk/includes/Locale.php

    r619 r815  
    11<?php
    22
    3 class LocaleText 
     3class LocaleText
    44{
    55        var $Data;
     
    1212        $this->Code = 'en';
    1313        $this->Title = 'English';
    14   }     
    15  
     14  }
     15
    1616        function Load()
    1717        {
    1818        }
    19        
     19
    2020        function Translate($Text)
    21         {       
     21        {
    2222                if(array_key_exists($Text, $this->Data) and ($this->Data[$Text] != ''))
    2323                  return($this->Data[$Text]);
    2424                  else return($Text);
    25         }       
     25        }
    2626}
    2727
     
    3030        var $Texts;
    3131        var $Dir;
    32        
     32
    3333        function __construct($System)
    3434        {
     
    3636                $this->Texts = new LocaleText();
    3737        }
    38        
     38
    3939        function Load($Language)
    4040        {
     
    4242                if(file_exists($FileName)) {
    4343                        include_once($FileName);
    44                         $ClassName = 'LocaleText'.$Language;                   
     44                        $ClassName = 'LocaleText'.$Language;
    4545                  $this->Texts = new $ClassName();
    4646                } else throw new Exception('Language file '.$FileName.' not found');
    4747                $this->Texts->Load();
    4848        }
    49        
     49
    5050        function AnalyzeCode($Path)
    5151  {
     
    6060      else if(file_exists($FullName))
    6161      {
    62         if(substr($FullName, -4) == '.php') 
     62        if(substr($FullName, -4) == '.php')
    6363        {
    6464                $Content = file_get_contents($FullName);
    6565                // Search occurence of T() function
    6666                while(strpos($Content, 'T(') !== false)
    67                 { 
     67                {
    6868                        $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1));
    6969                        $Content = substr($Content, strpos($Content, 'T(') + 2);
     
    7171                        //echo($Ord.',');
    7272                        if(!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
    73                         {       
    74                                 // Do for non-alpha previous character                                           
     73                        {
     74                                // Do for non-alpha previous character
    7575                          $Original = substr($Content, 0, strpos($Content, ')'));
    7676                          $Original2 = '';
    77                           if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 
     77                          if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
    7878                            $Original2 = substr($Original, 1, -1);
    79                           if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"')) 
    80                             $Original2 = substr($Original, 1, -1);                       
    81                           if($Original2 != '') 
     79                          if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
     80                            $Original2 = substr($Original, 1, -1);
     81                          if($Original2 != '')
    8282                          {
    8383                                if(!array_key_exists($Original2, $this->Texts->Data))
    8484                                  $this->Texts->Data[$Original2] = '';
    85                           } 
     85                          }
    8686                        }
    87                 }               
    88         }         
    89       }           
     87                }
     88        }
     89      }
    9090    }
    9191  }
    92  
     92
    9393  function SaveToFile($FileName)
    9494  {
     
    111111    file_put_contents($FileName, $Content);
    112112  }
    113  
     113
    114114  function LoadFromDatabase($Database, $LangCode)
    115115  {
     
    150150          $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    151151          '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
    152           else $Database->insert('Locale', array('Language' => $Language['Id'], 
     152          else $Database->insert('Locale', array('Language' => $Language['Id'],
    153153         'Original' => $Index, 'Translated' => $Item));
    154154      }
     
    162162        var $Codes;
    163163        var $Dir;
    164        
     164
    165165        function __construct($System)
    166166        {
    167167                parent::__construct($System);
    168168                $this->Codes = array('en');
    169                 $this->CurrentLocale = new LocaleFile($System);         
    170         }
    171        
     169                $this->CurrentLocale = new LocaleFile($System);
     170        }
     171
    172172        function LoadAvailable()
    173173        {
     
    177177    {
    178178          if(substr($FileName, -4) == '.php')
    179           {             
     179          {
    180180                $Code = substr($FileName, 0, -4);
    181181                $Locale = new LocaleFile($this->System);
     
    183183                $Locale->Load($Code);
    184184                $this->Available['Code'] = array('Code' => $Code, 'Title' => $Locale->Texts->Title);
    185           } 
     185          }
    186186          }
    187187  }
    188        
     188
    189189        function UpdateAll($Directory)
    190190        {
     
    195195    {
    196196          if(substr($FileName, -4) == '.php')
    197           {             
     197          {
    198198                  $FileLocale = new LocaleFile($this->System);
    199                   $FileLocale->Dir = $this->Dir;                 
     199                  $FileLocale->Dir = $this->Dir;
    200200                  $FileLocale->Load(substr($FileName, 0, -4));
    201                  
     201
    202202                  // Add new
    203203                  foreach($Locale->Texts->Data as $Index => $Item)
     
    215215        $this->CurrentLocale->Load($this->CurrentLocale->Texts->Code);
    216216        }
    217        
     217
    218218        function LoadLocale($Code)
    219219        {
     
    227227{
    228228        global $LocaleManager;
    229        
     229
    230230        if(isset($LocaleManager)) return($LocaleManager->CurrentLocale->Texts->Translate($Text));
    231231          else return($Text);
  • trunk/includes/MemoryStream.php

    r553 r815  
    55  public $Data;
    66  public $Position;
    7    
     7
    88  function __construct()
    99  {
    1010    $this->Data = '';
    1111    $this->Position = 0;
    12   } 
    13    
    14   function __destruct() 
     12  }
     13
     14  function __destruct()
    1515  {
    1616  }
    17  
     17
    1818  public function ReadBlock($Count)
    1919  {
     
    2222    return($Result);
    2323  }
    24  
     24
    2525  public function ReadByte()
    2626  {
     
    2828    $this->Position = $this->Position + 1;
    2929    return($Result);
    30   } 
    31    
     30  }
     31
    3232  public function ReadUint()
    3333  {
     
    3636    return($val[1]);
    3737  }
    38    
     38
    3939  public function ReadInt()
    4040  {
     
    4242    $this->Position = $this->Position + 4;
    4343    return($val[1]);
    44   } 
    45    
     44  }
     45
    4646  public function ReadFloat()
    4747  {
     
    5050    return($val[1]);
    5151  }
    52    
     52
    5353  public function ReadChar()
    5454  {
     
    7575    $this->Data = substr_replace($this->Data, $Value, $this->Position, $Count);
    7676    $this->Position = $this->Position + $Count;
    77   } 
     77  }
    7878
    7979  public function WriteByte($Value)
     
    8181    $this->Data[$this->Position] = pack('C*', $Value);
    8282    $this->Position++;
    83   } 
    84    
     83  }
     84
    8585  public function WriteUint($Value)
    8686  {
    8787    $this->WriteBlock(pack('V*', $Value), 4);
    8888  }
    89    
     89
    9090  public function WriteInt($Value)
    9191  {
    9292    $this->WriteBlock(pack('I*', $Value), 4);
    93   } 
    94    
     93  }
     94
    9595  public function WriteFloat($Value)
    9696  {
    9797    $this->WriteBlock(pack('f*', $Value), 4);
    9898  }
    99    
     99
    100100  public function WriteChar($Value)
    101101  {
    102102    $this->Data[$this->Position] = pack('C*', $Value);
    103103    $this->Position++;
    104   }   
    105  
     104  }
     105
    106106  public function WriteLine($Value)
    107107  {
     
    113113    $this->Position = $Position;
    114114  }
    115  
     115
    116116  public function GetPosition()
    117117  {
    118118    return($this->Position);
    119119  }
    120  
     120
    121121  public function GetSize()
    122122  {
  • trunk/includes/Update.php

    r805 r815  
    88  var $Database;
    99  var $InstallMethod;
    10  
     10
    1111  function __construct()
    1212  {
     
    1515          $this->VersionTable = 'DbVersion';
    1616  }
    17  
     17
    1818  function GetDbVersion()
    1919  {
    2020          $DbResult = $this->Database->select('DbVersion', '*', 'Id=1');
    21           $Version = $DbResult->fetch_assoc();   
     21          $Version = $DbResult->fetch_assoc();
    2222    return($Version['Revision']);
    2323  }
    24  
     24
    2525  function IsInstalled()
    26   {     
     26  {
    2727          $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
    2828    return($DbResult->num_rows > 0);
     
    3333          return($this->Revision <= $this->GetDbVersion());
    3434  }
    35  
     35
    3636  function Update()
    3737  {
    3838          $DbRevision = $this->GetDbVersion();
    39         $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 
     39        $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
    4040          while($this->Revision > $DbRevision)
    4141    {
    4242            $TraceItem = $this->Trace[$DbRevision];
    43             $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>';     
    44             $RevUpdate = $TraceItem['Function'];         
     43            $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>';
     44            $RevUpdate = $TraceItem['Function'];
    4545            $RevUpdate($this);
    4646            $DbRevision = $TraceItem['Revision'];
    4747            $this->Database->query('UPDATE `DbVersion` SET `Revision`= '.$TraceItem['Revision'].' WHERE `Id`=1');
    4848          }
    49           return($Output);       
     49          return($Output);
    5050  }
    51  
     51
    5252  function Install()
    53   {     
    54         $InstallMethod = $this->InstallMethod; 
     53  {
     54        $InstallMethod = $this->InstallMethod;
    5555        $InstallMethod($this);
    5656        $this->Update();
    5757  }
    58  
     58
    5959  function Uninstall()
    6060  {
    61    
     61
    6262  }
    63  
     63
    6464  function Execute($Query)
    6565  {
  • trunk/includes/Version.php

    r813 r815  
    66// and system will need database update.
    77
    8 $Revision = 813; // Subversion revision
     8$Revision = 815; // Subversion revision
    99$DatabaseRevision = 811; // Database structure revision
    10 $ReleaseTime = '2014-06-03';
     10$ReleaseTime = '2015-02-22';
  • trunk/includes/dbc.php

    r553 r815  
    2424  private $ColumnFormat; // Array (Index => Type)
    2525  private $EndOffset; // Calculated RecordSize according columns type
    26    
     26
    2727  private $RecordSize;
    2828  private $RecordCount;
    2929  private $StringBlockSize;
    3030  private $FieldCount;
    31      
     31
    3232  public function OpenFile($FileName, $ColumnFormat = array())
    3333  {
    3434    parent::OpenFile($FileName);
    35    
     35
    3636    $this->ColumnFormat = $ColumnFormat;
    3737    if($this->ReadUint() != DBC_SIGNATURE) die(NOT_DBC_FILE);
    38        
     38
    3939    $this->RecordCount = $this->ReadUint();
    4040    $this->FieldCount = $this->ReadUint();
    4141    $this->RecordSize = $this->ReadUint();
    4242    $this->StringBlockSize = $this->ReadUint();
    43      
     43
    4444    $this->GenerateOffsetTable();
    4545    if($this->EndOffset != $this->RecordSize)
    46     die(RECORD_SIZE_NOT_MATCH.$this->EndOffset.' <> '.$this->RecordSize); 
     46    die(RECORD_SIZE_NOT_MATCH.$this->EndOffset.' <> '.$this->RecordSize);
    4747  }
    4848
     
    5050  {
    5151    parent::CreateFile($FileName);
    52    
     52
    5353    $this->WriteUint(DBC_SIGNATURE);
    54        
     54
    5555    $this->StringList = array();
    5656    $this->StringOffset = 1;
     
    6565    $this->WriteUint($this->FieldCount);
    6666    $this->WriteUint($this->RecordSize);
    67     $this->WriteUint($this->StringBlockSize);         
    68   }
    69    
     67    $this->WriteUint($this->StringBlockSize);
     68  }
     69
    7070  private function GenerateOffsetTable()
    7171  {
    7272    // Preallocate array
    73     if($this->FieldCount > 0) $this->Offsets = array_fill(0, $this->FieldCount, 0); 
     73    if($this->FieldCount > 0) $this->Offsets = array_fill(0, $this->FieldCount, 0);
    7474      else $this->Offsets = array();
    75    
     75
    7676    $Offset = 0;
    7777    $I = 0;
     
    8383      switch($Format)
    8484      {
    85         case FORMAT_BYTE: 
    86           $Offset += 1; 
    87           break;
    88         case FORMAT_UINT32: 
    89         case FORMAT_SINT32: 
    90         case FORMAT_SINGLE: 
    91         case FORMAT_STRING: 
    92           $Offset += 4; 
    93           break;
    94       } 
     85        case FORMAT_BYTE:
     86          $Offset += 1;
     87          break;
     88        case FORMAT_UINT32:
     89        case FORMAT_SINT32:
     90        case FORMAT_SINGLE:
     91        case FORMAT_STRING:
     92          $Offset += 4;
     93          break;
     94      }
    9595      $I++;
    96     }   
     96    }
    9797    $this->EndOffset = $Offset;
    9898  }
    99  
     99
    100100  private function CellPos($Row, $Column)
    101101  {
    102102    return($this->HeaderSize + $Row * $this->RecordSize + $this->Offsets[$Column]);
    103103  }
    104    
     104
    105105  public function GetByte($Row, $Column)
    106106  {
    107     $this->SetPosition($this->CellPos($Row, $Column)); 
     107    $this->SetPosition($this->CellPos($Row, $Column));
    108108    return($this->ReadByte());
    109   }   
    110    
     109  }
     110
    111111  public function GetUInt($Row, $Column)
    112112  {
    113     $this->SetPosition($this->CellPos($Row, $Column)); 
     113    $this->SetPosition($this->CellPos($Row, $Column));
    114114    return($this->ReadUint());
    115115  }
    116    
     116
    117117  public function GetInt($Row, $Column)
    118118  {
    119     $this->SetPosition($this->CellPos($Row, $Column)); 
     119    $this->SetPosition($this->CellPos($Row, $Column));
    120120    return($this->ReadInt());
    121   } 
    122    
     121  }
     122
    123123  public function GetFloat($Row, $Column)
    124124  {
    125     $this->SetPosition($this->CellPos($Row, $Column)); 
     125    $this->SetPosition($this->CellPos($Row, $Column));
    126126    return($this->ReadFloat());
    127127  }
     
    129129  public function SetByte($Row, $Column, $Value)
    130130  {
    131     $this->SetPosition($this->CellPos($Row, $Column)); 
     131    $this->SetPosition($this->CellPos($Row, $Column));
    132132    $this->WriteByte($Value);
    133   }   
    134    
     133  }
     134
    135135  public function SetUint($Row, $Column, $Value)
    136136  {
    137     $this->SetPosition($this->CellPos($Row, $Column)); 
     137    $this->SetPosition($this->CellPos($Row, $Column));
    138138    $this->WriteUint($Value);
    139139  }
    140    
     140
    141141  public function SetInt($Row, $Column, $Value)
    142142  {
    143     $this->SetPosition($this->CellPos($Row, $Column)); 
     143    $this->SetPosition($this->CellPos($Row, $Column));
    144144    $this->WriteInt($Value);
    145   } 
    146    
     145  }
     146
    147147  public function SetFloat($Row, $Column, $Value)
    148148  {
    149     $this->SetPosition($this->CellPos($Row, $Column)); 
     149    $this->SetPosition($this->CellPos($Row, $Column));
    150150    $this->WriteFloat($Value);
    151151  }
    152  
     152
    153153  public function GetString($Row, $Column)
    154154  {
    155155    $Offset = $this->GetUint($Row, $Column);
    156    
     156
    157157    $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset;
    158158    if($Position >= $this->GetSize()) return('');
    159159    $this->SetPosition($Position);
    160      
     160
    161161    $String = '';
    162162    while(($Char = $this->ReadChar()) != "\0")
     
    165165    }
    166166    return($String);
    167   }   
    168  
     167  }
     168
    169169  public function SetString($Row, $Column, $Value)
    170170  {
    171171    if(in_array($Value, $this->StringList))
    172     { 
     172    {
    173173      $this->SetUint($Row, $Column, $this->StringListOffset[array_search($Value, $this->StringList)]);
    174     } else 
     174    } else
    175175    {
    176176      $this->SetUint($Row, $Column, $this->StringOffset);
     
    189189    $this->WriteUint($this->FieldCount);
    190190    $this->WriteUint($this->RecordSize);
    191     $this->WriteUint($this->StringOffset);         
     191    $this->WriteUint($this->StringOffset);
    192192    $this->SetPosition($this->HeaderSize + $this->RecordCount * $this->RecordSize);
    193193    $this->WriteByte(0);
    194194    foreach($this->StringList as $Index => $Item)
    195     {   
     195    {
    196196      $this->WriteString($Item."\0");
    197197    }
    198   }   
    199    
     198  }
     199
    200200  public function GetLine($Row)
    201201  {
     
    204204    $this->SetPosition($this->CellPos($Row, 0));
    205205    $Record->Data = $this->ReadBlock($this->RecordSize);
    206    
     206
    207207    // Preallocate array
    208     if($this->FieldCount > 0) $Line = array_fill(0, $this->FieldCount, 0); 
     208    if($this->FieldCount > 0) $Line = array_fill(0, $this->FieldCount, 0);
    209209      else $Line = array();
    210210    for($I = 0; $I < $this->FieldCount; $I++)
     
    212212      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
    213213        else $Format = FORMAT_UINT32;
    214       $Record->SetPosition($this->Offsets[$I]); 
     214      $Record->SetPosition($this->Offsets[$I]);
    215215      switch($Format)
    216216      {
    217         case FORMAT_BYTE: 
    218           $Line[$I] = $Record->ReadByte(); 
    219           break;
    220         case FORMAT_UINT32: 
    221           $Line[$I] = $Record->ReadUInt(); 
    222           break;
    223         case FORMAT_SINT32: 
    224           $Line[$I] = $Record->ReadInt(); 
    225           break;
    226         case FORMAT_SINGLE: 
    227           $Line[$I] = $Record->ReadFloat(); 
    228           break;
    229         case FORMAT_STRING: 
     217        case FORMAT_BYTE:
     218          $Line[$I] = $Record->ReadByte();
     219          break;
     220        case FORMAT_UINT32:
     221          $Line[$I] = $Record->ReadUInt();
     222          break;
     223        case FORMAT_SINT32:
     224          $Line[$I] = $Record->ReadInt();
     225          break;
     226        case FORMAT_SINGLE:
     227          $Line[$I] = $Record->ReadFloat();
     228          break;
     229        case FORMAT_STRING:
    230230          $Offset = $Record->ReadUint();
    231              
     231
    232232          $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset;
    233233          if($Position >= $this->GetSize()) $String = '';
    234           else 
     234          else
    235235          {
    236             $this->SetPosition($Position);     
     236            $this->SetPosition($Position);
    237237            $String = '';
    238238            while(($Char = $this->ReadChar()) != "\0")
     
    241241          $Line[$I] = $String;
    242242          break;
    243         default: 
     243        default:
    244244          break;
    245245      }
     
    252252    // Cache record data
    253253    $Record = new MemoryStream();
    254    
     254
    255255    for($I = 0; $I < $this->FieldCount; $I++)
    256256    {
    257257      if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];
    258258        else $Format = FORMAT_UINT32;
    259       $Record->SetPosition($this->Offsets[$I]); 
     259      $Record->SetPosition($this->Offsets[$I]);
    260260      switch($Format)
    261261      {
    262         case FORMAT_BYTE: 
    263           $Record->WriteByte($Line[$I]); 
    264           break;
    265         case FORMAT_UINT32: 
    266           $Record->WriteUint($Line[$I]); 
    267           break;
    268         case FORMAT_SINT32: 
    269           $Record->WriteInt($Line[$I]); 
    270           break;
    271         case FORMAT_SINGLE: 
    272           $Record->WriteFloat($Line[$I]); 
    273           break;
    274         case FORMAT_STRING: 
     262        case FORMAT_BYTE:
     263          $Record->WriteByte($Line[$I]);
     264          break;
     265        case FORMAT_UINT32:
     266          $Record->WriteUint($Line[$I]);
     267          break;
     268        case FORMAT_SINT32:
     269          $Record->WriteInt($Line[$I]);
     270          break;
     271        case FORMAT_SINGLE:
     272          $Record->WriteFloat($Line[$I]);
     273          break;
     274        case FORMAT_STRING:
    275275          if(in_array($Line[$I], $this->StringList))
    276           { 
     276          {
    277277            $Record->WriteUint($this->StringListOffset[array_search($Line[$I], $this->StringList)]);
    278           } else 
     278          } else
    279279          {
    280280            $Record->WriteUint($this->StringOffset);
     
    284284          }
    285285          break;
    286         default: 
     286        default:
    287287          break;
    288288      }
    289289    }
    290    
     290
    291291    $this->SetPosition($this->CellPos($Row, 0));
    292292    $this->WriteBlock($Record->Data, $this->RecordSize);
    293293    return($Line);
    294   } 
    295    
    296   public function GetRecordCount() 
    297   { 
    298     return($this->RecordCount); 
    299   }
    300 
    301   public function SetRecordCount($Value) 
    302   { 
     294  }
     295
     296  public function GetRecordCount()
     297  {
     298    return($this->RecordCount);
     299  }
     300
     301  public function SetRecordCount($Value)
     302  {
    303303    $this->RecordCount = $Value;
    304304  }
    305305
    306   public function GetFieldCount() 
    307   { 
    308     return($this->FieldCount); 
    309   }
    310 
    311   public function SetFieldCount($Value) 
    312   { 
     306  public function GetFieldCount()
     307  {
     308    return($this->FieldCount);
     309  }
     310
     311  public function SetFieldCount($Value)
     312  {
    313313    $this->FieldCount = $Value;
    314314    $this->GenerateOffsetTable();
Note: See TracChangeset for help on using the changeset viewer.