From 7e4f79cd473ea004cc0a97fe053020ffb46f2878 Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 7 Nov 2013 11:24:49 +0000 Subject: [PATCH] merge heihedata branch from r4014 to r4031, and merge metadata-en database and chinese database with en schema. --- .../admin/controllers/DataController.php | 61 ++- .../admin/controllers/DownController.php | 18 +- .../views/scripts/data/attachmentsadd.phtml | 3 +- .../views/scripts/data/ref-mdref-form.phtml | 1 + .../admin/views/scripts/data/ref-nav.phtml | 5 +- .../views/scripts/data/ref-risoutput.phtml | 50 +++ .../admin/views/scripts/data/ref.phtml | 55 +-- .../admin/views/scripts/down/offline.phtml | 14 +- .../down/offlineapps-notreceived.phtml | 2 +- application/config.ini | 2 +- .../default/controllers/AccountController.php | 9 - .../default/controllers/DataController.php | 390 ++++++++---------- .../default/controllers/IndexController.php | 25 +- .../default/views/scripts/account/login.phtml | 22 +- .../default/views/scripts/water/view.phtml | 23 +- application/module/Helpers/Table.php | 7 + application/module/Helpers/dbh.php | 28 ++ application/module/Open/App.php | 162 +++++++- application/module/Open/Open.php | 70 ++-- .../module/Order/Event/ApplicationEvent.php | 7 + .../Order/Handler/ApplicationHandler.php | 36 ++ .../Order/Listener/ApplicationListener.php | 25 ++ .../{listener => Listener}/ManagerEvents.php | 2 +- .../ManagerListener.php | 4 +- .../{listener => Listener}/OrderEvents.php | 2 +- .../{listener => Listener}/OrderListener.php | 8 +- .../{listener => Listener}/PdfEvents.php | 2 +- .../{listener => Listener}/PdfFormEvents.php | 2 +- .../module/Order/Manager/Application.php | 66 +++ .../Order/{mount => Mount}/ManagerOperate.php | 4 +- .../Order/{mount => Mount}/OrderOperate.php | 8 +- .../module/Order/{mount => Mount}/PdfForm.php | 6 +- .../Order/{mount => Mount}/PdfOperate.php | 10 +- application/module/Order/Order.php | 8 +- .../module/Reference/Handler/RisHandler.php | 9 +- application/module/Reference/Reference.php | 82 +++- application/module/Reference/Ris.php | 30 +- application/module/Reference/RisOutput.php | 153 +++++++ 38 files changed, 1009 insertions(+), 402 deletions(-) create mode 100644 application/admin/views/scripts/data/ref-risoutput.phtml create mode 100644 application/module/Order/Event/ApplicationEvent.php create mode 100644 application/module/Order/Handler/ApplicationHandler.php create mode 100644 application/module/Order/Listener/ApplicationListener.php rename application/module/Order/{listener => Listener}/ManagerEvents.php (84%) rename application/module/Order/{listener => Listener}/ManagerListener.php (89%) rename application/module/Order/{listener => Listener}/OrderEvents.php (90%) rename application/module/Order/{listener => Listener}/OrderListener.php (88%) rename application/module/Order/{listener => Listener}/PdfEvents.php (86%) rename application/module/Order/{listener => Listener}/PdfFormEvents.php (83%) create mode 100644 application/module/Order/Manager/Application.php rename application/module/Order/{mount => Mount}/ManagerOperate.php (89%) rename application/module/Order/{mount => Mount}/OrderOperate.php (91%) rename application/module/Order/{mount => Mount}/PdfForm.php (90%) rename application/module/Order/{mount => Mount}/PdfOperate.php (93%) create mode 100644 application/module/Reference/RisOutput.php diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index ed9cf60e..b7675d6d 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -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 "
";
+				echo $risText;
+				echo "
"; + } + }//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() diff --git a/application/admin/controllers/DownController.php b/application/admin/controllers/DownController.php index b28592ff..f7d06304 100644 --- a/application/admin/controllers/DownController.php +++ b/application/admin/controllers/DownController.php @@ -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() diff --git a/application/admin/views/scripts/data/attachmentsadd.phtml b/application/admin/views/scripts/data/attachmentsadd.phtml index 5660ef70..3c7c33f4 100644 --- a/application/admin/views/scripts/data/attachmentsadd.phtml +++ b/application/admin/views/scripts/data/attachmentsadd.phtml @@ -28,7 +28,6 @@
-

@@ -71,7 +70,7 @@ var upload = { makeFileHtml : function(data){ return '
' + '' - + data.realname + + '' +data.realname + '' +'' +'
'; }, diff --git a/application/admin/views/scripts/data/ref-mdref-form.phtml b/application/admin/views/scripts/data/ref-mdref-form.phtml index 6721ff29..5905972c 100644 --- a/application/admin/views/scripts/data/ref-mdref-form.phtml +++ b/application/admin/views/scripts/data/ref-mdref-form.phtml @@ -15,6 +15,7 @@
+ 设为数据中心文献
diff --git a/application/admin/views/scripts/data/ref-nav.phtml b/application/admin/views/scripts/data/ref-nav.phtml index 85329fdd..c3406955 100644 --- a/application/admin/views/scripts/data/ref-nav.phtml +++ b/application/admin/views/scripts/data/ref-nav.phtml @@ -1,10 +1,11 @@ \ No newline at end of file diff --git a/application/admin/views/scripts/data/ref-risoutput.phtml b/application/admin/views/scripts/data/ref-risoutput.phtml new file mode 100644 index 00000000..d12726d0 --- /dev/null +++ b/application/admin/views/scripts/data/ref-risoutput.phtml @@ -0,0 +1,50 @@ +headTitle($this->config->title->site); +$this->headTitle('后台管理'); +$this->headTitle()->setSeparator(' - '); +$this->breadcrumb('首页'); +$this->breadcrumb('数据管理'); +$this->breadcrumb('文献管理'); +$this->breadcrumb()->setSeparator(' > '); +$this->theme->AppendPlus($this,'colorbox'); +$this->theme->AppendPlus($this,"uploadify"); +$this->theme->AppendPlus($this,'admin_plugin'); +?> + +
+
+ partial('data/left.phtml'); ?> +
+
+
+ partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?> +
+ error)) { ?> + error ?> + + msg)) { ?> + msg ?> + +

RIS导出

+
+ +
+ years)) { ?> + 按年份 : + years as $k=>$v){ ?> + () + +
+ +
+ +
+ 其它方式:全部 +
+ + +
+
+ \ No newline at end of file diff --git a/application/admin/views/scripts/data/ref.phtml b/application/admin/views/scripts/data/ref.phtml index b1298c2b..9670014e 100644 --- a/application/admin/views/scripts/data/ref.phtml +++ b/application/admin/views/scripts/data/ref.phtml @@ -37,6 +37,17 @@ table thead tr th {background:#EBF2F6;} msg)) { ?> msg ?> + + ac == 'westdc'){ ?> + + + + years)) { ?> + years as $k=>$v){ ?> + () + + +
paginator)): ?> @@ -45,8 +56,7 @@ table thead tr th {background:#EBF2F6;} - @@ -58,37 +68,36 @@ table thead tr th {background:#EBF2F6;} - page > 1) + { + $autoindex = ($this->page - 1) * $this->pagelimit; + }else{ + $autoindex=0; + } foreach ($this->paginator as $item): $autoindex++;?> - - - - + - - - - - - - - - - -
标题 - 年份 + 年份
+ []  + + {reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'未知作者'; ?>}  + {未知标题':$item['title'] ?>}  + {未知期刊':$item['publisher'] ?>}  + {未知年份':$item['year'] ?>}  + + + 编辑 RIS编辑 数据(+) 删除
- 编辑 - RIS编辑 - 数据 - 删除 -
diff --git a/application/admin/views/scripts/down/offline.phtml b/application/admin/views/scripts/down/offline.phtml index 12e44025..17bbb488 100644 --- a/application/admin/views/scripts/down/offline.phtml +++ b/application/admin/views/scripts/down/offline.phtml @@ -27,8 +27,20 @@
离线数据服务记录
-添加新的离线服务记录 | 下载所有离线服务记录 | 自动匹配离线下载用户与网站用户 | 下载服务用户邮箱列表 +添加新的离线服务记录 | 下载所有离线服务记录 | 自动匹配离线下载用户与网站用户 | 下载服务用户邮箱列表 | 下载上月服务记录(科技部上报) + +
+
+
+ + + + +
+
+
+ paginator)): ?> diff --git a/application/admin/views/scripts/down/offlineapps-notreceived.phtml b/application/admin/views/scripts/down/offlineapps-notreceived.phtml index c9e8f0b2..ca1f62eb 100644 --- a/application/admin/views/scripts/down/offlineapps-notreceived.phtml +++ b/application/admin/views/scripts/down/offlineapps-notreceived.phtml @@ -54,7 +54,7 @@ table thead tr th {background:#EBF2F6;color:#444;} diff --git a/application/config.ini b/application/config.ini index 42762c9c..239b5cdc 100755 --- a/application/config.ini +++ b/application/config.ini @@ -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 diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php index 40dd9b20..78487b85 100755 --- a/application/default/controllers/AccountController.php +++ b/application/default/controllers/AccountController.php @@ -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); diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index fb4354a2..f7d14005 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -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); diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index de4dec15..dc3ddb1a 100755 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -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_publisheddb->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(); diff --git a/application/default/views/scripts/account/login.phtml b/application/default/views/scripts/account/login.phtml index e53bd83d..963e4e81 100755 --- a/application/default/views/scripts/account/login.phtml +++ b/application/default/views/scripts/account/login.phtml @@ -1,9 +1,9 @@ headTitle($this->config->title->site); - $this->headTitle('用户登录'); + $this->headTitle('login'); $this->headTitle()->setSeparator(' - '); - $this->breadcrumb('首页'); - $this->breadcrumb('用户登录'); + $this->breadcrumb('Home'); + $this->breadcrumb('Login'); $this->breadcrumb()->setSeparator(' > '); ?> render('breadcrumbs.phtml'); ?> metadata;if ($md):?> -

escape($md->title); -if ($md->title_en) echo '
'.$this->escape($md->title_en);?> -

-
+

escape($md->title); + if ($md->title_en) echo '
'.$this->escape($md->title_en);?> +

+
@@ -36,18 +36,19 @@ if ($md->title_en) echo '
'.$this->escape($md->title_en);?>

- citation) : ?> + citation) : ?>

本数据引用方式数据引用帮助

datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 escape($md->citation);?>

- datadoi) && !strpos($md->citation,$md->datadoi)) : ?> -

数据的引用datadoi) && !strpos($md->citation,$md->datadoi)) : ?> +

数据的引用 + 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.']'; ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

- - ref) : ?> + ref) : ?>

相关文献(作者推荐)

    @@ -65,7 +66,7 @@ if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> endforeach; ?>
- themeref) :?> + themeref) :?>

专题文献

@@ -84,7 +85,7 @@ if ($md->title_en) echo '
'.$this->escape($md->title_en);?> endforeach; ?> - userref) : ?> + userref) : ?>

数据施引文献

    diff --git a/application/module/Helpers/Table.php b/application/module/Helpers/Table.php index 87ceade0..69256584 100644 --- a/application/module/Helpers/Table.php +++ b/application/module/Helpers/Table.php @@ -20,4 +20,11 @@ class Table //元数据 public $metadata = "metadata"; + + //会员 + public $member = "users"; + + //开放平台 + public $oauth_clients = "oauth_clients"; + public $oauth_access_tokens = "oauth_access_tokens"; } \ No newline at end of file diff --git a/application/module/Helpers/dbh.php b/application/module/Helpers/dbh.php index 83791cd1..b9f2e7a8 100644 --- a/application/module/Helpers/dbh.php +++ b/application/module/Helpers/dbh.php @@ -1,11 +1,15 @@ 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) diff --git a/application/module/Open/App.php b/application/module/Open/App.php index 23d3b377..a4da49a0 100644 --- a/application/module/Open/App.php +++ b/application/module/Open/App.php @@ -1,15 +1,72 @@ 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 } \ No newline at end of file diff --git a/application/module/Open/Open.php b/application/module/Open/Open.php index 8a6445df..29534eb9 100644 --- a/application/module/Open/Open.php +++ b/application/module/Open/Open.php @@ -1,26 +1,18 @@ 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; } } \ No newline at end of file diff --git a/application/module/Order/Event/ApplicationEvent.php b/application/module/Order/Event/ApplicationEvent.php new file mode 100644 index 00000000..b8031621 --- /dev/null +++ b/application/module/Order/Event/ApplicationEvent.php @@ -0,0 +1,7 @@ +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; + } + +} diff --git a/application/module/Order/Listener/ApplicationListener.php b/application/module/Order/Listener/ApplicationListener.php new file mode 100644 index 00000000..3bfa7c7b --- /dev/null +++ b/application/module/Order/Listener/ApplicationListener.php @@ -0,0 +1,25 @@ +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) + { + + } + +} \ No newline at end of file diff --git a/application/module/Order/listener/ManagerEvents.php b/application/module/Order/Listener/ManagerEvents.php similarity index 84% rename from application/module/Order/listener/ManagerEvents.php rename to application/module/Order/Listener/ManagerEvents.php index 2fedd65f..c3e370aa 100644 --- a/application/module/Order/listener/ManagerEvents.php +++ b/application/module/Order/Listener/ManagerEvents.php @@ -1,5 +1,5 @@ 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; + } +} \ No newline at end of file diff --git a/application/module/Order/mount/ManagerOperate.php b/application/module/Order/Mount/ManagerOperate.php similarity index 89% rename from application/module/Order/mount/ManagerOperate.php rename to application/module/Order/Mount/ManagerOperate.php index f2cb243d..b540321c 100644 --- a/application/module/Order/mount/ManagerOperate.php +++ b/application/module/Order/Mount/ManagerOperate.php @@ -1,5 +1,5 @@ getMessage()); + view::Dump($e->getMessage()); } return true; diff --git a/application/module/Order/mount/PdfForm.php b/application/module/Order/Mount/PdfForm.php similarity index 90% rename from application/module/Order/mount/PdfForm.php rename to application/module/Order/Mount/PdfForm.php index 5c83af22..52024d4a 100644 --- a/application/module/Order/mount/PdfForm.php +++ b/application/module/Order/Mount/PdfForm.php @@ -1,10 +1,10 @@ 0) { diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php index ca7abfd6..a38a9627 100644 --- a/application/module/Reference/Reference.php +++ b/application/module/Reference/Reference.php @@ -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; + } + } diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php index 3b891373..c9432ddd 100644 --- a/application/module/Reference/Ris.php +++ b/application/module/Reference/Ris.php @@ -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; } //卸载不需要的变量 diff --git a/application/module/Reference/RisOutput.php b/application/module/Reference/RisOutput.php new file mode 100644 index 00000000..44b7151f --- /dev/null +++ b/application/module/Reference/RisOutput.php @@ -0,0 +1,153 @@ +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 "
    "; + $arr[$this->attr_flip[$k]] = array(0=>$v); + } + } + } + //echo "
    "; + return $arr; + }//transformToRis + + //输出成文件 + public function output($risData) + { + $risWirte = new RISWriter(); + return @$risWirte->writeRecords($risData); + }//output +}
查看详细 接收 - 退回 + 退回 上传申请表 重置申请表