添加数据文献类型支持,修复编辑混乱问题
This commit is contained in:
parent
0628745e69
commit
4e7639cd53
|
@ -607,8 +607,8 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$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'])));
|
||||||
}
|
}
|
||||||
$sql="insert into mdref (uuid,refid) values(?,?)";
|
$sql="insert into mdref (uuid,refid,reftype) values(?,?,?)";
|
||||||
$this->db->query($sql,array(trim($formdata['uuid']),$row['id']));
|
$this->db->query($sql,array(trim($formdata['uuid']),$row['id'],$formdata['reftype']));
|
||||||
$this->messenger->addMessage('提示信息:您已经成功添加该数据文献。');
|
$this->messenger->addMessage('提示信息:您已经成功添加该数据文献。');
|
||||||
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
|
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
|
||||||
}else {
|
}else {
|
||||||
|
@ -653,8 +653,8 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
if ($row['id']!='')
|
if ($row['id']!='')
|
||||||
{
|
{
|
||||||
//更新文献信息
|
//更新文献信息
|
||||||
$sql="update mdref set refid=? where uuid=? and refid=?";
|
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
|
||||||
$td = $this->db->query($sql,array($row['id'],$formdata['uuid'],$edit));
|
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||||
$sql="update reference set reference=?,link=? where id=?";
|
$sql="update reference set reference=?,link=? where id=?";
|
||||||
$this->db->query($sql,array($formdata['reference'],$formdata['link'],$row['id']));
|
$this->db->query($sql,array($formdata['reference'],$formdata['link'],$row['id']));
|
||||||
if($td)
|
if($td)
|
||||||
|
@ -668,19 +668,11 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$sth = $this->db->prepare($sql);
|
$sth = $this->db->prepare($sql);
|
||||||
if($sth->execute())
|
if($sth->execute())
|
||||||
{
|
{
|
||||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$sql = "INSERT INTO mdref (uuid,refid) VALUES ('".$formdata['uuid']."','".$temp['id']."')";
|
$sql="update mdref set refid=?,reftype=? where uuid=? and id=?";
|
||||||
if($this->db->exec($sql))
|
$td = $this->db->query($sql,array($row['id'],$formdata['reftype'],$formdata['uuid'],$edit));
|
||||||
{
|
$this->messenger->addMessage('提示信息:您已经编辑该数据文献。');
|
||||||
$sql = "DELETE FROM mdref where uuid='".$formdata['uuid']."' and refid='$edit'";
|
$this->_redirect('/admin/data/reference/show/'.$formdata['uuid']);
|
||||||
@$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);
|
|
||||||
}
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('提示信息:文献创建失败,请重试');
|
$this->messenger->addMessage('提示信息:文献创建失败,请重试');
|
||||||
|
@ -691,7 +683,7 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$form->populate($formdata);
|
$form->populate($formdata);
|
||||||
}
|
}
|
||||||
} else {
|
} 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));
|
$formdata=$this->db->fetchRow($sql,array($edit));
|
||||||
$form->populate($formdata);
|
$form->populate($formdata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ foreach ($this->paginator as $item):
|
||||||
$u=$item['uuid'];
|
$u=$item['uuid'];
|
||||||
endif;
|
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>';
|
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;
|
endforeach;
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -21,9 +21,11 @@ class ReferenceForm extends Zend_Form
|
||||||
$link=new Zend_Form_Element_Text('link');
|
$link=new Zend_Form_Element_Text('link');
|
||||||
$link->setLabel('URL(optional)')
|
$link->setLabel('URL(optional)')
|
||||||
->addFilter('StringTrim');
|
->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 = new Zend_Form_Element_Submit('submit');
|
||||||
$submit->setAttrib('id', 'submitbutton')->setLabel('发送');
|
$submit->setAttrib('id', 'submitbutton')->setLabel('发送');
|
||||||
$this->addElements(array($uuid,$reference,$link,$submit));
|
$this->addElements(array($uuid,$reference,$link,$reftype,$submit));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue