1 | <?php
|
---|
2 |
|
---|
3 | include(dirname(__FILE__).'/Base.php');
|
---|
4 | include(dirname(__FILE__).'/Enumeration.php');
|
---|
5 | include(dirname(__FILE__).'/Boolean.php');
|
---|
6 | include(dirname(__FILE__).'/Integer.php');
|
---|
7 | include(dirname(__FILE__).'/String.php');
|
---|
8 | include(dirname(__FILE__).'/Text.php');
|
---|
9 | include(dirname(__FILE__).'/PointerOneToMany.php');
|
---|
10 | include(dirname(__FILE__).'/PointerOneToOne.php');
|
---|
11 | include(dirname(__FILE__).'/Date.php');
|
---|
12 | include(dirname(__FILE__).'/Time.php');
|
---|
13 | include(dirname(__FILE__).'/DateTime.php');
|
---|
14 | include(dirname(__FILE__).'/Password.php');
|
---|
15 | include(dirname(__FILE__).'/Float.php');
|
---|
16 | include(dirname(__FILE__).'/Hyperlink.php');
|
---|
17 | include(dirname(__FILE__).'/Hidden.php');
|
---|
18 | include(dirname(__FILE__).'/File/File.php');
|
---|
19 | include(dirname(__FILE__).'/GPS.php');
|
---|
20 | include(dirname(__FILE__).'/IPv4Address.php');
|
---|
21 |
|
---|
22 | class Type
|
---|
23 | {
|
---|
24 | var $System;
|
---|
25 | var $TypeDefinitionList;
|
---|
26 |
|
---|
27 | function __construct($System)
|
---|
28 | {
|
---|
29 | $this->System = $System;
|
---|
30 | $this->TypeDefinitionList = array
|
---|
31 | (
|
---|
32 | 'Enumeration' => array('Name' => 'Enumeration', 'Class' => 'Enumeration', 'ParentType' => '', 'Parameters' => array()),
|
---|
33 | 'Boolean' => array('Name' => 'Boolean', 'Class' => 'Boolean', 'ParentType' => '', 'Parameters' => array()),
|
---|
34 | 'Integer' => array('Name' => 'Integer', 'Class' => 'Integer', 'ParentType' => '', 'Parameters' => array()),
|
---|
35 | 'String' => array('Name' => 'String', 'Class' => 'String', 'ParentType' => '', 'Parameters' => array()),
|
---|
36 | 'Text' => array('Name' => 'Text', 'Class' => 'Text', 'ParentType' => '', 'Parameters' => array()),
|
---|
37 | 'Date' => array('Name' => 'Date', 'Class' => 'Date', 'ParentType' => '', 'Parameters' => array()),
|
---|
38 | 'Time' => array('Name' => 'Time', 'Class' => 'Time', 'ParentType' => '', 'Parameters' => array()),
|
---|
39 | 'DateTime' => array('Name' => 'DateTime', 'Class' => 'DateTime', 'ParentType' => '', 'Parameters' => array()),
|
---|
40 | 'Password' => array('Name' => 'Password', 'Class' => 'Password', 'ParentType' => '', 'Parameters' => array()),
|
---|
41 | 'Float' => array('Name' => 'Float', 'Class' => 'Float', 'ParentType' => '', 'Parameters' => array()),
|
---|
42 | 'Hyperlink' => array('Name' => 'Hyperlink', 'Class' => 'Hyperlink', 'ParentType' => '', 'Parameters' => array()),
|
---|
43 | 'Hidden' => array('Name' => 'Hidden', 'Class' => 'Hidden', 'ParentType' => '', 'Parameters' => array()),
|
---|
44 | 'File' => array('Name' => 'File', 'Class' => 'File', 'ParentType' => '', 'Parameters' => array()),
|
---|
45 | 'GPS' => array('Name' => 'GPS', 'Class' => 'GPS', 'ParentType' => '', 'Parameters' => array()),
|
---|
46 | 'IPv4Address' => array('Name' => 'IPv4Address', 'Class' => 'IPv4Address', 'ParentType' => '', 'Parameters' => array()),
|
---|
47 | 'PointerOneToOne' => array('Name' => 'PointerOneToOne', 'Class' => 'PointerOneToOne', 'ParentType' => '', 'Parameters' => array()),
|
---|
48 | 'PointerOneToMany' => array('Name' => 'PointerOneToMany', 'Class' => 'PointerOneToMany', 'ParentType' => '', 'Parameters' => array()),
|
---|
49 | );
|
---|
50 | }
|
---|
51 |
|
---|
52 | function ExecuteTypeEvent($TypeName, $Event, $Parameters = array())
|
---|
53 | {
|
---|
54 | if(array_key_exists($TypeName, $this->TypeDefinitionList))
|
---|
55 | {
|
---|
56 | $Type = $this->TypeDefinitionList[$TypeName];
|
---|
57 | $TypeClass = 'Type'.$Type['Class'];
|
---|
58 | $TypeObject = new $TypeClass($this->System);
|
---|
59 | if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
|
---|
60 | else return($TypeName.'->'.$Event.'('.serialize($Parameters).')');
|
---|
61 | } else return($TypeName);
|
---|
62 | }
|
---|
63 |
|
---|
64 | function RegisterType($Name, $ParentType, $Parameters)
|
---|
65 | {
|
---|
66 | if($ParentType != '')
|
---|
67 | {
|
---|
68 | $Type = $this->TypeDefinitionList[$ParentType];
|
---|
69 | } else $Type = array();
|
---|
70 |
|
---|
71 | $Type['Name'] = $Name;
|
---|
72 | $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters);
|
---|
73 | $this->TypeDefinitionList[$Name] = $Type;
|
---|
74 | }
|
---|
75 |
|
---|
76 | function GetTypeDefinition($TypeName)
|
---|
77 | {
|
---|
78 | return($this->TypeDefinitionList[$TypeName]);
|
---|
79 | }
|
---|
80 | }
|
---|