source: trunk/www/Base/Types/Type.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
File size: 3.6 KB
Line 
1<?php
2
3include(dirname(__FILE__).'/Base.php');
4include(dirname(__FILE__).'/Enumeration.php');
5include(dirname(__FILE__).'/Boolean.php');
6include(dirname(__FILE__).'/Integer.php');
7include(dirname(__FILE__).'/String.php');
8include(dirname(__FILE__).'/Text.php');
9include(dirname(__FILE__).'/PointerOneToMany.php');
10include(dirname(__FILE__).'/PointerOneToOne.php');
11include(dirname(__FILE__).'/Date.php');
12include(dirname(__FILE__).'/Time.php');
13include(dirname(__FILE__).'/DateTime.php');
14include(dirname(__FILE__).'/Password.php');
15include(dirname(__FILE__).'/Float.php');
16include(dirname(__FILE__).'/Hyperlink.php');
17include(dirname(__FILE__).'/Hidden.php');
18include(dirname(__FILE__).'/File/File.php');
19include(dirname(__FILE__).'/GPS.php');
20include(dirname(__FILE__).'/IPv4Address.php');
21
22$TypeDefinitionList = array(
23 'Enumeration' => array('Name' => 'Enumeration', 'Class' => 'Enumeration', 'ParentType' => '', 'Parameters' => array()),
24 'Boolean' => array('Name' => 'Boolean', 'Class' => 'Boolean', 'ParentType' => '', 'Parameters' => array()),
25 'Integer' => array('Name' => 'Integer', 'Class' => 'Integer', 'ParentType' => '', 'Parameters' => array()),
26 'String' => array('Name' => 'String', 'Class' => 'String', 'ParentType' => '', 'Parameters' => array()),
27 'Text' => array('Name' => 'Text', 'Class' => 'Text', 'ParentType' => '', 'Parameters' => array()),
28 'Date' => array('Name' => 'Date', 'Class' => 'Date', 'ParentType' => '', 'Parameters' => array()),
29 'Time' => array('Name' => 'Time', 'Class' => 'Time', 'ParentType' => '', 'Parameters' => array()),
30 'DateTime' => array('Name' => 'DateTime', 'Class' => 'DateTime', 'ParentType' => '', 'Parameters' => array()),
31 'Password' => array('Name' => 'Password', 'Class' => 'Password', 'ParentType' => '', 'Parameters' => array()),
32 'Float' => array('Name' => 'Float', 'Class' => 'Float', 'ParentType' => '', 'Parameters' => array()),
33 'Hyperlink' => array('Name' => 'Hyperlink', 'Class' => 'Hyperlink', 'ParentType' => '', 'Parameters' => array()),
34 'Hidden' => array('Name' => 'Hidden', 'Class' => 'Hidden', 'ParentType' => '', 'Parameters' => array()),
35 'File' => array('Name' => 'File', 'Class' => 'File', 'ParentType' => '', 'Parameters' => array()),
36 'GPS' => array('Name' => 'GPS', 'Class' => 'GPS', 'ParentType' => '', 'Parameters' => array()),
37 'IPv4Address' => array('Name' => 'IPv4Address', 'Class' => 'IPv4Address', 'ParentType' => '', 'Parameters' => array()),
38 'PointerOneToOne' => array('Name' => 'PointerOneToOne', 'Class' => 'PointerOneToOne', 'ParentType' => '', 'Parameters' => array()),
39 'PointerOneToMany' => array('Name' => 'PointerOneToMany', 'Class' => 'PointerOneToMany', 'ParentType' => '', 'Parameters' => array()),
40);
41
42function ExecuteTypeEvent($System, $TypeName, $Event, $Parameters = array())
43{
44 global $TypeDefinitionList;
45
46 if(array_key_exists($TypeName, $TypeDefinitionList))
47 {
48 $Type = $TypeDefinitionList[$TypeName];
49 $TypeClass = 'Type'.$Type['Class'];
50 $TypeObject = new $TypeClass($System);
51 if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
52 else return($TypeName.'->'.$Event.'('.serialize($Parameters).')');
53 } else return($TypeName);
54}
55
56function RegisterType($Name, $ParentType, $Parameters)
57{
58 global $TypeDefinitionList;
59
60 if($ParentType != '')
61 {
62 $Type = $TypeDefinitionList[$ParentType];
63 } else $Type = array();
64
65 $Type['Name'] = $Name;
66 $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters);
67 $TypeDefinitionList[$Name] = $Type;
68}
69
70function GetTypeDefinition($TypeName)
71{
72 global $TypeDefinitionList;
73
74 return($TypeDefinitionList[$TypeName]);
75}
Note: See TracBrowser for help on using the repository browser.