CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MetadataSchema--Test.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: SPT--FileName.php
4 #
5 # FUNCTIONS PROVIDED:
6 # FunctionName($Parameter, $Parameter)
7 # - brief description of function supplied for use in HTML file
8 #
9 # FUNCTIONS EXPECTED:
10 # FunctionName($Parameter, $Parameter)
11 # - brief description of function that HTML file must supply
12 #
13 # OPTIONAL FUNCTIONS:
14 # FunctionName($Parameter, $Parameter)
15 # - brief description of function that HTML file may supply
16 #
17 # FORM FIELDS EXPECTED:
18 # F_FormFieldName
19 # - brief description of form field purpose and/or content
20 #
21 # Part of the Scout Portal Toolkit
22 # Copyright 2002 Internet Scout Project
23 # http://scout.cs.wisc.edu
24 #
25
26 require_once("include/SPT--Common.php");
27 PageTitle("");
28
29 require_once("include/SPT--MetadataSchema.php");
30
31
32 # ----- EXPORTED FUNCTIONS ---------------------------------------------------
33
34 # ----- LOCAL FUNCTIONS ------------------------------------------------------
35
36 function ListFields(&$Schema)
37 {
38 $Fields = $Schema->GetFields();
39 foreach ($Fields as $Field)
40 {
41 printf("Id: %d<br>\n", $Field->Id());
42 printf("Name: %s<br>\n", $Field->Name());
43 printf("Type: %s<br>\n", $Field->Type());
44 }
45 }
46
47 function UnitTest()
48 {
49 print("<br>Creating schema...<br>");
50 $Schema = new MetadataSchema();
51
52 print("<br>Listing fields...<br>");
53 ListFields($Schema);
54
55 print("<br>Adding field...<br>");
56 $Schema->AddField("TestFieldOne", MetadataSchema::MDFTYPE_NUMBER);
57 $Schema->AddField("TestFieldTwo", MetadataSchema::MDFTYPE_PARAGRAPH);
58
59 print("<br>Listing fields...<br>");
60 ListFields($Schema);
61
62 print("<br>Dropping field...<br>");
63 $Field = $Schema->GetFieldByName("TestFieldOne");
64 $Schema->DropField($Field->Id());
65 $Field = $Schema->GetFieldByName("TestFieldTwo");
66 $Schema->DropField($Field->Id());
67
68 print("<br>Listing fields...<br>");
69 ListFields($Schema);
70 }
71
72
73 # ----- MAIN -----------------------------------------------------------------
74
75 include(FindUIFile("include/SPT--StandardPageStart.html"));
76 UnitTest();
77 include(FindUIFile("include/SPT--StandardPageEnd.html"));
78
79 ?>