Sfoglia il codice sorgente

updated UrlAction_Ant - added download output link

Piotr Labudda 9 anni fa
parent
commit
eccacc7da6

+ 2 - 0
SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-get-wfs-xml/out/.htaccess

@@ -0,0 +1,2 @@
+Order Allow,Deny
+Allow from all

+ 22 - 12
SE/se-lib/Route/UrlAction/Ant.php

@@ -17,12 +17,12 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
       DBG::nicePrint($taskList, 'ant-url_action');
 
       $featureID = V::get('featureID', '', $_GET);
-      $namespace = V::get('namespace', '', $_GET);
+      $typeName = V::get('typeName', '', $_GET);
       // TODO: validate missing ...
 
       UI::startTag('ul');
       foreach ($taskList as $path => $label) {
-        $link = "index.php?_route=UrlAction_Ant&_task=ant&path={$path}&namespace={$namespace}&featureID={$featureID}";
+        $link = "index.php?_route=UrlAction_Ant&_task=ant&path={$path}&typeName={$typeName}&featureID={$featureID}";
         echo UI::h('li', [], [
           UI::h('a', ['href'=>$link], "Uruchom '{$label}'")
         ]);
@@ -35,6 +35,16 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
     UI::dol();
   }
 
+  public function outputAction() {// index.php?_route=UrlAction_Ant&_task=output & path={$path} & file={$file}";
+    $path = V::get('path', '', $_GET);
+    if (!$path) throw new Exception("Missing Ant path!");
+    $file = V::get('file', '', $_GET);
+    if (!$file) throw new Exception("Missing Ant file!");
+    // TODO: allow auth by token?
+
+    throw new Exception("TODO: return output file '$file' from ant task '{$path}'");
+  }
+
   public function antAction() {
     UI::gora();
     try {
@@ -42,26 +52,26 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
       $path = V::get('path', '', $_GET);
       if (!$path) throw new Exception("Missing Ant path!");
       $featureID = V::get('featureID', '', $_GET);
-      $namespace = V::get('namespace', '', $_GET);
-      
-      $namespace_dot = explode(':', $namespace);
-      
+      $typeName = V::get('typeName', '', $_GET);
+      $typeName_dot = explode(':', $typeName);// TODO: get wfs prefix from typeName
 
       // TODO: validate missing ...
       DBG::nicePrint($path, '$path');
       DBG::nicePrint($featureID, '$featureID');
-      DBG::nicePrint($namespace, '$namespace');
+      DBG::nicePrint($typeName, '$typeName');
 
       $taskList = $this->getAntUrlActionList();
       if (!array_key_exists($path, $taskList)) throw new Exception("Ant path not exists! '{$path}'");
 
       echo UI::h('hr');
-      
-	  
-//      $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:TEST_PERMS&SRSNAME=EPSG:3003&featureID=TEST_PERMS.63";
-      $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=".$namespace."&SRSNAME=EPSG:3003&featureID=".$namespace_dot[1].".".$featureID ;
+
+      $webRootUrl = Request::getPathUri() . "schema/ant-url_action/{$path}";// TODO: security - only for test
+      $outputFunctionUrl = Request::getPathUri() . "index.php?_route=UrlAction_Ant&_task=output&path={$path}&file=";
+      DBG::nicePrint($webRootUrl, '$webRootUrl');
+      DBG::nicePrint($outputFunctionUrl, '$outputFunctionUrl');
+      $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=".$typeName."&SRSNAME=EPSG:3003&featureID=".$typeName_dot[1].".".$featureID ;
       $cryptedPass = base64_encode(User::getLogin() . ":" . Crypt::decrypt($_SESSION['ADM_PASS_HASH']));
-      $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} -S  -Durl='{$testUrl}' -DpasswordBase64Basic='{$cryptedPass}' 2>&1";
+      $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} -S  -DoutputFunctionUrl='{$outputFunctionUrl}' -DwebRootUrl='{$webRootUrl}' -Durl='{$testUrl}' -DpasswordBase64Basic='{$cryptedPass}' 2>&1";
       DBG::nicePrint(str_replace(APP_PATH_ROOT, 'SE', $cmd), 'command');
       V::exec($cmd, $out, $ret);
       DBG::nicePrint($out, 'output');