From b431fa7f1088c474cc824bd7bb366d0f4b0d5f9e Mon Sep 17 00:00:00 2001 From: wlx Date: Sat, 26 Nov 2011 10:51:45 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=87=E7=8C=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=87=E4=BB=B6=E5=AF=BC=E5=85=A5=20#261?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/DataController.php | 30 ++++++++++++++-- .../admin/views/scripts/data/reference.phtml | 2 +- .../views/scripts/data/referenceadd.phtml | 1 + .../views/scripts/data/referenceimport.phtml | 34 +++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 application/admin/views/scripts/data/referenceimport.phtml diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 38c8b765..b75ed94a 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -552,7 +552,8 @@ class Admin_DataController extends Zend_Controller_Action $delete=(int)$this->_getParam('delete'); $uuid=$this->_getParam('uuid'); $search=$this->_getParam('search'); - $keyword=$this->_getParam('keyword'); + $keyword=$this->_getParam('keyword'); + $import=(int)$this->_getParam('import'); if ($add) { $form=new ReferenceForm(); @@ -623,6 +624,31 @@ class Admin_DataController extends Zend_Controller_Action $this->messenger->addMessage($e->getMessage()); } $this->_redirect("/admin/data/reference"); + } elseif ($import) { + if ($this->_request->isPost()) { + if ($_FILES["ref"]["error"] == UPLOAD_ERR_OK) { + $tmp_name = $_FILES["ref"]["tmp_name"]; + $fp = fopen($tmp_name, "rb"); + $ref=fread($fp, filesize($tmp_name)); + fclose($fp); + $lines=explode("\n",$ref); + foreach($lines as $line) + { + $data=explode(";",$line); + $sql="insert into reference (reference) values(?)"; + try { + $this->db->exec($this->db->quoteInto($sql,$data[1])); + } catch (Exception $e) {} + $sql="select id from reference where reference=?"; + $row=$this->db->fetchRow($this->db->quoteInto($sql,$data[1])); + $sql="insert into mdref (uuid,refid) values(?,".$row['id'].")"; + try { + $this->db->exec($this->db->quoteInto($sql,$data[0])); + } catch (Exception $e) {} + } + }//end if + } + $this->_helper->viewRenderer('referenceimport'); } else if($search){ if(!empty($keyword)) { @@ -711,7 +737,7 @@ class Admin_DataController extends Zend_Controller_Action //move_uploaded_file($tmp_name, "../data/import/$name"); }//end if }//foreach - $this->_redirect('/metadata'); + $this->_redirect('/data'); } else { //do nothing now. } diff --git a/application/admin/views/scripts/data/reference.phtml b/application/admin/views/scripts/data/reference.phtml index f2e99268..dcb764eb 100644 --- a/application/admin/views/scripts/data/reference.phtml +++ b/application/admin/views/scripts/data/reference.phtml @@ -37,7 +37,7 @@
添加新的数据文献 - + | 导入数据文献文件
paginator)): ?> diff --git a/application/admin/views/scripts/data/referenceadd.phtml b/application/admin/views/scripts/data/referenceadd.phtml index cb535379..0c3e3049 100644 --- a/application/admin/views/scripts/data/referenceadd.phtml +++ b/application/admin/views/scripts/data/referenceadd.phtml @@ -23,5 +23,6 @@ 添加新的数据文献 +| 导入数据文献文件 form; ?> \ No newline at end of file diff --git a/application/admin/views/scripts/data/referenceimport.phtml b/application/admin/views/scripts/data/referenceimport.phtml new file mode 100644 index 00000000..f8200879 --- /dev/null +++ b/application/admin/views/scripts/data/referenceimport.phtml @@ -0,0 +1,34 @@ +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): ?> +

+ +
+ +添加新的数据文献 | 导入数据文献文件 +
+ + + + 上传数据文献文件:
+
+ +
+
\ No newline at end of file