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 @@ '; + $i=0; + $u=$item['uuid']; + endif; + if ($i==0) echo ''; +?> + + + \ No newline at end of file diff --git a/application/admin/views/scripts/data/reference.phtml~ b/application/admin/views/scripts/data/reference.phtml~ new file mode 100644 index 00000000..58843297 --- /dev/null +++ b/application/admin/views/scripts/data/reference.phtml~ @@ -0,0 +1,46 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('数据管理'); + $this->breadcrumb('数据文献管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('data/left.phtml'); ?> +
+
+msg or $this->messages) :?> +
+msg) : ?> +

msg; ?>

+messages): foreach($this->messages as $msg): ?> +

+ +
+ +添加新的数据文献paginator; ?> +paginator)): ?> +
+paginator as $item): + if ($u==$item['uuid']) : + $i+=1; + else : + if (!empty($u)) echo ''; + $i=0; + $u=$item['uuid']; + endif; + if ($i==0) echo ''; +?> +
+ +
\ No newline at end of file diff --git a/application/admin/views/scripts/data/referenceadd.phtml b/application/admin/views/scripts/data/referenceadd.phtml new file mode 100644 index 00000000..cb535379 --- /dev/null +++ b/application/admin/views/scripts/data/referenceadd.phtml @@ -0,0 +1,27 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('数据管理'); + $this->breadcrumb('数据文献管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('data/left.phtml'); ?> +
+
+msg or $this->messages) :?> +
+msg) : ?> +

msg; ?>

+messages): foreach($this->messages as $msg): ?> +

+ +
+ +添加新的数据文献 +form; ?> +
\ No newline at end of file diff --git a/application/admin/views/scripts/data/referenceadd.phtml~ b/application/admin/views/scripts/data/referenceadd.phtml~ new file mode 100644 index 00000000..bffea142 --- /dev/null +++ b/application/admin/views/scripts/data/referenceadd.phtml~ @@ -0,0 +1,27 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('数据管理'); + $this->breadcrumb('特色推荐管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('data/left.phtml'); ?> +
+
+msg or $this->messages) :?> +
+msg) : ?> +

msg; ?>

+messages): foreach($this->messages as $msg): ?> +

+ +
+ +添加新的数据文献 +form; ?> +
\ No newline at end of file diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 8dcd8bee..b1ce9572 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -551,6 +551,10 @@ class DataController extends Zend_Controller_Action $sql="select * from onlineresource where uuid=? and description<>'数据说明文档' and (linkage not like '%ftp.westgis%') and (linkage not like '%westdc%')"; $sql=$db->quoteInto($sql,$uuid); $this->view->resources=$db->fetchAll($sql); + //建议参考文献 + $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?"; + $sql=$db->quoteInto($sql,$uuid); + $this->view->ref=$db->fetchAll($sql); //相关用户 $sql="select p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id"; $this->view->authors=$db->fetchAll($sql,array($uuid)); diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml index 44149535..245d560e 100755 --- a/application/default/views/scripts/data/view.phtml +++ b/application/default/views/scripts/data/view.phtml @@ -144,8 +144,18 @@ endforeach;

本数据引用方式

escape($md->citation);?>

-

数据使用声明

-uselimits) : +ref) : ?> +

建议参考文献

+
    + ref as $ref) : + echo '
  1. '.$ref['reference'].'
  2. '; + endforeach; + ?> +
+ +

数据使用声明

+uselimits) : foreach($this->uselimits as $uselimit) : echo str_replace(array("\r\n", "\n", "\r"),'

',$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