示例#1
0
文件: index.php 项目: tedwp/porpoise
try {
    /* handle POST (if any) */
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        GUI::handlePOST();
    }
    /* handle action */
    switch ($_action) {
        case "main":
            GUI::printMessage("%s", GUI::createMainScreen());
            break;
        case "layer":
            $layerProperties = DML::getLayerProperties($_REQUEST["layerName"]);
            if (empty($layerProperties->layer)) {
                $layerProperties = new LayarResponse();
                $layerProperties->layer = $_REQUEST["layerName"];
                DML::saveLayerProperties($_REQUEST["layerName"], $layerProperties);
            }
            GUI::printMessage("%s", GUI::createLayerScreen($_REQUEST["layerName"]));
            break;
        case "poi":
            $poi = DML::getPOI($_REQUEST["layerName"], $_REQUEST["poiID"]);
            if (empty($poi)) {
                throw new Exception(sprintf("POI not found: %s:%s", $_REQUEST["layerName"], $_REQUEST["poiID"]));
            }
            GUI::printMessage("%s", GUI::createPOIScreen($_REQUEST["layerName"], $poi));
            break;
        case "newPOI":
            GUI::printMessage("%s", GUI::createNewPOIScreen($_REQUEST["layerName"]));
            break;
        case "migrate":
            GUI::printMessage("%s", GUI::createMigrationScreen());
示例#2
0
 /**
  * Handle POST
  *
  * Checks whether there is something in the POST to handle and calls
  * appropriate methods if there is.
  *
  * @throws Exception When invalid data is passed in POST
  */
 public static function handlePOST()
 {
     $post = $_POST;
     /* not interested in login attempts */
     unset($post["username"]);
     unset($post["password"]);
     if (empty($post)) {
         /* nothing interesting in POST */
         return;
     }
     $action = $_REQUEST["action"];
     switch ($action) {
         case "poi":
             $poi = self::makePOIFromRequest($post);
             DML::savePOI($_REQUEST["layerName"], $poi);
             break;
         case "newPOI":
             $poi = self::makePOIFromRequest($post);
             DML::savePOI($_REQUEST["layerName"], $poi);
             self::redirect("layer", array("layerName" => $_REQUEST["layerName"]));
             break;
         case "deletePOI":
             DML::deletePOI($_REQUEST["layerName"], $_REQUEST["poiID"]);
             self::redirect("layer", array("layerName" => $_REQUEST["layerName"]));
             break;
         case "migrate":
             DML::migrateLayers($_REQUEST["from"], $_REQUEST["to"]);
             break;
         case "layer":
             $layerProperties = self::makeLayerPropertiesFromRequest($post);
             $layerProperties->layer = $_REQUEST["layerName"];
             DML::saveLayerProperties($_REQUEST["layerName"], $layerProperties);
             break;
         default:
             throw new Exception(sprintf("No POST handler defined for action %s\n", $action));
     }
 }