remove docAction in DataController, add doiAction, add doi view

This commit is contained in:
wlx 2013-05-12 10:30:30 +00:00
parent 4079de5c22
commit 8162580014
2 changed files with 97 additions and 90 deletions

View File

@ -1851,95 +1851,7 @@ class DataController extends Zend_Controller_Action
}
}
/*
* 转换元数据为WORD DOC格式
*/
public function docAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid=$this->_request->getParam('uuid');
$review=$this->_request->getParam('review');
if (!empty($uuid))
{
$sql="select x.data,m.title,m.description,g.id,m.projection from xml x left join metadata m on m.id=x.id left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid);
$row=$this->db->fetchRow($sql);
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?";
$sql=$this->db->quoteInto($sql,$uuid);
$ref=$this->db->fetchAll($sql);
$reference='<ol>';
foreach($ref as $refer)
{
$reference.='<li>'.$refer['reference'].'</li>';
}
$reference.='</ol>';
if (is_numeric($row['projection']))
{
$sql="select proj4text from spatial_ref_sys where auth_srid=?";
$rs=$this->db->fetchRow($sql,array($row['projection']));
if ($rs) $projection=$rs['proj4text'];
}
if (empty($projection)) $projection=$row['projection'];
} else
$projection='';
$dom = new DOMDocument();
$dom->loadXML($row['data']);
//提前对表格进行预处理
$wiki=new WikiFormat();
$abs=$wiki->parseTable($this->view->escape($row["description"]));
//处理外部链接
$abs=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$abs);
$abs=str_replace(array("\r\n", "\n", "\r"),'</p><p>',$abs);
$abs=str_replace("'","&apos;",$abs);//not needed?
$id = $row['id'];
$thumburl=sprintf('%05d',floor(($id+0.1)/100)*100).'-'.sprintf('%05d',ceil(($id+0.1)/100)*100-1)."/".$id;
$xslt = new XSLTProcessor();
$xslt->registerPHPFunctions();
$xslt->setParameter('', 'thumburl', $thumburl);
$xslt->setParameter('', 'abstract', $abs);
$xslt->setParameter('','projection',$projection);
$xslt->setParameter('','reference',$reference);
$XSL = new DOMDocument();
$XSL->load( '../data/doc.xsl', LIBXML_NOCDATA);
$xslt->importStylesheet($XSL);
$content='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
$content.='<title>'.$row['title'].'</title>';
$content.='<style>
body{MARGIN-RIGHT: auto;MARGIN-LEFT: auto;font-size:14px;line-height:22px;font-family:宋体,Arial;}
span{font-size:14px;}
div{clear: both;margin: 0 auto;width:100%;vertical-align:baseline;}
#uuid{text-align: right;}
h3{font-size: 18px;}
img {border:0 none;}
a, a:visited {color:Blue;text-decoration:none;}
a:hover{text-decoration:underline;}
ul{list-style: none;margin: 0;}
ul li{list-style:none;}
#etitle{font-size:16px;margin-left:10px;}
span{font-weight:bolder;}
#content{padding:5px 0 10px 0;border:1px solid #BF5008;}
#divFooter {background-color:#BF5008;color:White;font-size:12px;padding:5px 15px;}
#divFooter a:link, #divFooter a:visited, #divFooter a:active {color:White;font-family:Arial,Serif;text-decoration:none;}
</style>
</head>
<body>';
$content.=$xslt->transformToXML($dom);
if ($review==1) $content.=file_get_contents('../data/review-table.htm',true);
$content.="</body></html>";
$this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
->setHeader('Content-Disposition','attachment; filename="'.$row['title'].'.doc"')
->setHeader('Content-Length', strlen($content))
->setHeader('Content-Type','application/force-download')
->setHeader('Content-Type','application/download')
->setHeader('Content-Description','File Transfer')
->setHeader('Content-Transfer-Encoding','binary')
->setHeader('Expires',0)
->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
->setHeader('Pragma','public')
->setBody($content);
}
public function jsonexit($data){
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
@ -1999,6 +1911,43 @@ class DataController extends Zend_Controller_Action
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('fund-list');
}
}
}
//实现基于DOI信息的浏览
function doiAction()
{
$ac = $this->_request->getParam('ac');
if ($ac=='unready') {
//列出没有DOI的数据
$sql="select m.* from 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';
} else if ($ac=='prepare') {
//列出有DOI但还未进行提交申请的数据
$sql="select m.* from 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';
} else if ($ac=='unsubmit') {
//列出有DOI并计划提交申请的数据
$sql="select m.*,d.doi as datadoi,date(d.ts_created) as ts_created from 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';
} else if ($ac=='submit') {
//列出有DOI并计划提交申请的数据
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted from 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';
} else if ($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 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;
}
}

View File

@ -0,0 +1,58 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle('支持项目');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
$this->breadcrumb('<a href="/data/doi">DOI浏览</a>');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
?>
<div id='row-fluid'>
<div><?= $this->breadcrumb() ?> </div>
<?= $this->partial('data/tools.phtml'); ?>
<ul class="nav nav-tabs">
<li id="Nav-doi-publish"><a href="/data/doi">已发布DOI的数据</a></li>
<li id="Nav-doi-submit"><a href="/data/doi/ac/submit">已提交DOI申请的数据</a></li>
<li id="Nav-doi-unsubmit"><a href="/data/doi/ac/unsubmit">未提交DOI申请的数据</a></li>
<li id="Nav-doi-prepare"><a href="/data/doi/ac/prepare">准备申请DOI的数据</a></li>
<li id="Nav-doi-unready"><a href="/data/doi/ac/unready">无DOI的数据</a></li>
</ul>
</div>
<?php if (!empty($this->paginator)) : ?>
<hr />
<div class="pagenavi"><?= $this->paginator; ?></div>
<?php foreach($this->paginator as $md) : ?>
<div class="media well well-small">
<a class="pull-left colorbox" href="/service/bigthumb/uuid/<?php echo $md['uuid']; ?>">
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/data/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<?php if (@$md['datadoi']) : ?>
<h4 class="media-heading">DOI:<?php echo $md['datadoi'];?>
<?php if (@$md['ts_submitted']) : ?> <span class="label label-info">申请日期:<?php echo $md['ts_submitted'];?></span>
<?php else: if (@$md['ts_created']) : ?> <span class="label label-info">创建日期:<?php echo $md['ts_created'];?></span> <?php endif; ?>
<?php endif; ?>
<?php if (@$md['ts_published']) : ?> <span class="label label-success">发布日期:<?php echo $md['ts_published'];?></span><?php endif; ?>
</h4>
<?php else: if (@$md['doi']): ?>
<h4 class="media-heading">DOI:<?php echo $md['doi']; ?></h4>
<?php endif; ?>
<?php endif; ?>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>
<?php endforeach; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
<?php else : ?>
暂无对应信息。
<?php endif; ?>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$(".colorbox").colorbox({rel:"colorbox",photo:"true",transition:"fade"});
$(".colorbox").colorbox({photo:"true"});
});
</script>