コード例 #1
0
ファイル: utils.php プロジェクト: geofac/mapguide-rest
 public static function ParseLibraryResourceID($parts, $stopAt = null)
 {
     $appendSlash = false;
     $count = count($parts);
     if ($stopAt != null) {
         $newParts = array();
         for ($i = 0; $i < $count; $i++) {
             if ($parts[$i] === $stopAt) {
                 break;
             } else {
                 array_push($newParts, $parts[$i]);
             }
         }
         $parts = $newParts;
         $count = count($parts);
     }
     if ($count > 0) {
         $lastPart = $parts[$count - 1];
         //If the last part is not a known resource extension, append a slash to indicate a folder
         if (!MgUtils::StringEndsWith($lastPart, "." . MgResourceType::FeatureSource) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::LayerDefinition) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::MapDefinition) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::WebLayout) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::ApplicationDefinition) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::SymbolDefinition) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::DrawingSource) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::PrintLayout) && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::SymbolLibrary) && !MgUtils::StringEndsWith($lastPart, ".WatermarkDefinition") && !MgUtils::StringEndsWith($lastPart, ".TileSetDefinition") && !MgUtils::StringEndsWith($lastPart, "." . MgResourceType::LoadProcedure)) {
             $appendSlash = true;
         }
     }
     $resIdStr = "Library://" . implode("/", $parts);
     if ($appendSlash === true) {
         $resIdStr .= "/";
     }
     return new MgResourceIdentifier($resIdStr);
 }
コード例 #2
0
ファイル: routes.doc.php プロジェクト: geofac/mapguide-rest
    } else {
        $docUrl = $app->config("SelfUrl") . "/apidoc";
    }
    $assetUrlRoot = $app->config("SelfUrl") . "/doc";
    $docTpl = $app->config("AppRootDir") . "/assets/doc/viewer.tpl";
    $smarty = new Smarty();
    $smarty->setCompileDir($app->config("Cache.RootDir") . "/templates_c");
    $smarty->assign("title", $app->localizer->getText("L_PRODUCT_API_REFERENCE", "mapguide-rest"));
    $smarty->assign("docUrl", $docUrl);
    $smarty->assign("docAssetRoot", $assetUrlRoot);
    $output = $smarty->fetch($docTpl);
    $app->response->header("Content-Type", "text/html");
    $app->response->setBody($output);
});
$app->get("/apidoc/:file", function ($file) use($app) {
    if (MgUtils::StringEndsWith($file, ".json")) {
        $file = str_replace(".json", "", $file);
    }
    $prefix = MgUtils::GetApiVersionNamespace($app, "/apidoc");
    if (strlen($prefix) > 0) {
        $path = $app->config("AppRootDir") . "/doc/data/{$prefix}/{$file}.json";
    } else {
        $path = $app->config("AppRootDir") . "/doc/data/{$file}.json";
    }
    $doc = json_decode(file_get_contents($path));
    if (strlen($prefix) > 0) {
        $doc->basePath = $app->config("SelfUrl") . "/{$prefix}";
    } else {
        $doc->basePath = $app->config("SelfUrl");
    }
    $doc->swaggerVersion = SWAGGER_API_VERSION;