Ticket #190 增加了元数据选择附件的功能

This commit is contained in:
Li Jianxuan 2011-09-29 07:55:05 +00:00
parent 10c9736c6e
commit a97d92402b
4 changed files with 164 additions and 3 deletions

View File

@ -232,6 +232,7 @@ class Admin_DataController extends Zend_Controller_Action
$down=(int)$this->_getParam('down');
$search = $this->_getParam('search');
$keyword = $this->_getParam('keyword');
$att=$this->_getParam('att');
if ($delete)
{
@ -243,7 +244,81 @@ class Admin_DataController extends Zend_Controller_Action
$this->messenger->addMessage($e->getMessage());
}
$this->_redirect("/admin/data/md");
} elseif ($down) {
}//删除
elseif($att>0){
$submit=$this->_request->getParam('submit');
$uuid=$this->_request->getParam('uuid');
$atts=$this->_request->getParam('ids');
$addatts=$this->_request->getParam('addatts');
$this->view->id = $att;
$this->view->uuid = $uuid;
if(!empty($addatts))
{
if(empty($submit))
{
$sql = "select title from metadata where uuid='$uuid'";
$re = $this->db->query($sql);
$rows = $re->fetch();
$this->view->id = $att;
$this->view->uuid = $uuid;
$this->view->mdtitle = $rows['title'];
$this->view->thisatt = $rows;
$this->_redirect("/admin/data/attachments/uuid/$uuid/mdtitle/{$rows['title']}");
}
else
{
if(!empty($uuid))
{
foreach($atts as $v)
{
$sql = "insert into mdattach (uuid,id) values ('$uuid','$v')";
try{
$this->db->exec($sql);
$this->messenger->addMessage('成功添加附件:'.$v);
}catch (Exception $e)
{
$this->messenger->addMessage('添加附件失败:'.$v);
}
}
$this->_redirect("/admin/data/md/att/1/uuid/$uuid");
}
}
}//empty($addatts)
else
{
if(!empty($uuid))
{
$sql = "select m.*,a.*,d.title from mdattach m
left join attachments a on m.id = a.id
left join metadata d on m.uuid=d.uuid where m.uuid='$uuid'";
$re = $this->db->query($sql);
$rows = $re->fetchAll();
$sql = "select title from metadata where uuid='$uuid'";
$re = $this->db->query($sql);
$title = $re->fetch();
$this->view->atts=$rows;
$this->view->mdtitle = $title['title'];
$this->_helper->viewRenderer('attmanager');
}
}
}//编辑附件
elseif ($down) {
$zip = new ZipArchive();
$url="/tmp/xml.zip";
$opened=$zip->open($url, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
@ -734,6 +809,14 @@ class Admin_DataController extends Zend_Controller_Action
$delete = $this->_request->getParam('delete');
$edit = $this->_request->getParam('edit');
$down = $this->_request->getParam('down');
$uuid = $this->_request->getParam('uuid');
$mdtitle = $this->_request->getParam('mdtitle');
if(!empty($uuid)&&!empty($mdtitle))
{
$this->view->uuid= $uuid;
$this->view->mdtitle=$mdtitle;
}
if($add && empty($edit))
{
@ -938,6 +1021,7 @@ class Admin_DataController extends Zend_Controller_Action
else
{
$sql="select * from attachments order by id desc";
$re= $this->db->query($sql);
$rows = $re->fetchAll();

View File

@ -38,8 +38,13 @@
</div><!-- search DIV -->
<?php if (count($this->paginator)): ?>
<form method="get" action="/admin/data/md/att/1/addatts/1">
<table>
<thead><tr>
<?php
if(!empty($this->uuid))
echo '<th width="40">选择</th>';
?>
<th width='300'>描述</th>
<th width='80'>类型</th>
<th width='80'>大小</th>
@ -52,6 +57,10 @@
<?php foreach ($this->paginator as $item): ?>
<?php $autoindex++;?>
<tr <?php if($autoindex%2 == 0) echo 'bgcolor="#CCCCCC"'; else echo 'bgcolor="#FFFFFF"'; ?>>
<?php
if(!empty($this->uuid))
echo '<td><input type="checkbox" value="'.$item['id'].'" name="ids[]" /></td>';
?>
<td><?php echo $item['filedesc'] ;?></td>
<td><?php
if($item['filetype']=='image') echo '图片' ;
@ -68,7 +77,13 @@
</td>
</tr>
<?php endforeach; ?>
</tbody></table>
</tbody>
</table>
<?php
if(!empty($this->uuid))
echo '<input type="hidden" name="uuid" value="'.$this->uuid.'" /><input type="hidden" name="submit" value="1" /><input type="submit" value="将已选择的附件添加到《'.$this->mdtitle.'》" />';
?>
</form>
<?php endif; ?>
<div style="width:50%;text-align:left;">
<?= $this->paginator; ?>

View File

@ -0,0 +1,62 @@
<?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('数据管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<?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; ?>
<div id="rightPanel">
<div><a href="/admin/data/md/att/1/uuid/<?php echo $this->uuid;?>/addatts/1/mdtitle/<?php echo $this->mdtitle ;?>">为此元数据添加附件</a></div>
<table>
<thead><tr>
<th width='300'>描述</th>
<th width='80'>类型</th>
<th width='80'>大小</th>
<th width='80'>下载次数</th>
<th width='150'>上传时间</th>
<th width="150">操作</th>
</tr></thead>
<tbody>
<?php
foreach ($this->atts as $v)
{
if($v['filesize']<1048576) $v['filesize'] = round(($v['filesize']/1024),2).'KB'; else $v['filesize'] = round(($v['filesize']/1024/1024),2).'MB';
echo '
<tr>
<td>'.$v['filedesc'].'</td>
<td>'.$v['filetype'].'</td>
<td>'.$v['filesize'].'</td>
<td>'.$v['downtimes'].'</td>
<td>'.date('Y-m-d H:i:s',strtotime($v['ts_created'])).'</td>
<td>
<a href="/admin/data/attachments/" onclick="return confirm(\'是否确定删除该附件?\')">从此元数据中移除</a>
</td>
</tr>';
}
?>
</tbody></table>
<div style="width:50%;text-align:left;">
</div>
</div>
</div>

View File

@ -44,7 +44,7 @@
,查看:<?= $item['viewed']; ?>次。 操作:
<a href="<?= $this->config->geonetwork->url; ?>srv/cn/metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a>
<a href="/admin/data/md/delete/<?= $item['id']; ?>">删除</a>
<a href="/admin/data/sync/uuid/<?= $item['uuid']; ?>">同步</a> </li>
<a href="/admin/data/sync/uuid/<?= $item['uuid']; ?>">同步</a> <a href="/admin/data/md/att/1/uuid/<?php echo $item['uuid'];?>">附件管理</a></li>
<li>数据贡献者:<?= $item['author']; ?></li>
<li><?= $item['description']; ?></li>
</ul>