#im",$html,$matchs,PREG_PATTERN_ORDER))
{
- foreach ($matchs[1] as $k=>$v){
- if($k < $max) $rev[$k]['content']=$v;
+ foreach ($matchs[0] as $k=>$v){
+ if($k < $max) $rev[$k]['content']=utf8_encode($v);
}
}
-
- $response=array("result"=>$rev,"count"=>$max,"morelink"=>'http://search.cnki.net/search.aspx?q='.$keyword,"error"=>$error);
+
+ //var_dump($rev);
+ //exit();
+ $response=array("result"=>$rev,"count"=>$max,"morelink"=>'http://scholar.google.com/scholar?hl=zh-CN&btnG=搜索&lr=&q='.$keyword,"error"=>$error);
$rev = Zend_Json::encode($response);
return $rev;
- }//cnki 搜索
+ }//scholar 搜索
+
+ function recommendAction(){
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $uuid = $this->_request->getParam('uuid');
+
+ $sql = "select d.uuid,count(distinct(d.userid)) as downtimes,m.title from dataorder d left join metadata m on d.uuid=m.uuid where d.userid in (
+ select distinct(userid) from dataorder where uuid=? and status in (0,5)
+ ) and d.uuid<>? and length(m.title)>2 group by d.uuid,m.title order by count(distinct(d.userid)) desc";
+ $rows = $this->db->fetchAll($sql,array($uuid,$uuid));
+
+ $paginator = Zend_Paginator::factory($rows);
+ $paginator->setCurrentPageNumber($this->_getParam('page'));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setView($this->view);
+ Zend_View_Helper_PaginationControl::setDefaultViewPartial('data/pagination_recommend.phtml');
+ $this->config = Zend_Registry::get('config');
+ if ($paginator)
+ {
+ foreach($paginator as $c)
+ {
+ print ''.$c['title']." [下载人数:".$c['downtimes']."]\r\n";
+ }
+ echo ''.$paginator.'
';
+ }
+ }//相关下载
+
+ function relatedAction(){
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $uuid = $this->_request->getParam('uuid');
+
+ $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 ";
+ $where=$this->db->quoteInto('m.uuid = ?',$uuid);
+ $sql.=$where;
+ $row=$this->db->fetchRow($sql);
+ if (!$row) exit("读取信息错误");
+ $id=$row['id'];
+
+ //相关元数据,根据同名关键词实现
+ $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<>?";
+ $rows=$this->db->fetchAll($sql,array($id,$id));
+
+ $paginator = Zend_Paginator::factory($rows);
+ $paginator->setCurrentPageNumber($this->_getParam('page'));
+ $paginator->setItemCountPerPage(10);
+ $paginator->setView($this->view);
+ Zend_View_Helper_PaginationControl::setDefaultViewPartial('data/pagination_related.phtml');
+ $this->config = Zend_Registry::get('config');
+ if ($paginator)
+ {
+ foreach($paginator as $c)
+ {
+ print ''.$c['title']."\r\n";
+ }
+ echo ''.$paginator.'
';
+ }
+ } //相关数据
+
+ function literatureAction(){
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $uuid = $this->_request->getParam('uuid');
+ $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 ";
+ $where=$this->db->quoteInto('m.uuid = ?',$uuid);
+ $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(10);
+ $paginator->setView($this->view);
+ Zend_View_Helper_PaginationControl::setDefaultViewPartial('data/pagination_literature.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.'
';
+ }
+ }//相关文献
}
diff --git a/application/default/views/scripts/data/pagination_recommend.phtml b/application/default/views/scripts/data/pagination_recommend.phtml
new file mode 100644
index 00000000..f93d00e2
--- /dev/null
+++ b/application/default/views/scripts/data/pagination_recommend.phtml
@@ -0,0 +1,26 @@
+pageCount): ?>
+
+
\ No newline at end of file
diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml
index 73988f96..0e2a5ce8 100755
--- a/application/default/views/scripts/heihe/view.phtml
+++ b/application/default/views/scripts/heihe/view.phtml
@@ -230,11 +230,11 @@ endforeach;
$ev = join(" ",$keywords);
?>
@@ -375,14 +375,21 @@ function postcomment(){ $.ajax({'type':"POST",'url':"/data/postcomment",'data':$
'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000); $('#returninfo').html(html);ajaxpage(0);},
'beforeSend':function(){$('#postcomment').attr('disabled','disabled');$('#postcomment').html('正在提交...'); }});}
+$('#literature_t').click(function(){literature(1);});
//ajax literature
-function literature(page){$.ajax({type:"GET",url:"/data/literature/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#literature').html(''+html+'
');},
-beforeSend:function(){$('#literature').html('加载中');}});};literature(1);
+function literature(page){$.ajax({type:"GET",url:"/service/literature/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#literature').html(''+html+'
');},
+beforeSend:function(){$('#literature').html('加载中');}});}
+$('#related_t').click(function(){related(1);});
//ajax related
-function related(page){$.ajax({type:"GET",url:"/data/related/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#related').html(''+html+'
');},
+function related(page){$.ajax({type:"GET",url:"/service/related/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#related').html(''+html+'
');},
beforeSend:function(){$('#related').html('加载中');}});};related(1);
+$('#recommend_t').click(function(){recommend(1);});
+//ajax recommend
+function recommend(page){$.ajax({type:"GET",url:"/service/recommend/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#recommend').html(''+html+'
');},
+beforeSend:function(){$('#related').html('加载中');}});}
+
function getFileList(){
var tw = ($(window).width() - $('#window-outter').width())/2;
$('#window-outter').css({'right':tw});
@@ -440,7 +447,7 @@ function getSubFileList(uuid,id,depth){
$('.googlesearch').click(function(){googleSearch('');});
$('.bingsearch').click(function(){bingSearch('');});
$('.cnkiSearch').click(function(){cnkiSearch('');});
-$('.scholar')click(function(){});
+$('.scholar').click(function(){scholarSearch('');});
function googleSearch(keyword){
$.ajax({type:"POST",url:"/service/googlesearch",data:'q='+keyword,
@@ -465,16 +472,23 @@ function googleSearch(keyword){
function scholarSearch(keyword){
$.ajax({type:"POST",url:"/service/scholarsearch",data:'q='+keyword,
success:function(html){
- var items = [];
+ //$('#searchlist').html(html);
+ var items = [];
var obj = jQuery.parseJSON(html);
- $.each(obj.responseData.results, function(key, val) {
- var html = ''+val['title']+'
'
- +val['url'].replace(/%(.*)/i,"") +'
'
- +val['content']
- +'
';
- items.push('' + html + '');
- });
- items.push('查看更多搜索结果(约'+obj.responseData.cursor.estimatedResultCount+'条)');
+ if(obj.error != '')
+ {
+ items.push('' + obj.error + '');
+ }else{
+ $.each(obj.result, function(key, val) {
+ var html = ''+val['title']+'
'
+ +''
+ +val['content']
+ +'
';
+
+ items.push('' + html + '');
+ });
+ }
+ items.push('查看更多搜索结果');
$('#searchlist').html(items.join(''));
$('html, body').animate({scrollTop:$('html').height()}, 'slow');
},
@@ -512,7 +526,7 @@ function cnkiSearch(keyword){
items.push('' + obj.error + '');
}else{
$.each(obj.result, function(key, val) {
- var html = ''+val['title']+'
'
+ var html = ''+val['title']+'
'
+val['url'].replace(/%(.*)/i,"") +'
'
+val['content']
+'
';