From 9f80d909c85ea324ed3337348b6e83ec39b70a78 Mon Sep 17 00:00:00 2001 From: arno Date: Mon, 18 Apr 2011 17:54:44 +0200 Subject: [PATCH] exported path: use title instead of idx for filename --- application/controllers/GeomController.php | 12 +++++++----- application/models/PathMapper.php | 6 ++++++ application/views/scripts/idx/index.phtml | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/application/controllers/GeomController.php b/application/controllers/GeomController.php index 497b2a8..b01837c 100644 --- a/application/controllers/GeomController.php +++ b/application/controllers/GeomController.php @@ -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) { diff --git a/application/models/PathMapper.php b/application/models/PathMapper.php index 7f43e22..7d514e9 100644 --- a/application/models/PathMapper.php +++ b/application/models/PathMapper.php @@ -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); diff --git a/application/views/scripts/idx/index.phtml b/application/views/scripts/idx/index.phtml index b69bf38..03355a2 100644 --- a/application/views/scripts/idx/index.phtml +++ b/application/views/scripts/idx/index.phtml @@ -85,14 +85,14 @@ if ($this->errorMsg) {
translate("export")?>
path->id) . '.kml'; + $href = $fullBaseUrl . 'geom/' . rawurlencode($this->path->displayTitle) . '.kml'; printf('%s', $href, $this->translate('kml export'), $this->translate('kml export')); print '
'; - $href = $fullBaseUrl . 'geom/' . urlencode($this->path->id) . '.gpx'; + $href = $fullBaseUrl . 'geom/' . rawurlencode($this->path->displayTitle) . '.gpx'; printf('%s', $href, $this->translate('gpx export'), -- 2.39.2