source: trunk/Packages/FormManager/Types/Base.php

Last change on this file was 8, checked in by chronos, 18 months ago
  • Modified: Updated Common package.
  • Modified: Form types made as separate FormManager package.
  • Fixed: PHP 8.1 support.
File size: 1.5 KB
Line 
1<?php
2
3class TypeBase
4{
5 public FormManager $FormManager;
6 public Database $Database;
7 public array $DatabaseCompareOperators = array();
8 public bool $Hidden;
9
10 function __construct(FormManager $FormManager)
11 {
12 $this->FormManager = &$FormManager;
13 $this->Database = &$FormManager->Database;
14 $this->Hidden = false;
15 }
16
17 function OnView(array $Item): ?string
18 {
19 return '';
20 }
21
22 function OnEdit(array $Item): string
23 {
24 return '';
25 }
26
27 function OnLoad(array $Item): ?string
28 {
29 return '';
30 }
31
32 function OnCanLoad(array $Item): bool
33 {
34 return array_key_exists($Item['Name'], $_POST);
35 }
36
37 function OnLoadDb(array $Item): ?string
38 {
39 return $Item['Value'];
40 }
41
42 function OnSaveDb(array $Item): ?string
43 {
44 return $Item['Value'];
45 }
46
47 function DatabaseEscape(string $Value): string
48 {
49 return addslashes($Value);
50 }
51
52 function OnFilterName(array $Item): string
53 {
54 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
55 $SQL = '('.$Item['SQL'].') AS ';
56 else $SQL = '';
57 return $SQL.'`'.$Item['Name'].'`';
58 }
59
60 function OnFilterNameQuery(array $Item): string
61 {
62 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
63 $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`';
64 else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
65 return $Output;
66 }
67
68 function Validate(array $Item): bool
69 {
70 return true;
71 }
72
73 function GetValidationFormat(): string
74 {
75 return '';
76 }
77}
Note: See TracBrowser for help on using the repository browser.