merge heihedata branch r5034 - r5101 into trunk

This commit is contained in:
wlx 2015-01-14 06:19:53 +00:00
parent f3fde709c4
commit 30f1f679d9
15 changed files with 1263 additions and 36 deletions

View File

@ -499,12 +499,13 @@ class Admin_DataController extends Zend_Controller_Action
}//search }//search
else{ else{
$sql = "SELECT md.*,s.viewed,g.id as gid,gen.id as genid,st.status as mdstatus,ds.id as datasetid FROM metadata md $sql = "SELECT md.*,s.viewed,g.id as gid,gen.id as genid,st.status as mdstatus,ds.id as datasetid,dataspatial.id as stid FROM metadata md
LEFT JOIN mdstat s ON md.uuid=s.uuid LEFT JOIN mdstat s ON md.uuid=s.uuid
LEFT JOIN geonetworkmetadata g ON g.uuid=md.uuid LEFT JOIN geonetworkmetadata g ON g.uuid=md.uuid
LEFT JOIN mdstatus st ON md.uuid=st.uuid LEFT JOIN mdstatus st ON md.uuid=st.uuid
LEFT JOIN dataset ds ON md.uuid=ds.uuid LEFT JOIN dataset ds ON md.uuid=ds.uuid
left join en.geonetworkmetadata gen on gen.uuid=md.uuid left join en.geonetworkmetadata gen on gen.uuid=md.uuid
left join dataspatial on dataspatial.uuid=md.uuid
ORDER BY md.id DESC"; ORDER BY md.id DESC";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(); $sth->execute();
@ -3777,6 +3778,75 @@ class Admin_DataController extends Zend_Controller_Action
}//ac == "changestatus" }//ac == "changestatus"
//统计
if($ac == 'status')
{
$status = new \Heihe\Status;
$fund_id = $this->_getParam('fund_id');
$this->view->funds = $fund_id;
if(!empty($fund_id) && is_array($fund_id) && count($fund_id)>0)
{
$status->fund_id = $fund_id;
}
if(view::isXmlHttpRequest())
{
echo $status->fileCount();
exit();
}
$this->_helper->viewRenderer('project-status');
$this->view->projects = $heihe->fetch();
$this->view->projectsCount = $status->projectsCount();
$this->view->dataCount = $status->dataCount();
$this->view->dataFileSize = $status->dataSize();
$this->view->applyTimes = $status->applyTimes();
$this->view->dataApplyTimes = $status->dataApplyTimes();
$this->view->applyTimesDistanct = $status->applyTimesDistinct();
//$this->view->fileCount = $status->fileCount();
$this->view->offlineServiceTimes = $status->serviceTimes('offline');
$this->view->onlineServiceTimes = $status->serviceTimes('online');
$this->view->offlineServiceSize = $status->serviceFilesize('offline');
$this->view->onlineServiceSize = $status->serviceFilesize('online');
$this->view->offlineServiceProjects = $status->serviceForProjects('offline');
$this->view->onlineServiceProjects = $status->serviceForProjects('online');
$this->view->allServiceProjects = $status->serviceForProjects('all');
}//status
if($ac == 'datas')
{
$this->_helper->viewRenderer('md');
view::addPaginator($heihe->metadata(),$this);
}// datas
if($ac == "userdown")
{
$status = new \Heihe\Status;
$this->_helper->viewRenderer('project-userdown');
view::addPaginator($status->downloadTimesByUser(),$this);
}
}//projectsAction() }//projectsAction()
public function fundAction() public function fundAction()
@ -4001,9 +4071,9 @@ class Admin_DataController extends Zend_Controller_Action
'title'=>$metadata['title'], 'title'=>$metadata['title'],
'doi'=>$metadata['doi'], 'doi'=>$metadata['doi'],
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid, 'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
'publisher'=>'寒区旱区科学数据中心', 'publisher'=>'黑河计划数据管理中心',
'title_en'=>$metadata['title_en'], 'title_en'=>$metadata['title_en'],
'publisher_en'=>'Cold and Arid Regions Science Data Center at Lanzhou', 'publisher_en'=>'Heihe Plan Science Data Center',
); );
}else{ }else{
$this->view->data['doi'] = $metadata['doi']; $this->view->data['doi'] = $metadata['doi'];
@ -4078,8 +4148,8 @@ class Admin_DataController extends Zend_Controller_Action
<doi_batch_id>'.$timestamp.'</doi_batch_id> <doi_batch_id>'.$timestamp.'</doi_batch_id>
<timestamp>'.$timestamp.'</timestamp> <timestamp>'.$timestamp.'</timestamp>
<depositor> <depositor>
<name>ISTIC</name> <name>WestDC</name>
<email_address>tuy@istic.ac.cn</email_address> <email_address>westdc@lzb.ac.cn</email_address>
</depositor> </depositor>
<registrant>ISTIC</registrant> <registrant>ISTIC</registrant>
</head> </head>
@ -4102,7 +4172,7 @@ class Admin_DataController extends Zend_Controller_Action
$doi.='<doi_data> $doi.='<doi_data>
<doi>'.$row['doi'].'</doi> <doi>'.$row['doi'].'</doi>
<timestamp>'.$timestamp.'</timestamp> <timestamp>'.$timestamp.'</timestamp>
<resource><![CDATA[http://westdc.westgis.ac.cn/data/'.$row['uuid'].']]></resource> <resource><![CDATA[http://www.heihedata.org/data/'.$row['uuid'].']]></resource>
</doi_data>'; </doi_data>';
$doi.='</database> $doi.='</database>
</science_data> </science_data>
@ -4129,6 +4199,102 @@ class Admin_DataController extends Zend_Controller_Action
} }
}//doi }//doi
public function spatialAction()
{
$ac = $this->_getParam('ac');
$submit = $this->_getParam('submit');
$uuid = $this->_getParam('uuid');
$q=$this->_getParam('q');
$this->view->q=$q;
include_once("data/DataSpatial.php");
$spatial = new DataSpatial($this->db);
include_once("helper/view.php");
if( empty($ac) || $ac == "index")
{
if(empty($uuid))
{
$rows = $spatial->fetch(0,$q);
view::addPaginator($rows,$this,10);
}else{
$this->_redirect('/admin/data/spatial/ac/edit/uuid/'.$uuid);
return true;
}
return true;
}//index
else if($ac == "edit")
{
$this->_helper->viewRenderer('spatial-add');
$id = $this->_getParam('id');
if(empty($uuid) && empty($id))
{
view::Msg('alert-error',"参数错误",-1);
return false;
}
if(empty($submit)){
if(!empty($uuid))
{
$this->view->uuid = $uuid;
$this->view->data = $spatial->view($uuid);
if(empty($this->view->data))
{
include('data/Metadata.php');
$md = new Metadata($this->db);
$metadata = $md->view($uuid);
$data['title']=$metadata['title'];
$data['temporal']=$spatial->mktemporal($metadata['timebegin'],$metadata['timeend']);
$data['spatial']=$spatial->mkspatial($metadata['east'],$metadata['south'],$metadata['west'],$metadata['north']);
$this->view->data[0]=$data;
}
}
}else{
$data = $spatial->_getParams($this->_request);
$this->view->data = $data;
$data['info'] = $spatial->checkinfo($data['info']);
if(!is_array($data['info'])){
$this->view->error = view::Error($data['info']);
return true;
}
$state = $spatial->update($data,$uuid);
if($state)
{
$this->view->msg = view::Msg('alert-success',"修改成功!",'/admin/data/spatial/uuid/'.$uuid);
return false;
}else{
$this->view->error = view::Error("修改失败");
return false;
}
}
}//edit
else if($ac == "del")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
if(empty($id))
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
if($spatial->delete($id) == true)
{
$this->jsonexit(array('success'=>$id));
return true;
}else{
$this->jsonexit(array('error'=>'删除失败'));
return true;
}
}//del
}//spatial
//发送邀请专家的邮件 //发送邀请专家的邮件
public function sendMailToExpert($pid,$name,$email,$code,$test=0) public function sendMailToExpert($pid,$name,$email,$code,$test=0)
{ {

View File

@ -25,5 +25,6 @@
<li id="Nav-data-project"><a href="/admin/data/project">汇交计划</a></li> <li id="Nav-data-project"><a href="/admin/data/project">汇交计划</a></li>
<li id="Nav-data-fund"><a href="/admin/data/fund">支持项目</a></li> <li id="Nav-data-fund"><a href="/admin/data/fund">支持项目</a></li>
<li id="Nav-data-doi"><a href="/admin/data/doi">DOI</a></li> <li id="Nav-data-doi"><a href="/admin/data/doi">DOI</a></li>
<li id="Nav-data-spatial"><a href="/admin/data/spatial">数据时空范围</a></li>
</ul> </ul>
</div> </div>

View File

@ -43,7 +43,9 @@
<?php foreach ($this->paginator as $item): ?> <?php foreach ($this->paginator as $item): ?>
<li class="well well-sm"> <li class="well well-sm">
<h4><a href="/data/<?= $item['uuid']; ?>" class="title"><?= $item['title']; ?></a></h4> <h4><a href="/data/<?= $item['uuid']; ?>" class="title"><?= $item['title']; ?></a></h4>
<p>大小:<?= $item['filesize']; ?>M创建时间<?= date('Y-m-d',strtotime($item['ts_created'])); ?>,查看:<?= $item['viewed']; ?>次。</p> <p> <p>大小:<?= $item['filesize']; ?>M创建时间<?= date('Y-m-d',strtotime($item['ts_created'])); ?>,查看:<?= $item['viewed']; ?>次。</p>
<?php if(isset($item['heihe_fund_title']) && !empty($item['heihe_fund_title'])) { ?><p>计划内项目: <?= $item['heihe_fund_title'] ?></p><?php } ?>
<p>
操作: 操作:
<?php if ($item['gid']>0) : ?> <?php if ($item['gid']>0) : ?>
<a class="label label-primary" href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a> <a class="label label-primary" href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a>
@ -74,6 +76,9 @@
<?php if (!isset($item['genid']) || !$item['genid']>0) : ?> <?php if (!isset($item['genid']) || !$item['genid']>0) : ?>
<a class="label label-primary iframe" href="/admin/data/gnenexport/uuid/<?php echo $item['uuid'];?>">导入英文版</a> <a class="label label-primary iframe" href="/admin/data/gnenexport/uuid/<?php echo $item['uuid'];?>">导入英文版</a>
<?php endif; ?> <?php endif; ?>
<?php if (!isset($item['stid']) || !$item['stid']>0) : ?>
<a class="label label-primary" href="/admin/data/spatial/ac/edit/uuid/<?php echo $item['uuid']; ?>">数据时空范围采集</a>
<?php endif; ?>
</p> </p>
<?php if($item['author']) :?> <?php if($item['author']) :?>
<p>数据贡献者:<?= $item['author']; ?></p> <p>数据贡献者:<?= $item['author']; ?></p>

View File

@ -0,0 +1,77 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/heihe">黑河数据集</a>');
$this->breadcrumb('黑河数据集');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->headLink()->appendStylesheet('/css/author.css');
?>
<div class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="col-md-10 col-sm-12">
<h2>统计信息</h2>
<hr />
<h4>数据:</h4>
<p>项目个数:<?= $this->projectsCount ?></p>
<p>数据条数:<?= $this->dataCount ?></p>
<p>总数据量:<?= round($this->dataFileSize / 1024 , 2) . 'GB' ?></p>
<p>文件个数:<a href="javascript:void(0);" id="fileCount">点击查看</a></p>
<p>服务次数(人/次)<a href="/admin/data/project/ac/userdown"><?= $this->applyTimes ?></a></p>
<p>服务次数(人/合并次,单个用户多次申请算作一次服务) <?= $this->applyTimesDistanct ?></p>
<p>服务次数(数据条/次)<?= $this->dataApplyTimes ?></p>
<h4>项目服务情况<small>(数据中心所有数据向计划内项目提供的服务)</small></h4>
<p>为黑河计划项目服务的次数-离线:<?= $this->offlineServiceTimes ?></p>
<p>为黑河计划项目服务的数据量-离线:<?= round($this->offlineServiceSize,2) ?>GB</p>
<p>为黑河计划项目服务的次数-在线:<?= $this->onlineServiceTimes ?></p>
<p>为黑河计划项目服务的数据量-在线:<?= round($this->onlineServiceSize ,2) ?>GB</p>
<p>为黑河计划项目服务的次数-总数:<?= $this->onlineServiceTimes + $this->offlineServiceTimes ?></p>
<p>为黑河计划项目服务的数据量-总数:<?= round($this->onlineServiceSize + $this->offlineServiceSize ,2)?>GB</p>
<p>服务计划内项目个数-离线:<?= $this->offlineServiceProjects ?></p>
<p>服务计划内项目个数-在线:<?= $this->onlineServiceProjects ?></p>
<p>服务计划内项目个数-综合(在线离线合并)<?= $this->allServiceProjects ?></p>
<h3>选择项目进行统计</h3>
<form method="get">
<div class="form-group">
<?php foreach($this->projects as $v) { ?>
<label class="checkbox-inline" title="<?= $v['title'] ?>">
<input type="checkbox" name="fund_id[]" value="<?= $v['code'] ?>" <?= (is_array($this->funds) && in_array($v['code'],$this->funds)) ? "checked":'' ?> title="<?= $v['title'] ?>" /><?= $v['code'] ?>
</label>
<?php }?>
</div>
<button type="submit" name="submit" value="1" class="btn btn-success">重新统计</button>
</form>
</div>
</div>
<?php $query = isset($_GET) && count($_GET) ? "?".http_build_query($_GET) :"" ; ?>
<script>
$('#fileCount').click(function(){
$.ajax({
'type': "POST",
'url': "<?= $query ?>",
'data': '',
'success': function(data){
$('#fileCount').after(data);
$('#fileCount').remove();
},
'beforeSend':function(){
$('#fileCount').html('正在加载...');
}
})
});
</script>

View File

@ -0,0 +1,89 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('黑河数据集');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'jquery');
// $this->theme->AppendPlus($this,'colorbox');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/js/lib/colorbox/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/js/lib/colorbox/colorbox.css');
?>
<div class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="col-md-10 col-sm-12">
<?php if(!empty($this->searchLink)){ ?>
<div class="input-group form-group">
<form id="datasearch" class="search_form input-group" action="<?= $this->searchLink ?>">
<input class="form-control" type="text" id="keyword" name="q" value="<?= $this->searchKeyword; ?>" placeholder="搜索关键字" />
<span class="input-group-btn"><button type="submit" class="btn btn-default" id="search_btn">搜索</button></span>
</form>
</div>
<?php }?>
<div class="">
<a href="/admin/data/project/ac/status" class="btn btn-info">统计</a>
<a href="/admin/data/project/ac/datas" class="btn btn-info">计划内的数据</a>
<a href="/admin/data/project/ac/download" class="btn btn-info">计划内的下载纪录</a>
</div>
<h5>
<?= $this->Count; ?> 条记录
</h5>
<div id="datalistZ">
<?php if (count($this->paginator)): ?>
<table class="table">
<thead>
<th>用户ID</th>
<th>用户名</th>
<th>姓名</th>
<th>下载次数</th>
</thead>
<tbody>
<?php
$autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;
?>
<tr>
<td><?= $item['id'] ?></td>
<td><?= $item['username'] ?></td>
<td><?= $item['realname'] ?></td>
<td><?= $item['c'] ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php endif; ?>
</div>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<div style="display:none;">
<div id="confirm_dialog" class="cbox_content">
<div class="sepH_c tac"><strong>状态修改</strong></div>
<div id="cbox_dialog_content" class="sepH_c ">
<select id="status_selector" style="width:300px;" name="" class="form-control">
<?php
foreach($this->project_status as $k=>$v)
{
echo '<option value="'.$k.'">'.$v.'</option>';
}
?>
</select>
</div>
<div class="tac pull-right" id="cbox_ctl_btns">
<a href="javascript:void(0);" class="btn btn-success btn-sm" id="confirm_yes"
onclick="changeStatusAction($('#status_selector').attr('name'),$('#status_selector').val());">确定</a>
<a href="javascript:void(0);" class="btn btn-danger btn-sm" id="confirm_no" onclick="$.colorbox.close();">取消</a>
</div>
</div>
</div>
</div>

View File

@ -28,6 +28,11 @@
</form> </form>
</div> </div>
<?php }?> <?php }?>
<div class="">
<a href="/admin/data/project/ac/status" class="btn btn-info">统计</a>
<a href="/admin/data/project/ac/datas" class="btn btn-info">计划内的数据</a>
<a href="/admin/data/project/ac/userdown" class="btn btn-info">计划内的下载纪录</a>
</div>
<h5> <h5>
<?= $this->Count; ?> 条记录 <?= $this->Count; ?> 条记录
</h5> </h5>

View File

@ -0,0 +1,121 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('数据时空范围');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
?>
<div class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="col-md-10 col-sm-12">
<div>
<ul class="nav nav-tabs">
<li><a href="/admin/data/spatial">浏览所有</a></li>
<?php if(!empty($this->uuid)) {?>
<li class="active"><a href="javascript:void(0);">编辑</a></li>
<?php }?>
</ul>
</div>
<div class="">
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<p></p>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4>提示</h4>
1. 空间范围请使用经纬度dd格式进行添加。<br/>
2. 日期精确到天。中括号代表包含,小括号代表不包含。
</div>
<h2><?php echo $this->data[0]['title']; ?></h2>
<form class="form-horizontal" method="post">
<div id="datalist">
<?php if (count($this->data)): ?>
<table class="stylized table table-bordered table-striped table-hover">
<thead>
<tr>
<th width="60%">空间范围</th>
<th>时间范围</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
foreach ($this->data as $item):
if (isset($item['id']) && $item['id']>0) :
$autoindex++; ?>
<tr class="infocontrol">
<td><textarea class="col-md-12" rows="3" name="info[<?= $autoindex ?>][spatial]" ><?= $item['spatial'] ?></textarea></td>
<td><input type="text" name="info[<?= $autoindex ?>][temporal]" class="form-control" value="<?= $item['temporal'] ?>" /></td>
<td>
编辑:点 线 矩形 多边形
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
</td>
<input type="hidden" name="info[<?= $autoindex ?>][id]" value=" <?=$item->id?> " />
</tr>
<?php endif; endforeach; if ((count($this->data)==1) && !isset($this->data[0]['id'])) :
$item=$this->data[0]; ?>
<tr class="infocontrol">
<td><textarea class="col-md-12" rows="3" name="info[1][spatial]" ><?= $item['spatial'] ?></textarea></td>
<td><input type="text" name="info[1][temporal]" class="form-control"
value="<?= $item['temporal'] ?>" /></td>
<td>
点 线 矩形 多边形
<a href="/admin/data/spatial/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
</td>
<input type="hidden" name="info[1][id]" value="0" />
</tr>
<?php endif; endif;?>
</tbody>
</table>
</div>
<div class="form-group">
<div class="col-sm-12">
<a class="pull-right" href="javascript:void(0);" onclick="addinput()" >+为该数据添加一行新时空范围</a>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input type="hidden" name="submit" value="1" />
<?php if(!empty($this->uuid)) { ?>
<input type="hidden" name="uuid" value=" <?=$this->uuid?>" />
<?php } ?>
<button type="submit" class="btn btn-primary pull-right">提交</button>
</div>
</div>
</form>
<?php } ?>
</div>
</div>
</div>
<script>
function addinput(){
var now_index = $('.infocontrol').length;
var index = now_index + 1;
html = '<tr class="infocontrol">'
+'<td><textarea class="col-md-12" rows="3" name="info['+index+'][spatial]" placeholder="WKT Geometry"></textarea></td>'
+'<td><input type="text" name="info['+index+'][temporal]" class="form-control" value="" placeholder="Date range"/></td>'
+'<td><a href="">点 线 矩形 多边形</a>'
+' <label class="control-label"><a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a></label>'
+'</td><input type="hidden" name="info['+index+'][id]" value="0" />'
+'</tr>';
now_index = null;
index = null;
$('.infocontrol').last().after(html);
}
function RmInput(e){
$e = $(e);
$e.parent().parent().parent('tr.infocontrol').remove();
}
</script>
<!-- //页面内容 -->

View File

@ -0,0 +1,167 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('数据时空范围');
$this->breadcrumb()->setSeparator(' > ');
// $this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin');
$this->headScript()->appendFile('/js/lib/colorbox/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/js/lib/colorbox/colorbox.css');
?>
<div class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="col-md-10 col-sm-12 span10">
<div class="form-group">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="/admin/data/spatial">浏览所有</a></li>
</ul>
</div>
<div class="input-group form-group">
<form id="datasearch" class="search_form input-group" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" class="form-control" placeholder="搜索关键字" />
<span class="input-group-btn"><button class="btn btn-default" type="submit" id="search_btn">搜索</button></span>
</form>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="stylized table table-bordered table-striped table-hover">
<thead>
<tr>
<th>元数据</th>
<th>空间范围</th>
<th>时间范围</th>
<th>修改时间</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<td><a href="/data/<?= $item['uuid'] ?>"><?= $item['title'] ?></a></td>
<td><?= $item['spatial'] ?></td>
<td><?= $item['temporal'] ?></td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_changed'])) ?></td>
<td>
<a href="/admin/data/spatial/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/spatial/ac/del"
}
$(document).ready(function(e) {
$('.verified_btn').click(function(e) {
$(this).ajaxmsg({
callback:function(){window.location.reload();}
});
});
});
(function( $ ){
$.fn.ajaxmsg = function( options ) {
var settings = $.extend( {
url:'',
callback : '',
}, options);
var methods = {
msg : function(id)
{
methods.submited();
},
creatWindow : function(content){
$.colorbox({
initialHeight: '0',
initialWidth: '0',
html: methods.dialog(content),
opacity: '0.3',
onComplete: function(){
$('.confirm_yes').click(function(e){
e.preventDefault();
if(typeof(settings.callback)=='function')
{
settings.callback();
}
$.colorbox.close();
});
$('.confirm_no').click(function(e){
e.preventDefault();
$.colorbox.close();
});
}
});
},
submited : function(){
$.ajax({
'type':"POST",
'url':settings.url,
'data':'',
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{alert(data.error);}
if(typeof(data.success)!='undefined')
{
methods.creatWindow(data.success);
}
}
else{
alert('出现错误,请稍候再试');
}
},
'timeout': 30000,
'error': function(){
alert('出现错误,请刷新后重试');
}
});
},
dialog : function(content){
HTML = '<div class=""><div class="modal-header"><h3>提示信息</h3></div>'
+ '<div class="modal-body"><div class=" span5">'+content+'</div></div>'
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">确定</a></div></div>';
return HTML;
}
}
this.each(function() {
settings.url = $(this).attr('rel');
if(settings.url == '')
{
alert('参数错误');
}
methods.msg();
});
};
})( jQuery );
</script>

View File

@ -178,7 +178,7 @@ $(document).ready(function(){
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" id="pubtimeturn" name="pubtimer" value="1" <?php if($this->ev['is_pub']==true && !empty($this->ev['ts_published'])) echo 'checked="checked"'; ?>/>定时发布? <input type="checkbox" id="pubtimeturn" name="pubtimer" value="1" <?php if($this->ev['is_pub']==true && !empty($this->ev['ts_published'])) echo 'checked="checked"'; ?>/>定时发布?
</label> </label>
<input class="form-control" type="text" name="pubtime" id="pubtime" value="<?php echo date("Y-m-d H:i",strtotime($this->ev['ts_published']));?>" readonly="readonly" disabled /> <input class="form-control" type="text" name="pubtime" id="pubtime" value="<?php echo date("Y-m-d H:i",strtotime($this->ev['ts_published']));?>" />
<span class="text-muted"> e.g. 2011-10-28 9:35 or 2011-10-28 21:35</span> <span class="text-muted"> e.g. 2011-10-28 9:35 or 2011-10-28 21:35</span>
</div> </div>
</div> </div>

View File

@ -335,7 +335,7 @@ class HiwaterController extends DataController
function rsproductAction() function rsproductAction()
{ {
$this->getmdlimited(array('DEM','DOM','降水','土壤水分','积雪','植被类型','植被覆盖度','物候期','NPP'),'卫星遥感产品'); $this->getmd(array('卫星遥感产品'));
$this->_helper->viewRenderer('base'); $this->_helper->viewRenderer('base');
} }

View File

@ -3,7 +3,7 @@ $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data); $this->headTitle($this->config->title->data);
$this->headTitle('支持项目'); $this->headTitle('支持项目');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->nav[] = array('link'=>"/fund",'title'=>'项目浏览'); $this->nav[] = array('link'=>"/heihe/fund",'title'=>'项目浏览');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
?> ?>
<?= $this->render('breadcrumbs.phtml') ?> <?= $this->render('breadcrumbs.phtml') ?>

View File

@ -78,6 +78,7 @@
<h4><a href="/data/doi">最新注册DOI数据</a></h4> <h4><a href="/data/doi">最新注册DOI数据</a></h4>
<ul class="unstyled"> <ul class="unstyled">
<?php foreach($this->dois as $doi) : <?php foreach($this->dois as $doi) :
if (isset($doi->title))
echo '<li class="well well-small">['.date('Y-m-d',strtotime($doi->ts_published)).']<a href="/data/'.$doi->uuid.'">'.str_replace('"','',substr($doi->authors,1,-1)).'. '.$doi->title.'. '.$doi->publisher.', '.(empty($doi->publish_year)?date('Y',strtotime($doi->ts_published)):date('Y',strtotime($doi->publish_year))).'. doi:'.$doi->doi.'</a></li>'; echo '<li class="well well-small">['.date('Y-m-d',strtotime($doi->ts_published)).']<a href="/data/'.$doi->uuid.'">'.str_replace('"','',substr($doi->authors,1,-1)).'. '.$doi->title.'. '.$doi->publisher.', '.(empty($doi->publish_year)?date('Y',strtotime($doi->ts_published)):date('Y',strtotime($doi->publish_year))).'. doi:'.$doi->doi.'</a></li>';
//echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.$md->publish_year.'. doi:'.$md->doi.']'; //echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.$md->publish_year.'. doi:'.$md->doi.']';
endforeach; endforeach;

View File

@ -2,6 +2,7 @@
/** /**
* Heihe 黑河项目通用类 * Heihe 黑河项目通用类
*/ */
//namespace Heihe;
class Heihe class Heihe
{ {
@ -27,6 +28,51 @@ class Heihe
} }
//获取所有计划
public function fetch()
{
$sql = "SELECT * FROM {$this->tbl_heiheproject}
ORDER BY id ASC";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll();
return $rows;
}
//计划内的yuan数据
public function metadata($keyword = "")
{
if(empty($keyword))
$wheresql = "";
else{
$wheresql = [];
$keyword = trim($keyword);
$keyword = str_replace("'","''",$keyword);
$wheresql[] = " md.title LIKE '%$keyword%' ";
$wheresql[] = " md.title_en LIKE '%$keyword%'";
$wheresql[] = " md.description LIKE '%$keyword%' ";
$wheresql = " WHERE " . join(" OR ",$wheresql);
}
$sql = "SELECT md.*,s.viewed,g.id as gid,gen.id as genid,st.status as mdstatus,ds.id as datasetid,fund.title as heihe_fund_title FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
LEFT JOIN mdstat s ON md.uuid=s.uuid
LEFT JOIN geonetworkmetadata g ON g.uuid=md.uuid
LEFT JOIN mdstatus st ON md.uuid=st.uuid
LEFT JOIN dataset ds ON md.uuid=ds.uuid
LEFT JOIN en.geonetworkmetadata gen on gen.uuid=md.uuid
$wheresql
ORDER BY md.id";
$rs = $this->db->query($sql);
return $rs->fetchAll(\PDO::FETCH_ASSOC);
}
//获取汇交状态 //获取汇交状态
public function getStatus($code){ public function getStatus($code){
@ -306,3 +352,369 @@ class Heihe
} }
} }
class Status{
public $fund_id;
function __construct()
{
$this->db = \Zend_Registry::get('db');
}
public function makeConditionFound($field)
{
if(empty($this->fund_id))
{
return null;
}
$str = join("','",$this->fund_id);
return "$field IN ('". $str . "')";
}
public function makeWhereSql($array)
{
if(is_array($array) && count($array) > 0)
return " WHERE " . join(" AND ",$array);
else
return "";
}
//项目总数
public function projectsCount()
{
$fund = $this->makeConditionFound("hh.code");
if(!empty( $fund ))
{
$wheresql = $this->makeWhereSql(array($fund));
}else{
$wheresql = "";
}
$sql = "SELECT count(hh.code) as c FROM heiheproject hh $wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//数据条数
public function dataCount()
{
$arr = [
"md.uuid IS NOT NULL",
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT count(md.uuid) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//数据量
public function dataSize()
{
$arr = [
"md.uuid IS NOT NULL"
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT SUM(md.filesize) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//文件数
public function fileCount()
{
$arr = [
"md.uuid IS NOT NULL",
"df.filename !~ E'[/|\]+$'"
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT count(df.id) FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataset ds ON ds.uuid = md.uuid
RIGHT JOIN datafile df ON ds.id = df.dsid
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//数据申请数量
public function dataApplyTimes()
{
$arr = [
"md.uuid IS NOT NULL",
"(o.offlineappid <> -1 OR o.onlineappid <> -1)"
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT count(distinct o.id) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataorder o ON o.uuid = md.uuid
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//服务人次
public function applyTimes()
{
$arr = [
"md.uuid IS NOT NULL",
"(o.offlineappid <> -1 OR o.onlineappid <> -1)"
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT count(distinct o.offlineappid) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataorder o ON o.uuid = md.uuid
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//服务人次(用户唯一)
public function applyTimesDistinct()
{
$arr = [
"md.uuid IS NOT NULL",
"(o.offlineappid <> -1 OR o.onlineappid <> -1)"
];
$fund = $this->makeConditionFound("fund.fund_id");
if(!empty($fund))
$arr[] = $fund;
$wheresql = $this->makeWhereSql($arr);
$sql = "SELECT count(distinct o.userid) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataorder o ON o.uuid = md.uuid
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//每个用户数据申请量
public function downloadTimesByData()
{
$sql = "SELECT o.userid,count(o.id) FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataorder o ON o.uuid = md.uuid
WHERE md.uuid IS NOT NULL AND (o.offlineappid <> -1 OR o.onlineappid <> -1)
GROUP BY o.userid";
$rs = $this->db->query($sql);
return $rs->fetchAll;
}
//详细的用户申请次数统计
public function downloadTimesByUser()
{
$sql = "SELECT u.id,u.username, u.realname ,count(o.id) as c FROM metadata md
LEFT JOIN mdfund mf ON mf.uuid = md.uuid
RIGHT JOIN fund ON fund.id = mf.fid
RIGHT JOIN heiheproject hh ON hh.code = fund.fund_id
RIGHT JOIN dataorder o ON o.uuid = md.uuid
LEFT JOIN users u ON u.id = o.userid
WHERE md.uuid IS NOT NULL AND (o.offlineappid <> -1 OR o.onlineappid <> -1)
GROUP BY u.id,u.username, u.realname";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
//为黑河计划项目服务的情况
public function serviceTimes($type = "offline")
{
if($type == 'offline')
{
$arr = ['ts_approved IS NOT NULL'];
}else{
$arr = [];
}
$fund = $this->makeConditionFound("project_id");
if(!empty($fund))
{
$arr[] = $fund;
}else{
$select = "SELECT DISTINCT code FROM heiheproject";
$rs = $this->db->query($select);
$code_statck = [];
while($row = $rs->fetch())
{
$code_statck[] = $row['code'];
}
$arr[] = " project_id IN ('".join("','" , $code_statck)."')";
}
$wheresql = $this->makeWhereSql($arr);
if($type == 'offline')
$sql = "SELECT count(id) FROM offlineapp $wheresql";
else
$sql = "SELECT count(id) FROM onlineapp $wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//服务数据大小
public function serviceFilesize($type = "offline")
{
if($type == 'offline')
{
$arr = ['off.ts_approved IS NOT NULL'];
}else{
$arr = [];
}
if($type == 'offline')
$fund = $this->makeConditionFound("off.project_id");
else
$fund = $this->makeConditionFound("ol.project_id");
if(!empty($fund))
{
$arr[] = $fund;
}else{
$select = "SELECT DISTINCT code FROM heiheproject";
$rs = $this->db->query($select);
$code_statck = [];
while($row = $rs->fetch())
{
$code_statck[] = $row['code'];
}
if($type == 'offline')
$arr[] = " off.project_id IN ('".join("','" , $code_statck)."')";
else
$arr[] = " ol.project_id IN ('".join("','" , $code_statck)."')";
}
$wheresql = $this->makeWhereSql($arr);
if($type == 'offline')
$sql = "SELECT SUM(md.filesize) /1024 as size FROM metadata md
LEFT JOIN dataorder o ON o.uuid=md.uuid
LEFT JOIN offlineapp off ON off.id = o.offlineappid
$wheresql";
else
$sql = "SELECT SUM(md.filesize) /1024 as size FROM metadata md
LEFT JOIN dataorder o ON o.uuid=md.uuid
LEFT JOIN onlineapp as ol ON ol.id = o.onlineappid
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
//服务计划内的项目个数
public function serviceForProjects($type = "offline")
{
if($type == 'offline')
{
$arr = ['ts_approved IS NOT NULL'];
}else{
$arr = [];
}
$fund = $this->makeConditionFound("project_id");
if(!empty($fund))
{
$arr[] = $fund;
}else{
$select = "SELECT DISTINCT code FROM heiheproject";
$rs = $this->db->query($select);
$code_statck = [];
while($row = $rs->fetch())
{
$code_statck[] = $row['code'];
}
$arr[] = " project_id IN ('".join("','" , $code_statck)."')";
}
$wheresql = $this->makeWhereSql($arr);
if($type == 'offline')
$sql = "SELECT count(DISTINCT project_id) as c FROM offlineapp
$wheresql";
elseif($type == "online")
$sql = "SELECT count(DISTINCT project_id) as c FROM onlineapp
$wheresql";
else
$sql = "SELECT count(DISTINCT project_id) FROM
(SELECT DISTINCT off.project_id FROM offlineapp off UNION ALL SELECT DISTINCT ol.project_id FROM onlineapp ol) apply
$wheresql";
$rs = $this->db->query($sql);
return $rs->fetchColumn(0);
}
}

View File

@ -0,0 +1,180 @@
<?php
class DataSpatial extends Zend_Controller_Plugin_Abstract
{
private $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量
public $tbl = "dataspatial";
function __construct($db)
{
$this->db = $db;
}
function fetch($uid=0,$keyword='')
{
$wheresql=' 1=1 ';
if(!empty($keyword))
{
if(preg_match("/\'/",$keyword))
{
$keyword = preg_replace("/\'/","''",$keyword);
}
$wheresql.=" and m.title like '%$keyword%'";
}
if(empty($uid))
{
$sql = "SELECT m.title,d.id,d.uuid,st_astext(d.the_geom) as spatial,d.temporal,d.ts_changed FROM ".$this->tbl." d left join metadata m on d.uuid=m.uuid where ".$wheresql."ORDER BY d.ts_changed desc";
}else{
$sql = "SELECT m.title,d.id,d.uuid,st_astext(d.the_geom) as spatial,d.temporal,d.ts_changed FROM ".$this->tbl." d
left join metadata m on d.uuid=m.uuid
LEFT JOIN mdauthor a ON d.uuid=a.uuid
WHERE a.userid=".$uid." AND a.status>0 and ".$wheresql."
ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC
";
}
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
function update($data,$uuid,$uid=0){
if(!empty($uid))
{
include_once("data/Author.php");
$author = new Author($this->db);
if($author->checkAuthor($uuid,$uid)==false)
{
return "您没有权限";
}
}
$this->db->beginTransaction();
try
{
foreach($data['info'] as $item)
{
if ($item['id']>0)
{
//update
if (isset($item['temporal']))
$sql="update $this->tbl set the_geom=ST_GeometryFromText('SRID=4326;".$item['spatial']."'),temporal='".$item['temporal']."',ts_changed=now() where id=".$item['id']." and uuid='".$data['uuid']."'";
else
$sql="update $this->tbl set the_geom=ST_GeometryFromText('SRID=4326;".$item['spatial']."'),ts_changed=now() where id=".$item['id']." and uuid='".$data['uuid']."'";
} else {
//insert
if (isset($item['temporal']))
$sql="insert into $this->tbl (uuid,the_geom,temporal) values('".$data['uuid']."',ST_GeometryFromText('SRID=4326;".$item['spatial']."'),'".$item['temporal']."')";
else
$sql="insert into $this->tbl (uuid,the_geom) values('".$data['uuid']."',ST_GeometryFromText('SRID=4326;".$item['spatial']."'))";
}
$this->db->exec($sql);
}
$this->db->commit();
return true;
} catch (Exception $e) {
$this->db->rollBack();
return $e->getMessage();
}
}
function view($id)
{
if(is_numeric($id))
{
$sql = "SELECT m.title,d.id,d.uuid,st_astext(d.the_geom) as spatial,d.temporal,d.ts_changed FROM ".$this->tbl." d left join metadata m on d.uuid=m.uuid WHERE d.id=$id";
}else{
$sql = "SELECT m.title,d.id,d.uuid,st_astext(d.the_geom) as spatial,d.temporal,d.ts_changed FROM ".$this->tbl." d left join metadata m on d.uuid=m.uuid WHERE d.uuid='$id'";
}
$rs = $this->db->query($sql);
$row = $rs->fetchAll();
return $row;
}
function delete($id,$uid=0){
if(!is_numeric($id))
{
return "参数错误";
}
if($uid != 0){
$sql = "SELECT uuid FROM ".$this->tbl." WHERE id=$id";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['uuid']) && !empty($row['uuid'])){
include_once("data/Author.php");
$author = new Author($this->db);
if($author->checkAuthor($row['uuid'],$uid)==false)
{
return "您没有权限";
}
$condition = " id=$id ";
$sql = "DELETE FROM ".$this->tbl." WHERE $condition";
return $this->db->exec($sql);
}else{
return "该记录不存在";
}
}else{
$condition = " id=$id ";
$sql = "DELETE FROM ".$this->tbl." WHERE $condition";
return $this->db->exec($sql);
}
}
function _getParams(Zend_Controller_Request_Abstract $request)
{
$data = array(
'uuid' => trim($request->getParam('uuid')),
'info'=>$_POST['info']
);
return $data;
}
function checkinfo($info){
if(!is_array($info)){
return NULL;
}
foreach($info as $k=>$v)
{
if(empty($v['spatial']) && empty($v['temporal']))
{
unset($info[$k]);
}else{
if(empty($v['spatial']))
{
return "请输入 $k 中的空间范围";
}
}
}
return $info;
}
function mkspatial($e,$s,$w,$n)
{
$str='GeometryCollection(';
if (($e==$w) && ($s==$n))
{
$str.="Point($e $s)";
} else {
$str.="Polygon(($e $s,$e $n,$w $n,$w $s,$e $s))";
}
$str.=')';
return $str;
}
function mktemporal($begin,$end=null)
{
if (!$begin) return '';
$str='[';
$begin=date('Y-m-d',strtotime($begin));
if (isset($end)) $end=date('Y-m-d',strtotime($end));
if (isset($end) && ($end!=$begin))
{
$str.="$begin,$end";
} else {
$str.="$begin,$begin";
}
$str.=']';
return $str;
}
}

View File

@ -25,9 +25,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
} }
if(empty($uid)) if(empty($uid))
{ {
$sql = "SELECT * FROM ".$this->tbl_doi." d where ".$wheresql."ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC"; $sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." d where ".$wheresql."ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC";
}else{ }else{
$sql = "SELECT d.* FROM ".$this->tbl_doi." d $sql = "SELECT d.*,array_to_json(d.organization) as org_json,array_to_json(d.organization_en) as orgen_json FROM ".$this->tbl_doi." d
LEFT JOIN mdauthor a ON d.uuid=a.uuid LEFT JOIN mdauthor a ON d.uuid=a.uuid
WHERE a.userid=".$uid." AND a.status>0 and ".$wheresql." WHERE a.userid=".$uid." AND a.status>0 and ".$wheresql."
ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC
@ -39,12 +39,12 @@ class Doi extends Zend_Controller_Plugin_Abstract
} }
function add($data){ function add($data){
include_once("helper/dbh.php");
$dbh = new dbh($this->db);
$this->data_process_in($data); $this->data_process_in($data);
//include_once("helper/view.php"); $sql="insert into ".$this->tbl_doi." (doi,authors,organization,publisher,uuid,url,title,title_en,publisher_en,author_en,organization_en) values('".
//view::Dump($data); $data['doi']."','".$data['authors']."',array[".$data['organization']."],'".$data['publisher']."','".$data['uuid'].
return $dbh->insert($this->tbl_doi,$data); "','".$data['url']."','".$data['title']."','".$data['title_en']."','".$data['publisher_en']."','".$data['author_en'].
"',array[".$data['organization_en']."])";
return $this->db->exec($sql);
} }
function update($data,$uuid,$uid=0){ function update($data,$uuid,$uid=0){
@ -73,7 +73,11 @@ class Doi extends Zend_Controller_Plugin_Abstract
}else{ }else{
$condition = " uuid='$uuid' "; $condition = " uuid='$uuid' ";
} }
$state = $dbh->update($this->tbl_doi,$data,$condition,true); $sql="update $this->tbl_doi set doi='".$data['doi']."',uuid='".$data['uuid']."',publisher='".$data['publisher']."',
url='".$data['url']."',title='".$data['title']."',title_en='".$data['title_en']."',publisher_en='".$data['publisher_en']."',
authors='".$data['authors']."',author_en='".$data['author_en']."',organization=array[".$data['organization']."],
organization_en=array[".$data['organization_en']."] where ".$condition;
$state=$this->db->exec($sql);
if( $state == true) if( $state == true)
{ {
@ -91,15 +95,19 @@ class Doi extends Zend_Controller_Plugin_Abstract
$orgs_en = array(); $orgs_en = array();
foreach($data['info'] as $k=>$v) foreach($data['info'] as $k=>$v)
{ {
$authors[$v['order']] = str_replace(",","",$v['author']); $authors[(int)$v['order']] = $v['author'];
$orgs[$v['order']] = str_replace(",","",$v['organization']); $orgs[(int)$v['order']] = $v['organization'];
$authors_en[$v['order']] = str_replace(",","",$v['author_en']); $authors_en[(int)$v['order']] = $v['author_en'];
$orgs_en[$v['order']] = str_replace(",","",$v['organization_en']); $orgs_en[(int)$v['order']] = $v['organization_en'];
} }
ksort($authors);
ksort($orgs);
ksort($authors_en);
ksort($orgs_en);
$authors = "{".join(",",$authors)."}"; $authors = "{".join(",",$authors)."}";
$orgs = "{".join(",",$orgs)."}"; $orgs = "'".join("','",$orgs)."'";
$authors_en = "{".join(",",$authors_en)."}"; $authors_en = "{".join(",",$authors_en)."}";
$orgs_en = "{".join(",",$orgs_en)."}"; $orgs_en = "'".join("','",$orgs_en)."'";
$data['authors'] = $authors; $data['authors'] = $authors;
$data['organization'] = $orgs; $data['organization'] = $orgs;
$data['author_en'] = $authors_en; $data['author_en'] = $authors_en;
@ -109,9 +117,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
function data_process_out(&$data){ function data_process_out(&$data){
$authors = $this->array_split($data['authors']); $authors = $this->array_split($data['authors']);
$orgs = $this->array_split($data['organization']); $orgs = json_decode($data['org_json']);
$authors_en = $this->array_split($data['author_en']); $authors_en = $this->array_split($data['author_en']);
$orgs_en = $this->array_split($data['organization_en']); $orgs_en = json_decode($data['orgen_json']);
$info = array(); $info = array();
foreach($authors as $k=>$v) foreach($authors as $k=>$v)
{ {
@ -120,18 +128,13 @@ class Doi extends Zend_Controller_Plugin_Abstract
'organization'=>str_replace("\"","",$orgs[$k]), 'organization'=>str_replace("\"","",$orgs[$k]),
'author_en'=>str_replace("\"","",$authors_en[$k]), 'author_en'=>str_replace("\"","",$authors_en[$k]),
'organization_en'=>str_replace("\"","",$orgs_en[$k]), 'organization_en'=>str_replace("\"","",$orgs_en[$k]),
'order'=> count($authors)+($k-1) 'order'=> count($authors)+$k
); );
} }
//include_once("helper/view.php");
//view::Dump($info);
return $info; return $info;
} }
function array_split($a){ function array_split($a){
/*$a = str_replace("{",'',$a);
$a = str_replace("}",'',$a);
$a = explode(",",$a); */
return explode(',',substr($a,1,-1)); return explode(',',substr($a,1,-1));
} }
@ -139,9 +142,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
{ {
if(is_numeric($id)) if(is_numeric($id))
{ {
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id"; $sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." WHERE id=$id";
}else{ }else{
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'"; $sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." WHERE uuid='$id'";
} }
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();