reaplced the git service code (main gitbackendinterface()) with a new
[gwvp.git] / gwvplib / gwvpweb.php
index 8607e07..3cc931c 100644 (file)
@@ -3,6 +3,9 @@
 // this function is the initial insertion point for the web calls, here we need to determine where we go
 global $CALL_ME_FUNCTIONS;
 
+// the home_page_provders bit is an array 
+global $HOME_PAGE_PROVIDERS;
+
 $MENU_ITEMS["00home"]["text"] = "Home";
 $MENU_ITEMS["00home"]["link"] = "$BASE_URL";
 
@@ -94,7 +97,7 @@ function gwvp_goMainPage($bodyFunction = null)
                echo "</td></tr>";
        }
        
-       echo "<tr width=\"100%\" bgcolor=\"#fff0f0\"><td>";
+       echo "<tr width=\"100%\" bgcolor=\"#ddffdd\"><td>";
        gwvp_MenuBuilder();
        echo "</td><td align=\"right\">";
        gwvp_LoginBuilder();
@@ -109,7 +112,7 @@ function gwvp_goMainPage($bodyFunction = null)
                if(function_exists($bodyFunction)) {
                        $bodyFunction();
                } else {
-                       error_log("Got called with non-existant body function");
+                       error_log("Got called with non-existant body function, $bodyFunction");
                        gwvp_BodyBuilder();
                }
        }
@@ -147,24 +150,44 @@ function gwvp_MessageBuilder()
 // builds the menu structure
 function gwvp_MenuBuilder()
 {
-       global $MENU_ITEMS;
+       global $MENU_ITEMS, $BASE_URL;
        
        ksort($MENU_ITEMS);
        
+       echo "\n\n\n";
        echo "<table border=\"1\"><tr><td><b><i>Menu</i></b></td>";
        foreach($MENU_ITEMS as $key => $val) {
                $link = $val["link"];
                $text = $val["text"];
+               
+               // TODO: redo this bit with stristr to find urls - special case for home
+               $menucolor = "";
+               if(isset($_REQUEST["q"])) {
+                       $extlink = str_replace("$BASE_URL/", "", $link);
+                       error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
+                       if(stristr($_REQUEST["q"], $extlink)!==false) {
+                               $menucolor = " bgcolor=\"#ffdddd\"";
+                               
+                       }
+               } else {
+                       // special case for home
+                       if($link == $BASE_URL) $menucolor = " bgcolor=\"#ffdddd\"";
+               }
+               
+               
+               
+               
                if(isset($val["userlevel"])) {
                        if(gwvp_CheckAuthLevel($val["userlevel"])) {
-                               echo "<td><a href=\"$link\">$text</a></td>";
+                               echo "<td$menucolor><a href=\"$link\">$text</a></td>";
                        }
                        
                } else {
-                       echo "<td><a href=\"$link\">$text</a></td>";
+                       echo "<td$menucolor><a href=\"$link\">$text</a></td>";
                }
        }
        echo "</tr></table>";
+       echo "\n\n\n";
        
 }
 
@@ -172,18 +195,29 @@ function gwvp_LoginBuilder()
 {
        global $WEB_ROOT_FS, $BASE_URL;
        
+       echo "\n\n\n";
        $login = gwvp_IsLoggedIn();
        if($login === false) {
                gwvp_SingleLineLoginForm();
        } else {
                echo "Hello, ".gwvp_GetFullName($login)." <a href=\"$BASE_URL/logout\">logout</a>";
        }
+       echo "\n\n\n";
 }
 
 // builds the body structure
 function gwvp_BodyBuilder()
 {
-       echo "I AM THE MAIN BODY, FEAR ME!!!!";
+       global $HOME_PAGE_PROVIDERS;
+       
+       echo "I AM THE MAIN BODY, FEAR ME!!!! - have no idea whats going to go here";
+       if(isset($HOME_PAGE_PROVIDERS)) {
+               ksort($HOME_PAGE_PROVIDERS);
+               foreach($HOME_PAGE_PROVIDERS as $provider) {
+                       error_log("Loading home_page_provider, $provider");
+                       $provider();
+               }
+       }
 }
 
 // builds the tail structure
@@ -192,4 +226,16 @@ function gwvp_TailBuilder()
        echo "<font size=\"-1\"><i>Copyright 2011, PJR - licensed under GPL</i></font>";
 }
 
+function gwvp_fourZeroThree()
+{
+       header("HTTP/1.0 403 Permission Denied");
+}
+
+function gwvp_fourZeroFour()
+{
+       header("HTTP/1.0 404 No Such Thing");
+}
+
+
+
 ?>
\ No newline at end of file