merge heihedata branch from r3925 to r3955.

This commit is contained in:
wlx 2013-10-09 08:03:47 +00:00
parent b854b5cb53
commit a36fecad2a
21 changed files with 712 additions and 162 deletions

View File

@ -1,6 +1,7 @@
<?php
use Helpers\View as view;
use Reference\Reference;
use \Files\Files;
class Admin_DataController extends Zend_Controller_Action
{
@ -1100,14 +1101,14 @@ class Admin_DataController extends Zend_Controller_Action
}
} //搜索
else{
$select=$this->db->select();
$select->from('mdref',array('id as mdid','refid','place'))
->join('metadata','metadata.uuid=mdref.uuid')
->join('reference','reference.id=mdref.refid')
->order('metadata.ts_created desc')
->order('mdref.place');
$paginator = Zend_Paginator::factory($select);
else{
$sql="select m.title as mdtitle,m.uuid,mr.id as mdid,mr.refid,mr.place,r.reference
from mdref mr right join metadata m on mr.uuid=m.uuid
left join reference r on mr.refid=r.id
order by m.ts_created desc,mr.place";
$re=$this->db->query($sql);
$row=$re->fetchAll();
$paginator = Zend_Paginator::factory($row);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
@ -1122,13 +1123,36 @@ class Admin_DataController extends Zend_Controller_Action
{
$this->view->ac = $ac = $this->_getParam('ac');
$submit = $this->_getParam('submit');
$keyword = $this->view->q = trim($this->_getParam('q'));
$order = $this->view->search_order = trim($this->_getParam('order'));
$sort = $this->view->search_sort = trim($this->_getParam('sort'));
$reference = new Reference();
if(!empty($keyword))
{
$reference->keyword = $keyword;
}
if(!empty($order))
{
$reference->order = $order;
}
if(!empty($sort))
{
$reference->sort = $sort;
}
//文献首页
if(empty($ac))
{
view::addPaginator($reference->fetchReferences(),$this,10);
view::addPaginator($reference->fetchReferences(),$this,12);
return true;
}
else if ($ac == "water")
{
view::addPaginator($reference->fetchThemeReferences('water'),$this,10);
return true;
}
@ -1137,9 +1161,13 @@ class Admin_DataController extends Zend_Controller_Action
{
$this->_helper->viewRenderer('ref-add');
$id = $this->_getParam('id');
$attid = $this->_getParam('attid');
if(!empty($submit))
{
$this->view->data = $reference->getReferenceParam();
$attid = $this->view->data['attid'];
if(empty($id) || !is_numeric($id))
{
$status = $reference->reference();
@ -1154,18 +1182,30 @@ class Admin_DataController extends Zend_Controller_Action
if(!empty($id))
{
$msg = "文献修改成功!";
view::Post($this,$msg,-2);
return true;
}else{
$msg = "文献添加成功!";
view::Post($this,$msg,"/admin/data/ref/ac/add");
return true;
}
view::Post($this,$msg,"/admin/data/ref/ac/add");
}
}else{
$this->view->data = array();
if(!empty($id) && is_numeric($id))
{
$this->view->data = $reference->getOneReferenceData($id);
}
}
if(!empty($attid))
{
$files = new Files();
$attfile = $files->getOne($attid);
$this->view->data['attid'] = $attid;
$this->view->data['file'] = $attfile;
}
return true;
}
@ -1174,7 +1214,12 @@ class Admin_DataController extends Zend_Controller_Action
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$statu = $reference->uploadReferencePdf($_FILES['Filedata']);
$autoread = false;
if($this->_getParam('multi'))
{
$autoread = true;
}
$statu = $reference->uploadReferencePdf($_FILES['Filedata'],$autoread);
$this->jsonexit($statu);
return true;
}
@ -1189,6 +1234,35 @@ class Admin_DataController extends Zend_Controller_Action
return true;
}
//批量上传
if($ac == "multiupload")
{
$this->_helper->viewRenderer('ref-multiupload');
return true;
}
//文件管理
if($ac == "files")
{
$this->_helper->viewRenderer('ref-files');
view::addPaginator($reference->getReferenceFiles(),$this,10);
return true;
}
//删除文献
if($ac == "deleteref")
{
$refid = $this->_getParam('id');
if($reference->deleteReference($refid))
{
view::Post($this,"删除成功!",-1);
}else{
view::Post($this,"删除失败!",-1);
}
return true;
}
}//文献管理 refAction()
/*
@ -2567,7 +2641,7 @@ class Admin_DataController extends Zend_Controller_Action
}else{
$mail->addTo($this->debug_email);
}
@$mail->send();
//@$mail->send();
$data = array("commited"=>1,"error"=>'该版本已经成功发布!');
$this->jsonexit($data);
@ -3488,13 +3562,13 @@ class Admin_DataController extends Zend_Controller_Action
if(empty($uuid))
{
$rows = $fund->fetch(NULL,true,0,$keyword);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
}else{
include('data/Metadata.php');
$md = new Metadata($this->db);
$this->view->md = $md->view($uuid);
$rows = $fund->fetch($uuid);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
}
return true;
}
@ -3504,7 +3578,7 @@ class Admin_DataController extends Zend_Controller_Action
$this->_helper->viewRenderer('fund-data-list');
$this->view->q = $q = $this->_getParam('q');
$rows = $fund->fetchFromData(true,0,$q);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
return true;
}
@ -3515,7 +3589,7 @@ class Admin_DataController extends Zend_Controller_Action
$id = $this->_getParam('id');
$this->view->fund = $fund->view($id);
$rows = $fund->fetchFromData($id,0,$q);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
return true;
}
@ -3647,7 +3721,7 @@ class Admin_DataController extends Zend_Controller_Action
$md = new Metadata($this->db);
$this->view->md = $md->view($uuid);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
return true;
}//formd
@ -3695,7 +3769,7 @@ class Admin_DataController extends Zend_Controller_Action
}
$rows = $fund->getData($id,$keyword);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
}
}//fund
@ -3716,7 +3790,7 @@ class Admin_DataController extends Zend_Controller_Action
if(empty($uuid))
{
$rows = $doi->fetch(0,$q);
view::addPaginator($rows,$this->view,$this->_request);
view::addPaginator($rows,$this,10);
}else{
$this->_redirect('/admin/data/doi/ac/edit/?uuid='.$uuid);
return true;

View File

@ -170,6 +170,7 @@ class Admin_DownController extends Zend_Controller_Action
//离线数据申请管理
function offlineappAction()
{
set_time_limit(0);
include_once("Dataorder.php");
$DO = new Dataorder($this->db);
@ -181,8 +182,23 @@ class Admin_DownController extends Zend_Controller_Action
$page =(int)$this->_getParam('page');
$reset =(int)$this->_getParam('reset');
$status =(int)$this->_getParam('status');
$ac = $this->_getParam('ac');
$q = $this->_getParam('q');
if($ac == "pending")
{
$keyword = "";
if(!empty($q))
{
$keyword = $q;
}
$rows = $DO->fetchAllOfflineApp(3,$keyword);
view::addPaginator($rows,$this,10);
return true;
}
if (!$page) $page=1;
if ($view) {
//查看此次申请的pdf
@ -215,10 +231,10 @@ class Admin_DownController extends Zend_Controller_Action
//如果是wsn数据则生成数据
$dataservice = new DataService();
$offlineapp = new Offlineapp();
if ($offlineapp->hasWsnData($start))
{
@$dataservice->makeWsnData(array('uid'=>$row['userid'],'action'=>'prepare'));
$offlineapp = new Offlineapp();
if ($offlineapp->hasWsnData($start))
{
@$dataservice->makeWsnData(array('uid'=>$row['userid'],'action'=>'prepare'));
}
$sql="select applicationform as pdflink from offlineapp where id=?";
@ -547,14 +563,14 @@ class Admin_DownController extends Zend_Controller_Action
//$this->_redirect('/admin/down/offlineapp/'.$page);
}
//如果是wsn数据则生成数据
//如果是wsn数据则生成数据
//wsn数据在ftp服务器端进行处理
/*$dataservice = new DataService();
@$dataservice->makeWsnData();*/
$sql="update dataorder set status=5,ts_approved=now() where offlineappid=?";
$this->db->query($sql,array($finish));
$sql="update offlineapp set ts_approved=now() where id=? and ts_approved is null";
$sql="update offlineapp set ts_approved=now(),status=5 where id=? and ts_approved is null";
$this->db->query($sql,array($finish));
$sql="select * from offlineapp where id=?";
$row=$this->db->fetchRow($sql,array($finish));
@ -1122,7 +1138,7 @@ class Admin_DownController extends Zend_Controller_Action
}
$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');
$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);

View File

@ -45,6 +45,12 @@ table thead tr th {background:#EBF2F6;}
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputYear">出版社/期刊</label>
<div class="controls">
<input type="text" name="publisher" id="inputYear" class="input-block-level" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputReference">引用方式(前台显示)</label>
<div class="controls">
@ -58,9 +64,15 @@ table thead tr th {background:#EBF2F6;}
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputBibtex">完整引用方式</label>
<label class="control-label" for="inputBibtex">ris</label>
<div class="controls">
<textarea name="bibtex" id="inputBibtex" class="input-block-level"><?= isset($this->data['bibtex']) ? $this->data['bibtex']:"" ?></textarea>
<textarea name="ris" id="inputBibtex" class="input-block-level"><?= isset($this->data['ris']) ? $this->data['ris']:"" ?></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputNote">备注</label>
<div class="controls">
<textarea name="note" id="inputNote" class="input-block-level"><?= isset($this->data['note']) ? $this->data['note']:"" ?></textarea>
</div>
</div>
<div class="control-group">

View File

@ -0,0 +1,105 @@
<?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,'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>
<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; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>文件名</th>
<th>状态</th>
<th width="140">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<td><?= $item['realname'] ?></td>
<td><?= empty($item['attid']) ? '<font color="#CC0000">未编辑</font>':"已编辑" ?></td>
<td>
<a class="file-editor" href="/admin/data/ref/ac/add/<?= empty($item['attid']) ? 'attid/'.$item['id'] : 'id/'.$item['refid']?>">编辑</a>
<a href="javascript:void(0);" onclick="file.delete(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<script>
$(document).ready(function(e) {
});
var file = {
delete : function(id){
if(confirm("是否确定删除?") == false)
{
return false;
}
$.ajax({
'type':"POST",
'url':'/admin/data/ref/ac/delete',
'data':'attid=' + id,
'success':function(data){
if(typeof(data) == 'undefined')
{
alert("数据源错误,请联系管理员");
return false;
}
if(!$.isEmptyObject(data.error))
{
alert(data.error);
return false;
}
$('#DataLine_'+id).fadeOut();
},
'timeout': 30000,
'error': function(){
alert('附件删除出错');
}
});
}
}
</script>

View File

@ -0,0 +1,120 @@
<?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{ ?>
<form class="form-horizontal" method="post">
<div class="control-group">
<label class="control-label" for="inputPassword">PDF</label>
<div class="controls">
<input type="file" name="Filedata" id="file_upload" />
<div id="uploadedFile"></div>
</div>
</div>
<div class="form-actions">
<a class="btn btn-primary" href="/admin/data/ref/ac/files">文件管理</a>
</div>
</form>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<script>
var _this = {
SessionID : '<?php echo session_id(); ?>'
};
var uploader;
var param;
param = {
"PHPSESSID" : _this.SessionID,
"multi" : 'yes'
};
$(function() {
$('#file_upload').uploadify({
'swf' : '/js/lib/uploadify/uploadify.swf',
'uploader' : '/admin/data/ref/ac/pdfupload',
'multi' : true,
'auto' : true,
'fileTypeExts' : '*.pdf',
'onUploadSuccess' : function(file, data, response) {
upload.onsuccess(file, data, response);
},
'onUploadStart' : function(file) {
$('#file_upload').uploadify('settings','formData',param);
}
});
});
var upload = {
onsuccess : function(file, data, response){
_data = $.parseJSON(data);
if(!$.isEmptyObject(_data.error))
{
alert(_data.error);
}else{
$('#uploadedFile').append(upload.makeFileHtml(_data));
}
},
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
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
+'</div>';
},
deleteFile : function(id){
$.ajax({
'type':"POST",
'url':'/admin/data/ref/ac/delete',
'data':'attid=' + id,
'success':function(data){
if(typeof(data) == 'undefined')
{
alert("数据源错误,请联系管理员");
return false;
}
if(!$.isEmptyObject(data.error))
{
alert(data.error);
return false;
}
},
'timeout': 30000,
'error': function(){
alert('附件删除出错');
}
});
}
};
</script>
<?php if(isset($this->data['attid']) && !empty($this->data['attid'])){ ?>
<input type="hidden" id="reference_file_content" value='<?= json_encode($this->data['file']) ?>' />
<script>
upload.onsuccess('',$('#reference_file_content').val(),"");
</script>
<?php } ?>

View File

@ -1,5 +1,6 @@
<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=="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>

View File

@ -24,6 +24,8 @@ table thead tr th {background:#EBF2F6;}
<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>
@ -39,8 +41,14 @@ table thead tr th {background:#EBF2F6;}
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>标题</th>
<th>年份</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=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>
<th width="140">操作</th>
</tr>
</thead>
@ -48,15 +56,29 @@ table thead tr th {background:#EBF2F6;}
<?php $autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<tr id="DataLine_<?= $item['id']?>">
<?php if(!empty($item['title']) || !empty($item['year'])) { ?>
<td><?= $item['title'] ?></td>
<td><?= $item['year'] ?></td>
<td>
<td rowspan="2">
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="2"><?= $item['reference'] ?></td>
</tr>
<?php } ?>
<?php if(empty($item['title']) && empty($item['year'])) { ?>
<td colspan="2"><?= $item['reference'] ?></td>
<td>
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
@ -67,96 +89,4 @@ table thead tr th {background:#EBF2F6;}
</div>
<!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/doi/ac/del"
}
$(document).ready(function(e) {
$('.verified_btn').click(function(e) {
$(this).ajaxmsg({
callback:function(){window.location.reload();}
});
});
});
(function( $ ){
$.fn.ajaxmsg = function( options ) {
var settings = $.extend( {
url:'',
callback : '',
}, options);
var methods = {
msg : function(id)
{
methods.submited();
},
creatWindow : function(content){
$.colorbox({
initialHeight: '0',
initialWidth: '0',
html: methods.dialog(content),
opacity: '0.3',
onComplete: function(){
$('.confirm_yes').click(function(e){
e.preventDefault();
if(typeof(settings.callback)=='function')
{
settings.callback();
}
$.colorbox.close();
});
$('.confirm_no').click(function(e){
e.preventDefault();
$.colorbox.close();
});
}
});
},
submited : function(){
$.ajax({
'type':"POST",
'url':settings.url,
'data':'',
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{alert(data.error);}
if(typeof(data.success)!='undefined')
{
methods.creatWindow(data.success);
}
}
else{
alert('出现错误,请稍候再试');
}
},
'timeout': 30000,
'error': function(){
alert('出现错误,请刷新后重试');
}
});
},
dialog : function(content){
HTML = '<div class=""><div class="modal-header"><h3>提示信息</h3></div>'
+ '<div class="modal-body"><div class=" span5">'+content+'</div></div>'
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">确定</a></div></div>';
return HTML;
}
}
this.each(function() {
settings.url = $(this).attr('rel');
if(settings.url == '')
{
alert('参数错误');
}
methods.msg();
});
};
})( jQuery );
</script>

View File

@ -56,7 +56,7 @@ foreach ($this->paginator as $item):
$i=0;
$u=$item['uuid'];
endif;
if ($i==0) echo '<div class="well"><h4>元数据:<a href="/data/'.$item['uuid'].'">'.$item['title'].'</a><a href="/admin/data/reference/add/1/uuid/'.$item['uuid'].'">添加</a></h4><ol>';
if ($i==0) echo '<div class="well"><h4>元数据:<a href="/data/'.$item['uuid'].'">'.$item['mdtitle'].'</a><a href="/admin/data/reference/add/1/uuid/'.$item['uuid'].'">添加</a></h4><ol>';
echo '<li>文献(<a href="/admin/data/reference/edit/'.$item['mdid'].'">编辑</a> <a href="/admin/data/reference/delete/'.$item['mdid'].'">删除</a> <a href="javascript:void(0);" class="order" rel="'.$item['mdid'].'" rev="'.$item['place'].'">排序</a>'.$item['place'].'. '.$item['reference'].'</li>';
endforeach;
echo '</ul>';

View File

@ -32,7 +32,7 @@
<a href="/admin/down/offlineapp/reset/-1" onclick="return confirm('是否重置该申请?')">重置1年前的所有未收到申请表的记录</a>
| <a href="/admin/down/offlineapp/status/4">已收到的申请</a>
| <a href="/admin/down/offlineapp/status/-1">已拒绝的申请</a>
| <a href="/admin/down/offlineapp">待处理的申请</a>
| <a href="/admin/down/offlineapp/ac/pending">待处理的申请</a>
| <a href="/admin/down/offline">已通过的申请(离线服务记录)</a>
<div class="search">
<form action="/admin/down/offlineapp" method="get">

View File

@ -10,9 +10,9 @@ if(!empty($this->pageTitle))
<div class="hero-unit">
<h2><?= $this->content ?><?php if(!empty($this->url)) echo ",系统正在为您跳转..."?></h2>
<?php if(!empty($this->url)) {?>
<?php if($this->url == -1) { ?>
<?php if(is_numeric($this->url)) { ?>
<a href="javascript:history.go(-1);">如果没有跳转请点击这样</a>
<script language="javascript">setTimeout("history.go(-1)",3000);</script>
<script language="javascript">setTimeout("history.go(<?= $this->url ?>)",3000);</script>
<?php }else {?>
<a href="<?= $this->url ?>">如果没有跳转请点击这样</a>
<script language="javascript">setTimeout("self.location='<?= $this->url?>'",3000);</script>

View File

@ -294,7 +294,7 @@ class AccountController extends Zend_Controller_Action
'controller' => $this->_request->getControllerName(),
'action' => $this->_request->getActionName(),
);
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity())
{
@ -306,7 +306,12 @@ class AccountController extends Zend_Controller_Action
if(($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login"))
{
$this->view->href = '/';
$this->view->href = $_SERVER['REQUEST_URI'];
}
if($tohref == "/account/login")
{
$this->view->href = $tohref = "/";
}
if(!empty($tohref))
@ -364,13 +369,12 @@ class AccountController extends Zend_Controller_Action
}
else
{
if(!empty($tohref))
{
view::Post($this,"登录成功,正在跳转",$tohref);
return true;
}
if($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login")
{
view::Post($this,"登录成功,正在跳转",'/');
@ -592,6 +596,7 @@ class AccountController extends Zend_Controller_Action
}
}
}
} //找回密码
}

View File

@ -24,8 +24,12 @@ class Dataorder
if ($statu==4)
$wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status=4) ";
elseif ($statu==-1)
$wheresql[] = " (o.pdflink is not null and o.status=-1)";
else
$wheresql[] = " (o.pdflink is not null and d.status=-1)";
elseif ($statu == 3)
$wheresql[] = " (o.applicationform is not null and d.status=3 ) ";
elseif ($statu == 5)
$wheresql[] = " (o.status=5) ";
else
$wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status in (3,4))";
if(!empty($q))

View File

@ -12,4 +12,10 @@ class Table
//数据申请
public $offlineapp = "offlineapp";
//Source
public $source = "source";
//元数据
public $metadata = "metadata";
}

View File

@ -131,9 +131,30 @@ class View extends \Zend_Controller_Plugin_Abstract
return $protocol."://".$_SERVER['SERVER_NAME'];
}
static function isXmlHttpRequest()
static function isXmlHttpRequest($ctl = NULL)
{
$zfhttp = new \Zend_Controller_Request_Http();
return $zfhttp->isXmlHttpRequest();
$request = new \Zend_Controller_Request_Http();
if($request->isXmlHttpRequest())
{
if(!empty($ctl))
{
$helper = new \Zend_Controller_Action_HelperBroker($ctl);
$helper->layout->disableLayout();
$helper->viewRenderer->setNoRender();
}
return true;
}else{
return false;
}
}
static function isUuid($uuid)
{
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
{
return false;
}else{
return true;
}
}
}

View File

@ -229,6 +229,14 @@ class Order
return $data;
}
$results = $this->events()->trigger('order.pdfNumCheck', $this, compact('uid'));
$data = $results->bottom();
if($data !== true)
{
return $data;
}
$results = $this->events()->trigger('order.onUpdate', $this, compact('formData','uid'));
$data = $results->bottom();
@ -259,6 +267,14 @@ class Order
return $data;
}
$results = $this->events()->trigger('order.pdfNumCheck', $this, compact('uid'));
$data = $results->bottom();
if($data !== true)
{
return $data;
}
$pdf = $this->pdfPrint($formData,$uid,true,true);
$returnid = true;
@ -385,7 +401,15 @@ class Order
$uid = $user->id;
$sql="update dataorder set status=3 where status=2 and userid=$uid and offlineappid=$offlineappid";
$results = $this->events()->trigger('order.pdfNumCheck', $this, compact('uid'));
$data = $results->bottom();
if($data !== true)
{
return $data;
}
$sql = "update dataorder set status=3 where status=2 and userid=$uid and offlineappid=$offlineappid";
if($this->db->exec($sql) < 0)
{
return "数据篮状态更新失败,请重试";
@ -399,7 +423,7 @@ class Order
$data = array(
"user" => empty($user->realname) ? $user->username : $user->realname,
"link"=> view::getHostLink() . '/admin/down/offlineapps/ac/view/offlineappid/'.$offlineappid
"link"=> view::getHostLink() . '/admin/down/offlineapp/ac/view/offlineappid/'.$offlineappid
);
$mail = new Mail();

View File

@ -45,6 +45,7 @@ class OrderListener implements \Zend_EventManager_ListenerAggregate
$events->attach('order.formcheck', array($PdfFormClass, 'checkPdfOrderField'), 100);
$PdfClass = new PdfOperate();
$events->attach('order.pdfNumCheck', array($PdfClass, 'checkPdfOrderNum'), 100);
$events->attach('order.onUpdate', array($PdfClass, 'updateUserInfo'), 100);
$events->attach('order.onSubmited', array($PdfClass, 'orderSubmited'), 100);
}

View File

@ -137,6 +137,27 @@ class PdfOperate implements \Order\listener\PdfEvents
return true;
}
//检查生成pdf的数量
public function checkPdfOrderNum(\Zend_EventManager_Event $e)
{
$uid = (int)$e->getParam('uid');
if(empty($uid))
{
$uid = view::User('id');
}
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=? and status=2 AND offlineappid=-1";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uid));
$inorder = $rs['datacount'];
if($inorder <= $this->config->download->max)
{
return true;
}else{
return "本次订单将使申请数量超过限制所以无法生成PDF请在数据篮-待提交订单中移除相应数据确保待提交的数据申请条数小于等于5条然后再重新生成。";
}
}
//发送邮件通知
public function sendEmail($formData,$pdf)
{

View File

@ -7,4 +7,5 @@ interface ReferenceEvent
public function processReferenceData(\Zend_EventManager_Event $e);
public function insertToReferenceTable(\Zend_EventManager_Event $e);
}

View File

@ -1,8 +1,11 @@
<?php
namespace Reference\Handler;
use Helpers\View as view;
use Helpers\dbh;
use \Helpers\View as view;
use \Helpers\dbh;
use \Helpers\Table;
use \Files\Files;
use \Reference\Reference;
//事件中存在的操作
class ReferenceHandler implements \Reference\Event\ReferenceEvent
@ -10,6 +13,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
private $db; //传入PDO对象误
private $config; //全局配置
public $table;
public $tbl_maillog = ""; //邮件日志表
function __construct($db = NULL)
@ -22,6 +26,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
}
$this->config = \Zend_Registry::get('config');
$this->table = new Table();
}
public function checkReferenceParam(\Zend_EventManager_Event $e)
@ -58,4 +63,27 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
return $data;
}
public function insertToReferenceTable(\Zend_EventManager_Event $e)
{
$att = $e->getParam('file_data');
$reference = new Reference();
$title = $reference->getReferenceTitleFromFilenName($att['realname']);
$data = array(
'title'=>$title,
'attid'=>$att['id'],
'reference'=>$title.'---'.date("Y-m-d H:i:s").".".microtime().rand()
);
$dbh = new dbh();
$cache_data = array();
$cache_data['ref_id'] = $dbh->insert($this->table->reference,$data,true);
$cache_data['ref_title'] = $title;
return $cache_data;
}
}

View File

@ -16,6 +16,7 @@ class ReferenceListener implements \Zend_EventManager_ListenerAggregate
$Handler = new ReferenceHandler();
$events->attach('submit.checkParam', array($Handler, 'checkReferenceParam'), 100);
$events->attach('submit.processData', array($Handler, 'processReferenceData'), 100);
$events->attach('upload.insertToReferenceTable', array($Handler, 'insertToReferenceTable'), 100);
}
public function detach(\Zend_EventManager_EventCollection $events)

View File

@ -13,6 +13,11 @@ class Reference
protected $events = NULL;
public $table;
public $keyword;
public $order;
public $sort = "DESC";
public $reftype;
function __construct($db = NULL,$mail = NULL)
{
@ -84,22 +89,23 @@ class Reference
{
$request = new \Zend_Controller_Request_Http();
$data = array(
'reference'=>$request->getParam('reference'),
'link'=>$request->getParam('link'),
'publisher'=>$request->getParam('publisher'),
'year' => $request->getParam('year'),
'title' => $request->getParam('title'),
'bibtex' => $request->getParam('bibtex'),
'attid' => $request->getParam('attid')
'reference' => trim($request->getParam('reference')),
'link' => trim($request->getParam('link')),
'publisher' => trim($request->getParam('publisher')),
'year' => (int)$request->getParam('year'),
'title' => trim($request->getParam('title')),
'ris' => trim($request->getParam('ris')),
'note' => trim($request->getParam('note')),
'attid' => (int)$request->getParam('attid')
);
return $data;
}
//上传文献PDF
public function uploadReferencePdf($file)
public function uploadReferencePdf($file,$autoread = false)
{
$files = new Files();
$file_info = $files->upload($file,'reference/',true);
$file_info = $files->upload($file,'literature/',true);
if(isset($file_info['error']) && !empty($file_info['error']))
{
@ -108,7 +114,7 @@ class Reference
$file_data = array(
'filename' => $file_info['file_url'],
'filetype' => 'reference',
'filetype' => 'literature',
'filedesc' => $file_info['file_mime'],
'userid' => view::User('id'),
'filesize' => $file_info['file_size'],
@ -118,12 +124,27 @@ class Reference
$dbh = new dbh();
$file_id = $dbh->insert($this->table->attachments,$file_data,true);
$file_data['id'] = $file_id;
if($autoread)
{
$params = compact('file_data');
$results = $this->events()->trigger('upload.insertToReferenceTable', $this, $params);
$cache_data = $results->bottom();
$file_data = array_merge($file_data,$cache_data);
}
return $file_data;
}
//通过文件名自动提取文章标题
public function getReferenceTitleFromFilenName($filename)
{
$file = new Files();
$title = str_replace( ".".$file->getFileTextExt($filename),"",$filename);
return $title;
}
//删除文献文件
public function deleteReferenceAttchment($attid)
{
@ -146,11 +167,64 @@ class Reference
//所有文献
public function fetchReferences()
{
$sql = "SELECT * FROM {$this->table->reference} ORDER BY id DESC";
$wheresql = array();
if(!empty($this->keyword))
{
$wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "{$this->table->reference}.title";
}else{
$order = "{$this->table->reference}.{$this->order}";
}
$sql = "SELECT {$this->table->reference}.* FROM
{$this->table->reference}
$wheresql
ORDER BY $order {$this->sort}";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
//获取专题数据的文献
public function fetchThemeReferences($code)
{
$wheresql = array();
$wheresql[] = " s.code='$code' ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "ref.year,ref.title";
}else{
$order = "ref.{$this->order} {$this->sort}";
}
$sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//单条文献的信息
public function getOneReferenceData($id)
{
@ -162,13 +236,119 @@ class Reference
$sql = "SELECT * FROM {$this->table->reference} WHERE id=$id LIMIT 1";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if ($row['attid'])
{
$files = new Files();
$attfile = $files->getOne($row['attid']);
$files = new Files();
$attfile = $files->getOne($row['attid']);
$row['file'] = $attfile;
$row['file'] = $attfile;
}
return $row;
}
//获得reference类型的附件
public function getReferenceFiles()
{
$sql = "SELECT att.*,ref.attid,ref.id as refid FROM {$this->table->attachments} att
LEFT JOIN {$this->table->reference} ref ON att.id=ref.attid
WHERE att.filetype='literature'";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//删除文献
public function deleteReference($id,$delete_att = false)
{
if(empty($id) || !is_numeric($id))
{
return false;
}
if($delete_att == false)
{
$sql = "DELETE FROM {$this->table->reference} WHERE id=$id";
return $this->db->exec($sql);
}else{
}
}
//建立文献与数据的关系
public function createRelationFromReferenceToData($refid,$uuid,$reftype,$place)
{
if(empty($refid) || is_numeric($refid))
{
return "参数错误";
}
if(!view::isUuid($uuid))
{
return "参数错误";
}
$data = array(
'uuid'=>$uuid,
'refid'=>$refid,
'reftype'=>$reftype,
'place'=>$place
);
$dbh = new dbh();
$id = $dbh->insert($this->table->metadata_reference,$data,true);
if(is_numeric($id))
{
return $id;
}else{
return "关系写入失败,请检查是否已经存在";
}
}
//获得某个文献关联的数据 (根据文献获得数据)
public function getDataByReference($id)
{
if(empty($id) || !is_numeric($id))
{
return "参数错误";
}
$sql = "SELECT mr.reftype,mr.place,md.title,md.uuid FROM {$this->table->metadata_reference} mr
LEFT JOIN {$this->table->metadata} md ON mr.uuid=md.uuid
WHERE mr.refid=$id";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//获得某个数据关联的文献 (根据数据获得文献)
public function getReferenceByData($uuid)
{
if(!view::isUuid($uuid))
{
return "参数错误";
}
$sql = "SELECT mr.reftype,mr.place,md.title,md.uuid FROM {$this->table->metadata_reference} mr
LEFT JOIN {$this->table->metadata} md
WHERE mr.uuid = $uuid";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//文献类型
public function referenceType()
{
return array(
1 => '作者文献',
2 => '施引文献',
3 => '参考文献',
4 => '多篇文献'
);
}
}
}