实现数据文献的功能(ticket #123)

This commit is contained in:
wlx 2010-01-05 15:12:07 +00:00
parent 0cfa50d3f1
commit 68f852dbf0
9 changed files with 284 additions and 3 deletions

View File

@ -505,6 +505,97 @@ class Admin_DataController extends Zend_Controller_Action
$this->view->paginator=$paginator; $this->view->paginator=$paginator;
} }
/* /*
* 数据文献管理
*/
function referenceAction()
{
$add=(int)$this->_getParam('add');
$edit=(int)$this->_getParam('edit');
$delete=(int)$this->_getParam('delete');
$uuid=$this->_getParam('uuid');
if ($add) {
$form=new ReferenceForm();
if ($this->_request->isPost()) {
$formdata=$this->_request->getPost();
if ($form->isValid($formdata)) {
$sql="select id from reference where reference=?";
$row=$this->db->query($sql,array($formdata['reference']));
if (!$row)
{
$sql="insert into reference (reference,link) values(?,?)";
$this->db->query($sql,array($formdata['reference'],$formdata['link']));
$sql="select id from reference where reference=?";
$row=$this->db->query($sql,array($formdata['reference']));
}
$sql="insert into mdref (uuid,refid) values(?,?)";
$this->db->query($sql,array($formdata['uuid'],$row['id']));
$this->messenger->addMessage('提示信息:您已经成功添加该数据文献。');
$this->_redirect('/admin/data/reference');
}else {
$form->populate($formdata);
}
} else {
if ($uuid)
{
$formdata['uuid']=$uuid;
$form->populate($formdata);
}
}
$this->view->form=$form;
$this->_helper->viewRenderer('referenceadd');
} elseif ($edit){
$form=new ReferenceForm();
if ($this->_request->isPost()) {
$formdata=$this->_request->getPost();
if ($form->isValid($formdata)) {
$sql="select id from reference where reference=?";
$row=$this->db->query($sql,array($formdata['reference']));
if (!$row)
{
//更新文献信息
$sql="update reference set reference=?,link=? where id=?";
$param=array($formdata['reference'],$formdata['link'],$edit);
$this->db->query($sql,$param);
} else {
//更新文献链接表
$sql="update mdref set refid=? where uuid=? and refid=?";
$this->db->query($sql,array($row['id'],$formdata['uuid'],$edit));
}
$this->messenger->addMessage('提示信息:您已经编辑该数据文献。');
$this->_redirect('/admin/data/reference');
} else {
$form->populate($formdata);
}
} else {
$sql="select * from reference r left join mdref m on r.id=m.refid where r.id=?";
$formdata=$this->db->fetchRow($sql,array($edit));
$form->populate($formdata);
}
$this->view->form=$form;
$this->_helper->viewRenderer('referenceadd');
} elseif ($delete) {
$sql="delete from mdref where id=?";
try {
$this->db->query($sql,array($delete));
$this->messenger->addMessage('提示信息:您已经成功删除该数据文献。');
} catch (Exception $e) {
$this->messenger->addMessage($e->getMessage());
}
$this->_redirect("/admin/data/reference");
}
$select=$this->db->select();
$select->from('mdref',array('id as mdid','refid'))
->join('metadata','metadata.uuid=mdref.uuid')
->join('reference','reference.id=mdref.refid')
->order('reference.id desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
}
/*
* 删除元数据,删除前有确认 * 删除元数据,删除前有确认
*/ */
function deleteAction() function deleteAction()

View File

@ -1,6 +1,7 @@
<ul> <ul>
<li><a href="/admin/data/md">元数据管理</a></li> <li><a href="/admin/data/md">元数据管理</a></li>
<li><a href="/admin/data/comment">数据反馈管理</a></li> <li><a href="/admin/data/comment">数据反馈管理</a></li>
<li><a href="/admin/data/reference">数据文献管理</a></li>
<li><a href="/admin/data/import">上传元数据文件</a></li> <li><a href="/admin/data/import">上传元数据文件</a></li>
<li><a href="/admin/data/batchimport">导入服务器元数据目录</a></li> <li><a href="/admin/data/batchimport">导入服务器元数据目录</a></li>
<li><a href="/admin/data/sync">同步GeoNetwork元数据</a></li> <li><a href="/admin/data/sync">同步GeoNetwork元数据</a></li>

View File

@ -0,0 +1,46 @@
<?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/data">数据管理</a>');
$this->breadcrumb('数据文献管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<a href="/admin/data/reference/add/1">添加新的数据文献</a><?= $this->paginator; ?>
<?php if (count($this->paginator)): ?>
<div id="datasetcd">
<?php
$u='';
$i=0;
foreach ($this->paginator as $item):
if ($u==$item['uuid']) :
$i+=1;
else :
if (!empty($u)) echo '</ul>';
$i=0;
$u=$item['uuid'];
endif;
if ($i==0) echo '<ul><li>元数据:<a href="/data/'.$item['uuid'].'">'.$item['title'].'</a><a href="/admin/data/reference/add/1/uuid/'.$item['uuid'].'">添加</a></li>';
echo '<li>文献(<a href="/admin/data/reference/edit/'.$item['refid'].'">编辑</a> <a href="/admin/data/reference/delete/'.$item['mdid'].'">删除</a>'.$item['reference'].'</li>';
endforeach;
echo '</ul>';
?>
</div>
<?php endif; ?>
</div>

View File

@ -0,0 +1,46 @@
<?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/data">数据管理</a>');
$this->breadcrumb('数据文献管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<a href="/admin/data/reference/add/1">添加新的数据文献</a><?= $this->paginator; ?>
<?php if (count($this->paginator)): ?>
<div id="datasetcd">
<?php
$u='';
$i=0;
foreach ($this->paginator as $item):
if ($u==$item['uuid']) :
$i+=1;
else :
if (!empty($u)) echo '</ul>';
$i=0;
$u=$item['uuid'];
endif;
if ($i==0) echo '<ul><li>元数据:<a href="/data/'.$item['uuid'].'">'.$item['title'].'</a><a href="/admin/data/reference/add/1/uuid/'.$item['uuid'].'">添加</a></li>';
echo '<li>文献(<a href="/admin/data/reference/edit/'.$item['mdid'].'">编辑</a> <a href="/admin/data/reference/delete/'.$item['mdid'].'">删除</a>'.$item['reference'].'</li>';
endforeach;
echo '</ul>';
?>
</div>
<?php endif; ?>
</div>

View File

@ -0,0 +1,27 @@
<?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/data">数据管理</a>');
$this->breadcrumb('数据文献管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<a href="/admin/data/reference/add/1">添加新的数据文献</a>
<?= $this->form; ?>
</div>

View File

@ -0,0 +1,27 @@
<?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/data">数据管理</a>');
$this->breadcrumb('特色推荐管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<a href="/admin/data/reference/add/1">添加新的数据文献</a>
<?= $this->form; ?>
</div>

View File

@ -551,6 +551,10 @@ class DataController extends Zend_Controller_Action
$sql="select * from onlineresource where uuid=? and description<>'数据说明文档' and (linkage not like '%ftp.westgis%') and (linkage not like '%westdc%')"; $sql="select * from onlineresource where uuid=? and description<>'数据说明文档' and (linkage not like '%ftp.westgis%') and (linkage not like '%westdc%')";
$sql=$db->quoteInto($sql,$uuid); $sql=$db->quoteInto($sql,$uuid);
$this->view->resources=$db->fetchAll($sql); $this->view->resources=$db->fetchAll($sql);
//建议参考文献
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?";
$sql=$db->quoteInto($sql,$uuid);
$this->view->ref=$db->fetchAll($sql);
//相关用户 //相关用户
$sql="select p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id"; $sql="select p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id";
$this->view->authors=$db->fetchAll($sql,array($uuid)); $this->view->authors=$db->fetchAll($sql,array($uuid));

View File

@ -144,8 +144,18 @@ endforeach;
<h2>本数据引用方式</h2> <h2>本数据引用方式</h2>
<p><?php echo $this->escape($md->citation);?></p> <p><?php echo $this->escape($md->citation);?></p>
<?php endif; ?> <?php endif; ?>
<?php if ($this->ref) : ?>
<h2>建议参考文献</h2>
<ol>
<?php foreach($this->ref as $ref) :
echo '<li>'.$ref['reference'].'</li>';
endforeach;
?>
</ol>
<?php endif; ?>
<h2>数据使用声明</h2> <h2>数据使用声明</h2>
<?php if ($this->uselimits) : <?php
if ($this->uselimits) :
foreach($this->uselimits as $uselimit) : foreach($this->uselimits as $uselimit) :
echo str_replace(array("\r\n", "\n", "\r"),'</p><p>',$this->escape($uselimit['uselimit'])); echo str_replace(array("\r\n", "\n", "\r"),'</p><p>',$this->escape($uselimit['uselimit']));
endforeach; endforeach;

View File

@ -0,0 +1,29 @@
<?php
class ReferenceForm extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('Reference');
$uuid = new Zend_Form_Element_Text('uuid');
$uuid->setLabel('UUID')->setRequired(true)->addValidator('NotEmpty')
->addFilter('StripTags') ->addFilter('StringTrim');
$reference=new Zend_Form_Element_Text('reference');
$reference->setLabel('文献')
->setRequired(true)
->addFilter('StringTrim')
->addValidator('NotEmpty');
$link=new Zend_Form_Element_Text('link');
$link->setLabel('URL(optional)')
->addFilter('StringTrim');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton')->setLabel('发送');
$this->addElements(array($uuid,$reference,$link,$submit));
}
}