后台我负责的评审中增加了按专题搜索

This commit is contained in:
Li Jianxuan 2013-06-13 08:06:11 +00:00
parent 34ccbd15f9
commit a19a57a512
4 changed files with 60 additions and 14 deletions

View File

@ -580,21 +580,27 @@ class Admin_ReviewController extends Zend_Controller_Action
function myreviewAction(){ function myreviewAction(){
include_once("data/Review.php"); include_once("data/Review.php");
include_once("data/Source.php");
include_once("helper/view.php"); include_once("helper/view.php");
$search=$this->_request->getParam('search'); $search=$this->_request->getParam('search');
$keyword = $this->_request->getParam('keyword'); $filter['keyword'] = $this->_request->getParam('keyword');
$filter['code'] = $this->_request->getParam('code');
$review = new Review($this->db); $review = new Review($this->db);
if(!empty($search) && !empty($keyword)) if(!empty($search) && !empty($filter))
{ {
$rows = $review->adminReviews($keyword); $rows = $review->adminReviews($filter);
$this->view->keyword = $keyword; $this->view->keyword = $filter['keyword'];
$this->view->code = $filter['code'];
}else{ }else{
$rows = $review->adminReviews(); $rows = $review->adminReviews();
} }
view::addPaginator($rows,$this->view,$this->_request); $source = new Source($this->db);
$this->view->source = $source->Fetch();
view::addPaginator($rows,$this,NULL,15);
return true; return true;
}//我管理的元数据 }//我管理的元数据

View File

@ -26,12 +26,26 @@ table thead tr th {background:#EBF2F6;color:#444;}
<?php endforeach;endif; ?> <?php endforeach;endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<form action="" method="get" class="search input-append"> <form method="get" id="search">
<input type="hidden" name="search" value='1' /> <input type="hidden" name="search" value='1' />
<input type="text" class="q" name="keyword" value="<?php echo $this->keyword; ?>" /> <input type="hidden" name="code" id="code" value="<?php echo $this->code; ?>" />
<button type="submit" class="btn">搜索</button> <div class="input-append">
</form> <input type="text" class="q" name="keyword" value="<?php echo $this->keyword; ?>" tabindex="1" />
<div class="btn-group">
<button tabindex="-1" class="btn" type="submit">搜索</button>
<button tabindex="-1" data-toggle="dropdown" class="btn dropdown-toggle">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" onclick="$('#code').val('');$('#search').submit()">所有专题</a></li>
<?php if(!empty($this->source)) { ?>
<?php foreach($this->source as $v) { ?>
<li><a href="javascript:void(0);" onclick="$('#code').val('<?= $v['id'] ?>');$('#search').submit()"><?= $v['code'] ?></a></li>
<?php } }?>
</ul>
</div>
</div>
</form>
<table class="table table-bordered table-hover"> <table class="table table-bordered table-hover">
<thead> <thead>
<tr> <tr>

View File

@ -64,7 +64,7 @@ class Review extends Zend_Controller_Plugin_Abstract
} }
//后台我负责的评审 //后台我负责的评审
function adminReviews($keyword = "",$order="") function adminReviews($filter = "",$order="")
{ {
include_once('helper/view.php'); include_once('helper/view.php');
$uid = view::User('id'); $uid = view::User('id');
@ -74,9 +74,13 @@ class Review extends Zend_Controller_Plugin_Abstract
$wheresql[] = " m.status in (1,2,3,4) "; $wheresql[] = " m.status in (1,2,3,4) ";
$wheresql[] = " u.id=$uid "; $wheresql[] = " u.id=$uid ";
if(!empty($keyword)) if(isset($filter['keyword']) && !empty($filter['keyword']))
{ {
$wheresql[] = " md.title like '%$keyword%' "; $wheresql[] = " md.title like '%".$filter['keyword']."%' ";
}
if(isset($filter['code']) && !empty($filter['code']))
{
$wheresql[] = " s.id=".$filter['code']." ";
} }
if(count($wheresql)>0) if(count($wheresql)>0)
@ -91,6 +95,7 @@ class Review extends Zend_Controller_Plugin_Abstract
right join metadata md on md.uuid=m.uuid right join metadata md on md.uuid=m.uuid
left join geonetworkmetadata g on m.uuid=g.uuid left join geonetworkmetadata g on m.uuid=g.uuid
left join users u on u.id=m.userid left join users u on u.id=m.userid
left join datasource s on s.uuid=md.uuid
$wheresql $wheresql
order by m.status desc,m.ts_accepted desc"; order by m.status desc,m.ts_accepted desc";

View File

@ -0,0 +1,21 @@
<?php
class Source
{
private $db; //传入PDO对象.
//使用到的公共变量
public $tbl_source = "source";
public $tbl_datasource = "datasource";
function __construct($db)
{
$this->db = $db;
}
function Fetch()
{
$sql = "SELECT * FROM ".$this->tbl_source."";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
}