Changeset 815
- Timestamp:
- Feb 22, 2015, 11:05:49 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HTML/BBCodeParser2.php
r760 r815 140 140 */ 141 141 var $_filters = array(); 142 142 143 143 /** 144 144 * Constructor, initialises the options and filters … … 146 146 * Sets options to properly escape the tag 147 147 * characters in preg_replace() etc. 148 * 148 * 149 149 * All the filters in the options are initialised and their defined tags 150 150 * are copied into the private variable _definedTags. -
trunk/HTML/BBCodeParser2/Filter/Links.php
r760 r815 156 156 return $matches[1].$o.'url'.$c.$matches[2].$o.'/url'.$c.$trailing; 157 157 } 158 158 159 159 return $matches[0]; 160 160 } … … 195 195 return $o.'url='.$urlServ.$path.$c.$matches[6].$o.'/url'.$c; 196 196 } 197 197 198 198 //Else remove url tag 199 199 return $matches[6]; -
trunk/HTML/BBCodeParser2/Filter/Lists.php
r760 r815 29 29 30 30 /** 31 * 31 * 32 32 */ 33 33 class HTML_BBCodeParser2_Filter_Lists extends HTML_BBCodeParser2_Filter … … 84 84 $oe = $options['open_esc']; 85 85 $ce = $options['close_esc']; 86 86 87 87 $pattern = array( "!".$oe."\*".$ce."!", 88 88 "!".$oe."(u?)list=(?-i:A)(\s*[^".$ce."]*)".$ce."!i", … … 92 92 "!".$oe."(u?)list=(?-i:1)(\s*[^".$ce."]*)".$ce."!i", 93 93 "!".$oe."(u?)list([^".$ce."]*)".$ce."!i"); 94 94 95 95 $replace = array( $o."li".$c, 96 96 $o."\$1list=upper-alpha\$2".$c, … … 100 100 $o."\$1list=decimal\$2".$c, 101 101 $o."\$1list\$2".$c ); 102 102 103 103 $this->_preparsed = preg_replace($pattern, $replace, $this->_text); 104 104 } -
trunk/Modules/AoWoW/AoWoW.php
r626 r815 13 13 $this->Dependencies = array(); 14 14 } 15 15 16 16 function Start() 17 17 { -
trunk/Modules/Import/generatecodeXML.php
r565 r815 3 3 //$xml_buffer = array(); 4 4 5 function startElement($parser, $name, $attrs) 5 function startElement($parser, $name, $attrs) 6 6 { 7 7 global $depth, $xml_buffer; 8 9 for ($i = 0; $i < $depth[$parser]; $i++) 8 9 for ($i = 0; $i < $depth[$parser]; $i++) 10 10 { 11 11 echo " "; … … 14 14 // print_r( $attrs); 15 15 // generování proměných 16 16 17 17 $xml_buffer[count($xml_buffer)+1] = array($depth[$parser],$attrs); 18 18 // print_r($xml_buffer); … … 20 20 } 21 21 22 function endElement($parser, $name) 22 function endElement($parser, $name) 23 23 { 24 24 global $depth; 25 25 26 26 $depth[$parser]--; 27 27 } … … 30 30 31 31 $files = scandir($verze); 32 foreach($files as $file) 32 foreach($files as $file) 33 33 { 34 34 $end = substr($file, strlen($file) - 3); … … 36 36 { 37 37 echo('<br />--'.$file.'<br /><br />'); 38 $file = $verze.'/'.$file; 38 $file = $verze.'/'.$file; 39 39 $xml_buffer = array(); //mazání 40 40 41 41 $xml_parser = xml_parser_create(); 42 42 xml_set_element_handler($xml_parser, 'startElement', 'endElement'); 43 if (!($fp = fopen($file, 'r'))) 43 if (!($fp = fopen($file, 'r'))) 44 44 { 45 45 die('could not open XML input'); 46 46 } 47 47 48 while ($data = fread($fp, 4096)) 48 while ($data = fread($fp, 4096)) 49 49 { 50 if (!xml_parse($xml_parser, $data, feof($fp))) 50 if (!xml_parse($xml_parser, $data, feof($fp))) 51 51 { 52 52 die(sprintf("XML error: %s at line %d", … … 56 56 } 57 57 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++) 60 60 { 61 61 $line = $xml_buffer[$i]; 62 if (isset($line[1]['TEXT'])) 62 if (isset($line[1]['TEXT'])) 63 63 { 64 64 $name = $line[1]['NAME']; 65 65 66 if ($name == '') 66 if ($name == '') 67 67 { //u FontString 68 68 $j = 1; 69 while (substr($name,0,1) == '') 69 while (substr($name,0,1) == '') 70 70 { 71 if (isset($xml_buffer[$i-$j][1]['NAME'])) 71 if (isset($xml_buffer[$i-$j][1]['NAME'])) 72 72 { 73 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 73 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 74 74 } 75 $j++; 75 $j++; 76 76 } 77 77 } 78 78 79 if (substr($name,0,1) == '$') 79 if (substr($name,0,1) == '$') 80 80 { //zjišťování potomků 81 81 $j = 1; 82 while (substr($name,0,1) == '$') 82 while (substr($name,0,1) == '$') 83 83 { 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']))) 85 85 { 86 86 $name = substr($name,strlen('$parent')); 87 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 87 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 88 88 } 89 $j++; 89 $j++; 90 90 } 91 91 } -
trunk/Modules/News/News.php
r765 r815 6 6 { 7 7 var $RSSChannels; 8 8 9 9 function __construct($System) 10 10 { … … 17 17 $this->Dependencies = array(); 18 18 } 19 19 20 20 function Start() 21 21 { 22 22 $this->System->RegisterPage('news', 'PageNews'); 23 23 $this->System->RegisterPage('rss', 'PageRSS'); 24 $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news', 24 $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news', 25 25 'Callback' => array('PageNews', 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS)); 26 26 } 27 27 28 28 function ShowBox() 29 29 { … … 37 37 return($Output); 38 38 } 39 39 40 40 function RegisterRSS($Channel, $Pos = NULL, $Callback = NULL) 41 41 { … … 47 47 } 48 48 } 49 49 50 50 function ShowRSSHeader() 51 51 { 52 $Output = ''; 52 $Output = ''; 53 53 foreach($this->RSSChannels as $Channel) 54 54 { … … 56 56 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 57 57 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 58 } 58 } 59 59 return($Output); 60 60 } … … 74 74 return($Output); 75 75 } 76 76 77 77 function ShowList() 78 78 { … … 82 82 83 83 $Output = '<h3>'.T('News').'</h3>'.$PageList['Output']; 84 if($this->System->User->Licence(LICENCE_ADMIN)) 84 if($this->System->User->Licence(LICENCE_ADMIN)) 85 85 $Output .= ' <a href="?a=add">'.T('Add').'</a>'; 86 86 $Output .= '<div class="shoutbox">'; … … 90 90 $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>'; 91 91 $Output .= '</div>'.$PageList['Output']; 92 return($Output); 92 return($Output); 93 93 } 94 94 95 95 function ShowAddForm() 96 96 { … … 124 124 return($Output); 125 125 } 126 126 127 127 function ShowRSS() 128 128 { … … 149 149 'Items' => $Items, 150 150 )); 151 return($Output); 151 return($Output); 152 152 } 153 153 } -
trunk/Modules/ShoutBox/ShoutBox.php
r805 r815 13 13 $this->Dependencies = array('News'); 14 14 } 15 15 16 16 function Start() 17 17 { 18 18 $this->System->RegisterPage('shoutbox', 'PageShoutBox'); 19 19 $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)); 22 22 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 23 23 $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox', 24 24 T('Shoutbox'), array('UserName', 'Text'), '`ShoutBox`', $this->System->Link('/shoutbox/?search=')); 25 25 } 26 26 27 27 function ShowBox() 28 28 { … … 37 37 $Output .= '</table></div>'; 38 38 return($Output); 39 } 39 } 40 40 } 41 41 … … 53 53 return($Output); 54 54 } 55 55 56 56 function ShowList() 57 57 { … … 64 64 $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")'; 65 65 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 66 } else $SearchQuery = ''; 66 } else $SearchQuery = ''; 67 67 68 68 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ShoutBox` WHERE 1'.$SearchQuery); … … 71 71 72 72 $Output .= '<h3>'.T('Shoutbox').'</h3>'.$PageList['Output']; 73 if($this->System->User->Licence(LICENCE_USER)) 73 if($this->System->User->Licence(LICENCE_USER)) 74 74 $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>'; 75 75 $Output .= '<div class="shoutbox">'; … … 80 80 return($Output); 81 81 } 82 82 83 83 function ShowAddForm() 84 84 { … … 98 98 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 99 99 $Output .= $this->ShowList(); 100 return($Output); 100 return($Output); 101 101 } 102 102 103 103 function AddFinish() 104 104 { … … 134 134 $Output .= $this->ShowList(); 135 135 return($Output); 136 } 137 136 } 137 138 138 function ShowRSS() 139 139 { -
trunk/Modules/Translation/Translation.php
r806 r815 20 20 $this->Dependencies = array('News'); 21 21 } 22 22 23 23 function Start() 24 24 { 25 25 global $TranslationTree; 26 26 27 27 $this->System->RegisterPage('comparison.php', 'PageTranslationComparison'); 28 28 $this->System->RegisterPage('form.php', 'PageTranslationForm'); … … 31 31 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList'); 32 32 $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'), 34 34 'Channel' => 'translation', 'Callback' => array($this, 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS)); 35 35 $this->System->RegisterMenuItem(array( … … 39 39 'Permission' => LICENCE_ANONYMOUS, 40 40 'Icon' => '', 41 ), 1); 41 ), 1); 42 42 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 43 43 { … … 45 45 { 46 46 $Table = $Group['TablePrefix']; 47 47 48 48 $Columns = array('ID', 'Entry'); 49 49 foreach($Group['Items'] as $Item) 50 50 { 51 51 if($Item['Column'] != '') $Columns[] = $Item['Column']; 52 } 52 } 53 53 54 54 $this->System->ModuleManager->Modules['Search']->RegisterSearch('group'.$Group['Id'], 55 55 sprintf(T('Translation group "%s"'), $Group['Name']), $Columns, '`'.$Table.'`', $this->System->Link('/TranslationList.php?group='. 56 $Group['Id'].'&user=0&state=0&entry=&text=')); 56 $Group['Id'].'&user=0&state=0&entry=&text=')); 57 57 } 58 } 58 } 59 59 } 60 60 61 61 function ShowRSS() 62 62 { -
trunk/includes/Application.php
r577 r815 5 5 var $Name; 6 6 var $System; 7 7 8 8 function Run() 9 9 { 10 10 11 11 } 12 12 } -
trunk/includes/Base.php
r573 r815 6 6 var $Config; 7 7 var $System; 8 8 9 9 function __construct($System) 10 10 { … … 17 17 class Model extends Base 18 18 { 19 19 20 20 } 21 21 -
trunk/includes/FileStream.php
r553 r815 7 7 private $Handle; 8 8 private $FileName; 9 9 10 10 function __construct() 11 11 { 12 12 $this->Handle = false; 13 } 14 15 function __destruct() 13 } 14 15 function __destruct() 16 16 { 17 17 if($this->Handle) 18 18 fclose($this->Handle); 19 19 } 20 20 21 21 public function OpenFile($FileName) 22 22 { … … 24 24 $this->CloseFile(); 25 25 $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)); 27 27 } 28 28 … … 32 32 $this->CloseFile(); 33 33 $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)); 35 35 } 36 36 37 37 public function CloseFile() 38 38 { 39 39 if($this->Handle) 40 fclose($this->Handle); 40 fclose($this->Handle); 41 41 } 42 42 43 43 public function ReadBlock($Count) 44 44 { 45 45 return(fread($this->Handle, $Count)); 46 46 } 47 47 48 48 public function ReadByte() 49 49 { 50 50 return(fread($this->Handle, 1)); 51 } 52 51 } 52 53 53 public function ReadUint() 54 54 { … … 56 56 return($val[1]); 57 57 } 58 58 59 59 public function ReadInt() 60 60 { 61 61 $val = unpack('I*', fread($this->Handle, 4)); 62 62 return($val[1]); 63 } 64 63 } 64 65 65 public function ReadFloat() 66 66 { … … 68 68 return($val[1]); 69 69 } 70 70 71 71 public function ReadChar() 72 72 { … … 77 77 { 78 78 return(fgets($this->Handle)); 79 } 79 } 80 80 81 81 public function ReadTextLine() 82 82 { 83 83 return(fgets($this->Handle)); 84 } 85 84 } 85 86 86 public function WriteBlock($Value, $Count) 87 87 { 88 88 fwrite($this->Handle, $Value, $Count); 89 } 90 89 } 90 91 91 public function WriteByte($Value) 92 92 { 93 93 fwrite($this->Handle, pack('C*', $Value), 1); 94 } 95 94 } 95 96 96 public function WriteUint($Value) 97 97 { 98 98 fwrite($this->Handle, pack('V*', $Value), 4); 99 99 } 100 100 101 101 public function WriteInt($Value) 102 102 { 103 103 fwrite($this->Handle, pack('I*', $Value), 4); 104 } 105 104 } 105 106 106 public function WriteFloat($Value) 107 107 { 108 108 fwrite($this->Handle, pack('f*', $Value), 4); 109 109 } 110 110 111 111 public function WriteChar($Value) 112 112 { 113 113 fwrite($this->Handle, $Value, 1); 114 } 115 114 } 115 116 116 public function WriteString($Value) 117 117 { … … 128 128 fseek($this->Handle, $Position, SEEK_SET); 129 129 } 130 130 131 131 public function GetPosition() 132 132 { 133 133 return(ftell($this->Handle)); 134 134 } 135 135 136 136 public function GetSize() 137 137 { -
trunk/includes/Locale.php
r619 r815 1 1 <?php 2 2 3 class LocaleText 3 class LocaleText 4 4 { 5 5 var $Data; … … 12 12 $this->Code = 'en'; 13 13 $this->Title = 'English'; 14 } 15 14 } 15 16 16 function Load() 17 17 { 18 18 } 19 19 20 20 function Translate($Text) 21 { 21 { 22 22 if(array_key_exists($Text, $this->Data) and ($this->Data[$Text] != '')) 23 23 return($this->Data[$Text]); 24 24 else return($Text); 25 } 25 } 26 26 } 27 27 … … 30 30 var $Texts; 31 31 var $Dir; 32 32 33 33 function __construct($System) 34 34 { … … 36 36 $this->Texts = new LocaleText(); 37 37 } 38 38 39 39 function Load($Language) 40 40 { … … 42 42 if(file_exists($FileName)) { 43 43 include_once($FileName); 44 $ClassName = 'LocaleText'.$Language; 44 $ClassName = 'LocaleText'.$Language; 45 45 $this->Texts = new $ClassName(); 46 46 } else throw new Exception('Language file '.$FileName.' not found'); 47 47 $this->Texts->Load(); 48 48 } 49 49 50 50 function AnalyzeCode($Path) 51 51 { … … 60 60 else if(file_exists($FullName)) 61 61 { 62 if(substr($FullName, -4) == '.php') 62 if(substr($FullName, -4) == '.php') 63 63 { 64 64 $Content = file_get_contents($FullName); 65 65 // Search occurence of T() function 66 66 while(strpos($Content, 'T(') !== false) 67 { 67 { 68 68 $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1)); 69 69 $Content = substr($Content, strpos($Content, 'T(') + 2); … … 71 71 //echo($Ord.','); 72 72 if(!(($Ord >= ord('a')) and ($Ord <= ord('z')))) 73 { 74 // Do for non-alpha previous character 73 { 74 // Do for non-alpha previous character 75 75 $Original = substr($Content, 0, strpos($Content, ')')); 76 76 $Original2 = ''; 77 if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 77 if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 78 78 $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 != '') 82 82 { 83 83 if(!array_key_exists($Original2, $this->Texts->Data)) 84 84 $this->Texts->Data[$Original2] = ''; 85 } 85 } 86 86 } 87 } 88 } 89 } 87 } 88 } 89 } 90 90 } 91 91 } 92 92 93 93 function SaveToFile($FileName) 94 94 { … … 111 111 file_put_contents($FileName, $Content); 112 112 } 113 113 114 114 function LoadFromDatabase($Database, $LangCode) 115 115 { … … 150 150 $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '. 151 151 '(`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'], 153 153 'Original' => $Index, 'Translated' => $Item)); 154 154 } … … 162 162 var $Codes; 163 163 var $Dir; 164 164 165 165 function __construct($System) 166 166 { 167 167 parent::__construct($System); 168 168 $this->Codes = array('en'); 169 $this->CurrentLocale = new LocaleFile($System); 170 } 171 169 $this->CurrentLocale = new LocaleFile($System); 170 } 171 172 172 function LoadAvailable() 173 173 { … … 177 177 { 178 178 if(substr($FileName, -4) == '.php') 179 { 179 { 180 180 $Code = substr($FileName, 0, -4); 181 181 $Locale = new LocaleFile($this->System); … … 183 183 $Locale->Load($Code); 184 184 $this->Available['Code'] = array('Code' => $Code, 'Title' => $Locale->Texts->Title); 185 } 185 } 186 186 } 187 187 } 188 188 189 189 function UpdateAll($Directory) 190 190 { … … 195 195 { 196 196 if(substr($FileName, -4) == '.php') 197 { 197 { 198 198 $FileLocale = new LocaleFile($this->System); 199 $FileLocale->Dir = $this->Dir; 199 $FileLocale->Dir = $this->Dir; 200 200 $FileLocale->Load(substr($FileName, 0, -4)); 201 201 202 202 // Add new 203 203 foreach($Locale->Texts->Data as $Index => $Item) … … 215 215 $this->CurrentLocale->Load($this->CurrentLocale->Texts->Code); 216 216 } 217 217 218 218 function LoadLocale($Code) 219 219 { … … 227 227 { 228 228 global $LocaleManager; 229 229 230 230 if(isset($LocaleManager)) return($LocaleManager->CurrentLocale->Texts->Translate($Text)); 231 231 else return($Text); -
trunk/includes/MemoryStream.php
r553 r815 5 5 public $Data; 6 6 public $Position; 7 7 8 8 function __construct() 9 9 { 10 10 $this->Data = ''; 11 11 $this->Position = 0; 12 } 13 14 function __destruct() 12 } 13 14 function __destruct() 15 15 { 16 16 } 17 17 18 18 public function ReadBlock($Count) 19 19 { … … 22 22 return($Result); 23 23 } 24 24 25 25 public function ReadByte() 26 26 { … … 28 28 $this->Position = $this->Position + 1; 29 29 return($Result); 30 } 31 30 } 31 32 32 public function ReadUint() 33 33 { … … 36 36 return($val[1]); 37 37 } 38 38 39 39 public function ReadInt() 40 40 { … … 42 42 $this->Position = $this->Position + 4; 43 43 return($val[1]); 44 } 45 44 } 45 46 46 public function ReadFloat() 47 47 { … … 50 50 return($val[1]); 51 51 } 52 52 53 53 public function ReadChar() 54 54 { … … 75 75 $this->Data = substr_replace($this->Data, $Value, $this->Position, $Count); 76 76 $this->Position = $this->Position + $Count; 77 } 77 } 78 78 79 79 public function WriteByte($Value) … … 81 81 $this->Data[$this->Position] = pack('C*', $Value); 82 82 $this->Position++; 83 } 84 83 } 84 85 85 public function WriteUint($Value) 86 86 { 87 87 $this->WriteBlock(pack('V*', $Value), 4); 88 88 } 89 89 90 90 public function WriteInt($Value) 91 91 { 92 92 $this->WriteBlock(pack('I*', $Value), 4); 93 } 94 93 } 94 95 95 public function WriteFloat($Value) 96 96 { 97 97 $this->WriteBlock(pack('f*', $Value), 4); 98 98 } 99 99 100 100 public function WriteChar($Value) 101 101 { 102 102 $this->Data[$this->Position] = pack('C*', $Value); 103 103 $this->Position++; 104 } 105 104 } 105 106 106 public function WriteLine($Value) 107 107 { … … 113 113 $this->Position = $Position; 114 114 } 115 115 116 116 public function GetPosition() 117 117 { 118 118 return($this->Position); 119 119 } 120 120 121 121 public function GetSize() 122 122 { -
trunk/includes/Update.php
r805 r815 8 8 var $Database; 9 9 var $InstallMethod; 10 10 11 11 function __construct() 12 12 { … … 15 15 $this->VersionTable = 'DbVersion'; 16 16 } 17 17 18 18 function GetDbVersion() 19 19 { 20 20 $DbResult = $this->Database->select('DbVersion', '*', 'Id=1'); 21 $Version = $DbResult->fetch_assoc(); 21 $Version = $DbResult->fetch_assoc(); 22 22 return($Version['Revision']); 23 23 } 24 24 25 25 function IsInstalled() 26 { 26 { 27 27 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 28 28 return($DbResult->num_rows > 0); … … 33 33 return($this->Revision <= $this->GetDbVersion()); 34 34 } 35 35 36 36 function Update() 37 37 { 38 38 $DbRevision = $this->GetDbVersion(); 39 $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 39 $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 40 40 while($this->Revision > $DbRevision) 41 41 { 42 42 $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']; 45 45 $RevUpdate($this); 46 46 $DbRevision = $TraceItem['Revision']; 47 47 $this->Database->query('UPDATE `DbVersion` SET `Revision`= '.$TraceItem['Revision'].' WHERE `Id`=1'); 48 48 } 49 return($Output); 49 return($Output); 50 50 } 51 51 52 52 function Install() 53 { 54 $InstallMethod = $this->InstallMethod; 53 { 54 $InstallMethod = $this->InstallMethod; 55 55 $InstallMethod($this); 56 56 $this->Update(); 57 57 } 58 58 59 59 function Uninstall() 60 60 { 61 61 62 62 } 63 63 64 64 function Execute($Query) 65 65 { -
trunk/includes/Version.php
r813 r815 6 6 // and system will need database update. 7 7 8 $Revision = 81 3; // Subversion revision8 $Revision = 815; // Subversion revision 9 9 $DatabaseRevision = 811; // Database structure revision 10 $ReleaseTime = '201 4-06-03';10 $ReleaseTime = '2015-02-22'; -
trunk/includes/dbc.php
r553 r815 24 24 private $ColumnFormat; // Array (Index => Type) 25 25 private $EndOffset; // Calculated RecordSize according columns type 26 26 27 27 private $RecordSize; 28 28 private $RecordCount; 29 29 private $StringBlockSize; 30 30 private $FieldCount; 31 31 32 32 public function OpenFile($FileName, $ColumnFormat = array()) 33 33 { 34 34 parent::OpenFile($FileName); 35 35 36 36 $this->ColumnFormat = $ColumnFormat; 37 37 if($this->ReadUint() != DBC_SIGNATURE) die(NOT_DBC_FILE); 38 38 39 39 $this->RecordCount = $this->ReadUint(); 40 40 $this->FieldCount = $this->ReadUint(); 41 41 $this->RecordSize = $this->ReadUint(); 42 42 $this->StringBlockSize = $this->ReadUint(); 43 43 44 44 $this->GenerateOffsetTable(); 45 45 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); 47 47 } 48 48 … … 50 50 { 51 51 parent::CreateFile($FileName); 52 52 53 53 $this->WriteUint(DBC_SIGNATURE); 54 54 55 55 $this->StringList = array(); 56 56 $this->StringOffset = 1; … … 65 65 $this->WriteUint($this->FieldCount); 66 66 $this->WriteUint($this->RecordSize); 67 $this->WriteUint($this->StringBlockSize); 68 } 69 67 $this->WriteUint($this->StringBlockSize); 68 } 69 70 70 private function GenerateOffsetTable() 71 71 { 72 72 // 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); 74 74 else $this->Offsets = array(); 75 75 76 76 $Offset = 0; 77 77 $I = 0; … … 83 83 switch($Format) 84 84 { 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 } 95 95 $I++; 96 } 96 } 97 97 $this->EndOffset = $Offset; 98 98 } 99 99 100 100 private function CellPos($Row, $Column) 101 101 { 102 102 return($this->HeaderSize + $Row * $this->RecordSize + $this->Offsets[$Column]); 103 103 } 104 104 105 105 public function GetByte($Row, $Column) 106 106 { 107 $this->SetPosition($this->CellPos($Row, $Column)); 107 $this->SetPosition($this->CellPos($Row, $Column)); 108 108 return($this->ReadByte()); 109 } 110 109 } 110 111 111 public function GetUInt($Row, $Column) 112 112 { 113 $this->SetPosition($this->CellPos($Row, $Column)); 113 $this->SetPosition($this->CellPos($Row, $Column)); 114 114 return($this->ReadUint()); 115 115 } 116 116 117 117 public function GetInt($Row, $Column) 118 118 { 119 $this->SetPosition($this->CellPos($Row, $Column)); 119 $this->SetPosition($this->CellPos($Row, $Column)); 120 120 return($this->ReadInt()); 121 } 122 121 } 122 123 123 public function GetFloat($Row, $Column) 124 124 { 125 $this->SetPosition($this->CellPos($Row, $Column)); 125 $this->SetPosition($this->CellPos($Row, $Column)); 126 126 return($this->ReadFloat()); 127 127 } … … 129 129 public function SetByte($Row, $Column, $Value) 130 130 { 131 $this->SetPosition($this->CellPos($Row, $Column)); 131 $this->SetPosition($this->CellPos($Row, $Column)); 132 132 $this->WriteByte($Value); 133 } 134 133 } 134 135 135 public function SetUint($Row, $Column, $Value) 136 136 { 137 $this->SetPosition($this->CellPos($Row, $Column)); 137 $this->SetPosition($this->CellPos($Row, $Column)); 138 138 $this->WriteUint($Value); 139 139 } 140 140 141 141 public function SetInt($Row, $Column, $Value) 142 142 { 143 $this->SetPosition($this->CellPos($Row, $Column)); 143 $this->SetPosition($this->CellPos($Row, $Column)); 144 144 $this->WriteInt($Value); 145 } 146 145 } 146 147 147 public function SetFloat($Row, $Column, $Value) 148 148 { 149 $this->SetPosition($this->CellPos($Row, $Column)); 149 $this->SetPosition($this->CellPos($Row, $Column)); 150 150 $this->WriteFloat($Value); 151 151 } 152 152 153 153 public function GetString($Row, $Column) 154 154 { 155 155 $Offset = $this->GetUint($Row, $Column); 156 156 157 157 $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset; 158 158 if($Position >= $this->GetSize()) return(''); 159 159 $this->SetPosition($Position); 160 160 161 161 $String = ''; 162 162 while(($Char = $this->ReadChar()) != "\0") … … 165 165 } 166 166 return($String); 167 } 168 167 } 168 169 169 public function SetString($Row, $Column, $Value) 170 170 { 171 171 if(in_array($Value, $this->StringList)) 172 { 172 { 173 173 $this->SetUint($Row, $Column, $this->StringListOffset[array_search($Value, $this->StringList)]); 174 } else 174 } else 175 175 { 176 176 $this->SetUint($Row, $Column, $this->StringOffset); … … 189 189 $this->WriteUint($this->FieldCount); 190 190 $this->WriteUint($this->RecordSize); 191 $this->WriteUint($this->StringOffset); 191 $this->WriteUint($this->StringOffset); 192 192 $this->SetPosition($this->HeaderSize + $this->RecordCount * $this->RecordSize); 193 193 $this->WriteByte(0); 194 194 foreach($this->StringList as $Index => $Item) 195 { 195 { 196 196 $this->WriteString($Item."\0"); 197 197 } 198 } 199 198 } 199 200 200 public function GetLine($Row) 201 201 { … … 204 204 $this->SetPosition($this->CellPos($Row, 0)); 205 205 $Record->Data = $this->ReadBlock($this->RecordSize); 206 206 207 207 // 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); 209 209 else $Line = array(); 210 210 for($I = 0; $I < $this->FieldCount; $I++) … … 212 212 if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I]; 213 213 else $Format = FORMAT_UINT32; 214 $Record->SetPosition($this->Offsets[$I]); 214 $Record->SetPosition($this->Offsets[$I]); 215 215 switch($Format) 216 216 { 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: 230 230 $Offset = $Record->ReadUint(); 231 231 232 232 $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset; 233 233 if($Position >= $this->GetSize()) $String = ''; 234 else 234 else 235 235 { 236 $this->SetPosition($Position); 236 $this->SetPosition($Position); 237 237 $String = ''; 238 238 while(($Char = $this->ReadChar()) != "\0") … … 241 241 $Line[$I] = $String; 242 242 break; 243 default: 243 default: 244 244 break; 245 245 } … … 252 252 // Cache record data 253 253 $Record = new MemoryStream(); 254 254 255 255 for($I = 0; $I < $this->FieldCount; $I++) 256 256 { 257 257 if(array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I]; 258 258 else $Format = FORMAT_UINT32; 259 $Record->SetPosition($this->Offsets[$I]); 259 $Record->SetPosition($this->Offsets[$I]); 260 260 switch($Format) 261 261 { 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: 275 275 if(in_array($Line[$I], $this->StringList)) 276 { 276 { 277 277 $Record->WriteUint($this->StringListOffset[array_search($Line[$I], $this->StringList)]); 278 } else 278 } else 279 279 { 280 280 $Record->WriteUint($this->StringOffset); … … 284 284 } 285 285 break; 286 default: 286 default: 287 287 break; 288 288 } 289 289 } 290 290 291 291 $this->SetPosition($this->CellPos($Row, 0)); 292 292 $this->WriteBlock($Record->Data, $this->RecordSize); 293 293 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 { 303 303 $this->RecordCount = $Value; 304 304 } 305 305 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 { 313 313 $this->FieldCount = $Value; 314 314 $this->GenerateOffsetTable();
Note:
See TracChangeset
for help on using the changeset viewer.