Changeset 887 for trunk/Common/Form
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- Location:
- trunk/Common/Form
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
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];
Note:
See TracChangeset
for help on using the changeset viewer.