merge heihedata branch from r4014 to r4031, and merge metadata-en database and chinese database with en schema.

This commit is contained in:
wlx 2013-11-07 11:24:49 +00:00
parent 4e9a496f63
commit 7e4f79cd47
38 changed files with 1009 additions and 402 deletions

View File

@ -2,6 +2,7 @@
use Helpers\View as view; use Helpers\View as view;
use Reference\Reference; use Reference\Reference;
use Reference\Ris; use Reference\Ris;
use Reference\RisOutput;
use Helpers\dbh; use Helpers\dbh;
use \Files\Files; use \Files\Files;
@ -1128,6 +1129,7 @@ class Admin_DataController extends Zend_Controller_Action
$keyword = $this->view->q = trim($this->_getParam('q')); $keyword = $this->view->q = trim($this->_getParam('q'));
$order = $this->view->search_order = trim($this->_getParam('order')); $order = $this->view->search_order = trim($this->_getParam('order'));
$sort = $this->view->search_sort = trim($this->_getParam('sort')); $sort = $this->view->search_sort = trim($this->_getParam('sort'));
$field = $this->view->search_field = $this->_getParam('field');
$reference = new Reference(); $reference = new Reference();
@ -1136,6 +1138,11 @@ class Admin_DataController extends Zend_Controller_Action
$reference->keyword = $keyword; $reference->keyword = $keyword;
} }
if(!empty($field))
{
$reference->field = $field;
}
if(!empty($order)) if(!empty($order))
{ {
$reference->order = $order; $reference->order = $order;
@ -1146,32 +1153,41 @@ class Admin_DataController extends Zend_Controller_Action
$reference->sort = $sort; $reference->sort = $sort;
} }
$this->view->reference = $reference;
$this->view->page = $this->_getParam('page');
$this->view->pagelimit = 12;
//文献首页 //文献首页
if(empty($ac)) if(empty($ac))
{ {
$this->view->referenceType = $reference->referenceType(); $this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this,12); view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit);
$this->view->years = $reference->countByYear();
return true; return true;
} }
else if ($ac == "water") else if ($ac == "water")
{ {
$this->view->referenceType = $reference->referenceType(); $this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchThemeReferences('water'),$this,10); view::addPaginator($reference->fetchThemeReferences('water'),$this,$this->view->pagelimit);
return true; return true;
} }
else if ($ac == "westdc") else if ($ac == "westdc")
{ {
$this->view->referenceType = $reference->referenceType(); $this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchWestdcReferences(),$this,10); view::addPaginator($reference->fetchWestdcReferences(),$this,$this->view->pagelimit);
return true; return true;
} }
else if ($ac == "todo") else if ($ac == "todo")
{ {
$this->view->referenceType = $reference->referenceType(); $this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchTodoReferences(),$this,10); view::addPaginator($reference->fetchTodoReferences(),$this,$this->view->pagelimit);
return true; return true;
} }
unset($this->view->reference);
unset($this->view->page);
unset($this->view->pagelimit);
//添加 //添加
if($ac == "add") if($ac == "add")
{ {
@ -1378,6 +1394,41 @@ class Admin_DataController extends Zend_Controller_Action
return true; return true;
}//ris单篇更新 }//ris单篇更新
//ris导出
if($ac == "risoutput")
{
$this->_helper->viewRenderer('ref-risoutput');
$this->view->years = $reference->countByYear();
if(!empty($submit))
{
$mode = $this->_getParam('mode');
$risOutput = new RisOutput();
$preData = $risOutput->preRead($mode);
$risData = $risOutput->processArrayDataToRisData($preData);
$risText = $risOutput->output($risData);
echo "<pre>";
echo $risText;
echo "</pre>";
}
}//ris output
if($ac == "ristest")
{
$this->_helper->viewRenderer('ref-ris');
$submit = $this->_getParam('submit');
if(!empty($submit))
{
$ris = new \Reference\Ris();
view::Dump($ris->processRis(NULL,$this->_getParam('ristext')),false);
}
}
}//文献管理 refAction() }//文献管理 refAction()

View File

@ -4,6 +4,7 @@ use Files\Files;
use Files\Output; use Files\Output;
use Files\Listener\FileListener; use Files\Listener\FileListener;
use Order\Manager\Offlineapp; use Order\Manager\Offlineapp;
use Order\Manager\Application;
use data\DataService; use data\DataService;
use Mail\Mail; use Mail\Mail;
@ -1137,16 +1138,15 @@ class Admin_DownController extends Zend_Controller_Action
->setBody($objWriter->save('php://output'));*/ ->setBody($objWriter->save('php://output'));*/
} }
$select=$this->db->select();
$select->from('offlineapp')->where('ts_approved is not null')->where('pdflink is not null')->where('status>=0')->order('ts_created desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
$this->view->page = $this->_getParam('page'); $this->view->page = $this->_getParam('page');
$application = new Application();
$this->view->q = $application->keyword = $this->_getParam('q');
$application->filter = $this->_getParam('filter');
view::addPaginator($application->passed(),$this,20);
return true;
} }
//在线数据下载情况仅针对onlineapp表自2011-9-8开始记录。 //在线数据下载情况仅针对onlineapp表自2011-9-8开始记录。
function onlineAction() function onlineAction()

View File

@ -28,7 +28,6 @@
<div id="datalist"> <div id="datalist">
</div> </div>
<input id="file_upload" name="Filedata" type="file" /> <input id="file_upload" name="Filedata" type="file" />
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
</p> </p>
</form> </form>
@ -71,7 +70,7 @@ var upload = {
makeFileHtml : function(data){ makeFileHtml : function(data){
return '<div class="alert alert-success">' return '<div class="alert alert-success">'
+ '<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>' + '<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
+ data.realname + '<a href="/service/attach/id/' + data.id + '">' +data.realname + '</a>'
+'<input type="hidden" name="attid" value="'+data.id+'"></input>' +'<input type="hidden" name="attid" value="'+data.id+'"></input>'
+'</div>'; +'</div>';
}, },

View File

@ -15,6 +15,7 @@
<label class="control-label" for="inputUuid">元数据UUID</label> <label class="control-label" for="inputUuid">元数据UUID</label>
<div class="controls"> <div class="controls">
<input type="text" name="uuid" id="inputUuid" placeholder="UUID"> <input type="text" name="uuid" id="inputUuid" placeholder="UUID">
<span class="help-block"><a href="javascript:void(0);" onclick="$(this).parent('span').prev('input').val('e31f5ea7-a4af-4ae3-9ac1-1a84132c4338')">设为数据中心文献</a></span>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">

View File

@ -1,10 +1,11 @@
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li <?= empty($this->ac) ? 'class="active"':"" ?>><a href="/admin/data/ref">浏览所有</a></li> <li <?= empty($this->ac) ? 'class="active"':"" ?>><a href="/admin/data/ref">浏览所有</a></li>
<li <?= $this->ac=="water" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/water">WATER文献</a></li> <li <?= $this->ac=="water" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/water">WATER文献</a></li>
<li <?= $this->ac=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</a></li> <li <?= $this->ac=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</a></li>
<li <?= $this->ac=="todo" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/todo">待处理文献</a></li> <li <?= $this->ac=="todo" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/todo">待处理文献</a></li>
<li <?= $this->ac=="add" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/add">单篇添加</a></li> <li <?= $this->ac=="add" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/add">单篇添加</a></li>
<li <?= $this->ac=="multiupload" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/multiupload">批量上传</a></li> <li <?= $this->ac=="multiupload" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/multiupload">批量上传</a></li>
<li <?= $this->ac=="files" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/files">文件管理</a></li> <li <?= $this->ac=="files" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/files">文件管理</a></li>
<li <?= $this->ac=="ris" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/ris">RIS导入</a></li> <li <?= $this->ac=="ris" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/ris">RIS导入</a></li>
<li <?= $this->ac=="risoutput" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/risoutput">RIS导出</a></li>
</ul> </ul>

View File

@ -0,0 +1,50 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('文献管理');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,"uploadify");
$this->theme->AppendPlus($this,'admin_plugin');
?>
<style>
table thead tr th {background:#EBF2F6;}
</style>
<div class="row-fluid">
<div class="span2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span10">
<div>
<?= $this->partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<h3>RIS导出</h3>
<hr />
<div>
<?php if(!empty($this->years)) { ?>
按年份 :
<?php foreach($this->years as $k=>$v){ ?>
<a class="btn btn-info" href="?field[year]=<?= $v['year'] ?>"><?= empty($v['year']) ? "未知":$v['year'] ?>(<?= $v['num'] ?>)</a>
<?php } ?>
<hr />
<?php } ?>
</div>
<div>
其它方式:<a class="btn btn-info" href="?submit=1&mode=all">全部</a>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->

View File

@ -37,6 +37,17 @@ table thead tr th {background:#EBF2F6;}
<?php if(!empty($this->msg)) { ?> <?php if(!empty($this->msg)) { ?>
<?= $this->msg ?> <?= $this->msg ?>
<?php } else{ ?> <?php } else{ ?>
<?php if($this->ac == 'westdc'){ ?>
<button type="button" class="btn btn-success" onclick="$('#mdref')[0].reset();mdref.edit('','','e31f5ea7-a4af-4ae3-9ac1-1a84132c4338',0,0)">添加数据中心文献</button>
<?php } ?>
<?php if(!empty($this->years)) { ?>
<?php foreach($this->years as $k=>$v){ ?>
<a class="btn btn-info" href="?field[year]=<?= $v['year'] ?>"><?= empty($v['year']) ? "未知":$v['year'] ?>(<?= $v['num'] ?>)</a>
<?php } ?>
<?php } ?>
<div id="datalist"> <div id="datalist">
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
@ -45,8 +56,7 @@ table thead tr th {background:#EBF2F6;}
<th>标题 <th>标题
<a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a> <a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a> <a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th> 年份
<th>年份
<a href="?order=year&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a> <a href="?order=year&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=year&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a> <a href="?order=year&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th> </th>
@ -58,37 +68,36 @@ table thead tr th {background:#EBF2F6;}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $autoindex=0; <?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<tr id="DataLine_<?= $item['id']?>"> <tr id="DataLine_<?= $item['id']?>">
<?php if(!empty($item['title']) || !empty($item['year'])) { ?> <td>
[<?= $autoindex ?>]&nbsp;
<td><?= $item['title'] ?></td> <?php if ($item['ris']) :
<td><?= $item['year'] ?></td> echo $item['reference'];
else :
?>
{<?php $authors = $this->reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'<font color="#CC0000">未知作者</font>'; ?>}&nbsp;
{<?= empty($item['title']) ? '<font color="#CC0000">未知标题</font>':$item['title'] ?>}&nbsp;
{<?= empty($item['publisher']) ? '<font color="#CC0000">未知期刊</font>':$item['publisher'] ?>}&nbsp;
{<?= empty($item['year']) ? '<font color="#CC0000">未知年份</font>':$item['year'] ?>}&nbsp;
<?php endif; ?>
</td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td> <td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td>
<td rowspan="2"> <td>
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a> <a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a> <a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a>
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>(<a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit('',<?= $item['id']?>,'',0,0)">+</a>) <a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>(<a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit('',<?= $item['id']?>,'',0,0)">+</a>)
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a> <a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2"><?= $item['reference'] ?></td>
</tr>
<?php } ?>
<?php if(empty($item['title']) && empty($item['year'])) { ?>
<td colspan="2"><?= $item['reference'] ?></td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td>
<td>
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a>
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<?php } ?>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>

View File

@ -27,8 +27,20 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
<div class="right_title">离线数据服务记录</div> <div class="right_title">离线数据服务记录</div>
<a href="/admin/down/offline/add/1">添加新的离线服务记录</a> | <a href="/admin/down/offline/down/1">下载所有离线服务记录</a> | <a href="/admin/down/offline/update/1" onclick="return confirm('该操作需要较长时间,请不要中途刷新页面,是否确定继续?')">自动匹配离线下载用户与网站用户</a> | <a href="/admin/down/offline/emaillist/1">下载服务用户邮箱列表</a> <a href="/admin/down/offline/add/1">添加新的离线服务记录</a> | <a href="/admin/down/offline/down/1">下载所有离线服务记录</a> | <a href="/admin/down/offline/update/1" onclick="return confirm('该操作需要较长时间,请不要中途刷新页面,是否确定继续?')">自动匹配离线下载用户与网站用户</a> | <a href="/admin/down/offline/emaillist/1">下载服务用户邮箱列表</a>
| <a href="/admin/down/offline/monthreport/1">下载上月服务记录(科技部上报)</a> | <a href="/admin/down/offline/monthreport/1">下载上月服务记录(科技部上报)</a>
<div>
<div class="input-append">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
</div>
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
<table> <table>
<thead><tr> <thead><tr>

View File

@ -54,7 +54,7 @@ table thead tr th {background:#EBF2F6;color:#444;}
<td> <td>
<a href="/admin/down/offlineapps/ac/view/?offlineappid=<?= $item['id'] ?>">查看详细</a> <a href="/admin/down/offlineapps/ac/view/?offlineappid=<?= $item['id'] ?>">查看详细</a>
<a href="/admin/down/offlineapps/ac/receive/?offlineappid=<?= $item['id'] ?>">接收</a> <a href="/admin/down/offlineapps/ac/receive/?offlineappid=<?= $item['id'] ?>">接收</a>
<a href="/admin/down/offlineapps/ac/return/?offlineappid=<?= $item['id'] ?>">退回</a> <a href="/admin/down/offlineapps/ac/deny/offlineappid/<?= $item['id'] ?>">退回</a>
<a href="javascript:void(0);" onclick="upload.showUploadForm(<?= $item['id'] ?>);">上传申请表</a> <a href="javascript:void(0);" onclick="upload.showUploadForm(<?= $item['id'] ?>);">上传申请表</a>
<a href="/admin/down/offlineapps/ac/resetappform/?offlineappid=<?= $item['id'] ?>" onclick="return confirm('是否确认重置该用户的申请表?')">重置申请表</a> <a href="/admin/down/offlineapps/ac/resetappform/?offlineappid=<?= $item['id'] ?>" onclick="return confirm('是否确认重置该用户的申请表?')">重置申请表</a>
</td> </td>

View File

@ -3,7 +3,7 @@ db.adapter = PDO_PGSQL
db.params.host = localhost db.params.host = localhost
db.params.username = gis db.params.username = gis
db.params.password = gispassword db.params.password = gispassword
db.params.dbname = wdsmetadata db.params.dbname = metadata
geonetwork.url=http://wdscar.westgis.ac.cn/geonetwork/ geonetwork.url=http://wdscar.westgis.ac.cn/geonetwork/
geonetwork.adapter = PDO_PGSQL geonetwork.adapter = PDO_PGSQL

View File

@ -374,15 +374,6 @@ class AccountController extends Zend_Controller_Action
view::Post($this,"登录成功,正在跳转",$tohref); view::Post($this,"登录成功,正在跳转",$tohref);
return true; return true;
} }
if($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login")
{
view::Post($this,"登录成功,正在跳转",'/');
return true;
}else{
view::Post($this,"登录成功,正在跳转",$_SERVER['REQUEST_URI']);
return true;
}
} }
}else{ }else{
$this->setCaptcha($captcha); $this->setCaptcha($captcha);

View File

@ -24,62 +24,32 @@ class DataController extends Zend_Controller_Action
function indexAction() function indexAction()
{ {
//序列 //序列
$state=$this->db->query('select s.id,s.name,count(*) as count from series s,dataseries d where d.sid=s.id and length(s.name)>2 group by s.id,s.name order by count desc limit 15'); $state=$this->db->query('select s.id,s.name,count(*) as count from en.series s,en.dataseries d where d.sid=s.id and length(s.name)>2 group by s.id,s.name order by count desc limit 15');
$this->view->serie=$state->fetchAll(); $this->view->serie=$state->fetchAll();
//分类 //分类
$state=$this->db->query('select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh'); $state=$this->db->query('select c.code,name,name_zh,count(*) from en.category c,en.categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh');
$this->view->category=$state->fetchAll(); $this->view->category=$state->fetchAll();
//关键词 //关键词
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='place' group by keyword order by count desc limit 20"); $state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=normalmetadata.id where keytype='place' group by keyword order by count desc limit 20");
$k1=$state->fetchAll(); $k1=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='theme' group by keyword order by count desc limit 20"); $state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=normalmetadata.id where keytype='theme' group by keyword order by count desc limit 20");
//$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20"); //$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20");
$k2=$state->fetchAll(); $k2=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='discipline' group by keyword order by count desc limit 20"); $state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=normalmetadata.id where keytype='discipline' group by keyword order by count desc limit 20");
$k3=$state->fetchAll(); $k3=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='stratum' group by keyword order by count desc limit 20"); $state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=normalmetadata.id where keytype='stratum' group by keyword order by count desc limit 20");
$k4=$state->fetchAll(); $k4=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='temporal' group by keyword order by count desc limit 20"); $state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=normalmetadata.id where keytype='temporal' group by keyword order by count desc limit 20");
//$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='temporal' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20"); //$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='temporal' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20");
$k5=$state->fetchAll(); $k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5); $this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
//最新10个入库数据 //最新10个入库数据
$state=$this->db->query('select id,uuid,title from normalmetadata order by id desc limit 10'); $state=$this->db->query('select id,uuid,title from en.normalmetadata order by id desc limit 10');
$this->view->metadata = $state->fetchAll(); $this->view->metadata = $state->fetchAll();
//特色数据 //特色数据
//服务 //服务
$l=new mydir($this->view->config->paths->newsletter,"newsletter_*.pdf");
$this->view->newsletter=$l->getLast();
$name=basename($this->view->newsletter,'.pdf');
list(,$this->view->newsletterno)=explode("_",$name);
$this->view->addHelperPath('helper','Zend_View_Helper_');
$form=new MaillistForm();
$form->submit->setLabel('输入邮件地址,订阅数据通讯列表');
$this->view->form=$form;
if ($this->_request->isPost()) {
//发送邮件
$formData=$this->_request->getPost();
if ($form->isValid($formData)) {
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($formData['email']);
$mail->setBodyText(".");
$mail->setSubject('subscribe');
$mail->addTo($this->view->config->reportemail);
$mail->send();
$this->messenger->addMessage('订阅成功,请检查您的邮件!');
$this->_redirect('/data/');
}
} else {
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$user=$auth->getIdentity();
$formData['email']=$user->email;
$form->populate($formData);
}
}
$searchform=new SearchForm(); $searchform=new SearchForm();
$this->view->searchform=$searchform; $this->view->searchform=$searchform;
@ -546,8 +516,8 @@ class DataController extends Zend_Controller_Action
function viewAction() function viewAction()
{ {
$id = (int)$this->_request->getParam('id'); $id = (int)$this->_request->getParam('id');
$sql="select m.*,s.status,g.id as gid,t.filename,i.doi as datadoi,i.author_en,i.publisher_en, date_part('year',i.ts_published) as publish_year from normalmetadata m left join mdstatus s on m.uuid=s.uuid $sql="select m.*,s.status,g.id as gid,t.filename,i.doi as datadoi,i.author_en,i.publisher_en, date_part('year',i.ts_published) as publish_year from en.normalmetadata m left join en.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 left join datadoi i on i.uuid=m.uuid where "; left join en.thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid left join datadoi i on i.uuid=m.uuid where ";
if (empty($id)) { if (empty($id)) {
$uuid = $this->_request->getParam('uuid'); $uuid = $this->_request->getParam('uuid');
if (empty($uuid)) $this->_redirect('/data'); if (empty($uuid)) $this->_redirect('/data');
@ -617,175 +587,175 @@ class DataController extends Zend_Controller_Action
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=4 order by m.place"; $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=4 order by m.place";
$sql=$this->db->quoteInto($sql,$uuid); $sql=$this->db->quoteInto($sql,$uuid);
$this->view->themeref=$this->db->fetchAll($sql); $this->view->themeref=$this->db->fetchAll($sql);
//用户发表文献 //用户发表文献
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=1"; $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=1";
$sql=$this->db->quoteInto($sql,$uuid); $sql=$this->db->quoteInto($sql,$uuid);
$this->view->userref=$this->db->fetchAll($sql); $this->view->userref=$this->db->fetchAll($sql);
//多篇引用形式hiwater //多篇引用形式hiwater
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=3 order by m.place"; $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=3 order by m.place";
$sql=$this->db->quoteInto($sql,$uuid); $sql=$this->db->quoteInto($sql,$uuid);
$this->view->mcitation=$this->db->fetchAll($sql); $this->view->mcitation=$this->db->fetchAll($sql);
//相关用户 //相关用户
$sql="select p.email,p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id"; $sql="select p.email,p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id";
$this->view->authors=$this->db->fetchAll($sql,array($uuid)); $this->view->authors=$this->db->fetchAll($sql,array($uuid));
//数据限制信息 //数据限制信息
$sql="select u.* from uselimit u left join mdlimit m on u.id=m.lid where m.uuid=?"; $sql="select u.* from uselimit u left join mdlimit m on u.id=m.lid where m.uuid=?";
$this->view->uselimits=$this->db->fetchAll($sql,array($uuid)); $this->view->uselimits=$this->db->fetchAll($sql,array($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 ( $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) 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 limit 10;"; ) and d.uuid<>? and length(m.title)>2 group by d.uuid,m.title order by count(distinct(d.userid)) desc limit 10;";
$this->view->downlists = $this->db->fetchAll($sql,array($uuid,$uuid)); $this->view->downlists = $this->db->fetchAll($sql,array($uuid,$uuid));
//相关文献 //相关文献
$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 ("; $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) foreach($this->view->keys as $k)
{ {
if ($k['keytype']=='theme') if ($k['keytype']=='theme')
{ {
$sql.=" a.title like '%".$k['keyword']."%' or "; $sql.=" a.title like '%".$k['keyword']."%' or ";
} }
} }
$sql.=" 1<>1) order by a.ts_created desc limit 10"; $sql.=" 1<>1) order by a.ts_created desc limit 10";
$this->view->literature=$this->db->fetchAll($sql); $this->view->literature=$this->db->fetchAll($sql);
//相关元数据,根据同名关键词实现 //相关元数据,根据同名关键词实现
$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 heihemetadata 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";
$this->view->related=$this->db->fetchAll($sql,array($id,$id)); $this->view->related=$this->db->fetchAll($sql,array($id,$id));
//用户下载记录 //用户下载记录
$sql = "select o.ts_created,m.uuid,u.realname,u.unit,oa.project as onlineproject, fa.project as offlineproject $sql = "select o.ts_created,m.uuid,u.realname,u.unit,oa.project as onlineproject, fa.project as offlineproject
from dataorder as o left join metadata as m on o.uuid = m.uuid left join users as u on o.userid=u.id from dataorder as o left join metadata as m on o.uuid = m.uuid left join users as u on o.userid=u.id
left join onlineapp oa on o.onlineappid=oa.id left join offlineapp fa on o.offlineappid=fa.id left join onlineapp oa on o.onlineappid=oa.id left join offlineapp fa on o.offlineappid=fa.id
where m.uuid = '$uuid' and (o.status=0 or o.status=5) and u.realname IS NOT NULL order by o.ts_created desc limit 10"; where m.uuid = '$uuid' and (o.status=0 or o.status=5) and u.realname IS NOT NULL order by o.ts_created desc limit 10";
$this->view->downhistory=$this->db->fetchAll($sql); $this->view->downhistory=$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); $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); $this->view->attachments = $this->db->fetchAll($sql);
//数据版本 //数据版本
$sql = "SELECT count(id) as c FROM mdversion WHERE uuid=? AND changelog IS NOT NULL"; $sql = "SELECT count(id) as c FROM mdversion WHERE uuid=? AND changelog IS NOT NULL";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(array($uuid)); $sth->execute(array($uuid));
$row = $sth->fetch(); $row = $sth->fetch();
$this->view->version = $row; $this->view->version = $row;
$archives = new Archive($this->db); $archives = new Archive($this->db);
$data_archives = $archives->getArchiveByUUID($uuid); $data_archives = $archives->getArchiveByUUID($uuid);
if(!empty($data_archives)) if(!empty($data_archives))
{ {
foreach($data_archives as $k=>$v) foreach($data_archives as $k=>$v)
{ {
$data_archives[$k]['url'] = $archives->getArchiveUrlByCid($v['id']); $data_archives[$k]['url'] = $archives->getArchiveUrlByCid($v['id']);
} }
} }
$this->view->data_archives = $data_archives; $this->view->data_archives = $data_archives;
//支持项目 //支持项目
include_once("data/Fund.php"); include_once("data/Fund.php");
$fund = new Fund($this->db); $fund = new Fund($this->db);
$this->view->fund = $fund->fetch($uuid); $this->view->fund = $fund->fetch($uuid);
//判断特殊数据服务 //判断特殊数据服务
$this->view->dataService= $this->checkDataService($uuid); $this->view->dataService= $this->checkDataService($uuid);
//自动跳转 //自动跳转
$sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?"; $sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?";
$row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid)); $row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
$jump=$this->_request->getParam('jump'); $jump=$this->_request->getParam('jump');
if ($jump=="") $jump=1;//默认跳转 if ($jump=="") $jump=1;//默认跳转
if (@$row->has_pages && ($jump==1)) if (@$row->has_pages && ($jump==1))
{ {
$this->_helper->viewRenderer($row->code.'/view',null,true); $this->_helper->viewRenderer($row->code.'/view',null,true);
} }
} //viewAction } //viewAction
//检查特殊数据服务是否存在 //检查特殊数据服务是否存在
private function checkDataService($uuid) private function checkDataService($uuid)
{ {
$order = new \Order\mount\OrderOperate(); $order = new \Order\Mount\OrderOperate();
$service = $order->getDataService($uuid); $service = $order->getDataService($uuid);
if(empty($service)) if(empty($service))
{ {
return NULL; return NULL;
}else{ }else{
if($order->checkOrderHas($uuid)) if($order->checkOrderHas($uuid))
{ {
return NULL; return NULL;
}else{ }else{
return $service; return $service;
} }
} }
}//checkDataService }//checkDataService
//特殊数据服务 //特殊数据服务
public function dataserviceAction() public function dataserviceAction()
{ {
$uuid = $this->_getParam('uuid'); $uuid = $this->_getParam('uuid');
if(empty($uuid)) if(empty($uuid))
{ {
$this->jsonexit(array("error"=>"参数错误")); $this->jsonexit(array("error"=>"参数错误"));
} }
$dataservice = new \data\DataService(); $dataservice = new \data\DataService();
$info = $dataservice->get($uuid); $info = $dataservice->get($uuid);
//暂时只有wsn //暂时只有wsn
{ {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$data = array( $data = array(
"type"=>"wsn", //服务类型 "type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段 "info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.request()", //成功后的js回调函数 "callback"=>"westdc.dataservice.wsn.request()", //成功后的js回调函数
); );
$data['data'] = $dataservice->getWsnData("site",$uuid); $data['data'] = $dataservice->getWsnData("site",$uuid);
if(empty($data['data'])) if(empty($data['data']))
{ {
$this->jsonexit(array("error"=>'数据接口错误,请联系管理员')); $this->jsonexit(array("error"=>'数据接口错误,请联系管理员'));
return true; return true;
} }
if(!is_array($data['data'])) if(!is_array($data['data']))
{ {
$this->jsonexit(array("error"=>$data['data'])); $this->jsonexit(array("error"=>$data['data']));
return true; return true;
} }
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$this->jsonexit($data); $this->jsonexit($data);
} }
// WSN end // WSN end
} }
public function wsnAction() public function wsnAction()
{ {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$type = $this->_getParam('type'); $type = $this->_getParam('type');
$uuid = $this->_getParam("uuid"); $uuid = $this->_getParam("uuid");
$dataservice = new DataService(); $dataservice = new DataService();
if($type == 'var') if($type == 'var')
{ {
$sites = array( $sites = array(
"chk"=>$this->_getParam("siteid") "chk"=>$this->_getParam("siteid")
); );
$info = $dataservice->get($uuid); $info = $dataservice->get($uuid);
$data = array( $data = array(
"type"=>"wsn", //服务类型 "type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段 "info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.Submit()", //成功后的js回调函数 "callback"=>"westdc.dataservice.wsn.Submit()", //成功后的js回调函数
); );
$data['data'] = $dataservice->getWsnData("var",$uuid,$sites); $data['data'] = $dataservice->getWsnData("var",$uuid,$sites);

View File

@ -10,13 +10,8 @@ class IndexController extends Zend_Controller_Action
$this->view->main_nav_pageID = "index"; $this->view->main_nav_pageID = "index";
} }
function indexAction() function indexAction()
{ {
//数据通讯
$l=new mydir($this->view->config->paths->newsletter,"newsletter_*.pdf");
$this->view->newsletter=$l->getLast();
$name=basename($this->view->newsletter,'.pdf');
list(,$this->view->newsletterno)=explode("_",$name);
//统计数据 //统计数据
$sql='select (select count(*) from users) as usernum,(select count(*) from normalmetadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum'; $sql='select (select count(*) from users) as usernum,(select count(*) from normalmetadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum';
$row=$this->db->fetchRow($sql); $row=$this->db->fetchRow($sql);
@ -35,17 +30,11 @@ class IndexController extends Zend_Controller_Action
else else
$this->view->onlinesize=$row['sum']; $this->view->onlinesize=$row['sum'];
} }
//特色推荐
$sql="select * from datafeature order by id desc";
$this->view->feature=$this->db->fetchRow($sql);
//特色数据集
$sql="select * from datasetcd order by random()";
$this->view->datasetcd=$this->db->fetchRow($sql);
//下载最多数据(top 5) //下载最多数据(top 5)
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata m left join dataorder d on m.uuid=d.uuid where m.datatype=0 group by m.id order by count(d.uuid) desc limit 5)"; $sql="select uuid,title,id from en.normalmetadata where id in (select m.id from en.normalmetadata m left join dataorder d on m.uuid=d.uuid where m.datatype=0 group by m.id order by count(d.uuid) desc limit 5)";
$this->db->setFetchMode(Zend_Db::FETCH_OBJ); $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$this->view->mdtop=$this->db->fetchAll($sql); $this->view->mdtop=$this->db->fetchAll($sql);
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata m left join dataorder d on m.uuid=d.uuid where m.datatype=1 group by m.id order by count(d.uuid) desc limit 5)"; $sql="select uuid,title,id from en.normalmetadata where id in (select m.id from en.normalmetadata m left join dataorder d on m.uuid=d.uuid where m.datatype=1 group by m.id order by count(d.uuid) desc limit 5)";
$this->view->offlinemdtop=$this->db->fetchAll($sql); $this->view->offlinemdtop=$this->db->fetchAll($sql);
$sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()"; $sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()";
$this->view->mdrandom=$this->db->fetchRow($sql); $this->view->mdrandom=$this->db->fetchRow($sql);
@ -58,7 +47,7 @@ class IndexController extends Zend_Controller_Action
$News = new Archive($this->db); $News = new Archive($this->db);
$time = date("Y-m-d H:i:s",time()); $time = date("Y-m-d H:i:s",time());
$sql = "SELECT * FROM archive WHERE is_pub=true AND ts_published<'$time' AND image!='' and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5"; $sql = "SELECT * FROM en.archive WHERE is_pub=true AND ts_published<'$time' AND image!='' and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);
@ -71,7 +60,7 @@ class IndexController extends Zend_Controller_Action
$this->view->news = $rows; $this->view->news = $rows;
//$time = date("Y-m-d H:i:s",time()); //$time = date("Y-m-d H:i:s",time());
$sql = "SELECT * FROM archive WHERE is_pub=true AND ts_published<now() and id in (select ar_catalog.aid from ar_catalog left join ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news') order by ts_published desc LIMIT 12 "; $sql = "SELECT * FROM en.archive WHERE is_pub=true AND ts_published<now() and id in (select ar_catalog.aid from en.ar_catalog left join en.ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news') order by ts_published desc LIMIT 12 ";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);
@ -85,7 +74,7 @@ class IndexController extends Zend_Controller_Action
$this->view->list_news = $rows; $this->view->list_news = $rows;
$sql="select d.*,m.ts_published as publish_year from datadoi d right join metadata m on d.uuid=m.uuid where d.ts_published is not null order by ts_published desc limit 4"; $sql="select d.*,m.ts_published as publish_year from datadoi d right join en.metadata m on d.uuid=m.uuid where d.ts_published is not null order by ts_published desc limit 4";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$this->view->dois = $sth->fetchAll(); $this->view->dois = $sth->fetchAll();

View File

@ -1,9 +1,9 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('用户登录'); $this->headTitle('login');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">Home</a>');
$this->breadcrumb('<a href="/account/login">用户登录</a>'); $this->breadcrumb('<a href="/account/login">Login</a>');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
?> ?>
<style> <style>
@ -25,7 +25,7 @@
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<?php if(empty($this->error)) { ?> <?php if(empty($this->error)) { ?>
<div class="alert alert-info alert-login"> <div class="alert alert-info alert-login">
请输入用户名和密码登录 Please input your username and password
</div> </div>
<? }else{ ?> <? }else{ ?>
<div class="alert alert-error alert-login"> <div class="alert alert-error alert-login">
@ -33,23 +33,23 @@
</div> </div>
<?php } ?> <?php } ?>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="username">用户名</label> <label class="control-label" for="username">Username</label>
<div class="controls"> <div class="controls">
<input id="username" type="text" value="" name="username" /> <input id="username" type="text" value="" name="username" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="password">密码</label> <label class="control-label" for="password">Password</label>
<div class="controls"> <div class="controls">
<input id="password" type="password" value="" name="password" /> <input id="password" type="password" value="" name="password" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="captcha">验证码</label> <label class="control-label" for="captcha">Captcha</label>
<div class="controls"> <div class="controls">
<input id="captcha" type="text" value="" name="captcha" /> <input id="captcha" type="text" value="" name="captcha" />
<img id="captcha_img" src="<?php echo $this->captcha ?>" style="cursor:pointer" /> <img id="captcha_img" src="<?php echo $this->captcha ?>" style="cursor:pointer" />
<a href="javascript:void(0);" onclick="changecaptcha()">看不清?</a> <a href="javascript:void(0);" onclick="changecaptcha()">Not clear?</a>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -58,9 +58,9 @@
<?php if(!empty($this->href)){?> <?php if(!empty($this->href)){?>
<input type="hidden" name="href" value="<?= $this->href ?>" /> <input type="hidden" name="href" value="<?= $this->href ?>" />
<?php }?> <?php }?>
<label class="checkbox"><input id="remember" type="checkbox" value="1" name="remember">记住我</label> <label class="checkbox"><input id="remember" type="checkbox" value="1" name="remember">Remember me</label>
<button type="submit" class="btn">登录</button> <button type="submit" class="btn">Login</button>
<a href="/account/fetchpwd">忘记密码?</a> <a href="/account/fetchpwd">Forgot password?</a>
</div> </div>
</div> </div>
</form> </form>

View File

@ -23,10 +23,10 @@ h3.gs_rt{font-size:110%;}
</style> </style>
<?= $this->render('breadcrumbs.phtml'); ?> <?= $this->render('breadcrumbs.phtml'); ?>
<?php $md=$this->metadata;if ($md):?> <?php $md=$this->metadata;if ($md):?>
<h3><?php echo $this->escape($md->title); <h3><?php echo $this->escape($md->title);
if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?> if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</h3> </h3>
<hr /> <hr />
<div class="row"> <div class="row">
<div class="span8"> <div class="span8">
<div> <div>
@ -36,18 +36,19 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</p> </p>
</div> </div>
<div> <div>
<?php if ($md->citation) : ?> <?php if ($md->citation) : ?>
<hr /> <hr />
<h4><i class="icon-quote-left muted"></i>本数据引用方式<a class="btn btn-danger pull-right" href="/archives/help/platform/archive-23.html" ><i class="icon-comment"></i>数据引用帮助</a></h4> <h4><i class="icon-quote-left muted"></i>本数据引用方式<a class="btn btn-danger pull-right" href="/archives/help/platform/archive-23.html" ><i class="icon-comment"></i>数据引用帮助</a></h4>
<p><?php if (empty($md->datadoi) || !strpos($md->citation,$md->datadoi)) : ?><span class="label label-info">文章的引用</span> <p><?php if (empty($md->datadoi) || !strpos($md->citation,$md->datadoi)) : ?><span class="label label-info">文章的引用</span>
<?php endif; echo $this->escape($md->citation);?></p> <?php endif; echo $this->escape($md->citation);?></p>
<?php if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?> <?php if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?>
<p><span class="label label-info">数据的引用</span><?php <p><span class="label label-info">数据的引用</span>
<?php
echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi; echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi;
echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']';
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p> ?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
<?php endif; endif; ?> <?php endif;
<?php endif; if ($this->ref) : ?> endif; if ($this->ref) : ?>
<hr /> <hr />
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4> <h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
<ol> <ol>
@ -65,7 +66,7 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
endforeach; endforeach;
?> ?>
</ol> </ol>
<?php endif; if ($this->themeref) :?> <?php endif; if ($this->themeref) :?>
<hr /> <hr />
<h4><i class="icon-eye-open text-success"></i>专题文献</h4> <h4><i class="icon-eye-open text-success"></i>专题文献</h4>
@ -84,7 +85,7 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
endforeach; endforeach;
?> ?>
</ol> </ol>
<?php if ($this->userref) : ?> <?php endif; if ($this->userref) : ?>
<hr /> <hr />
<h4><i class="icon-eye-open text-success"></i>数据施引文献</h4> <h4><i class="icon-eye-open text-success"></i>数据施引文献</h4>
<ol> <ol>

View File

@ -20,4 +20,11 @@ class Table
//元数据 //元数据
public $metadata = "metadata"; public $metadata = "metadata";
//会员
public $member = "users";
//开放平台
public $oauth_clients = "oauth_clients";
public $oauth_access_tokens = "oauth_access_tokens";
} }

View File

@ -1,11 +1,15 @@
<?php <?php
namespace Helpers; namespace Helpers;
use \Helpers\View as view;
class dbh class dbh
{ {
private $db; //传入PDO对象. private $db; //传入PDO对象.
private $product = 0; //产品环境 private $product = 0; //产品环境
public $debug = 0;
function __construct($db = NULL) function __construct($db = NULL)
{ {
if(empty($db)) if(empty($db))
@ -41,6 +45,12 @@ class dbh
if($return == false){ if($return == false){
$sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas)"; $sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas)";
if($this->debug == 1)
{
view::Dump($sql,false);
}
try{ try{
return $this->db->exec($sql); return $this->db->exec($sql);
}catch (Exception $e) { }catch (Exception $e) {
@ -53,6 +63,12 @@ class dbh
} }
}else{ }else{
$sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas) RETURNING id"; $sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas) RETURNING id";
if($this->debug == 1)
{
view::Dump($sql,false);
}
try{ try{
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
if($sth->execute()) if($sth->execute())
@ -108,6 +124,12 @@ class dbh
try{ try{
$sql = "UPDATE \"".$table."\" SET $fields $wheresql"; $sql = "UPDATE \"".$table."\" SET $fields $wheresql";
if($this->debug == 1)
{
view::Dump($sql,false);
}
if($this->db->exec($sql)) if($this->db->exec($sql))
{ {
return true; return true;
@ -125,6 +147,12 @@ class dbh
}else{ }else{
try{ try{
$sql = "UPDATE \"".$table."\" SET $fields $wheresql"; $sql = "UPDATE \"".$table."\" SET $fields $wheresql";
if($this->debug == 1)
{
view::Dump($sql,false);
}
return $this->db->exec($sql); return $this->db->exec($sql);
}catch (Exception $e) { }catch (Exception $e) {
if($this->product) if($this->product)

View File

@ -1,15 +1,72 @@
<?php <?php
namespace Open; namespace Open;
use Open\Open as open; use \Helpers\View as view;
use \Helpers\dbh;
use \Open\Open as open;
use \Open\Listener\AppListener as Listener;
class app extends open implements openbase class App
{ {
public $tbl_oauth_clients = "oauth_clients"; //oauth 客户端表 public $config;
public $db;
public $table;
public $checkFiled = array('phone','realname','unit','address');
public function __construct($db = NULL,$auth = NULL) public function __construct($db = NULL,$auth = NULL)
{ {
$this->load(); if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$Listener = new Listener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
public function appStatus()
{
return array(
-1 => '关闭',
0 => '测试',
1 => '启用'
);
}
//检查用户资料完整性
public function checkinfo()
{
$uid = view::User('id');
$sql = "SELECT * FROM ".$this->table->member. " WHERE id=$uid";
$rs = $this->db->query($sql);
$row = $rs->fetch();
foreach($this->checkFiled as $v)
{
if(empty($row[$v]))
{
return "请完善个人信息";
}
}
return true;
} }
//获得用户创建的app //获得用户创建的app
@ -17,10 +74,10 @@ class app extends open implements openbase
{ {
if(empty($uid)) if(empty($uid))
{ {
$uid = $this->user->id; $uid = view::User('id');
} }
$sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE user_id=".$this->user->id; $sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE user_id=".$uid ." ORDER BY id DESC";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
@ -34,12 +91,103 @@ class app extends open implements openbase
{ {
return false; return false;
} }
$sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE id=".$id; $sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE id=".$id;
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetch(); $rows = $rs->fetch();
return $rows; return $rows;
} }
//收集创建应用的参数
public function getAppCreateParam(\Zend_Controller_Request_Abstract $request = NULL)
{
$request = new \Zend_Controller_Request_Http();
$data = array(
'subject' => trim($request->getParam('subject')),
'client_domain' => trim($request->getParam('client_domain')),
'redirect_uri' => trim($request->getParam('redirect_uri')),
'status' => (int)$request->getParam('status')
);
return $data;
}//getAppCreateParam
//添加或者编辑
public function appCreate($id = NULL)
{
if(!empty($id))
{
if(!is_numeric($id) || $id<1)
{
return "参数错误";
}
}
$data = $this->getAppCreateParam();
$params = compact('data');
$results = $this->events()->trigger('app.checkParam', $this, $params);
$cache_data = $results->bottom();
if($cache_data !== true)
{
return $cache_data;
}
if(!empty($id))
{
$params = compact('data','id');
}
$results = $this->events()->trigger('app.processData', $this, $params);
$data = $results->bottom();
$dbh = new dbh();
if(empty($id))
{
$id = $dbh->insert($this->table->oauth_clients,$data,true);
if($id > 0)
{
$results = $this->events()->trigger('app.created', $this, compact("data","id"));
$cache_data = $results->bottom();
return $id;
}else{
return "应用创建中发生错误,请重试!";
}
}else{
$status = $dbh->update($this->table->oauth_clients,$data," id=$id ");
if($status)
{
$results = $this->events()->trigger('app.eidted', $this, compact("data","id"));
$cache_data = $results->bottom();
return true;
}else{
return "应用编辑中发生错误,请重试";
}
}
}//appCreate
//删除App
public function delete($id)
{
if(!is_numeric($id) || $id<1)
{
return "参数错误";
}
try{
$sql = "DELETE FROM {$this->table->oauth_clients} WHERE id=$id";
$rs = $this->db->exec($sql);
if($rs)
{
return true;
}else{
return "删除失败";
}
}catch(Excaption $e){
return "服务器处理中遇到错误";
}
}//delete
} }

View File

@ -1,26 +1,18 @@
<?php <?php
namespace open; namespace Open;
interface openbase use \Helpers\View as view;
{ use \Open\Listener\OpenListener as Listener;
public function __construct($db = NULL,$auth = NULL);
}
interface openextend extends openbase class Open extends \Zend_Controller_Plugin_Abstract
{
public function load();
}
abstract class open extends \Zend_Controller_Plugin_Abstract implements openextend
{ {
public $db; public $db;
public $auth = NULL; public $config;
public $user; public $table;
public $checkFiled = array('phone','realname','unit','address');
public function load($db = NULL,$auth = NULL){
$this->config = \Zend_Registry::get('config'); public function __construct($db = NULL,$auth = NULL){
if(empty($db)) if(empty($db))
{ {
$this->db = \Zend_Registry::get('db'); $this->db = \Zend_Registry::get('db');
@ -28,39 +20,27 @@ abstract class open extends \Zend_Controller_Plugin_Abstract implements openexte
$this->db = $db; $this->db = $db;
} }
if(empty($auth)) $this->config = \Zend_Registry::get('config');
{
$this->auth = \Zend_Auth::getInstance(); $Listener = new Listener();
if($this->auth->hasIdentity()) @$this->events()->attachAggregate($Listener);
{
$this->user = $this->auth->getIdentity(); $this->table = new \Helpers\Table();
}
}else{
$this->auth = false;
}
} }
//检查用户资料完整性 public function events(\Zend_EventManager_EventCollection $events = NULL)
public function checkinfo() {
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
public function clientCredentials()
{ {
if($this->auth === false)
{
return "未登陆";
}
include_once("Users.php");
$user = new \Users($this->db);
$info = $user->getUserInfo($this->user->id);
foreach($this->checkFiled as $v)
{
if(empty($info[$v]))
{
return "请完善个人信息";
}
}
return true;
} }
} }

View File

@ -0,0 +1,7 @@
<?php
namespace Order\Event;
interface ApplicationEvent
{
//public function appCheckParam(\Zend_EventManager_Event $e);
}

View File

@ -0,0 +1,36 @@
<?php
namespace Order\Handler;
use \Helpers\View as view;
use \Helpers\dbh;
use \Helpers\Table;
use \Files\Files;
class ApplicationHandler implements \Order\Event\ApplicationEvent
{
private $db; //传入PDO对象误
private $config; //全局配置
public $table;
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->table = new Table();
}
public function applicationCheckParam(\Zend_EventManager_Event $e)
{
$data = $e->getParam('data');
return true;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Order\Listener;
use \Order\Handler\ApplicationHandler as Handler;
class ApplicationListener implements \Zend_EventManager_ListenerAggregate
{
private $event;
function __construct()
{
$this->event = new \Zend_EventManager_EventManager();
}
public function attach(\Zend_EventManager_EventCollection $events)
{
$Handler = new Handler();
//$events->attach('app.checkParam', array($Handler, 'appCheckParam'), 100);
}
public function detach(\Zend_EventManager_EventCollection $events)
{
}
}

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
//接口 需要实现的Listener中的方法 //接口 需要实现的Listener中的方法
interface ManagerEvents interface ManagerEvents
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
use Order\mount\ManagerOperate; use Order\Mount\ManagerOperate;
//侦听 //侦听
class ManagerListener implements \Zend_EventManager_ListenerAggregate class ManagerListener implements \Zend_EventManager_ListenerAggregate

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
//接口 需要实现的Listener中的方法 //接口 需要实现的Listener中的方法
interface OrderEvents interface OrderEvents
{ {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
use Order\mount\OrderOperate; use Order\Mount\OrderOperate;
use Order\mount\PdfForm; use Order\Mount\PdfForm;
use Order\mount\PdfOperate; use Order\Mount\PdfOperate;
//侦听 //侦听
class OrderListener implements \Zend_EventManager_ListenerAggregate class OrderListener implements \Zend_EventManager_ListenerAggregate

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
//接口 需要实现的Listener中的方法 //接口 需要实现的Listener中的方法
interface PdfEvents interface PdfEvents
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Order\listener; namespace Order\Listener;
//接口 需要实现的Listener中的方法 //接口 需要实现的Listener中的方法
interface PdfFormEvents interface PdfFormEvents
{ {

View File

@ -0,0 +1,66 @@
<?php
namespace Order\Manager;
use \Helpers\View as view;
use \Helpers\dbh;
use \Order\Listener\ApplicationListener as Listener;
class Application
{
public $config;
public $db;
public $table;
public $keyword;
public $filter;
public function __construct($db = NULL,$auth = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$Listener = new Listener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
//已经通过的所有申请
public function passed()
{
$select=$this->db->select();
$select ->from('offlineapp')
->where('ts_approved is not null')
->where('pdflink is not null')
->where('status>=0')
->order('ts_created desc');
if(!empty($this->keyword))
{
$select ->where(" (username LIKE '%{$this->keyword}%' OR
unit LIKE '%{$this->keyword}%' OR
project_id LIKE '%{$this->keyword}%' OR
project_type LIKE '%{$this->keyword}%' OR
project_leader LIKE '%{$this->keyword}%' OR
project LIKE '%{$this->keyword}%' )");
}
return $select;
}
}

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Order\mount; namespace Order\Mount;
use Helpers\View as view; use Helpers\View as view;
use Helpers\dbh; use Helpers\dbh;
@ -7,7 +7,7 @@ use Mail\Mail;
use Order\Manager\Offlineapp; use Order\Manager\Offlineapp;
//事件中存在的操作 //事件中存在的操作
class ManagerOperate implements \Order\listener\ManagerEvents class ManagerOperate implements \Order\Listener\ManagerEvents
{ {
private $db; private $db;
private $config; private $config;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Order\mount; namespace Order\Mount;
use Helpers\View as view; use \Helpers\View as view;
//事件中存在的操作 //事件中存在的操作
class OrderOperate implements \Order\listener\OrderEvents class OrderOperate implements \Order\Listener\OrderEvents
{ {
private $db; private $db;
private $config; private $config;
@ -49,7 +49,7 @@ class OrderOperate implements \Order\listener\OrderEvents
} }
}catch(Exception $e) }catch(Exception $e)
{ {
\view::Dump($e->getMessage()); view::Dump($e->getMessage());
} }
return true; return true;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Order\mount; namespace Order\Mount;
use Helpers\View as view; use \Helpers\View as view;
//事件中存在的操作 //事件中存在的操作
class PdfForm implements \Order\listener\PdfFormEvents class PdfForm implements \Order\Listener\PdfFormEvents
{ {
private $db; private $db;
private $config; private $config;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace Order\mount; namespace Order\Mount;
use Helpers\View as view; use \Helpers\View as view;
use Helpers\dbh; use \Helpers\dbh;
use Mail\Mail; use \Mail\Mail;
//事件中存在的操作 //事件中存在的操作
class PdfOperate implements \Order\listener\PdfEvents class PdfOperate implements \Order\Listener\PdfEvents
{ {
private $db; private $db;
private $config; private $config;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Order; namespace Order;
use Helpers\View as view; use \Helpers\View as view;
use Mail\Mail; use \Mail\Mail;
use Order\listener\OrderListener; use \Order\Listener\OrderListener;
use Files\Output; use \Files\Output;
class Order class Order
{ {

View File

@ -36,13 +36,14 @@ class RisHandler implements \Reference\Event\RisEvent
$wheresql = array(); $wheresql = array();
$wheresql[] = " title='{$ref['title']}' "; $wheresql[] = " lower(title)=lower('{$ref['title']}') ";
$wheresql[] = " year='{$ref['year']}' "; $wheresql[] = " year='{$ref['year']}' ";
if(isset($ref['publisher'])) //暂时不使用期刊限制
/*if(isset($ref['publisher']))
{ {
$wheresql[] = " publisher='{$ref['publisher']}' "; $wheresql[] = " publisher='{$ref['publisher']}' ";
} }*/
if(count($wheresql) > 0) if(count($wheresql) > 0)
{ {

View File

@ -16,6 +16,7 @@ class Reference
public $keyword; public $keyword;
public $order; public $order;
public $sort = "DESC"; public $sort = "DESC";
public $field;
public $reftype; public $reftype;
@ -176,6 +177,24 @@ class Reference
{ {
$wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') "; $wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') ";
} }
if(!empty($this->field))
{
foreach($this->field as $k=>$v)
{
if(!empty($v))
{
if(!is_numeric($v)) $v="'{$v}'";
$wheresql[] = " ({$this->table->reference}.{$k}={$v} ) ";
}else{
if(is_numeric($v))
$wheresql[] = " ({$this->table->reference}.{$k} IS NULL OR {$this->table->reference}.{$k}=0 ) ";
else
$wheresql[] = " ({$this->table->reference}.{$k} IS NULL ) ";
}//if(empty($v)
}//foreach
}
if(count($wheresql)>0) if(count($wheresql)>0)
{ {
$wheresql = " WHERE ".join(" AND ",$wheresql); $wheresql = " WHERE ".join(" AND ",$wheresql);
@ -453,7 +472,7 @@ class Reference
public function referenceType() public function referenceType()
{ {
return array( return array(
0 => '相关文献', 0 => '相关文献',//作者建议的文献或数据中心建议的文献
1 => '施引文献', 1 => '施引文献',
2 => '参考文献', 2 => '参考文献',
3 => '多篇文献', 3 => '多篇文献',
@ -517,4 +536,65 @@ class Reference
} }
} }
//按年份获得文献数量
public function countByYear()
{
$sql = "SELECT count(id) as num,year FROM {$this->table->reference} GROUP BY year ORDER BY year DESC";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//获得作者
public function getAuthorByReference($id,$join = false)
{
if(is_numeric($id))
{
$sql = "SELECT * FROM {$this->table->reference_author} WHERE id=$id ORDER BY place ASC";
$rs = $this->db->query($sql);
if(!$join)
{
return $rs->fetchAll();
}else{
foreach($rows = $rs->fetchAll() as $k=>$v)
{
$rows[$k] = (string)$v['firstname'].$v['lastname'];
}
return $rows;
}
}
if(is_array($id))
{
$sql = "SELECT * FROM {$this->table->reference_author} WHERE id IN (".join(",",$id).")";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
return;
}
//获得标签
public function getTagsByReference($id,$single = false)
{
if(is_numeric($id))
{
$sql = "SELECT * FROM {$this->table->reference_tag} WHERE id=$id";
$rs = $this->db->query($sql);
if(!$single)
{
return $rs->fetchAll();
}else{
foreach($rows = $rs->fetchAll() as $k=>$v)
{
$rows[$k] = (string)$v['tag'];
}
return $rows;
}
}
return;
}
} }

View File

@ -174,18 +174,20 @@ class Ris
$results = $this->events()->trigger('checkLoad', $this, compact('ref')); $results = $this->events()->trigger('checkLoad', $this, compact('ref'));
$id = $results->bottom(); $id = $results->bottom();
$this->unsetVar($ref);
if ($id > 0) if ($id > 0)
{ {
$this->unsetVar($ref);
$this->events()->trigger('deleteAuthor', $this, compact('id')); $this->events()->trigger('deleteAuthor', $this, compact('id'));
$this->events()->trigger('deleteTag', $this, compact('id')); $this->events()->trigger('deleteTag', $this, compact('id'));
unset($ref['reference']); unset($ref['reference']);
$dbh->update($this->table->reference,$ref," id=$id "); $dbh->update($this->table->reference,$ref," id=$id ");
} else { } else {
$ref['reference'] = $this->makeReferenceFlag($ref); $ref['reference'] = $this->makeReferenceFlag($ref);
$this->unsetVar($ref);
$id = $dbh->insert($this->table->reference,$ref,true); $id = $dbh->insert($this->table->reference,$ref,true);
} }
@ -272,17 +274,17 @@ class Ris
//创建reference 字段 //创建reference 字段
public function makeReferenceFlag($ref){ public function makeReferenceFlag($ref){
$str = array(); $str = join(', ',$ref['author']).'. ';
isset($ref['author']) ? $str[] = join(",",$ref['author']):""; $str .= $ref['title'].'. ';
isset($ref['title']) ? $str[] = $ref['title']:""; $str .= $ref['publisher'].', ';
isset($ref['year']) ? $str[] = $ref['year']:""; isset($ref['year']) ? $str .= $ref['year'].', ':"";
isset($ref['volume']) ? $str[] = $ref['volume']:""; isset($ref['volume']) ? $str .= $ref['volume']:"";
isset($ref['issue']) ? $str[] = $ref['issue']:""; isset($ref['issue']) ? $str .= '('.$ref['issue'].')':"";
isset($ref['pages']) ? $str[] = $ref['pages']:""; isset($ref['pages']) ? $str .= ':'.$ref['pages']:"";
isset($ref['endpage'])? $str[] = $ref['endpage']:""; isset($ref['endpage'])? $str .= '-'.$ref['endpage']:"";
isset($ref['doi']) ? $str[] = $ref['doi'] : ""; isset($ref['doi']) ? $str .= '. doi:'.$ref['doi'] : "";
return join(",",$str); return $str;
} }
//卸载不需要的变量 //卸载不需要的变量

View File

@ -0,0 +1,153 @@
<?php
namespace Reference;
use \Helpers\View as view;
use \Helpers\dbh;
//use \Reference\Listener\RisOutputListener as Listener;
use \Files\Files;
use \Reference\Reference;
use \Reference\Ris;
use \LibRIS\RISReader;
use \LibRIS\RISTags;
use \LibRIS\RISWriter;
class RisOutput
{
private $db; //传入PDO对象.
private $config; //站点设置
private $dbh;
protected $events = NULL;
public $table;
public $ris_records = NULL;
protected $ris;
public $attr;
public $attr_flip;
function __construct($db = NULL,$mail = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
//$Listener = new Listener();
//@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
//读取数据
public function preRead($mode = "all")
{
if($mode == "all")
{
$sql = "SELECT * FROM {$this->table->reference} where length(ris)<10 or ris is null ORDER BY year DESC,title ASC,id ASC";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
}//preRead
//将数据组成RIS数组格式
public function processArrayDataToRisData($arrayData,$risPrior = true,$mixAuthor = true,$mixTags = true)
{
if(!is_array($arrayData))
{
return false;
}
$risData = array();
if($risPrior === true)
{
$risReader = new RISReader();
}
$this->ris = new Ris();
$this->attr = $this->ris->attr;
$this->attr_flip = array_flip($this->ris->attr);
unset($this->ris);
$this->reference = new Reference();
foreach($arrayData as $k=>$v)
{
$risData[$k] = $this->transformToRis($v);
if($mixAuthor === true || $mixTags === true)
{
if($mixAuthor === true)
{
$author = $this->reference->getAuthorByReference($v['id'],true);
if(is_array($author) && count($author)>0)
{
$risData[$k] = array_merge($risData[$k],array("AU"=>$author));
}
unset($author);
}//mixAuthor
if($mixTags === true)
{
$tags = $this->reference->getTagsByReference($v['id'],true);
if(is_array($tags) && count($tags) > 0)
{
$risData[$k] = array_merge($risData[$k],array("KW"=>$tags));
}
unset($tags);
}
}
if(!is_array($risData[$k]) || count($risData[$k]) < 1)
{
unset($risData[$k]);
}
unset($arrayData[$k]);
}
return $risData;
}//processArrayDataToRisData
//单条记录的整编
public function transformToRis($record)
{
$arr = array();
foreach($record as $k=>$v)
{
if(!empty($v))
{
if(isset($this->attr_flip[$k]))
{
//echo $k ."-". $this->attr_flip[$k] . '-' .$v;
//echo "<br />";
$arr[$this->attr_flip[$k]] = array(0=>$v);
}
}
}
//echo "<br />";
return $arr;
}//transformToRis
//输出成文件
public function output($risData)
{
$risWirte = new RISWriter();
return @$risWirte->writeRecords($risData);
}//output
}