Moving the old code aside into the archive as i begin a new
[glcas.git] / archive / v1 / lib / www.php
1 <?php
2
3 global $BASE_URLS;
4
5 $BASE_URLS["wp"]["base"] = "";
6 $BASE_URLS["wp"]["function"] = "wp_pageBuilder";
7 $MENU_ITEMS["wp"]["title"] = "Home";
8 $MENU_ITEMS["wp"]["link"] = "/";
9
10 function goWebProcessor($calls)
11 {
12         if(isset($calls["needs_base_page"])) {
13                 if($calls["needs_base_page"] == true) {
14                         // build page
15                         // echo "here base\n";
16                         www_basePage($calls);
17                 } else {
18                         $func = $calls["page_builder"];
19                         $func();
20                 }
21         } else {
22                 www_basePage($calls);
23         }
24 }
25
26 function wp_pageBuilder()
27 {
28         $calls["needs_base_page"] = true;
29         
30         return $calls;
31 }
32
33 function www_basePage($calls)
34 {
35                 
36         // header
37         if(isset($calls["header_function"])) {
38                 $func = $calls["header_function"];
39                 $func();
40         } else {
41                 www_header();
42         }
43         
44         echo "<table><tr><td colspan=\"2\">";
45         
46         // top
47         if(isset($calls["top_function"])) {
48                 $func = $calls["top_function"];
49                 $func();
50         } else {
51                 www_top();
52         }
53         
54         echo "</td></tr><tr valign=\"top\"><td>";
55         
56         // left menu
57         if(isset($calls["left_menu_function"])) {
58                 $func = $calls["left_menu_function"];
59                 $func();
60         } else {
61                 www_leftmenu();
62         }
63         
64         echo "</td><td>";
65         
66         // contentpane
67         if(isset($calls["content_pane_function"])) {
68                 $func = $calls["content_pane_function"];
69                 $func();
70         } else {
71                 www_contentpane();
72         }
73         
74         echo "</td></tr><tr colspan=\"2\"><td>";
75         
76         // footer
77         if(isset($calls["footer_function"])) {
78                 $func = $calls["footer_function"];
79                 $func();
80         } else {
81                 www_footer();
82         }
83         
84         echo "</td></tr></table>";
85
86         // page end
87         if(isset($calls["page_end_function"])) {
88                 $func = $calls["page_end_function"];
89                 $func();
90         } else {
91                 www_pageend();
92         }
93         
94 }
95
96 function www_header()
97 {
98         echo "<html><head>";
99         echo "<link rel=\"stylesheet\" href=\"".urlCreate("/css/content.css")."\" type=\"text/css\" media=\"screen, projection\" /> ";
100         echo "</head><body>";
101 }
102
103 function www_top()
104 {
105         echo "<h1>Welcome to GLCAS</h1>";
106         echo "<table><tr>";
107         
108         global $MENU_ITEMS, $GLOBAL_BASE_URL;
109         foreach($MENU_ITEMS as $mes) {
110                 $mtext = $mes["title"];
111                 $mlink = "$GLOBAL_BASE_URL/".$mes["link"];
112                 // remove the excess /'s
113                 $mlink2 = preg_replace("/\/[\/]+/", "/", $mlink);
114                 //echo "went from $mlink to $mlink2\n";
115                 echo "<td><a href=\"$mlink2\">$mtext</a></td>";
116         }
117         
118         echo "</tr></table>";
119         if(function_exists("msg_haveMessages")) if(msg_haveMessages()) {
120                 echo "<table bgcolor=\"#eeeeff\">";
121                 $msgs = msg_getMessages();
122                 
123                 foreach($msgs as $msg) {
124                         $msgtime = msg_toDate($msg["msgdate"]);
125                         $msgcol = $msg["msgcolour"];
126                         $msgtxt = $msg["msgtext"];
127                         $msgid = $msg["messages_id"];
128                         
129                         echo "<tr><td><font color=\"$msgcol\">$msgtime - $msgtxt</font></td>";
130                         echo "<td><a href=\"".urlCreate("/msg/acknowledge/$msgid")."\">Acknowledge</a></td></tr>";
131                 }
132                 echo "</table>";
133         }
134 }
135
136 function www_leftmenu()
137 {
138         echo "i be a left menu, yar";
139 }
140
141 function www_contentpane()
142 {
143         echo "i be a content pane, yar";
144 }
145
146 function www_footer()
147 {
148         echo "i be a footer, yar";
149 }       
150         
151         
152 function www_pageend()
153 {
154         echo "</body></html>";
155 }
156
157 function urlCreate($from)
158 {
159         global $MENU_ITEMS, $GLOBAL_BASE_URL;
160
161         $mlink = "$GLOBAL_BASE_URL/".$from;
162         $mlink = preg_replace("/\/[\/]+/", "/", $mlink);
163         
164         return $mlink;
165         
166 }
167
168
169 ?>