添加了文献排序功能和修改文献的功能
This commit is contained in:
parent
d7a7ad213e
commit
f3e7deaf02
|
@ -2574,41 +2574,97 @@ class AuthorController extends Zend_Controller_Action
|
|||
//文献管理
|
||||
function literatureAction()
|
||||
{
|
||||
$ac = $this->_request->getParam('ac');
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
$id = $this->_request->getParam('id');
|
||||
$ac = $this->_request->getParam('ac');
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
$id = $this->_request->getParam('id');
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
$u_id = $user->id;
|
||||
}
|
||||
|
||||
include_once("helper/view.php");
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
$author->Literature = new Literature($this->db);
|
||||
|
||||
//查看单条数据的所有文献
|
||||
if (!empty($uuid) && empty($ac))
|
||||
{
|
||||
$sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link FROM mdref mr
|
||||
LEFT JOIN metadata md ON md.uuid=mr.uuid
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
left join reference r on mr.refid=r.id
|
||||
WHERE md.title IS NOT NULL AND a.userid=? and mr.uuid=? AND a.status=1
|
||||
order by md.ts_created desc
|
||||
";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($u_id,$uuid));
|
||||
$rows = $sth->fetchAll();
|
||||
$rows = $author->Literature->byuuid($uuid);
|
||||
@$this->view->mdtitle=$rows[0]['title'];
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(15);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
view::addPaginator($rows,$this->view,$this->_request);
|
||||
$this->_helper->viewRenderer('literature-viewdata');
|
||||
}
|
||||
|
||||
//编辑单条文献
|
||||
if($ac == "edit")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$id = $this->_getParam('id');
|
||||
$content = $this->_getParam('content');
|
||||
|
||||
if(empty($id))
|
||||
{
|
||||
$this->jsonexit(array('error'=>'参数错误'));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($content))
|
||||
{
|
||||
$this->jsonexit(array('error'=>'请输入内容'));
|
||||
return true;
|
||||
}
|
||||
|
||||
$s = $author->Literature->edit($id,$content);
|
||||
if($s !== true)
|
||||
{
|
||||
$this->jsonexit(array('error'=>'出现错误'));
|
||||
return true;
|
||||
}else{
|
||||
$this->jsonexit(array('success'=>'修改成功!'));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//修改排序
|
||||
if($ac == "order")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$id = $this->_getParam('id');
|
||||
$order = (int)$this->_getParam('order');
|
||||
|
||||
if(empty($id))
|
||||
{
|
||||
$this->jsonexit(array('error'=>'参数错误'));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($order))
|
||||
{
|
||||
$this->jsonexit(array('error'=>'请输入排序数字,除0以外'));
|
||||
return true;
|
||||
}
|
||||
|
||||
$s = $author->Literature->order($id,$order);
|
||||
if($s !== true)
|
||||
{
|
||||
$this->jsonexit(array('error'=>'出现错误'));
|
||||
return true;
|
||||
}else{
|
||||
$this->jsonexit(array('success'=>'修改成功!'));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//查看单条文献的所有数据
|
||||
if (!empty($id) && empty($ac))
|
||||
{
|
||||
|
@ -2701,33 +2757,16 @@ class AuthorController extends Zend_Controller_Action
|
|||
//按数据浏览
|
||||
else if($ac=="bydata")
|
||||
{
|
||||
$keywords = $this->_request->getParam('q');
|
||||
if(!empty($keywords))
|
||||
$this->view->q = $keywords;
|
||||
$sql = "SELECT md.title,md.uuid,count(mr.id) as c FROM metadata md
|
||||
LEFT JOIN mdref mr ON md.uuid=mr.uuid
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
left join reference r on mr.refid=r.id
|
||||
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
|
||||
$keywords = $this->_request->getParam('q');
|
||||
if(!empty($keywords))
|
||||
{
|
||||
$search=new SimpleSearch($keywords);
|
||||
$where=$search->sql_expr(array("md.title","md.description"));
|
||||
$sql.=' and '.$where;
|
||||
$lit = $author->Literature->bydata($keywords);
|
||||
$this->view->q = $keywords;
|
||||
}else{
|
||||
$lit = $author->Literature->bydata();
|
||||
}
|
||||
$sql.=" group by md.uuid,md.title";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($u_id));
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
|
||||
view::addPaginator($lit,$this->view,$this->_request);
|
||||
$this->_helper->viewRenderer('literature-bydata');
|
||||
}
|
||||
|
||||
|
@ -4005,7 +4044,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
'title'=>$metadata['title'],
|
||||
'doi'=>$metadata['doi'],
|
||||
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
|
||||
'publisher'=>view::User('realname'),
|
||||
'publisher'=>'寒区旱区科学数据中心',
|
||||
);
|
||||
}else{
|
||||
$this->view->data['info'] = $doi->data_process_out($this->view->data);
|
||||
|
|
|
@ -3,6 +3,7 @@ $this->headTitle($this->config->title->site);
|
|||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->theme->AppendModel($this,"author-literature");
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
|
||||
|
@ -34,9 +35,12 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<li class="well" id="list_<?php echo $item['id'].$item['uuid'];?>">
|
||||
<p><?php echo $item['reference'];?>
|
||||
<p><?php echo $item['reference'];?></p>
|
||||
<p>
|
||||
【 <a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a>
|
||||
| <a onclick="return confirm('是否确定删除该版本?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
|
||||
| <a href="javascript:void(0);" class="edit" rel="<?= $item['id'];?>">编辑</a>
|
||||
| <a href="javascript:void(0);" class="order" rel="<?= $item['id'];?>" rev="<?= $item['place']?>">排序</a>
|
||||
| <a onclick="return confirm('是否确定删除该文献?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
|
||||
| <a href="/author/literature/ac/add/uuid/<?php echo $item['uuid'];?>" class="more iframe">添加文献</a>
|
||||
】</p>
|
||||
</li>
|
||||
|
@ -45,8 +49,6 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -49,7 +49,7 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<p><?php echo $item['reference'];?>
|
||||
【 <a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a>
|
||||
|
|
||||
<a onclick="return confirm('是否确定删除该版本?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
|
||||
<a onclick="return confirm('是否确定删除该文献?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
|
||||
】</p>
|
||||
</li>
|
||||
<?php endforeach;
|
||||
|
|
|
@ -158,5 +158,13 @@ class Theme
|
|||
|
||||
}// AppendPlus
|
||||
|
||||
//加载页面中的JS
|
||||
function AppendModel($render,$model)
|
||||
{
|
||||
|
||||
$model = trim($model);
|
||||
|
||||
$render->headScript()->appendFile("/js/lib/custom/models/".$model.".js");
|
||||
|
||||
}//
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
class Author extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
public $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
//使用到的公共变量
|
||||
|
@ -42,3 +42,81 @@ class Author extends Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Literature extends Author
|
||||
{
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
function byuuid($uuid){
|
||||
include_once("helper/view.php");
|
||||
$uid = view::User('id');
|
||||
$sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link,mr.place FROM mdref mr
|
||||
LEFT JOIN metadata md ON md.uuid=mr.uuid
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
left join reference r on mr.refid=r.id
|
||||
WHERE md.title IS NOT NULL AND a.userid=? and mr.uuid=? AND a.status=1
|
||||
order by mr.place ASC,r.id DESC,md.ts_created desc
|
||||
";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($uid,$uuid));
|
||||
$rows = $sth->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function edit($id,$content){
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
|
||||
$data = array(
|
||||
'reference' => $content
|
||||
);
|
||||
|
||||
$s = $dbh->update("reference",$data," id=$id ",false);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function order($id,$order){
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
|
||||
$data = array(
|
||||
'place' => $order
|
||||
);
|
||||
|
||||
$s = $dbh->update("mdref",$data," refid=$id ",false);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function bydata($keywords=""){
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
$uid = $user->id;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "SELECT md.title,md.uuid,count(mr.id) as c FROM metadata md
|
||||
LEFT JOIN mdref mr ON md.uuid=mr.uuid
|
||||
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
||||
left join reference r on mr.refid=r.id
|
||||
WHERE md.title IS NOT NULL AND a.userid=$uid AND a.status=1";
|
||||
if(!empty($keywords))
|
||||
{
|
||||
include_once('SimpleSearch.php');
|
||||
$search=new SimpleSearch($keywords);
|
||||
$where=$search->sql_expr(array("md.title","md.description"));
|
||||
$sql.=' and '.$where;
|
||||
}
|
||||
$sql.=" group by md.uuid,md.title";
|
||||
|
||||
$sth = $this->db->query($sql);
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
$(document).ready(function(e) {
|
||||
$('.edit').click(function(e) {
|
||||
$(this).litedit({'id':$(this).attr('rel')});
|
||||
});
|
||||
$('.order').click(function(e) {
|
||||
$(this).litorder({'id':$(this).attr('rel')});
|
||||
});
|
||||
});
|
||||
// JavaScript Document
|
||||
(function( $ ){
|
||||
|
||||
$.fn.litedit = function( options ) {
|
||||
|
||||
var settings = $.extend( {
|
||||
id:'',
|
||||
content : '',
|
||||
}, options);
|
||||
|
||||
var methods = {
|
||||
edit : function(id)
|
||||
{
|
||||
methods.creatWindow(id);
|
||||
},
|
||||
creatWindow : function(id){
|
||||
$.colorbox({
|
||||
initialHeight: '0',
|
||||
initialWidth: '0',
|
||||
html: methods.dialog,
|
||||
opacity: '0.3',
|
||||
onComplete: function(){
|
||||
$('.confirm_yes').click(function(e){
|
||||
e.preventDefault();
|
||||
methods.submited(id);
|
||||
$.colorbox.close();
|
||||
});
|
||||
$('.confirm_no').click(function(e){
|
||||
e.preventDefault();
|
||||
$.colorbox.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
submited : function(id){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/author/literature/',
|
||||
'data':'ac=edit&id='+id+'&content='+$('#content_input_area').val(),
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{alert(data.error);}
|
||||
if(typeof(data.success)!='undefined')
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert('出现错误,请稍候再试');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
alert('出现错误,请刷新后重试');
|
||||
}
|
||||
});
|
||||
},
|
||||
dialog : function(content){
|
||||
HTML = '<div class=""><div class="modal-header"><h3>修改文献</h3></div>'
|
||||
+ '<div class="modal-body"><textarea class="span8" id="content_input_area">'+settings.content+'</textarea></div>'
|
||||
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
|
||||
return HTML;
|
||||
}
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
if( settings.id == '')
|
||||
{
|
||||
alert('参数错误');
|
||||
}
|
||||
|
||||
settings.content = $(this).parent('p').prev('p').html();
|
||||
|
||||
methods.edit(settings.id);
|
||||
});
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.fn.litorder = function( options ) {
|
||||
|
||||
var settings = $.extend( {
|
||||
id:'',
|
||||
order : '',
|
||||
}, options);
|
||||
|
||||
var methods = {
|
||||
edit : function(id)
|
||||
{
|
||||
methods.creatWindow(id);
|
||||
},
|
||||
creatWindow : function(id){
|
||||
$.colorbox({
|
||||
initialHeight: '0',
|
||||
initialWidth: '0',
|
||||
html: methods.dialog,
|
||||
opacity: '0.3',
|
||||
onComplete: function(){
|
||||
$('.confirm_yes').click(function(e){
|
||||
e.preventDefault();
|
||||
methods.submited(id);
|
||||
$.colorbox.close();
|
||||
});
|
||||
$('.confirm_no').click(function(e){
|
||||
e.preventDefault();
|
||||
$.colorbox.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
submited : function(id){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/author/literature/',
|
||||
'data':'ac=order&id='+id+'&order='+$('#order_input').val(),
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{alert(data.error);}
|
||||
if(typeof(data.success)!='undefined')
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert('出现错误,请稍候再试');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
alert('出现错误,请刷新后重试');
|
||||
}
|
||||
});
|
||||
},
|
||||
dialog : function(content){
|
||||
HTML = '<div class=""><div class="modal-header"><h3>修改排序</h3></div>'
|
||||
+ '<div class="modal-body">数字越小排序越靠前<br />'
|
||||
+ '请输入排序数字<input type="text" id="order_input" value="'+settings.order+'"/></div>'
|
||||
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
|
||||
return HTML;
|
||||
}
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
if( settings.id == '')
|
||||
{
|
||||
alert('参数错误');
|
||||
}
|
||||
settings.order = $(this).attr('rev');
|
||||
methods.edit(settings.id);
|
||||
});
|
||||
|
||||
};
|
||||
})( jQuery );
|
Loading…
Reference in New Issue