添加数据文献类型支持,修复编辑混乱问题

This commit is contained in:
wlx 2012-05-19 13:55:50 +00:00
parent 0628745e69
commit 4e7639cd53
3 changed files with 14 additions and 20 deletions

View File

@ -607,8 +607,8 @@ class Admin_DataController extends Zend_Controller_Action
$sql="select id from reference where reference=?";
$row=$this->db->fetchRow($sql,array(trim($formdata['reference'])));
}
$sql="insert into mdref (uuid,refid) values(?,?)";
$this->db->query($sql,array(trim($formdata['uuid']),$row['id']));
$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 {
@ -653,8 +653,8 @@ class Admin_DataController extends Zend_Controller_Action
if ($row['id']!='')
{
//更新文献信息
$sql="update mdref set refid=? where uuid=? and refid=?";
$td = $this->db->query($sql,array($row['id'],$formdata['uuid'],$edit));
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
$sql="update reference set reference=?,link=? where id=?";
$this->db->query($sql,array($formdata['reference'],$formdata['link'],$row['id']));
if($td)
@ -668,19 +668,11 @@ class Admin_DataController extends Zend_Controller_Action
$sth = $this->db->prepare($sql);
if($sth->execute())
{
$temp = $sth->fetch(PDO::FETCH_ASSOC);
$sql = "INSERT INTO mdref (uuid,refid) VALUES ('".$formdata['uuid']."','".$temp['id']."')";
if($this->db->exec($sql))
{
$sql = "DELETE FROM mdref where uuid='".$formdata['uuid']."' and refid='$edit'";
@$this->db->exec($sql);
$this->messenger->addMessage('提示信息:您已经编辑该数据文献。');
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
}else
{
$this->messenger->addMessage('提示信息:文献关联失败,请重试');
$this->_redirect('/admin/data/reference/edit/'.$edit);
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
$this->messenger->addMessage('提示信息:您已经编辑该数据文献。');
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
}else
{
$this->messenger->addMessage('提示信息:文献创建失败,请重试');
@ -691,7 +683,7 @@ class Admin_DataController extends Zend_Controller_Action
$form->populate($formdata);
}
} else {
$sql="select m.uuid,r.reference,r.link from reference r left join mdref m on r.id=m.refid where r.id=?";
$sql="select m.uuid,r.reference,r.link,m.reftype from reference r left join mdref m on r.id=m.refid where m.id=?";
$formdata=$this->db->fetchRow($sql,array($edit));
$form->populate($formdata);
}

View File

@ -54,7 +54,7 @@ foreach ($this->paginator as $item):
$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>';
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>';
?>

View File

@ -21,9 +21,11 @@ class ReferenceForm extends Zend_Form
$link=new Zend_Form_Element_Text('link');
$link->setLabel('URL(optional)')
->addFilter('StringTrim');
$reftype=new Zend_Form_Element_Radio('reftype');
$reftype->setRequired(true)->setLabel('文献类型')->setMultiOptions(array('0'=>'作者文献','1'=>'用户文献'))->setValue(0);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton')->setLabel('发送');
$this->addElements(array($uuid,$reference,$link,$submit));
$this->addElements(array($uuid,$reference,$link,$reftype,$submit));
}
}