add series with place keyword support, and simple search suppport

This commit is contained in:
wlx 2010-06-04 05:08:11 +00:00
parent 58f5934475
commit 4a1fd699ac
3 changed files with 35 additions and 6 deletions

View File

@ -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"

View File

@ -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 {
//提供全部数据集序列列表
}

View File

@ -21,10 +21,21 @@ $this->breadcrumb()->setSeparator(' > ');
<li><a href='/data/series/<?php echo $cg['name']; ?>'><?php echo $cg['name']; ?></a>(<?php echo $cg['count']; ?>)</li>
<?php endforeach; ?>
</ul></fieldset>
<?php if ($this->showtools) : ?>
<fieldset><legend>本序列中常用地点关键词</legend>
<ul>
<?php foreach($this->places as $place) : ?>
<li><a href='/data/series/<?php echo $this->seriesid; ?>/<?php echo urlencode($place['keyword']); ?>'><?php echo $place['keyword']; ?></a><span class="note">(<?php echo $place['count']; ?>)</span></li>
<?php endforeach; ?>
</ul>
</fieldset>
<?php endif; ?>
</div>
<?php if (!empty($this->metadata)) : ?>
<div id='metacontent'>
<h1>当前浏览数据集序列:<?php echo $this->codename; ?></h1><?php echo $this->page->getNavigation(); ?>
<h1>当前浏览数据集序列:<?php echo $this->codename; ?></h1>
<?php if ($this->showtools) echo $this->form; ?>
<?php echo $this->page->getNavigation(); ?>
<?php foreach($this->metadata as $md) : ?>
<hr />
<div class="mditem">