add dataset action

This commit is contained in:
Li Jianxuan 2013-04-26 08:24:42 +00:00
parent 3130e6f665
commit 9a5f173c57
3 changed files with 1815 additions and 1606 deletions

View File

@ -433,13 +433,17 @@ class Admin_DataController extends Zend_Controller_Action
}//search }//search
else{ else{
$select=$this->db->select(); $sql = "SELECT md.*,s.viewed,g.id as gid,st.status as mdstatus,ds.id as datasetid FROM metadata md
$select->from('metadata') LEFT JOIN mdstat s ON md.uuid=s.uuid
->joinLeft('mdstat','metadata.uuid=mdstat.uuid','viewed') LEFT JOIN geonetworkmetadata g ON g.uuid=md.uuid
->joinLeft('geonetworkmetadata','geonetworkmetadata.uuid=metadata.uuid','id as gid') LEFT JOIN mdstatus st ON md.uuid=st.uuid
->joinLeft('mdstatus','metadata.uuid=mdstatus.uuid','status as mdstatus') LEFT JOIN dataset ds ON md.uuid=ds.uuid
->order('metadata.id desc'); ORDER BY md.id DESC";
$paginator = Zend_Paginator::factory($select); $sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max); $paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view); $paginator->setView($this->view);
@ -448,6 +452,95 @@ class Admin_DataController extends Zend_Controller_Action
} }
} }
/*
* datasetAction()
* 数据存档
*
*/
function datasetAction()
{
$ac = $this->_request->getParam('ac');
if($ac == "getdataset")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer('md-dataset');
$uuid = $this->_request->getParam('uuid');
$sql = "SELECT * FROM dataset WHERE uuid=?";
$sth = $this->db->prepare($sql);
$sth ->execute(array($uuid));
$row = $sth->fetch();
$this->view->dataset = $row;
$this->view->uuid = $uuid;
}
if($ac == "update")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_request->getParam('uuid');
$host = $this->_getParam('host');
$path = $this->_getParam('path');
$sql = "UPDATE dataset SET host=?,path=? WHERE uuid=?";
$sth = $this->db->prepare($sql);
$ds = $sth ->execute(array($host,$path,$uuid));
if($ds)
{
$data = array("ok"=>1);
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>"处理中出现错误");
$this->jsonexit($data);
return true;
}
}
if($ac == "add")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_request->getParam('uuid');
$host = $this->_getParam('host');
$path = $this->_getParam('path');
$sql = "SELECT * FROM dataset WHERE uuid=?";
$sth = $this->db->prepare($sql);
$sth ->execute(array($uuid));
$row = $sth->fetch();
if(!empty($row['id']))
{
$data = array("error"=>"该数据已经有存档信息,不能重复添加");
$this->jsonexit($data);
return true;
}
$sql = "INSERT INTO dataset (uuid,host,path) VALUES (?,?,?)";
$sth = $this->db->prepare($sql);
$ds = $sth ->execute(array($uuid,$host,$path));
if($ds)
{
$data = array("ok"=>1);
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>"处理中出现错误");
$this->jsonexit($data);
return true;
}
}
}//datasetAction存档管理
function commentAction() function commentAction()
{ {
$delete=(int)$this->_getParam('delete'); $delete=(int)$this->_getParam('delete');
@ -1538,5 +1631,10 @@ class Admin_DataController extends Zend_Controller_Action
$iso=new ISO19115(); $iso=new ISO19115();
$iso->saveDB($this->db,$xml); $iso->saveDB($this->db,$xml);
} }
public function jsonexit($data){
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
return true;
}
} }

View File

@ -0,0 +1,99 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据存档</title>
<link rel="stylesheet" type="text/css" media="screen" href="/css/default.css" />
<script src='/static/js/jquery-1.7.2.min.js' type="text/javascript"></script>
<script type="text/javascript" src="/js/jquery.colorbox-min.js"></script>
<link href="/css/author.css" media="screen" rel="stylesheet" type="text/css"/>
<link href="/static/js/uploadify/uploadify.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/css/colorbox.css" media="screen" rel="stylesheet" type="text/css" />
<style>
#loading{margin:0px;border:none;height:50px;width:98%;background:url(/static/img/colorbox-images/loading.gif) center center no-repeat;display:none;position:absolute;left:0px;top:0px;overflow:hidden;background:#ccc;}
</style>
</head>
<body>
<!-- 页面内容 -->
<div id="warpper">
<div id="loading" class="info info-box"></div>
<div id="datalist">
<?php
if(!empty($this->dataset))
{?>
<p>主机:<br /><input type="text" id="host" name="host" value="<?= $this->dataset['host']?>" class="full" /></p>
<p>路径:<br /><input type="text" id="path" name="path" value="<?= $this->dataset['path']?>" class="full" /></p>
<p><button type="button" class="btn btn-green" onclick="updateDataSet()">修改</button></p>
<?php }else{ ?>
<p>主机:<br /><input type="text" id="host" name="host" value="" class="full" /></p>
<p>路径:<br /><input type="text" id="path" name="path" value="" class="full" /></p>
<p><button type="button" class="btn btn-green" onclick="addDataSet()">添加</button></p>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<script>
function updateDataSet(){
if(confirm("是否确定修改") == false)
{return false;}
$.ajax({
'type':"POST",
'url':'/admin/data/dataset',
'data':'ac=update&uuid=<?= $this->uuid ?>&host='+$('#host').val()+'&path='+$('#path').val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(data.ok != null)
{
Alert('修改成功!');
setTimeout("parent.$.fn.colorbox.close();",2000);
}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){
Alert('出现错误,请稍后再试');
}
});
}
function addDataSet(){
$.ajax({
'type':"POST",
'url':'/admin/data/dataset',
'data':'ac=add&uuid=<?= $this->uuid ?>&host='+$('#host').val()+'&path='+$('#path').val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(data.ok != null)
{
Alert('添加成功!');
setTimeout("parent.$.fn.colorbox.close();parent.window.location.href=parent.window.location.href;",2000);
}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){
Alert('出现错误,请稍后再试');
}
});
}
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
$(".inline").colorbox({inline:true, width:"50%"});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
}
</script>
</body>
</html>

View File

@ -8,6 +8,9 @@
$this->breadcrumb('<a href="/admin/data">数据管理</a>'); $this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('元数据管理</a>'); $this->breadcrumb('元数据管理</a>');
$this->breadcrumb()->setSeparator(' > '); $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');
?> ?>
<div id="leftPanel"> <div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?> <?= $this->partial('data/left.phtml'); ?>
@ -51,6 +54,12 @@
<?php if (@!is_numeric($item['mdstatus'])) : ?> <?php if (@!is_numeric($item['mdstatus'])) : ?>
<a href="/admin/review/addon/uuid/<?php echo $item['uuid'];?>">放入元数据评审</a> <a href="/admin/review/addon/uuid/<?php echo $item['uuid'];?>">放入元数据评审</a>
<?php endif; ?> <?php endif; ?>
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
<?php if(!empty($item['datasetid'])):?>
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">存档</a>
<?php else: ?>
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">添加存档</a>
<?php endif;?>
<!--<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a>--> <!--<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a>-->
</p> </p>
<!--<p>数据贡献者:<?= $item['author']; ?></p>--> <!--<p>数据贡献者:<?= $item['author']; ?></p>-->
@ -62,3 +71,6 @@
<?php endif; ?> <?php endif; ?>
<?php echo $this->paginator; ?> <?php echo $this->paginator; ?>
</div> </div>
<script>
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
</script>