From 6a9bdd0109ba46c3ca386e810dd9f66985a3f03d Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 30 Sep 2013 03:09:21 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=92=8C=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/DataController.php | 14 +++++- .../admin/views/scripts/data/ref.phtml | 14 ++++-- application/module/Reference/Reference.php | 49 +++++++++++++++++-- 3 files changed, 68 insertions(+), 9 deletions(-) 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(); }
标题年份标题 + + + 年份 + + + 操作