From c1c799b9a150b260f8b178ad503738cdf54a6e0a Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 24 Nov 2011 03:27:25 +0000 Subject: [PATCH] =?UTF-8?q?heihe=20view=20=E4=B8=AD=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=87=E7=8C=AE=E7=9A=84=E8=B0=83=E7=94=A8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAajax=E5=88=86=E9=A1=B5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/DataController.php | 72 +++++++++++++++---- .../default/views/scripts/heihe/view.phtml | 33 ++++----- 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index bcaa20db..fe32c9ac 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -593,17 +593,6 @@ class DataController extends Zend_Controller_Action $sql="select distinct(md.uuid),md.title from keyword kw left join normalmetadata md on kw.id=md.id where kw.keyword in (select k.keyword from keyword k left join metadata m on k.id=m.id where m.id=? and k.keytype='theme') and kw.id<>? limit 10"; //$sql="select distinct(md.uuid),md.title from keyword kw left join metadata md on kw.id=md.id where kw.keyword in (select k.keyword from keyword k left join metadata m on k.id=m.id where m.id=?) and kw.id<>? limit 10"; $this->view->related=$this->db->fetchAll($sql,array($id,$id)); - //相关文献 - $sql="select a.*,array_to_string(array(select author from knl_author t where t.item_id=a.item_id order by place asc),'; ') as author from knl_article a where ("; - foreach($this->view->keys as $k) - { - if ($k->keytype=='theme') - { - $sql.=" a.title like '%".$k->keyword."%' or "; - } - } - $sql.=" 1<>1) order by a.ts_created desc limit 10"; - $this->view->literature=$this->db->fetchAll($sql); //数据附件 $sql = $this->db->quoteInto("select m.id,a.realname from mdattach m left join attachments a on m.id=a.id where m.uuid=?",$uuid); $this->view->attachments = $this->db->fetchAll($sql); @@ -619,13 +608,65 @@ class DataController extends Zend_Controller_Action } } + function literatureAction(){ + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $keyword=$this->_request->getParam("q"); + + $id = (int)$this->_request->getParam('id'); + $sql="select m.id from normalmetadata m left join mdstatus s on m.uuid=s.uuid + left join thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid where "; + if (empty($id)) { + $uuid = $this->_request->getParam('uuid'); + if (empty($uuid)) exit("读取信息错误"); + $where=$this->db->quoteInto('m.uuid = ?',$uuid); + } else { + $where=$this->db->quoteInto('m.id = ?',$id); + } + $sql.=$where; + $row=$this->db->fetchRow($sql); + if (!$row) exit("读取信息错误"); + $id=$row['id']; + + $keys=$this->db->fetchAll("select * from keyword where id=? order by keytype,ts_created",array($id)); + + $wheresql = array(); + foreach ($keys as $k=>$v) + { + if($v['keytype']=="theme") + $wheresql[] = " a.title like '%".$v['keyword']."%' "; + } + $wheresql[] = " 1<>1 "; + $wheresql = join(" or ",$wheresql); + $sql="select a.*,array_to_string(array(select author from knl_author t where t.item_id=a.item_id order by place asc),'; ') as author from knl_article a where ($wheresql) order by a.ts_created desc"; + $rows = $this->db->fetchAll($sql); + + $paginator = Zend_Paginator::factory($rows); + $paginator->setCurrentPageNumber($this->_getParam('page')); + $paginator->setItemCountPerPage(5); + $paginator->setView($this->view); + Zend_View_Helper_PaginationControl::setDefaultViewPartial('data/pagination_ajax.phtml'); + $this->config = Zend_Registry::get('config'); + if ($paginator) + { + foreach($paginator as $c) + { + $u=parse_url($c['url']); + if (@$u['host']=='hdl.handle.net') $c['url'] = $this->config->seekspace->handleurl.$u['path']; + print '
  • '.$c['title'].'【'.$c['author'].' '.$c['publisher'].' '.$c['ts_issued']."】
  • "; + } + echo '
    '.$paginator.'
    '; + } + }//相关文献 + function replace($string){ $patterns = array("/\"/i","/\'/i"); $replacements = array("“","‘"); ksort($patterns); ksort($replacements); return preg_replace($patterns, $replacements, $string); - } + }//引号替换 + function postcommentAction(){ $this->_helper->layout->disableLayout(); @@ -708,7 +749,9 @@ class DataController extends Zend_Controller_Action echo "出错了,请稍后再试"; exit(); } - } + }//ajax评论 + + /* * 数据评论,根据UUID读取 */ @@ -739,7 +782,7 @@ class DataController extends Zend_Controller_Action } echo '
    '.$paginator.'
    '; }//else echo "
  • No comments.
  • "; - } + }//评论列表 function creatform($datas) { return ' @@ -768,6 +811,7 @@ class DataController extends Zend_Controller_Action '; } + /** * 判断用户是否填写了申请信息 * @param string $uuid diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml index a39f2ed1..96d09b68 100755 --- a/application/default/views/scripts/heihe/view.phtml +++ b/application/default/views/scripts/heihe/view.phtml @@ -254,29 +254,12 @@ endforeach; -literature) : ?>
    -
    -