diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 229e473e..977131ae 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -503,7 +503,98 @@ class Admin_DataController extends Zend_Controller_Action $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $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; + } /* * 删除元数据,删除前有确认 */ diff --git a/application/admin/views/scripts/data/left.phtml b/application/admin/views/scripts/data/left.phtml index edcc15d2..84283e84 100644 --- a/application/admin/views/scripts/data/left.phtml +++ b/application/admin/views/scripts/data/left.phtml @@ -1,6 +1,7 @@
msg; ?>
+messages): foreach($this->messages as $msg): ?> + + +msg; ?>
+messages): foreach($this->messages as $msg): ?> + + +msg; ?>
+messages): foreach($this->messages as $msg): ?> + + +msg; ?>
+messages): foreach($this->messages as $msg): ?> + + +escape($md->citation);?>
-',$this->escape($uselimit['uselimit'])); endforeach; diff --git a/application/models/ReferenceForm.php b/application/models/ReferenceForm.php new file mode 100644 index 00000000..bf5e2c86 --- /dev/null +++ b/application/models/ReferenceForm.php @@ -0,0 +1,29 @@ +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)); + } +} \ No newline at end of file