实现新建元数据的模板和数据分离

This commit is contained in:
wlx 2012-05-04 16:26:03 +00:00
parent 4e225fb02b
commit 74584ae00f
3 changed files with 121 additions and 42 deletions

View File

@ -2071,18 +2071,44 @@ class AuthorController extends Zend_Controller_Action
$this->_helper->viewRenderer('newdata-import');
}
//从模板新建元数据
else if($ac=="add")
else if($ac=="add-by-template")
{
$keywords = $this->_request->getParam('q');
$sql="select id,(regexp_matches(data,'<resTitle>(.*)</resTitle>'))[1] as title,(owner-$u_id) as isowner from metadata where istemplate='y' and schemaid='iso19115'";
if(!empty($keywords))
{
$this->view->q = $keywords;
$search=new Search($keywords);
$where=$search->sql_expr(array("data"));
$sql.=' and '.$where;
}
$sql.=" order by changedate desc";
$sth = $this->wdb->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->_helper->viewRenderer('newdata-add');
}
else if($ac=="add-by-data")
{
$keywords = $this->_request->getParam('q');
$sql = "SELECT md.title,md.uuid,md.description,gn.id as gid FROM normalmetadata md
left join geonetworkmetadata gn on md.uuid=gn.uuid
WHERE gn.id is not null";
if(!empty($keywords))
{
$this->view->q = $keywords;
$search=new Search($keywords);
$where=$search->sql_expr(array("md.title","md.description"));
$sql.=' and '.$where;
}
$sql.=" order by md.ts_created desc";
$sth = $this->db->prepare($sql);
$sth->execute();
@ -2094,14 +2120,8 @@ class AuthorController extends Zend_Controller_Action
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('newdata-add-bydata');
}
$sql="select id,(regexp_matches(data,'<resTitle>(.*)</resTitle>'))[1] as title from metadata where istemplate='y' and schemaid='iso19115'";
$sth=$this->wdb->prepare($sql);
$sth->execute();
$this->view->templates=$sth->fetchAll();
$this->_helper->viewRenderer('newdata-add');
}
//提交数据
else if($ac=="commit")
{

View File

@ -0,0 +1,63 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('新建数据');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow"><a class="text-shadow" href="/author/newdata">未提交数据列表</a></li>
<li class="box-shadow"><a class="text-shadow iframe" href="/service/geonetwork?url=metadata.xmlinsert.form">导入元数据</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/newdata/ac/add-by-template">根据模板新建元数据</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/author/newdata/ac/add-by-data">根据已有数据新建元数据</a></li>
</ul>
</div>
<div id="datalist">
<h2>根据已有数据创建元数据</h2>
<form id="datasearch" class="search_form" action="/author/newdata/ac/add-by-data">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
<?php
if (count($this->paginator)):
echo "<ul>";
$autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;
?>
<li>
<p><span class="title"><?php echo $item['title'];?></span>
<a href="/service/geonetwork?url=metadata.create?group=2<?php echo urlencode('&id='.$item['gid']); ?>">以此为模板新建</a>
| <a href="/data/<?php echo $item['uuid'];?>" target="_blank">查看数据</a></p>
<p><?php echo mb_strlen($item['description'])>400?$this->escape(mb_substr($item['description'],0,400,'UTF-8').'...'):$this->escape($item['description']); ?></p>
</li>
<?php
endforeach;
echo "</ul>";
endif; ?>
</div>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<!-- //页面内容 -->
<script>
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
$('#wapper').width($('body').width()-300);
</script>

View File

@ -25,21 +25,14 @@ $this->breadcrumb()->setSeparator(' > ');
<ul>
<li class="box-shadow"><a class="text-shadow" href="/author/newdata">未提交数据列表</a></li>
<li class="box-shadow"><a class="text-shadow iframe" href="/service/geonetwork?url=metadata.xmlinsert.form">导入元数据</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/author/newdata/ac/add">新建元数据</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/author/newdata/ac/add-by-template">根据模板新建元数据</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/newdata/ac/add-by-data">根据已有数据新建元数据</a></li>
</ul>
</div>
<div id="datalist">
<?php if ($this->templates) : ?>
<h2>根据预制元数据模板创建数据</h2>
<ul>
<?php foreach ($this->templates as $item) : ?>
<li><a href="/service/geonetwork?url=metadata.create?group=2<?php echo urlencode('&id='.$item['id']); ?>" target="_blank"><?php echo $item['title']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<h2>根据已有元数据来创建数据</h2>
<form id="datasearch" class="search_form" action="/author/newdata/ac/add">
<form id="datasearch" class="search_form" action="/author/newdata/ac/add-by-template">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
@ -52,9 +45,12 @@ $this->breadcrumb()->setSeparator(' > ');
?>
<li>
<p><span class="title"><?php echo $item['title'];?></span>
<a href="/service/geonetwork?url=metadata.create?group=2<?php echo urlencode('&id='.$item['gid']); ?>">以此为模板新建</a>
| <a href="/data/<?php echo $item['uuid'];?>" target="_blank">查看数据</a></p>
<p><?php echo mb_strlen($item['description'])>400?$this->escape(mb_substr($item['description'],0,400,'UTF-8').'...'):$this->escape($item['description']); ?></p>
<a href="/service/geonetwork?url=metadata.create?group=2<?php echo urlencode('&id='.$item['id']); ?>" target="_blank">以此为模板新建</a>
<?php if ($this->isadmin || $item['isowner']==0) : ?>
| <a href="/service/geonetwork?url=metadata.edit?id=<?php echo $item['id'];?>" target="_blank">修改此模板</a>
| <a href="/service/geonetwork?url=metadata.show?id=<?php echo $item['id'];?>" target="_blank">查看此模板</a>
<?php endif; ?>
</p>
</li>
<?php
endforeach;