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 Reference\Reference;
use Reference\Ris;
use Reference\RisOutput;
use Helpers\dbh;
use \Files\Files;
@ -1128,6 +1129,7 @@ class Admin_DataController extends Zend_Controller_Action
$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'));
$field = $this->view->search_field = $this->_getParam('field');
$reference = new Reference();
@ -1136,6 +1138,11 @@ class Admin_DataController extends Zend_Controller_Action
$reference->keyword = $keyword;
}
if(!empty($field))
{
$reference->field = $field;
}
if(!empty($order))
{
$reference->order = $order;
@ -1146,32 +1153,41 @@ class Admin_DataController extends Zend_Controller_Action
$reference->sort = $sort;
}
$this->view->reference = $reference;
$this->view->page = $this->_getParam('page');
$this->view->pagelimit = 12;
//文献首页
if(empty($ac))
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this,12);
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit);
$this->view->years = $reference->countByYear();
return true;
}
else if ($ac == "water")
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchThemeReferences('water'),$this,10);
view::addPaginator($reference->fetchThemeReferences('water'),$this,$this->view->pagelimit);
return true;
}
else if ($ac == "westdc")
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchWestdcReferences(),$this,10);
view::addPaginator($reference->fetchWestdcReferences(),$this,$this->view->pagelimit);
return true;
}
else if ($ac == "todo")
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchTodoReferences(),$this,10);
view::addPaginator($reference->fetchTodoReferences(),$this,$this->view->pagelimit);
return true;
}
unset($this->view->reference);
unset($this->view->page);
unset($this->view->pagelimit);
//添加
if($ac == "add")
{
@ -1378,6 +1394,41 @@ class Admin_DataController extends Zend_Controller_Action
return true;
}//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()

View File

@ -4,6 +4,7 @@ use Files\Files;
use Files\Output;
use Files\Listener\FileListener;
use Order\Manager\Offlineapp;
use Order\Manager\Application;
use data\DataService;
use Mail\Mail;
@ -1137,16 +1138,15 @@ class Admin_DownController extends Zend_Controller_Action
->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');
$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开始记录。
function onlineAction()

View File

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

View File

@ -15,6 +15,7 @@
<label class="control-label" for="inputUuid">元数据UUID</label>
<div class="controls">
<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 class="control-group">

View File

@ -1,10 +1,11 @@
<ul class="nav nav-tabs">
<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=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</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=="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=="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=="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>

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)) { ?>
<?= $this->msg ?>
<?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">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
@ -45,8 +56,7 @@ table thead tr th {background:#EBF2F6;}
<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=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=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
@ -58,37 +68,36 @@ table thead tr th {background:#EBF2F6;}
</tr>
</thead>
<tbody>
<?php $autoindex=0;
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<?php if(!empty($item['title']) || !empty($item['year'])) { ?>
<td><?= $item['title'] ?></td>
<td><?= $item['year'] ?></td>
<td>
[<?= $autoindex ?>]&nbsp;
<?php if ($item['ris']) :
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 rowspan="2">
<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="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>
</td>
</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; ?>
</tbody>
</table>

View File

@ -27,8 +27,20 @@
</div>
<?php endif; ?>
<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>
<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)): ?>
<table>
<thead><tr>

View File

@ -54,7 +54,7 @@ table thead tr th {background:#EBF2F6;color:#444;}
<td>
<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/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="/admin/down/offlineapps/ac/resetappform/?offlineappid=<?= $item['id'] ?>" onclick="return confirm('是否确认重置该用户的申请表?')">重置申请表</a>
</td>

View File

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

View File

@ -374,15 +374,6 @@ class AccountController extends Zend_Controller_Action
view::Post($this,"登录成功,正在跳转",$tohref);
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{
$this->setCaptcha($captcha);

View File

@ -24,62 +24,32 @@ class DataController extends Zend_Controller_Action
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();
//分类
$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();
//关键词
$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();
$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");
$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();
$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();
$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");
$k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
//最新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();
//特色数据
//服务
$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();
$this->view->searchform=$searchform;
@ -546,8 +516,8 @@ class DataController extends Zend_Controller_Action
function viewAction()
{
$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
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 ";
$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 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)) {
$uuid = $this->_request->getParam('uuid');
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=$this->db->quoteInto($sql,$uuid);
$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=$this->db->quoteInto($sql,$uuid);
$this->view->userref=$this->db->fetchAll($sql);
//多篇引用形式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=$this->db->quoteInto($sql,$uuid);
$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";
$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=?";
$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 (
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;";
$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 (";
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="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";
$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
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
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);
//数据附件
$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);
//数据版本
$sql = "SELECT count(id) as c FROM mdversion WHERE uuid=? AND changelog IS NOT NULL";
$sth = $this->db->prepare($sql);
$sth->execute(array($uuid));
$row = $sth->fetch();
$this->view->version = $row;
$archives = new Archive($this->db);
$data_archives = $archives->getArchiveByUUID($uuid);
if(!empty($data_archives))
{
foreach($data_archives as $k=>$v)
{
$data_archives[$k]['url'] = $archives->getArchiveUrlByCid($v['id']);
}
}
$this->view->data_archives = $data_archives;
//支持项目
include_once("data/Fund.php");
$fund = new Fund($this->db);
$this->view->fund = $fund->fetch($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=?";
$row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
$jump=$this->_request->getParam('jump');
if ($jump=="") $jump=1;//默认跳转
if (@$row->has_pages && ($jump==1))
{
$this->_helper->viewRenderer($row->code.'/view',null,true);
}
} //viewAction
//检查特殊数据服务是否存在
private function checkDataService($uuid)
{
$order = new \Order\mount\OrderOperate();
$service = $order->getDataService($uuid);
if(empty($service))
{
return NULL;
}else{
if($order->checkOrderHas($uuid))
{
return NULL;
}else{
return $service;
}
}
}//checkDataService
//特殊数据服务
public function dataserviceAction()
{
$uuid = $this->_getParam('uuid');
if(empty($uuid))
{
$this->jsonexit(array("error"=>"参数错误"));
}
$dataservice = new \data\DataService();
$info = $dataservice->get($uuid);
//暂时只有wsn
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.request()", //成功后的js回调函数
);
$data['data'] = $dataservice->getWsnData("site",$uuid);
if(empty($data['data']))
{
$this->jsonexit(array("error"=>'数据接口错误,请联系管理员'));
return true;
}
if(!is_array($data['data']))
{
$this->jsonexit(array("error"=>$data['data']));
return true;
}
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->jsonexit($data);
}
// WSN end
}
public function wsnAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$type = $this->_getParam('type');
$uuid = $this->_getParam("uuid");
$dataservice = new DataService();
if($type == 'var')
{
$sites = array(
"chk"=>$this->_getParam("siteid")
);
$info = $dataservice->get($uuid);
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.Submit()", //成功后的js回调函数
);
//用户发表文献
$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);
$this->view->userref=$this->db->fetchAll($sql);
//多篇引用形式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=$this->db->quoteInto($sql,$uuid);
$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";
$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=?";
$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 (
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;";
$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 (";
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="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));
//用户下载记录
$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
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";
$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);
$this->view->attachments = $this->db->fetchAll($sql);
//数据版本
$sql = "SELECT count(id) as c FROM mdversion WHERE uuid=? AND changelog IS NOT NULL";
$sth = $this->db->prepare($sql);
$sth->execute(array($uuid));
$row = $sth->fetch();
$this->view->version = $row;
$archives = new Archive($this->db);
$data_archives = $archives->getArchiveByUUID($uuid);
if(!empty($data_archives))
{
foreach($data_archives as $k=>$v)
{
$data_archives[$k]['url'] = $archives->getArchiveUrlByCid($v['id']);
}
}
$this->view->data_archives = $data_archives;
//支持项目
include_once("data/Fund.php");
$fund = new Fund($this->db);
$this->view->fund = $fund->fetch($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=?";
$row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
$jump=$this->_request->getParam('jump');
if ($jump=="") $jump=1;//默认跳转
if (@$row->has_pages && ($jump==1))
{
$this->_helper->viewRenderer($row->code.'/view',null,true);
}
} //viewAction
//检查特殊数据服务是否存在
private function checkDataService($uuid)
{
$order = new \Order\Mount\OrderOperate();
$service = $order->getDataService($uuid);
if(empty($service))
{
return NULL;
}else{
if($order->checkOrderHas($uuid))
{
return NULL;
}else{
return $service;
}
}
}//checkDataService
//特殊数据服务
public function dataserviceAction()
{
$uuid = $this->_getParam('uuid');
if(empty($uuid))
{
$this->jsonexit(array("error"=>"参数错误"));
}
$dataservice = new \data\DataService();
$info = $dataservice->get($uuid);
//暂时只有wsn
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.request()", //成功后的js回调函数
);
$data['data'] = $dataservice->getWsnData("site",$uuid);
if(empty($data['data']))
{
$this->jsonexit(array("error"=>'数据接口错误,请联系管理员'));
return true;
}
if(!is_array($data['data']))
{
$this->jsonexit(array("error"=>$data['data']));
return true;
}
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->jsonexit($data);
}
// WSN end
}
public function wsnAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$type = $this->_getParam('type');
$uuid = $this->_getParam("uuid");
$dataservice = new DataService();
if($type == 'var')
{
$sites = array(
"chk"=>$this->_getParam("siteid")
);
$info = $dataservice->get($uuid);
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"westdc.dataservice.wsn.Submit()", //成功后的js回调函数
);
$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";
}
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);
function indexAction()
{
//统计数据
$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);
@ -35,17 +30,11 @@ class IndexController extends Zend_Controller_Action
else
$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)
$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->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);
$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);
@ -58,7 +47,7 @@ class IndexController extends Zend_Controller_Action
$News = new Archive($this->db);
$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);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
@ -71,7 +60,7 @@ class IndexController extends Zend_Controller_Action
$this->view->news = $rows;
//$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);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
@ -85,7 +74,7 @@ class IndexController extends Zend_Controller_Action
$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);
$this->view->dois = $sth->fetchAll();

View File

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

View File

@ -23,10 +23,10 @@ h3.gs_rt{font-size:110%;}
</style>
<?= $this->render('breadcrumbs.phtml'); ?>
<?php $md=$this->metadata;if ($md):?>
<h3><?php echo $this->escape($md->title);
if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</h3>
<hr />
<h3><?php echo $this->escape($md->title);
if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</h3>
<hr />
<div class="row">
<div class="span8">
<div>
@ -36,18 +36,19 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</p>
</div>
<div>
<?php if ($md->citation) : ?>
<?php if ($md->citation) : ?>
<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>
<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 if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?>
<p><span class="label label-info">数据的引用</span><?php
<?php if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?>
<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->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>
<?php endif; endif; ?>
<?php endif; if ($this->ref) : ?>
<?php endif;
endif; if ($this->ref) : ?>
<hr />
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
<ol>
@ -65,7 +66,7 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
endforeach;
?>
</ol>
<?php endif; if ($this->themeref) :?>
<?php endif; if ($this->themeref) :?>
<hr />
<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;
?>
</ol>
<?php if ($this->userref) : ?>
<?php endif; if ($this->userref) : ?>
<hr />
<h4><i class="icon-eye-open text-success"></i>数据施引文献</h4>
<ol>

View File

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

View File

@ -1,15 +1,72 @@
<?php
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)
{
$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
@ -17,10 +74,10 @@ class app extends open implements openbase
{
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);
$rows = $rs->fetchAll();
@ -34,12 +91,103 @@ class app extends open implements openbase
{
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);
$rows = $rs->fetch();
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
namespace open;
namespace Open;
interface openbase
{
public function __construct($db = NULL,$auth = NULL);
}
use \Helpers\View as view;
use \Open\Listener\OpenListener as Listener;
interface openextend extends openbase
{
public function load();
}
abstract class open extends \Zend_Controller_Plugin_Abstract implements openextend
class Open extends \Zend_Controller_Plugin_Abstract
{
public $db;
public $auth = NULL;
public $user;
public $config;
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))
{
$this->db = \Zend_Registry::get('db');
@ -28,39 +20,27 @@ abstract class open extends \Zend_Controller_Plugin_Abstract implements openexte
$this->db = $db;
}
if(empty($auth))
{
$this->auth = \Zend_Auth::getInstance();
if($this->auth->hasIdentity())
{
$this->user = $this->auth->getIdentity();
}
}else{
$this->auth = false;
}
$this->config = \Zend_Registry::get('config');
$Listener = new Listener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
//检查用户资料完整性
public function checkinfo()
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 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
namespace Order\listener;
namespace Order\Listener;
//接口 需要实现的Listener中的方法
interface ManagerEvents
{

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<?php
namespace Order\listener;
namespace Order\Listener;
//接口 需要实现的Listener中的方法
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
namespace Order\mount;
namespace Order\Mount;
use Helpers\View as view;
use Helpers\dbh;
@ -7,7 +7,7 @@ use Mail\Mail;
use Order\Manager\Offlineapp;
//事件中存在的操作
class ManagerOperate implements \Order\listener\ManagerEvents
class ManagerOperate implements \Order\Listener\ManagerEvents
{
private $db;
private $config;

View File

@ -1,10 +1,10 @@
<?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 $config;
@ -49,7 +49,7 @@ class OrderOperate implements \Order\listener\OrderEvents
}
}catch(Exception $e)
{
\view::Dump($e->getMessage());
view::Dump($e->getMessage());
}
return true;

View File

@ -1,10 +1,10 @@
<?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 $config;

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@ class Reference
public $keyword;
public $order;
public $sort = "DESC";
public $field;
public $reftype;
@ -176,6 +177,24 @@ class Reference
{
$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)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
@ -453,7 +472,7 @@ class Reference
public function referenceType()
{
return array(
0 => '相关文献',
0 => '相关文献',//作者建议的文献或数据中心建议的文献
1 => '施引文献',
2 => '参考文献',
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'));
$id = $results->bottom();
$this->unsetVar($ref);
if ($id > 0)
{
{
$this->unsetVar($ref);
$this->events()->trigger('deleteAuthor', $this, compact('id'));
$this->events()->trigger('deleteTag', $this, compact('id'));
unset($ref['reference']);
$dbh->update($this->table->reference,$ref," id=$id ");
} else {
$ref['reference'] = $this->makeReferenceFlag($ref);
} else {
$ref['reference'] = $this->makeReferenceFlag($ref);
$this->unsetVar($ref);
$id = $dbh->insert($this->table->reference,$ref,true);
}
@ -272,17 +274,17 @@ class Ris
//创建reference 字段
public function makeReferenceFlag($ref){
$str = array();
isset($ref['author']) ? $str[] = join(",",$ref['author']):"";
isset($ref['title']) ? $str[] = $ref['title']:"";
isset($ref['year']) ? $str[] = $ref['year']:"";
isset($ref['volume']) ? $str[] = $ref['volume']:"";
isset($ref['issue']) ? $str[] = $ref['issue']:"";
isset($ref['pages']) ? $str[] = $ref['pages']:"";
isset($ref['endpage'])? $str[] = $ref['endpage']:"";
isset($ref['doi']) ? $str[] = $ref['doi'] : "";
$str = join(', ',$ref['author']).'. ';
$str .= $ref['title'].'. ';
$str .= $ref['publisher'].', ';
isset($ref['year']) ? $str .= $ref['year'].', ':"";
isset($ref['volume']) ? $str .= $ref['volume']:"";
isset($ref['issue']) ? $str .= '('.$ref['issue'].')':"";
isset($ref['pages']) ? $str .= ':'.$ref['pages']:"";
isset($ref['endpage'])? $str .= '-'.$ref['endpage']:"";
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
}