$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');
$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');
$state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=en.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=en.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 en.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");
$state=$this->db->query("select keyword,count(*) from en.keyword right join en.normalmetadata on keyword.id=en.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=en.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=en.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 en.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");
{$page=(int)$this->_request->getParam('page');if(empty($page))$page=1;$limit=30;$offset=$limit*($page-1);$state=$this->db->query('select count(*) from en.normalmetadata where datatype=0');$row=$state->fetchAll();$sum=$row[0]['count'];$select=$this->db->select();$select->from('en.normalmetadata','*')->where('datatype=0')->order('title')->limitPage($page,$limit);$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$limit);}
functionofflinelistAction()
{
$page=(int)$this->_request->getParam('page');
if(empty($page))$page=1;
$limit=30;
$offset=$limit*($page-1);
$state=$this->db->query('select count(*) from en.normalmetadata where datatype=1');
//展示最近20条离线神情记录情况
functionofflineappAction(){$sql="select * from offlineapp where ts_approved is not null and pdflink<>'' and status>=0 and uuid in (select uuid from en.metadata) order by ts_created desc limit 20";$this->view->rows=$this->db->fetchAll($sql);}
/*
* 数据浏览
*/functionbrowseAction(){$page=(int)$this->_request->getParam('page');if(empty($page))$page=1;$limit=10;$offset=$limit*($page-1);$state=$this->db->query('select count(*) from en.normalmetadata');$row=$state->fetchAll();$sum=$row[0]['count'];$select=$this->db->select();$select->from('en.normalmetadata','*')->order('id desc')->limitPage($page,$limit);$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$limit);}
functiontagAction(){$id=(int)$this->_request->getParam('id');$key=$this->_request->getParam('key');$keytype=$this->_request->getParam('keytype');$page=(int)$this->_request->getParam('page');if(empty($page))$page=1;$limit=10;$offset=$limit*($page-1);$sql='select keyword,count(*),keytype from en.keyword right join en.normalmetadata on keyword.id=en.normalmetadata.id ';if(!empty($keytype)&&($keytype=='place'||$keytype=='theme'||$keytype=='discipline'||$keytype=='temporal'))$sql.=" where keytype='".$keytype."'";$sql.=' group by keyword,keytype order by keytype,keyword,count desc';$state=$this->db->query($sql);$this->view->keywords=$state->fetchAll();
$this->view->codename=$key;$sql=$this->db->quoteInto('select count(m.id) from en.normalmetadata m,en.keyword k where m.id=k.id and k.keyword=?',$key);$state=$this->db->query($sql);$row=$state->fetchAll();$sum=$row[0]['count'];$select=$this->db->select();$select->from('en.normalmetadata','*')->join('en.keyword','en.normalmetadata.id=keyword.id')->where('keyword.keyword=?',$key)->order('en.normalmetadata.title')->limitPage($page,$limit);//$sql=$db->quoteInto('select m.* from metadata m,keyword k where m.id=k.id and k.keyword=?',$key);
//$state=$db->query($sql);
$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$limit);}}
$keyword=$this->_request->getParam('keyword');if(empty($id)){if(!empty($name)){$where=$this->db->quoteInto('name = ?',$name);$row=$this->db->fetchRow("select * from en.series where ".$where);}}else{$where=$this->db->quoteInto('id = ?',$id);$row=$this->db->fetchRow("select * from en.series where ".$where);}
$page=(int)$this->_request->getParam('page');if(empty($page))$page=1;$limit=10;$offset=$limit*($page-1);$state=$this->db->query('select s.id,name,count(*) from en.series s,en.dataseries d where d.sid=s.id group by s.id,s.name');$this->view->serie=$state->fetchAll();
if($id>0){//$where=$this->db->quoteInto('id = ?',$id);
//$row=$this->db->fetchRow("select * from series where ".$where);
$this->view->codename=$row['name'];if(!empty($keyword)){$sql='select count(m.id) as count from en.normalmetadata m,en.dataseries d,en.keyword k where m.id=d.id and m.id=k.id and d.sid=? and k.keyword=?';$row=$this->db->fetchAll($sql,array($id,$keyword));$this->view->codename.="[Tags: ".$keyword." ]";
}else{$sql='select count(m.id) as count from en.normalmetadata m,en.dataseries d where m.id=d.id and d.sid=?';$row=$this->db->fetchAll($sql,array($id));}$sum=$row[0]['count'];$select=$this->db->select();$select->from('en.normalmetadata','*')->join('en.dataseries','en.normalmetadata.id=dataseries.id')->where('dataseries.sid=?',$id)->order('en.normalmetadata.title')->limitPage($page,$limit);if(!empty($keyword))$select->join('keyword','keyword.id=en.normalmetadata.id')->where('keyword.keyword=?',$keyword);$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$limit);
$sql=$this->db->quoteInto("select keyword,count(*) as count from (select t.keyword,t.id from en.keyword t left join en.dataseries d on t.id=d.id where t.keytype='place' and d.sid=?) as f group by keyword order by count desc limit 30",$id);$state=$this->db->query($sql);$row=$state->fetchAll();$this->view->places=$row;$this->view->seriesid=$id;}else{//提供全部数据集序列列表
}}
/*
* 分类浏览模式
*/functioncategoryAction(){$page=$this->_request->getParam('page');$code=(int)$this->_request->getParam('code');$state=$this->db->query('select c.code,name,name_zh,count(*) from en.category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh');$this->view->category=$state->fetchAll();if($code>0&&$code<20){$where=$this->db->quoteInto('code = ?',$code);$row=$this->db->fetchRow("select * from categorycode where ".$where);$this->view->codename=$row['name'];$sql='select count(m.id) from en.normalmetadata m left join en.category c on m.id=c.id where c.code=?';$row=$this->db->fetchRow($sql,array($code));$sum=$row['count'];$select=$this->db->select();$select->from('en.normalmetadata as m','*')->joinLeft('en.category as c','m.id=c.id')->where('c.code=?',$code)->order('m.title')->limitPage($page,$this->limit);$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$this->limit);}else{//提供全部分类列表
}}
/*
* 时空动态浏览
*/functiontimemapAction(){$sql='select id,uuid,west,south,north,east,title,timebegin,timeend from en.normalmetadata where timebegin is not null';$this->view->rows=$this->db->fetchAll($sql);}
$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
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=1 and r.language<>'zh' order by r.year desc,r.ts_created desc limit 15";
$sql="select p.email,p.individual,p.organisation,r.role from en.role r left join en.responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id";
if(empty($uuid)){$this->view->AlertType="alert-error";$this->view->msg="Wrong Parameter.";$this->view->jump_url="/data";returntrue;}$this->view->projectType=array("Choose Funding type"=>"","National Funding"=>"National Funding","Thesis or Dissertation"=>"Thesis or Dissertation","Others"=>"Others",);$userid=Zend_Auth::getInstance()->getIdentity()->id;
if(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$datas['email'])){$this->view->error="Please correct your email";returntrue;}
if(mb_strlen($datas['project'],"utf-8")<8){$this->view->error="The content of the fund must large than 8 chars.";returntrue;}if(preg_match('/^\d+$/',$datas['project'])){$this->view->error="Please input the content of the fund.";returntrue;}
if($this->db->insert('onlineapp',$data)){$select="select id from onlineapp where userid='$userid' order by id desc";$re=$this->db->query($select);$row=$re->fetch();$this->view->AlertType="alert-success";$this->view->jump_url='/data/download/uuid/'.$uuid.'/onlineappid/'.$row['id'];$this->view->msg="You are successful submit your online data download information, just wait a moment to auto jump to the download url.<a href=\"".$this->view->jump_url."\"> Or click here to visit the download url.</a>";$msg="用户{$data['username']} 填写了在线数据申请表 <a href=\"/admin/down/online/show/{$row['id']}\">查看详细</a>";$title="用户 {$data['username']} 申请了在线下载数据";include_once("message.php");message::post($this->db,0,-1,$title,$msg);
returntrue;}else{$this->view->AlertType="alert-error";$this->view->error="Failure.";$this->view->info=$data;returntrue;}returntrue;}else{$testsql="select * from onlineapp where userid='$userid' and uuid='$uuid' order by id desc";$result=$this->db->query($testsql);$rows=$result->fetch();if(empty($rows['id'])){include_once("Users.php");$usr=newUsers($this->db);$this->view->info=$usr->getUserInfo($userid);returntrue;}else{$datas['realname']=$rows['username'];$datas['unit']=$rows['unit'];$datas['phone']=$rows['phone'];$datas['address']=$rows['address'];$datas['postcode']=$rows['postcode'];$datas['email']=$rows['email'];$datas['project']=$rows['project'];$datas['project_id']=$rows['project_id'];$datas['project_type']=$rows['project_type'];$datas['project_title']=$rows['project_title'];$datas['project_leader']=$rows['project_leader'];$this->view->info=$datas;returntrue;}}returntrue;}
/*
* 数据下载,根据UUID进行判断
* 一次只下载一个数据(一个元数据项)
*/functiondownloadAction(){$uuid=$this->_request->getParam('uuid');$onlineappid=$this->_request->getParam('onlineappid');$this->view->pageID="account-dataorder";if(empty($uuid))$this->_redirect('/data');$auth=Zend_Auth::getInstance();if($auth->hasIdentity()){$user=$auth->getIdentity();$userid=$user->id;}$testsql="select id,has_send_mail from onlineapp where userid='$userid' and uuid='$uuid' order by id desc";$result=$this->db->query($testsql);$rows=$result->fetch();$has_send_mail=$rows['has_send_mail'];
if(empty($rows['id'])){$this->_redirect('/data/'.$uuid);}else{$sql="select onlineappid,id from dataorder where status=0 and userid='$userid' and uuid='$uuid' order by id desc";$re=$this->db->query($sql);$row=$re->fetch();if(empty($row['onlineappid'])){$data=array('userid'=>$userid,'uuid'=>$uuid,'onlineappid'=>$onlineappid,'ts_approved'=>'now()',);try{$this->db->insert('dataorder',$data);}catch(Exception$e){}}else{$sql="update dataorder set onlineappid='$onlineappid',ts_approved=now() where id='{$row['id']}'";try{$this->db->exec($sql);}catch(Exception$e){}}}$sql=$this->db->quoteInto("select * from dataset o left join en.metadata m on o.uuid=m.uuid left join en.mdstatus s on m.uuid=s.uuid where s.status>4 and m.datatype=0 and m.uuid=?",$uuid);$data=$this->db->fetchRow($sql);$updateftp=$updateftp1=false;$this->view->md=$data;$this->view->userpass=md5('westdc'.rand(1000,9999));$this->view->ftptime=date('Y-m-d H:i:s',strtotime('+1 week'));$sql=$this->db->quoteInto("select * from ftpuser where userid=?",$userid);$row=$this->db->fetchRow($sql);$datacount=$row['datacount'];if($data['host']=='ftp.westgis.ac.cn'){//添加FTP帐号信息以及时间控制信息
$updateftp=true;$g6=newG6ftp();$g6->db=$this->db;//不进行判断,每个元数据中的下载地址都对应一个虚拟路径
$path[]=$data['path'];$this->view->username='westdc'.$userid;$uu=(object)array("id"=>$userid,"username"=>$this->view->username,"password"=>$this->view->userpass,"path"=>$path,"maxdata"=>$this->view->config->download->max,"time"=>$this->view->ftptime,"datacount"=>$datacount);if($g6->createuser($uu)){$this->view->userpass=$g6->pwd;$this->view->ftptime=$g6->time;}else{$this->messenger->addMessage('Error: You are downloading too much data now.');$this->_redirect('/data/order');}}elseif($data['host']=='ftp1.westgis.ac.cn'){//添加FTP1帐号信息以及时间控制信息
$proftp=newProftp();$proftp->db=$this->db;//proftp离线用户名和g6的用户名稍有不同
$this->view->username='westdc_'.$userid;$uu=(object)array("id"=>$userid,"username"=>$this->view->username,"password"=>$this->view->userpass,"host"=>'ftp1.westgis.ac.cn',"param"=>"onlineappid=".$onlineappid,"maxdata"=>$this->view->config->download->max,"time"=>$this->view->ftptime,"datacount"=>$datacount);if($proftp->createuser($uu)){$this->view->userpass=$proftp->pwd;$this->view->ftptime=$proftp->time;}}elseif($data['host']=='ftp2.westgis.ac.cn'){//添加FTP2帐号信息以及时间控制信息
$proftp=newPureftp();$proftp->db=$this->db;$this->view->username='westdc_'.$userid;$uu=(object)array("id"=>$userid,"username"=>$this->view->username,"password"=>$this->view->userpass,"host"=>'ftp2.westgis.ac.cn',"param"=>"onlineappid=".$onlineappid,"maxdata"=>$this->view->config->download->max,"time"=>$this->view->ftptime,"datacount"=>$datacount);if($proftp->createuser($uu)){$this->view->userpass=$proftp->pwd;$this->view->ftptime=$proftp->time;}}$ftpurl='ftp://'.$this->view->username.'@'.$data['host'];if($data['host']=='ftp.westgis.ac.cn')$ftpurl.=$data['path'];
//设置输出
//if ($updateftp || $updateftp1) $this->view->userpass=$password;
$this->view->ftpurl=$ftpurl;//更新下载记录
//todo: 尝试添加一个RULE:若有对应数据存在,则不插入( userid,uuid,status=0,ts_approved:null)
/*$sql="select * from dataorder where userid=? and uuid=? and status=0 and (ts_approved is null)";$u=$this->db->fetchRow($sql,array($userid,$uuid));
if(empty($u)){$sql="insert into dataorder (userid,uuid,ts_created) values(?,?,now())";$this->db->query($sql,array($userid,$uuid));}*/
if(!empty($ftpurl)&&!$has_send_mail){$data=array("uuid"=>$uuid,"title"=>$this->view->md['title']."(".$this->view->md['filesize']."MB)","user"=>$user->username,"ftpuser"=>$this->view->username,"ftppwd"=>$this->view->userpass,"ftptime"=>$this->view->ftptime,"ftpurl"=>$this->view->ftpurl,"note"=>$updateftp?'BTW: You need to enter the path mannually.':'');
$mailtp=newEmailText($this->db,'online-download-en',$data);$mail=newWestdcMailer($this->view->config->smtp);$mail->setBodyText($mailtp->getBody());$mail->setFrom($this->view->config->service->email,'CARD data service');$mail->addTo($user->email);$mail->setSubject($mailtp->getSubject());@$mail->send();
$sql="update onlineapp set has_send_mail=true where id=?";$sth=$this->db->prepare($sql);$sth->execute(array($onlineappid));}}
/*
* 离线申请(可以包括在线数据),在无数据参数时,则显示已有列表
*/functionorderAction(){$this->view->pageID="account-dataorder";$ac=$this->_request->getParam('ac');$uuid=$this->_request->getParam('uuid');$del=$this->_request->getParam('del');$apply=$this->_request->getParam('apply');$finish=$this->_request->getParam('finish');$cancel=$this->_request->getParam('cancel');$wsn=$this->_request->getParam('wsn');$pdf=$this->_request->getParam('pdf');$selections=$this->_request->getParam('data');//if (empty($uuid)) $this->_redirect('/data');
$userid=view::User('id');//添加到数据篮
if($uuid){//存在历史遗留问题,原来的数据并不能保证唯一
$order=newOrder();$state=$order->addOrder($uuid);if($state!==true){if(!is_array($state)){$this->view->msg=view::Msg('alert-error',$state);}else{$service_type=$order->serviceTypeTest($state['service_type']);if($service_type!==false){view::Post($this,$service_type,$state['service_url']."?href=".urlencode(view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid);}else{$this->view->msg=view::Msg('alert-error',"Error: could not add this dataset.");}}}else{$this->view->msg=view::Msg('alert-success',"Success! You can add more dataset or submit your application.");}if(empty($ac))$ac='offline1';}elseif($selections){if(empty($uuid)){$this->view->msg=view::Msg('alert-error',"Error: Wrong parameter.");}$order=newOrder();$state=$order->addOrder($uuid,$selections);if($state!==true){$this->view->msg=view::Msg('alert-error',$state);}else{$this->view->msg=view::Msg('alert-success',"Success! You can add more dataset or submit your application.");}if(empty($ac))$ac='offline1';}//删除申请
elseif($del){$order=newOrder();$state=$order->del($del);if($state!==true){$this->view->msg=view::Msg('alert-error',$state);}else{$this->view->msg=view::Msg('alert-success',"The order is canceled.");}$this->_redirect('/data/order');}//提交申请
elseif($apply){if($apply=="all"||!is_numeric($apply)){$apply=-1;}
$order=newOrder();$state=$order->apply($apply);if($state!==true){$this->view->msg=view::Msg('alert-error',$state);}else{$this->view->msg=view::Msg('alert-success',"Please click Submitting to generate your pdf Order.");}if(empty($ac))$ac='offline2';}//完成
elseif($finish){if($finish=='all'){$sql=$this->db->quoteInto("update dataorder set ts_approved=now() where status=0 and userid=?",$userid);$this->db->query($sql);$sql="update ftpuser set datacount=0 where userid=?";$this->db->query($sql,array($userid));}else{$sql="update dataorder set ts_approved=now() where status=0 and userid=? and id=?";$this->db->query($sql,array($userid,(int)$finish));$sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0";$this->db->query($sql,array($userid));}}elseif($wsn){$this->_helper->viewRenderer('order-wsn');returntrue;}
elseif($cancel){if($cancel=='all'){$sql=$this->db->quoteInto("update dataorder set ts_approved=now(),status=-1 where status=0 and userid=?",$userid);$this->db->query($sql);$sql="update ftpuser set datacount=0 where userid=?";$this->db->query($sql,array($userid));}else{$sql="update dataorder set ts_approved=now(),status=-1 where status in (0,1,2) and userid=? and id=?";$this->db->query($sql,array($userid,(int)$cancel));$sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0";$this->db->query($sql,array($userid));}if(empty($ac))$ac='offline2';}//生成PDF离线申请文件
elseif($pdf){//用户信息可以从SESSION中读取?离线申请信息
//$sql="select * from users where id=?";
$order=newOrder();$rows=$order->getOrderItemForPdf();$this->view->projectType=$order->projectType;if($rows){$this->_helper->viewRenderer('pdf');$this->view->data2=$rows;if($this->_request->isPost()){$this->view->formData=$formData=$this->_request->getPost();$datalist='';foreach($rowsas$i=>$row){$datalist.=($i+1).". ".$row['title'].";";}$formData['datalist']=$datalist;if(@$formData['save']){$order->setPdfData($rows);$s=$order->SaveOrder($formData);if($s!==true){$this->view->error=view::Msg('alert-error',$s);returntrue;}//不能修改顺序
$this->_helper->layout->disableLayout();$this->_helper->viewRenderer->setNoRender();returntrue;}elseif($formData['submit']){//生成PDF
$order->setPdfData($rows);$s=$order->SubmitOrder($formData);if($s!==true){$this->view->error=view::Msg('alert-error',$s);returntrue;}
$this->view->msg=view::Msg('alert-success','Message: Your offline order is submitted. Please <a href="/data/order/ac/offline3">upload your PDF with personal signature</a>.',0);if(empty($ac))$ac='offline3';}}else{$sql="select u.* from users u left join offlineapp o on u.id=o.userid where u.id=? ORDER BY o.id DESC";$row=$this->db->fetchRow($sql,array($userid));$this->view->formData=$row;}}else{$this->view->msg=view::Msg('alert-error',"Error: You have not submitted any order, or you need to wait the auditing.",0);}returntrue;}//pdf
if($ac=="commitapplicationform"){$offlineappid=$this->_getParam('offlineappid');if(!is_numeric($offlineappid)||$offlineappid<1){view::Post($this,"Wrong parameter",-1);returntrue;}$order=newOrder();$status=$order->commitApplicationForm($offlineappid);if($status!==true){view::Post($this,$status,-1);}else{view::Post($this,"Your order has submitted, please wait CARD receive your order.",'/data/order/ac/offline3');}returntrue;}
//显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载
$sql="select d.*,m.title,m.datatype,off.applicationform from dataorder d
right join en.metadata m on d.uuid=m.uuid
left join offlineapp off ON off.id = d.offlineappid
where d.userid=? order by d.status,d.ts_created desc";$rows=$this->db->fetchAll($sql,array($userid));$showorders=array();$counts=array('onlineapp'=>0,'offline1'=>0,'offline2'=>0,'offline3'=>0,'offline4'=>0);if(count($rows)>0){foreach($rowsas$k=>$v){switch($v['status']){case0:$counts['onlineapp']++;break;case1:$counts['offline1']++;break;case2:$counts['offline2']++;break;case3:$counts['offline3']++;break;case4:$counts['offline3']++;break;case5:$counts['offline4']++;break;}
/*
* 查看数据缩略图
*/functionthumbAction(){$page=(int)$this->_request->getParam('page');if(empty($page))$page=1;$offset=$this->limit*($page-1);$state=$this->db->query("select count(*) from en.normalmetadata");$row=$state->fetchAll();$sum=$row[0]['count'];$select=$this->db->select();$select->from('en.normalmetadata as m','m.*')->order('m.title desc')->limitPage($page,9);$this->view->metadata=$this->db->fetchAll($select);$this->view->page=newPagination($sum,$page,$this->limit);}
functionorganizationAction(){$page=$this->_request->getParam('page');$name=$this->_request->getParam('name');$state=$this->db->query("select distinct responsible.organisation from en.responsible left join en.role on role.resid=responsible.id where role.role in ('pointOfContact','resourceProvider','owner')");$this->view->organisation=$state->fetchAll();if(!empty($name)){$this->view->codename=$name;$sql="select distinct m.* from en.normalmetadata m left join en.role r on m.uuid=r.uuid left join en.responsible s on r.resid=s.id where r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";$sth=$this->db->prepare($sql);$sth->execute(array($name));$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;}else{//提供全部分类列表
}}
functionfundAction(){$id=(int)$this->_request->getParam('id');if(!empty($id)){$sql="select * from fund where id=?";$this->view->fund=$this->db->fetchRow($sql,array($id));if($this->view->fund){$sql="select distinct m.* from en.normalmetadata m left join mdfund mf on m.uuid=mf.uuid where mf.fid=?";$sth=$this->db->prepare($sql);$sth->execute(array($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;}}else{//提供全部分类列表
$sql="select f.id,f.title_en,f.fund_id,f.fund_type_en,f.ts_created,count(m.id) as datacount,sum(md.filesize) as filesize
//实现基于DOI信息的浏览
functiondoiAction(){$ac=$this->_request->getParam('ac');if($ac=='unready'){//列出没有DOI的数据
$sql="select m.* from en.normalmetadata m where length(m.doi)<3 and m.uuid not in (select uuid from datadoi) order by m.ts_created desc";$this->view->pageID='doi-unready';}elseif($ac=='prepare'){//列出有DOI但还未进行提交申请的数据
$sql="select m.* from en.normalmetadata m where length(m.doi)>3 and m.uuid not in (select uuid from datadoi) order by m.ts_created desc";$this->view->pageID='doi-prepare';}elseif($ac=='unsubmit'){
//列出有DOI并计划提交申请的数据
$sql="select m.*,d.doi as datadoi,date(d.ts_created) as ts_created from en.normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_created is not null and d.ts_submitted is null order by d.ts_created desc";$this->view->pageID='doi-unsubmit';}elseif($ac=='submit'){//列出有DOI并计划提交申请的数据
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted from en.normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_submitted is not null and d.ts_published is null order by d.ts_submitted desc,d.ts_created desc";$this->view->pageID='doi-submit';}elseif($ac=='publish'||empty($ac)){//默认:列出最新发布的DOI数据
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted,date(d.ts_published) as ts_published from en.normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_published is not null order by d.ts_published desc,d.ts_submitted desc,d.ts_created desc";$this->view->pageID='doi-publish';}$sth=$this->db->prepare($sql);$sth->execute();$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->view->pageID='author-verified';$this->view->ac='verified';if($id){//列出作者的数据
$sql="select username,realname from users where id=?";$this->view->author=$this->db->fetchRow($sql,array($id));$sql="select m.* from en.normalmetadata m left join mdauthor a on a.uuid=m.uuid where a.userid=?";$sth=$this->db->prepare($sql);$sth->execute(array($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;}else{//已经认证过的数据作者
$sql="select u.username,u.realname,u.id,count(u.id) as count from mdauthor a left join users u on a.userid=u.id
$sql="select m.uuid,m.title,m.citation,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year from en.normalmetadata m