6c3723b1926d4af7df41165ca1a53ac8a909e050
[glcas.git] / libglcas / web.php
1 <?php 
2
3 // if i believed in name spacing in php, i'd use it.
4 error_log("glcasweb loaded");
5
6 class GLCASWeb {
7         
8         function __construct($config)
9         {
10                 $this->config = $config;
11         }
12         
13         function go($urlhandlers)
14         {
15                 $url = "/";
16                 if(isset($_REQUEST["q"])) {
17                         $url = $_REQUEST["q"];
18                 }
19                 
20                 // create a url parser
21                 $urlparser = new GLCASUrlParser($urlhandlers, $this->config);
22                 
23                 // 
24                 $call_class = $urlparser->getClass($url);
25                 $call_class->go($url);
26         }
27         
28         private $config;
29         
30 }
31
32 function GLCASpageBuilder($bodyClass, $bodyFunction, $title="GLCAS")
33 {
34         global $WEB_ROOT_FS;
35         
36         // TODO: load css
37         // TODO: load js
38         // header
39         echo "<html><title>$title</title><body>";
40         
41         // page top
42         echo "<h1>GLCAS</h1><br>";
43         echo "<table><tr><td>messages go here<td></tr><tr><td>";
44         
45         // menu, then body
46         echo "<table><tr><td>Menu goes here</td></tr><tr><td>";
47         // body
48         $url = "/";
49         if(isset($_REQUEST["q"])) {
50                 $url = $_REQUEST["q"];
51         }
52         
53         if($bodyClass != null) {
54                 $bodyClass->$bodyFunction($url);
55         } else $bodyFunction($url);
56         echo "</td></tr></table>";
57         
58         
59         // close the big wrap-around table
60         echo "</td></tr></table>";
61         
62         // footer
63         echo "<br><font size=\"-1\">Copyright 2011, PJR</font><br></body></html>";
64         
65 }
66
67
68 ?>