]> dev.renevier.net Git - syj.git/commitdiff
exported path: use title instead of idx for filename
authorarno <arno@renevier.net>
Mon, 18 Apr 2011 15:54:44 +0000 (17:54 +0200)
committerarno <arno@renevier.net>
Mon, 18 Apr 2011 15:54:44 +0000 (17:54 +0200)
application/controllers/GeomController.php
application/models/PathMapper.php
application/views/scripts/idx/index.phtml

index 497b2a8ca4692561644c743d68e8f0454e619c04..b01837c8c50c218e20cb452c59ffc6ff3bebe4dc 100644 (file)
@@ -28,12 +28,14 @@ class GeomController extends Zend_Controller_Action
         }
 
         if (!$pathMapper->find($idx, $path)) {
-            if ($pathMapper->hasexisted($idx)) {
-                $api->setCode(410);
-            } else {
-                $api->setCode(404);
+            if (!$pathMapper->findByTitle($idx, $path)) {
+                if ($pathMapper->hasexisted($idx)) {
+                    $api->setCode(410);
+                } else {
+                    $api->setCode(404);
+                }
+                return;
             }
-            return;
         }
 
         switch ($ext) {
index 7f43e2239b64bae6d1187c9ea1c44f6571d77059..7d514e9f655a9ffac7c746f11cef451838468a52 100644 (file)
@@ -35,6 +35,12 @@ class Syj_Model_PathMapper
         return $this->_fetchItem($select, $path);
     }
 
+    public function findByTitle($title, Syj_Model_Path $path) {
+        $select = $this->_select();
+        $select->where('title = ?', (string)$title);
+        return $this->_fetchItem($select, $path);
+    }
+
     public function findByUrl($url, Syj_Model_Path $path) {
         $select = $this->_select();
         $select->where('id = ?', (int)$url)->orWhere('urlcomp = ?', (string)$url);
index b69bf38d99e14f30fb9c3516e13c276315737e13..03355a2a817799b132cbbcc502db1286ff3e7cbb 100644 (file)
@@ -85,14 +85,14 @@ if ($this->errorMsg) {
 
                     <div id="path-export-title" class="info-title"><?php echo $this->translate("export")?></div>
                     <div id="path-export-content"><?php
-                       $href = $fullBaseUrl . 'geom/' . urlencode($this->path->id) . '.kml';
+                       $href = $fullBaseUrl . 'geom/' . rawurlencode($this->path->displayTitle) . '.kml';
                        printf('<a href="%s" title="%s">%s</a>',
                                         $href,
                                         $this->translate('kml export'),
                                         $this->translate('kml export'));
 
                         print '<br>';
-                       $href = $fullBaseUrl . 'geom/' . urlencode($this->path->id) . '.gpx';
+                       $href = $fullBaseUrl . 'geom/' . rawurlencode($this->path->displayTitle) . '.gpx';
                        printf('<a href="%s" title="%s">%s</a>',
                                         $href,
                                         $this->translate('gpx export'),