From: arno Date: Mon, 18 Apr 2011 15:54:44 +0000 (+0200) Subject: exported path: use title instead of idx for filename X-Git-Tag: v0.3.2~2 X-Git-Url: https://dev.renevier.net/?p=syj.git;a=commitdiff_plain;h=9f80d909c85ea324ed3337348b6e83ec39b70a78 exported path: use title instead of idx for filename --- 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'),