#397 文献管理中增加“添加数据中心文献”和“查看数据中心文献”功能

This commit is contained in:
Li Jianxuan 2012-09-05 03:03:37 +00:00
parent 1493169ad4
commit 314664fb97
3 changed files with 79 additions and 51 deletions

View File

@ -738,35 +738,42 @@ class Admin_DataController extends Zend_Controller_Action
$show = $this->_getParam('show'); $show = $this->_getParam('show');
if ($add) { if ($add) {
$form=new ReferenceForm(); $type = $this->_getParam('type');
if ($this->_request->isPost()) { if($type == 'dc')
$formdata=$this->_request->getPost(); {
if ($form->isValid($formdata)) { $this->_helper->viewRenderer('referenceadd');
$sql="select id from reference where reference=?"; $this->view->type = "dc";
$row=$this->db->fetchRow($sql,array(trim($formdata['reference']))); }else{
if (!$row) $form=new ReferenceForm();
{ if ($this->_request->isPost()) {
$sql="insert into reference (reference,link) values(?,?)"; $formdata=$this->_request->getPost();
$this->db->query($sql,array(trim($formdata['reference']),trim($formdata['link']))); if ($form->isValid($formdata)) {
$sql="select id from reference where reference=?"; $sql="select id from reference where reference=?";
$row=$this->db->fetchRow($sql,array(trim($formdata['reference']))); $row=$this->db->fetchRow($sql,array(trim($formdata['reference'])));
if (!$row)
{
$sql="insert into reference (reference,link) values(?,?)";
$this->db->query($sql,array(trim($formdata['reference']),trim($formdata['link'])));
$sql="select id from reference where reference=?";
$row=$this->db->fetchRow($sql,array(trim($formdata['reference'])));
}
$sql="insert into mdref (uuid,refid,reftype) values(?,?,?)";
$this->db->query($sql,array(trim($formdata['uuid']),$row['id'],$formdata['reftype']));
$this->messenger->addMessage('提示信息:您已经成功添加该数据文献。');
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
}else {
$form->populate($formdata);
}
} else {
if ($uuid)
{
$formdata['uuid']=$uuid;
$form->populate($formdata);
} }
$sql="insert into mdref (uuid,refid,reftype) values(?,?,?)";
$this->db->query($sql,array(trim($formdata['uuid']),$row['id'],$formdata['reftype']));
$this->messenger->addMessage('提示信息:您已经成功添加该数据文献。');
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
}else {
$form->populate($formdata);
}
} else {
if ($uuid)
{
$formdata['uuid']=$uuid;
$form->populate($formdata);
} }
$this->view->form=$form;
$this->_helper->viewRenderer('referenceadd');
} }
$this->view->form=$form;
$this->_helper->viewRenderer('referenceadd');
} //添加 } //添加
else if($show){ else if($show){

View File

@ -37,7 +37,9 @@
<div class="controlplan"> <div class="controlplan">
<a href="/admin/data/reference/add/1">添加新的数据文献</a> <a href="/admin/data/reference/add/1">添加新的数据文献</a>
| <a href="/admin/data/reference/add/1/type/dc">添加数据中心文献</a>
| <a href="/admin/data/reference/import/1">导入数据文献文件</a> | <a href="/admin/data/reference/import/1">导入数据文献文件</a>
| <a href="/admin/data/reference/show/e31f5ea7-a4af-4ae3-9ac1-1a84132c4338">查看数据中心文献</a>
</div> </div>
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>

View File

@ -1,28 +1,47 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('后台管理'); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css'); $this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>'); $this->breadcrumb('<a href="/admin">后台首页</a>');
$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(' > ');
?> ?>
<div id="leftPanel"> <div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?> <?= $this->partial('data/left.phtml'); ?>
</div> </div>
<div id="rightPanel"> <div id="rightPanel">
<?php if ($this->msg or $this->messages) :?> <?php if ($this->msg or $this->messages) :?>
<div id="message"> <div id="message">
<?php if ($this->msg) : ?> <?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p> <p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?> <?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p> <p><?php echo $msg; ?></p>
<?php endforeach;endif; ?> <?php endforeach;endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<a href="/admin/data/reference/add/1">添加新的数据文献</a> <a href="/admin/data/reference/add/1">添加新的数据文献</a>
| <a href="/admin/data/reference/import/1">导入数据文献文件</a> | <a href="/admin/data/reference/add/1/type/dc">添加数据中心文献</a>
<?= $this->form; ?> | <a href="/admin/data/reference/import/1">导入数据文献文件</a>
| <a href="/admin/data/reference/show/e31f5ea7-a4af-4ae3-9ac1-1a84132c4338">查看数据中心文献</a>
<?php
if($this->type == 'dc')
{?>
<form id="Reference" enctype="application/x-www-form-urlencoded" action="/admin/data/reference/add/1/" method="post"><dl class="zend_form">
<input type="hidden" name="uuid" id="uuid" value="e31f5ea7-a4af-4ae3-9ac1-1a84132c4338" readonly="readonly">
<dt id="reference-label"><label for="reference" class="required">文献</label></dt>
<dd id="reference-element">
<input type="text" name="reference" id="reference" value=""></dd>
<dt id="link-label"><label for="link" class="optional">URL(optional)</label></dt>
<dd id="link-element">
<input type="text" name="link" id="link" value=""></dd>
<dt id="reftype-label"><label class="required">文献类型</label></dt>
<dd id="reftype-element">
<label for="reftype-0"><input type="radio" name="reftype" id="reftype-0" value="0" checked="checked">作者文献</label><br /><label for="reftype-1"><input type="radio" name="reftype" id="reftype-1" value="1">用户文献</label></dd>
<dt id="submit-label">&#160;</dt><dd id="submit-element">
<input type="submit" name="submit" id="submitbutton" value="发送"></dd></dl></form>
<?php }
else ?><?= $this->form; ?>
</div> </div>