diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php
index eddef63b..0db8525b 100755
--- a/application/admin/controllers/DataController.php
+++ b/application/admin/controllers/DataController.php
@@ -1124,6 +1124,8 @@ class Admin_DataController extends Zend_Controller_Action
$this->view->ac = $ac = $this->_getParam('ac');
$submit = $this->_getParam('submit');
$keyword = $this->view->q = trim($this->_getParam('q'));
+ $order = $this->view->search_order = trim($this->_getParam('order'));
+ $sort = $this->view->search_sort = trim($this->_getParam('sort'));
$reference = new Reference();
@@ -1132,10 +1134,20 @@ class Admin_DataController extends Zend_Controller_Action
$reference->keyword = $keyword;
}
+ if(!empty($order))
+ {
+ $reference->order = $order;
+ }
+
+ if(!empty($sort))
+ {
+ $reference->sort = $sort;
+ }
+
//文献首页
if(empty($ac))
{
- view::addPaginator($reference->fetchReferences(),$this,10);
+ view::addPaginator($reference->fetchReferences(),$this,12);
return true;
}
else if ($ac == "water")
diff --git a/application/admin/views/scripts/data/ref.phtml b/application/admin/views/scripts/data/ref.phtml
index da953d80..0a40a223 100644
--- a/application/admin/views/scripts/data/ref.phtml
+++ b/application/admin/views/scripts/data/ref.phtml
@@ -22,8 +22,10 @@ table thead tr th {background:#EBF2F6;}
-
@@ -39,8 +41,14 @@ table thead tr th {background:#EBF2F6;}
- 标题 |
- 年份 |
+ 标题
+
+
+ |
+ 年份
+
+
+ |
操作 |
diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php
index 7c75a89c..db1c7ead 100644
--- a/application/module/Reference/Reference.php
+++ b/application/module/Reference/Reference.php
@@ -15,6 +15,8 @@ class Reference
protected $events = NULL;
public $table;
public $keyword;
+ public $order;
+ public $sort = "DESC";
function __construct($db = NULL,$mail = NULL)
{
@@ -164,12 +166,29 @@ class Reference
//所有文献
public function fetchReferences()
{
+ $wheresql = array();
if(!empty($this->keyword))
{
- $search = new Search();
- $keyword = $search->splitKeyword($this->keyword);
+ $wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') ";
}
- $sql = "SELECT * FROM {$this->table->reference} ORDER BY id DESC";
+ if(count($wheresql)>0)
+ {
+ $wheresql = " WHERE ".join(" AND ",$wheresql);
+ }else{
+ $wheresql = "";
+ }
+
+ if(empty($this->order))
+ {
+ $order = "{$this->table->reference}.title";
+ }else{
+ $order = "{$this->table->reference}.{$this->order}";
+ }
+
+ $sql = "SELECT {$this->table->reference}.* FROM
+ {$this->table->reference}
+ $wheresql
+ ORDER BY $order {$this->sort}";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
@@ -177,10 +196,30 @@ class Reference
//获取专题数据的文献
public function fetchThemeReferences($code)
{
+ $wheresql = array();
+ $wheresql[] = " s.code='$code' ";
+ if(!empty($this->keyword))
+ {
+ $wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
+ }
+ if(count($wheresql)>0)
+ {
+ $wheresql = " WHERE ".join(" AND ",$wheresql);
+ }else{
+ $wheresql = "";
+ }
+
+ if(empty($this->order))
+ {
+ $order = "ref.year,ref.title";
+ }else{
+ $order = "ref.{$this->order} {$this->sort}";
+ }
+
$sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid
- where s.code='$code'
- order by ref.year,ref.title";
+ $wheresql
+ ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}