Moving the old code aside into the archive as i begin a new
[glcas.git] / archive / v1 / lib / www.php
diff --git a/archive/v1/lib/www.php b/archive/v1/lib/www.php
new file mode 100644 (file)
index 0000000..f356ca0
--- /dev/null
@@ -0,0 +1,169 @@
+<?php
+
+global $BASE_URLS;
+
+$BASE_URLS["wp"]["base"] = "";
+$BASE_URLS["wp"]["function"] = "wp_pageBuilder";
+$MENU_ITEMS["wp"]["title"] = "Home";
+$MENU_ITEMS["wp"]["link"] = "/";
+
+function goWebProcessor($calls)
+{
+       if(isset($calls["needs_base_page"])) {
+               if($calls["needs_base_page"] == true) {
+                       // build page
+                       // echo "here base\n";
+                       www_basePage($calls);
+               } else {
+                       $func = $calls["page_builder"];
+                       $func();
+               }
+       } else {
+               www_basePage($calls);
+       }
+}
+
+function wp_pageBuilder()
+{
+       $calls["needs_base_page"] = true;
+       
+       return $calls;
+}
+
+function www_basePage($calls)
+{
+               
+       // header
+       if(isset($calls["header_function"])) {
+               $func = $calls["header_function"];
+               $func();
+       } else {
+               www_header();
+       }
+       
+       echo "<table><tr><td colspan=\"2\">";
+       
+       // top
+       if(isset($calls["top_function"])) {
+               $func = $calls["top_function"];
+               $func();
+       } else {
+               www_top();
+       }
+       
+       echo "</td></tr><tr valign=\"top\"><td>";
+       
+       // left menu
+       if(isset($calls["left_menu_function"])) {
+               $func = $calls["left_menu_function"];
+               $func();
+       } else {
+               www_leftmenu();
+       }
+       
+       echo "</td><td>";
+       
+       // contentpane
+       if(isset($calls["content_pane_function"])) {
+               $func = $calls["content_pane_function"];
+               $func();
+       } else {
+               www_contentpane();
+       }
+       
+       echo "</td></tr><tr colspan=\"2\"><td>";
+       
+       // footer
+       if(isset($calls["footer_function"])) {
+               $func = $calls["footer_function"];
+               $func();
+       } else {
+               www_footer();
+       }
+       
+       echo "</td></tr></table>";
+
+       // page end
+       if(isset($calls["page_end_function"])) {
+               $func = $calls["page_end_function"];
+               $func();
+       } else {
+               www_pageend();
+       }
+       
+}
+
+function www_header()
+{
+       echo "<html><head>";
+       echo "<link rel=\"stylesheet\" href=\"".urlCreate("/css/content.css")."\" type=\"text/css\" media=\"screen, projection\" /> ";
+       echo "</head><body>";
+}
+
+function www_top()
+{
+       echo "<h1>Welcome to GLCAS</h1>";
+       echo "<table><tr>";
+       
+       global $MENU_ITEMS, $GLOBAL_BASE_URL;
+       foreach($MENU_ITEMS as $mes) {
+               $mtext = $mes["title"];
+               $mlink = "$GLOBAL_BASE_URL/".$mes["link"];
+               // remove the excess /'s
+               $mlink2 = preg_replace("/\/[\/]+/", "/", $mlink);
+               //echo "went from $mlink to $mlink2\n";
+               echo "<td><a href=\"$mlink2\">$mtext</a></td>";
+       }
+       
+       echo "</tr></table>";
+       if(function_exists("msg_haveMessages")) if(msg_haveMessages()) {
+               echo "<table bgcolor=\"#eeeeff\">";
+               $msgs = msg_getMessages();
+               
+               foreach($msgs as $msg) {
+                       $msgtime = msg_toDate($msg["msgdate"]);
+                       $msgcol = $msg["msgcolour"];
+                       $msgtxt = $msg["msgtext"];
+                       $msgid = $msg["messages_id"];
+                       
+                       echo "<tr><td><font color=\"$msgcol\">$msgtime - $msgtxt</font></td>";
+                       echo "<td><a href=\"".urlCreate("/msg/acknowledge/$msgid")."\">Acknowledge</a></td></tr>";
+               }
+               echo "</table>";
+       }
+}
+
+function www_leftmenu()
+{
+       echo "i be a left menu, yar";
+}
+
+function www_contentpane()
+{
+       echo "i be a content pane, yar";
+}
+
+function www_footer()
+{
+       echo "i be a footer, yar";
+}      
+       
+       
+function www_pageend()
+{
+       echo "</body></html>";
+}
+
+function urlCreate($from)
+{
+       global $MENU_ITEMS, $GLOBAL_BASE_URL;
+
+       $mlink = "$GLOBAL_BASE_URL/".$from;
+       $mlink = preg_replace("/\/[\/]+/", "/", $mlink);
+       
+       return $mlink;
+       
+}
+
+
+?>
\ No newline at end of file