Each webbox is composed of several files and is stored in a single
directory with an index.php3 file. To call a boxaction, the desired
webbox's index.php3 URL is called and also passed the name of the boxaction to
call along with any arguments to it. A typical URL style call would
look like:
<a href="/people/index.php3?boxaction=viewcustomer&custid=12345">View Customer</a>
A typical form-based call to the same boxaction can be written:
<form action="/people/index.php3" method=post>
<index type=hidden name="boxaction" value="viewcustomer">
Enter the customer's ID number: <input type=text name="custid">
<input type=submit value="View Customer Record">
</form>
A given webbox's boxactions are implemented in a single class called a
"gateway". The index.php3 script instantiates the "gateway"
class for its box. A long switch statement on the $boxaction parameter chooses
the boxaction to call. Continuing our "add a customer" example, the relevant
snippet of code from the index.php3 file might look like this:
<?php
$homedir = "/www/htdocs/people/";
include $homedir . "gateway.php3";
$g = new Gateway_People($homedir);
switch ($boxaction) {
case "viewcustomer":
$g->viewCustomer($custid);
break;
case "checkauthentication":
$g->checkAuthentication($username, $password);
break;
//
// Other boxactions
//
default:
$g->showDefaultPage();
break;
}
?>