Changeset 63
- Timestamp:
- Aug 3, 2021, 11:20:41 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 3 deleted
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 nbproject2 Config.php3 1 .settings 4 2 .project 5 3 .buildpath 4 .htaccess
-
- Property svn:ignore
-
trunk/Config
-
Property svn:ignore
set to
Config.php
ModulesConfig.php
-
Property svn:ignore
set to
-
trunk/Global.php
r55 r63 1 1 <?php 2 2 3 function HumanDate( $Time)3 function HumanDate(int $Time): string 4 4 { 5 5 return date('j.n.Y', $Time); 6 6 } 7 7 8 function HumanTime( $Time)8 function HumanTime(int $Time): string 9 9 { 10 10 return date('H:i:s', $Time); 11 11 } 12 12 13 function HumanDateTime( $Time)13 function HumanDateTime(int $Time): string 14 14 { 15 15 $Output = HumanDate($Time); … … 19 19 } 20 20 21 function Link2( $URL)21 function Link2(string $URL): string 22 22 { 23 23 global $Config; … … 26 26 } 27 27 28 function ProcessURL() 28 function ProcessURL(): array 29 29 { 30 30 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) … … 40 40 } 41 41 42 function GetQueryStringArray( $QueryString)42 function GetQueryStringArray(string $QueryString): array 43 43 { 44 44 $Result = array(); … … 56 56 } 57 57 58 function SetQueryStringArray( $QueryStringArray)58 function SetQueryStringArray(array $QueryStringArray): string 59 59 { 60 60 $Parts = array(); … … 66 66 } 67 67 68 function GetPageList($TotalCount) 68 function HumanSize(int $Value): string 69 { 70 global $UnitNames; 71 72 $UnitIndex = 0; 73 while ($Value > 1024) 74 { 75 $Value = round($Value / 1024, 3); 76 $UnitIndex++; 77 } 78 return $Value.' '.$UnitNames[$UnitIndex]; 79 } 80 81 function GetPageList(int $TotalCount): array 69 82 { 70 83 global $Config; … … 72 85 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 73 86 74 $ItemPerPage = $Config['ItemsPerPage'];75 $Around = round( $Config['VisiblePagingItems'] / 2);87 $ItemPerPage = (int)$Config['ItemsPerPage']; 88 $Around = round((int)$Config['VisiblePagingItems'] / 2); 76 89 $Result = ''; 77 90 $PageCount = floor($TotalCount / $ItemPerPage) + 1; … … 131 144 $OrderArrowImage = array('sort_asc.png', 'sort_desc.png'); 132 145 133 function GetOrderTableHeader( $Columns, $DefaultColumn, $DefaultOrder = 0)146 function GetOrderTableHeader(array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array 134 147 { 135 148 global $OrderDirSQL, $OrderArrowImage, $Config; … … 179 192 } 180 193 181 function GetMicrotime() 194 function GetMicrotime(): float 182 195 { 183 196 list($Usec, $Sec) = explode(' ', microtime()); … … 189 202 var $Items = array(); 190 203 191 function GetOutput( $Link)204 function GetOutput(string $Link): string 192 205 { 193 206 $Output = ''; … … 355 368 '<input value="'.$_SESSION[$Item['Name'].'do'].'" onkeyup="'. 356 369 'if (event.keyCode!=9) upf(\''.$Item['Name'].'do\',$(this).val(),(event.keyCode==13?0:1));" '. 357 'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>'. 358 '<div class="label-box">'.$Item['Units'].'</div>'. 359 '</div> '; 370 'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>'; 371 if (array_key_exists('Units', $Item)) 372 { 373 $Output .= '<div class="label-box">'.$Item['Units'].'</div>'; 374 } 375 $Output .= '</div> '; 360 376 } 361 377 } … … 365 381 } 366 382 367 function GetWhere( $Database)383 function GetWhere(Database $Database): string 368 384 { 369 385 $Where = ''; -
trunk/Modules/Club/Club.php
r55 r63 1 1 <?php 2 2 3 class ModuleClub extends AppModule3 class ModuleClub extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 17 function Start(): void 18 18 { 19 $this->System->RegisterPage( 'tancirny', 'PageDanceClub');20 } 19 $this->System->RegisterPage(['tancirny'], 'PageDanceClub'); 20 } 21 21 } 22 22 23 23 class PageClub extends Page 24 { 24 { 25 25 function __construct($System) 26 26 { 27 27 parent::__construct($System); 28 $this->FullTitle = 'Tančírny'; 29 $this->ShortTitle = 'Tančírny'; 28 $this->Title = 'Tančírny'; 30 29 } 31 32 function Show() 30 31 function Show(): string 33 32 { 34 35 33 return 'Dance clubs'; 36 34 } -
trunk/Modules/Dance/Dance.php
r55 r63 1 1 <?php 2 2 3 class ModuleDance extends AppModule3 class ModuleDance extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 18 { 19 $this->System->RegisterPage( 'tance', 'PageDanceList');20 $this->System->RegisterPage( 'tanec', 'PageDance');21 $this->System->RegisterPage( 'figura', 'PageDanceFigure');22 $this->System->RegisterPage( 'figury', 'PageDanceFigureList');23 $this->System->RegisterMenuItem('/tance', 'Tance');24 $this->System->RegisterMenuItem('/figury', 'Figury');25 } 17 function Start(): void 18 { 19 $this->System->RegisterPage(['tance'], 'PageDanceList'); 20 $this->System->RegisterPage(['tanec'], 'PageDance'); 21 $this->System->RegisterPage(['figura'], 'PageDanceFigure'); 22 $this->System->RegisterPage(['figury'], 'PageDanceFigureList'); 23 Core::Cast($this->System)->RegisterMenuItem('/tance', 'Tance'); 24 Core::Cast($this->System)->RegisterMenuItem('/figury', 'Figury'); 25 } 26 26 } 27 27 … … 31 31 { 32 32 parent::__construct($System); 33 $this->FullTitle = 'Tanec'; 34 $this->ShortTitle = 'Tanec'; 35 } 36 37 function Show() 38 { 39 $this->Title = 'Tanec - Tance - '.$this->Title; 33 $this->Title = 'Tanec'; 34 } 35 36 function Show(): string 37 { 40 38 $Output = ''; 41 39 if (count($this->System->PathItems) > 1) … … 101 99 $Output .= '</td>'; 102 100 }*/ 103 101 104 102 return $Output; 105 103 } … … 111 109 { 112 110 parent::__construct($System); 113 $this->FullTitle = 'Tance'; 114 $this->ShortTitle = 'Tance'; 115 } 116 117 function Show() 118 { 119 $this->Title = 'Tance - '.$this->Title; 111 $this->Title = 'Tance'; 112 } 113 114 function Show(): string 115 { 120 116 $Output = '<div class="title">Tance</div>'; 121 117 $Output .= '<table class="WideTable">'; … … 141 137 { 142 138 parent::__construct($System); 143 $this->FullTitle = 'Taneční figura'; 144 $this->ShortTitle = 'Figura'; 145 } 146 147 function Show() 148 { 149 $this->Title = 'Taneční figura - Tance - '.$this->Title; 139 $this->Title = 'Figura'; 140 $this->Description = 'Taneční figura'; 141 } 142 143 function Show(): string 144 { 150 145 $Output = ''; 151 146 if (count($this->System->PathItems) > 1) … … 196 191 $Output .= '</td>'; 197 192 }*/ 198 193 199 194 return $Output; 200 195 } … … 206 201 { 207 202 parent::__construct($System); 208 $this->FullTitle = 'Tance'; 209 $this->ShortTitle = 'Tance'; 210 } 211 212 function Show() 213 { 214 $this->Title = 'Tance - '.$this->Title; 203 $this->Title = 'Figury'; 204 $this->Description = 'Taneční figury'; 205 } 206 207 function Show(): string 208 { 215 209 $Output = '<div class="title">Taneční figury</div>'; 216 210 $Output .= '<table class="WideTable">'; -
trunk/Modules/Event/Event.php
r61 r63 3 3 include_once(dirname(__FILE__).'/Import/JoeClub.php'); 4 4 5 function GetDefaultEventFilter( $Table = '')5 function GetDefaultEventFilter(string $Table = ''): string 6 6 { 7 7 global $Config; … … 9 9 if ($Table != '') $Table = $Table.'.'; 10 10 11 return '('.$Table.'Hidden=0) AND ('.$Table.'TimeFrom > "'.TimeToMysqlDateTime(time() - $Config['EventInterval']).'")';11 return '('.$Table.'Hidden=0) AND ('.$Table.'TimeFrom > "'.TimeToMysqlDateTime(time() - (int)$Config['EventInterval']).'")'; 12 12 } 13 13 14 function ReduceSpaces( $Content)14 function ReduceSpaces(string $Content): string 15 15 { 16 16 while (strpos($Content, ' ') !== false) $Content = str_replace(' ', ' ', $Content); … … 18 18 } 19 19 20 function RemoveLines( $Content)20 function RemoveLines(string $Content): string 21 21 { 22 22 while (strpos($Content, "\n") !== false) $Content = str_replace("\n", ' ', $Content); … … 24 24 } 25 25 26 function RemoveTabs( $Content)26 function RemoveTabs(string $Content): string 27 27 { 28 28 while (strpos($Content, "\t") !== false) $Content = str_replace("\t", '', $Content); … … 34 34 public $Database; 35 35 36 function Parse( $Id = null)36 function Parse(int $Id = null): string 37 37 { 38 38 $Output = ''; … … 73 73 } 74 74 75 function Import() 75 function Import(): string 76 76 { 77 77 $this->AddedCount = 0; … … 99 99 var $Price = 0; 100 100 101 function AddIfNotExist( $TimeInterval = 0, $CompareTime = true, $CompareRemoteId = false)101 function AddIfNotExist(int $TimeInterval = 0, bool $CompareTime = true, bool $CompareRemoteId = false): int 102 102 { 103 103 $Where = '(`Description` = "'.$this->Database->real_escape_string($this->Description).'") AND '. -
trunk/Modules/Event/EventPage.php
r62 r63 1 1 <?php 2 2 3 class ModuleEvent extends AppModule3 class ModuleEvent extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 18 { 19 $this->System->RegisterPage( 'udalosti', 'PageEventList');20 $this->System->RegisterPage( array('udalosti', 'udalost'), 'PageEventItem');21 $this->System->RegisterPage( array('udalosti', 'aktualizace'), 'PageEventUpdate');22 $this->System->RegisterPage( array('udalosti', 'rss'), 'PageEventRss');23 $this->System->RegisterMenuItem('/udalosti', 'Události');17 function Start(): void 18 { 19 $this->System->RegisterPage(['udalosti'], 'PageEventList'); 20 $this->System->RegisterPage(['udalosti', 'udalost'], 'PageEventItem'); 21 $this->System->RegisterPage(['udalosti', 'aktualizace'], 'PageEventUpdate'); 22 $this->System->RegisterPage(['udalosti', 'rss'], 'PageEventRss'); 23 Core::Cast($this->System)->RegisterMenuItem('/udalosti', 'Události'); 24 24 } 25 25 } … … 30 30 { 31 31 parent::__construct($System); 32 $this-> FullTitle = 'Taneční události';33 $this-> ShortTitle = 'Události';34 } 35 36 function Show() 32 $this->Title = 'Události'; 33 $this->Description = 'Taneční události'; 34 } 35 36 function Show(): string 37 37 { 38 38 $Filter = new Filter(); … … 47 47 48 48 $Output = ''; 49 $this->Title = 'Události - '.$this->Title;50 49 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 51 50 $this->RawPage = true; … … 111 110 { 112 111 parent::__construct($System); 113 $this-> FullTitle = 'Aktualizace tanečníchudálostí';114 $this-> ShortTitle = 'Aktualizaceudálostí';115 } 116 117 function Show() 112 $this->Title = 'Aktualizace událostí'; 113 $this->Description = 'Aktualizace tanečních událostí'; 114 } 115 116 function Show(): string 118 117 { 119 118 $EventSources = new EventSources(); … … 130 129 { 131 130 parent::__construct($System); 132 $this->FullTitle = 'Taneční událost'; 133 $this->ShortTitle = 'Událost'; 134 } 135 136 function Show() 137 { 138 $this->Title = 'Událost - Události - '.$this->Title; 131 $this->Title = 'Událost'; 132 $this->Description = 'Taneční událost'; 133 } 134 135 function Show(): string 136 { 139 137 $Output = ''; 140 138 if (count($this->System->PathItems) > 2) … … 142 140 $id = $this->System->PathItems[2] * 1; 143 141 } else return 'Položka nenalezena'; 144 if ( $this->System->IsAdmin())142 if (Core::Cast($this->System)->IsAdmin()) 145 143 { 146 144 if (array_key_exists('hide', $_GET)) $this->Database->update('Event', 'Id='.$id, array('Hidden' => 1)); … … 154 152 { 155 153 $Event = $DbResult->fetch_assoc(); 156 if (($Event['Filter'] == '0') and ! $this->System->IsAdmin())154 if (($Event['Filter'] == '0') and !Core::Cast($this->System)->IsAdmin()) 157 155 return 'Položka nenalezena'; 158 156 if ($Event['Link'] != '') $Link = '<a href="'.$Event['Link'].'">Odkaz</a>'; … … 168 166 '<tr><th>Zdroj importu</th><td><a href="'.$Event['SourceURL'].'">'.$Event['SourceName'].'</a></td></tr>'; 169 167 $Output .= '</table>'; 170 if ( $this->System->IsAdmin()) {168 if (Core::Cast($this->System)->IsAdmin()) { 171 169 if ($Event['Hidden'] == '1') 172 170 $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>'; … … 183 181 { 184 182 parent::__construct($System); 185 $this-> FullTitle = 'RSS kanáltanečních událostí';186 $this-> ShortTitle = 'RSS tanečníudálostí';187 } 188 189 function Show() 183 $this->Title = 'RSS tanečních událostí'; 184 $this->Description = 'RSS kanál tanečních událostí'; 185 } 186 187 function Show(): string 190 188 { 191 189 global $Config; -
trunk/Modules/Event/Import/JoeClub.php
r55 r63 3 3 class EventSourceJoeClub extends EventSource 4 4 { 5 function ImportInternal() 5 function ImportInternal(): string 6 6 { 7 7 $Output = ''; -
trunk/Modules/Meet/Import/Amblar.php
r57 r63 26 26 class MeetSourceAmblar extends MeetSource 27 27 { 28 function Import() 28 function Import(): string 29 29 { 30 30 $Output = parent::Import(); … … 79 79 } 80 80 81 function ImportItem( &$MeetItem)81 function ImportItem(MeetItem &$MeetItem): string 82 82 { 83 83 global $HeightTags, $AgeTags, $LevelTags; … … 92 92 { 93 93 $Output .= 'Main block not isolated.</br>'; 94 return ;94 return $Output; 95 95 } 96 96 -
trunk/Modules/Meet/Import/AstraPraha.php
r57 r63 3 3 class MeetSourceAstraPraha extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Csts.php
r57 r63 3 3 class MeetSourceCsts extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Ella.php
r57 r63 3 3 class MeetSourceElla extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Eso.php
r57 r63 3 3 class MeetSourceEso extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Facebook.php
r57 r63 3 3 class MeetSourceFacebook extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 return ;7 return ''; 8 8 $Output = parent::Import(); 9 9 $Content = file_get_contents($this->URL); -
trunk/Modules/Meet/Import/MajkluvSvet.php
r57 r63 3 3 class MeetSourceMajkluvSvet extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/SalsaDance.php
r57 r63 3 3 class MeetSourceSalsaDance extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Seznamka.php
r58 r63 3 3 class MeetSourceSeznamka extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/TanecniSkola.php
r60 r63 3 3 class MeetSourceTanecniSkola extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Import/Vavruska.php
r57 r63 3 3 class MeetSourceVavruska extends MeetSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/Meet/Meet.php
r61 r63 20 20 } 21 21 22 function GetTextBetween( &$Text, $Start, $End)22 function GetTextBetween(string &$Text, string $Start, string $End): string 23 23 { 24 24 $Result = ''; … … 32 32 } 33 33 34 function HumanDateTimeToTime( $DateTime)34 function HumanDateTimeToTime(string $DateTime): ?int 35 35 { 36 36 if ($DateTime == '') return NULL; … … 47 47 } 48 48 49 function HumanDateToTime( $Date)49 function HumanDateToTime(string $Date): ?int 50 50 { 51 51 if ($Date == '') return NULL; … … 53 53 } 54 54 55 function DecodeHtmlEnt( $str)55 function DecodeHtmlEnt(string $str): string 56 56 { 57 57 $prefix = '&#'; … … 90 90 } 91 91 92 function RemoveHtmlComments( $Content)92 function RemoveHtmlComments(string $Content): string 93 93 { 94 94 $Result = ''; … … 103 103 } 104 104 105 function is_alpha( $Char)105 function is_alpha(string $Char): bool 106 106 { 107 107 return (($Char >= 'a') and ($Char <= 'z')) or (($Char >= 'A') and ($Char <= 'Z')); 108 108 } 109 109 110 function is_white_space( $Char)110 function is_white_space(string $Char): bool 111 111 { 112 112 return ($Char == ' ') or ($Char == "\t"); 113 113 } 114 114 115 function GetDefaultMeetFilter( $Table = '')115 function GetDefaultMeetFilter(string $Table = ''): string 116 116 { 117 117 global $Config; … … 119 119 if ($Table != '') $Table = $Table.'.'; 120 120 121 return '('.$Table.'Hidden=0) AND ('.$Table.'Time > "'.TimeToMysqlDateTime(time() - $Config['MeetInterval']).'")';122 } 123 124 function GetNumberBeforeText( $Text, $Needle)121 return '('.$Table.'Hidden=0) AND ('.$Table.'Time > "'.TimeToMysqlDateTime(time() - (int)$Config['MeetInterval']).'")'; 122 } 123 124 function GetNumberBeforeText(string $Text, string $Needle): string 125 125 { 126 126 $Result = ''; … … 148 148 } 149 149 150 function GetNumberAfterText( $Text, $Needle)150 function GetNumberAfterText(string $Text, string $Needle): string 151 151 { 152 152 $Result = ''; … … 175 175 } 176 176 177 function GetAgeFromText( $Text)177 function GetAgeFromText(string $Text): string 178 178 { 179 179 $Text = strtolower($Text); … … 212 212 } 213 213 214 function GetHeightFromText( $Text)214 function GetHeightFromText(string $Text): string 215 215 { 216 216 $Text = strtolower($Text); … … 228 228 } 229 229 230 function GetWeightFromText( $Text)230 function GetWeightFromText(string $Text): string 231 231 { 232 232 $Text = strtolower($Text); … … 238 238 } 239 239 240 function GetAgeHeightWeightFromText( $Text)240 function GetAgeHeightWeightFromText(string $Text): array 241 241 { 242 242 $Result = array('', '', ''); … … 261 261 } 262 262 263 function GetEmailFromText( $Text)263 function GetEmailFromText(string $Text): string 264 264 { 265 265 $Result = ''; … … 302 302 ); 303 303 304 function GetLocationFromText( $Text)304 function GetLocationFromText(string $Text): string 305 305 { 306 306 global $Locations; … … 315 315 } 316 316 317 function GetGenderFromName( $Text)317 function GetGenderFromName(string $Text): string 318 318 { 319 319 $Gender = Gender::Male; … … 334 334 public $Database; 335 335 336 function Parse( $Id = null)336 function Parse(?int $Id = null): string 337 337 { 338 338 $Output = ''; … … 392 392 } 393 393 394 function Import() 394 function Import(): string 395 395 { 396 396 return ''; 397 397 } 398 398 399 function DoImport() 399 function DoImport(): string 400 400 { 401 401 $this->MeetItems = array(); … … 406 406 foreach ($this->MeetItems as $MeetItem) 407 407 { 408 if ($MeetItem->IsSpam()) continue; 408 409 $this->AddedCount += $MeetItem->AddIfNotExist($this->AddTimeInterval, $this->AddCompareTime, $this->AddCompareRemoteId); 409 410 } … … 434 435 var $RemoteId = ''; 435 436 436 function AddIfNotExist( $TimeInterval = 0, $CompareTime = true, $CompareRemoteId = false)437 function AddIfNotExist(int $TimeInterval = 0, bool $CompareTime = true, bool $CompareRemoteId = false): int 437 438 { 438 439 $Where = '(`Message` = "'.$this->Database->real_escape_string($this->Message).'") AND '. … … 473 474 return $Result; 474 475 } 475 } 476 477 function IsSpam(): bool 478 { 479 $Keywords = array('půjčk', 'úvěr'); 480 foreach ($Keywords as $Keyword) 481 { 482 if (strpos($this->Message, $Keyword) !== false) 483 { 484 return false; 485 } 486 } 487 return true; 488 } 489 } -
trunk/Modules/Meet/MeetPage.php
r62 r63 1 1 <?php 2 2 3 class ModuleMeet extends AppModule3 class ModuleMeet extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 18 { 19 $this->System->RegisterPage( 'seznamka', 'PageMeetList');20 $this->System->RegisterPage( array('seznamka', 'inzerat'), 'PageMeetItem');21 $this->System->RegisterPage( array('seznamka', 'aktualizace'), 'PageMeetUpdate');22 $this->System->RegisterPage( array('seznamka', 'rss'), 'PageMeetRss');23 $this->System->RegisterMenuItem('/seznamka', 'Seznamka');17 function Start(): void 18 { 19 $this->System->RegisterPage(['seznamka'], 'PageMeetList'); 20 $this->System->RegisterPage(['seznamka', 'inzerat'], 'PageMeetItem'); 21 $this->System->RegisterPage(['seznamka', 'aktualizace'], 'PageMeetUpdate'); 22 $this->System->RegisterPage(['seznamka', 'rss'], 'PageMeetRss'); 23 Core::Cast($this->System)->RegisterMenuItem('/seznamka', 'Seznamka'); 24 24 } 25 25 } … … 30 30 { 31 31 parent::__construct($System); 32 $this-> FullTitle = 'Taneční seznamka';33 $this-> ShortTitle = 'Seznamka';34 } 35 36 function Show() 32 $this->Title = 'Seznamka'; 33 $this->Description = 'Taneční seznamka'; 34 } 35 36 function Show(): string 37 37 { 38 38 global $Config; … … 52 52 53 53 $Output = ''; 54 $this->Title = 'Seznamka - '.$this->Title;55 54 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 56 55 $this->RawPage = true; … … 121 120 { 122 121 parent::__construct($System); 123 $this-> FullTitle = 'Aktualizace tanečníseznamky';124 $this-> ShortTitle = 'Aktualizaceseznamky';125 } 126 127 function Show() 122 $this->Title = 'Aktualizace seznamky'; 123 $this->Description = 'Aktualizace taneční seznamky'; 124 } 125 126 function Show(): string 128 127 { 129 128 $MeetSources = new MeetSources(); … … 140 139 { 141 140 parent::__construct($System); 142 $this->FullTitle = 'Inzerát taneční seznamky'; 143 $this->ShortTitle = 'Inzerát seznamky'; 144 } 145 146 function Show() 147 { 148 $this->Title = 'Inzerát - Seznamka - '.$this->Title; 141 $this->Title = 'Inzerát'; 142 $this->Description = 'Inzerát taneční seznamky'; 143 } 144 145 function Show(): string 146 { 149 147 $Output = ''; 150 148 if (count($this->System->PathItems) > 2) … … 152 150 $id = $this->System->PathItems[2] * 1; 153 151 } else return 'Položka nenalezena'; 154 if ( $this->System->IsAdmin())152 if (Core::Cast($this->System)->IsAdmin()) 155 153 { 156 154 if (array_key_exists('hide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 1)); … … 165 163 { 166 164 $MeetItem = $DbResult->fetch_assoc(); 167 if (($MeetItem['Filter'] == '0') and ! $this->System->IsAdmin())165 if (($MeetItem['Filter'] == '0') and !Core::Cast($this->System)->IsAdmin()) 168 166 return 'Položka nenalezena'; 169 167 if ($MeetItem['Link'] != '') $Link = '<a href="'.$MeetItem['Link'].'">Odkaz</a>'; … … 183 181 '<tr><th>Zdroj importu</th><td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td></tr>'; 184 182 $Output .= '</table>'; 185 if ( $this->System->IsAdmin()) {183 if (Core::Cast($this->System)->IsAdmin()) { 186 184 if ($MeetItem['Hidden'] == '1') 187 185 $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>'; … … 198 196 { 199 197 parent::__construct($System); 200 $this-> FullTitle = 'RSS kanál tanečníseznamky';201 $this-> ShortTitle = 'RSS inzerátyseznamky';202 } 203 204 function Show() 198 $this->Title = 'RSS inzeráty seznamky'; 199 $this->Description = 'RSS kanál taneční seznamky'; 200 } 201 202 function Show(): string 205 203 { 206 204 global $Config; -
trunk/Modules/Movie/Movie.php
r56 r63 1 1 <?php 2 2 3 class ModuleMovie extends AppModule3 class ModuleMovie extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 17 function Start(): void 18 18 { 19 $this->System->RegisterPage( 'filmy', 'PageMovieList');20 $this->System->RegisterMenuItem('/filmy', 'Filmy');19 $this->System->RegisterPage(['filmy'], 'PageMovieList'); 20 Core::Cast($this->System)->RegisterMenuItem('/filmy', 'Filmy'); 21 21 } 22 22 } … … 27 27 { 28 28 parent::__construct($System); 29 $this-> FullTitle = 'Taneční filmy';30 $this-> ShortTitle = 'Filmy';29 $this->Title = 'Filmy'; 30 $this->Description = 'Taneční filmy'; 31 31 } 32 32 33 function Show() 33 function Show(): string 34 34 { 35 35 $Output = ''; 36 $this->Title = 'Filmy - '.$this->Title;37 36 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 38 37 $this->RawPage = true; -
trunk/Modules/RSS/RSS.php
r56 r63 1 1 <?php 2 2 3 class ModuleRSS extends AppModule3 class ModuleRSS extends Module 4 4 { 5 5 var $RSSChannels; … … 17 17 } 18 18 19 function Start() 19 function Start(): void 20 20 { 21 $this->System->RegisterPage( 'rss', 'PageRSS');22 $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader'));21 $this->System->RegisterPage(array('rss'), 'PageRSS'); 22 Core::Cast($this->System)->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader')); 23 23 } 24 24 25 function RegisterRSS( $Channel, $Pos = NULL, $Callback = NULL)25 function RegisterRSS(array $Channel, ?int $Pos = NULL, $Callback = NULL): void 26 26 { 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; … … 33 33 } 34 34 35 function UnregisterRSS( $ChannelName)35 function UnregisterRSS(string $ChannelName): void 36 36 { 37 37 unset($this->RSSChannels[$ChannelName]); … … 39 39 } 40 40 41 function ShowRSSHeader() 41 function ShowRSSHeader(): string 42 42 { 43 43 $Output = ''; … … 54 54 class PageRSS extends Page 55 55 { 56 function Show() 56 function Show(): string 57 57 { 58 58 $this->RawPage = true; -
trunk/Modules/School/School.php
r55 r63 1 1 <?php 2 2 3 class ModuleSchool extends AppModule3 class ModuleSchool extends Module 4 4 { 5 5 function __construct($System) … … 15 15 } 16 16 17 function Start() 17 function Start(): void 18 18 { 19 $this->System->RegisterPage( 'skoly', 'PageSchoolList');20 $this->System->RegisterMenuItem('/skoly', 'Školy');21 } 19 $this->System->RegisterPage(['skoly'], 'PageSchoolList'); 20 Core::Cast($this->System)->RegisterMenuItem('/skoly', 'Školy'); 21 } 22 22 } 23 23 … … 27 27 { 28 28 parent::__construct($System); 29 $this-> FullTitle = 'Taneční školy';30 $this-> ShortTitle = 'Školy';29 $this->Title = 'Školy'; 30 $this->Description = 'Taneční školy'; 31 31 } 32 32 33 function Show() 33 function Show(): string 34 34 { 35 $this->Title = 'Taneční školy - '.$this->Title;36 35 $Output = '<div class="title">Taneční školy</div>'; 37 36 $Output .= '<table class="WideTable">'; -
trunk/Packages/Common/Base.php
r56 r63 1 1 <?php 2 3 class System4 {5 /* @var Database */6 var $Database;7 8 function __construct()9 {10 $this->Database = new Database();11 }12 }13 2 14 3 class Base 15 4 { 16 /** @var Application */ 17 var $System; 18 /* @var Database */ 19 var $Database; 5 public System $System; 6 public Database $Database; 20 7 21 function __construct( Application$System)8 function __construct(System $System) 22 9 { 23 10 $this->System = &$System; 24 11 $this->Database = &$System->Database; 25 12 } 13 14 static function GetClassName() 15 { 16 return get_called_class(); 17 } 26 18 } 27 28 class Model extends Base29 {30 31 }32 33 class View extends Base34 {35 36 }37 38 class Controller extends Base39 {40 41 } -
trunk/Packages/Common/Common.php
r56 r63 11 11 include_once(dirname(__FILE__).'/Error.php'); 12 12 include_once(dirname(__FILE__).'/Base.php'); 13 include_once(dirname(__FILE__).'/Application.php'); 14 include_once(dirname(__FILE__).'/AppModule.php'); 13 include_once(dirname(__FILE__).'/View.php'); 14 include_once(dirname(__FILE__).'/Model.php'); 15 include_once(dirname(__FILE__).'/ModelDesc.php'); 16 include_once(dirname(__FILE__).'/Controller.php'); 17 include_once(dirname(__FILE__).'/System.php'); 18 include_once(dirname(__FILE__).'/Module.php'); 19 include_once(dirname(__FILE__).'/ModuleManager.php'); 15 20 include_once(dirname(__FILE__).'/Config.php'); 16 21 include_once(dirname(__FILE__).'/Page.php'); 17 22 include_once(dirname(__FILE__).'/Locale.php'); 18 23 include_once(dirname(__FILE__).'/Update.php'); 19 include_once(dirname(__FILE__).'/Setup.php');20 24 include_once(dirname(__FILE__).'/Table.php'); 21 25 include_once(dirname(__FILE__).'/Process.php'); 26 include_once(dirname(__FILE__).'/Generics.php'); 27 include_once(dirname(__FILE__).'/BigInt.php'); 28 include_once(dirname(__FILE__).'/Int128.php'); 29 include_once(dirname(__FILE__).'/Pdf.php'); 30 include_once(dirname(__FILE__).'/Modules/Setup.php'); 31 include_once(dirname(__FILE__).'/Modules/ModuleManager.php'); 22 32 23 33 class PackageCommon 24 34 { 25 var$Name;26 var$Version;27 var$ReleaseDate;28 var$License;29 var$Creator;30 var$Homepage;35 public string $Name; 36 public string $Version; 37 public int $ReleaseDate; 38 public string $License; 39 public string $Creator; 40 public string $Homepage; 31 41 32 42 function __construct() 33 43 { 34 44 $this->Name = 'Common'; 35 $this->Version = '1. 4';36 $this->ReleaseDate = strtotime('2020-0 4-07');45 $this->Version = '1.2'; 46 $this->ReleaseDate = strtotime('2020-03-29'); 37 47 $this->Creator = 'Chronos'; 38 $this->License = 'GNU/GPL ';48 $this->License = 'GNU/GPLv3'; 39 49 $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/'; 40 50 } … … 43 53 class Paging 44 54 { 45 var$TotalCount;46 var$ItemPerPage;47 var$Around;48 var$SQLLimit;49 var$Page;55 public int $TotalCount; 56 public int $ItemPerPage; 57 public int $Around; 58 public string $SQLLimit; 59 public int $Page; 50 60 51 function __construct( $System)61 function __construct() 52 62 { 63 global $System; 64 53 65 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 54 66 $this->Around = $System->Config['Web']['VisiblePagingItems']; 55 67 } 56 68 57 function Show() 69 function Show(): string 58 70 { 59 71 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); -
trunk/Packages/Common/Config.php
r55 r63 3 3 class Config 4 4 { 5 var$Data;5 public array $Data; 6 6 7 7 function __construct() … … 10 10 } 11 11 12 function ReadValue( $Name)12 function ReadValue(string $Name) 13 13 { 14 14 if (!is_array($Name)) $Name = explode('/', $Name); … … 22 22 } 23 23 24 function WriteValue( $Name, $Value)24 function WriteValue(string $Name, $Value) 25 25 { 26 26 if (!is_array($Name)) $Name = explode('/', $Name); … … 34 34 } 35 35 36 function LoadFromFile( $FileName)36 function LoadFromFile(string $FileName): void 37 37 { 38 38 $ConfigData = array(); … … 40 40 foreach ($this->Data as $Index => $Item) 41 41 { 42 if (array_key_exi ts($Index, $ConfigData))42 if (array_key_exists($Index, $ConfigData)) 43 43 $this->Data[$Index] = $ConfigData[$Index]; 44 44 } 45 45 } 46 46 47 function SaveToFile( $FileName)47 function SaveToFile(string $FileName): void 48 48 { 49 49 file_put_contents($FileName, "<?php \n\n\$ConfigData = ".var_export($this->Data, true).";\n"); 50 50 } 51 51 52 function GetAsArray() 52 function GetAsArray(): array 53 53 { 54 54 return $this->Data; -
trunk/Packages/Common/Database.php
r56 r63 2 2 3 3 // Extended database class 4 // Date: 2020- 04-074 // Date: 2020-11-10 5 5 6 6 function microtime_float() … … 12 12 class DatabaseResult 13 13 { 14 var$PDOStatement;15 var$num_rows = 0;14 public PDOStatement $PDOStatement; 15 public int $num_rows = 0; 16 16 17 17 function fetch_assoc() … … 33 33 class Database 34 34 { 35 var $Prefix; 36 var $Functions; 37 var $Type; 38 var $PDO; 39 var $Error; 40 var $insert_id; 41 var $LastQuery; 42 var $ShowSQLError; 43 var $ShowSQLQuery; 44 var $LogSQLQuery; 45 var $LogFile; 35 public string $Prefix; 36 public array $Functions; 37 public string $Type; 38 public PDO $PDO; 39 public string $Error; 40 public string $insert_id; 41 public string $LastQuery; 42 public bool $ShowSQLError; 43 public bool $ShowSQLQuery; 44 public bool $LogSQLQuery; 45 public string $LogFile; 46 public string $Database; 46 47 47 48 function __construct() 48 49 { 49 50 $this->Prefix = ''; 50 $this->Functions = array('NOW( )', 'CURDATE()', 'CURTIME()', 'UUID()');51 $this->Functions = array('NOW(', 'CURDATE(', 'CURTIME(', 'UUID(', 'SHA1('); 51 52 $this->Type = 'mysql'; // mysql, pgsql 52 53 $this->Error = ''; … … 56 57 $this->LogSQLQuery = false; 57 58 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 58 }59 60 61 function Connect( $Host, $User, $Password, $Database)59 $this->Database = ''; 60 } 61 62 function Connect(string $Host, string $User, string $Password, string $Database): void 62 63 { 63 64 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; 64 65 else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host; 65 66 else $ConnectionString = ''; 67 $this->Database = $Database; 66 68 try { 67 69 $this->PDO = new PDO($ConnectionString, $User, $Password); 68 69 70 } catch (Exception $E) 70 71 { … … 74 75 } 75 76 76 function Disconnect() 77 function Disconnect(): void 77 78 { 78 79 unset($this->PDO); 79 80 } 80 81 81 function Connected() 82 function Connected(): bool 82 83 { 83 84 return isset($this->PDO); 84 85 } 85 86 86 function select_db( $Database)87 function select_db(string $Database) 87 88 { 88 89 $this->query('USE `'.$Database.'`'); 89 90 } 90 91 91 function query($Query) 92 function query($Query): DatabaseResult 92 93 { 93 94 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 94 95 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float(); 95 $this->LastQuery = $Query; 96 $this->LastQuery = $Query; 97 //echo('a'.$this->ShowSQLQuery.'<'.$QueryStartTime.', '.microtime_float()); 96 98 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 97 $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s'; 98 if ($this->LogSQLQuery == true) 99 { 100 $Time = round(microtime_float() - $QueryStartTime, 4); 101 $Duration = ' ; '.$Time. ' s'; 102 } 103 if (($this->LogSQLQuery == true) and ($Time != 0)) 99 104 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 100 105 if ($this->ShowSQLQuery == true) … … 102 107 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 103 108 $Result = new DatabaseResult(); 104 $Result->PDOStatement = $this->PDO->query($Query); 105 if ($Result->PDOStatement) 106 { 107 $Result->num_rows = $Result->PDOStatement->rowCount(); 109 $Statement = $this->PDO->query($Query); 110 if ($Statement) 111 { 112 $Result->PDOStatement = $Statement; 113 $Result->num_rows = $Statement->rowCount(); 108 114 $this->insert_id = $this->PDO->lastInsertId(); 109 115 } else 110 { 111 $ this->Error = $this->PDO->errorInfo();112 $this->Error = $ this->Error[2];116 { 117 $Error = $this->PDO->errorInfo(); 118 $this->Error = $Error[2]; 113 119 if (($this->Error != '') and ($this->ShowSQLError == true)) 114 120 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); … … 118 124 } 119 125 120 function select( $Table, $What = '*', $Condition = 1)126 function select(string $Table, string $What = '*', string $Condition = '1'): DatabaseResult 121 127 { 122 128 return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 123 129 } 124 130 125 function delete( $Table, $Condition)131 function delete(string $Table, string $Condition): void 126 132 { 127 133 $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 128 134 } 129 135 130 function insert( $Table, $Data)136 function insert(string $Table, array $Data): int 131 137 { 132 138 $this->query($this->GetInsert($Table, $Data)); 133 139 $this->insert_id = $this->PDO->lastInsertId(); 134 } 135 136 function GetInsert($Table, $Data) 140 return $this->insert_id; 141 } 142 143 function IsFunction(string $Text): bool 144 { 145 $Pos = strpos($Text, '('); 146 return ($Pos !== false) && in_array(substr($Text, 0, $Pos + 1), $this->Functions); 147 } 148 149 function GetInsert(string $Table, array $Data): string 137 150 { 138 151 $Name = ''; … … 141 154 { 142 155 $Name .= ',`'.$Key.'`'; 143 if (!in_array($Value, $this->Functions)) 156 if (is_null($Value)) $Value = 'NULL'; 157 else if (!$this->IsFunction($Value)) 144 158 { 145 if (is_null($Value)) $Value = 'NULL'; 146 else $Value = $this->PDO->quote($Value); 159 $Value = $this->PDO->quote($Value); 147 160 } 148 161 $Values .= ','.$Value; … … 153 166 } 154 167 155 function update( $Table, $Condition, $Data)168 function update(string $Table, string $Condition, array $Data): void 156 169 { 157 170 $this->query($this->GetUpdate($Table, $Condition, $Data)); 158 171 } 159 160 function GetUpdate( $Table, $Condition, $Data)172 173 function GetUpdate(string $Table, string $Condition, array $Data): string 161 174 { 162 175 $Values = ''; 163 176 foreach ($Data as $Key => $Value) 164 177 { 165 if (!in_array($Value, $this->Functions)) 178 if (is_null($Value)) $Value = 'NULL'; 179 else if (!$this->IsFunction($Value)) 166 180 { 167 if (is_null($Value)) $Value = 'NULL'; 168 else $Value = $this->PDO->quote($Value); 181 $Value = $this->PDO->quote($Value); 169 182 } 170 183 $Values .= ', `'.$Key.'`='.$Value; … … 174 187 } 175 188 176 function replace( $Table, $Data)189 function replace(string $Table, array $Data): void 177 190 { 178 191 $Name = ''; … … 180 193 foreach ($Data as $Key => $Value) 181 194 { 182 if (!in_array($Value, $this->Functions)) 195 if (is_null($Value)) $Value = 'NULL'; 196 else if (!$this->IsFunction($Value)) 183 197 { 184 if (is_null($Value)) $Value = 'NULL'; 185 else $Value = $this->PDO->quote($Value); 198 $Value = $this->PDO->quote($Value); 186 199 } 187 200 $Name .= ',`'.$Key.'`'; … … 195 208 } 196 209 197 function charset( $Charset)210 function charset(string $Charset): void 198 211 { 199 212 $this->query('SET NAMES "'.$Charset.'"'); 200 213 } 201 214 202 function real_escape_string( $Text)215 function real_escape_string(string $Text): string 203 216 { 204 217 return addslashes($Text); 205 218 } 206 219 207 function quote( $Text)220 function quote(string $Text): string 208 221 { 209 222 return $this->PDO->quote($Text); 210 223 } 211 224 212 public function __sleep() 225 public function __sleep(): array 213 226 { 214 227 return array('LastQuery'); 215 228 } 216 229 217 public function __wakeup() 218 { 219 } 220 221 public function Transaction($Queries) 222 { 223 $this->PDO->beginTransaction(); 224 foreach ($Queries as $Query) 225 { 226 $Statement = $this->PDO->prepare($Query); 227 $Statement->execute(); 228 } 229 $this->PDO->commit(); 230 public function __wakeup(): void 231 { 232 } 233 234 public function Transaction(array $Queries): void 235 { 236 //echo('|'."\n"); 237 $this->PDO->beginTransaction(); 238 foreach ($Queries as $Query) 239 { 240 //echo('|'.$Query."\n"); 241 $Statement = $this->PDO->prepare($Query); 242 $Statement->execute(); 243 } 244 $this->PDO->commit(); 245 } 246 247 public function TableExists(string $Name): bool 248 { 249 $DbResult = $this->query('SELECT * FROM information_schema.tables WHERE table_schema = "'.$this->Database. 250 '" AND table_name = "'.$Name.'" LIMIT 1'); 251 return $DbResult->num_rows != 0; 230 252 } 231 253 } -
trunk/Packages/Common/Error.php
r55 r63 3 3 class ErrorHandler 4 4 { 5 var$Encoding;6 var$ShowError;7 var$UserErrors;8 var$OnError;5 public string $Encoding; 6 public bool $ShowError; 7 public int $UserErrors; 8 public $OnError; 9 9 10 10 function __construct() … … 63 63 } 64 64 65 function ExceptionHandler( Exception$Exception)65 function ExceptionHandler(Throwable $Exception) 66 66 { 67 67 $Backtrace = $Exception->getTrace(); … … 75 75 } 76 76 77 function ShowDefaultError( $Message)77 function ShowDefaultError(string $Message): void 78 78 { 79 79 $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". -
trunk/Packages/Common/Image.php
r56 r63 9 9 class Font 10 10 { 11 var$Size;12 var$FileName;13 var$Color;11 public int $Size; 12 public string $FileName; 13 public int $Color; 14 14 15 15 function __construct() … … 23 23 class Pen 24 24 { 25 var$Color;26 var$X;27 var$Y;25 public int $Color; 26 public int $X; 27 public int $Y; 28 28 29 29 function __construct() … … 38 38 class Brush 39 39 { 40 var$Color;40 public int $Color; 41 41 42 42 function __construct() … … 49 49 class Image 50 50 { 51 var $Image; 52 var $Type; 53 var $Font; 54 var $Pen; 51 public $Image; 52 public int $Type; 53 public Font $Font; 54 public Pen $Pen; 55 public Brush $Brush; 55 56 56 57 function __construct() … … 63 64 } 64 65 65 function SaveToFile( $FileName)66 function SaveToFile(string $FileName): void 66 67 { 67 68 if ($this->Type == IMAGETYPE_JPEG) … … 79 80 } 80 81 81 function LoadFromFile( $FileName)82 function LoadFromFile(string $FileName): void 82 83 { 83 84 $ImageInfo = getimagesize($FileName); … … 89 90 if ($this->Type == IMAGETYPE_GIF) 90 91 { 91 $this->Image = imagecreatefromgif ($FileName);92 $this->Image = imagecreatefromgif ($FileName); 92 93 } else 93 94 if ( $this->Type == IMAGETYPE_PNG) … … 97 98 } 98 99 99 function Output() 100 function Output(): void 100 101 { 101 102 $this->SaveToFile(NULL); 102 103 } 103 104 104 function SetSize( $Width, $Height)105 function SetSize(int $Width, int $Height): void 105 106 { 106 107 $NewImage = imagecreatetruecolor($Width, $Height); … … 110 111 } 111 112 112 function GetWidth() 113 function GetWidth(): int 113 114 { 114 115 return imagesx($this->Image); 115 116 } 116 117 117 function GetHeight() 118 function GetHeight(): int 118 119 { 119 120 return imagesy($this->Image); 120 121 } 121 122 122 function TextOut( $X, $Y, $Text)123 function TextOut(int $X, int $Y, string $Text): void 123 124 { 124 125 imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text); 125 126 } 126 127 127 function ConvertColor( $Color)128 function ConvertColor(int $Color): int 128 129 { 129 130 return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff); 130 131 } 131 132 132 function FillRect( $X1, $Y1, $X2, $Y2)133 function FillRect(int $X1, int $Y1, int $X2, int $Y2): void 133 134 { 134 135 imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color)); 135 136 } 136 137 137 function Line( $X1, $Y1, $X2, $Y2)138 function Line(int $X1, int $Y1, int $X2, int $Y2): void 138 139 { 139 140 imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color)); -
trunk/Packages/Common/Locale.php
r55 r63 3 3 class LocaleText 4 4 { 5 var$Data;6 var$Code;7 var$Title;5 public array $Data; 6 public string $Code; 7 public string $Title; 8 8 9 9 function __construct() … … 14 14 } 15 15 16 function Load() 17 { 18 } 19 20 function Translate( $Text, $Group = '')16 function Load(): void 17 { 18 } 19 20 function Translate(string $Text, string $Group = ''): string 21 21 { 22 22 if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != '')) … … 25 25 } 26 26 27 function TranslateReverse( $Text, $Group = '')27 function TranslateReverse(string $Text, string $Group = ''): string 28 28 { 29 29 $Key = array_search($Text, $this->Data[$Group]); … … 35 35 class LocaleFile extends Model 36 36 { 37 var$Texts;38 var$Dir;37 public LocaleText $Texts; 38 public string $Dir; 39 39 40 40 function __construct(System $System) … … 44 44 } 45 45 46 function Load( $Language)46 function Load(string $Language): void 47 47 { 48 48 $FileName = $this->Dir.'/'.$Language.'.php'; … … 55 55 } 56 56 57 function AnalyzeCode( $Path)57 function AnalyzeCode(string $Path): void 58 58 { 59 59 // Search for php files … … 98 98 } 99 99 100 function SaveToFile( $FileName)100 function SaveToFile(string $FileName): void 101 101 { 102 102 $Content = '<?php'."\n". … … 119 119 } 120 120 121 function LoadFromDatabase( $Database, $LangCode)121 function LoadFromDatabase(Database $Database, string $LangCode): void 122 122 { 123 123 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); … … 132 132 } 133 133 134 function SaveToDatabase( Database $Database, $LangCode)135 { 136 $DbResult = $ Database->select('Language', '*', 'Code='.$Database->quote($LangCode));134 function SaveToDatabase(string $LangCode): void 135 { 136 $DbResult = $this->Database->select('Language', '*', 'Code='.$this->Database->quote($LangCode)); 137 137 if ($DbResult->num_rows > 0) 138 138 { 139 139 $Language = $DbResult->fetch_assoc(); 140 $ Database->delete('Locale', '`Language`='.$Language['Id']);140 $this->Database->delete('Locale', '`Language`='.$Language['Id']); 141 141 foreach ($this->Texts->Data as $Index => $Item) 142 $ Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.143 'VALUES('.$Language['Id'].','.$ Database->quote($Index).','.$Database->quote($Item).')');144 } 145 } 146 147 function UpdateToDatabase( Database $Database, $LangCode)148 { 149 $DbResult = $ Database->select('Language', '*', '`Code`='.$Database->quote($LangCode));142 $this->Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '. 143 'VALUES('.$Language['Id'].','.$this->Database->quote($Index).','.$this->Database->quote($Item).')'); 144 } 145 } 146 147 function UpdateToDatabase(string $LangCode): void 148 { 149 $DbResult = $this->Database->select('Language', '*', '`Code`='.$this->Database->quote($LangCode)); 150 150 if ($DbResult->num_rows > 0) 151 151 { … … 153 153 foreach ($this->Texts->Data as $Index => $Item) 154 154 { 155 $DbResult = $ Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).155 $DbResult = $this->Database->select('Locale', '*', '(`Original` ='.$this->Database->quote($Index). 156 156 ') AND (`Language`='.($Language['Id']).')'); 157 157 if ($DbResult->num_rows > 0) 158 $ Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.159 '(`Original` ='.$ Database->quote($Index).')', array('Translated' => $Item));160 else $ Database->insert('Locale', array('Language' => $Language['Id'],158 $this->Database->update('Locale', '(`Language`='.($Language['Id']).') AND '. 159 '(`Original` ='.$this->Database->quote($Index).')', array('Translated' => $Item)); 160 else $this->Database->insert('Locale', array('Language' => $Language['Id'], 161 161 'Original' => $Index, 'Translated' => $Item)); 162 162 } … … 167 167 class LocaleManager extends Model 168 168 { 169 var$CurrentLocale;170 var$Codes;171 var$Dir;172 var$LangCode;173 var$DefaultLangCode;174 var$Available;169 public LocaleFile $CurrentLocale; 170 public array $Codes; 171 public string $Dir; 172 public string $LangCode; 173 public string $DefaultLangCode; 174 public array $Available; 175 175 176 176 function __construct(System $System) … … 182 182 $this->DefaultLangCode = 'en'; 183 183 $this->Available = array(); 184 } 185 186 function LoadAvailable() 184 $this->Dir = ''; 185 } 186 187 function LoadAvailable(): void 187 188 { 188 189 $this->Available = array(); … … 201 202 } 202 203 203 function UpdateAll( $Directory)204 function UpdateAll(string $Directory): void 204 205 { 205 206 $Locale = new LocaleFile($this->System); … … 222 223 if (!array_key_exists($Index, $Locale->Texts->Data)) 223 224 unset($FileLocale->Texts->Data[$Index]); 224 $FileLocale->UpdateToDatabase($ this->System->Database, $FileLocale->Texts->Code);225 $FileLocale->UpdateToDatabase($FileLocale->Texts->Code); 225 226 $FileName = $this->Dir.'/'.$FileLocale->Texts->Code.'.php'; 226 227 $FileLocale->SaveToFile($FileName); … … 230 231 } 231 232 232 function LoadLocale( $Code)233 function LoadLocale(string $Code): void 233 234 { 234 235 if (array_key_exists($Code, $this->Available)) … … 241 242 242 243 // Short named global translation function 243 function T( $Text, $Group = '')244 function T(string $Text, string $Group = ''): string 244 245 { 245 246 global $GlobalLocaleManager; -
trunk/Packages/Common/Mail.php
r55 r63 9 9 class Mail 10 10 { 11 var $Priorities; 12 var $Subject; 13 var $From; 14 var $Recipients; 15 var $Bodies; 16 var $Attachments; 17 var $AgentIdent; 18 var $Organization; 19 var $ReplyTo; 20 var $Headers; 11 public string $Subject; 12 public string $From; 13 public array $Recipients; 14 public array $Bodies; 15 public array $Attachments; 16 public string $AgentIdent; 17 public string $Organization; 18 public string $ReplyTo; 19 public array $Headers; 20 private array $Priorities; 21 private string $Boundary; 21 22 22 23 function __construct() … … 28 29 } 29 30 30 function Clear() 31 function Clear(): void 31 32 { 32 33 $this->Bodies = array(); … … 41 42 } 42 43 43 function AddToCombined( $Address)44 function AddToCombined(string $Address): void 44 45 { 45 46 $this->Recipients[] = array('Address' => $Address, 'Type' => 'SendCombined'); 46 47 } 47 48 48 function AddTo( $Address, $Name)49 function AddTo(string $Address, string $Name): void 49 50 { 50 51 $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Send'); 51 52 } 52 53 53 function AddCc( $Address, $Name)54 function AddCc(string $Address, string $Name): void 54 55 { 55 56 $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Copy'); 56 57 } 57 58 58 function AddBcc( $Address, $Name)59 function AddBcc(string $Address, string $Name): void 59 60 { 60 61 $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'HiddenCopy'); 61 62 } 62 63 63 function AddBody( $Content, $MimeType = 'text/plain', $Charset = 'utf-8')64 function AddBody(string $Content, string $MimeType = 'text/plain', string $Charset = 'utf-8'): void 64 65 { 65 66 $this->Bodies[] = array('Content' => $Content, 'Type' => strtolower($MimeType), … … 67 68 } 68 69 69 function Organization( $org)70 function Organization(string $org): void 70 71 { 71 72 if (trim($org != '')) $this->xheaders['Organization'] = $org; 72 73 } 73 74 74 function Priority( $Priority)75 function Priority(int $Priority): bool 75 76 { 76 77 if (!intval($Priority)) return false; 77 78 78 if (!isset($this-> priorities[$Priority - 1])) return false;79 80 $this->xheaders['X-Priority'] = $this-> priorities[$Priority - 1];79 if (!isset($this->Priorities[$Priority - 1])) return false; 80 81 $this->xheaders['X-Priority'] = $this->Priorities[$Priority - 1]; 81 82 return true; 82 83 } 83 84 84 function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT) 85 function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT): void 85 86 { 86 87 $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType, … … 88 89 } 89 90 90 function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT) 91 function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT): void 91 92 { 92 93 $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType, … … 94 95 } 95 96 96 function Send() 97 function Send(): bool 97 98 { 98 99 if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body')); … … 144 145 if ($this->Subject == '') throw new Exception(T('Mail message missing Subject')); 145 146 146 147 147 $res = mail($To, $this->Subject, $Body, $Headers); 148 148 return $res; 149 149 } 150 150 151 function ValidEmail( $Address)152 { 153 if ( ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];154 if ( ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))151 function ValidEmail(string $Address): bool 152 { 153 if (preg_match(".*<(.+)>", $Address, $regs)) $Address = $regs[1]; 154 if (preg_match("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address)) 155 155 return true; 156 156 else return false; 157 157 } 158 158 159 function CheckAdresses( $Addresses)159 function CheckAdresses(array $Addresses): void 160 160 { 161 161 foreach ($Addresses as $Address) 162 162 { 163 163 if (!$this->ValidEmail($Address)) 164 throw new Exception(sprintf(T('Mail message invalid address %s'), $Address)); 165 } 166 } 167 168 private function ContentEncoding($Charset) 164 { 165 throw new Exception(sprintf(T('Mail message invalid address %s'), $Address)); 166 } 167 } 168 } 169 170 private function ContentEncoding($Charset): string 169 171 { 170 172 if ($Charset != CHARSET_ASCII) return '8bit'; … … 172 174 } 173 175 174 private function BuildAttachment($Body) 176 private function BuildAttachment($Body): string 175 177 { 176 178 if (count($this->Attachments) > 0) … … 206 208 } 207 209 208 private function BuildBody() 210 private function BuildBody(): string 209 211 { 210 212 $Result = ''; … … 219 221 $this->Headers['Content-Transfer-Encoding'] = $this->ContentEncoding($this->Bodies[0]['Charset']); 220 222 } 221 222 223 223 224 foreach ($this->Bodies as $Body) -
trunk/Packages/Common/NetworkAddress.php
r55 r63 1 1 <?php 2 3 define('IPV4_BIT_WIDTH', 32); 2 4 3 5 class NetworkAddressIPv4 4 6 { 5 var$Address;6 var$Prefix;7 public int $Address; 8 public int $Prefix; 7 9 8 10 function __construct() … … 12 14 } 13 15 14 function GetNetMask() 16 function GetNetMask(): int 15 17 { 16 return 0xffffffff ^ ((1 << (32- $this->Prefix)) - 1);18 return ((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1); 17 19 } 18 20 19 function AddressToString() 21 function AddressToString(): string 20 22 { 21 23 return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))); 22 24 } 23 25 24 function AddressFromString( $Value)26 function AddressFromString(string $Value): void 25 27 { 26 28 $Parts = explode('.', $Value); … … 28 30 } 29 31 30 function GetRange() 32 function GetRange(): array 31 33 { 32 34 $From = new NetworkAddressIPv4(); 33 35 $From->Address = $this->Address; 34 $From->Prefix = 32;36 $From->Prefix = IPV4_BIT_WIDTH; 35 37 $HostMask = 0xffffffff ^ $this->GetNetMask(); 36 38 $To = new NetworkAddressIPv4(); 37 39 $To->Address = $From->Address + $HostMask; 38 $To->Prefix = 32;40 $To->Prefix = IPV4_BIT_WIDTH; 39 41 return array('From' => $From, 'To' => $To); 40 42 } 41 43 42 function ChangePrefix( $NewPrefix)44 function ChangePrefix(int $NewPrefix): void 43 45 { 44 46 $this->Prefix = $NewPrefix; 45 if ($this->Prefix > 32) $this->Prefix = 32;47 if ($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH; 46 48 if ($this->Prefix < 0) $this->Prefix = 0; 47 49 $this->Address = $this->Address & $this->GetNetMask(); 48 50 } 49 51 50 function Contain( $Address)52 function Contain(NetworkAddressIPv4 $Address): bool 51 53 { 52 54 $UpperNetmask = $this->GetNetMask(); 53 55 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true; 54 56 else $Result = false; 55 //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n");56 57 return $Result; 57 58 } 58 59 } 59 60 61 define('IPV6_BIT_WIDTH', 128); 62 60 63 class NetworkAddressIPv6 61 64 { 62 var$Address;63 var$Prefix;65 public string $Address; 66 public int $Prefix; 64 67 65 68 function __construct() … … 69 72 } 70 73 71 function AddressToString() 74 function GetNetMask(): string 75 { 76 return Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)), 77 Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH - $this->Prefix)), IntToInt128(1))); 78 } 79 80 function AddressToString(): string 72 81 { 73 82 return inet_ntop($this->Address); 74 83 } 75 84 76 function AddressFromString( $Value)85 function AddressFromString(string $Value) 77 86 { 78 87 $this->Address = inet_pton($Value); 79 88 } 80 89 81 function GetOctets() 90 function ChangePrefix(int $NewPrefix): void 91 { 92 $this->Prefix = $NewPrefix; 93 if ($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH; 94 if ($this->Prefix < 0) $this->Prefix = 0; 95 $this->Address = Int128And($this->Address, $this->GetNetMask()); 96 } 97 98 function GetOctets(): array 82 99 { 83 100 $Result = array(); … … 92 109 } 93 110 94 function EncodeMAC( $MAC)111 function EncodeMAC(string $MAC): void 95 112 { 96 113 $MAC = explode(':', $MAC); … … 107 124 } 108 125 126 function Contain(NetworkAddressIPv6 $Address): bool 127 { 128 $UpperNetmask = $this->GetNetMask(); 129 if (($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true; 130 else $Result = false; 131 return $Result; 132 } 109 133 } -
trunk/Packages/Common/Page.php
r56 r63 3 3 class Page extends View 4 4 { 5 var $Title; 6 var $ParentClass; 7 var $RawPage; 8 var $OnSystemMessage; 5 public string $Title; 6 public string $Description; 7 public string $ParentClass; 8 public bool $RawPage; 9 public $OnSystemMessage; 10 public string $Load; 11 public string $Unload; 9 12 10 13 function __construct(System $System) … … 13 16 $this->RawPage = false; 14 17 $this->OnSystemMessage = array(); 18 $this->Title = ""; 19 $this->Description = ""; 20 $this->ParentClass = ""; 15 21 } 16 22 17 function Show() 23 function Show(): string 18 24 { 19 25 return ''; 20 26 } 21 27 22 function GetOutput() 28 function GetOutput(): string 23 29 { 24 30 $Output = $this->Show(); … … 26 32 } 27 33 28 function SystemMessage( $Title, $Text)34 function SystemMessage(string $Title, string $Text): string 29 35 { 30 36 return call_user_func_array($this->OnSystemMessage, array($Title, $Text)); -
trunk/Packages/Common/PrefixMultiplier.php
r55 r63 72 72 class PrefixMultiplier 73 73 { 74 function TruncateDigits($Value, $Digits = 4) 74 function TruncateDigits($Value, $Digits = 4): string 75 75 { 76 76 for ($II = 2; $II > -6; $II--) … … 87 87 } 88 88 89 function Add($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal') 89 function Add($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal'): string 90 90 { 91 91 global $PrefixMultipliers; -
trunk/Packages/Common/Process.php
r56 r63 3 3 class Process 4 4 { 5 var$Command;6 var$Handle;7 var$Pipes;8 var$Environment;9 var$WorkingDir;10 5 public string $Command; 6 public $Handle; 7 public array $Pipes; 8 public array $Environment; 9 public ?string $WorkingDir; 10 11 11 function __construct() 12 12 { … … 17 17 $this->WorkingDir = null; 18 18 } 19 20 function Start() 19 20 function Start(): void 21 21 { 22 if (!$this->IsRunning())22 if (!$this->IsRunning()) 23 23 { 24 24 $DescriptorSpec = array( … … 28 28 ); 29 29 30 $this->Handle = proc_open($this->Command, $DescriptorSpec, $this->Pipes, 30 $this->Handle = proc_open($this->Command, $DescriptorSpec, $this->Pipes, 31 31 $this->WorkingDir, $this->Environment); 32 32 stream_set_blocking($this->Pipes[0], FALSE); … … 35 35 } 36 36 } 37 38 function Stop() 37 38 function Stop(): void 39 39 { 40 if ($this->IsRunning())40 if ($this->IsRunning()) 41 41 { 42 42 proc_close($this->Handle); … … 44 44 } 45 45 } 46 47 function IsRunning() 46 47 function IsRunning(): bool 48 48 { 49 return (is_resource($this->Handle));49 return is_resource($this->Handle); 50 50 } 51 51 } -
trunk/Packages/Common/RSS.php
r55 r63 3 3 class RSS 4 4 { 5 var$Charset;6 var$Title;7 var$Link;8 var$Description;9 var$WebmasterEmail;10 var$Items;5 public string $Charset; 6 public string $Title; 7 public string $Link; 8 public string $Description; 9 public string $WebmasterEmail; 10 public array $Items; 11 11 12 12 function __construct() 13 13 { 14 $this->Charset = 'utf-8'; 14 $this->Charset = 'utf8'; 15 $this->Title = ''; 16 $this->Link = ''; 17 $this->Description = ''; 18 $this->WebmasterEmail = ''; 15 19 $this->Items = array(); 16 20 } 17 21 18 function Generate() 22 function Generate(): string 19 23 { 20 Header('Content-Type: text/xml; charset=utf-8');21 24 $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<? 22 23 24 25 26 27 28 29 30 25 '<rss version="2.0">'."\n". 26 " <channel>\n". 27 " <title>".$this->Title."</title>\n". 28 " <link>".$this->Link."</link>\n". 29 " <description>".$this->Description."</description>\n". 30 " <language>cs</language>\n". 31 " <webMaster>".$this->WebmasterEmail."</webMaster>\n". 32 " <pubDate>".date('r')."</pubDate>\n". 33 " <ttl>20</ttl>\n"; 31 34 foreach ($this->Items as $Item) 32 35 { … … 34 37 ' <title>'.htmlspecialchars($Item['Title'])."</title>\n". 35 38 ' <description>'.htmlspecialchars($Item['Description'])."</description>\n". 36 37 39 ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n". 40 ' <link>'.$Item['Link']."</link>\n". 38 41 " </item>\n"; 39 42 } -
trunk/Packages/Common/Table.php
r56 r63 3 3 class Control 4 4 { 5 var$Name;5 public string $Name; 6 6 7 function Show() 7 function Show(): string 8 8 { 9 9 return ''; … … 13 13 class Table 14 14 { 15 function GetCell($Y, $X) 15 function GetCell($Y, $X): string 16 16 { 17 17 return ''; … … 26 26 } 27 27 28 function RowsCount() 28 function RowsCount(): int 29 29 { 30 30 return 0; … … 34 34 class TableMemory extends Table 35 35 { 36 var$Cells;36 public array $Cells; 37 37 38 function GetCell($Y, $X) 38 function GetCell($Y, $X): string 39 39 { 40 40 return $this->Cells[$Y][$X]; 41 41 } 42 42 43 function RowsCount() 43 function RowsCount(): int 44 44 { 45 45 return count($this->Cells); … … 49 49 class TableSQL extends Table 50 50 { 51 var$Query;52 var$Database;53 var$Cells;51 public string $Query; 52 public Database $Database; 53 public array $Cells; 54 54 55 function GetCell($Y, $X) 55 function GetCell($Y, $X): string 56 56 { 57 57 return $this->Cells[$Y][$X]; … … 73 73 } 74 74 75 function RowsCount() 75 function RowsCount(): int 76 76 { 77 77 return count($this->Cells); … … 81 81 class TableColumn 82 82 { 83 var$Name;84 var$Title;83 public string $Name; 84 public string $Title; 85 85 } 86 86 87 87 class VisualTable extends Control 88 88 { 89 var$Cells;90 var$Columns;91 var$OrderSQL;92 var$OrderColumn;93 var$OrderDirection;94 var$OrderArrowImage;95 var$DefaultColumn;96 var$DefaultOrder;97 var$Table;98 var$Style;89 public array $Cells; 90 public array $Columns; 91 public string $OrderSQL; 92 public string $OrderColumn; 93 public int $OrderDirection; 94 public array $OrderArrowImage; 95 public string $DefaultColumn; 96 public int $DefaultOrder; 97 public TableMemory $Table; 98 public string $Style; 99 99 100 function __construct( $System)100 function __construct() 101 101 { 102 global $System; 103 102 104 $this->Columns = array(); 103 105 $this->Table = new TableMemory(); … … 124 126 } 125 127 126 function Show() 128 function Show(): string 127 129 { 128 130 $Output = '<table class="'.$this->Style.'">'; … … 146 148 } 147 149 148 function GetOrderHeader() 150 function GetOrderHeader(): string 149 151 { 150 152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; -
trunk/Packages/Common/UTF8.php
r55 r63 526 526 } 527 527 528 function ToUTF8 ($String, $Charset = 'iso2')528 function ToUTF8string(string $String, string $Charset = 'iso2'): string 529 529 { 530 530 $Result = ''; … … 540 540 } 541 541 542 function FromUTF8( $String, $Charset = 'iso2')542 function FromUTF8(string $String, string $Charset = 'iso2'): string 543 543 { 544 544 $Result = ''; … … 546 546 for ($I = 0; $I < strlen($String); $I++) 547 547 { 548 if (ord($String {$I}) & 0x80) // UTF control character548 if (ord($String[$I]) & 0x80) // UTF control character 549 549 { 550 if (ord($String {$I}) & 0x40) // First550 if (ord($String[$I]) & 0x40) // First 551 551 { 552 552 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 553 $UTFPrefix = $String {$I};553 $UTFPrefix = $String[$I]; 554 554 } 555 else $UTFPrefix .= $String {$I}; // Next555 else $UTFPrefix .= $String[$I]; // Next 556 556 } else 557 557 { 558 558 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 559 559 $UTFPrefix = ''; 560 $Result .= $String {$I};560 $Result .= $String[$I]; 561 561 } 562 562 } -
trunk/Packages/Common/Update.php
r56 r63 3 3 class UpdateManager 4 4 { 5 var $Revision; 6 var $Trace; 7 var $VersionTable; 8 /* @var Database */ 9 var $Database; 10 var $InstallMethod; 5 public int $Revision; 6 public array $Trace; 7 public string $VersionTable; 8 public Database $Database; 9 public string $InstallMethod; 11 10 12 11 function __construct() … … 19 18 } 20 19 21 function GetDbVersion() 20 function GetDbVersion(): ?int 22 21 { 23 22 $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1'); … … 26 25 } 27 26 28 function IsInstalled() 27 function IsInstalled(): bool 29 28 { 30 29 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); … … 32 31 } 33 32 34 function IsUpToDate() 33 function IsUpToDate(): bool 35 34 { 36 35 return $this->Revision <= $this->GetDbVersion(); 37 36 } 38 37 39 function Upgrade() 38 function Upgrade(): string 40 39 { 41 40 $DbRevision = $this->GetDbVersion(); … … 59 58 } 60 59 61 function Install() 60 function Install(): void 62 61 { 63 62 $InstallMethod = $this->InstallMethod; 64 63 $InstallMethod($this); 65 $this->Update();66 64 } 67 65 68 function Uninstall() 66 function Uninstall(): void 69 67 { 70 71 68 } 72 69 73 function InsertSampleData() 70 function InsertSampleData(): void 74 71 { 75 72 $InstallMethod = $this->InsertSampleDataMethod; … … 77 74 } 78 75 79 function Execute( $Query)76 function Execute(string $Query): DatabaseResult 80 77 { 81 78 echo($Query.';<br/>'); -
trunk/View.php
r56 r63 5 5 class BaseView extends View 6 6 { 7 var$TimeStart;8 var$FormatHTML = false;9 var$ShowRuntimeInfo = false;10 var$ShowNavigation = false;11 var$BasicHTML = false;12 var$ParentClass = '';13 var $ShortTitle;14 var $FullTitle;15 var$Encoding;16 var$Style;7 public int $TimeStart; 8 public bool $FormatHTML = false; 9 public bool $ShowRuntimeInfo = false; 10 public bool $ShowNavigation = false; 11 public bool $BasicHTML = false; 12 public string $ParentClass = ''; 13 public string $Title; 14 public string $Description; 15 public string $Encoding; 16 public string $Style; 17 17 18 18 function __construct($System) … … 36 36 } 37 37 38 function SystemMessage( $Title, $Text)38 function SystemMessage(string $Title, string $Text): string 39 39 { 40 40 return '<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>'; … … 43 43 } 44 44 45 function ShowNavigation( $Page)45 function ShowNavigation(Page $Page): string 46 46 { 47 47 if (array_key_exists('REQUEST_URI', $_SERVER)) … … 71 71 } 72 72 73 function ShowHeader($Page) 74 { 75 $Title = $Page->FullTitle; 76 $Path = $Page->ShortTitle; 73 function ShowHeader(Page $Page): string 74 { 75 $Path = $Page->Title; 77 76 78 77 $Navigation = $this->ShowNavigation($Page); … … 99 98 100 99 $Output .= '</head><body'.$BodyParam.'>'; 101 $Output .= $this->System->ShowMenu();100 $Output .= Core::Cast($this->System)->ShowMenu(); 102 101 if ($this->BasicHTML == false) 103 102 { … … 115 114 } 116 115 117 function ShowFooter() 116 function ShowFooter(): string 118 117 { 119 118 global $ScriptTimeStart, $Revision, $ReleaseTime; … … 125 124 $Output .= '<div class="Footer">'. 126 125 '<i>'; 127 $Output .= ' Kontakt: <a href="mailto:'.$this->System->Config['Web']['AdminEmail'].'">'.$this->System->Config['Web']['AdminEmail'].'</a> '; 128 $Output .= ' <a href="https://app.zdechov.net/tanec/">Zdrojový kód</a> '; 126 $Output .= ' Projekt <a href="https://app.zdechov.net/tanec/">Tanec</a> | '; 127 $Output .= ' Správce: <a href="mailto:'.$this->System->Config['Web']['AdminEmail'].'">'.$this->System->Config['Web']['AdminEmail'].'</a> '; 128 129 129 //$Output .= ' Verze: '.$Revision.' ('.HumanDate($ReleaseTime).') '; 130 130 if ($this->ShowRuntimeInfo == true) … … 139 139 } 140 140 141 function GetOutput( $Page)141 function GetOutput(Page $Page): string 142 142 { 143 143 $Page->OnSystemMessage = array($this->System->BaseView, 'SystemMessage'); … … 152 152 } 153 153 154 function NewPage( $ClassName)154 function NewPage(string $ClassName): Page 155 155 { 156 156 $Page = new $ClassName(); … … 162 162 163 163 // XML formating function 164 function FormatOutput( $s)164 function FormatOutput(string $s): string 165 165 { 166 166 $out = ''; -
trunk/index.php
r61 r63 5 5 require_once('Packages/Common/Common.php'); 6 6 require_once('View.php'); 7 8 7 9 8 require_once('Modules/Meet/Meet.php'); … … 18 17 if (isset($_SERVER['REMOTE_ADDR'])) session_start(); 19 18 20 class ApplicationTanec extends Application 21 { 22 var $Config; 23 var $Title; 24 var $Pages; 25 var $PathItems; 26 var $ShowPage; 27 var $MainMenu; 28 var $PageHeaders; 29 var $Bars; 19 class Core extends System 20 { 21 public array $Config; 22 public array $PathItems; 23 public bool $ShowPage; 24 public array $MainMenu; 25 public array $PageHeaders; 26 public array $Bars; 30 27 31 28 function __construct() … … 38 35 } 39 36 40 function IsAdmin() 37 function IsAdmin(): bool 41 38 { 42 39 return array_key_exists('IsAdmin', $_SESSION) and ($_SESSION['IsAdmin'] == 1); 43 40 } 44 41 45 function Link( $URL)42 function Link(string $URL): string 46 43 { 47 44 return $this->Config['BaseURL'].$URL; 48 45 } 49 46 50 function AbsoluteLink( $URL)47 function AbsoluteLink(string $URL): string 51 48 { 52 49 return $this->Config['HostName'].$this->Config['BaseURL'].$URL; 53 50 } 54 51 55 function ShowMenu() 52 function ShowMenu(): string 56 53 { 57 54 $Output = '<div>'; … … 64 61 } 65 62 66 function ProcessURL() 63 function ProcessURL(): array 67 64 { 68 65 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) … … 78 75 } 79 76 80 function RegisterPage($Path, $Handler) 77 function RegisterPage($Path, $Handler): void 81 78 { 82 79 if (is_array($Path)) … … 93 90 } 94 91 95 function RegisterMenuItem( $Link, $Title)92 function RegisterMenuItem(string $Link, string $Title): void 96 93 { 97 94 $this->MainMenu[] = array('Link' => $Link, 'Title' => $Title); 98 95 } 99 96 100 function RegisterPageHeader( $Name, $Callback)97 function RegisterPageHeader(string $Name, array $Callback): void 101 98 { 102 99 $this->PageHeaders[$Name] = $Callback; 103 100 } 104 101 105 function RegisterPageBar( $Name)102 function RegisterPageBar(string $Name): void 106 103 { 107 104 $this->Bars[$Name] = array(); 108 105 } 109 106 110 function UnregisterPageBar( $Name)107 function UnregisterPageBar(string $Name): void 111 108 { 112 109 unset($this->Bars[$Name]); 113 110 } 114 111 115 function SearchPage( $PathItems, $Pages)112 function SearchPage(array $PathItems, array $Pages): ?string 116 113 { 117 114 if (count($PathItems) > 0) $PathItem = $PathItems[0]; … … 127 124 } 128 125 129 function PageNotFound() 126 function PageNotFound(): string 130 127 { 131 128 return 'Page '.implode('/', $this->PathItems).' not found.'; 132 129 } 133 130 134 function ShowPage() 131 function ShowPage(): void 135 132 { 136 133 $this->BaseView = new BaseView($this); 137 134 138 /* @var $Page Page */139 135 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 140 136 if ($ClassName != '') 141 137 { 142 138 $Page = new $ClassName($this); 143 } else { 139 } else 140 { 144 141 $Page = new PageMissing($this); 145 142 } … … 147 144 } 148 145 149 function Run() 146 function Run(): void 150 147 { 151 148 $this->RunCommon(); … … 157 154 } 158 155 159 function RunCommon() 156 function RunCommon(): void 160 157 { 161 158 global $Config; … … 172 169 173 170 $this->RegisterPageBar('Top'); 174 $this->Title = 'Tanec'; 175 $Output = ''; 171 $this->Name = 'Tanec'; 172 } 173 174 static function Cast(System $System): Core 175 { 176 if ($System instanceof Core) 177 { 178 return $System; 179 } 180 throw new Exception('Expected Core type but '.gettype($System)); 176 181 } 177 182 } … … 179 184 class PageMissing extends Page 180 185 { 181 var $FullTitle = 'Stránka nenalezena';182 var $ShortTitle = 'Stránka nenalezena';183 184 186 function __construct($System) 185 187 { 186 188 parent::__construct($System); 189 $this->Title = 'Stránka nenalezena'; 187 190 $this->ParentClass = 'PagePortal'; 188 191 } 189 192 190 function Show() 193 function Show(): string 191 194 { 192 195 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); … … 202 205 } 203 206 204 function Show() 207 function Show(): string 205 208 { 206 209 $this->RawPage = true; … … 214 217 class PageSiteMap extends Page 215 218 { 216 function Show() 219 function Show(): string 217 220 { 218 221 $this->RawPage = true; … … 265 268 class PageLogin extends Page 266 269 { 267 function Show() 270 function __construct($System) 271 { 272 parent::__construct($System); 273 $this->Title = 'Přihlášení'; 274 $this->ParentClass = 'PagePortal'; 275 } 276 277 function Show(): string 268 278 { 269 279 global $Config; … … 296 306 $Output .= $this->ShowLoginForm(); 297 307 } 298 if ($this->System->IsAdmin()) $Output .= '<div>Jsi přihlášen jako správce. <a href="?logoff">Odhlásit</a></div>';308 if(Core::Cast($this->System)->IsAdmin()) $Output .= '<div>Jsi přihlášen jako správce. <a href="?logoff">Odhlásit</a></div>'; 299 309 return $Output; 300 310 } 301 311 302 function ShowLoginForm() 312 function ShowLoginForm(): string 303 313 { 304 314 return '<form method="post" action="?login">'. 305 306 307 308 } 309 } 310 311 $Revision = 51; // Subversion revision315 'Heslo: <input type="password" name="password" value=""/><br/>'. 316 '<input type="submit" value="Přihlásit"/>'. 317 '</form>'; 318 } 319 } 320 321 $Revision = 63; // Subversion revision 312 322 $DatabaseRevision = 51; // SQL structure revision 313 $ReleaseTime = strtotime('202 0-01-01');314 315 $Application = new ApplicationTanec();323 $ReleaseTime = strtotime('2021-08-03'); 324 325 $Application = new Core(); 316 326 $Application->ModuleManager->LoadModulesFromDir(dirname(__FILE__).'/Modules'); 317 327 $Application->Modules = $Application->ModuleManager->Modules; 318 328 $Application->ModuleManager->InstallAll(); 319 329 $Application->ModuleManager->StartAll(); 320 $Application->RegisterPage( '', 'PageDanceList');321 $Application->RegisterPage( 'robots.txt', 'PageRobots');322 $Application->RegisterPage( 'sitemap.xml', 'PageSiteMap');323 $Application->RegisterPage( 'admin', 'PageLogin');330 $Application->RegisterPage([''], 'PageDanceList'); 331 $Application->RegisterPage(['robots.txt'], 'PageRobots'); 332 $Application->RegisterPage(['sitemap.xml'], 'PageSiteMap'); 333 $Application->RegisterPage(['admin'], 'PageLogin'); 324 334 $Application->Run();
Note:
See TracChangeset
for help on using the changeset viewer.