diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index 4c5a3886..00c05243 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -1875,8 +1875,277 @@ class AuthorController extends Zend_Controller_Action $this->_helper->viewRenderer('newdata-add'); } } - - + + //文献管理 + function literatureAction() + { + $ac = $this->_request->getParam('ac'); + $uuid = $this->_request->getParam('uuid'); + $id = $this->_request->getParam('id'); + + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $u_id = $user->id; + } + + //查看单条数据的所有文献 + 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(); + @$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; + $this->_helper->viewRenderer('literature-viewdata'); + } + + //查看单条文献的所有数据 + if (!empty($id) && empty($ac)) + { + $sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link,(a.userid-?) as isauthor 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 mr.refid=? AND a.status=1 + order by md.ts_created desc + "; + $sth = $this->db->prepare($sql); + $sth->execute(array($u_id,$id)); + $rows = $sth->fetchAll(); + @$this->view->mdtitle=$rows[0]['reference']; + + $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; + $this->_helper->viewRenderer('literature-viewliter'); + } + + //查看所有文献列表 + else if((empty($ac) && empty($uuid)) && empty($id)) + { + $keywords = $this->_request->getParam('q'); + $sql = "SELECT md.title,md.uuid,r.reference,r.id,mr.id as mrid 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 a.status=1"; + if(!empty($keywords)) + $this->view->q = $keywords; + if(!empty($keywords)) + { + $search=new Search($keywords); + $where=$search->sql_expr(array("r.reference","md.title","md.description")); + $sql.=' and '.$where; + } + $sql.=" order by md.ts_created desc"; + $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(15); + $paginator->setView($this->view); + Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); + $this->view->paginator=$paginator; + } + + //按文献浏览 + else if($ac=="byliter") + { + $keywords = $this->_request->getParam('q'); + if(!empty($keywords)) + $this->view->q = $keywords; + $sql = "SELECT count(md.uuid) as c,r.reference,r.id FROM reference r + left join mdref mr on r.id=mr.refid + LEFT JOIN metadata md ON md.uuid=mr.uuid + LEFT JOIN mdauthor a ON md.uuid=a.uuid + + WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1"; + if(!empty($keywords)) + { + $search=new Search($keywords); + $where=$search->sql_expr(array("r.reference")); + $sql.=' and '.$where; + } + $sql.=" group by r.reference,r.id"; + + $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; + + $this->_helper->viewRenderer('literature-byliter'); + } + + //按数据浏览 + 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"; + if(!empty($keywords)) + { + $search=new Search($keywords); + $where=$search->sql_expr(array("md.title","md.description")); + $sql.=' and '.$where; + } + $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; + + $this->_helper->viewRenderer('literature-bydata'); + } + + //添加文献信息 + else if($ac == "add") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $data = ""; + try{ + $uuid = $this->_request->getParam('uuid'); + $ref=$this->_request->getParam('ref'); + $reftype=$this->_request->getParam('reftype'); + if(empty($uuid) || empty($ref) || !is_numeric($reftype)) + { + $data = array("error"=>"参数错误"); + $this->jsonexit($data); + return true; + } + + $sql="select * from mdauthor where userid=? and uuid=? and status=1"; + $sth = $this->db->prepare($sql); + $sth->execute(array($u_id,$uuid)); + $row = $sth->fetch(); + if (empty($row)) + { + $data = array("error"=>$this->alertbox('warning','您不是该数据作者,无法添加对应文献信息。')); + $this->jsonexit($data); + return true; + } + + $sql="select id from reference where reference=?"; + $sth = $this->db->prepare($sql); + $sth->execute(array($ref)); + $row = $sth->fetch(); + if (!$row) + { + $sql="insert into reference (reference,link) values(?,?)"; + $sth = $this->db->prepare($sql); + $sth->execute(array(trim($ref),'')); + $sql="select id from reference where reference=?"; + $sth = $this->db->prepare($sql); + $sth->execute(array(trim($ref))); + $row = $sth->fetch(); + } + $sql="insert into mdref (uuid,refid,reftype) values(?,?,?)"; + $sth = $this->db->prepare($sql); + $ex=$sth->execute(array($uuid,$row['id'],$reftype)); + + if($ex) + { + $data = array("commited"=>1,"error"=>$this->alertbox('ok','成功添加文献!')); + $this->jsonexit($data); + return true; + }else{ + $data = array("error"=>$this->alertbox('error','提交失败,请确认权限后重试')); + $this->jsonexit($data); + return true; + } + }catch(Exception $e) { + $msg = "提交失败,请确认权限后重试"; + if($this->debug>0) + {$msg .= $e->getMessage();} + $data = array("error"=>$this->alertbox('error',$msg)); + $this->jsonexit($data); + return true; + } + }//添加文献 + + //删除某个文献 + else if($ac=="delete") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $data = ""; + + $id = $this->_request->getParam('id'); + $uuid = $this->_request->getParam('uuid'); + if(empty($uuid) || !is_numeric($id)) + { + $data = array("error"=>"参数错误"); + $this->jsonexit($data); + return true; + } + try{ + $sql = "DELETE FROM mdref r + USING mdauthor a + WHERE r.uuid=a.uuid and r.refid=? and r.uuid=? AND a.userid=? AND a.status=1"; + $sth = $this->db->prepare($sql); + $ex = $sth -> execute(array($id,$uuid,$u_id)); + + if($ex) + { + $data = array("deleted"=>$id.$uuid,"error"=>$this->alertbox('ok','删除成功')); + $this->jsonexit($data); + return true; + }else{ + $data = array("error"=>$this->alertbox('error','删除失败,请确认权限后重试')); + $this->jsonexit($data); + return true; + } + }catch(Exception $e) { + $msg = "删除失败,请确认权限后重试"; + if($this->debug>0) + {$msg .= $e->getMessage();} + $data = array("error"=>$this->alertbox('error',$msg)); + $this->jsonexit($data); + return true; + } + } + } //成为作者后的后继处理工作 private function author_first($uuid,$author) diff --git a/application/default/views/scripts/author/literature-bydata.phtml b/application/default/views/scripts/author/literature-bydata.phtml new file mode 100644 index 00000000..0163967e --- /dev/null +++ b/application/default/views/scripts/author/literature-bydata.phtml @@ -0,0 +1,104 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->headLink()->appendStylesheet('/css/colorbox.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('数据文献管理'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+

请输入元数据标题关键字进行搜索

+
+ + +
+
+ paginator)): + echo "
+
+ + + \ No newline at end of file diff --git a/application/default/views/scripts/author/literature-byliter.phtml b/application/default/views/scripts/author/literature-byliter.phtml new file mode 100644 index 00000000..1f85d4dd --- /dev/null +++ b/application/default/views/scripts/author/literature-byliter.phtml @@ -0,0 +1,55 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('数据文献管理'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+

请输入文献关键字进行搜索

+
+ + +
+
+ paginator)): + echo "
+
+ + \ No newline at end of file diff --git a/application/default/views/scripts/author/literature-viewdata.phtml b/application/default/views/scripts/author/literature-viewdata.phtml new file mode 100644 index 00000000..c509f689 --- /dev/null +++ b/application/default/views/scripts/author/literature-viewdata.phtml @@ -0,0 +1,102 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->headLink()->appendStylesheet('/css/colorbox.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('数据文献管理'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+ +
+ paginator)): + if ($this->mdtitle) echo "

元数据:".$this->mdtitle."

"; + echo "
+
+ + + \ No newline at end of file diff --git a/application/default/views/scripts/author/literature-viewliter.phtml b/application/default/views/scripts/author/literature-viewliter.phtml new file mode 100644 index 00000000..1aa26b40 --- /dev/null +++ b/application/default/views/scripts/author/literature-viewliter.phtml @@ -0,0 +1,104 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->headLink()->appendStylesheet('/css/colorbox.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('数据文献管理'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+ +
+ paginator)): + if ($this->mdtitle) echo "

文献:".$this->mdtitle."

"; + echo "
+
+ + + \ No newline at end of file diff --git a/application/default/views/scripts/author/literature.phtml b/application/default/views/scripts/author/literature.phtml new file mode 100644 index 00000000..0e00f2e4 --- /dev/null +++ b/application/default/views/scripts/author/literature.phtml @@ -0,0 +1,110 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->headLink()->appendStylesheet('/css/colorbox.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('数据文献管理'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+

请输入元数据或文献标题关键字进行搜索

+
+ + +
+
+ paginator)): + echo "
+
+ + + \ No newline at end of file