Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- Search for |

- File List
- File Members

# MetadataSchema--Test.php

Go to the documentation of this file.

    00001 <?PHP
    00002 #
    00003 #   FILE:  SPT--FileName.php
    00004 #
    00005 #   FUNCTIONS PROVIDED:
    00006 #       FunctionName($Parameter, $Parameter)
    00007 #           - brief description of function supplied for use in HTML file
    00008 #
    00009 #   FUNCTIONS EXPECTED:
    00010 #       FunctionName($Parameter, $Parameter)
    00011 #           - brief description of function that HTML file must supply
    00012 #
    00013 #   OPTIONAL FUNCTIONS:
    00014 #       FunctionName($Parameter, $Parameter)
    00015 #           - brief description of function that HTML file may supply
    00016 #
    00017 #   FORM FIELDS EXPECTED:
    00018 #       F_FormFieldName
    00019 #           - brief description of form field purpose and/or content
    00020 #
    00021 #   Part of the Scout Portal Toolkit
    00022 #   Copyright 2002 Internet Scout Project
    00023 #   http://scout.cs.wisc.edu
    00024 #
    00025
    00026 require_once("include/SPT--Common.php");
    00027 PageTitle("");
    00028
    00029 require_once("include/SPT--MetadataSchema.php");
    00030
    00031
    00032 # ----- EXPORTED FUNCTIONS ---------------------------------------------------
    00033
    00034 # ----- LOCAL FUNCTIONS ------------------------------------------------------
    00035
    00036 function ListFields(&$Schema)
    00037 {
    00038     $Fields = $Schema->GetFields();
    00039     foreach ($Fields as $Field)
    00040     {
    00041         printf("Id: %d<br>\n", $Field->Id());
    00042         printf("Name: %s<br>\n", $Field->Name());
    00043         printf("Type: %s<br>\n", $Field->Type());
    00044     }
    00045 }
    00046
    00047 function UnitTest()
    00048 {
    00049     print("<br>Creating schema...<br>");
    00050     $Schema = new MetadataSchema();
    00051
    00052     print("<br>Listing fields...<br>");
    00053     ListFields($Schema);
    00054
    00055     print("<br>Adding field...<br>");
    00056     $Schema->AddField("TestFieldOne", MetadataSchema::MDFTYPE_NUMBER);
    00057     $Schema->AddField("TestFieldTwo", MetadataSchema::MDFTYPE_PARAGRAPH);
    00058
    00059     print("<br>Listing fields...<br>");
    00060     ListFields($Schema);
    00061
    00062     print("<br>Dropping field...<br>");
    00063     $Field = $Schema->GetFieldByName("TestFieldOne");
    00064     $Schema->DropField($Field->Id());
    00065     $Field = $Schema->GetFieldByName("TestFieldTwo");
    00066     $Schema->DropField($Field->Id());
    00067
    00068     print("<br>Listing fields...<br>");
    00069     ListFields($Schema);
    00070 }
    00071
    00072
    00073 # ----- MAIN -----------------------------------------------------------------
    00074
    00075 include(FindUIFile("include/SPT--StandardPageStart.html"));
    00076 UnitTest();
    00077 include(FindUIFile("include/SPT--StandardPageEnd.html"));
    00078
    00079 ?>