Changeset 887
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 145 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r886 r887 14 14 class Core extends Application 15 15 { 16 /** @var Type */ 17 var $Type; 18 var $Pages; 19 var $Bars; 20 /** @var FormManager */ 21 var $FormManager; 22 /** @var Config */ 23 var $ConfigManager; 24 var $PathItems; 25 var $RootURLFolder; 26 var $ShowPage; 27 var $Setup; 28 var $CommandLine; 29 var $PageHeaders; 30 var $BaseView; 16 public Type $Type; 17 public array $Bars; 18 public FormManager $FormManager; 19 public array $Config; 20 public Config $ConfigManager; 21 public array $PathItems; 22 public string $RootURLFolder; 23 public bool $ShowPage; 24 public Setup $Setup; 25 public array $PageHeaders; 26 public BaseView $BaseView; 27 public LocaleManager $LocaleManager; 28 public array $LinkLocaleExceptions; 31 29 32 30 function __construct() 33 31 { 34 32 parent::__construct(); 35 $this->Modules = array(); 36 $this->Pages = array(); 33 $this->Config = array(); 37 34 $this->ModuleManager->FileName = dirname(__FILE__).'/../Config/ModulesConfig.php'; 38 35 $this->FormManager = new FormManager($this->Database); … … 42 39 if (substr($this->RootURLFolder, -10, 10) == '/index.php') 43 40 $this->RootURLFolder = substr($this->RootURLFolder, 0, -10); 44 $this->CommandLine = array();45 41 $this->PageHeaders = array(); 46 } 47 48 function RegisterPage($Path, $Handler) 49 { 50 if (is_array($Path)) 51 { 52 $Page = &$this->Pages; 53 $LastKey = array_pop($Path); 54 foreach ($Path as $PathItem) 55 { 56 $Page = &$Page[$PathItem]; 57 } 58 if (!is_array($Page)) $Page = array('' => $Page); 59 $Page[$LastKey] = $Handler; 60 } else $this->Pages[$Path] = $Handler; 61 } 62 63 function UnregisterPage($Path) 64 { 65 unset($this->Pages[$Path]); 66 } 67 68 function SearchPage($PathItems, $Pages) 42 $this->LinkLocaleExceptions = array(); 43 } 44 45 function SearchPage(array $PathItems, array $Pages): ?string 69 46 { 70 47 if (count($PathItems) > 0) $PathItem = $PathItems[0]; … … 80 57 } 81 58 82 function PageNotFound() 83 { 84 return 'Page '.implode('/', $this->PathItems).' not found.'; 85 } 86 87 function ShowPage() 59 function ShowPage(): void 88 60 { 89 61 $this->BaseView = new BaseView($this); … … 94 66 { 95 67 $Page = new $ClassName($this); 96 } else { 68 } else 69 { 97 70 $Page = new PageMissing($this); 98 71 } … … 100 73 } 101 74 102 function ModulePresent( $Name)103 { 104 return array_key_exists($Name, $this->Module s);105 } 106 107 function AddModule($Module) 108 { 109 $this->Module s[get_class($Module)] = $Module;110 } 111 112 function HumanDate( $Time)75 function ModulePresent(string $Name): bool 76 { 77 return array_key_exists($Name, $this->ModuleManager->Modules); 78 } 79 80 function AddModule($Module): void 81 { 82 $this->ModuleManager->Modules[get_class($Module)] = $Module; 83 } 84 85 function HumanDate(int $Time): string 113 86 { 114 87 return date('j.n.Y', $Time); 115 88 } 116 89 117 function Link( $Target)90 function Link(string $Target): string 118 91 { 119 92 return $this->RootURLFolder.$Target; 120 93 } 121 94 122 function ShowAction( $Id)95 function ShowAction(string $Id): string 123 96 { 124 97 $Output = ''; … … 131 104 if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png'; 132 105 if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']); 133 if (!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id))106 if (!defined('NEW_PERMISSION') or ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('System', 'Read', 'Item', $Id)) 134 107 $Output .= '<img alt="'.$Action['Title'].'" src="'.$this->Link('/images/favicons/'.$Action['Icon']). 135 108 '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>'; … … 138 111 } 139 112 140 function RunCommon() 141 { 142 global $Database, $ScriptTimeStart, $ConfigFileName, $Mail, $Type, 143 $DatabaseRevision, $Config, $GlobalLocaleManager; 113 function RunCommon(): void 114 { 115 global $Database, $ScriptTimeStart, $ConfigFileName, $Config, $GlobalLocaleManager; 144 116 145 117 date_default_timezone_set('Europe/Prague'); … … 199 171 } 200 172 201 function Run() 173 function Run(): void 202 174 { 203 175 $this->RunCommon(); … … 213 185 { 214 186 $NewLangCode = $this->PathItems[0]; 215 if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) 187 if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) 216 188 { 217 189 array_shift($this->PathItems); … … 226 198 } 227 199 228 function RunCommandLine() 200 function RunCommandLine(): void 229 201 { 230 202 global $argv; … … 236 208 { 237 209 $Command = $this->CommandLine[$argv[1]]; 238 $Output = call_user_func($Command ['Callback'], $argv);210 $Output = call_user_func($Command->Callback, $argv); 239 211 } else $Output = 'Command "'.$argv[1].'" not supported.'."\n"; 240 } else $Output = 'No command was given as parameter '."\n";212 } else $Output = 'No command was given as parameter. Use "list" to show available commands.'."\n"; 241 213 echo($Output); 242 214 } 243 215 244 function RegisterCommandLine($Name, $Callback) 245 { 246 $this->CommandLine[$Name] = array('Name' => $Name, 'Callback' => $Callback); 247 } 248 249 function RegisterPageBar($Name) 216 function RegisterPageBar(string $Name): void 250 217 { 251 218 $this->Bars[$Name] = array(); 252 219 } 253 220 254 function UnregisterPageBar( $Name)221 function UnregisterPageBar(string $Name): void 255 222 { 256 223 unset($this->Bars[$Name]); 257 224 } 258 225 259 function RegisterPageBarItem( $BarName, $ItemName, $Callback)226 function RegisterPageBarItem(string $BarName, string $ItemName, callable $Callback): void 260 227 { 261 228 $this->Bars[$BarName][$ItemName] = $Callback; 262 229 } 263 230 264 function RegisterPageHeader($Name, $Callback) 231 function UnregisterPageBarItem(string $BarName, string $ItemName): void 232 { 233 unset($this->Bars[$BarName][$ItemName]); 234 } 235 236 function RegisterPageHeader(string $Name, callable $Callback): void 265 237 { 266 238 $this->PageHeaders[$Name] = $Callback; 239 } 240 241 function UnregisterPageHeader(string $Name): void 242 { 243 unset($this->PageHeaders[$Name]); 267 244 } 268 245 } … … 270 247 class PageMissing extends Page 271 248 { 272 var $FullTitle = 'Stránka nenalezena'; 273 var $ShortTitle = 'Stránka nenalezena'; 274 275 function __construct($System) 249 function __construct(System $System) 276 250 { 277 251 parent::__construct($System); 252 $this->FullTitle = 'Stránka nenalezena'; 253 $this->ShortTitle = 'Stránka nenalezena'; 278 254 $this->ParentClass = 'PagePortal'; 279 255 } 280 256 281 function Show() 257 function Show(): string 282 258 { 283 259 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); -
trunk/Application/DefaultConfig.php
r874 r887 3 3 class DefaultConfig 4 4 { 5 function Get() 5 function Get(): array 6 6 { 7 7 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); -
trunk/Application/FormClasses.php
r844 r887 3 3 // TODO: Split all form class definitions to modules 4 4 5 function RegisterFormClasses( $FormManager)5 function RegisterFormClasses(FormManager $FormManager): void 6 6 { 7 7 $FormManager->Classes = array( -
trunk/Application/FullInstall.php
r782 r887 1 1 <?php 2 2 3 function FullInstall( $Manager)3 function FullInstall(UpdateManager $Manager): void 4 4 { 5 5 $Manager->Execute(" -
trunk/Application/UpdateTrace.php
r885 r887 1 1 <?php 2 2 3 function UpdateTo493( $Manager)3 function UpdateTo493(UpdateManager $Manager): void 4 4 { 5 5 $Manager->Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'"); 6 6 } 7 7 8 function UpdateTo494( $Manager)8 function UpdateTo494(UpdateManager $Manager): void 9 9 { 10 10 $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n". … … 13 13 } 14 14 15 function UpdateTo495( $Manager)15 function UpdateTo495(UpdateManager $Manager): void 16 16 { 17 17 $Manager->Execute("INSERT INTO `MapPosition` (SELECT NULL AS `Id`, `Name`, `MapPositionX` AS `Latitude`, `MapPositionY` AS `Longitude` FROM `Subject`)"); … … 24 24 } 25 25 26 function UpdateTo497( $Manager)26 function UpdateTo497(UpdateManager $Manager): void 27 27 { 28 28 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY ( `Id` ) "); … … 52 52 } 53 53 54 function UpdateTo498( $Manager)54 function UpdateTo498(UpdateManager $Manager): void 55 55 { 56 56 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". … … 76 76 } 77 77 78 function UpdateTo499( $Manager)78 function UpdateTo499(UpdateManager $Manager): void 79 79 { 80 80 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Currency` ( … … 121 121 } 122 122 123 function UpdateTo500( $Manager)123 function UpdateTo500(UpdateManager $Manager): void 124 124 { 125 125 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` ( … … 145 145 } 146 146 147 function UpdateTo502( $Manager)147 function UpdateTo502(UpdateManager $Manager): void 148 148 { 149 149 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginName` VARCHAR( 255 ) NOT NULL "); … … 159 159 } 160 160 161 function UpdateTo505( $Manager)161 function UpdateTo505(UpdateManager $Manager): void 162 162 { 163 163 $Manager->Execute("UPDATE `ISMenuItem` SET `Name` = 'Služby', `Table` = 'Service' WHERE `ISMenuItem`.`Name` ='Tarify';"); … … 186 186 } 187 187 188 function UpdateTo507( $Manager)188 function UpdateTo507(UpdateManager $Manager): void 189 189 { 190 190 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". … … 229 229 } 230 230 231 function UpdateTo515( $Manager)231 function UpdateTo515(UpdateManager $Manager): void 232 232 { 233 233 $Manager->Execute("ALTER TABLE `PermissionUserAssignment` CHANGE `User` `User` INT( 11 ) NULL"); 234 234 } 235 235 236 function UpdateTo517( $Manager)236 function UpdateTo517(UpdateManager $Manager): void 237 237 { 238 238 $Manager->Execute("ALTER TABLE `Log` ADD `IPAddress` VARCHAR( 16 ) NOT NULL"); 239 239 } 240 240 241 function UpdateTo526( $Manager)241 function UpdateTo526(UpdateManager $Manager): void 242 242 { 243 243 $Manager->Execute("ALTER TABLE `Hyperlink` CHANGE `Name` `Title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL"); … … 276 276 } 277 277 278 function UpdateTo527( $Manager)278 function UpdateTo527(UpdateManager $Manager): void 279 279 { 280 280 $Manager->Execute("RENAME TABLE `ISMenuItem` TO `MenuItem` ;"); … … 304 304 } 305 305 306 function UpdateTo535( $Manager)306 function UpdateTo535(UpdateManager $Manager): void 307 307 { 308 308 // Set all string collation to utf8 general … … 314 314 } 315 315 316 function UpdateTo549( $Manager)316 function UpdateTo549(UpdateManager $Manager): void 317 317 { 318 318 $Manager->Execute("ALTER TABLE `FinanceOperation` ADD `Generate` INT NOT NULL DEFAULT '0', … … 322 322 } 323 323 324 function UpdateTo550( $Manager)324 function UpdateTo550(UpdateManager $Manager): void 325 325 { 326 326 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;'); … … 329 329 } 330 330 331 function UpdateTo551( $Manager)331 function UpdateTo551(UpdateManager $Manager): void 332 332 { 333 333 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` , … … 343 343 } 344 344 345 function UpdateTo565( $Manager)345 function UpdateTo565(UpdateManager $Manager): void 346 346 { 347 347 $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` ( … … 369 369 } 370 370 371 function UpdateTo571( $Manager)371 function UpdateTo571(UpdateManager $Manager): void 372 372 { 373 373 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL , … … 375 375 } 376 376 377 function UpdateTo574( $Manager)377 function UpdateTo574(UpdateManager $Manager): void 378 378 { 379 379 $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;'); … … 383 383 } 384 384 385 function UpdateTo584( $Manager)385 function UpdateTo584(UpdateManager $Manager): void 386 386 { 387 387 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` ( … … 441 441 } 442 442 443 function UpdateTo591( $Manager)443 function UpdateTo591(UpdateManager $Manager): void 444 444 { 445 445 $Manager->Execute('ALTER TABLE `StockItem` ADD `Esemble` INT NULL , … … 449 449 } 450 450 451 function UpdateTo597( $Manager)451 function UpdateTo597(UpdateManager $Manager): void 452 452 { 453 453 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Model` ( … … 463 463 } 464 464 465 function UpdateTo601( $Manager)465 function UpdateTo601(UpdateManager $Manager): void 466 466 { 467 467 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceWireless` ( … … 489 489 } 490 490 491 function UpdateTo615( $Manager)491 function UpdateTo615(UpdateManager $Manager): void 492 492 { 493 493 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `AntennaPolarity` INT NOT NULL , … … 523 523 } 524 524 525 function UpdateTo619( $Manager)525 function UpdateTo619(UpdateManager $Manager): void 526 526 { 527 527 $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLogged` INT NOT NULL ;'); 528 528 } 529 529 530 function UpdateTo620( $Manager)530 function UpdateTo620(UpdateManager $Manager): void 531 531 { 532 532 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `ChannelWidthLower` INT NOT NULL , … … 536 536 } 537 537 538 function UpdateTo627( $Manager)538 function UpdateTo627(UpdateManager $Manager): void 539 539 { 540 540 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `TimeCreation` `Time` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00";'); … … 542 542 } 543 543 544 function UpdateTo632( $Manager)544 function UpdateTo632(UpdateManager $Manager): void 545 545 { 546 546 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceOperationRel` ( … … 557 557 } 558 558 559 function UpdateTo633( $Manager)559 function UpdateTo633(UpdateManager $Manager): void 560 560 { 561 561 $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLoggedHash` VARCHAR( 40 ) NOT NULL ;'); 562 562 } 563 563 564 function UpdateTo645( $Manager)564 function UpdateTo645(UpdateManager $Manager): void 565 565 { 566 566 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceVATType` ( … … 576 576 } 577 577 578 function UpdateTo646( $Manager)578 function UpdateTo646(UpdateManager $Manager): void 579 579 { 580 580 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contract` ( … … 612 612 } 613 613 614 function UpdateTo647( $Manager)614 function UpdateTo647(UpdateManager $Manager): void 615 615 { 616 616 $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Employee` ) REFERENCES `Employee` ( … … 647 647 } 648 648 649 function UpdateTo656( $Manager)649 function UpdateTo656(UpdateManager $Manager): void 650 650 { 651 651 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Measure` ( … … 706 706 } 707 707 708 function UpdateTo657( $Manager)708 function UpdateTo657(UpdateManager $Manager): void 709 709 { 710 710 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceUpDown` ( … … 727 727 } 728 728 729 function UpdateTo661( $Manager)729 function UpdateTo661(UpdateManager $Manager): void 730 730 { 731 731 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contact` ( … … 773 773 } 774 774 775 function UpdateTo662( $Manager)775 function UpdateTo662(UpdateManager $Manager): void 776 776 { 777 777 $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, 2 AS `Category`, `ICQ` AS `Value`, NULL AS `Subject`, `Id` AS `User` FROM `User` … … 783 783 } 784 784 785 function UpdateTo668( $Manager)785 function UpdateTo668(UpdateManager $Manager): void 786 786 { 787 787 $Manager->Execute('CREATE TABLE IF NOT EXISTS `APIToken` ( … … 799 799 } 800 800 801 function UpdateTo671( $Manager)801 function UpdateTo671(UpdateManager $Manager): void 802 802 { 803 803 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSignal` ( … … 834 834 } 835 835 836 function UpdateTo674( $Manager)836 function UpdateTo674(UpdateManager $Manager): void 837 837 { 838 838 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateRx` INT NOT NULL ;'); … … 840 840 } 841 841 842 function UpdateTo676( $Manager)842 function UpdateTo676(UpdateManager $Manager): void 843 843 { 844 844 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Device` INT NULL , … … 848 848 } 849 849 850 function UpdateTo678( $Manager)850 function UpdateTo678(UpdateManager $Manager): void 851 851 { 852 852 $Manager->Execute('ALTER TABLE `Contact` ADD `Description` VARCHAR( 255 ) NOT NULL ;'); … … 879 879 } 880 880 881 function UpdateTo679( $Manager)881 function UpdateTo679(UpdateManager $Manager): void 882 882 { 883 883 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `Product` INT NOT NULL AFTER `Id` , … … 885 885 } 886 886 887 function UpdateTo688( $Manager)887 function UpdateTo688(UpdateManager $Manager): void 888 888 { 889 889 // Convert monthly plus payment for consumption to regular service … … 899 899 } 900 900 901 function UpdateTo692( $Manager)901 function UpdateTo692(UpdateManager $Manager): void 902 902 { 903 903 // Convert user emails to contacts … … 912 912 } 913 913 914 function UpdateTo696( $Manager)914 function UpdateTo696(UpdateManager $Manager): void 915 915 { 916 916 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;'); … … 920 920 } 921 921 922 function UpdateTo697( $Manager)922 function UpdateTo697(UpdateManager $Manager): void 923 923 { 924 924 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;'); … … 929 929 } 930 930 931 function UpdateTo707( $Manager)931 function UpdateTo707(UpdateManager $Manager): void 932 932 { 933 933 $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;'); 934 934 } 935 935 936 function UpdateTo710( $Manager)936 function UpdateTo710(UpdateManager $Manager): void 937 937 { 938 938 $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;'); … … 995 995 } 996 996 997 function UpdateTo715( $Manager)997 function UpdateTo715(UpdateManager $Manager): void 998 998 { 999 999 $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP FOREIGN KEY `StockSerialNumber_ibfk_6`;'); … … 1005 1005 } 1006 1006 1007 function UpdateTo718( $Manager)1007 function UpdateTo718(UpdateManager $Manager): void 1008 1008 { 1009 1009 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Company` ( … … 1033 1033 } 1034 1034 1035 function UpdateTo719( $Manager)1035 function UpdateTo719(UpdateManager $Manager): void 1036 1036 { 1037 1037 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;'); … … 1077 1077 } 1078 1078 1079 function UpdateTo720( $Manager)1079 function UpdateTo720(UpdateManager $Manager): void 1080 1080 { 1081 1081 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;'); … … 1108 1108 } 1109 1109 1110 function UpdateTo722( $Manager)1110 function UpdateTo722(UpdateManager $Manager): void 1111 1111 { 1112 1112 $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;'); 1113 1113 } 1114 1114 1115 function UpdateTo725( $Manager)1115 function UpdateTo725(UpdateManager $Manager): void 1116 1116 { 1117 1117 // Text column of invoices is not used. Text from invoice items is taken instead. … … 1149 1149 } 1150 1150 1151 function UpdateTo726( $Manager)1151 function UpdateTo726(UpdateManager $Manager): void 1152 1152 { 1153 1153 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); … … 1172 1172 } 1173 1173 1174 function UpdateTo729( $Manager)1174 function UpdateTo729(UpdateManager $Manager): void 1175 1175 { 1176 1176 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `AutoImport` INT NOT NULL ;'); … … 1209 1209 } 1210 1210 1211 function UpdateTo730( $Manager)1211 function UpdateTo730(UpdateManager $Manager): void 1212 1212 { 1213 1213 $Manager->Execute('CREATE TABLE IF NOT EXISTS `SchedulerAction` ( … … 1224 1224 } 1225 1225 1226 function UpdateTo731( $Manager)1226 function UpdateTo731(UpdateManager $Manager): void 1227 1227 { 1228 1228 // NetworkDomain … … 1308 1308 } 1309 1309 1310 function UpdateTo735( $Manager)1310 function UpdateTo735(UpdateManager $Manager): void 1311 1311 { 1312 1312 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkFreeAccess` ( … … 1332 1332 } 1333 1333 1334 function UpdateTo736( $Manager)1334 function UpdateTo736(UpdateManager $Manager): void 1335 1335 { 1336 1336 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkLinkType` ( … … 1345 1345 } 1346 1346 1347 function UpdateTo739( $Manager)1347 function UpdateTo739(UpdateManager $Manager): void 1348 1348 { 1349 1349 $Manager->Execute('ALTER TABLE `NetworkDomain` ADD KEY (`Parent`);'); … … 1364 1364 } 1365 1365 1366 function UpdateTo740( $Manager)1366 function UpdateTo740(UpdateManager $Manager): void 1367 1367 { 1368 1368 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` ( … … 1423 1423 } 1424 1424 1425 function UpdateTo741( $Manager)1425 function UpdateTo741(UpdateManager $Manager): void 1426 1426 { 1427 1427 // Add Direction column … … 1436 1436 } 1437 1437 1438 function UpdateTo742( $Manager)1438 function UpdateTo742(UpdateManager $Manager): void 1439 1439 { 1440 1440 $Manager->Execute('CREATE TABLE IF NOT EXISTS `DocumentLineCode` ( … … 1486 1486 } 1487 1487 1488 function UpdateTo747( $Manager)1488 function UpdateTo747(UpdateManager $Manager): void 1489 1489 { 1490 1490 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;'); … … 1509 1509 } 1510 1510 1511 function UpdateTo748( $Manager)1511 function UpdateTo748(UpdateManager $Manager): void 1512 1512 { 1513 1513 $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`'); … … 1518 1518 } 1519 1519 1520 function UpdateTo752( $Manager)1520 function UpdateTo752(UpdateManager $Manager): void 1521 1521 { 1522 1522 $Manager->Database->query('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) '. … … 1554 1554 } 1555 1555 1556 function UpdateTo755( $Manager)1556 function UpdateTo755(UpdateManager $Manager): void 1557 1557 { 1558 1558 $Manager->Execute("INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`, `Direction`) ". … … 1576 1576 } 1577 1577 1578 function UpdateTo759( $Manager)1578 function UpdateTo759(UpdateManager $Manager): void 1579 1579 { 1580 1580 $Manager->Execute('ALTER TABLE `Scheduler` ADD `Duration` INT NOT NULL AFTER `Period`;'); … … 1582 1582 1583 1583 /* 1584 function UpdateTo761( $Manager)1584 function UpdateTo761(UpdateManager $Manager): void 1585 1585 { 1586 1586 $Manager->Execute('INSERT INTO `MACAddress` (SELECT "" AS `Id`,`MAC` AS `Value` FROM `NetworkSignal` GROUP BY `MAC`)'); … … 1590 1590 */ 1591 1591 1592 function UpdateTo762( $Manager)1592 function UpdateTo762(UpdateManager $Manager): void 1593 1593 { 1594 1594 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `OnlineNotify` INT NOT NULL AFTER `API`;'); 1595 1595 } 1596 1596 1597 function UpdateTo763( $Manager)1597 function UpdateTo763(UpdateManager $Manager): void 1598 1598 { 1599 1599 $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `OnlineNotify` INT NOT NULL AFTER `LastOnline`;'); … … 1601 1601 } 1602 1602 1603 function UpdateTo765( $Manager)1603 function UpdateTo765(UpdateManager $Manager): void 1604 1604 { 1605 1605 $Manager->Execute('CREATE TABLE IF NOT EXISTS `SupportActivity` ( … … 1632 1632 } 1633 1633 1634 function UpdateTo768( $Manager)1634 function UpdateTo768(UpdateManager $Manager): void 1635 1635 { 1636 1636 $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD `Domain` INT NOT NULL AFTER `Comment`;'); … … 1672 1672 } 1673 1673 1674 function UpdateTo770( $Manager)1674 function UpdateTo770(UpdateManager $Manager): void 1675 1675 { 1676 1676 $Manager->Execute("CREATE TABLE IF NOT EXISTS `OS` ( … … 1787 1787 } 1788 1788 1789 function UpdateTo785( $Manager)1789 function UpdateTo785(UpdateManager $Manager): void 1790 1790 { 1791 1791 $Manager->Execute('DROP TABLE `NetworkInterfaceStat`'); 1792 1792 } 1793 1793 1794 function UpdateTo786( $Manager)1794 function UpdateTo786(UpdateManager $Manager): void 1795 1795 { 1796 1796 $Manager->Execute('ALTER TABLE `Member` DROP FOREIGN KEY Member_ibfk_28;'); … … 1803 1803 } 1804 1804 1805 function UpdateTo792( $Manager)1805 function UpdateTo792(UpdateManager $Manager): void 1806 1806 { 1807 1807 // Transform contracts … … 1823 1823 } 1824 1824 1825 function UpdateTo800( $Manager)1825 function UpdateTo800(UpdateManager $Manager): void 1826 1826 { 1827 1827 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockItemHistory` ( … … 1840 1840 } 1841 1841 1842 function UpdateTo802( $Manager)1842 function UpdateTo802(UpdateManager $Manager): void 1843 1843 { 1844 1844 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveGroup` ( … … 1889 1889 } 1890 1890 1891 function UpdateTo803( $Manager)1891 function UpdateTo803(UpdateManager $Manager): void 1892 1892 { 1893 1893 $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItemSerialRel` ( … … 1905 1905 } 1906 1906 1907 function UpdateTo807( $Manager)1907 function UpdateTo807(UpdateManager $Manager): void 1908 1908 { 1909 1909 $Manager->Execute('ALTER TABLE `Product` ADD `StockMinCount` INT NOT NULL AFTER `UnitOfMeasure`;'); 1910 1910 } 1911 1911 1912 function UpdateTo808( $Manager)1912 function UpdateTo808(UpdateManager $Manager): void 1913 1913 { 1914 1914 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceTreasuryCheck` ( … … 1948 1948 } 1949 1949 1950 function UpdateTo814( $Manager)1950 function UpdateTo814(UpdateManager $Manager): void 1951 1951 { 1952 1952 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPort` ( … … 1972 1972 } 1973 1973 1974 function UpdateTo817( $Manager)1974 function UpdateTo817(UpdateManager $Manager): void 1975 1975 { 1976 1976 $Manager->Execute('ALTER TABLE `NetworkConfiguration` ADD `SysName` VARCHAR(255) NOT NULL FIRST;'); … … 1990 1990 } 1991 1991 1992 function UpdateTo818( $Manager)1992 function UpdateTo818(UpdateManager $Manager): void 1993 1993 { 1994 1994 $Manager->Execute('ALTER TABLE `NetworkPort` ADD `Protocol` INT NOT NULL AFTER `Enabled`;'); … … 2007 2007 } 2008 2008 2009 function UpdateTo824( $Manager)2009 function UpdateTo824(UpdateManager $Manager): void 2010 2010 { 2011 2011 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceLatency` ( … … 2021 2021 } 2022 2022 2023 function UpdateTo831( $Manager)2023 function UpdateTo831(UpdateManager $Manager): void 2024 2024 { 2025 2025 $Manager->Execute('ALTER TABLE `NetworkLinkType` '. … … 2033 2033 } 2034 2034 2035 function UpdateTo838( $Manager)2035 function UpdateTo838(UpdateManager $Manager): void 2036 2036 { 2037 2037 $Manager->Execute('ALTER TABLE `News` CHANGE `Date` `Date` DATETIME NULL, CHANGE `TargetDate` `TargetDate` DATETIME NULL;'); 2038 2038 } 2039 2039 2040 function UpdateTo844( $Manager)2040 function UpdateTo844(UpdateManager $Manager): void 2041 2041 { 2042 2042 $Manager->Execute('ALTER TABLE `DocumentLine` ADD `Yearly` BOOLEAN NOT NULL DEFAULT FALSE AFTER `Shortcut`;'); 2043 2043 } 2044 2044 2045 function UpdateTo855( $Manager)2045 function UpdateTo855(UpdateManager $Manager): void 2046 2046 { 2047 2047 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDeviceLog` ( … … 2058 2058 } 2059 2059 2060 function UpdateTo862( $Manager)2060 function UpdateTo862(UpdateManager $Manager): void 2061 2061 { 2062 2062 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Previous` INT NULL AFTER `Duration`'); … … 2065 2065 } 2066 2066 2067 function UpdateTo867( $Manager)2067 function UpdateTo867(UpdateManager $Manager): void 2068 2068 { 2069 2069 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NotifyLog` ( … … 2077 2077 } 2078 2078 2079 function UpdateTo869( $Manager)2079 function UpdateTo869(UpdateManager $Manager): void 2080 2080 { 2081 2081 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSpeedLimit` ( … … 2104 2104 } 2105 2105 2106 function UpdateTo870( $Manager)2106 function UpdateTo870(UpdateManager $Manager): void 2107 2107 { 2108 2108 $Manager->Execute('ALTER TABLE `NetworkSubnet`ADD COLUMN `MaskIPv6` INT(11) NOT NULL AFTER `AddressRangeIPv6`;'); … … 2111 2111 } 2112 2112 2113 function UpdateTo878( $Manager)2113 function UpdateTo878(UpdateManager $Manager): void 2114 2114 { 2115 2115 $Manager->Execute('ALTER TABLE `NewsImport` ADD `Method` VARCHAR(255) NOT NULL AFTER `Category`;'); … … 2118 2118 } 2119 2119 2120 function UpdateTo880( $Manager)2120 function UpdateTo880(UpdateManager $Manager): void 2121 2121 { 2122 2122 $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";'); … … 2125 2125 } 2126 2126 2127 function UpdateTo882( $Manager)2127 function UpdateTo882(UpdateManager $Manager): void 2128 2128 { 2129 2129 $Manager->Execute('ALTER TABLE `FinanceMonthlyOverall` CHANGE `Investment` `Investment` INT(11) NOT NULL DEFAULT "0";'); 2130 2130 } 2131 2131 2132 function UpdateTo885( $Manager)2132 function UpdateTo885(UpdateManager $Manager): void 2133 2133 { 2134 2134 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Value` `Value` FLOAT NOT NULL DEFAULT "0";'); … … 2137 2137 class Updates 2138 2138 { 2139 function Get() 2139 function Get(): array 2140 2140 { 2141 2141 return array( -
trunk/Application/View.php
r874 r887 6 6 { 7 7 var $TimeStart; 8 var$FormatHTML = false;9 var$ShowRuntimeInfo = false;10 var$ClearPage = false;11 var$BasicHTML = false;12 var$ParentClass = '';13 var$ShortTitle;14 var$FullTitle;15 var$Encoding;16 var$Style;8 public bool $FormatHTML = false; 9 public bool $ShowRuntimeInfo = false; 10 public bool $ClearPage = false; 11 public bool $BasicHTML = false; 12 public string $ParentClass = ''; 13 public string $ShortTitle; 14 public string $FullTitle; 15 public string $Encoding; 16 public string $Style; 17 17 18 function __construct( $System)18 function __construct(System $System) 19 19 { 20 20 parent::__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)73 function ShowHeader(Page $Page): string 74 74 { 75 75 $Title = $Page->FullTitle; … … 109 109 } 110 110 111 function ShowFooter() 111 function ShowFooter(): string 112 112 { 113 113 global $ScriptTimeStart, $Revision, $ReleaseTime; … … 128 128 } 129 129 130 function GetOutput( $Page)130 function GetOutput(Page $Page): string 131 131 { 132 132 $Page->OnSystemMessage = array($this->System->BaseView, 'SystemMessage'); … … 141 141 } 142 142 143 function NewPage( $ClassName)143 function NewPage(string $ClassName): Page 144 144 { 145 145 $Page = new $ClassName(); … … 151 151 152 152 // XML formating function 153 function FormatOutput( $s)153 function FormatOutput(string $s): string 154 154 { 155 155 $out = ''; -
trunk/Common/Form/Form.php
r874 r887 22 22 class Form 23 23 { 24 var $FormManager;25 var $Definition;26 var $Values;27 var $ValuesValidate;28 var $ValuesFilter;29 var $OnSubmit;30 var $Database;31 32 function __construct( $FormManager)24 public FormManager $FormManager; 25 public Database $Database; 26 public array $Definition; 27 public array $Values; 28 public array $ValuesValidate; 29 public array $ValuesFilter; 30 public string $OnSubmit; 31 32 function __construct(FormManager $FormManager) 33 33 { 34 34 $this->FormManager = &$FormManager; … … 41 41 } 42 42 43 function LoadDefaults() 43 function LoadDefaults(): void 44 44 { 45 45 foreach ($this->Definition['Items'] as $Index => $Item) … … 58 58 } 59 59 60 function SetClass( $Name)60 function SetClass(string $Name): void 61 61 { 62 62 $this->Definition = &$this->FormManager->Classes[$Name]; … … 64 64 } 65 65 66 function GetValue( $Index, $Event = 'OnView')66 function GetValue(string $Index, string $Event = 'OnView'): string 67 67 { 68 68 $Item = $this->Definition['Items'][$Index]; … … 82 82 } 83 83 84 function ShowViewForm() 84 function ShowViewForm(): string 85 85 { 86 86 $Table = array( … … 116 116 } 117 117 118 function ShowEditForm() 118 function ShowEditForm(): string 119 119 { 120 120 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; … … 125 125 } 126 126 127 function ShowEditBlock( $Context = '')127 function ShowEditBlock(string $Context = ''): string 128 128 { 129 129 $Hidden = ''; … … 182 182 } 183 183 184 function LoadValuesFromDatabase( $Id)184 function LoadValuesFromDatabase(string $Id): void 185 185 { 186 186 foreach ($this->Definition['Items'] as $Index => $Item) … … 232 232 } 233 233 234 function SaveValuesToDatabase( $Id)234 function SaveValuesToDatabase(string $Id) 235 235 { 236 236 $Values = array(); … … 269 269 } 270 270 271 function LoadValuesFromForm() 271 function LoadValuesFromForm(): void 272 272 { 273 273 $this->Values = $this->LoadValuesFromFormBlock(); 274 274 } 275 275 276 function LoadValuesFromFormBlock( $Context = '')276 function LoadValuesFromFormBlock(string $Context = ''): array 277 277 { 278 278 if ($Context != '') $Context = $Context.'-'; … … 319 319 } 320 320 321 function Validate() 321 function Validate(): bool 322 322 { 323 323 $Valid = true; … … 358 358 359 359 360 function MakeLink( $Target, $Title)360 function MakeLink(string $Target, string $Title): string 361 361 { 362 362 return '<a href="'.$Target.'">'.$Title.'</a>'; 363 363 } 364 364 365 function Table( $Table)365 function Table(array $Table): string 366 366 { 367 367 $Result = '<table class="BasicTable">'; … … 389 389 class FormManager 390 390 { 391 var$Classes;392 var$FormTypes;393 var$Database;394 var$Type;395 var$RootURL;396 var$ShowRelation;397 398 function __construct( $Database)391 public array $Classes; 392 public array $FormTypes; 393 public Database $Database; 394 public Type $Type; 395 public string $RootURL; 396 public bool $ShowRelation; 397 398 function __construct(Database $Database) 399 399 { 400 400 $this->Database = &$Database; … … 405 405 } 406 406 407 function RegisterClass( $Name, $Class)407 function RegisterClass(string $Name, array $Class): void 408 408 { 409 409 $this->Classes[$Name] = $Class; 410 410 } 411 411 412 function UnregisterClass( $Name)412 function UnregisterClass(string $Name): void 413 413 { 414 414 unset($this->Classes[$Name]); 415 415 } 416 416 417 function RegisterFormType( $Name, $Class)417 function RegisterFormType(string $Name, array $Class): void 418 418 { 419 419 $this->FormTypes[$Name] = $Class; 420 420 } 421 421 422 function UnregisterFormType( $Name)422 function UnregisterFormType(string $Name): void 423 423 { 424 424 unset($this->FormTypes[$Name]); 425 425 } 426 426 427 function UpdateSQLMeta() 427 function UpdateSQLMeta(): void 428 428 { 429 429 $this->Database->query('DELETE FROM ModelField'); -
trunk/Common/Form/Types/Base.php
r874 r887 3 3 class TypeBase 4 4 { 5 var $FormManager;6 var$Database;7 var$DatabaseCompareOperators = array();8 var$Hidden;5 public FormManager $FormManager; 6 public Database $Database; 7 public array $DatabaseCompareOperators = array(); 8 public bool $Hidden; 9 9 10 function __construct( $FormManager)10 function __construct(FormManager $FormManager) 11 11 { 12 12 $this->FormManager = &$FormManager; … … 15 15 } 16 16 17 function OnView( $Item)17 function OnView(array $Item): ?string 18 18 { 19 19 return ''; 20 20 } 21 21 22 function OnEdit( $Item)22 function OnEdit(array $Item): string 23 23 { 24 24 return ''; 25 25 } 26 26 27 function OnLoad( $Item)27 function OnLoad(array $Item): ?string 28 28 { 29 29 return ''; 30 30 } 31 31 32 function OnLoadDb( $Item)32 function OnLoadDb(array $Item): ?string 33 33 { 34 34 return $Item['Value']; 35 35 } 36 36 37 function OnSaveDb( $Item)37 function OnSaveDb(array $Item): ?string 38 38 { 39 39 return $Item['Value']; 40 40 } 41 41 42 function DatabaseEscape( $Value)42 function DatabaseEscape(string $Value): string 43 43 { 44 44 return addslashes($Value); 45 45 } 46 46 47 function OnFilterName( $Item)47 function OnFilterName(array $Item): string 48 48 { 49 49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) … … 53 53 } 54 54 55 function OnFilterNameQuery( $Item)55 function OnFilterNameQuery(array $Item): string 56 56 { 57 57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) … … 61 61 } 62 62 63 function Validate( $Item)63 function Validate(array $Item): bool 64 64 { 65 65 return true; 66 66 } 67 67 68 function GetValidationFormat() 68 function GetValidationFormat(): string 69 69 { 70 70 return ''; -
trunk/Common/Form/Types/Boolean.php
r874 r887 5 5 class TypeBoolean extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!='); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!='); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 if (array_key_exists($Item['Name'], $_POST)) return 1; -
trunk/Common/Form/Types/Color.php
r874 r887 5 5 class TypeColor extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!='); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!='); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = '<span style="background-color: #'.$Item['Value'].'"> </span>'; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/Date.php
r874 r887 5 5 class TypeDate extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 global $MonthNames;12 13 15 if ($Item['Value'] == null) return ''; 14 16 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); … … 19 21 } 20 22 21 function OnEdit( $Item)23 function OnEdit(array $Item): string 22 24 { 23 25 global $MonthNames; … … 74 76 } 75 77 76 function OnLoad( $Item)78 function OnLoad(array $Item): ?string 77 79 { 78 80 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; … … 80 82 } 81 83 82 function OnLoadDb( $Item)84 function OnLoadDb(array $Item): ?string 83 85 { 84 86 return MysqlDateToTime($Item['Value']); 85 87 } 86 88 87 function OnSaveDb( $Item)89 function OnSaveDb(array $Item): ?string 88 90 { 89 91 if ($Item['Value'] == null) return null; … … 91 93 } 92 94 93 function DatabaseEscape( $Value)95 function DatabaseEscape(string $Value): string 94 96 { 95 97 return '"'.addslashes($Value).'"'; -
trunk/Common/Form/Types/DateTime.php
r871 r887 5 5 class TypeDateTime extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 global $MonthNames;12 13 15 if ($Item['Value'] == 0) return ''; 14 16 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); … … 19 21 } 20 22 21 function OnEdit( $Item)23 function OnEdit(array $Item): string 22 24 { 23 25 global $MonthNames; … … 99 101 } 100 102 101 function OnLoad( $Item)103 function OnLoad(array $Item): ?string 102 104 { 103 105 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; … … 106 108 } 107 109 108 function OnLoadDb( $Item)110 function OnLoadDb(array $Item): ?string 109 111 { 110 112 return MysqlDateTimeToTime($Item['Value']); 111 113 } 112 114 113 function OnSaveDb( $Item)115 function OnSaveDb(array $Item): ?string 114 116 { 115 117 if ($Item['Value'] == null) return null; … … 117 119 } 118 120 119 function DatabaseEscape( $Value)121 function DatabaseEscape(string $Value): string 120 122 { 121 123 return '"'.addslashes($Value).'"'; -
trunk/Common/Form/Types/Enumeration.php
r874 r887 5 5 class TypeEnumeration extends TypeBase 6 6 { 7 function OnView($Item) 7 function OnView($Item): ?string 8 8 { 9 9 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); … … 14 14 } 15 15 16 function OnEdit( $Item)16 function OnEdit(array $Item): string 17 17 { 18 18 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); … … 32 32 } 33 33 34 function OnLoad( $Item)34 function OnLoad(array $Item): ?string 35 35 { 36 36 if ($_POST[$Item['Name']] == '') return NULL; … … 38 38 } 39 39 40 function OnLoadDb( $Item)40 function OnLoadDb(array $Item): ?string 41 41 { 42 42 if ($Item['Value'] == '') return NULL; -
trunk/Common/Form/Types/File.php
r874 r887 3 3 class DbFile 4 4 { 5 var$Id;6 var$FileName;7 var$Size;8 var$Directory;9 var$DirectoryId;10 var$TempName;5 public string $Id; 6 public string $FileName; 7 public int $Size; 8 public string $Directory; 9 public string $DirectoryId; 10 public string $TempName; 11 11 12 function DetectMimeType() 12 function DetectMimeType(): string 13 13 { 14 14 // For proper mime-type detection php-pecl-Fileinfo package should be installed on *nix systems … … 19 19 } 20 20 21 function GetSize($Item) 21 function GetSize($Item): int 22 22 { 23 23 $FileName = $this->GetFullName($Item); … … 27 27 } 28 28 29 function GetFullName() 29 function GetFullName(): string 30 30 { 31 $Path = ''; 31 32 $ParentId = $this->Directory; 32 33 while ($ParentId != null) … … 37 38 $ParentId = $DbRow['Parent']; 38 39 } 39 $Result = $this->UploadFileFolder.'/'.$Path.$ File->Name;40 $Result = $this->UploadFileFolder.'/'.$Path.$this->FileName; 40 41 return $Result; 41 42 } 42 43 43 function GetExt() 44 function GetExt(): string 44 45 { 45 46 return substr($this->Name, 0, strpos($this->Name, '.') - 1); 46 47 } 47 48 48 function Delete() 49 function Delete(): void 49 50 { 50 51 if (file_exists($this->GetFullName())) unlink($this->GetFullName()); 51 52 } 52 53 53 function GetContent() 54 function GetContent(): string 54 55 { 55 56 if ($this->TempName != '') $Content = file_get_contents($this->TempName); … … 61 62 class TypeFile extends TypeBase 62 63 { 63 var$UploadFileFolder;64 var$FileDownloadURL;65 var$DirectoryId;64 public string $UploadFileFolder; 65 public string $FileDownloadURL; 66 public string $DirectoryId; 66 67 67 function __construct( $FormManager)68 function __construct(FormManager $FormManager) 68 69 { 69 70 parent::__construct($FormManager); … … 72 73 } 73 74 74 function OnView( $Item)75 function OnView(array $Item): ?string 75 76 { 76 77 $File = &$Item['Value']; … … 79 80 } 80 81 81 function OnEdit( $Item)82 function OnEdit(array $Item): string 82 83 { 83 84 // Check max value of upload_max_filesize … … 89 90 } 90 91 91 function OnLoad( $Item)92 function OnLoad(array $Item): ?string 92 93 { 93 94 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); … … 106 107 } 107 108 108 function OnLoadDb( $Item)109 function OnLoadDb(array $Item): ?string 109 110 { 110 111 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 111 112 $File = &$Item['Value']; 112 113 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 113 if ($DbResult->num_rows ()> 0)114 if ($DbResult->num_rows > 0) 114 115 { 115 116 $DbRow = $DbResult->fetch_assoc(); … … 121 122 } 122 123 123 function OnSaveDb( $Item)124 function OnSaveDb(array $Item): ?string 124 125 { 125 126 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); … … 128 129 'Size' => $File->GetSize(), 'Directory' => $File->Directory); 129 130 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 130 if ($DbResult->num_rows ()> 0)131 if ($DbResult->num_rows > 0) 131 132 { 132 133 $DbRow = $DbResult->fetch_assoc(); … … 143 144 } 144 145 if (!move_uploaded_file($File->TempName, $FileName)) 145 SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 146 $this->System->SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 147 return ''; 146 148 } 147 149 -
trunk/Common/Form/Types/Float.php
r874 r887 5 5 class TypeFloat extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = $Item['Value']; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/GPS.php
r874 r887 5 5 class TypeGPS extends TypeBase 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 global $Database; 10 11 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 9 $DbResult = $this->Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 12 10 if ($DbResult->num_rows > 0) 13 11 { … … 20 18 } 21 19 22 function OnEdit( $Item)20 function OnEdit(array $Item): string 23 21 { 24 global $Database;25 26 22 if ($Item['Value'] != '') 27 23 { 28 $DbResult = $ Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);24 $DbResult = $this->Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 29 25 if ($DbResult->num_rows > 0) 30 26 { … … 43 39 } 44 40 45 function OnLoad( $Item)41 function OnLoad(array $Item): ?string 46 42 { 47 global $Database;48 49 43 $Latitude = $this->Implode($_POST[$Item['Name'].'-lat-deg'], $_POST[$Item['Name'].'-lat-min'], $_POST[$Item['Name'].'-lat-sec']); 50 44 $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 51 $ Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');52 return $ Database->insert_id;45 $this->Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 46 return $this->Database->insert_id; 53 47 } 54 48 55 function Explode( $Float)49 function Explode(float $Float): array 56 50 { 57 51 $Degrees = intval($Float); … … 64 58 } 65 59 66 function Implode($Degrees, $Minutes, $Seconds) 60 function Implode($Degrees, $Minutes, $Seconds): float 67 61 { 68 62 if ($Degrees < 0) return -(abs($Degrees) + ($Minutes + $Seconds / 60) / 60); -
trunk/Common/Form/Types/Hidden.php
r874 r887 11 11 } 12 12 13 function OnView( $Item)13 function OnView(array $Item): ?string 14 14 { 15 15 $Output = $Item['Value']; … … 17 17 } 18 18 19 function OnEdit( $Item)19 function OnEdit(array $Item): string 20 20 { 21 21 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; … … 23 23 } 24 24 25 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 26 26 { 27 27 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/Hyperlink.php
r874 r887 5 5 class TypeHyperlink extends TypeBase 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 9 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; … … 11 11 } 12 12 13 function OnEdit( $Item)13 function OnEdit(array $Item): string 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 17 17 } 18 18 19 function OnLoad( $Item)19 function OnLoad(array $Item): ?string 20 20 { 21 21 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/IPv4Address.php
r874 r887 5 5 class TypeIPv4Address extends TypeBase 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 9 $Output = $Item['Value']; … … 11 11 } 12 12 13 function OnEdit( $Item)13 function OnEdit(array $Item): string 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 17 17 } 18 18 19 function OnLoad( $Item)19 function OnLoad(array $Item): ?string 20 20 { 21 21 return $_POST[$Item['Name']]; 22 22 } 23 23 24 function Validate( $Item)24 function Validate(array $Item): bool 25 25 { 26 26 if ($Item['Null'] and ($Item['Value'] == '')) return true; … … 28 28 } 29 29 30 function GetValidationFormat() 30 function GetValidationFormat(): string 31 31 { 32 32 return 'x.x.x.x kde x je hodnota 0..255'; -
trunk/Common/Form/Types/IPv6Address.php
r874 r887 5 5 class TypeIPv6Address extends TypeBase 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 9 $Output = $Item['Value']; … … 11 11 } 12 12 13 function OnEdit( $Item)13 function OnEdit(array $Item): string 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 17 17 } 18 18 19 function OnLoad( $Item)19 function OnLoad(array $Item): ?string 20 20 { 21 21 return $_POST[$Item['Name']]; 22 22 } 23 23 24 function Validate( $Item)24 function Validate(array $Item): bool 25 25 { 26 26 if ($Item['Null'] and ($Item['Value'] == '')) return true; … … 28 28 } 29 29 30 function GetValidationFormat() 30 function GetValidationFormat(): string 31 31 { 32 32 return 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f'; -
trunk/Common/Form/Types/Image.php
r874 r887 3 3 class TypeImage extends TypeString 4 4 { 5 function OnView( $Item)5 function OnView(array $Item): ?string 6 6 { 7 7 global $System; -
trunk/Common/Form/Types/Integer.php
r874 r887 5 5 class TypeInteger extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = $Item['Value']; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 return $_POST[$Item['Name']]; 24 28 } 25 29 26 function Validate( $Item)30 function Validate(array $Item): bool 27 31 { 28 32 if ($Item['Null'] and ($Item['Value'] == '')) return true; … … 30 34 } 31 35 32 function GetValidationFormat() 36 function GetValidationFormat(): string 33 37 { 34 38 return 'číselná hodnota'; -
trunk/Common/Form/Types/MacAddress.php
r874 r887 5 5 class TypeMacAddress extends TypeString 6 6 { 7 var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = $Item['Value']; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); … … 25 29 } 26 30 27 function DatabaseEscape( $Value)31 function DatabaseEscape(string $Value): string 28 32 { 29 33 return '"'.addslashes($Value).'"'; 30 34 } 31 35 32 function Validate( $Item)36 function Validate(array $Item): bool 33 37 { 34 38 if ($Item['Null'] and ($Item['Value'] == '')) return true; … … 36 40 } 37 41 38 function GetValidationFormat() 42 function GetValidationFormat(): string 39 43 { 40 44 return 'XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F'; -
trunk/Common/Form/Types/OneToMany.php
r874 r887 5 5 class TypeOneToMany extends TypeBase 6 6 { 7 var$EditActions;7 public array $EditActions; 8 8 9 function OnView( $Item)9 function OnView(array $Item): ?string 10 10 { 11 11 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; … … 18 18 } 19 19 20 function OnEdit( $Item)20 function OnEdit(array $Item): string 21 21 { 22 22 $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">'; … … 54 54 } 55 55 56 function OnLoad( $Item)56 function OnLoad(array $Item): ?string 57 57 { 58 58 if ($_POST[$Item['Name']] == '') return NULL; … … 60 60 } 61 61 62 function OnLoadDb( $Item)62 function OnLoadDb(array $Item): ?string 63 63 { 64 64 if ($Item['Value'] == '') return NULL; … … 66 66 } 67 67 68 function OnFilterName( $Item)68 function OnFilterName(array $Item): string 69 69 { 70 70 return '`'.$Item['Name'].'_Filter`'; 71 71 } 72 72 73 function OnFilterNameQuery( $Item)73 function OnFilterNameQuery(array $Item): string 74 74 { 75 75 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; -
trunk/Common/Form/Types/OneToMany2.php
r874 r887 5 5 class TypeOneToMany2 extends TypeBase 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 9 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; … … 11 11 } 12 12 13 function OnEdit( $Item)13 function OnEdit(array $Item): string 14 14 { 15 15 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; … … 17 17 } 18 18 19 function OnLoad( $Item)19 function OnLoad(array $Item): ?string 20 20 { 21 21 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/Password.php
r874 r887 7 7 class TypePassword extends TypeBase 8 8 { 9 function OnView( $Item)9 function OnView(array $Item): ?string 10 10 { 11 11 $Output = ''; … … 15 15 } 16 16 17 function OnEdit( $Item)17 function OnEdit(array $Item): string 18 18 { 19 19 $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>'; … … 21 21 } 22 22 23 function OnLoad( $Item)23 function OnLoad(array $Item): ?string 24 24 { 25 25 global $Database; … … 42 42 } 43 43 44 function OnSaveDb( $Item)44 function OnSaveDb(array $Item): string 45 45 { 46 46 if ($Item['Value'] == '') return ''; … … 51 51 } 52 52 53 function OnLoadDb( $Item)53 function OnLoadDb(array $Item): ?string 54 54 { 55 55 return ''; -
trunk/Common/Form/Types/RandomHash.php
r874 r887 11 11 } 12 12 13 function OnView( $Item)13 function OnView(array $Item): ?string 14 14 { 15 15 $Output = $Item['Value']; … … 17 17 } 18 18 19 function OnEdit( $Item)19 function OnEdit(array $Item): string 20 20 { 21 21 if ($Item['Value'] == '') … … 29 29 } 30 30 31 function OnLoad( $Item)31 function OnLoad(array $Item): ?string 32 32 { 33 33 return $_POST[$Item['Name']]; -
trunk/Common/Form/Types/String.php
r874 r887 5 5 class TypeString extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = $Item['Value']; … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); … … 25 29 } 26 30 27 function DatabaseEscape( $Value)31 function DatabaseEscape(string $Value): string 28 32 { 29 33 return '"'.addslashes($Value).'"'; -
trunk/Common/Form/Types/Text.php
r874 r887 5 5 class TypeText extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!='); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 $Output = str_replace("\n", '<br/>', strip_tags($Item['Value'])); … … 13 17 } 14 18 15 function OnEdit( $Item)19 function OnEdit(array $Item): string 16 20 { 17 21 $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>'; … … 19 23 } 20 24 21 function OnLoad( $Item)25 function OnLoad(array $Item): ?string 22 26 { 23 27 return $_POST[$Item['Name']]; 24 28 } 25 29 26 function DatabaseEscape( $Value)30 function DatabaseEscape(string $Value): string 27 31 { 28 32 return '"'.addslashes($Value).'"'; -
trunk/Common/Form/Types/Time.php
r874 r887 5 5 class TypeTime extends TypeBase 6 6 { 7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 7 function __construct(FormManager $FormManager) 8 { 9 parent::__construct($FormManager); 10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>'); 11 } 8 12 9 function OnView( $Item)13 function OnView(array $Item): ?string 10 14 { 11 15 if ($Item['Value'] == 0) return ''; … … 17 21 } 18 22 19 function OnEdit( $Item)23 function OnEdit(array $Item): string 20 24 { 21 25 if (($Item['Value'] == null) or (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')))) … … 24 28 $IsNull = true; 25 29 } else $IsNull = false; 26 $ Parts = getdate($Item['Value']);30 $TimeParts = getdate($Item['Value']); 27 31 28 32 $Output = ''; … … 70 74 } 71 75 72 function OnLoad( $Item)76 function OnLoad(array $Item): ?string 73 77 { 74 78 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; … … 76 80 } 77 81 78 function OnLoadDb( $Item)82 function OnLoadDb(array $Item): ?string 79 83 { 80 84 return MysqlTimeToTime($Item['Value']); 81 85 } 82 86 83 function OnSaveDb( $Item)87 function OnSaveDb(array $Item): ?string 84 88 { 85 89 if ($Item['Value'] == null) return null; … … 87 91 } 88 92 89 function DatabaseEscape( $Value)93 function DatabaseEscape(string $Value): string 90 94 { 91 95 return '"'.addslashes($Value).'"'; -
trunk/Common/Form/Types/TimeDiff.php
r874 r887 5 5 class TypeTimeDiff extends TypeInteger 6 6 { 7 function OnView( $Item)7 function OnView(array $Item): ?string 8 8 { 9 9 if ($Item['Value'] == null) $Output = ''; -
trunk/Common/Form/Types/Type.php
r874 r887 28 28 class Type 29 29 { 30 var $FormManager;31 var$TypeDefinitionList;32 var$Values;30 public FormManager $FormManager; 31 public array $TypeDefinitionList; 32 public array $Values; 33 33 34 function __construct( $FormManager)34 function __construct(FormManager $FormManager) 35 35 { 36 36 $this->FormManager = &$FormManager; … … 65 65 } 66 66 67 function ExecuteTypeEvent( $TypeName, $Event, $Parameters = array())67 function ExecuteTypeEvent(string $TypeName, string $Event, array $Parameters = array()): ?string 68 68 { 69 69 if (array_key_exists($TypeName, $this->TypeDefinitionList)) … … 77 77 } 78 78 79 function IsHidden( $TypeName)79 function IsHidden(string $TypeName): bool 80 80 { 81 81 if (array_key_exists($TypeName, $this->TypeDefinitionList)) … … 88 88 } 89 89 90 function RegisterType( $Name, $ParentType, $Parameters)90 function RegisterType(string $Name, string $ParentType, array $Parameters): void 91 91 { 92 92 if ($ParentType != '') … … 103 103 } 104 104 105 function UnregisterType( $Name)105 function UnregisterType(string $Name): void 106 106 { 107 107 unset($this->TypeDefinitionList[$Name]); … … 109 109 } 110 110 111 function GetTypeDefinition( $TypeName)111 function GetTypeDefinition(string $TypeName): array 112 112 { 113 113 return $this->TypeDefinitionList[$TypeName]; -
trunk/Common/Global.php
r874 r887 20 20 $YesNo = array(false => 'Ne', true => 'Ano'); 21 21 22 function HumanSize( $Value)22 function HumanSize(int $Value): string 23 23 { 24 24 global $UnitNames; … … 33 33 } 34 34 35 function GetMicrotime() 35 function GetMicrotime(): float 36 36 { 37 37 list($Usec, $Sec) = explode(' ', microtime()); … … 39 39 } 40 40 41 function ShowArray( $Pole)41 function ShowArray(array $Array): void 42 42 { 43 43 echo('<pre style="font-size: 8pt;">'); 44 print_r($ Pole);44 print_r($Array); 45 45 echo('</pre>'); 46 46 } 47 47 48 function HumanDate( $Time)48 function HumanDate(?string $Time): string 49 49 { 50 50 if ($Time != '') … … 58 58 59 59 // Show page listing numbers 60 function PagesList( $URL, $Page, $TotalCount, $CountPerPage)60 function PagesList(string $URL, int $Page, int $TotalCount, int $CountPerPage): string 61 61 { 62 62 $Count = ceil($TotalCount / $CountPerPage); … … 94 94 } 95 95 96 function ExtractTime($Time) 96 function ExtractTime($Time): array 97 97 { 98 98 return array( … … 106 106 } 107 107 108 function GetQueryStringArray( $QueryString)108 function GetQueryStringArray(string $QueryString): array 109 109 { 110 110 $Result = array(); … … 122 122 } 123 123 124 function SetQueryStringArray( $QueryStringArray)124 function SetQueryStringArray(array $QueryStringArray): string 125 125 { 126 126 $Parts = array(); … … 132 132 } 133 133 134 function GetPageList( $ObjectName, $TotalCount)134 function GetPageList(string $ObjectName, int $TotalCount): array 135 135 { 136 136 global $System; … … 209 209 $OrderArrowImage = array('sort_asc.png', 'sort_desc.png'); 210 210 211 function GetOrderTableHeader( $ObjectName, $Columns, $DefaultColumn, $DefaultOrder = 0)211 function GetOrderTableHeader(string $ObjectName, array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array 212 212 { 213 213 global $OrderDirSQL, $OrderArrowImage, $Config, $System; … … 262 262 } 263 263 264 function GetRemoteAddress() 264 function GetRemoteAddress(): string 265 265 { 266 266 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; … … 269 269 } 270 270 271 function IsInternetAddr() 271 function IsInternetAddr(): bool 272 272 { 273 273 global $Config; … … 286 286 } 287 287 288 function GetMemberByIP($IP) 289 { 290 global $Database; 291 288 function GetMemberByIP(Database $Database, string $IP): string 289 { 292 290 $DbResult = $Database->query('SELECT `Id` FROM `Member` WHERE '. 293 291 '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '. … … 300 298 } 301 299 302 function CommandExist( $Command)300 function CommandExist(string $Command): bool 303 301 { 304 302 $Result = shell_exec('which '.$Command); … … 306 304 } 307 305 308 function RemoveDiacritic( $Text)306 function RemoveDiacritic(string $Text): string 309 307 { 310 308 return str_replace( … … 316 314 } 317 315 318 function RouterOSIdent( $Name)316 function RouterOSIdent(string $Name): string 319 317 { 320 318 return strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-', … … 328 326 } 329 327 330 function NotBlank( $Text)328 function NotBlank(string $Text): string 331 329 { 332 330 if ($Text == '') return ' '; … … 334 332 } 335 333 336 function strip_cdata( $string)334 function strip_cdata(string $string): string 337 335 { 338 336 preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); … … 351 349 } 352 350 353 function ProcessURL() 351 function ProcessURL(): array 354 352 { 355 353 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) … … 365 363 } 366 364 367 function RepeatFunction( $Period, $Callback)365 function RepeatFunction(int $Period, callable $Callback): void 368 366 { 369 367 while (1) … … 384 382 return call_user_func_array('pack', array_merge(array($v), (array)$a)); 385 383 } 386 -
trunk/Common/VCL/Database.php
r874 r887 19 19 } 20 20 21 function Show() 21 function Show(): string 22 22 { 23 23 // Get total item count in database -
trunk/Common/VCL/General.php
r874 r887 1 1 <?php 2 2 3 4 //print_r($_SESSION); 5 6 function ReadSessionVar($Name, $Persistent = true) 3 function ReadSessionVar(string $Name, bool $Persistent = true): string 7 4 { 8 5 //echo($Name.','); … … 20 17 class Element 21 18 { 22 var$Id;23 var$Enabled;24 var$Visible;19 public string $Id; 20 public bool $Enabled; 21 public bool $Visible; 25 22 26 23 function __construct() … … 30 27 } 31 28 32 function Show() 29 function Show(): string 33 30 { 34 31 $Output = ''; … … 37 34 } 38 35 39 function Prepare() 36 function Prepare(): void 40 37 { 41 38 } … … 44 41 class Layout extends Element 45 42 { 46 var$Items;47 48 function Show() 43 public array $Items; 44 45 function Show(): string 49 46 { 50 47 if ($this->Visible) … … 57 54 } 58 55 59 function Prepare() 56 function Prepare(): void 60 57 { 61 58 foreach ($this->Items as $Item) … … 66 63 class Button extends Element 67 64 { 68 var$Caption;69 70 function Show() 65 public string $Caption; 66 67 function Show(): string 71 68 { 72 69 if ($this->Visible) … … 79 76 class Edit extends Element 80 77 { 81 var$Text;82 83 function Show() 78 public string $Text; 79 80 function Show(): string 84 81 { 85 82 return parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>'; 86 83 } 87 84 88 function Prepare() 85 function Prepare(): void 89 86 { 90 87 $this->Text = ReadSessionVar($this->Id.'_Text'); … … 94 91 class PageSelect extends Element 95 92 { 96 var$Count;97 var$Position;98 var$PageSize;93 public int $Count; 94 public int $Position; 95 public int $PageSize; 99 96 100 97 function __construct() … … 106 103 } 107 104 108 function Show() 105 function Show(): string 109 106 { 110 107 if (array_key_exists($this->Id.'_Page', $_GET)) … … 122 119 } 123 120 124 function Prepare() 121 function Prepare(): void 125 122 { 126 123 $this->Position = ReadSessionVar($this->Id.'_Page'); … … 130 127 class ListViewColumn extends Element 131 128 { 132 var$Name;133 134 function Show() 129 public string $Name; 130 131 function Show(): string 135 132 { 136 133 return $this->Name; … … 140 137 class ListView extends Element 141 138 { 142 var$Columns;143 var$Rows;144 var$OnColumnClick;145 var$OnColumnDraw;139 public array $Columns; 140 public array $Rows; 141 public $OnColumnClick; 142 public $OnColumnDraw; 146 143 147 144 function __construct() … … 152 149 } 153 150 154 function Show() 151 function Show(): string 155 152 { 156 153 $Output = '<table class="WideTable" style="font-size: small;><tr>'; … … 176 173 class PageListView extends ListView 177 174 { 178 var$PageSelect;179 var$SortOrder;180 var$SortColumn;181 var$OrderArrowImage;175 public PageSelect $PageSelect; 176 public int $SortOrder; 177 public string $SortColumn; 178 public array $OrderArrowImage; 182 179 183 180 function __construct() … … 190 187 } 191 188 192 function ColumnClick( $Column)189 function ColumnClick(ListViewColumn $Column): string 193 190 { 194 191 return '?'.$this->Id.'_SortColumn='.$Column->Id.'&'.$this->Id.'_SortOrder='.(1 - $this->SortOrder); 195 192 } 196 193 197 function ColumnDraw( $Column)194 function ColumnDraw(ListViewColumn $Column): string 198 195 { 199 196 global $System; … … 211 208 } 212 209 213 function Show() 210 function Show(): string 214 211 { 215 212 $this->PageSelect->Count = count($this->Rows); … … 222 219 } 223 220 224 function Prepare() 221 function Prepare(): void 225 222 { 226 223 $this->PageSelect->Id = $this->Id.'PageSelect'; … … 233 230 class TableLayout extends Element 234 231 { 235 var$Rows;236 var$Span;237 238 function Show() 239 { 240 $Output .= '<table>';232 public array $Rows; 233 public string $Span; 234 235 function Show(): string 236 { 237 $Output = '<table>'; 241 238 foreach ($this->Rows as $RowNum => $Row) 242 239 { … … 254 251 } 255 252 256 function Prepare() 253 function Prepare(): void 257 254 { 258 255 foreach ($this->Rows as $RowNum => $Row) … … 268 265 class Label extends Element 269 266 { 270 var$Caption;271 var$OnExecute;272 273 function Show() 267 public string $Caption; 268 public $OnExecute; 269 270 function Show(): string 274 271 { 275 272 $Output = $this->Caption; … … 282 279 } 283 280 284 function Prepare() 281 function Prepare(): void 285 282 { 286 283 $Object = ReadSessionVar('O', false); … … 293 290 class Page2 294 291 { 295 var$Items;296 297 function Show() 292 public array $Items; 293 294 function Show(): string 298 295 { 299 296 $Output = '<!DOCTYPE html><html><head></head><body>'; … … 304 301 } 305 302 306 function Prepare() 303 function Prepare(): void 307 304 { 308 305 foreach ($this->Items as $Item) -
trunk/Install/deb/debian/conf/Config.php
r877 r887 3 3 $IsDeveloper = array_key_exists('REMOTE_ADDR', $_SERVER) and in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 4 4 5 $Config['SystemPassword'] = sha1(rand om(23232));5 $Config['SystemPassword'] = sha1(rand(23232)); 6 6 $Config['Database']['Host'] = 'localhost'; 7 7 $Config['Database']['User'] = 'isp-central'; -
trunk/Install/deb/debian/conf/Modules.php
r842 r887 1 <?php 1 <?php 2 2 3 $ConfigModules = array 3 $ConfigModules = array( 4 4 ); -
trunk/Modules/API/API.php
r874 r887 17 17 class ModuleAPI extends AppModule 18 18 { 19 function __construct( $System)19 function __construct(System $System) 20 20 { 21 21 parent::__construct($System); … … 28 28 } 29 29 30 function DoStart() 30 function DoStart(): void 31 31 { 32 $this->System->RegisterPage( array('api'), 'PageAPI');32 $this->System->RegisterPage(['api'], 'PageAPI'); 33 33 } 34 34 } … … 36 36 class PageAPI extends Page 37 37 { 38 var$DataFormat;39 40 function __construct( $System)38 public string $DataFormat; 39 40 function __construct(System $System) 41 41 { 42 42 parent::__construct($System); 43 43 $this->ClearPage = true; 44 $this->DataFormat = ''; 44 45 } 45 46 46 function Show() 47 function Show(): string 47 48 { 48 49 // p - token … … 50 51 $Token = $_GET['p']; 51 52 $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"'); 52 if ($DbResult->num_rows > 0) 53 if ($DbResult->num_rows > 0) 53 54 { 54 55 $DbRow = $DbResult->fetch_assoc(); … … 75 76 } 76 77 77 function ShowList( $Table, $ItemId)78 function ShowList(string $Table, $ItemId): string 78 79 { 79 80 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes))) … … 84 85 $SourceTable = '('.$FormClass['SQL'].') AS `TX`'; 85 86 else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`'; 86 87 87 88 $Filter = ''; 88 89 if ($ItemId != 0) … … 112 113 $dom->appendChild($root); 113 114 114 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 116 { 116 117 foreach ($array as $key => $value) 117 118 { 118 if ( is_array($value) ) 119 if ( is_array($value) ) 119 120 { 120 121 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric'); -
trunk/Modules/Chat/Chat.php
r874 r887 3 3 class PageChatHistory extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 17 17 } 18 18 19 function Show() 19 function Show(): string 20 20 { 21 21 global $MonthNames; 22 22 23 if (! $this->System->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění';23 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění'; 24 24 25 25 if (array_key_exists('date', $_GET)) $Date = $_GET['date']; … … 87 87 class ModuleChat extends AppModule 88 88 { 89 function __construct( $System)89 function __construct(System $System) 90 90 { 91 91 parent::__construct($System); … … 98 98 } 99 99 100 function DoStart() 100 function DoStart(): void 101 101 { 102 102 $this->System->Pages['chat'] = 'PageChatHistory'; -
trunk/Modules/Chat/irc_bot.php
r873 r887 39 39 } 40 40 41 function Run() 41 function Run(): void 42 42 { 43 43 global $Database; … … 195 195 echo("-Connection lost.\n"); 196 196 } 197 198 197 } 199 198 -
trunk/Modules/Customer/Customer.php
r874 r887 3 3 class ModuleCustomer extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Member', array( … … 187 187 )); 188 188 189 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Customer',190 array( 'ModuleCustomer', 'ShowDashboardItem'));189 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Customer', 190 array($this, 'ShowDashboardItem')); 191 191 } 192 192 193 function ShowDashboardItem() 193 function ShowDashboardItem(): string 194 194 { 195 195 $DbResult = $this->Database->select('Member', 'COUNT(*)', '1'); -
trunk/Modules/EmailQueue/EmailQueue.php
r882 r887 3 3 class PageEmailQueueProcess extends Page 4 4 { 5 var $FullTitle = 'Odeslání pošty z fronty'; 6 var $ShortTitle = 'Fronta pošty'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Odeslání pošty z fronty'; 9 $this->ShortTitle = 'Fronta pošty'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();15 $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process(); 12 16 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output; 13 17 return $Output; … … 17 21 class ModuleEmailQueue extends AppModule 18 22 { 19 function __construct( $System)23 function __construct(System $System) 20 24 { 21 25 parent::__construct($System); … … 28 32 } 29 33 30 function DoInstall() 34 function DoInstall(): void 31 35 { 32 36 } 33 37 34 function DoUninstall() 38 function DoUninstall(): void 35 39 { 36 40 } 37 41 38 function DoStart() 42 function DoStart(): void 39 43 { 40 $this->System->RegisterPage( 'fronta-posty', 'PageEmailQueueProcess');44 $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess'); 41 45 $this->System->FormManager->RegisterClass('Email', array( 42 46 'Title' => 'Nový email', … … 70 74 } 71 75 72 function DoStop() 76 function DoStop(): void 73 77 { 74 78 } … … 83 87 } 84 88 85 function Process() 89 function Process(): string 86 90 { 87 91 $Output = ''; … … 103 107 $Mail->Send(); 104 108 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 105 $this->System->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);109 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('System', 'SendEmail', $DbRow['Id']); 106 110 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 107 111 } 108 112 return $Output; 109 113 } 114 115 static function Cast(AppModule $AppModule): ModuleEmailQueue 116 { 117 if ($AppModule instanceof ModuleEmailQueue) 118 { 119 return $AppModule; 120 } 121 throw new Exception('Expected ModuleEmailQueue type but '.gettype($AppModule)); 122 } 110 123 } 111 -
trunk/Modules/Employee/Employee.php
r738 r887 3 3 class ModuleEmployee extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Employee', array( -
trunk/Modules/Error/Error.php
r873 r887 3 3 class ModuleError extends AppModule 4 4 { 5 var $Encoding; 6 var $ShowError; 7 var $UserErrors; 8 var $ErrorHandler; 5 public string $Encoding; 6 public ErrorHandler $ErrorHandler; 9 7 10 function __construct( $System)8 function __construct(System $System) 11 9 { 12 10 parent::__construct($System); … … 19 17 20 18 $this->ErrorHandler = new ErrorHandler(); 19 $this->Encoding = 'utf-8'; 21 20 } 22 21 23 function DoInstall() 22 function DoInstall(): void 24 23 { 25 24 } 26 25 27 function DoUnInstall() 26 function DoUnInstall(): void 28 27 { 29 28 } 30 29 31 function DoStart() 30 function DoStart(): void 32 31 { 33 32 $this->ErrorHandler->ShowError = $this->System->Config['Web']['ShowPHPError']; … … 36 35 } 37 36 38 function DoStop() 37 function DoStop(): void 39 38 { 40 39 $this->ErrorHandler->Stop(); 41 40 } 42 41 43 function DoOnError( $Error)42 function DoOnError(string $Error): void 44 43 { 45 $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);44 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Error', 'Log', $Error); 46 45 47 46 //if ($Config['Web']['ErrorLogFile'] != '') -
trunk/Modules/File/File.php
r885 r887 5 5 class File extends Model 6 6 { 7 var$FilesDir;8 9 function __construct( $System)7 public string $FilesDir; 8 9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 13 13 } 14 14 15 function Delete($Id) 15 function Delete($Id): void 16 16 { 17 17 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); … … 24 24 } 25 25 26 function CreateFromUpload( $Name)26 function CreateFromUpload(string $Name): string 27 27 { 28 28 // Submited form with file input have to be enctype="multipart/form-data" … … 41 41 } 42 42 43 function DetectMimeType( $FileName)43 function DetectMimeType(string $FileName): string 44 44 { 45 45 $MimeTypes = GetMimeTypes(); … … 49 49 } 50 50 51 function Download( $Id)51 function Download(string $Id): void 52 52 { 53 53 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); … … 67 67 } 68 68 69 function GetDir( $Id)69 function GetDir(string $Id): string 70 70 { 71 71 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); … … 77 77 } 78 78 79 function GetFullPath( $Id)79 function GetFullPath(string $Id): string 80 80 { 81 81 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); … … 93 93 class PageFile extends Page 94 94 { 95 function Show() 95 function Show(): string 96 96 { 97 97 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; … … 99 99 else return $this->SystemMessage('Chyba', 'Nezadáno id souboru'); 100 100 $this->ClearPage = true; 101 $Output = $this->System->Modules['File']->Download($Id);101 $Output = ModuleFile::Cast($this->System->GetModule('File'))->File->Download($Id); 102 102 return $Output; 103 103 } … … 106 106 class PageFileCheck extends Page 107 107 { 108 function __construct( $System)108 function __construct(System $System) 109 109 { 110 110 parent::__construct($System); … … 114 114 } 115 115 116 function GetAbsolutePath( $Path)116 function GetAbsolutePath(string $Path): string 117 117 { 118 118 $Path = trim($Path); … … 137 137 } 138 138 139 function Show() 139 function Show(): string 140 140 { 141 141 $Output = '<strong>Missing files:</strong><br>'; 142 if (! $this->System->User->CheckPermission('File', 'Check'))142 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('File', 'Check')) 143 143 return 'Nemáte oprávnění'; 144 144 $DbResult = $this->Database->select('File', 'Id'); … … 146 146 { 147 147 $Id = $DbRow['Id']; 148 $FileName = $this->GetAbsolutePath( $this->System->Modules['File']->GetFullPath($Id));148 $FileName = $this->GetAbsolutePath(ModuleFile::Cast($this->System->GetModule('File'))->File->GetFullPath($Id)); 149 149 if (!file_exists($FileName)) 150 150 $Output .= '<a href="'.$this->System->Link('/is/?a=view&t=File&i='.$Id).'">'.$FileName.'</a><br>'; … … 156 156 class ModuleFile extends AppModule 157 157 { 158 function __construct($System) 158 public File $File; 159 160 function __construct(System $System) 159 161 { 160 162 parent::__construct($System); … … 164 166 $this->License = 'GNU/GPLv3'; 165 167 $this->Description = 'Base module for file management'; 166 $this->Dependencies = array(); 167 } 168 169 function DoInstall() 170 { 171 } 172 173 function DoUninstall() 174 { 175 } 176 177 function DoStart() 168 $this->Dependencies = array('User'); 169 170 $this->File = new File($this->System); 171 } 172 173 function DoInstall(): void 174 { 175 } 176 177 function DoUninstall(): void 178 { 179 } 180 181 function DoStart(): void 178 182 { 179 183 global $Config; 180 184 181 $this->System->RegisterPage('file', 'PageFile'); 182 $this->System->RegisterPage('file-check', 'PageFileCheck'); 183 $this->System->AddModule(new File($this->System)); 184 $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; 185 $this->System->RegisterPage(['file'], 'PageFile'); 186 $this->System->RegisterPage(['file-check'], 'PageFileCheck'); 187 $this->File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; 185 188 $this->System->FormManager->RegisterClass('File', array( 186 189 'Title' => 'Soubor', … … 271 274 } 272 275 273 function DoStop() 274 { 275 } 276 } 276 static function Cast(AppModule $AppModule): ModuleFile 277 { 278 if ($AppModule instanceof ModuleFile) 279 { 280 return $AppModule; 281 } 282 throw new Exception('Expected ModuleFile type but got '.gettype($AppModule)); 283 } 284 } -
trunk/Modules/File/MimeTypes.php
r885 r887 1 1 <?php 2 2 3 function GetMimeTypes() 3 function GetMimeTypes(): array 4 4 { 5 5 return array( -
trunk/Modules/Finance/Bill.php
r874 r887 3 3 class Bill extends Model 4 4 { 5 var $SpecificSymbol = 1; // počítačová sít6 var $Checked;5 public int $SpecificSymbol = 1; // computer network number 6 public bool $Checked = false; 7 7 8 8 function GenerateHTML() … … 11 11 } 12 12 13 function SaveToFile($FileName) 14 { 15 global $Database; 16 13 function SaveToFile(string $FileName) 14 { 17 15 $PdfData = $this->HtmlToPdf($this->GenerateHTML()); 18 16 file_put_contents($FileName, $PdfData); 19 17 } 20 18 21 function HtmlToPdf( $HtmlCode)19 function HtmlToPdf(string $HtmlCode): string 22 20 { 23 21 $Encoding = new Encoding(); … … 35 33 class BillInvoice extends Bill 36 34 { 37 var$InvoiceId;38 39 function ShowSubjectInfo( $Subject)35 public string $InvoiceId; 36 37 function ShowSubjectInfo(array $Subject): string 40 38 { 41 39 $BooleanText = array('Ne', 'Ano'); … … 50 48 } 51 49 52 function GenerateHTML() 53 { 54 $Finance = & $this->System->Modules['Finance'];50 function GenerateHTML(): string 51 { 52 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 55 53 $Finance->LoadMonthParameters(0); 56 54 … … 152 150 class BillOperation extends Bill 153 151 { 154 var$OperationId;155 156 function GenerateHTML() 152 public string $OperationId; 153 154 function GenerateHTML(): string 157 155 { 158 156 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. -
trunk/Modules/Finance/Finance.php
r877 r887 41 41 var $Rounding; 42 42 43 function LoadMonthParameters( $Period = 1) // 0 - now, 1 - next month43 function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); … … 78 78 } 79 79 80 function W2Kc($Spotreba) 80 function W2Kc($Spotreba): string 81 81 { 82 82 return round($Spotreba * 0.72 * $this->kWh); … … 88 88 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 89 89 $this->Database->insert('FinanceYear', array('Year' => $Year, 90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));91 $YearId = $this->Database->insert_id;90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0)); 91 $YearId = $this->Database->insert_id; 92 92 93 93 // Create DocumentLineSequence from previous … … 95 95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));99 }100 } 101 102 function GetFinanceYear( $Year)97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, 98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id'])); 99 } 100 } 101 102 function GetFinanceYear(int $Year) 103 103 { 104 104 if ($Year == 0) … … 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 { 112 $this->CreateFinanceYear($Year); 109 if ($DbResult->num_rows == 0) 110 { 111 if ($Year == date('Y')) 112 { 113 $this->CreateFinanceYear($Year); 113 114 $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 114 } else throw new Exception('Rok '.$Year.' nenalezen');115 }115 } else throw new Exception('Rok '.$Year.' nenalezen'); 116 } 116 117 $FinanceYear = $DbResult->fetch_assoc(); 117 118 if ($FinanceYear['Closed'] == 1) … … 120 121 } 121 122 122 function GetNextDocumentLineNumber( $Id,$FinanceYear = 0)123 { 124 $FinanceYear = $this->GetFinanceYear($FinanceYear);123 function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0) 124 { 125 $FinanceYear = $this->GetFinanceYear($FinanceYear); 125 126 126 127 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id); … … 141 142 } 142 143 143 function GetNextDocumentLineNumberId( $Id, $FinanceYear = 0)144 function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int 144 145 { 145 146 $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear); … … 148 149 } 149 150 150 function GetFinanceGroupById( $Id, $Table)151 function GetFinanceGroupById(string $Id, string $Table): ?array 151 152 { 152 153 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); … … 154 155 $Group = $DbResult->fetch_assoc(); 155 156 return $Group; 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 } 158 159 function RecalculateMemberPayment() 157 } 158 echo('Finance group id '.$Id.' not found in table '.$Table); 159 return null; 160 } 161 162 function RecalculateMemberPayment(): string 160 163 { 161 164 $Output = 'Aktualizuji finance členů...<br />'; … … 199 202 $Consumption = 0; 200 203 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 201 202 203 204 'MonthlyInternet' => $MonthlyInet, 205 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 206 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); 204 207 } 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');208 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment'); 206 209 return $Output; 207 210 } 208 211 209 function GetVATByType( $TypeId)212 function GetVATByType(string $TypeId): string 210 213 { 211 214 $Time = time(); … … 220 223 class ModuleFinance extends AppModule 221 224 { 222 function __construct($System) 225 public Finance $Finance; 226 public Bill $Bill; 227 228 function __construct(System $System) 223 229 { 224 230 parent::__construct($System); … … 229 235 $this->Description = 'Base module for finance management'; 230 236 $this->Dependencies = array('File', 'EmailQueue'); 231 } 232 233 function DoInstall() 234 { 235 } 236 237 function DoUninstall() 238 { 239 } 240 241 function DoStart() 237 238 $this->Bill = new Bill($this->System); 239 $this->Finance = new Finance($this->System); 240 } 241 242 function DoInstall(): void 243 { 244 } 245 246 function DoUninstall(): void 247 { 248 } 249 250 function DoStart(): void 242 251 { 243 252 global $Config; 244 253 245 $this->System->RegisterPage( array('finance', 'sprava'), 'PageFinanceManage');246 $this->System->RegisterPage( array('finance', 'platby'), 'PageFinanceUserState');247 $this->System->RegisterPage( array('finance', 'import'), 'PageFinanceImportPayment');248 $this->System->RegisterPage( array('finance', 'zivnost'), 'PageFinanceTaxFiling');254 $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage'); 255 $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState'); 256 $this->System->RegisterPage(['finance', 'import'], 'PageFinanceImportPayment'); 257 $this->System->RegisterPage(['finance', 'zivnost'], 'PageFinanceTaxFiling'); 249 258 250 259 $this->System->FormManager->RegisterClass('FinanceOperation', array( … … 644 653 )); 645 654 646 647 $this->System->AddModule(new Bill($this->System)); 648 $this->System->AddModule(new Finance($this->System)); 649 $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId']; 650 $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId']; 651 652 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Finance', 653 array('ModuleFinance', 'ShowDashboardItem')); 654 } 655 656 function ShowDashboardItem() 655 $this->Finance->MainSubject = $Config['Finance']['MainSubjectId']; 656 $this->Finance->DirectoryId = $Config['Finance']['DirectoryId']; 657 658 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem')); 659 } 660 661 function ShowDashboardItem(): string 657 662 { 658 663 $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1'); … … 662 667 } 663 668 664 function DoStop() 665 { 666 } 667 668 function BeforeInsertFinanceOperation( $Form)669 function DoStop(): void 670 { 671 } 672 673 function BeforeInsertFinanceOperation(Form $Form): array 669 674 { 670 675 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 671 676 else $Year = date("Y", $Form->Values['ValidFrom']); 672 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');673 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);674 return $Form->Values; 675 } 676 677 function AfterInsertFinanceOperation( $Form, $Id)678 { 679 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');677 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 678 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 679 return $Form->Values; 680 } 681 682 function AfterInsertFinanceOperation(Form $Form, string $Id): array 683 { 684 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 680 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 681 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 683 688 } 684 689 685 function BeforeModifyFinanceOperation( $Form, $Id)686 { 687 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');690 function BeforeModifyFinanceOperation(Form $Form, string $Id): array 691 { 692 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 688 693 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 689 694 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 691 696 } 692 697 693 function BeforeInsertFinanceInvoice( $Form)698 function BeforeInsertFinanceInvoice(Form $Form): array 694 699 { 695 700 // Get new DocumentLineCode by selected invoice Group 696 701 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 697 702 else $Year = date("Y", $Form->Values['ValidFrom']); 698 $Group = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');699 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);700 return $Form->Values; 701 } 702 703 function AfterInsertFinanceInvoice( $Form, $Id)704 { 705 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');703 $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 704 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 705 return $Form->Values; 706 } 707 708 function AfterInsertFinanceInvoice(Form $Form, string $Id): array 709 { 710 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 706 711 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 707 712 $DbRow = $DbResult->fetch_row(); … … 713 718 } 714 719 715 function BeforeModifyFinanceInvoice( $Form, $Id)716 { 717 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');720 function BeforeModifyFinanceInvoice(Form $Form, string $Id): array 721 { 722 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 718 723 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 719 724 $DbRow = $DbResult->fetch_row(); … … 724 729 } 725 730 726 function AfterInsertFinanceInvoiceItem( $Form, $Id)731 function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array 727 732 { 728 733 $ParentForm = new Form($this->System->FormManager); … … 733 738 } 734 739 735 function AfterModifyFinanceInvoiceItem( $Form, $Id)740 function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array 736 741 { 737 742 $ParentForm = new Form($this->System->FormManager); … … 742 747 } 743 748 744 function BeforeInsertContract( $Form)749 function BeforeInsertContract(Form $Form): array 745 750 { 746 751 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 747 752 else $Year = date("Y", $Form->Values['ValidFrom']); 748 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 749 return $Form->Values; 753 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 754 return $Form->Values; 755 } 756 757 static function Cast(AppModule $AppModule): ModuleFinance 758 { 759 if ($AppModule instanceof ModuleFinance) 760 { 761 return $AppModule; 762 } 763 throw new Exception('Expected ModuleFinance type but '.gettype($AppModule)); 750 764 } 751 765 } -
trunk/Modules/Finance/Import.php
r874 r887 3 3 class PageFinanceImportPayment extends Page 4 4 { 5 var $FullTitle = 'Import plateb'; 6 var $ShortTitle = 'Import plateb'; 7 var $ParentClass = 'PageFinance'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Import plateb'; 9 $this->ShortTitle = 'Import plateb'; 10 $this->ParentClass = 'PageFinance'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';15 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 12 16 if (array_key_exists('Operation', $_GET)) 13 17 { … … 26 30 } 27 31 28 function Prepare() 32 function Prepare(): string 29 33 { 30 $Finance = $this->System->Modules['Finance'];34 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 31 35 $Finance->LoadMonthParameters(0); 32 36 $Data = explode("\n", $_POST['Source']); … … 124 128 } 125 129 126 function InsertMoney( $Subject, $Value, $Cash, $Taxable, $Time, $Text,$Group)130 function InsertMoney(string $Subject, string $Value, string $Cash, string $Taxable, string $Time, string $Text, array $Group) 127 131 { 128 132 $Year = date('Y', $Time); 129 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);133 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 130 134 // TODO: Fixed BankAccount=1, allow to select bank account for import 131 135 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 136 140 } 137 141 138 function Insert() 142 function Insert(): string 139 143 { 140 $Finance = $this->System->Modules['Finance'];144 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 141 145 $Finance->LoadMonthParameters(0); 142 146 $Output = ''; … … 144 148 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 149 { 146 if ($_POST['Money'.$I] < 0) { 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 } else { 149 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 if ($_POST['Money'.$I] < 0) 151 { 152 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 153 } else 154 { 155 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 156 } 151 157 $Date = explode('-', $_POST['Date'.$I]); … … 154 160 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 155 161 $Output .= $I.', '; 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');162 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 157 163 } 158 164 return $Output; -
trunk/Modules/Finance/Manage.php
r886 r887 3 3 class PageFinanceManage extends Page 4 4 { 5 var $FullTitle = 'Správa financí'; 6 var $ShortTitle = 'Správa financí'; 7 var $ParentClass = 'PageFinance'; 8 9 function Show() 10 { 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Správa financí'; 9 $this->ShortTitle = 'Správa financí'; 10 $this->ParentClass = 'PageFinance'; 11 } 12 13 function Show(): string 14 { 15 $Output = ''; 16 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) 13 17 return 'Nemáte oprávnění'; 14 18 … … 18 22 { 19 23 case 'Recalculate': 20 $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();24 $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment(); 21 25 break; 22 26 case 'ShowMonthlyPayment': … … 51 55 $Year = date('Y', $Time); 52 56 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];57 $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount']; 54 58 if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0); 55 59 $MonthCurrent = date('n', $Time); … … 72 76 function ShowMonthlyPayment() 73 77 { 74 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';78 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 75 79 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 80 '`MemberPayment`.`Cash` AS `Cash`, '. … … 128 132 global $LastInsertTime; 129 133 134 $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 135 130 136 $Year = date('Y', $TimeCreation); 131 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);137 $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 138 $SumValue = 0; 133 139 foreach ($Items as $Item) { 134 140 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 141 } 136 $Finance = &$this->System->Modules['Finance'];137 142 $SumValue = round($SumValue, $Finance->Rounding); 138 143 $this->Database->insert('FinanceInvoice', array( … … 181 186 { 182 187 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], 183 'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType($Service['VAT']));188 'Quantity' => $Period['MonthCount'], 'VAT' => ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetVATByType($Service['VAT'])); 184 189 $MonthlyTotal += $Service['Price']; 185 190 } … … 196 201 197 202 // Load invoice group 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');203 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 204 foreach ($InvoiceItems as $Index => $Item) 200 205 { … … 275 280 function ProcessMonthlyPayment() 276 281 { 277 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';282 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 278 283 $Output = ''; 279 284 280 285 $Output .= $this->ProcessTableUpdates(); 281 286 282 $Finance = & $this->System->Modules['Finance'];287 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 283 288 $Finance->LoadMonthParameters(0); 284 289 … … 334 339 //flush(); 335 340 //$this->GenerateBills(); 336 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);341 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output); 337 342 } 338 343 $Output = str_replace("\n", '<br/>', $Output); … … 379 384 $Service = $DbResult->fetch_assoc(); 380 385 $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n". 381 'Vaše platební období: <strong>'. $this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".386 'Vaše platební období: <strong>'.ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n". 382 387 'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n". 383 388 'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n". … … 407 412 408 413 $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.'; 409 $this->System->ModuleManager->Modules['EmailQueue']->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,414 ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content, 410 415 $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>'); 411 416 $Output = ''; … … 416 421 function GenerateInvoice($Where) 417 422 { 423 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 418 424 $Output = ''; 419 425 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. … … 423 429 if ($Row['File'] == null) 424 430 { 425 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 426 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 431 $this->Database->insert('File', array('Name' => '', 'Size' => 0, 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 427 432 $FileId = $this->Database->insert_id; 428 433 } else $FileId = $Row['File']; … … 432 437 $Bill->System = &$this->System; 433 438 $Bill->InvoiceId = $Row['Id']; 434 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;439 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 435 440 $Bill->SaveToFile($FullFileName); 436 441 if (file_exists($FullFileName)) … … 446 451 function GenerateOperation($Where) 447 452 { 453 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 448 454 $Output = ''; 449 455 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. … … 454 460 { 455 461 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 456 'Directory' => $ this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));462 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 457 463 $FileId = $this->Database->insert_id; 458 464 } else $FileId = $Row['File']; … … 462 468 $Bill->System = &$this->System; 463 469 $Bill->OperationId = $Row['Id']; 464 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;470 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 465 471 $Bill->SaveToFile($FullFileName); 466 472 if (file_exists($FullFileName)) -
trunk/Modules/Finance/Trade.php
r874 r887 3 3 class PageFinanceTaxFiling extends Page 4 4 { 5 var $FullTitle = 'Daňová evidence';6 var $ShortTitle = 'Daňová evidence';7 var $ParentClass = 'PageFinance';8 5 var $StartEvidence = 0; 6 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Daňová evidence'; 11 $this->ShortTitle = 'Daňová evidence'; 12 $this->ParentClass = 'PageFinance'; 13 } 9 14 10 15 function GetTimePeriodBalance($StartTime, $EndTime) … … 340 345 function ShowSubjectAccount() 341 346 { 347 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 348 342 349 $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">'; 343 350 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; … … 424 431 } 425 432 426 function Show() 427 { 428 if (! $this->System->User->CheckPermission('Finance', 'TradingStatus'))433 function Show(): string 434 { 435 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'TradingStatus')) 429 436 return 'Nemáte oprávnění'; 430 431 $Finance = &$this->System->Modules['Finance'];432 437 433 438 $Output = ''; -
trunk/Modules/Finance/UserState.php
r874 r887 3 3 class PageFinanceUserState extends Page 4 4 { 5 var $FullTitle = 'Stav financí účastníka'; 6 var $ShortTitle = 'Stav financí'; 7 var $ParentClass = 'PageUser'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Stav financí účastníka'; 9 $this->ShortTitle = 'Stav financí'; 10 $this->ParentClass = 'PageUser'; 11 } 8 12 9 13 function ShowFinanceOperation($Subject) … … 69 73 } 70 74 71 function Show() 75 function Show(): string 72 76 { 73 $Finance = & $this->System->Modules['Finance'];77 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 74 78 $Finance->LoadMonthParameters(0); 75 79 … … 77 81 if (array_key_exists('i', $_GET)) 78 82 { 79 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';83 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 80 84 $CustomerId = $_GET['i']; 81 85 } else 82 86 { 83 if (! $this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění';84 $UserId = $this->System->User->User['Id'];87 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění'; 88 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 85 89 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 90 if ($DbResult->num_rows > 0) -
trunk/Modules/FinanceBankAPI/FileImport.php
r884 r887 5 5 class BankImport 6 6 { 7 var$System;8 var$Database;9 var$BankAccount;10 11 function __construct( $System)7 public System $System; 8 public Database $Database; 9 public int $BankAccount; 10 11 function __construct(System $System) 12 12 { 13 13 $this->Database = &$System->Database; … … 15 15 } 16 16 17 function Import() 18 { 17 function Import(): string 18 { 19 return ''; 19 20 } 20 21 … … 23 24 } 24 25 25 function PairOperations() 26 { 26 function PairOperations(): void 27 { 28 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 27 29 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 30 while ($DbRow = $DbResult->fetch_assoc()) … … 34 36 { 35 37 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) { 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 } else { 39 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 38 if ($DbRow['Value'] >= 0) 39 { 40 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 41 } else 42 { 43 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 40 44 } 41 45 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 42 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);43 $ DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,46 $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 47 $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 44 48 'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 45 49 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id'])); … … 65 69 class PageImportAPI extends Page 66 70 { 67 var $FullTitle = 'Import plateb přes API'; 68 var $ShortTitle = 'Import plateb přes API'; 69 var $ParentClass = 'PageFinance'; 70 71 function Import($Id) 71 function __construct(System $System) 72 { 73 parent::__construct($System); 74 $this->FullTitle = 'Import plateb přes API'; 75 $this->ShortTitle = 'Import plateb přes API'; 76 $this->ParentClass = 'PageFinance'; 77 } 78 79 function Import(int $Id): string 72 80 { 73 81 $Output = ''; … … 92 100 } 93 101 94 function Show() 95 { 96 if (! $this->System->User->CheckPermission('Finance', 'SubjectList'))102 function Show(): string 103 { 104 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) 97 105 return 'Nemáte oprávnění'; 98 106 … … 104 112 class PageImportFile extends Page 105 113 { 106 var $FullTitle = 'Import plateb ze souboru'; 107 var $ShortTitle = 'Import plateb ze souboru'; 108 var $ParentClass = 'PageFinance'; 109 110 function Show() 114 function __construct(System $System) 115 { 116 parent::__construct($System); 117 $this->FullTitle = 'Import plateb ze souboru'; 118 $this->ShortTitle = 'Import plateb ze souboru'; 119 $this->ParentClass = 'PageFinance'; 120 } 121 122 function Show(): string 111 123 { 112 124 $Output = ''; 113 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';125 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 114 126 if (array_key_exists('Operation', $_GET)) 115 127 { … … 121 133 } 122 134 123 function ShowForm() 135 function ShowForm(): string 124 136 { 125 137 $Form = new Form($this->System->FormManager); … … 156 168 } 157 169 158 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group) 170 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void 159 171 { 160 172 $Year = date('Y', $Time); 161 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(173 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId( 162 174 $Group['DocumentLine'], $Year); 163 175 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 166 178 } 167 179 168 function Insert() 169 { 170 $Finance = $ this->System->Modules['Finance'];180 function Insert(): string 181 { 182 $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 171 183 $Output = ''; 172 184 173 185 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 186 { 175 if ($_POST['Money'.$I] >= 0) { 187 if ($_POST['Money'.$I] >= 0) 188 { 176 189 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 190 'FinanceOperationGroup'); 178 } else { 191 } else 192 { 179 193 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 180 194 'FinanceOperationGroup'); … … 185 199 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 186 200 $Output .= $I.', '; 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');201 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 188 202 } 189 203 return $Output; -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r874 r887 8 8 class ModuleFinanceBankAPI extends AppModule 9 9 { 10 function __construct( $System)10 function __construct(System $System) 11 11 { 12 12 parent::__construct($System); … … 16 16 $this->License = 'GNU/GPLv3'; 17 17 $this->Description = 'Communication through API to various banks, manual file import'; 18 $this->Dependencies = array('Finance', 'Scheduler' );18 $this->Dependencies = array('Finance', 'Scheduler', 'IS'); 19 19 } 20 20 21 function DoInstall() 21 function DoInstall(): void 22 22 { 23 23 } 24 24 25 function DoUninstall() 25 function DoUninstall(): void 26 26 { 27 27 } 28 28 29 function DoStart() 29 function DoStart(): void 30 30 { 31 31 $this->System->FormManager->RegisterClass('ImportBankFile', array( … … 60 60 )); 61 61 62 $this->System->RegisterPage( array('finance', 'import-api'), 'PageImportAPI');63 $this->System->RegisterPage( array('finance', 'import-soubor'), 'PageImportFile');62 $this->System->RegisterPage(['finance', 'import-api'], 'PageImportAPI'); 63 $this->System->RegisterPage(['finance', 'import-soubor'], 'PageImportFile'); 64 64 65 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('FinanceBankAPI',66 array( 'ModuleFinanceBankAPI', 'ShowDashboardItem'));65 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('FinanceBankAPI', 66 array($this, 'ShowDashboardItem')); 67 67 } 68 68 69 function DoStop() 69 function DoStop(): void 70 70 { 71 71 } 72 72 73 function ShowDashboardItem() 73 function ShowDashboardItem(): string 74 74 { 75 75 $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL'); … … 79 79 } 80 80 81 function PresetItem( $Item)81 function PresetItem(array $Item): array 82 82 { 83 83 $Preset = array(); 84 84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 85 85 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 86 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');86 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); 87 87 88 88 $Preset = array( … … 100 100 class ScheduleBankImport extends SchedulerTask 101 101 { 102 function Execute() 102 function Execute(): string 103 103 { 104 104 $Output = ''; -
trunk/Modules/FinanceBankAPI/Fio.php
r874 r887 5 5 class Fio 6 6 { 7 var$UserName;8 var$Password;9 var$Account;7 public string $UserName; 8 public string $Password; 9 public int $Account; 10 10 11 function Import( $TimeFrom, $TimeTo)11 function Import(int $TimeFrom, int $TimeTo): array 12 12 { 13 13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.'); … … 59 59 } 60 60 61 function NoValidDataError( $Response)61 function NoValidDataError(array $Response): void 62 62 { 63 63 // Try to get error message 64 // If something go wrong fio show HTML login page and display error message65 $Response = implode('', $Response);64 // If something go wrong fio shows HTML login page and display error message 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 67 if (strpos($Response, $ErrorMessageStart) !== false) 68 {69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));71 } else $ErrorMessage = '';72 throw new Exception('No valid GPC data: '.$ErrorMessage);68 { 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); 70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>'))); 71 } else $ErrorMessage = ''; 72 throw new Exception('No valid GPC data: '.$ErrorMessage); 73 73 } 74 74 } -
trunk/Modules/FinanceBankAPI/FioAPI.php
r874 r887 23 23 } 24 24 25 function Import( $TimeFrom, $TimeTo)25 function Import(int $TimeFrom, int $TimeTo): array 26 26 { 27 27 if ($this->Token == '') throw new Exception('Missing value for Token property.'); … … 101 101 } 102 102 103 function NoValidDataError( $Response)103 function NoValidDataError(array $Response): void 104 104 { 105 105 // Try to get error message -
trunk/Modules/FinanceBankAPI/GPC.php
r874 r887 6 6 class GPC 7 7 { 8 function ParseLine( $Line)8 function ParseLine(string $Line): array 9 9 { 10 10 $Line = ' '.$Line; -
trunk/Modules/FinanceBankAPI/ImportFio.php
r884 r887 5 5 class ImportFio extends BankImport 6 6 { 7 function Import() 7 function Import(): string 8 8 { 9 9 $Fio = new FioAPI(); -
trunk/Modules/FinanceBankAPI/ImportPS.php
r873 r887 11 11 function ImportTxt($Content) 12 12 { 13 $Finance = &$this->System->Modules['Finance'];14 $Data = explode("\n", $Content);15 13 } 16 14 17 15 function ImportCVS($Content) 18 16 { 19 $Finance = &$this->System->Modules['Finance'];20 21 17 $Data = explode("\n", $Content); 22 18 foreach ($Data as $Key => $Value) -
trunk/Modules/IS/IS.php
r873 r887 5 5 class PageIS extends Page 6 6 { 7 var $FullTitle = 'Správa dat'; 8 var $ShortTitle = 'Správa dat'; 9 var $ParentClass = 'PagePortal'; 10 var $MenuItems; 11 var $HideMenu; 12 var $ShowActionName; 7 public array $MenuItems; 8 public bool $HideMenu; 9 public bool $ShowActionName; 13 10 14 11 function __construct($System) 15 12 { 16 13 parent::__construct($System); 14 $this->FullTitle = 'Správa dat'; 15 $this->ShortTitle = 'Správa dat'; 16 $this->ParentClass = 'PagePortal'; 17 17 18 $this->MenuItems = array(); 18 19 $this->HideMenu = false; … … 20 21 } 21 22 22 function Show() 23 { 24 if (! $this->System->User->CheckPermission('IS', 'Manage'))23 function Show(): string 24 { 25 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('IS', 'Manage')) 25 26 return 'Nemáte oprávnění'; 26 27 $this->System->FormManager->ShowRelation = true; … … 78 79 } 79 80 80 function Dashboard() 81 function Dashboard(): string 81 82 { 82 83 $Output = '<strong>Nástěnka:</strong><br/>'; 83 foreach ( $this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)84 foreach (ModuleIS::Cast($this->System->GetModule('IS'))->DashboardItems as $Item) 84 85 { 85 86 if (is_string($Item['Callback'][0])) … … 93 94 } 94 95 95 function ShowFavoriteAdd( $Table, $ItemId)96 { 97 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this-> System->User->User['Id'].')');96 function ShowFavoriteAdd(string $Table, string $ItemId): string 97 { 98 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 98 99 if ($DbResult->num_rows > 0) 99 100 { … … 101 102 } else 102 103 { 103 $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));104 $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'])); 104 105 $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených'); 105 106 } … … 108 109 } 109 110 110 function ShowFavoriteDel( $Table, $ItemId)111 { 112 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='. $this->System->User->User['Id'].')');111 function ShowFavoriteDel(string $Table, string $ItemId): string 112 { 113 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 113 114 if ($DbResult->num_rows > 0) 114 115 { … … 124 125 } 125 126 126 function LogChange( $Form, $Action, $NewId, $OldId)127 function LogChange(Form $Form, string $Action, string $NewId, string $OldId): void 127 128 { 128 129 $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n"; … … 152 153 } 153 154 } 154 $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values);155 } 156 157 function ShowEdit( $Table, $Id)155 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('IS', $Action, $Values); 156 } 157 158 function ShowEdit(string $Table, string $Id): string 158 159 { 159 160 $Output = ''; 160 161 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 161 162 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 162 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))163 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 163 164 return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění'); 164 165 if (array_key_exists('o', $_GET)) … … 226 227 } 227 228 228 function ShowDelete( $Table, $Id)229 function ShowDelete(string $Table, string $Id): string 229 230 { 230 231 $Output = ''; … … 232 233 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 233 234 $FormClass = $this->System->FormManager->Classes[$Table]; 234 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))235 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 235 236 return 'Nemáte oprávnění'; 236 237 $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id); … … 266 267 } 267 268 268 function ShowAdd( $Table, $Actions = array())269 function ShowAdd(string $Table, array $Actions = array()): string 269 270 { 270 271 $Output = ''; 271 272 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 272 273 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 273 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))274 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 274 275 return 'Nemáte oprávnění'; 275 276 if (array_key_exists('o', $_GET)) … … 315 316 316 317 //$this->Database->update($Table, 'Id='.$Id, 317 // array('UserCreate' => $this->System->User->User['Id'],318 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 318 319 // 'TimeCreate' => 'NOW()')); 319 320 } catch (Exception $E) … … 357 358 } 358 359 359 function ShowAddSub( $Table, $Filter = '', $Title = '')360 { 361 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))360 function ShowAddSub(string $Table, string $Filter = '', string $Title = ''): string 361 { 362 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 362 363 return 'Nemáte oprávnění'; 363 364 $this->BasicHTML = true; … … 367 368 } 368 369 369 function ShowTabs( $Tabs, $QueryParamName, $TabContent)370 function ShowTabs(array $Tabs, string $QueryParamName, string $TabContent): string 370 371 { 371 372 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 388 389 } 389 390 390 function ShowView( $Table, $Id, $WithoutActions = false)391 function ShowView(string $Table, string $Id, bool $WithoutActions = false): string 391 392 { 392 393 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 393 394 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 394 395 $FormClass = $this->System->FormManager->Classes[$Table]; 395 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))396 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 396 397 return 'Nemáte oprávnění'; 397 398 … … 473 474 } 474 475 475 function ShowTable( $Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')476 function ShowTable(string $Table, string $Filter = '', string $Title = '', string $RowActions = '', string $ExcludeColumn = ''): string 476 477 { 477 478 if (!array_key_exists($Table, $this->System->FormManager->Classes)) … … 673 674 } 674 675 675 function ShowSelect( $Table, $Filter = '', $Title = '')676 { 677 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))676 function ShowSelect(string $Table, string $Filter = '', string $Title = ''): string 677 { 678 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 678 679 return 'Nemáte oprávnění'; 679 680 $this->BasicHTML = true; … … 686 687 } 687 688 688 function ShowMapSelect( $Table, $Filter = '', $Title = '')689 { 690 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))689 function ShowMapSelect(string $Table, string $Filter = '', string $Title = ''): string 690 { 691 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 691 692 return 'Nemáte oprávnění'; 692 693 $Map = new MapOpenStreetMaps($this->System); … … 701 702 } 702 703 703 function ShowList( $Table, $Filter = '', $Title = '', $ExcludeColumn = '', $ExcludeValue = '')704 function ShowList(string $Table, string $Filter = '', string $Title = '', string $ExcludeColumn = '', string $ExcludeValue = ''): string 704 705 { 705 706 $Output = ''; 706 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))707 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 707 708 return 'Nemáte oprávnění'; 708 709 if (!array_key_exists($Table, $this->System->FormManager->Classes)) … … 738 739 if (array_key_exists('mi', $_GET)) 739 740 { 740 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='. $this->System->User->User['Id'].')');741 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 741 742 if ($DbResult->num_rows > 0) 742 743 { … … 761 762 } 762 763 763 function ShowFavorites() 764 function ShowFavorites(): string 764 765 { 765 766 $this->MenuItems = array(); … … 768 769 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '. 769 770 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '. 770 'WHERE `MenuItemFavorite`.`User`='. $this->System->User->User['Id'].' '.771 'WHERE `MenuItemFavorite`.`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].' '. 771 772 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`'); 772 773 while ($DbRow = $DbResult->fetch_assoc()) … … 778 779 } 779 780 780 function ShowMenu() 781 function ShowMenu(): string 781 782 { 782 783 $this->MenuItems = array(); … … 794 795 } 795 796 796 function ShowMenuItem( $Parent, $All = false)797 function ShowMenuItem(string $Parent, bool $All = false): string 797 798 { 798 799 $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">'; … … 810 811 if ($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/> '; 811 812 else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/> '; 812 //if ( $this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))813 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION')) 813 814 $Output .= '<li>'.$Image.$LinkTitle.'</li>'; 814 815 if ($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']); … … 819 820 } 820 821 821 function TableToModule( $Table)822 function TableToModule(string $Table): string 822 823 { 823 824 $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '. … … 830 831 } 831 832 832 function ShowAction( $Name, $Target, $Icon, $Confirm = '')833 function ShowAction(string $Name, string $Target, string $Icon, string $Confirm = ''): string 833 834 { 834 835 $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'. … … 846 847 var $DashboardItems; 847 848 848 function __construct( $System)849 function __construct(System $System) 849 850 { 850 851 parent::__construct($System); … … 855 856 $this->License = 'GNU/GPLv3'; 856 857 $this->Description = 'User interface for generic information system'; 857 $this->Dependencies = array( );858 $this->Dependencies = array('User'); 858 859 859 860 $this->DashboardItems = array(); 860 861 } 861 862 862 function DoInstall() 863 { 864 } 865 866 function DoUninstall() 867 { 868 } 869 870 function DoStart() 871 { 872 $this->System->RegisterPage( 'is', 'PageIS');863 function DoInstall(): void 864 { 865 } 866 867 function DoUninstall(): void 868 { 869 } 870 871 function DoStart(): void 872 { 873 $this->System->RegisterPage(['is'], 'PageIS'); 873 874 $this->System->FormManager->RegisterClass('MenuItem', array( 874 875 'Title' => 'Položky nabídky', … … 914 915 } 915 916 916 function DoStop() 917 { 918 } 919 920 function RegisterDashboardItem( $Name, $Callback)917 function DoStop(): void 918 { 919 } 920 921 function RegisterDashboardItem(string $Name, callable $Callback): void 921 922 { 922 923 $this->DashboardItems[$Name] = array('Callback' => $Callback); 923 924 } 924 925 925 function UnregisterDashboardItem( $Name)926 function UnregisterDashboardItem(string $Name): void 926 927 { 927 928 unset($this->DashboardItems[$Name]); 928 929 } 930 931 static function Cast(AppModule $AppModule): ModuleIS 932 { 933 if ($AppModule instanceof ModuleIS) 934 { 935 return $AppModule; 936 } 937 throw new Exception('Expected ModuleIS type but '.gettype($AppModule)); 938 } 929 939 } -
trunk/Modules/Log/Log.php
r874 r887 3 3 class ModuleLog extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoInstall() 16 function DoInstall(): void 17 17 { 18 18 } 19 19 20 function DoUnInstall() 20 function DoUnInstall(): void 21 21 { 22 22 } 23 23 24 function DoStart() 24 function DoStart(): void 25 25 { 26 26 $this->System->FormManager->RegisterClass('Log', array( … … 38 38 ), 39 39 )); 40 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Logs',41 'Channel' => 'log', 'Callback' => array( 'ModuleLog', 'ShowRSS'),40 ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Logs', 41 'Channel' => 'log', 'Callback' => array($this, 'ShowRSS'), 42 42 'Permission' => array('Module' => 'Log', 'Operation' => 'RSS'))); 43 43 } 44 44 45 function DoStop() 45 function DoStop(): void 46 46 { 47 47 } 48 48 49 function NewRecord( $Module, $Operation, $Value = '')49 function NewRecord(string $Module, string $Operation, string $Value = ''): void 50 50 { 51 if ( array_key_exists('User', $this->System->ModuleManager->Modules) and52 array_key_exists('Id', $this->System->User->User))53 $UserId = $this->System->User->User['Id'];51 if ($this->System->ModuleManager->ModulePresent('User') and 52 array_key_exists('Id', ModuleUser::Cast($this->System->GetModule('User'))->User->User)) 53 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 54 54 else $UserId = NULL; 55 55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR']; … … 60 60 } 61 61 62 function ShowRSS() 62 function ShowRSS(): string 63 63 { 64 64 $this->ClearPage = true; … … 98 98 return $RSS->Generate(); 99 99 } 100 101 static function Cast(AppModule $AppModule): ModuleLog 102 { 103 if ($AppModule instanceof ModuleLog) 104 { 105 return $AppModule; 106 } 107 throw new Exception('Expected ModuleLog type but got '.gettype($AppModule)); 108 } 100 109 } -
trunk/Modules/Map/Map.php
r874 r887 5 5 class PageNetworkMap extends Page 6 6 { 7 var $FullTitle = 'Mapa sítě'; 8 var $ShortTitle = 'Mapa sítě'; 9 var $ParentClass = 'PagePortal'; 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Mapa sítě'; 11 $this->ShortTitle = 'Mapa sítě'; 12 $this->ParentClass = 'PagePortal'; 13 } 10 14 //var $Load = 'initialize()'; 11 15 //var $Unload = 'GUnload()'; 12 16 13 function Show() 14 { 15 if (! $this->System->User->CheckPermission('Map', 'Show'))17 function Show(): string 18 { 19 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Map', 'Show')) 16 20 return 'Nemáte oprávnění'; 17 21 … … 23 27 } 24 28 25 function ShowPosition() 29 function ShowPosition(): string 26 30 { 27 31 $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']); … … 44 48 } 45 49 46 function ShowMain() 50 function ShowMain(): string 47 51 { 48 52 $Map = new MapOpenStreetMaps($this->System); … … 242 246 class TypeMapPosition extends TypeString 243 247 { 244 function OnEdit( $Item)248 function OnEdit(array $Item): string 245 249 { 246 250 $Output = parent::OnEdit($Item); … … 255 259 class ModuleMap extends AppModule 256 260 { 257 function __construct( $System)261 function __construct(System $System) 258 262 { 259 263 parent::__construct($System); … … 263 267 $this->License = 'GNU/GPL'; 264 268 $this->Description = 'Show objects on Google maps'; 265 $this->Dependencies = array('Network' );269 $this->Dependencies = array('Network', 'User'); 266 270 $this->SupportedModels = array(); 267 271 } 268 272 269 function DoStart() 273 function DoStart(): void 270 274 { 271 275 $this->System->Pages['map'] = 'PageNetworkMap'; … … 310 314 } 311 315 312 function DoInstall() 316 function DoInstall(): void 313 317 { 314 318 $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` ( … … 320 324 } 321 325 322 function DoUninstall() 326 function DoUninstall(): void 323 327 { 324 328 $this->Database->query('DROP TABLE `MapPosition`'); -
trunk/Modules/Map/MapAPI.php
r874 r887 3 3 class MapMarker 4 4 { 5 var$Position;6 var$Text;5 public array $Position; 6 public string $Text; 7 7 } 8 8 9 9 class MapPolyLine 10 10 { 11 var$Points = array();12 var$Color = 'black';11 public array $Points = array(); 12 public string $Color = 'black'; 13 13 } 14 14 15 15 class Map extends Model 16 16 { 17 var$Position;18 var$Zoom;19 var$Key;17 public array $Position; 18 public int $Zoom; 19 public string $Key; 20 20 var $OnClickObject; 21 var$MarkerText;22 var$Markers;23 var$PolyLines;21 public string $MarkerText; 22 public array $Markers; 23 public array $PolyLines; 24 24 25 function __construct( $System)25 function __construct(System $System) 26 26 { 27 27 parent::__construct($System); … … 35 35 } 36 36 37 function Show() 37 function Show(): string 38 38 { 39 39 return ''; … … 43 43 class MapGoogle extends Map 44 44 { 45 function ShowPage( $Page)45 function ShowPage(Page $Page): string 46 46 { 47 47 $Page->Load = 'initialize()'; … … 113 113 class MapOpenStreetMaps extends Map 114 114 { 115 function GetPageHeader() 115 function GetPageHeader(): string 116 116 { 117 117 $Output = '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" … … 124 124 } 125 125 126 function ShowPage( $Page)126 function ShowPage(Page $Page): string 127 127 { 128 128 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); -
trunk/Modules/Meals/Meals.php
r874 r887 3 3 class PageEatingPlace extends Page 4 4 { 5 var $FullTitle = 'Jídleníček jídelny Na kopečku';6 var $ShortTitle = 'Jídelníček';7 var $ParentClass = 'PagePortal';8 5 var $DayNames = array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'); 9 6 var $DayNamesShort = array('NE', 'PO', 'ÚT', 'ST', 'ČT', 'PÁ', 'SO'); … … 11 8 var $DayCount = 20; // počet dopředu zobrazených dnů 12 9 13 function Show() 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Jídleníček jídelny Na kopečku'; 14 $this->ShortTitle = 'Jídelníček'; 15 $this->ParentClass = 'PagePortal'; 16 } 17 18 function Show(): string 14 19 { 15 20 if (count($this->System->PathItems) > 1) … … 21 26 } 22 27 23 function ShowMenu() 28 function ShowMenu(): string 24 29 { 25 30 //echo('Dnes je '.HumanDate(date('Y-m-d')).'<br>'); … … 43 48 } 44 49 45 function ShowPrint() 50 function ShowPrint(): string 46 51 { 47 52 $this->ClearPage = true; … … 94 99 } 95 100 96 function PrintTableRow( $Row)101 function PrintTableRow(array $Row): string 97 102 { 98 103 global $LastWeekOfYear; … … 120 125 } 121 126 122 function ShowEdit() 127 function ShowEdit(): string 123 128 { 124 129 Header('Cache-Control: no-cache'); … … 136 141 } 137 142 $Output .= '<div style="color: red; font-size: larger;">Menu uloženo!</div>'; 138 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave');143 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'MenuSave'); 139 144 } 140 145 if ($_GET['action'] == 'saveinfo') … … 143 148 $this->Database->insert('MealsInfo', array('Info' => $_POST['info'], 'Price' => $_POST['price'])); 144 149 $Output .= '<div style="color: red; font-size: larger;">Informační údaje uloženy!</div>'; 145 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'InfoSave');150 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'InfoSave'); 146 151 } 147 152 } … … 179 184 class ModuleMeals extends AppModule 180 185 { 181 function __construct( $System)186 function __construct(System $System) 182 187 { 183 188 parent::__construct($System); … … 191 196 } 192 197 193 function DoInstall() 194 { 195 } 196 197 function DoUnInstall() 198 { 199 } 200 201 function DoStart() 202 { 203 $this->System->RegisterPage( 'jidelna', 'PageEatingPlace');198 function DoInstall(): void 199 { 200 } 201 202 function DoUnInstall(): void 203 { 204 } 205 206 function DoStart(): void 207 { 208 $this->System->RegisterPage(['jidelna'], 'PageEatingPlace'); 204 209 } 205 210 } -
trunk/Modules/Meteostation/Meteostation.php
r874 r887 3 3 class PageMeteo extends Page 4 4 { 5 var $FullTitle = 'Stav meteostanice'; 6 var $ShortTitle = 'Meteostanice'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Stav meteostanice'; 9 $this->ShortTitle = 'Meteostanice'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 15 $Output = 'Stav meteostanice:<br/>'; … … 22 26 var $URL; 23 27 24 function DownloadData() 28 function DownloadData(): void 25 29 { 26 30 $XmlData = simplexml_load_file($this->URL); … … 50 54 } 51 55 52 function CreateImage($FileName) 56 function CreateImage($FileName): void 53 57 { 54 58 $Image = new Image(); … … 63 67 } 64 68 65 function LoadFromDb() 69 function LoadFromDb(): void 66 70 { 67 71 $DbResult = $this->Database->select('Meteostation', '*', 'Id = '.$this->Id); … … 77 81 var $Data; 78 82 79 function __construct( $System)83 function __construct(System $System) 80 84 { 81 85 parent::__construct($System); … … 88 92 } 89 93 90 function DownloadAll() 94 function DownloadAll(): void 91 95 { 92 96 $DbResult = $this->Database->select('MeteoStation', '*'); 93 97 while ($DbRow = $DbResult->fetch_assoc()) 94 98 { 95 $MeteoStation = new MeteoStation( );99 $MeteoStation = new MeteoStation($this->System); 96 100 $MeteoStation->Id = $DbRow['Id']; 97 101 $MeteoStation->LoadFromDb(); … … 102 106 103 107 104 function DoInstall() 108 function DoInstall(): void 105 109 { 106 110 } 107 111 108 function DoUninstall() 112 function DoUninstall(): void 109 113 { 110 114 } 111 115 112 function DoStart() 116 function DoStart(): void 113 117 { 114 $this->System->RegisterPage( 'meteo', 'PageMeteo');118 $this->System->RegisterPage(['meteo'], 'PageMeteo'); 115 119 } 116 120 117 function DoStop() 121 function DoStop(): void 118 122 { 119 123 } -
trunk/Modules/Network/HostList.php
r874 r887 5 5 class PageHostList extends Page 6 6 { 7 var $FullTitle = 'Seznam registrovaných počítačů'; 8 var $ShortTitle = 'Seznam počítačů'; 9 var $ParentClass = 'PageNetwork'; 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Seznam registrovaných počítačů'; 11 $this->ShortTitle = 'Seznam počítačů'; 12 $this->ParentClass = 'PageNetwork'; 13 } 10 14 11 function Show() 15 function Show(): string 12 16 { 13 if (! $this->System->User->CheckPermission('Network', 'ShowHostList'))17 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowHostList')) 14 18 return 'Nemáte oprávnění'; 15 19 -
trunk/Modules/Network/Hosting.php
r874 r887 3 3 class PageHosting extends Page 4 4 { 5 var $FullTitle = 'Hostované projekty'; 6 var $ShortTitle = 'Hostované projekty'; 7 var $ParentClass = 'PageNetwork'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Hostované projekty'; 9 $this->ShortTitle = 'Hostované projekty'; 10 $this->ParentClass = 'PageNetwork'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 15 $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>'; -
trunk/Modules/Network/Network.php
r879 r887 8 8 class PageFrequencyPlan extends Page 9 9 { 10 var $FullTitle = 'Výpis obsazení frekvenčních kanálů'; 11 var $ShortTitle = 'Frekvenční plán'; 12 var $ParentClass = 'PageNetwork'; 13 14 function Show() 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Výpis obsazení frekvenčních kanálů'; 14 $this->ShortTitle = 'Frekvenční plán'; 15 $this->ParentClass = 'PageNetwork'; 16 } 17 18 function Show(): string 15 19 { 16 20 // http://en.wikipedia.org/wiki/List_of_WLAN_channels … … 75 79 class PageNetwork extends Page 76 80 { 77 var $FullTitle = 'Technické informace o síti'; 78 var $ShortTitle = 'Síť'; 79 var $ParentClass = 'PagePortal'; 80 81 function Show() 82 { 83 if (count($this->System->PathItems) > 1) 84 { 85 $Output = $this->PageNotFound(); 86 } else $Output = $this->ShowInformation(); 87 return $Output; 88 } 89 90 function ShowInformation() 91 { 92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo')) 81 function __construct(System $System) 82 { 83 parent::__construct($System); 84 $this->FullTitle = 'Technické informace o síti'; 85 $this->ShortTitle = 'Síť'; 86 $this->ParentClass = 'PagePortal'; 87 } 88 89 function Show(): string 90 { 91 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowInfo')) 93 92 return 'Nemáte oprávnění'; 94 93 … … 102 101 class ModuleNetwork extends AppModule 103 102 { 104 var$MinNotifyTime;105 106 function __construct( $System)103 public int $MinNotifyTime; 104 105 function __construct(System $System) 107 106 { 108 107 parent::__construct($System); … … 112 111 $this->License = 'GNU/GPLv3'; 113 112 $this->Description = 'Networking related tools'; 114 $this->Dependencies = array('Notify' );113 $this->Dependencies = array('Notify', 'IS'); 115 114 116 115 // TODO: Make notify time configurable … … 118 117 } 119 118 120 function DoInstall() 121 { 122 } 123 124 function DoUninstall() 125 { 126 } 127 128 function DoStart() 129 { 130 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability',119 function DoInstall(): void 120 { 121 } 122 123 function DoUninstall(): void 124 { 125 } 126 127 function DoStart(): void 128 { 129 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkReachability', 131 130 array($this, 'ReachabilityCheck')); 132 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',131 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkPort', 133 132 array($this, 'PortCheck')); 134 133 135 $this->System->RegisterPage( 'network', 'PageNetwork');136 $this->System->RegisterPage( array('network', 'administration'), 'PageNetworkAdministration');137 $this->System->RegisterPage( array('network', 'subnet'), 'PageSubnet');138 $this->System->RegisterPage( array('network', 'user-hosts'), 'PageNetworkHostList');139 $this->System->RegisterPage( array('network', 'hosting'),'PageHosting');140 $this->System->RegisterPage( array('network', 'hosts'), 'PageHostList');141 $this->System->RegisterPage( array('network', 'frequency-plan'), 'PageFrequencyPlan');142 143 $this->System->RegisterCommandLine('networklog_import', array($this, 'ImportNetworkLog'));134 $this->System->RegisterPage(['network'], 'PageNetwork'); 135 $this->System->RegisterPage(['network', 'administration'], 'PageNetworkAdministration'); 136 $this->System->RegisterPage(['network', 'subnet'], 'PageSubnet'); 137 $this->System->RegisterPage(['network', 'user-hosts'], 'PageNetworkHostList'); 138 $this->System->RegisterPage(['network', 'hosting'],'PageHosting'); 139 $this->System->RegisterPage(['network', 'hosts'], 'PageHostList'); 140 $this->System->RegisterPage(['network', 'frequency-plan'], 'PageFrequencyPlan'); 141 142 $this->System->RegisterCommandLine('networklog_import', 'Imports network logs from remote server', array($this, 'ImportNetworkLog')); 144 143 145 144 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array( … … 750 749 )); 751 750 752 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network',753 array( 'ModuleNetwork', 'ShowDashboardItem'));751 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Network', 752 array($this, 'ShowDashboardItem')); 754 753 755 754 $this->System->RegisterModel('NetworkDevice', array( … … 761 760 } 762 761 763 function AfterInsertNetworkDevice( $Form)762 function AfterInsertNetworkDevice(Form $Form): void 764 763 { 765 764 $this->System->Models['NetworkDevice']->DoOnChange(); 766 765 } 767 766 768 function AfterModifyNetworkDevice( $Form, $Id)767 function AfterModifyNetworkDevice(Form $Form, string $Id): void 769 768 { 770 769 $this->System->Models['NetworkDevice']->DoOnChange(); 771 770 } 772 771 773 function AfterInsertNetworkInterface( $Form)772 function AfterInsertNetworkInterface(Form $Form): void 774 773 { 775 774 $this->System->Models['NetworkInterface']->DoOnChange(); 776 775 } 777 776 778 function AfterModifyNetworkInterface( $Form, $Id)777 function AfterModifyNetworkInterface(Form $Form, string $Id): void 779 778 { 780 779 $this->System->Models['NetworkInterface']->DoOnChange(); 781 780 } 782 781 783 function BeforeDeleteNetworkInterface( $Form, $Id)782 function BeforeDeleteNetworkInterface(Form $Form, string $Id): void 784 783 { 785 784 $this->Database->query('DELETE FROM `NetworkInterfaceUpDown` WHERE `Interface`='.$Id); … … 791 790 } 792 791 793 function ImportNetworkLog( $Parameters)792 function ImportNetworkLog(array $Parameters): void 794 793 { 795 794 global $Config; … … 813 812 { 814 813 $DbRow2 = $DbResult2->fetch_assoc(); 815 $DeviceI D= $DbRow2['Device'];814 $DeviceId = $DbRow2['Device']; 816 815 $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'], 817 816 'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag'])); … … 820 819 } 821 820 822 function ShowDashboardItem() 821 function ShowDashboardItem(): string 823 822 { 824 823 $Output = ''; … … 841 840 } 842 841 843 function DoStop() 844 { 845 } 846 847 function OnlineList( $Title, $OnlineNow, $OnlinePrevious, $MinDuration)842 function DoStop(): void 843 { 844 } 845 846 function OnlineList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array 848 847 { 849 848 $Time = time(); … … 886 885 } 887 886 888 function ReachabilityCheck() 887 function ReachabilityCheck(): array 889 888 { 890 889 $NewOnline = $this->OnlineList('Nově online', 1, 0, 0); … … 898 897 } 899 898 900 function PortCheckList( $Title, $OnlineNow, $OnlinePrevious, $MinDuration)899 function PortCheckList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array 901 900 { 902 901 $Time = time(); … … 937 936 } 938 937 939 function PortCheck() 938 function PortCheck(): array 940 939 { 941 940 $Output = ''; -
trunk/Modules/Network/Subnet.php
r874 r887 3 3 class PageSubnet extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`'); -
trunk/Modules/Network/UserHosts.php
r874 r887 3 3 class PageNetworkHostList extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 global $Config; 16 16 17 if ( $this->System->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');17 if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'); 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; 19 19 $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>'; 20 20 $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice '. 21 21 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '. 22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='. $this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].') ORDER BY NetworkDevice.Name'); 23 23 while ($Device = $DbResult->fetch_assoc()) 24 24 { -
trunk/Modules/NetworkConfig/Generate.php
r873 r887 2 2 3 3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 include_once(dirname(__FILE__).'/../../Application/ System.php');4 include_once(dirname(__FILE__).'/../../Application/Core.php'); 5 5 $System = new Core(); 6 6 $System->ShowPage = false; -
trunk/Modules/NetworkConfig/NetworkConfig.php
r874 r887 5 5 var $ConfigItems; 6 6 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 17 17 } 18 18 19 function DoInstall() 19 function DoInstall(): void 20 20 { 21 21 } 22 22 23 function DoUnInstall() 23 function DoUnInstall(): void 24 24 { 25 25 } 26 26 27 function DoStart() 27 function DoStart(): void 28 28 { 29 29 $this->System->FormManager->RegisterClass('NetworkConfiguration', array( … … 55 55 'States' => array('Neplánováno', 'V plánu', 'Provádí se'), 56 56 )); 57 58 $this->System->RegisterCommandLine('config', array($this, 'Config'));57 58 $this->System->RegisterCommandLine('config', 'Configures network services.', array($this, 'Config')); 59 59 $this->System->Models['NetworkDevice']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange')); 60 60 $this->System->Models['NetworkInterface']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange')); 61 61 } 62 63 function DoNetworkChange() 62 63 function DoNetworkChange(): void 64 64 { 65 65 $this->Database->query('UPDATE `NetworkConfiguration` SET `Changed`=1 WHERE '. … … 67 67 } 68 68 69 function RegisterConfigItem( $Name, $ClassName)69 function RegisterConfigItem(string $Name, string $ClassName): void 70 70 { 71 71 $this->ConfigItems[$Name] = $ClassName; 72 72 } 73 73 74 function UnregisterConfigItem( $Name)74 function UnregisterConfigItem(string $Name): void 75 75 { 76 76 unset($this->ConfigItems[$Name]); 77 77 } 78 78 79 function Config( $Parameters)79 function Config(array $Parameters): void 80 80 { 81 81 $Output = ''; … … 90 90 } else $Output = 'Config item '.$ConfigItemName.' not found'; 91 91 } else $Output = 'Not enough parameters'; 92 return $Output; 92 echo($Output); 93 } 94 95 static function Cast(AppModule $AppModule): ModuleNetworkConfig 96 { 97 if ($AppModule instanceof ModuleNetworkConfig) 98 { 99 return $AppModule; 100 } 101 throw new Exception('Expected ModuleNetworkConfig type but got '.gettype($AppModule)); 93 102 } 94 103 } … … 96 105 class NetworkConfigItem extends Model 97 106 { 98 function Run() 107 function Run(): void 99 108 { 100 101 109 } 102 110 } -
trunk/Modules/NetworkConfigAirOS/Generators/Signal.php
r873 r887 5 5 class ConfigAirOSSignal extends NetworkConfigItem 6 6 { 7 function ReadWirelessRegistration() 7 function ReadWirelessRegistration(): void 8 8 { 9 9 $Time = time(); … … 19 19 //$SSHClient->Debug = true; 20 20 $Result = $SSHClient->Execute('wstalist'); 21 if (count($Result) > 0) 22 { 21 if (count($Result) > 0) 22 { 23 23 //print_r($Result); 24 24 $Array = json_decode(implode("\n", $Result), true); … … 44 44 echo("\n"); 45 45 } else echo("Empty response\n"); 46 47 46 } 48 47 } 49 48 50 function Run() 49 function Run(): void 51 50 { 52 51 RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration')); -
trunk/Modules/NetworkConfigAirOS/NetworkConfigAirOS.php
r781 r887 5 5 class ModuleNetworkConfigAirOS extends AppModule 6 6 { 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 16 16 } 17 17 18 function DoInstall() 18 function DoInstall(): void 19 19 { 20 20 } 21 21 22 function DoUnInstall() 22 function DoUnInstall(): void 23 23 { 24 24 } 25 25 26 function DoStart() 26 function DoStart(): void 27 27 { 28 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');28 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal'); 29 29 } 30 30 } -
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r874 r887 3 3 class ConfigCheckPorts extends NetworkConfigItem 4 4 { 5 function CheckPortStatus($IP, $Port, $Protocol = 'tcp') 5 function CheckPortStatus($IP, $Port, $Protocol = 'tcp'): int 6 6 { 7 7 $Timeout = 1; … … 17 17 return $State; 18 18 } 19 20 function CheckPorts() 19 20 function CheckPorts(): void 21 21 { 22 22 $StartTime = time(); … … 77 77 } 78 78 79 function Run() 79 function Run(): void 80 80 { 81 81 RepeatFunction(60, array($this, 'CheckPorts')); -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r873 r887 7 7 class ConfigDNS extends NetworkConfigItem 8 8 { 9 function GenerateDNS( $DNS)9 function GenerateDNS(array $DNS): void 10 10 { 11 11 $Output = '$ORIGIN '.$DNS['Domain'].'.'."\n". … … 147 147 } 148 148 149 function Run() 149 function Run(): void 150 150 { 151 151 $BaseDomain = 'zdechov.net'; -
trunk/Modules/NetworkConfigLinux/Generators/Latency.php
r873 r887 3 3 class ConfigLatency extends NetworkConfigItem 4 4 { 5 function PingHosts() 5 function PingHosts(): void 6 6 { 7 7 $Timeout = 2000; // ms … … 23 23 24 24 $Queries = array(); 25 foreach ($Output as $Index => $Line) 25 foreach ($Output as $Index => $Line) 26 26 { 27 27 $IP = substr($Line, 0, strPos($Line, ' ')); … … 35 35 } 36 36 37 function Run() 37 function Run(): void 38 38 { 39 39 RepeatFunction(10 * 60, array($this, 'PingHosts')); -
trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php
r824 r887 7 7 class ModuleNetworkConfigLinux extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-dns', 'ConfigDNS');31 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts');32 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-latency', 'ConfigLatency');30 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-dns', 'ConfigDNS'); 31 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts'); 32 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-latency', 'ConfigLatency'); 33 33 } 34 34 } -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r873 r887 4 4 class ConfigRouterOSDHCP extends NetworkConfigItem 5 5 { 6 function Run() 6 function Run(): void 7 7 { 8 8 $Path = array('ip', 'dhcp-server', 'lease'); -
trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php
r873 r887 3 3 class ConfigRouterOSDNS extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'dns', 'static'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r873 r887 3 3 class ConfigRouterOSFirewallFilter extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'firewall', 'filter'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r873 r887 3 3 class ConfigRouterOSFirewallMangle extends NetworkConfigItem 4 4 { 5 function ProcessNode($Node) 5 function ProcessNode($Node): void 6 6 { 7 7 global $InetInterface, $ItemsFirewall; 8 8 9 foreach ($Node['Items'] as $I ndex => $Item)9 foreach ($Node['Items'] as $Item) 10 10 { 11 11 if (count($Item['Items']) == 0) … … 47 47 } 48 48 49 function Run() 49 function Run(): void 50 50 { 51 51 $this->RunIPv4(); … … 53 53 } 54 54 55 function RunIPv4() 55 function RunIPv4(): void 56 56 { 57 57 global $ItemsFirewall; … … 149 149 } 150 150 151 function RunIPv6() 151 function RunIPv6(): void 152 152 { 153 153 global $ItemsFirewall; -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r873 r887 3 3 class ConfigRouterOSFirewallNAT extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'firewall', 'nat'); -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r873 r887 3 3 class ConfigRouterOSNetwatch extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('tool', 'netwatch'); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r873 r887 3 3 class ConfigRouterOSNetwatchImport extends NetworkConfigItem 4 4 { 5 function NetwatchImport() 5 function NetwatchImport(): void 6 6 { 7 7 $StartTime = time(); … … 44 44 $Queries = array(); 45 45 $QueriesInsert = array(); 46 foreach ($Interfaces as $In dex => $Interface)46 foreach ($Interfaces as $Interface) 47 47 { 48 48 // Update last online time if still online … … 103 103 } 104 104 105 function Run() 105 function Run(): void 106 106 { 107 107 RepeatFunction(10, array($this, 'NetwatchImport')); -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r873 r887 14 14 } 15 15 16 function Print() 16 function Print(): string 17 17 { 18 18 $Output = '(Min: '.$this->Min.' Max: '.$this->Max; … … 46 46 } 47 47 48 function CheckName($Name, &$UsedNames) 48 function CheckName($Name, &$UsedNames): void 49 49 { 50 50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); … … 52 52 } 53 53 54 function GetCommands(&$UsedNames = null) 54 function GetCommands(&$UsedNames = null): array 55 55 { 56 56 if ($UsedNames == null) $UsedNames = array(); … … 72 72 } 73 73 74 function GetParentName(string $Suffix) 74 function GetParentName(string $Suffix): string 75 75 { 76 76 if ($this->Parent != null) return $this->Parent->Name.$Suffix; … … 78 78 } 79 79 80 function UpdateMinSpeeds() 80 function UpdateMinSpeeds(): void 81 81 { 82 82 if (($this->LimitIn->Min == 0) or ($this->LimitOut->Min == 0)) … … 100 100 class SpeedLimitItems extends GenericList 101 101 { 102 function AddNew(string $Name, SpeedLimitItem $Parent = null) 102 function AddNew(string $Name, SpeedLimitItem $Parent = null): SpeedLimitItem 103 103 { 104 104 $Item = new SpeedLimitItem($Name, $Parent); 105 $Item->LimitIn = new SpeedLimit( );106 $Item->LimitOut = new SpeedLimit( );105 $Item->LimitIn = new SpeedLimit(0, 0); 106 $Item->LimitOut = new SpeedLimit(0, 0); 107 107 $this->Items[] = $Item; 108 108 return $Item; … … 119 119 } 120 120 121 function GetCommands(&$UsedNames) 121 function GetCommands(&$UsedNames): array 122 122 { 123 123 $Output = array(); … … 137 137 var $SpeedLimits; 138 138 139 function Run() 139 function Run(): void 140 140 { 141 141 $PathQueue = array('queue', 'tree'); … … 149 149 $this->UsedNames = array(); 150 150 151 $Finance = & $this->System->Modules['Finance'];151 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 152 152 $Finance->LoadMonthParameters(0); 153 153 … … 280 280 } 281 281 282 function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem) 282 function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem): void 283 283 { 284 284 $SpeedLimitName = $SpeedLimit['Name'].'-grp'; … … 297 297 } 298 298 299 function LoadSpeedLimits($SpeedLimitItem) 299 function LoadSpeedLimits($SpeedLimitItem): void 300 300 { 301 301 echo('Limit groups: '); … … 326 326 } 327 327 328 function UpdateMinSpeed($DeviceId) 328 function UpdateMinSpeed($DeviceId): void 329 329 { 330 330 $MinSpeed = 0; … … 340 340 341 341 // Calculate maximum real speed available for each network device Start with main router and continue with adjecement nodes. 342 function BuildTree($RootDeviceId, $BaseSpeed) 342 function BuildTree($RootDeviceId, $BaseSpeed): void 343 343 { 344 344 // Load network devices … … 438 438 } 439 439 440 function BuildQueueItems($DeviceId, $SpeedLimitParent) 440 function BuildQueueItems($DeviceId, $SpeedLimitParent): void 441 441 { 442 442 $Device = $this->Devices[$DeviceId]; … … 475 475 } 476 476 477 function RunTopology() 477 function RunTopology(): void 478 478 { 479 479 $PathQueue = array('queue', 'tree'); … … 487 487 $this->UsedNames = array(); 488 488 489 $Finance = & $this->System->Modules['Finance'];489 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 490 490 $Finance->LoadMonthParameters(0); 491 491 -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r874 r887 3 3 class ConfigRouterOSSignal extends NetworkConfigItem 4 4 { 5 function ReadWirelessRegistration() 5 function ReadWirelessRegistration(): void 6 6 { 7 7 $Time = time(); … … 66 66 $this->Database->Transaction($Queries); 67 67 } 68 69 function StripUnits($Value) 68 69 function StripUnits($Value): string 70 70 { 71 71 if (strpos($Value, '-') !== false) $Value = substr($Value, 0, strpos($Value, '-') - 1); // without channel info 72 72 if (substr($Value, -3, 3) == "MHz") $Value = substr($Value, 0, -3); // without MHz unit 73 if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 73 if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 75 75 if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit 76 76 return $Value; 77 77 } 78 78 79 function Run() 79 function Run(): void 80 80 { 81 81 RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration')); -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r874 r887 18 18 class ModuleNetworkConfigRouterOS extends AppModule 19 19 { 20 function __construct( $System)20 function __construct(System $System) 21 21 { 22 22 parent::__construct($System); … … 29 29 } 30 30 31 function DoInstall() 31 function DoInstall(): void 32 32 { 33 33 } 34 34 35 function DoUnInstall() 35 function DoUnInstall(): void 36 36 { 37 37 } 38 38 39 function DoStart() 39 function DoStart(): void 40 40 { 41 41 $this->System->Pages['zdarma'] = 'PageFreeAccess'; 42 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS');43 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');44 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal');45 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch');46 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport');47 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter');48 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT');49 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle');50 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue');42 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS'); 43 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP'); 44 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal'); 45 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch'); 46 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport'); 47 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter'); 48 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT'); 49 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle'); 50 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue'); 51 51 } 52 52 } … … 54 54 class PageFreeAccess extends Page 55 55 { 56 var $FullTitle = 'Přístup zdarma k Internetu'; 57 var $ShortTitle = 'Internet zdarma'; 58 var $ParentClass = 'PagePortal'; 59 var $AddressList = 'free-access'; 60 var $Timeout; 56 public string $AddressList = 'free-access'; 57 public int $Timeout; 61 58 62 function __construct( $System)59 function __construct(System $System) 63 60 { 64 61 parent::__construct($System); 62 $this->FullTitle = 'Přístup zdarma k Internetu'; 63 $this->ShortTitle = 'Internet zdarma'; 64 $this->ParentClass = 'PagePortal'; 65 65 66 $this->Timeout = 24 * 60 * 60; 66 67 } 67 68 68 function Show() 69 function Show(): string 69 70 { 70 71 $IPAddress = GetRemoteAddress(); 71 72 $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>'; 72 if (IsInternetAddr($IPAddress)) { 73 if (IsInternetAddr($IPAddress)) 74 { 73 75 $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'; 74 76 return $Output; … … 117 119 class ScheduleConfigureFreeAccess extends SchedulerTask 118 120 { 119 function Execute() 121 function Execute(): string 120 122 { 121 123 $Output = ''; -
trunk/Modules/NetworkConfigRouterOS/Routerboard.php
r874 r887 19 19 } 20 20 21 function Execute( $Commands)21 function Execute(array $Commands): array 22 22 { 23 23 $Output = array(); … … 44 44 } 45 45 46 function ExecuteBatch( $Commands)46 function ExecuteBatch(string $Commands): string 47 47 { 48 48 $Commands = trim($Commands); … … 65 65 } 66 66 67 function ItemGet( $Path)67 function ItemGet(array $Path): array 68 68 { 69 69 $Result = $this->Execute(implode(' ', $Path).' print'); … … 82 82 } 83 83 84 function ListGet( $Path, $Properties, $Conditions = array())84 function ListGet(array $Path, array $Properties, array $Conditions = array()): array 85 85 { 86 86 $PropertyList = '"'; … … 116 116 } 117 117 118 function ListGetPrint($Path, $Properties, $Conditions = array()) 118 function ListGetPrint($Path, $Properties, $Conditions = array()): array 119 119 { 120 120 $ConditionList = ''; … … 151 151 } 152 152 153 function ListEraseAll( $Path)153 function ListEraseAll(array $Path): void 154 154 { 155 155 $this->Execute(implode(' ', $Path).' { remove [find] }'); 156 156 } 157 157 158 function ListUpdate( $Path, $Properties, $Values, $Condition = array(), $UsePrint = false)158 function ListUpdate(array $Path, array $Properties, array $Values, array $Condition = array(), bool $UsePrint = false): array 159 159 { 160 160 // Get current list from routerboard -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r874 r887 11 11 ); 12 12 13 function Execute($Commands) 13 function Execute($Commands): array 14 14 { 15 15 if (is_array($Commands)) $Commands = implode(';', $Commands); … … 17 17 } 18 18 19 function GetItem($Command) 19 function GetItem($Command): array 20 20 { 21 21 $Result = $this->Execute($Command); … … 25 25 { 26 26 $ResultLineParts = explode(' ', trim($ResultLine)); 27 if ($ResultLineParts[1] {0}== '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes27 if ($ResultLineParts[1][0] == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 28 28 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 29 29 } … … 31 31 } 32 32 33 function GetList($Command, $Properties) 33 function GetList($Command, $Properties): array 34 34 { 35 35 $PropertyList = '"'; … … 55 55 } 56 56 57 function GetSystemResource() 57 function GetSystemResource(): array 58 58 { 59 59 return $this->GetItem('/system resource print'); 60 60 } 61 61 62 function GetFirewallFilterList() 62 function GetFirewallFilterList(): array 63 63 { 64 64 return $this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')); 65 65 } 66 66 67 function GetDHCPServerLeasesList() 67 function GetDHCPServerLeasesList(): array 68 68 { 69 69 return $this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')); -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r874 r887 25 25 } 26 26 27 function EncodeLength($Length) 28 { 29 if ($Length < 0x80) { 27 function EncodeLength(int $Length): int 28 { 29 if ($Length < 0x80) 30 { 30 31 $Length = chr($Length); 31 } else if ($Length < 0x4000) { 32 } else if ($Length < 0x4000) 33 { 32 34 $Length |= 0x8000; 33 35 $Length = chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 34 } else if ($Length < 0x200000) { 36 } else if ($Length < 0x200000) 37 { 35 38 $Length |= 0xC00000; 36 39 $Length = chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 37 } else if ($Length < 0x10000000) { 40 } else if ($Length < 0x10000000) 41 { 38 42 $Length |= 0xE0000000; 39 43 $Length = chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); … … 43 47 } 44 48 45 function ConnectOnce( $IP, $Login, $Password)49 function ConnectOnce(string $IP, string $Login, string $Password): void 46 50 { 47 51 if ($this->Connected) $this->Disconnect(); … … 63 67 } 64 68 65 function Connect( $IP, $Login, $Password)69 function Connect(string $IP, string $Login, string $Password): bool 66 70 { 67 71 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) … … 74 78 } 75 79 76 function Disconnect() 80 function Disconnect(): void 77 81 { 78 82 if ($this->Connected) … … 83 87 } 84 88 85 function ParseResponse($Response) 86 { 87 if (is_array($Response)) { 89 function ParseResponse(array $Response): array 90 { 91 if (is_array($Response)) 92 { 88 93 $Parsed = array(); 89 94 $Current = null; 90 95 $SingleValue = null; 91 96 $count = 0; 92 foreach ($Response as $x) { 97 foreach ($Response as $x) 98 { 93 99 if (in_array($x, array( 94 100 '!fatal', 95 101 '!re', 96 102 '!trap' 97 ))) { 98 if ($x == '!re') { 103 ))) 104 { 105 if ($x == '!re') 106 { 99 107 $Current =& $Parsed[]; 100 108 } else 101 109 $Current =& $Parsed[$x][]; 102 } else if ($x != '!done') { 103 if (preg_match_all('/[^=]+/i', $x, $Matches)) { 110 } else if ($x != '!done') 111 { 112 if (preg_match_all('/[^=]+/i', $x, $Matches)) 113 { 104 114 if ($Matches[0][0] == 'ret') { 105 115 $SingleValue = $Matches[0][1]; … … 109 119 } 110 120 } 111 if (empty($Parsed) && !is_null($SingleValue)) { 121 if (empty($Parsed) && !is_null($SingleValue)) 122 { 112 123 $Parsed = $SingleValue; 113 124 } … … 117 128 } 118 129 119 function ArrayChangeKeyName(&$array) 120 { 121 if (is_array($array)) { 122 foreach ($array as $k => $v) { 130 function ArrayChangeKeyName(array &$array): array 131 { 132 if (is_array($array)) 133 { 134 foreach ($array as $k => $v) 135 { 123 136 $tmp = str_replace("-", "_", $k); 124 137 $tmp = str_replace("/", "_", $tmp); 125 if ($tmp) { 138 if ($tmp) 139 { 126 140 $array_new[$tmp] = $v; 127 } else { 141 } else 142 { 128 143 $array_new[$k] = $v; 129 144 } 130 145 } 131 146 return $array_new; 132 } else { 147 } else 148 { 133 149 return $array; 134 150 } 135 151 } 136 152 137 function Read( $Parse = true)153 function Read(bool $Parse = true): array 138 154 { 139 155 $Line = ''; 140 156 $Response = array(); 141 while (true) { 157 while (true) 158 { 142 159 // Read the first byte of input which gives us some or all of the length 143 160 // of the remaining reply. … … 149 166 // If the fourth bit is set, we need to remove anything left in the first byte 150 167 // and then read in yet another byte. 151 if ($Byte & 0x80) { 152 if (($Byte & 0xc0) == 0x80) { 168 if ($Byte & 0x80) 169 { 170 if (($Byte & 0xc0) == 0x80) 171 { 153 172 $Length = (($Byte & 63) << 8) + ord(fread($this->Socket, 1)); 154 } else { 155 if (($Byte & 0xe0) == 0xc0) { 173 } else 174 { 175 if (($Byte & 0xe0) == 0xc0) 176 { 156 177 $Length = (($Byte & 31) << 8) + ord(fread($this->Socket, 1)); 157 178 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 158 } else { 159 if (($Byte & 0xf0) == 0xe0) { 179 } else 180 { 181 if (($Byte & 0xf0) == 0xe0) 182 { 160 183 $Length = (($Byte & 15) << 8) + ord(fread($this->Socket, 1)); 161 184 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 162 185 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 163 } else { 186 } else 187 { 164 188 $Length = ord(fread($this->Socket, 1)); 165 189 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); … … 169 193 } 170 194 } 171 } else { 195 } else 196 { 172 197 $Length = $Byte; 173 198 } 174 199 // If we have got more characters to read, read them in. 175 if ($Length > 0) { 200 if ($Length > 0) 201 { 176 202 $Line = ''; 177 203 $RetLen = 0; 178 while ($RetLen < $Length) { 204 while ($RetLen < $Length) 205 { 179 206 $ToRead = $Length - $RetLen; 180 207 $Line .= fread($this->Socket, $ToRead); … … 196 223 } 197 224 198 function Write( $Command, $Param2 = true)225 function Write(string $Command, bool $Param2 = true): bool 199 226 { 200 227 if ($Command) 201 228 { 202 229 $Data = explode("\n", $Command); 203 foreach ($Data as $Com) { 230 foreach ($Data as $Com) 231 { 204 232 $Com = trim($Com); 205 233 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 206 234 } 207 if (gettype($Param2) == 'integer') { 235 if (gettype($Param2) == 'integer') 236 { 208 237 fwrite($this->Socket, $this->EncodeLength(strlen('.tag='.$Param2)).'.tag='.$Param2.chr(0)); 209 238 } else if (gettype($Param2) == 'boolean') … … 214 243 } 215 244 216 function Comm( $Com, $Arr = array())245 function Comm(string $Com, array $Arr = array()): array 217 246 { 218 247 $Count = count($Arr); 219 248 $this->write($Com, !$Arr); 220 249 $i = 0; 221 foreach ($Arr as $k => $v) { 222 switch ($k[0]) { 250 foreach ($Arr as $k => $v) 251 { 252 switch ($k[0]) 253 { 223 254 case "?": 224 255 $el = "$k=$v"; -
trunk/Modules/NetworkShare/NetworkShare.php
r738 r887 7 7 class ModuleNetworkShare extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->RegisterPage( 'share', 'SharePage');30 $this->System->RegisterPage(['share'], 'SharePage'); 31 31 } 32 32 } -
trunk/Modules/NetworkShare/SharePage.php
r874 r887 3 3 class SharePage extends Page 4 4 { 5 var $FullTitle = 'Prohledávání sdílených souborů';6 var $ShortTitle = 'Sdílené soubory';7 var $ParentClass = 'PagePortal';8 5 var $Dependencies = array('Log'); 9 6 var $MaxNesting = 20; // Maximální vnoření … … 20 17 ); 21 18 19 function __construct(System $System) 20 { 21 parent::__construct($System); 22 $this->FullTitle = 'Prohledávání sdílených souborů'; 23 $this->ShortTitle = 'Sdílené soubory'; 24 $this->ParentClass = 'PagePortal'; 25 } 26 22 27 function ShowTime() 23 28 { … … 66 71 } 67 72 68 function Show() 69 { 70 if (! $this->System->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění';73 function Show(): string 74 { 75 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění'; 71 76 72 77 // If not only online checkbox checked … … 102 107 // Log search 103 108 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 104 $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);109 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']); 105 110 106 111 // Zobrazení formuláře -
trunk/Modules/NetworkTopology/NetworkTopology.php
r874 r887 3 3 class PageNetworkTopology extends Page 4 4 { 5 var $FullTitle = 'Grafické zobrazení topologie sítě';6 var $ShortTitle = 'Topologie sítě';7 var $ParentClass = 'PagePortal';8 5 var $TopHostName = 'NIX-ROUTER'; 9 6 10 function Show() 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Grafické zobrazení topologie sítě'; 11 $this->ShortTitle = 'Topologie sítě'; 12 $this->ParentClass = 'PagePortal'; 13 } 14 15 function Show(): string 11 16 { 12 17 if (count($this->System->PathItems) > 1) … … 132 137 class ModuleNetworkTopology extends AppModule 133 138 { 134 function __construct( $System)139 function __construct(System $System) 135 140 { 136 141 parent::__construct($System); … … 143 148 } 144 149 145 function DoInstall() 150 function DoInstall(): void 146 151 { 147 152 } 148 153 149 function DoUnInstall() 154 function DoUnInstall(): void 150 155 { 151 156 } 152 157 153 function DoStart() 158 function DoStart(): void 154 159 { 155 $this->System->RegisterPage( 'topologie', 'PageNetworkTopology');160 $this->System->RegisterPage(['topologie'], 'PageNetworkTopology'); 156 161 } 157 162 } -
trunk/Modules/News/Import/Vismo.php
r878 r887 3 3 class NewsSourceVismo extends NewsSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/News/ImportKinoVatra.php
r873 r887 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/../../Application/ System.php');4 $System = new System();3 include_once(dirname(__FILE__).'/../../Application/Core.php'); 4 $System = new Core(); 5 5 $System->ShowPage = false; 6 6 $System->Run(); -
trunk/Modules/News/ImportTvBeskyd.php
r873 r887 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/../../Application/ System.php');3 include_once(dirname(__FILE__).'/../../Application/Core.php'); 4 4 $System = new Core(); 5 5 $System->ShowPage = false; -
trunk/Modules/News/News.php
r878 r887 13 13 class ModuleNews extends AppModule 14 14 { 15 var$NewsCountPerCategory = 3;16 var$UploadedFilesFolder = 'files/news/';17 18 function __construct( $System)15 public int $NewsCountPerCategory = 3; 16 public string $UploadedFilesFolder = 'files/news/'; 17 18 function __construct(System $System) 19 19 { 20 20 parent::__construct($System); … … 28 28 } 29 29 30 function DoInstall() 31 { 32 } 33 34 function DoUnInstall() 35 { 36 } 37 38 function DoStart() 39 { 40 $this->System->RegisterPage('aktuality', 'PageNews'); 41 $this->System->RegisterPage(array('aktuality', 'aktualizace'), 'PageNewsUpdate'); 30 function DoInstall(): void 31 { 32 } 33 34 function DoUnInstall(): void 35 { 36 } 37 38 function DoStart(): void 39 { 40 $this->System->RegisterPage(['aktuality'], 'PageNews'); 41 $this->System->RegisterPage(['aktuality', 'subscription'], 'PageNewsSubscription'); 42 $this->System->RegisterPage(['aktuality', 'rss'], 'PageNewsRss'); 43 $this->System->RegisterPage(['aktuality', 'aktualizace'], 'PageNewsUpdate'); 42 44 $this->System->FormManager->RegisterClass('News', array( 43 45 'Title' => 'Aktualita', … … 86 88 if ($this->System->ModuleManager->ModulePresent('Search')) 87 89 { 88 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));89 } 90 } 91 92 function ShowNews( $Category, $ItemCount, $DaysAgo)90 ModuleSearch::Cast($this->System->GetModule('Search'))->RegisterSearch('Novinky', 'News', array('Title', 'Content')); 91 } 92 } 93 94 function ShowNews(string $Category, int $ItemCount, int $DaysAgo): string 93 95 { 94 96 $ItemCount = abs($ItemCount); … … 98 100 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 99 101 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 100 if ( $this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))102 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category)) 101 103 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 102 104 $Output .= '</div></div><div class="Content">'; … … 139 141 } 140 142 141 function LoadSettingsFromCookies() 143 function LoadSettingsFromCookies(): void 142 144 { 143 145 // Initialize default news setting … … 163 165 } 164 166 165 function Show() 167 function Show(): string 166 168 { 167 169 $Output = ''; … … 197 199 } 198 200 199 function ShowCustomizeMenu() 201 function ShowCustomizeMenu(): string 200 202 { 201 203 $Output = '<form action="?Action=CustomizeNewsSave" method="post">'; … … 220 222 } 221 223 222 function CustomizeSave() 224 function CustomizeSave(): void 223 225 { 224 226 $Checkbox = array('' => 0, 'on' => 1); … … 245 247 } 246 248 247 function ModifyContent( $Content)249 function ModifyContent(string $Content): string 248 250 { 249 251 $Result = ''; … … 254 256 { 255 257 $I = strpos($Content, 'http://'); 256 if (($I > 0) and ($Content {$I - 1}!= '"'))258 if (($I > 0) and ($Content[$I - 1] != '"')) 257 259 { 258 260 $Result .= substr($Content, 0, $I); … … 272 274 return $Result; 273 275 } 276 277 static function Cast(AppModule $AppModule): ModuleNews 278 { 279 if ($AppModule instanceof ModuleNews) 280 { 281 return $AppModule; 282 } 283 throw new Exception('Expected ModuleNews type but got '.gettype($AppModule)); 284 } 274 285 } -
trunk/Modules/News/NewsPage.php
r878 r887 3 3 class PageNews extends Page 4 4 { 5 var $FullTitle = 'Aktualní informace'; 6 var $ShortTitle = 'Aktuality'; 7 var $ParentClass = 'PagePortal'; 8 var $UploadedFilesFolder; 9 10 function Show() 11 { 12 $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder; 13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'subscription') return $this->ShowSubscription(); 16 else if ($this->System->PathItems[1] == 'rss') return $this->ShowRSS(); 17 else return PAGE_NOT_FOUND; 18 } else return $this->ShowMain(); 19 } 20 21 function ShowView() 22 { 23 $Output = ''; 24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Aktualní informace'; 9 $this->ShortTitle = 'Aktuality'; 10 $this->ParentClass = 'PagePortal'; 11 } 12 13 function ShowView(): string 14 { 15 $Output = ''; 16 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 25 17 else 26 18 { … … 35 27 else $Author = $Row['Name']; 36 28 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 29 if ((ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == $Row['User']) and 30 (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 38 31 { 39 32 $Output .= '<div class="Action">'; … … 42 35 $Output .= '</div>'; 43 36 } 44 $Output .= '</div><div class="Content">'. $this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';37 $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />'; 45 38 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 46 39 if ($Row['Enclosure'] != '') … … 50 43 foreach ($Enclosures as $Enclosure) 51 44 { 52 if (file_exists( $this->UploadedFilesFolder.$Enclosure))53 $Output .= ' <a href="'.$this->System->Link('/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';45 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 46 $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 54 47 } 55 48 } … … 60 53 } 61 54 62 function ShowAdd() 63 { 64 $Output = ''; 65 $Category = $this->GetCategory(); 66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 55 function ShowAdd(): string 56 { 57 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 58 $Output = ''; 59 $Category = $this->GetCategory(); 60 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 67 61 { 68 62 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 75 69 while ($DbRow = $DbResult->fetch_array()) 76 70 { 77 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))71 if ($User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 78 72 { 79 73 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; … … 96 90 } 97 91 98 function ShowAdd2() 99 { 92 function ShowAdd2(): string 93 { 94 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 100 95 $Output = ''; 101 96 $RemoteAddr = GetRemoteAddress(); 102 97 $Category = $this->GetCategory(); 103 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))98 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 104 99 { 105 100 // Process uploaded file … … 110 105 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 111 106 { 112 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);107 $UploadedFilePath = ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 113 108 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 114 109 { … … 124 119 $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'], 125 120 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 126 'Enclosure' => $Enclosures, 'Author' => $ this->System->User->User['Name'],127 'User' => $ this->System->User->User['Id'], 'Link' => $_POST['link']));121 'Enclosure' => $Enclosures, 'Author' => $User->User['Name'], 122 'User' => $User->User['Id'], 'Link' => $_POST['link'])); 128 123 $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />'; 129 124 $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; 130 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);125 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 131 126 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 132 127 return $Output; 133 128 } 134 129 135 function GetPageHeader() 130 function GetPageHeader(): string 136 131 { 137 132 return '<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'. … … 152 147 } 153 148 154 function ShowEdit() 155 { 156 $Output = ''; 157 $Category = $this->GetCategory(); 158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 149 function ShowEdit(): string 150 { 151 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 152 $Output = ''; 153 $Category = $this->GetCategory(); 154 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 159 155 { 160 156 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 161 157 $Row = $DbResult->fetch_array(); 162 if (($ this->System->User->User['Id'] == $Row['User']))158 if (($User->User['Id'] == $Row['User'])) 163 159 { 164 160 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 177 173 } 178 174 179 function ShowUpdate() 180 { 175 function ShowUpdate(): string 176 { 177 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 181 178 $Output = ''; 182 179 $RemoteAddr = GetRemoteAddress(); 183 180 $Category = $this->GetCategory(); 184 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))181 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 185 182 { 186 183 $_POST['id'] = $_POST['id'] * 1; … … 189 186 { 190 187 $Row = $DbResult->fetch_array(); 191 if ($ this->System->User->User['Id'] == $Row['User'])188 if ($User->User['Id'] == $Row['User']) 192 189 { 193 190 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], … … 201 198 } 202 199 203 function ShowDelete() 204 { 205 $Output = ''; 206 $Category = $this->GetCategory(); 207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 200 function ShowDelete(): string 201 { 202 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 203 $Output = ''; 204 $Category = $this->GetCategory(); 205 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 208 206 { 209 207 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 210 208 $Row = $DbResult->fetch_array(); 211 if ($ this->System->User->User['Id'] == $Row['User'])209 if ($User->User['Id'] == $Row['User']) 212 210 { 213 211 // TODO: Make upload using general File class … … 218 216 foreach ($Enclosures as $Enclosure) 219 217 { 220 if (file_exists( $this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);218 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) unlink(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure); 221 219 } 222 220 } … … 228 226 } 229 227 230 function ShowList() 231 { 232 $Output = ''; 233 $Category = $this->GetCategory(); 234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 228 function ShowList(): string 229 { 230 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 231 $Output = ''; 232 $Category = $this->GetCategory(); 233 if ($User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 235 234 { 236 235 $PerPage = 20; … … 250 249 else $Author = $Row['Name']; 251 250 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 252 if (($ this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))251 if (($User->User['Id'] == $Row['User']) and ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 253 252 { 254 253 $Output .= '<div class="Action">'; … … 257 256 $Output .= '</div>'; 258 257 } 259 $Output .= '</div><div class="Content">'. $this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';258 $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />'; 260 259 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 261 260 if ($Row['Enclosure'] != '') … … 265 264 foreach ($Enclosures as $Enclosure) 266 265 { 267 if (file_exists( $this->UploadedFilesFolder.$Enclosure))268 $Output .= ' <a href="'.$this->System->Link('/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';266 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 267 $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 269 268 } 270 269 } … … 277 276 } 278 277 279 function GetCategory() 278 function GetCategory(): array 280 279 { 281 280 $Category = array('Id' => 1); // Default category … … 292 291 } 293 292 294 function Show Main()293 function Show(): string 295 294 { 296 295 $Output = ''; … … 306 305 return $Output; 307 306 } 308 309 function ShowSubscription() 307 } 308 309 class PageNewsUpdate extends Page 310 { 311 function __construct(System $System) 312 { 313 parent::__construct($System); 314 $this->FullTitle = 'Aktualizace aktualit'; 315 $this->ShortTitle = 'Aktualizace aktualit'; 316 $this->ParentClass = 'PageNews'; 317 } 318 319 function Show(): string 320 { 321 $NewsSources = new NewsSources(); 322 $NewsSources->Database = $this->Database; 323 if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']); 324 else $Output = $NewsSources->Parse(); 325 return $Output; 326 } 327 } 328 329 class PageNewsSubscription extends Page 330 { 331 function __construct(System $System) 332 { 333 parent::__construct($System); 334 $this->FullTitle = 'Odběry aktualit'; 335 $this->ShortTitle = 'Odběry aktualit'; 336 $this->ParentClass = 'PageNews'; 337 } 338 339 function Show(): string 310 340 { 311 341 if (array_key_exists('build', $_GET)) … … 333 363 return $Output; 334 364 } 335 336 function ShowRSS() 365 } 366 367 class PageNewsRss extends Page 368 { 369 function __construct(System $System) 370 { 371 parent::__construct($System); 372 $this->FullTitle = 'RSS kanál aktualit'; 373 $this->ShortTitle = 'Aktuality RSS'; 374 $this->ParentClass = 'PageNews'; 375 } 376 377 function Show(): string 337 378 { 338 379 $this->ClearPage = true; … … 409 450 foreach ($Enclosures as $Enclosure) 410 451 { 411 if (file_exists( $this->UploadedFilesFolder.$Enclosure))412 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';452 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 453 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 413 454 } 414 455 } … … 432 473 } 433 474 } 434 435 class PageNewsUpdate extends Page436 {437 function __construct($System)438 {439 parent::__construct($System);440 $this->FullTitle = 'Aktualizace aktualit';441 $this->ShortTitle = 'Aktualizace aktualit';442 $this->ParentClass = 'PageNews';443 }444 445 function Show()446 {447 $NewsSources = new NewsSources();448 $NewsSources->Database = $this->Database;449 if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']);450 else $Output = $NewsSources->Parse();451 return $Output;452 }453 }454 -
trunk/Modules/News/NewsSource.php
r878 r887 1 1 <?php 2 2 3 function GetTextBetween( &$Text, $Start, $End)3 function GetTextBetween(string &$Text, string $Start, string $End): string 4 4 { 5 5 $Result = ''; … … 34 34 } 35 35 36 function HumanDateTimeToTime( $DateTime)36 function HumanDateTimeToTime(string $DateTime): int 37 37 { 38 38 if ($DateTime == '') return NULL; … … 49 49 } 50 50 51 function HumanDateToTime( $Date)51 function HumanDateToTime(string $Date): int 52 52 { 53 53 if ($Date == '') return NULL; … … 55 55 } 56 56 57 function GetUrlBase( $Url)57 function GetUrlBase(string $Url): string 58 58 { 59 59 $Result = parse_url($Url); … … 63 63 class NewsSources 64 64 { 65 public $Database;65 public Database $Database; 66 66 67 67 function Parse($Id = null) … … 94 94 class NewsSource 95 95 { 96 public $Name;97 public $URL;96 public string $Name; 97 public string $URL; 98 98 public $Method; 99 public $Id;100 public $Database;101 public $NewsItems;102 public $AddedCount;99 public int $Id; 100 public Database $Database; 101 public array $NewsItems; 102 public int $AddedCount; 103 103 public $Category; 104 104 … … 109 109 } 110 110 111 function Import() 111 function Import(): string 112 112 { 113 113 return ''; 114 114 } 115 115 116 function DoImport() 116 function DoImport(): string 117 117 { 118 118 $this->NewsItems = array(); … … 133 133 class NewsItem 134 134 { 135 var$Database;136 var$Title = '';137 var$Content = '';138 var $Date = '';139 var$Link = '';140 var$Category = '';141 var$Author = '';142 var$IP = '';143 var$Enclosure = '';135 public Database $Database; 136 public string $Title = ''; 137 public string $Content = ''; 138 public int $Date = 0; 139 public string $Link = ''; 140 public string $Category = ''; 141 public string $Author = ''; 142 public string $IP = ''; 143 public string $Enclosure = ''; 144 144 145 function AddIfNotExist() 145 function AddIfNotExist(): int 146 146 { 147 147 $Where = '(`Title` = "'.$this->Database->real_escape_string($this->Title).'") AND '. -
trunk/Modules/Notify/Notify.php
r874 r887 5 5 class ModuleNotify extends AppModule 6 6 { 7 var$Checks;8 9 function __construct( $System)7 public array $Checks; 8 9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 19 19 } 20 20 21 function DoStart() 21 function DoStart(): void 22 22 { 23 23 $this->System->FormManager->RegisterClass('NotifyUser', array( … … 38 38 ), 39 39 )); 40 $this->System->RegisterCommandLine('notify', array($this, 'RunCheck'));41 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log',42 'Channel' => 'notifylog', 'Callback' => array( 'ModuleNotify', 'ShowLogRSS'),40 $this->System->RegisterCommandLine('notify', 'Perform notifications processing.', array($this, 'RunCheck')); 41 ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Notify log', 42 'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'), 43 43 'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS'))); 44 44 } 45 45 46 function RegisterCheck( $Name, $Callback)46 function RegisterCheck(string $Name, callable $Callback): void 47 47 { 48 48 if (array_key_exists($Name, $this->Checks)) … … 51 51 } 52 52 53 function UnregisterCheck( $Name)53 function UnregisterCheck(string $Name): void 54 54 { 55 55 if (!array_key_exists($Name, $this->Checks)) … … 58 58 } 59 59 60 function Check() 60 function Check(): string 61 61 { 62 62 $Output = ''; … … 123 123 } 124 124 125 function RunCheck( $Parameters)125 function RunCheck(array $Parameters): void 126 126 { 127 127 RepeatFunction(30, array($this, 'Check')); 128 128 } 129 129 130 function DoInstall() 130 function DoInstall(): void 131 131 { 132 132 $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` ( … … 160 160 } 161 161 162 function DoUninstall() 162 function DoUninstall(): void 163 163 { 164 164 $this->Database->query('DROP TABLE `NotifyUser`'); … … 166 166 } 167 167 168 function ShowLogRSS() 168 function ShowLogRSS(): string 169 169 { 170 170 $this->ClearPage = true; … … 197 197 return $RSS->Generate(); 198 198 } 199 200 static function Cast(AppModule $AppModule): ModuleNotify 201 { 202 if ($AppModule instanceof ModuleNotify) 203 { 204 return $AppModule; 205 } 206 throw new Exception('Expected ModuleNotify type but got '.gettype($AppModule)); 207 } 199 208 } -
trunk/Modules/OpeningHours/OpeningHours.php
r874 r887 5 5 class PageSubjectOpenTime extends Page 6 6 { 7 var $FullTitle = 'Otvírací doby místních subjektů'; 8 var $ShortTitle = 'Otvírací doby'; 9 var $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'); 10 var $EventType = array('Žádný', 'Otevřeno', 'Zavřeno'); 11 var $ParentClass = 'PagePortal'; 12 13 function ToHumanTime($Time) 7 public array $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'); 8 public array $EventType = array('Žádný', 'Otevřeno', 'Zavřeno'); 9 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Otvírací doby místních subjektů'; 14 $this->ShortTitle = 'Otvírací doby'; 15 $this->ParentClass = 'PagePortal'; 16 } 17 18 function ToHumanTime(float $Time): string 14 19 { 15 20 $Hours = floor($Time / 60); … … 20 25 } 21 26 22 function ToHumanTime2( $Time)27 function ToHumanTime2(float $Time): string 23 28 { 24 29 $Days = floor($Time / 24 / 60); … … 34 39 } 35 40 36 function EditSubject( $Id)37 { 38 if ( $this->System->User->CheckPermission('OpeningHours', 'Edit'))41 function EditSubject(int $Id): string 42 { 43 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit')) 39 44 { 40 45 $Output = '<div class="Centred">'; … … 73 78 } 74 79 75 function SaveSubject($Id) 76 { 77 global $Config; 78 80 function SaveSubject(int $Id): string 81 { 79 82 $Output = ''; 80 if ( $this->System->User->CheckPermission('OpeningHours', 'Edit'))83 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit')) 81 84 { 82 85 $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id); … … 100 103 $Output .= 'Uloženo'; 101 104 102 $File = new File($this-> Database);105 $File = new File($this->System); 103 106 104 107 // Delete old file … … 114 117 } 115 118 116 function ShowAll() 119 function ShowAll(): string 117 120 { 118 121 $Output = '<div class="Centred">'; … … 138 141 } 139 142 } 140 //print_r($Events);141 143 142 144 // Calculate time to next event … … 190 192 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 193 192 if ( $this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))194 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 195 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; 194 196 $Output .= '<br />'; … … 198 200 } 199 201 200 function Show() 202 function Show(): string 201 203 { 202 204 if (count($this->System->PathItems) > 1) … … 215 217 class ModuleOpeningHours extends AppModule 216 218 { 217 function __construct( $System)219 function __construct(System $System) 218 220 { 219 221 parent::__construct($System); … … 226 228 } 227 229 228 function DoStart() 229 { 230 $this->System->Pages['otviraci-doby'] = 'PageSubjectOpenTime'; 231 } 232 233 function DoInstall() 234 { 235 } 236 237 function DoUnInstall() 230 function DoStart(): void 231 { 232 $this->System->RegisterPage(['otviraci-doby'], 'PageSubjectOpenTime'); 233 } 234 235 function DoStop(): void 236 { 237 $this->System->UnregisterPage(['otviraci-doby']); 238 } 239 240 function DoInstall(): void 241 { 242 } 243 244 function DoUnInstall(): void 238 245 { 239 246 } -
trunk/Modules/Portal/Portal.php
r874 r887 5 5 class ModulePortal extends AppModule 6 6 { 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 16 16 } 17 17 18 function DoInstall() 19 { 20 } 21 22 function DoUninstall() 23 { 24 } 25 26 function DoStart() 27 { 28 $this->System->RegisterPage( '', 'PagePortal');18 function DoInstall(): void 19 { 20 } 21 22 function DoUninstall(): void 23 { 24 } 25 26 function DoStart(): void 27 { 28 $this->System->RegisterPage([''], 'PagePortal'); 29 29 $this->System->FormManager->RegisterClass('MemberOptions', array( 30 30 'Title' => 'Nastavení zákazníka', … … 42 42 ), 43 43 )); 44 $this->System->ModuleManager->Modules['User']->UserPanel[] = array('PagePortal', 'UserPanel');45 } 46 47 function DoStop() 44 ModuleUser::Cast($this->System->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel'); 45 } 46 47 function DoStop(): void 48 48 { 49 49 } … … 52 52 class PagePortal extends Page 53 53 { 54 var $FullTitle = 'Zděchovský rozcestník'; 55 var $ShortTitle = 'Rozcestník'; 56 57 function ShowActions($ActionGroup) 54 function __construct(System $System) 55 { 56 parent::__construct($System); 57 $this->FullTitle = 'Zděchovský rozcestník'; 58 $this->ShortTitle = 'Rozcestník'; 59 } 60 61 function ShowActions(array $ActionGroup): string 58 62 { 59 63 $Output = ''; … … 67 71 } 68 72 69 function InfoBar() 73 function InfoBar(): string 70 74 { 71 75 $Output2 = ''; … … 98 102 //$Output .= 'Server běží: '.$this->GetServerUptime().' '; 99 103 100 if ( $this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))101 { 102 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='. $this->System->User->User['Id'].')');104 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) 105 { 106 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 103 107 if ($DbResult->num_rows > 0) 104 108 { … … 112 116 } 113 117 114 function UserPanel() 115 { 118 function UserPanel(): string 119 { 120 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 116 121 $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />'; 117 if ($ this->System->User->CheckPermission('Finance', 'MemberOptions'))122 if ($User->CheckPermission('Finance', 'MemberOptions')) 118 123 $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />'; 119 if ($ this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))124 if ($User->CheckPermission('Finance', 'DisplaySubjectState')) 120 125 $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />'; 121 if ($ this->System->User->CheckPermission('Network', 'RegistredHostList'))126 if ($User->CheckPermission('Network', 'RegistredHostList')) 122 127 $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />'; 123 if ($ this->System->User->CheckPermission('News', 'Insert'))128 if ($User->CheckPermission('News', 'Insert')) 124 129 $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />'; 125 if ($ this->System->User->CheckPermission('EatingPlace', 'Edit'))130 if ($User->CheckPermission('EatingPlace', 'Edit')) 126 131 $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />'; 127 if ($ this->System->User->CheckPermission('Finance', 'Manage'))132 if ($User->CheckPermission('Finance', 'Manage')) 128 133 $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />'; 129 if ($ this->System->User->CheckPermission('IS', 'Manage'))134 if ($User->CheckPermission('IS', 'Manage')) 130 135 $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />'; 131 136 return $Output; 132 137 } 133 138 134 function WebcamPanel() 135 { 136 $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage();137 return $Output; 138 } 139 140 function MeteoPanel() 139 function WebcamPanel(): string 140 { 141 $Output = ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ShowImage(); 142 return $Output; 143 } 144 145 function MeteoPanel(): string 141 146 { 142 147 $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>'; … … 144 149 } 145 150 146 function OnlineHostList() 151 function OnlineHostList(): string 147 152 { 148 153 $Output = '<span style="font-size: smaller;">'; … … 158 163 } 159 164 160 function ShowBadPayerList() 161 { 162 $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';163 $DbResult = $ Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');165 function ShowBadPayerList(): string 166 { 167 $Output = '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">'; 168 $DbResult = $this->Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money'); 164 169 while ($Row = $DbResult->fetch_array()) 165 170 { … … 170 175 } 171 176 172 function Panel( $Title, $Content, $Menu = array())177 function Panel(string $Title, string $Content, array $Menu = array()): string 173 178 { 174 179 if (count($Menu) > 0) 180 { 175 181 foreach ($Menu as $Item) 182 { 176 183 $Title .= '<div class="Action">'.$Item.'</div>'; 184 } 185 } 177 186 return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'; 178 187 } 179 188 180 function Show() 189 function Show(): string 181 190 { 182 191 $Output = ''; … … 186 195 if ($Action == 'CustomizeNewsSave') 187 196 { 188 $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();197 $Output .= ModuleNews::Cast($this->System->GetModule('News'))->CustomizeSave(); 189 198 } else 190 199 if ($Action == 'MemberOptions') 191 200 { 192 201 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '. 193 'WHERE `User`='. $this->System->User->User['Id']);202 'WHERE `User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']); 194 203 while ($CustomerUserRel = $DbResult->fetch_assoc()) 195 204 { … … 218 227 $Form->Values['FamilyMemberCount'] = 0; 219 228 220 $DbResult = $this->Database->update('Member', 'Id='.$this->System->User->User['Member'], 229 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 230 $DbResult = $this->Database->update('Member', 'Id='.$User->User['Member'], 221 231 array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'])); 222 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$ this->System->User->User['Member']);232 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$User->User['Member']); 223 233 $Member = $DbResult->fetch_assoc(); 224 234 $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], … … 228 238 'DIC' => $Form->Values['DIC'])); 229 239 $Output .= $this->SystemMessage('Nastavení', 'Nastavení zákazníka uloženo.'); 230 $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',240 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno', 231 241 $Form->Values['Name']); 232 242 $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '. 233 243 'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '. 234 244 'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '. 235 'ON Subject.Id = Member.Subject WHERE Member.Id='.$ this->System->User->User['Member']);245 'ON Subject.Id = Member.Subject WHERE Member.Id='.$User->User['Member']); 236 246 $DbRow = $DbResult->fetch_array(); 237 247 foreach ($Form->Definition['Items'] as $Index => $Item) … … 246 256 } 247 257 248 function ShowMain() 258 function ShowMain(): string 249 259 { 250 260 $Output = ''; … … 270 280 else if ($Panel['Module'] == 'UserOptions') 271 281 { 272 //if ( $this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());282 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel()); 273 283 } else 274 284 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel()); 275 285 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel()); 276 286 else if ($Panel['Module'] == 'NewsGroupList') 277 $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));287 $Output .= $this->Panel('Aktuality', ModuleNews::Cast($this->System->GetModule('News'))->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>')); 278 288 } 279 289 $Output .= '</td>'; -
trunk/Modules/RSS/RSS.php
r874 r887 3 3 class ModuleRSS extends AppModule 4 4 { 5 var$RSSChannels;5 public array $RSSChannels; 6 6 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 17 17 } 18 18 19 function Start()19 function DoStart(): void 20 20 { 21 $this->System->RegisterPage( 'rss', 'PageRSS');21 $this->System->RegisterPage(['rss'], 'PageRSS'); 22 22 $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader')); 23 23 } 24 24 25 function RegisterRSS( $Channel, $Pos = NULL, $Callback = NULL)25 function RegisterRSS(array $Channel, $Pos = NULL, $Callback = NULL): void 26 26 { 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; 28 28 29 29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 30 else { 30 else 31 { 31 32 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); 32 33 } 33 34 } 34 35 35 function UnregisterRSS($ChannelName) 36 function UnregisterRSS($ChannelName): void 36 37 { 37 38 unset($this->RSSChannels[$ChannelName]); … … 39 40 } 40 41 41 function ShowRSSHeader() 42 function ShowRSSHeader(): string 42 43 { 43 44 $Output = ''; 44 45 foreach ($this->RSSChannels as $Channel) 45 46 { 46 //if ( $this->System->User->Licence($Channel['Permission']))47 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence($Channel['Permission'])) 47 48 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 48 49 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; … … 50 51 return $Output; 51 52 } 53 54 static function Cast(AppModule $AppModule): ModuleRSS 55 { 56 if ($AppModule instanceof ModuleRSS) 57 { 58 return $AppModule; 59 } 60 throw new Exception('Expected ModuleRSS type but got '.gettype($AppModule)); 61 } 52 62 } 53 63 54 64 class PageRSS extends Page 55 65 { 56 function Show() 66 function Show(): string 57 67 { 58 68 $this->ClearPage = true; … … 62 72 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 63 73 else $Token = ''; 64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))74 if (array_key_exists($ChannelName, ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels)) 65 75 { 66 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];67 if ( $this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or68 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token))76 $Channel = ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels[$ChannelName]; 77 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 78 ModuleUser::Cast($this->System->GetModule('User'))->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 69 79 { 70 80 if (is_string($Channel['Callback'][0])) -
trunk/Modules/Scheduler/Scheduler.php
r874 r887 3 3 class ModuleScheduler extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Scheduler', array( … … 48 48 'Filter' => '1', 49 49 )); 50 $this->System->RegisterCommandLine('run-scheduler', array($this->System->ModuleManager->Modules['Scheduler'], 'Run')); 50 $this->System->RegisterCommandLine('run-scheduler', 'Runs scheduled tasks', 51 array(ModuleScheduler::Cast($this->System->GetModule('Scheduler')), 'Run')); 51 52 } 52 53 53 function DoInstall() 54 function DoInstall(): void 54 55 { 55 56 } 56 57 57 function DoUnInstall() 58 function DoUnInstall(): void 58 59 { 59 60 } 60 61 61 function Run( $Parameters)62 function Run(array $Parameters): void 62 63 { 63 64 while (true) … … 100 101 } 101 102 } 103 104 static function Cast(AppModule $AppModule): ModuleScheduler 105 { 106 if ($AppModule instanceof ModuleScheduler) 107 { 108 return $AppModule; 109 } 110 throw new Exception('Expected ModuleScheduler type but got '.gettype($AppModule)); 111 } 102 112 } 103 113 104 114 class SchedulerTask extends Model 105 115 { 106 function Execute() 116 function Execute(): string 107 117 { 118 return ''; 108 119 } 109 120 } 110 121 111 112 122 class ScheduleTaskTest extends SchedulerTask 113 123 { 114 function Execute() 124 function Execute(): string 115 125 { 116 126 $Output = '#'; -
trunk/Modules/Search/Search.php
r874 r887 3 3 class PageSearch extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 $Output = ''; … … 21 21 '</form>'; 22 22 if ($Text != '') 23 foreach ( $this->System->ModuleManager->Modules['Search']->Items as $Item)23 foreach (ModuleSearch::Cast($this->System->GetModule('Search'))->Items as $Item) 24 24 { 25 25 $Columns = ''; … … 33 33 $Condition = substr($Condition, 3); 34 34 $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '. 35 $this->System->ModuleManager->Modules['Search']->MaxItemCount);35 ModuleSearch::Cast($this->System->GetModule('Search'))->MaxItemCount); 36 36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>'; 37 37 while ($Row = $DbResult->fetch_assoc()) … … 49 49 class ModuleSearch extends AppModule 50 50 { 51 var$Items;52 var$MaxItemCount;51 public array $Items; 52 public int $MaxItemCount; 53 53 54 function __construct( $System)54 function __construct(System $System) 55 55 { 56 56 parent::__construct($System); … … 65 65 } 66 66 67 function DoStart() 67 function DoStart(): void 68 68 { 69 69 $this->System->Pages['search'] = 'PageSearch'; 70 70 } 71 71 72 function DoInstall() 72 function DoInstall(): void 73 73 { 74 74 } 75 75 76 function DoUnInstall() 76 function DoUnInstall(): void 77 77 { 78 78 } 79 79 80 function RegisterSearch( $Title, $TableName, $Columns)80 function RegisterSearch(string $Title, string $TableName, array $Columns): void 81 81 { 82 82 $this->Items[] = array('Name' => $Title, 'Table' => $TableName, 'Columns' => $Columns); 83 83 } 84 85 static function Cast(AppModule $AppModule): ModuleSearch 86 { 87 if ($AppModule instanceof ModuleSearch) 88 { 89 return $AppModule; 90 } 91 throw new Exception('Expected ModuleSearch type but got '.gettype($AppModule)); 92 } 84 93 } -
trunk/Modules/SpeedTest/SpeedTest.php
r874 r887 14 14 class ModuleSpeedTest extends AppModule 15 15 { 16 function __construct( $System)16 function __construct(System $System) 17 17 { 18 18 parent::__construct($System); … … 25 25 } 26 26 27 function DoStart() 27 function DoStart(): void 28 28 { 29 29 $this->System->Pages['speedtest'] = 'PageSpeedTest'; … … 33 33 class PageSpeedTest extends Page 34 34 { 35 var $FullTitle = 'Test rychlosti připojení'; 36 var $ShortTitle = 'Test rychlosti'; 37 var $ParentClass = 'PagePortal'; 35 function __construct(System $System) 36 { 37 parent::__construct($System); 38 $this->FullTitle = 'Test rychlosti připojení'; 39 $this->ShortTitle = 'Test rychlosti'; 40 $this->ParentClass = 'PagePortal'; 41 } 38 42 39 function Show() 43 function Show(): string 40 44 { 41 45 if (count($this->System->PathItems) > 1) … … 47 51 } 48 52 49 function ShowDownload() 53 function ShowDownload(): void 50 54 { 51 55 global $config; … … 54 58 } 55 59 56 function ShowMain() 60 function ShowMain(): string 57 61 { 58 62 global $config; -
trunk/Modules/Stock/Stock.php
r874 r887 3 3 class ModuleStock extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 global $Config; … … 246 246 } 247 247 248 function BeforeInsertStockMove( $Form)248 function BeforeInsertStockMove(Form $Form): array 249 249 { 250 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 250 251 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 251 252 else $Year = date("Y", $Form->Values['ValidFrom']); 252 $Group = $ this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup');253 $Form->Values['BillCode'] = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);253 $Group = $Finance->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 254 $Form->Values['BillCode'] = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 254 255 return $Form->Values; 255 256 } -
trunk/Modules/Subject/Subject.php
r886 r887 3 3 class ModuleSubject extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Subject', array( … … 127 127 'Filter' => '1', 128 128 )); 129 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Subject',130 array( 'ModuleSubject', 'ShowDashboardItem'));129 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Subject', 130 array($this, 'ShowDashboardItem')); 131 131 } 132 132 133 function DoInstall() 133 function DoInstall(): void 134 134 { 135 135 $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` ( … … 173 173 } 174 174 175 function DoUninstall() 175 function DoUninstall(): void 176 176 { 177 177 $this->Database->query('DROP TABLE `Contact`'); … … 180 180 } 181 181 182 function ShowDashboardItem() 182 function ShowDashboardItem(): string 183 183 { 184 184 $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1'); -
trunk/Modules/System/System.php
r874 r887 3 3 class PageModules extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function ShowList() 13 function ShowList(): string 14 14 { 15 15 $Output = ''; … … 62 62 } 63 63 64 function Show() 64 function Show(): string 65 65 { 66 66 $Output = ''; … … 69 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();71 $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else … … 78 78 if ($ModuleName != '') 79 79 { 80 $this->System->Modules[$ModuleName]->Install(); 81 $this->System->ModuleManager->Init(); 80 $this->System->ModuleManager->GetModule($ModuleName)->Install(); 82 81 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 83 82 … … 88 87 if ($ModuleName != '') 89 88 { 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); 91 $this->System->ModuleManager->Init(); 89 $this->System->ModuleManager->GetModule($ModuleName)->UnInstall(); 92 90 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 93 91 } else $Output .= 'Neplatná akce'; … … 100 98 class ModuleSystem extends AppModule 101 99 { 102 var$InstalledChecked;103 104 function __construct( $System)100 public bool $InstalledChecked; 101 102 function __construct(System $System) 105 103 { 106 104 parent::__construct($System); … … 113 111 } 114 112 115 function DoInstall() 113 function DoInstall(): void 116 114 { 117 115 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` ( … … 164 162 } 165 163 166 function DoUnInstall() 164 function DoUnInstall(): void 167 165 { 168 166 // Delete tables with reverse order … … 178 176 } 179 177 180 function DoStart() 181 { 182 $this->System->RegisterPage( 'module', 'PageModules');178 function DoStart(): void 179 { 180 $this->System->RegisterPage(['module'], 'PageModules'); 183 181 $this->System->FormManager->RegisterClass('Action', array( 184 182 'Title' => 'Akce', … … 402 400 } 403 401 404 function DoStop() 405 { 406 } 407 408 function IsInstalled() 402 function DoStop(): void 403 { 404 } 405 406 function IsInstalled(): bool 409 407 { 410 408 if ($this->InstalledChecked == false) … … 419 417 } 420 418 421 function ModuleChange($Module) 419 function ModuleChange($Module): void 422 420 { 423 421 //if ($this->IsInstalled()) … … 430 428 } 431 429 432 function LoadFromDatabase() 430 function LoadFromDatabase(): void 433 431 { 434 432 //DebugLog('Loading modules...'); … … 448 446 } 449 447 450 function SaveToDatabase() 448 function SaveToDatabase(): string 451 449 { 452 450 $Output = ''; … … 457 455 $Modules[$DbRow['Name']] = $DbRow; 458 456 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 $this->System->ModuleManager-> Modules[$DbRow['Name']]->Id = $DbRow['Id'];457 $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id']; 460 458 } 461 459 … … 470 468 'Description' => $Module->Description, 'License' => $Module->License, 471 469 'Installed' => $Module->Installed)); 472 $this->System->ModuleManager-> Modules[$Module->Name]->Id = $this->Database->insert_id;470 $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id; 473 471 } 474 472 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array( … … 512 510 { 513 511 if (!array_key_exists($Module->Id, $DbDependency) or 514 !in_array($this->System->ModuleManager-> Modules[$Dependency]->Id, $DbDependency[$Module->Id]))512 !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id])) 515 513 { 516 if ( array_key_exists($Dependency, $this->System->ModuleManager->Modules))517 $DependencyId = $this->System->ModuleManager-> Modules[$Dependency]->Id;514 if ($this->System->ModuleManager->ModulePresent($Dependency)) 515 $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id; 518 516 else throw new Exception('Dependent module '.$Dependency.' not found'); 519 517 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, … … 534 532 return $Output; 535 533 } 534 535 static function Cast(AppModule $AppModule): ModuleSystem 536 { 537 if ($AppModule instanceof ModuleSystem) 538 { 539 return $AppModule; 540 } 541 throw new Exception('Expected ModuleSystem type but got '.gettype($AppModule)); 542 } 536 543 } -
trunk/Modules/TV/TV.php
r874 r887 5 5 class PageIPTV extends Page 6 6 { 7 var $FullTitle = 'Síťová televize'; 8 var $ShortTitle = 'IPTV'; 9 var $ParentClass = 'PagePortal'; 10 11 function Show() 7 function __construct(System $System) 12 8 { 13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'playlist.m3u') return $this->ShowPlayList(); 16 else return PAGE_NOT_FOUND; 17 } else return $this->ShowChannelList(); 9 parent::__construct($System); 10 $this->FullTitle = 'Síťová televize'; 11 $this->ShortTitle = 'IPTV'; 12 $this->ParentClass = 'PagePortal'; 18 13 } 19 14 20 function Show ChannelList()15 function Show(): string 21 16 { 22 global $Channels; 23 24 $Output = 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 17 $Output = 'Stažení přehrávače: <a href="https://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 25 18 'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'. 26 19 'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>'. … … 28 21 '<div align="center"><strong>Výpis kanálů:</strong><br>'; 29 22 30 $Where =31 23 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '. 32 24 ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")'); … … 69 61 $Output .= '</div><br/>'; 70 62 71 $Output .= 'Další online TV na webu: <a href="http://spustit.cz">Spustit.cz</a><br/>'; 72 $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>'; 63 $Output .= 'Další online TV na webu: <a href="https://spustit.cz/">Spustit.cz</a><br/>'; 73 64 74 65 return $Output; 75 66 } 67 } 76 68 77 function ShowPlayList() 69 class PagePlaylist extends Page 70 { 71 function Show(): string 78 72 { 79 73 $this->ClearPage = true; … … 82 76 Header("Content-Disposition: attachment; filename=playlist.m3u"); 83 77 84 echo('#EXTM3U'."\n");78 $Output = '#EXTM3U'."\n"; 85 79 if (array_key_exists('id', $_GET)) 86 80 { … … 89 83 { 90 84 $Channel = $DbResult->fetch_array(); 91 echo('#EXTINF:0,'.$Channel['Name']."\n");92 echo($Channel['Stream']."\n");85 $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; 86 $Output .= $Channel['Stream']."\n"; 93 87 } 94 88 } else … … 97 91 while ($Channel = $DbResult->fetch_array()) 98 92 { 99 echo('#EXTINF:0,'.$Channel['Name']."\n");100 echo($Channel['Stream']."\n");93 $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; 94 $Output .= $Channel['Stream']."\n"; 101 95 } 102 96 } 97 return $Output; 103 98 } 104 99 } … … 106 101 class ModuleTV extends AppModule 107 102 { 108 function __construct( $System)103 function __construct(System $System) 109 104 { 110 105 parent::__construct($System); … … 117 112 } 118 113 119 function DoInstall() 114 function DoInstall(): void 120 115 { 121 116 } 122 117 123 function DoUninstall() 118 function DoUninstall(): void 124 119 { 125 120 } 126 121 127 function DoStart() 122 function DoStart(): void 128 123 { 129 $this->System->RegisterPage('tv', 'PageIPTV'); 124 $this->System->RegisterPage(['tv'], 'PageIPTV'); 125 $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist'); 130 126 $this->System->FormManager->RegisterClass('TV', array( 131 127 'Title' => 'TV kanály', … … 170 166 } 171 167 172 function DoStop() 168 function DoStop(): void 173 169 { 174 170 } -
trunk/Modules/TV/tkr.php
r874 r887 3 3 class CableTVChennelListPage extends Page 4 4 { 5 var $FullTitle = 'Seznam televizních kanálů místní kabelové televize'; 6 var $ShortTitle = 'Kanály kabelové televize'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Seznam televizních kanálů místní kabelové televize'; 9 $this->ShortTitle = 'Kanály kabelové televize'; 10 } 7 11 8 function Show() 12 function Show(): string 9 13 { 10 14 $Output = '<div align="center"><strong>Výpis kanálů:</strong><br>'. … … 21 25 } 22 26 23 $ System->AddModule(new CableTVChennelListPage($System));24 $ System->Modules['CableTVChennelListPage']->GetOutput();27 $Page = new CableTVChennelListPage($System); 28 $Page->GetOutput(); -
trunk/Modules/Task/Task.php
r760 r887 3 3 class ModuleTask extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Task', array( … … 89 89 )); 90 90 91 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Task',92 array( 'ModuleTask', 'ShowDashboardItem'));91 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Task', 92 array($this, 'ShowDashboardItem')); 93 93 } 94 94 95 function DoInstall() 95 function DoInstall(): void 96 96 { 97 98 97 } 99 98 100 function ShowDashboardItem() 99 function ShowDashboardItem(): string 101 100 { 102 101 $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100'); -
trunk/Modules/TimeMeasure/Graph.php
r874 r887 9 9 var $DefaultHeight; 10 10 11 function __construct( $System)11 function __construct(System $System) 12 12 { 13 13 parent::__construct($System); … … 17 17 } 18 18 19 function Show() 19 function Show(): string 20 20 { 21 21 $this->ClearPage = true; 22 return $this->Render(); 22 $this->Render(); 23 return ''; 23 24 } 24 25 25 function Render() 26 function Render(): void 26 27 { 27 28 $PrefixMultiplier = new PrefixMultiplier(); -
trunk/Modules/TimeMeasure/Main.php
r874 r887 3 3 class PageMeasure extends Page 4 4 { 5 var$GraphTimeRanges;6 var$DefaultVariables;7 var$ImageHeight;8 var$ImageWidth;9 10 function __construct( $System)5 public array $GraphTimeRanges; 6 public array $DefaultVariables; 7 public int $ImageHeight; 8 public int $ImageWidth; 9 10 function __construct(System $System) 11 11 { 12 12 parent::__construct($System); … … 23 23 ); 24 24 $this->GraphTimeRanges = array 25 (26 'hour' => array(27 'caption' => 'Hodina',28 'period' => 3600,29 ),30 'day' => array(31 'caption' => 'Den',32 'period' => 86400, // 3600 * 24,33 ),34 'week' => array(35 'caption' => 'Týden',36 'period' => 604800, // 3600 * 24 * 7,37 ),38 'month' => array(39 'caption' => 'Měsíc',40 'period' => 2592000, // 3600 * 24 * 30,41 ),42 'year' => array(43 'caption' => 'Rok',44 'period' => 31536000, // 3600 * 24 * 365,45 ),46 'years' => array(47 'caption' => 'Desetiletí',48 'period' => 315360000, // 3600 * 24 * 365 * 10,49 ),50 );25 ( 26 'hour' => array( 27 'caption' => 'Hodina', 28 'period' => 3600, 29 ), 30 'day' => array( 31 'caption' => 'Den', 32 'period' => 86400, // 3600 * 24, 33 ), 34 'week' => array( 35 'caption' => 'Týden', 36 'period' => 604800, // 3600 * 24 * 7, 37 ), 38 'month' => array( 39 'caption' => 'Měsíc', 40 'period' => 2592000, // 3600 * 24 * 30, 41 ), 42 'year' => array( 43 'caption' => 'Rok', 44 'period' => 31536000, // 3600 * 24 * 365, 45 ), 46 'years' => array( 47 'caption' => 'Desetiletí', 48 'period' => 315360000, // 3600 * 24 * 365 * 10, 49 ), 50 ); 51 51 } 52 52 … … 114 114 } 115 115 116 function Show() 116 function Show(): string 117 117 { 118 118 $Debug = 0; … … 182 182 } 183 183 184 function Graph() 184 function Graph(): string 185 185 { 186 186 $Output = '<strong>Graf:</strong><br/>'; … … 194 194 } 195 195 196 function MeasureTable() 196 function MeasureTable(): string 197 197 { 198 198 $PrefixMultiplier = new PrefixMultiplier(); … … 266 266 class PageMeasureAddValue extends Page 267 267 { 268 function Show() 268 function Show(): string 269 269 { 270 270 $this->ClearPage = true; -
trunk/Modules/TimeMeasure/TimeMeasure.php
r738 r887 7 7 class ModuleTimeMeasure extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->RegisterPage( 'grafy', 'PageMeasure');31 $this->System->RegisterPage( array('grafy', 'graf.png'), 'PageGraph');32 $this->System->RegisterPage( array('grafy', 'add.php'), 'PageMeasureAddValue');30 $this->System->RegisterPage(['grafy'], 'PageMeasure'); 31 $this->System->RegisterPage(['grafy', 'graf.png'], 'PageGraph'); 32 $this->System->RegisterPage(['grafy', 'add.php'], 'PageMeasureAddValue'); 33 33 $this->System->FormManager->RegisterClass('Measure', array( 34 34 'Title' => 'Měření', … … 50 50 } 51 51 52 function DoStop() 52 function DoStop(): void 53 53 { 54 54 } -
trunk/Modules/User/User.php
r874 r887 7 7 class ModuleUser extends AppModule 8 8 { 9 var $UserPanel; 10 11 function __construct($System) 9 public array $UserPanel; 10 public User $User; 11 12 function __construct(System $System) 12 13 { 13 14 parent::__construct($System); … … 19 20 $this->Dependencies = array(); 20 21 $this->UserPanel = array(); 21 } 22 23 function DoInstall() 22 $this->User = new User($System); 23 } 24 25 function DoInstall(): void 24 26 { 25 27 $this->Database->query("CREATE TABLE IF NOT EXISTS `User` ( … … 108 110 } 109 111 110 function DoUninstall() 112 function DoUninstall(): void 111 113 { 112 114 $this->Database->query('DROP TABLE `PermissionUserAssignment`'); … … 118 120 } 119 121 120 function DoUpgrade() 122 function DoUpgrade(): void 121 123 { 122 124 /* … … 129 131 } 130 132 131 function DoStart() 132 { 133 $this->System->User = new User($this->System); 134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 135 $this->System->RegisterPage('userlist', 'PageUserList'); 136 $this->System->RegisterPage('user', 'PageUser'); 133 function DoStart(): void 134 { 135 if (isset($_SERVER['REMOTE_ADDR'])) $this->User->Check(); 136 $this->System->RegisterPage(['userlist'], 'PageUserList'); 137 $this->System->RegisterPage(['user'], 'PageUser'); 137 138 $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback')); 138 139 $this->System->FormManager->RegisterClass('UserLogin', array( … … 272 273 'Filter' => '1', 273 274 )); 274 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('User',275 array('ModuleUser', 'ShowDashboardItem'));276 } 277 278 function ShowDashboardItem() 275 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('User', 276 array($this, 'ShowDashboardItem')); 277 } 278 279 function ShowDashboardItem(): string 279 280 { 280 281 $DbResult = $this->Database->select('User', 'COUNT(*)', '1'); … … 284 285 } 285 286 286 function DoStop() 287 { 288 } 289 290 function TopBarCallback() 291 { 292 if ($this-> System->User->User['Id'] == null)287 function DoStop(): void 288 { 289 } 290 291 function TopBarCallback(): string 292 { 293 if ($this->User->User['Id'] == null) 293 294 { 294 295 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 296 297 } else 297 298 { 298 $Output = $this-> System->User->User['Name'].299 $Output = $this->User->User['Name']. 299 300 ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'. 300 301 ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>'; … … 303 304 return $Output; 304 305 } 306 307 static function Cast(AppModule $AppModule): ModuleUser 308 { 309 if ($AppModule instanceof ModuleUser) 310 { 311 return $AppModule; 312 } 313 throw new Exception('Expected ModuleUser type but got '.gettype($AppModule)); 314 } 305 315 } -
trunk/Modules/User/UserList.php
r874 r887 3 3 class PageUserList extends Page 4 4 { 5 var $FullTitle = 'Seznam registrovaných uživatelů'; 6 var $ShortTitle = 'Seznam uživatelů'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Seznam registrovaných uživatelů'; 9 $this->ShortTitle = 'Seznam uživatelů'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (! $this->System->User->CheckPermission('User', 'ShowList'))15 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('User', 'ShowList')) 12 16 return 'Nemáte oprávnění'; 13 17 -
trunk/Modules/User/UserModel.php
r878 r887 28 28 class PasswordHash 29 29 { 30 function Hash( $Password, $Salt)30 function Hash(string $Password, string $Salt): string 31 31 { 32 32 return sha1(sha1($Password).$Salt); 33 33 } 34 34 35 function Verify( $Password, $Salt, $StoredHash)35 function Verify(string $Password, string $Salt, string $StoredHash): bool 36 36 { 37 37 return $this->Hash($Password, $Salt) == $StoredHash; 38 38 } 39 39 40 function GetSalt() 40 function GetSalt(): string 41 41 { 42 42 mt_srand(microtime(true) * 100000 + memory_get_usage(true)); … … 49 49 class User extends Model 50 50 { 51 var $Roles = array(); 52 var $User = array(); 53 var $OnlineStateTimeout; 54 var $PermissionCache = array(); 55 var $PermissionGroupCache = array(); 56 var $PermissionGroupCacheOp = array(); 57 /** @var Password */ 58 var $PasswordHash; 59 60 function __construct($System) 51 public array $Roles = array(); 52 public array $User = array(); 53 public int $OnlineStateTimeout; 54 public array $PermissionCache = array(); 55 public array $PermissionGroupCache = array(); 56 public array $PermissionGroupCacheOp = array(); 57 public PasswordHash $PasswordHash; 58 59 function __construct(System $System) 61 60 { 62 61 parent::__construct($System); … … 66 65 } 67 66 68 function Check() 67 function Check(): void 69 68 { 70 69 $SID = session_id(); … … 117 116 { 118 117 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');118 if ($DbRow['User'] != null) ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout'); 120 119 } 121 120 //$this->LoadPermission($this->User['Role']); … … 125 124 } 126 125 127 function Register( $Login, $Password, $Password2, $Email, $Name)126 function Register(string $Login, string $Password, string $Password2, string $Email, string $Name): string 128 127 { 129 128 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING; … … 172 171 173 172 $Result = USER_REGISTRATED; 174 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);173 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'NewRegistration', $Login); 175 174 } 176 175 } … … 180 179 } 181 180 182 function RegisterConfirm( $Id, $Hash)181 function RegisterConfirm(string $Id, string $Hash): string 183 182 { 184 183 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); … … 191 190 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); 192 191 $Output = USER_REGISTRATION_CONFIRMED; 193 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.192 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'RegisterConfirm', 'Login='. 194 193 $Row['Login'].', Id='.$Row['Id']); 195 194 } else $Output = PASSWORDS_UNMATCHED; … … 198 197 } 199 198 200 function Login( $Login, $Password, $StayLogged = false)199 function Login(string $Login, string $Password, bool $StayLogged = false): string 201 200 { 202 201 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0; … … 228 227 $Result = USER_LOGGED_IN; 229 228 $this->Check(); 230 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));229 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress())); 231 230 } 232 231 } else $Result = USER_NOT_REGISTRED; … … 234 233 } 235 234 236 function Logout() 235 function Logout(): string 237 236 { 238 237 $SID = session_id(); 239 238 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null)); 240 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);239 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout', $this->User['Login']); 241 240 $this->Check(); 242 241 return USER_LOGGED_OUT; … … 248 247 $DbResult = $this->Database->select('UserRole', '*'); 249 248 while ($DbRow = $DbResult->fetch_array()) 249 { 250 250 $this->Roles[] = $DbRow; 251 } 251 252 } 252 253 … … 257 258 if ($DbResult->num_rows > 0) 258 259 while ($DbRow = $DbResult->fetch_array()) 260 { 259 261 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 260 } 261 262 function PermissionMatrix() 262 } 263 } 264 265 function PermissionMatrix(): array 263 266 { 264 267 $Result = array(); … … 274 277 } 275 278 276 function CheckGroupPermission( $GroupId, $OperationId)279 function CheckGroupPermission(string $GroupId, string $OperationId): bool 277 280 { 278 281 $PermissionExists = false; … … 322 325 } 323 326 324 function CheckPermission( $Module, $Operation, $ItemType = '', $ItemIndex = 0)327 function CheckPermission(string $Module, string $Operation, string $ItemType = '', int $ItemIndex = 0): bool 325 328 { 326 329 // Get module id … … 373 376 } 374 377 375 function PasswordRecoveryRequest( $Login, $Email)378 function PasswordRecoveryRequest(string $Login, string $Email): string 376 379 { 377 380 $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"'); … … 395 398 396 399 $Output = USER_PASSWORD_RECOVERY_SUCCESS; 397 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);400 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 398 401 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 399 402 return $Output; 400 403 } 401 404 402 function PasswordRecoveryConfirm( $Id, $Hash, $NewPassword)405 function PasswordRecoveryConfirm(string $Id, string $Hash, string $NewPassword): string 403 406 { 404 407 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); … … 414 417 'Salt' => $Salt, 'Locked' => 0)); 415 418 $Output = USER_PASSWORD_RECOVERY_CONFIRMED; 416 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);419 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']); 417 420 } else $Output = PASSWORDS_UNMATCHED; 418 421 } else $Output = USER_NOT_FOUND; … … 420 423 } 421 424 422 function CheckToken( $Module, $Operation, $Token)425 function CheckToken(string $Module, string $Operation, string $Token): bool 423 426 { 424 427 $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"'); -
trunk/Modules/User/UserPage.php
r874 r887 3 3 class PageUser extends Page 4 4 { 5 var $FullTitle = 'Uživatel'; 6 var $ShortTitle = 'Uživatel'; 7 var $ParentClass = 'PagePortal'; 8 9 function Panel($Title, $Content, $Menu = array()) 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Uživatel'; 9 $this->ShortTitle = 'Uživatel'; 10 $this->ParentClass = 'PagePortal'; 11 } 12 13 function Panel(string $Title, string $Content, array $Menu = array()): string 10 14 { 11 15 if (count($Menu) > 0) … … 15 19 } 16 20 17 function ShowContacts() 21 function ShowContacts(): string 18 22 { 19 23 $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '. 20 24 'FROM `Contact` WHERE `User` = '. 21 $this->System->User->User['Id'];25 ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 22 26 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T'); 23 27 $DbRow = $DbResult->fetch_row(); … … 53 57 } 54 58 55 function ShowUserPanel() 56 { 59 function ShowUserPanel(): string 60 { 61 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 57 62 $Output = ''; 58 if ($ this->System->User->User['Id'] != null)63 if ($User->User['Id'] != null) 59 64 { 60 65 $Actions = ''; 61 foreach ( $this->System->ModuleManager->Modules['User']->UserPanel as $Action)66 foreach (ModuleUser::Cast($this->System->GetModule('User'))->UserPanel as $Action) 62 67 { 63 68 if (is_string($Action[0])) … … 71 76 $Output .= $this->Panel('Nabídka uživatele', $Actions); 72 77 $Output .= '</td><td style="vertical-align:top;">'; 73 if ($ this->System->User->User['Id'] != null)78 if ($User->User['Id'] != null) 74 79 { 75 80 $Form = new Form($this->System->FormManager); 76 81 $Form->SetClass('UserOptions'); 77 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);82 $Form->LoadValuesFromDatabase($User->User['Id']); 78 83 $Form->OnSubmit = '?Action=UserOptionsSave'; 79 84 $Output .= $Form->ShowViewForm(); … … 88 93 } 89 94 90 function Show() 91 { 95 function Show(): string 96 { 97 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 92 98 $Output = ''; 93 99 if (array_key_exists('Action', $_GET)) … … 112 118 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true; 113 119 else $StayLogged = false; 114 $Result = $ this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);120 $Result = $User->Login($_POST['Username'], $_POST['Password'], $StayLogged); 115 121 $Output .= $this->SystemMessage('Přihlášení', $Result); 116 122 if ($Result <> USER_LOGGED_IN) … … 130 136 if ($Action == 'Logout') 131 137 { 132 if ($ this->System->User->User['Id'] != null)133 { 134 $Output .= $this->SystemMessage('Odhlášení', $ this->System->User->Logout());138 if ($User->User['Id'] != null) 139 { 140 $Output .= $this->SystemMessage('Odhlášení', $User->Logout()); 135 141 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 136 142 } else 137 143 if ($Action == 'UserOptions') 138 144 { 139 if ($ this->System->User->User['Id'] != null)145 if ($User->User['Id'] != null) 140 146 { 141 147 $Form = new Form($this->System->FormManager); 142 148 $Form->SetClass('UserOptions'); 143 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);149 $Form->LoadValuesFromDatabase($User->User['Id']); 144 150 $Form->OnSubmit = '?Action=UserOptionsSave'; 145 151 $Output .= $Form->ShowEditForm(); … … 151 157 $Form->SetClass('UserOptions'); 152 158 $Form->LoadValuesFromForm(); 153 $Form->SaveValuesToDatabase($ this->System->User->User['Id']);159 $Form->SaveValuesToDatabase($User->User['Id']); 154 160 $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.'); 155 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']);156 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);161 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']); 162 $Form->LoadValuesFromDatabase($User->User['Id']); 157 163 $Form->OnSubmit = '?Action=UserOptionsSave'; 158 164 $Output .= $Form->ShowEditForm(); … … 169 175 { 170 176 $Output .= $this->SystemMessage('Potvrzení registrace', 171 $ this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));177 $User->RegisterConfirm($_GET['User'], $_GET['H'])); 172 178 } else 173 179 if ($Action == 'PasswordRecovery') … … 183 189 $Form->SetClass('PasswordRecovery'); 184 190 $Form->LoadValuesFromForm(); 185 $Result = $ this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);191 $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 186 192 $Output .= $this->SystemMessage('Obnova hesla', $Result); 187 193 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) … … 192 198 if ($Action == 'PasswordRecoveryConfirm') 193 199 { 194 $Output .= $this->SystemMessage('Obnova hesla', $ this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));200 $Output .= $this->SystemMessage('Obnova hesla', $User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P'])); 195 201 } else 196 202 if ($Action == 'UserRegisterSave') … … 199 205 $Form->SetClass('UserRegister'); 200 206 $Form->LoadValuesFromForm(); 201 $Result = $ this->System->User->Register($Form->Values['Login'], $Form->Values['Password'],207 $Result = $User->Register($Form->Values['Login'], $Form->Values['Password'], 202 208 $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 203 209 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); … … 216 222 } 217 223 218 function ShowMain() 224 function ShowMain(): string 219 225 { 220 226 $Output = 'Nebyla vybrána akce'; -
trunk/Modules/VPS/VPS.php
r770 r887 3 3 class ModuleVPS extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 16 16 } 17 17 18 function DoStart() 18 function DoStart(): void 19 19 { 20 20 21 21 } 22 22 23 function DoInstall() 23 function DoInstall(): void 24 24 { 25 25 -
trunk/Modules/WebCam/WebCam.php
r874 r887 3 3 class PageWebcam extends Page 4 4 { 5 var $FullTitle = 'Webová kamera'; 6 var $ShortTitle = 'Kamera'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Webová kamera'; 9 $this->ShortTitle = 'Kamera'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (file_exists( $this->System->ModuleManager->Modules['WebCam']->ImageFileName))15 if (file_exists(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)) 12 16 { 13 17 $Output = '<script language="JavaScript"> 14 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'. $this->System->Modules['Webcam']->ImageFileName.'";18 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'.ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName.'"; 15 19 16 20 // Force an immediate image load … … 32 36 </script>'; 33 37 34 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '.date('j.n.Y G:i', filemtime($this->System->Modules['Webcam']->ImageFileName)).'<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 38 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '. 39 date('j.n.Y G:i', filemtime(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)). 40 '<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 35 41 } else $Output = '<br />Obrázek nenalezen.<br /><br />'; 36 42 … … 44 50 class ModuleWebCam extends AppModule 45 51 { 46 var$ImageFileName = 'webcam.jpg';52 public string $ImageFileName = 'webcam.jpg'; 47 53 48 function __construct( $System)54 function __construct(System $System) 49 55 { 50 56 parent::__construct($System); … … 58 64 } 59 65 60 function DoStart() 66 function DoStart(): void 61 67 { 62 68 $this->System->Pages['webcam'] = 'PageWebcam'; 63 69 } 64 70 65 function ShowImage() 71 function ShowImage(): string 66 72 { 67 73 global $Config; … … 74 80 return $Output; 75 81 } 82 83 static function Cast(AppModule $AppModule): ModuleWebCam 84 { 85 if ($AppModule instanceof ModuleWebCam) 86 { 87 return $AppModule; 88 } 89 throw new Exception('Expected ModuleWebCam type but got '.gettype($AppModule)); 90 } 76 91 } -
trunk/Modules/Wiki/Wiki.php
r874 r887 3 3 class ModuleWiki extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 15 15 } 16 16 17 function DoInstall() 17 function DoInstall(): void 18 18 { 19 19 parent::Install(); … … 42 42 } 43 43 44 function DoUnInstall() 44 function DoUnInstall(): void 45 45 { 46 46 $this->Database->query('DELETE TABLE `WikiPageContent`'); … … 48 48 } 49 49 50 function DoStart() 50 function DoStart(): void 51 51 { 52 52 $this->LoadPages(); 53 53 } 54 54 55 function DoStop() 56 { 57 } 58 59 function LoadPages() 55 function DoStop(): void 56 { 57 } 58 59 function LoadPages(): void 60 60 { 61 61 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 62 62 while ($DbRow = $DbResult->fetch_assoc()) 63 63 { 64 $this->System->RegisterPage( $DbRow['NormalizedName'], 'PageWiki');64 $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki'); 65 65 $this->System->RegisterMenuItem(array( 66 66 'Title' => $DbRow['Name'], … … 76 76 class PageWiki extends Page 77 77 { 78 var $FullTitle = 'Wiki stránky'; 79 var $ShortTitle = 'Wiki'; 80 var $ParentClass = 'PagePortal'; 81 82 function Show() 78 function __construct(System $System) 79 { 80 parent::__construct($System); 81 $this->FullTitle = 'Wiki stránky'; 82 $this->ShortTitle = 'Wiki'; 83 $this->ParentClass = 'PagePortal'; 84 } 85 86 function Show(): string 83 87 { 84 88 if (array_key_exists('Action', $_GET)) … … 92 96 } 93 97 94 function ShowContent() 98 function ShowContent(): string 95 99 { 96 100 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 107 111 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 108 112 $Output .= $DbRow2['Content']; 109 if ( $this->System->User->Licence(LICENCE_MODERATOR))113 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 110 114 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 111 } else $Output = Show Message('Wiki stránka nenalezena', MESSAGE_CRITICAL);115 } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 112 116 } else 113 117 { … … 118 122 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 119 123 $Output .= $DbRow2['Content']; 120 if ( $this->System->User->Licence(LICENCE_MODERATOR))124 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 121 125 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 122 126 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 126 130 } 127 131 128 function EditContent() 129 { 130 if ( $this->System->User->Licence(LICENCE_MODERATOR))132 function EditContent(): string 133 { 134 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 131 135 { 132 136 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 151 155 } 152 156 153 function SaveContent() 154 { 155 if ( $this->System->User->Licence(LICENCE_MODERATOR))157 function SaveContent(): string 158 { 159 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 156 160 { 157 161 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 162 166 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 163 167 { 164 $ DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),165 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));168 $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 169 'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 166 170 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 167 171 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); … … 172 176 } 173 177 174 function ShowHistory() 175 { 176 if ( $this->System->User->Licence(LICENCE_MODERATOR))178 function ShowHistory(): string 179 { 180 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 177 181 { 178 182 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 218 222 } 219 223 220 function ToHtml( $text)224 function ToHtml(string $text): string 221 225 { 222 226 $text = preg_replace('/<source lang="(.*?)">(.*?)<\/source>/', '<pre lang="$1">$2</pre>', $text); -
trunk/Packages/Common/AppModule.php
r880 r887 36 36 class AppModule 37 37 { 38 var $Id; 39 var $Name; 40 var $Title; 41 var $Version; 42 var $License; 43 var $Creator; 44 var $HomePage; 45 var $Description; 46 var $Running; 47 var $Enabled; 48 var $Installed; 49 var $InstalledVersion; 50 /** @var ModuleType */ 51 var $Type; 52 var $Dependencies; 53 /** @var Database */ 54 var $Database; 55 /** @var System */ 56 var $System; 57 /** @var AppModuleManager */ 58 var $Manager; 59 var $OnChange; 60 61 function __construct(System $System) 38 public int $Id; 39 public string $Name; 40 public string $Title; 41 public string $Version; 42 public string $License; 43 public string $Creator; 44 public string $HomePage; 45 public string $Description; 46 public bool $Running; 47 public bool $Enabled; 48 public bool $Installed; 49 public string $InstalledVersion; 50 public int $Type; 51 public array $Dependencies; 52 public Database $Database; 53 public Application $System; 54 public AppModuleManager $Manager; 55 public $OnChange; 56 public array $Models; 57 58 function __construct(Application $System) 62 59 { 63 60 $this->System = &$System; … … 73 70 $this->Dependencies = array(); 74 71 $this->Type = ModuleType::Normal; 75 } 76 77 function Install() 72 $this->Models = array(); 73 } 74 75 function Install(): void 78 76 { 79 77 if ($this->Installed) return; … … 87 85 } 88 86 89 function Uninstall() 87 function Uninstall(): void 90 88 { 91 89 if (!$this->Installed) return; … … 98 96 } 99 97 100 function Upgrade() 98 function Upgrade(): void 101 99 { 102 100 if (!$this->Installed) return; … … 108 106 } 109 107 110 function Reinstall() 108 function Reinstall(): void 111 109 { 112 110 $this->Uninstall(); … … 115 113 } 116 114 117 function Start() 115 function Start(): void 118 116 { 119 117 if ($this->Running) return; … … 126 124 } 127 125 128 function Stop() 126 function Stop(): void 129 127 { 130 128 if (!$this->Running) return; … … 136 134 } 137 135 138 function Restart() 136 function Restart(): void 139 137 { 140 138 $this->Stop(); … … 142 140 } 143 141 144 function Enable() 142 function Enable(): void 145 143 { 146 144 if ($this->Enabled) return; … … 152 150 } 153 151 154 function Disable() 152 function Disable(): void 155 153 { 156 154 if (!$this->Enabled) return; … … 162 160 } 163 161 164 protected function DoStart() 165 { 166 } 167 168 protected function DoStop() 169 { 170 } 171 172 protected function DoInstall() 173 { 174 } 175 176 protected function DoUninstall() 177 { 178 } 179 180 protected function DoUpgrade() 181 { 182 162 protected function DoStart(): void 163 { 164 } 165 166 protected function DoStop(): void 167 { 168 } 169 170 protected function DoInstall(): void 171 { 172 } 173 174 protected function DoUninstall(): void 175 { 176 } 177 178 protected function DoUpgrade(): void 179 { 180 } 181 182 function AddModel(Model $Model): void 183 { 184 $this->Models[get_class($Model)] = $Model; 183 185 } 184 186 } … … 187 189 class AppModuleManager 188 190 { 189 var$Modules;190 var$System;191 var$FileName;192 var$ModulesDir;193 var$OnLoadModules;191 public array $Modules; 192 public System $System; 193 public string $FileName; 194 public string $ModulesDir; 195 public $OnLoadModules; 194 196 195 197 function __construct(System $System) … … 201 203 } 202 204 203 function Perform( $List, $Actions, $Conditions = array(ModuleCondition::All))205 function Perform(array $List, array $Actions, array $Conditions = array(ModuleCondition::All)): void 204 206 { 205 207 foreach ($List as $Index => $Module) … … 227 229 } 228 230 229 function EnumDependenciesCascade( $Module, &$List,$Conditions = array(ModuleCondition::All))231 function EnumDependenciesCascade(AppModule $Module, array &$List, array $Conditions = array(ModuleCondition::All)) 230 232 { 231 233 foreach ($Module->Dependencies as $Dependency) … … 248 250 } 249 251 250 function EnumSuperiorDependenciesCascade( $Module, &$List,$Conditions = array(ModuleCondition::All))252 function EnumSuperiorDependenciesCascade(AppModule $Module, array &$List, array $Conditions = array(ModuleCondition::All)) 251 253 { 252 254 foreach ($this->Modules as $RefModule) … … 267 269 } 268 270 269 function Start() 271 function Start(): void 270 272 { 271 273 $this->LoadModules(); … … 274 276 } 275 277 276 function StartAll() 278 function StartAll(): void 277 279 { 278 280 $this->Perform($this->Modules, array(ModuleAction::Start)); 279 281 } 280 282 281 function StartEnabled() 283 function StartEnabled(): void 282 284 { 283 285 $this->Perform($this->Modules, array(ModuleAction::Start), array(ModuleCondition::Enabled)); 284 286 } 285 287 286 function StopAll() 288 function StopAll(): void 287 289 { 288 290 $this->Perform($this->Modules, array(ModuleAction::Stop)); 289 291 } 290 292 291 function InstallAll() 293 function InstallAll(): void 292 294 { 293 295 $this->Perform($this->Modules, array(ModuleAction::Install)); … … 295 297 } 296 298 297 function UninstallAll() 299 function UninstallAll(): void 298 300 { 299 301 $this->Perform($this->Modules, array(ModuleAction::Uninstall)); … … 301 303 } 302 304 303 function EnableAll() 305 function EnableAll(): void 304 306 { 305 307 $this->Perform($this->Modules, array(ModuleAction::Enable)); … … 307 309 } 308 310 309 function DisableAll() 311 function DisableAll(): void 310 312 { 311 313 $this->Perform($this->Modules, array(ModuleAction::Disable)); … … 313 315 } 314 316 315 function ModulePresent( $Name)317 function ModulePresent(string $Name): bool 316 318 { 317 319 return array_key_exists($Name, $this->Modules); 318 320 } 319 321 320 function ModuleEnabled( $Name)322 function ModuleEnabled(string $Name): bool 321 323 { 322 324 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled; 323 325 } 324 326 325 function ModuleRunning( $Name)327 function ModuleRunning(string $Name): bool 326 328 { 327 329 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running; 328 330 } 329 331 330 /* @return Module */ 331 function SearchModuleById($Id) 332 function GetModule(string $Name): AppModule 333 { 334 return $this->Modules[$Name]; 335 } 336 337 function SearchModuleById(int $Id): string 332 338 { 333 339 foreach ($this->Modules as $Module) … … 339 345 } 340 346 341 function LoadState() 347 function LoadState(): void 342 348 { 343 349 $ConfigModules = array(); … … 355 361 } 356 362 357 function SaveState() 363 function SaveState(): void 358 364 { 359 365 $Data = array(); … … 369 375 } 370 376 371 function RegisterModule(AppModule $Module) 377 function RegisterModule(AppModule $Module): void 372 378 { 373 379 $this->Modules[$Module->Name] = &$Module; … … 376 382 } 377 383 378 function UnregisterModule(AppModule $Module) 384 function UnregisterModule(AppModule $Module): void 379 385 { 380 386 unset($this->Modules[array_search($Module, $this->Modules)]); 381 387 } 382 388 383 function LoadModulesFromDir( $Directory)389 function LoadModulesFromDir(string $Directory): void 384 390 { 385 391 $List = scandir($Directory); … … 395 401 } 396 402 397 function LoadModules() 403 function LoadModules(): void 398 404 { 399 405 if (is_array($this->OnLoadModules) and (count($this->OnLoadModules) == 2) and method_exists($this->OnLoadModules[0], $this->OnLoadModules[1])) 400 $this->OnLoadModules();406 call_user_func($this->OnLoadModules); 401 407 else $this->LoadModulesFromDir($this->ModulesDir); 402 408 } -
trunk/Packages/Common/Application.php
r873 r887 3 3 class ModelDef 4 4 { 5 var$OnChange;6 5 public array $OnChange; 6 7 7 function __construct() 8 8 { 9 9 $this->OnChange = array(); 10 10 } 11 12 function DoOnChange() 11 12 function DoOnChange(): void 13 13 { 14 14 foreach ($this->OnChange as $Callback) … … 17 17 } 18 18 } 19 20 function RegisterOnChange( $SysName, $Callback)19 20 function RegisterOnChange(string $SysName, callable $Callback): void 21 21 { 22 22 $this->OnChange[$SysName] = $Callback; 23 23 } 24 25 function UnregisterOnChange( $SysName)24 25 function UnregisterOnChange(string $SysName): void 26 26 { 27 27 unset($this->OnChange[$SysName]); … … 29 29 } 30 30 31 class Command 32 { 33 public string $Name; 34 public string $Description; 35 public $Callback; 36 37 function __construct(string $Name, string $Description, callable $Callback) 38 { 39 $this->Name = $Name; 40 $this->Description = $Description; 41 $this->Callback = $Callback; 42 } 43 } 44 31 45 class Application extends System 32 46 { 33 var$Name;34 /** @var AppModuleManager */35 var $ModuleManager;36 var $Modules;37 var $Models;38 47 public string $Name; 48 public AppModuleManager $ModuleManager; 49 public array $Models; 50 public array $CommandLine; 51 public array $Pages; 52 39 53 function __construct() 40 54 { … … 42 56 $this->Name = 'Application'; 43 57 $this->ModuleManager = new AppModuleManager($this); 44 $this->Modules = array();45 58 $this->Models = array(); 59 $this->CommandLine = array(); 60 $this->Pages = array(); 61 62 $this->RegisterCommandLine('list', 'Prints available commands', array($this, 'ListCommands')); 46 63 } 47 48 function RegisterModel($SysName, $Model) 64 65 function GetModule(string $Name): AppModule 66 { 67 return $this->ModuleManager->Modules[$Name]; 68 } 69 70 function RegisterModel(string $SysName, array $Model): void 49 71 { 50 72 $NewModelDef = new ModelDef(); … … 53 75 } 54 76 55 function UnregisterModel( $SysName)77 function UnregisterModel(string $SysName): void 56 78 { 57 79 unset($this->Models[$SysName]); 58 80 } 59 60 function R un()81 82 function RegisterCommandLine(string $Name, string $Description, callable $Callback): void 61 83 { 84 $this->CommandLine[$Name] = new Command($Name, $Description, $Callback); 85 } 62 86 87 function UnrgisterCommandLine(string $Name): void 88 { 89 unset($this->CommandLine[$Name]); 90 } 91 92 function ListCommands(array $Parameters) 93 { 94 $Output = 'Available commands:'."\n"; 95 foreach ($this->CommandLine as $Command) 96 { 97 $Output .= ' '.$Command->Name.' - '.$Command->Description."\n"; 98 } 99 echo($Output."\n"); 100 } 101 102 function RegisterPage(array $Path, string $Handler): void 103 { 104 $Page = &$this->Pages; 105 $LastKey = array_pop($Path); 106 foreach ($Path as $PathItem) 107 { 108 $Page = &$Page[$PathItem]; 109 } 110 if (!is_array($Page)) $Page = array('' => $Page); 111 $Page[$LastKey] = $Handler; 112 } 113 114 function UnregisterPage(array $Path): void 115 { 116 $Page = &$this->Pages; 117 $LastKey = array_pop($Path); 118 foreach ($Path as $PathItem) 119 { 120 $Page = &$Page[$PathItem]; 121 } 122 unset($Page[$LastKey]); 123 } 124 125 function Run(): void 126 { 127 } 128 129 function Link(string $Target): string 130 { 131 return $Target; 63 132 } 64 133 } -
trunk/Packages/Common/Base.php
r790 r887 3 3 class System 4 4 { 5 /* @var Database */ 6 var $Database; 5 public Database $Database; 7 6 8 7 function __construct() … … 14 13 class Base 15 14 { 16 /** @var Application */ 17 var $System; 18 /* @var Database */ 19 var $Database; 15 public Application $System; 16 public Database $Database; 20 17 21 function __construct( Application$System)18 function __construct(System $System) 22 19 { 23 20 $this->System = &$System; -
trunk/Packages/Common/Common.php
r874 r887 26 26 class PackageCommon 27 27 { 28 var$Name;29 var$Version;30 var$ReleaseDate;31 var$License;32 var$Creator;33 var$Homepage;28 public string $Name; 29 public string $Version; 30 public int $ReleaseDate; 31 public string $License; 32 public string $Creator; 33 public string $Homepage; 34 34 35 35 function __construct() … … 46 46 class Paging 47 47 { 48 var$TotalCount;49 var$ItemPerPage;50 var$Around;51 var$SQLLimit;52 var$Page;48 public int $TotalCount; 49 public int $ItemPerPage; 50 public int $Around; 51 public string $SQLLimit; 52 public int $Page; 53 53 54 54 function __construct() … … 60 60 } 61 61 62 function Show() 62 function Show(): string 63 63 { 64 64 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); -
trunk/Packages/Common/Database.php
r874 r887 2 2 3 3 // Extended database class 4 // Date: 20 16-01-114 // Date: 2020-11-10 5 5 6 6 function microtime_float() … … 13 13 { 14 14 var $PDOStatement; 15 var$num_rows = 0;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 46 47 47 function __construct() … … 57 57 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 58 58 } 59 60 61 function Connect($Host, $User, $Password, $Database) 59 60 function Connect(string $Host, string $User, string $Password, string $Database) 62 61 { 63 62 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; … … 79 78 } 80 79 81 function Connected() 80 function Connected(): bool 82 81 { 83 82 return isset($this->PDO); 84 83 } 85 84 86 function select_db( $Database)85 function select_db(string $Database) 87 86 { 88 87 $this->query('USE `'.$Database.'`'); 89 88 } 90 89 91 function query($Query) 90 function query($Query): DatabaseResult 92 91 { 93 92 if (!$this->Connected()) throw new Exception(T('Not connected to database')); … … 99 98 $Time = round(microtime_float() - $QueryStartTime, 4); 100 99 $Duration = ' ; '.$Time. ' s'; 101 } 100 } 102 101 if (($this->LogSQLQuery == true) and ($Time != 0)) 103 102 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); … … 112 111 $this->insert_id = $this->PDO->lastInsertId(); 113 112 } else 114 { 115 $ this->Error = $this->PDO->errorInfo();116 $this->Error = $ this->Error[2];113 { 114 $Error = $this->PDO->errorInfo(); 115 $this->Error = $Error[2]; 117 116 if (($this->Error != '') and ($this->ShowSQLError == true)) 118 117 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); … … 122 121 } 123 122 124 function select( $Table, $What = '*', $Condition = 1)123 function select(string $Table, string $What = '*', string $Condition = '1'): DatabaseResult 125 124 { 126 125 return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 127 126 } 128 127 129 function delete( $Table,$Condition)128 function delete(string $Table, string $Condition) 130 129 { 131 130 $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 132 131 } 133 132 134 function insert( $Table,$Data)133 function insert(string $Table, array $Data) 135 134 { 136 135 $this->query($this->GetInsert($Table, $Data)); 137 136 $this->insert_id = $this->PDO->lastInsertId(); 138 137 } 139 140 function GetInsert( $Table, $Data)138 139 function GetInsert(string $Table, array $Data): string 141 140 { 142 141 $Name = ''; … … 157 156 } 158 157 159 function update( $Table, $Condition,$Data)158 function update(string $Table, string $Condition, array $Data) 160 159 { 161 160 $this->query($this->GetUpdate($Table, $Condition, $Data)); 162 161 } 163 164 function GetUpdate( $Table, $Condition, $Data)162 163 function GetUpdate(string $Table, string $Condition, array $Data): string 165 164 { 166 165 $Values = ''; … … 178 177 } 179 178 180 function replace( $Table,$Data)179 function replace(string $Table, array $Data) 181 180 { 182 181 $Name = ''; … … 199 198 } 200 199 201 function charset( $Charset)200 function charset(string $Charset) 202 201 { 203 202 $this->query('SET NAMES "'.$Charset.'"'); 204 203 } 205 204 206 function real_escape_string( $Text)205 function real_escape_string(string $Text): string 207 206 { 208 207 return addslashes($Text); 209 208 } 210 209 211 function quote( $Text)210 function quote(string $Text): string 212 211 { 213 212 return $this->PDO->quote($Text); … … 222 221 { 223 222 } 224 225 public function Transaction( $Queries)223 224 public function Transaction(array $Queries) 226 225 { 227 226 //echo('|'."\n"); -
trunk/Packages/Common/Error.php
r873 r887 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() … … 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/Generics.php
r869 r887 5 5 var $Items = array(); 6 6 7 function Add($Item) 7 function Add($Item): void 8 8 { 9 9 $this->Items[] = $Item; 10 10 } 11 11 12 function RemoveAt(int $Index) 12 function RemoveAt(int $Index): void 13 13 { 14 14 unset($this->Items[$Index]); -
trunk/Packages/Common/Image.php
r874 r887 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); … … 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
r874 r887 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
r874 r887 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/Page.php
r874 r887 3 3 class Page extends View 4 4 { 5 var$FullTitle;6 var$ShortTitle;7 var$ParentClass;8 var$ClearPage;5 public string $FullTitle; 6 public string $ShortTitle; 7 public string $ParentClass; 8 public bool $ClearPage; 9 9 var $OnSystemMessage; 10 var$Load;11 var$Unload;10 public string $Load; 11 public string $Unload; 12 12 13 function __construct( $System)13 function __construct(System $System) 14 14 { 15 15 parent::__construct($System); 16 16 $this->ClearPage = false; 17 17 $this->OnSystemMessage = array(); 18 $this->FullTitle = ""; 19 $this->ShortTitle = ""; 20 $this->ParentClass = ""; 18 21 } 19 22 20 function Show() 23 function Show(): string 21 24 { 22 25 return ''; 23 26 } 24 27 25 function GetOutput() 28 function GetOutput(): string 26 29 { 27 30 $Output = $this->Show(); … … 29 32 } 30 33 31 function SystemMessage( $Title, $Text)34 function SystemMessage(string $Title, string $Text): string 32 35 { 33 36 return call_user_func_array($this->OnSystemMessage, array($Title, $Text)); -
trunk/Packages/Common/RSS.php
r874 r887 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 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 24 $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<? -
trunk/Packages/Common/Setup.php
r874 r887 3 3 class PageSetup extends Page 4 4 { 5 var $UpdateManager;6 var$ConfigDefinition;7 var$Config;8 var$DatabaseRevision;9 var$Revision;10 var $Updates;11 var $ConfigDir;12 13 function __construct( $System)5 public UpdateManager $UpdateManager; 6 public array $ConfigDefinition; 7 public array $Config; 8 public int $DatabaseRevision; 9 public int $Revision; 10 public string $ConfigDir; 11 public array $YesNo; 12 13 function __construct(System $System) 14 14 { 15 15 parent::__construct($System); 16 $this->Title = T('Application setup'); 16 $this->FullTitle = T('Application setup'); 17 $this->ShortTitle = T('Application setup'); 17 18 //$this->ParentClass = 'PagePortal'; 18 19 $this->ConfigDir = dirname(dirname(dirname(__FILE__))).'/Config'; … … 20 21 } 21 22 22 function LoginPanel() 23 function LoginPanel(): string 23 24 { 24 25 $Output = '<h3>Přihlášení k instalaci</h3>'. … … 32 33 } 33 34 34 function ControlPanel() 35 function ControlPanel(): string 35 36 { 36 37 $Output = '<h3>'.T('Instance management').'</h3>'; … … 62 63 } 63 64 64 function Show() 65 function Show(): string 65 66 { 66 67 global $ConfigDefinition, $DatabaseRevision, $Config, $Updates; … … 163 164 } 164 165 165 function ShowModules() 166 function ShowModules(): string 166 167 { 167 168 $Output = ''; … … 170 171 if ($Operation == 'install') 171 172 { 172 $this->System->ModuleManager-> Modules[$_GET['name']]->Install();173 $this->System->ModuleManager->GetModule($_GET['name'])->Install(); 173 174 $this->System->ModuleManager->SaveState(); 174 175 $Output .= 'Modul '.$_GET['name'].' instalován<br/>'; … … 176 177 if ($Operation == 'uninstall') 177 178 { 178 $this->System->ModuleManager-> Modules[$_GET['name']]->Uninstall();179 $this->System->ModuleManager->GetModule($_GET['name'])->Uninstall(); 179 180 $this->System->ModuleManager->SaveState(); 180 181 $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>'; … … 182 183 if ($Operation == 'enable') 183 184 { 184 $this->System->ModuleManager-> Modules[$_GET['name']]->Enable();185 $this->System->ModuleManager->GetModule($_GET['name'])->Enable(); 185 186 $this->System->ModuleManager->SaveState(); 186 187 $Output .= 'Modul '.$_GET['name'].' povolen<br/>'; … … 188 189 if ($Operation == 'disable') 189 190 { 190 $this->System->ModuleManager-> Modules[$_GET['name']]->Disable();191 $this->System->ModuleManager->GetModule($_GET['name'])->Disable(); 191 192 $this->System->ModuleManager->SaveState(); 192 193 $Output .= 'Modul '.$_GET['name'].' zakázán<br/>'; … … 194 195 if ($Operation == 'upgrade') 195 196 { 196 $this->System->ModuleManager-> Modules[$_GET['name']]->Upgrade();197 $this->System->ModuleManager->GetModule($_GET['name'])->Upgrade(); 197 198 $this->System->ModuleManager->SaveState(); 198 199 $Output .= 'Modul '.$_GET['name'].' povýšen<br/>'; … … 203 204 } 204 205 205 function ShowList() 206 function ShowList(): string 206 207 { 207 208 $Output = ''; … … 247 248 } 248 249 249 function PrepareConfig($Config) 250 function PrepareConfig($Config): string 250 251 { 251 252 $Output = ''; … … 322 323 } 323 324 324 function CreateConfig($Config) 325 function CreateConfig($Config): string 325 326 { 326 327 $Output = "<?php\n\n". … … 359 360 class PageSetupRedirect extends Page 360 361 { 361 function Show() 362 function Show(): string 362 363 { 363 364 $Output = ''; … … 377 378 class Setup extends Model 378 379 { 379 var $UpdateManager;380 public UpdateManager $UpdateManager; 380 381 381 382 function Start() … … 383 384 global $DatabaseRevision; 384 385 385 $this->System->RegisterPage( '', 'PageSetupRedirect');386 $this->System->RegisterPage( 'setup', 'PageSetup');386 $this->System->RegisterPage([''], 'PageSetupRedirect'); 387 $this->System->RegisterPage(['setup'], 'PageSetup'); 387 388 388 389 // Check database persistence structure … … 396 397 { 397 398 unset($this->UpdateManager); 398 $this->System->UnregisterPage( '');399 $this->System->UnregisterPage( 'setup');400 } 401 402 function CheckState() 399 $this->System->UnregisterPage(['']); 400 $this->System->UnregisterPage(['setup']); 401 } 402 403 function CheckState(): bool 403 404 { 404 405 return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and … … 432 433 } 433 434 434 function IsInstalled() 435 function IsInstalled(): bool 435 436 { 436 437 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"'); … … 438 439 } 439 440 440 function Upgrade() 441 function Upgrade(): string 441 442 { 442 443 $Updates = new Updates(); -
trunk/Packages/Common/Table.php
r874 r887 5 5 var $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 100 function __construct() … … 126 126 } 127 127 128 function Show() 128 function Show(): string 129 129 { 130 130 $Output = '<table class="'.$this->Style.'">'; … … 148 148 } 149 149 150 function GetOrderHeader() 150 function GetOrderHeader(): string 151 151 { 152 152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; -
trunk/Packages/Common/UTF8.php
r874 r887 526 526 } 527 527 528 function ToUTF8 ($String, $Charset = 'iso2')528 function ToUTF8string ($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
r874 r887 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() … … 63 62 $InstallMethod = $this->InstallMethod; 64 63 $InstallMethod($this); 65 $this->Update();66 64 } 67 65 … … 77 75 } 78 76 79 function Execute( $Query)77 function Execute(string $Query): DatabaseResult 80 78 { 81 79 echo($Query.';<br/>'); -
trunk/Packages/Package.php
r746 r887 1 1 <?php 2 2 3 class Package { 4 var $Name; 5 var $Version; 6 var $License; 7 var $Creator; 8 var $Homepage; 3 class Package 4 { 5 public string $Name; 6 public string $Version; 7 public string $License; 8 public string $Creator; 9 public string $Homepage; 9 10 } -
trunk/Readme.txt
r848 r887 1 Webový portál počítačové sítě ZděchovNET 2 ======================================== 1 Internet service portal and management system 2 ============================================= 3 4 * Required PHP 7.4 or higher 3 5 4 6 1) Instalace a nastavení systému -
trunk/block/index.php
r886 r887 1 1 <?php 2 2 3 include_once('../Application/ System.php');3 include_once('../Application/Core.php'); 4 4 5 5 class BlockPage extends Page 6 6 { 7 var $FullTitle = 'Blokování internetu'; 8 var $ShortTitle = 'Blokování internetu'; 9 var $Reasons = array( 7 private array $Reasons = array( 10 8 0 => 'Internet máte povolen, avšak došlo k chybě při kontrole přístupů k Internetu.', 11 9 1 => 'Váš počítač má blokován přístup k internetu. Pravděpodobně je váš účet v mínusu. Přihlaste se do systému a zkontrolujte stav vašich plateb. ', … … 15 13 ); 16 14 17 function Show() 15 function __construct(System $System) 16 { 17 parent::__construct($System); 18 $this->FullTitle = 'Blokování internetu'; 19 $this->ShortTitle = 'Blokování internetu'; 20 } 21 22 function Show(): string 18 23 { 19 24 $Output = '<br/><div style="font-size: 20 pt;">Máte blokován přístup k Internetu.</div> … … 42 47 } 43 48 44 $System = new System();49 $System = new Core(); 45 50 $System->ShowPage = false; 46 51 $System->Run(); 47 $ System->AddModule(new BlockPage($System));48 $System->Modules['BlockPage']->GetOutput();52 $Page = new BlockPage($System); 53 echo($Page->GetOutput()); 49 54 -
trunk/cmd.php
r873 r887 1 1 <?php 2 2 3 include_once('Application/ System.php');3 include_once('Application/Core.php'); 4 4 5 5 if (isset($_SERVER['REMOTE_ADDR'])) die(); -
trunk/index.php
r790 r887 1 1 <?php 2 2 3 include_once('Application/ System.php');3 include_once('Application/Core.php'); 4 4 5 5 $System = new Core(); -
trunk/locale/cs.php
r883 r887 3 3 class LocaleTextcs extends LocaleText 4 4 { 5 function Load() 5 function Load(): void 6 6 { 7 7 $this->Code = 'cs'; -
trunk/locale/en.php
r883 r887 3 3 class LocaleTexten extends LocaleText 4 4 { 5 function Load() 5 function Load(): void 6 6 { 7 7 $this->Code = 'en';
Note:
See TracChangeset
for help on using the changeset viewer.