添加了文献排序功能和修改文献的功能

This commit is contained in:
Li Jianxuan 2013-05-06 09:01:14 +00:00
parent d7a7ad213e
commit f3e7deaf02
6 changed files with 4472 additions and 4178 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author); $this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendModel($this,"author-literature");
$this->headLink()->appendStylesheet('/css/author.css'); $this->headLink()->appendStylesheet('/css/author.css');
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js'); $this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.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): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<li class="well" id="list_<?php echo $item['id'].$item['uuid'];?>"> <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 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> | <a href="/author/literature/ac/add/uuid/<?php echo $item['uuid'];?>" class="more iframe">添加文献</a>
</p> </p>
</li> </li>
@ -45,8 +49,6 @@ $this->breadcrumb()->setSeparator(' > ');
endif; ?> endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div> <div class="pagenavi"><?= $this->paginator; ?></div>
</div> </div>
</div> </div>
</div> </div>
<script> <script>

View File

@ -49,7 +49,7 @@ $this->breadcrumb()->setSeparator(' > ');
<p><?php echo $item['reference'];?> <p><?php echo $item['reference'];?>
<a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a> <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> </p>
</li> </li>
<?php endforeach; <?php endforeach;

View File

@ -158,5 +158,13 @@ class Theme
}// AppendPlus }// AppendPlus
//加载页面中的JS
function AppendModel($render,$model)
{
$model = trim($model);
$render->headScript()->appendFile("/js/lib/custom/models/".$model.".js");
}//
} }

View File

@ -1,44 +1,122 @@
<?php <?php
class Author extends Zend_Controller_Plugin_Abstract class Author extends Zend_Controller_Plugin_Abstract
{ {
private $db; //传入PDO对象. public $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象 private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量 //使用到的公共变量
public $tbl_metadata = "metadata"; //元数据 public $tbl_metadata = "metadata"; //元数据
public $tbl_author = "mdauthor"; //数据作者表 public $tbl_author = "mdauthor"; //数据作者表
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
//检查前台用户对某条数据的权限 //检查前台用户对某条数据的权限
function checkAuthor($uuid,$uid=0) function checkAuthor($uuid,$uid=0)
{ {
if(empty($uid)) if(empty($uid))
{ {
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
if($auth->hasIdentity()) if($auth->hasIdentity())
{ {
$user = $auth->getIdentity(); $user = $auth->getIdentity();
$uid = $user->id; $uid = $user->id;
} }
} }
if(!empty($uid)) if(!empty($uid))
{ {
$sql = "SELECT * FROM ".$this->tbl_author." WHERE uuid='$uuid' AND userid=$uid"; $sql = "SELECT * FROM ".$this->tbl_author." WHERE uuid='$uuid' AND userid=$uid";
}else{ }else{
return false; return false;
} }
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(PDO::FETCH_BOTH); $row = $rs->fetch(PDO::FETCH_BOTH);
if($row['status']>0) if($row['status']>0)
{ {
return true; return true;
}else{ }else{
return false; return false;
} }
} }
} }
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;
}
}

View File

@ -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 );