X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=gwvplib%2Fgwvpweb.php;h=6f8c36cad3fa87111e7c49ec2e6f084ae899b82d;hb=20d1cc1a856b039329b382a8119454099896c938;hp=f4761614eb63f815a3d7b5d18c20d45e8682685c;hpb=4c20cd2f33699e549a06995d9c5ab1374cceeaee;p=gwvp.git diff --git a/gwvplib/gwvpweb.php b/gwvplib/gwvpweb.php index f476161..6f8c36c 100644 --- a/gwvplib/gwvpweb.php +++ b/gwvplib/gwvpweb.php @@ -20,7 +20,8 @@ function gwvp_goWebBegin() // next, we go thru the CALL_ME_FUNCTIONS - the purpose of call_me_functions is to determine if a function should be called based on // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call) - // this is important for our plugin structure later on + // this is important for our plugin structure later on - the key on the array serves an an ordering method + ksort($CALL_ME_FUNCTIONS); foreach($CALL_ME_FUNCTIONS as $key => $val) { error_log("checking callmefunction $key as $val"); $callme = $val(); @@ -34,6 +35,12 @@ function gwvp_goWebBegin() gwvp_goMainPage(); } +function gwvp_SendMessage($messagetype, $message) +{ + $_SESSION["messagetype"] = $messagetype; + $_SESSION["message"] = $message; +} + function gwvp_goMainPage($bodyFunction = null) { // the main page will look pretty simple, a title, a menu then a body @@ -79,9 +86,21 @@ function gwvp_goMainPage($bodyFunction = null) echo "

Git over Web Via PHP

"; - echo "
"; + echo ""; + + if(isset($_SESSION["message"])) { + echo ""; + } + + echo ""; + echo ""; + + echo ""; echo "
"; + gwvp_MessageBuilder(); + echo "
"; gwvp_MenuBuilder(); - echo "
"; + gwvp_LoginBuilder(); + echo "
"; if($bodyFunction == null) { @@ -90,7 +109,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(); } } @@ -102,23 +121,83 @@ function gwvp_goMainPage($bodyFunction = null) } + +// builds the message builder if its needed +function gwvp_MessageBuilder() +{ + $message = ""; + $messagetype = "info"; + if(isset($_SESSION["message"])) $message = $_SESSION["message"]; + if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"]; + + if($message != "") { + switch($messagetype) { + case "info": + echo "
$message
"; + break; + case "error": + echo "
$message
"; + break; + } + unset($_SESSION["message"]); + if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]); + } +} + // builds the menu structure function gwvp_MenuBuilder() { - global $MENU_ITEMS; + global $MENU_ITEMS, $BASE_URL; ksort($MENU_ITEMS); - echo ""; + echo "
Menu
"; foreach($MENU_ITEMS as $key => $val) { $link = $val["link"]; $text = $val["text"]; - echo ""; + + // 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 "$text"; + } + + } else { + echo "$text"; + } } echo "
Menu$text
"; } +function gwvp_LoginBuilder() +{ + global $WEB_ROOT_FS, $BASE_URL; + + $login = gwvp_IsLoggedIn(); + if($login === false) { + gwvp_SingleLineLoginForm(); + } else { + echo "Hello, ".gwvp_GetFullName($login)." logout"; + } +} + // builds the body structure function gwvp_BodyBuilder() {