From 4a1fd699ac24b8ea2277e83c52a38730a85c108c Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 4 Jun 2010 05:08:11 +0000 Subject: [PATCH] add series with place keyword support, and simple search suppport --- application/config.ini | 6 ++++- .../default/controllers/DataController.php | 22 +++++++++++++++---- .../default/views/scripts/data/series.phtml | 13 ++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/application/config.ini b/application/config.ini index 5fcc4032..0578b80f 100755 --- a/application/config.ini +++ b/application/config.ini @@ -85,10 +85,14 @@ routes.datacat.defaults.controller = "data" routes.datacat.defaults.action = "category" routes.datacat.reqs.code = "\d+" +routes.dataseriesplace.route = "data/series/:id/:keyword" +routes.dataseriesplace.defaults.controller = "data" +routes.dataseriesplace.defaults.action = "series" +//routes.dataseries.reqs.code = "\d+" + routes.dataseries.route = "data/series/:id" routes.dataseries.defaults.controller = "data" routes.dataseries.defaults.action = "series" -//routes.dataseries.reqs.code = "\d+" routes.mddoc.route = "metainfo/:title" routes.mddoc.defaults.controller = "metainfo" diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 53cedf35..82b2ae43 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -242,6 +242,7 @@ class DataController extends Zend_Controller_Action $name=$id; $id=''; } + $keyword=$this->_request->getParam('keyword'); $md=new SeriesTable(); $db=$md->getAdapter(); if (empty($id)) { @@ -268,15 +269,28 @@ class DataController extends Zend_Controller_Action if ($id>0) { $where=$db->quoteInto('id = ?',$id); $row=$md->fetchRow($where); - $this->view->codename=$row->name; - $sql=$db->quoteInto('select count(m.id) as count from metadata m,dataseries d where m.id=d.id and d.sid=?',$id); - $state=$db->query($sql); - $row=$state->fetchAll(); + $this->view->codename=$row->name; + if (!empty($keyword)) + { + $sql='select count(m.id) as count from metadata m,dataseries d,keyword k where m.id=d.id and m.id=k.id and d.sid=? and k.keyword=?'; + $row=$db->fetchAll($sql,array($id,$keyword)); + }else{ + $sql='select count(m.id) as count from metadata m,dataseries d where m.id=d.id and d.sid=?'; + $row=$db->fetchAll($sql,array($id)); + } $sum=$row[0]['count']; $select=$db->select(); $select->from('metadata','*')->join('dataseries','metadata.id=dataseries.id')->where('dataseries.sid=?',$id)->order('metadata.title')->limitPage($page,$limit); + if (!empty($keyword)) $select->join('keyword','keyword.id=metadata.id')->where('keyword.keyword=?',$keyword); $this->view->metadata=$db->fetchAll($select); $this->view->page=new Pagination($sum,$page,$limit); + $this->view->showtools=($sum>$page)?true:false; + $this->view->form=new SearchForm(); + $sql=$db->quoteInto("select keyword,count(*) as count from (select t.keyword,t.id from keyword t left join dataseries d on t.id=d.id where t.keytype='place' and d.sid=?) as f group by keyword order by count desc limit 30",$id); + $state=$db->query($sql); + $row=$state->fetchAll(); + $this->view->places=$row; + $this->view->seriesid=$id; } else { //提供全部数据集序列列表 } diff --git a/application/default/views/scripts/data/series.phtml b/application/default/views/scripts/data/series.phtml index 734a4100..8a91f765 100755 --- a/application/default/views/scripts/data/series.phtml +++ b/application/default/views/scripts/data/series.phtml @@ -21,10 +21,21 @@ $this->breadcrumb()->setSeparator(' > ');
  • '>()
  • +showtools) : ?> +
    本序列中常用地点关键词 + +
    + metadata)) : ?>
    -

    当前浏览数据集序列:codename; ?>

    page->getNavigation(); ?> +

    当前浏览数据集序列:codename; ?>

    +showtools) echo $this->form; ?> +page->getNavigation(); ?> metadata as $md) : ?>