From 6a6d968e97dc9a95482e5003c2e46ab0e27b3d70 Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 21 Sep 2011 09:13:33 +0000
Subject: [PATCH] =?UTF-8?q?fix=20ticket=20#144,=20=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E5=88=B0word=E7=9A=84=E8=BD=AC?=
=?UTF-8?q?=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/DataController.php | 70 ++++++++++++++++++-
.../default/views/scripts/data/view.phtml | 2 +-
2 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php
index 28a1d412..15400ead 100755
--- a/application/default/controllers/DataController.php
+++ b/application/default/controllers/DataController.php
@@ -1263,8 +1263,74 @@ class DataController extends Zend_Controller_Action
print "
";
}
- }
-
+ }
+ /*
+ * 转换元数据为WORD DOC格式
+ */
+ public function docAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $ua = $_SERVER["HTTP_USER_AGENT"];
+ $uuid=$this->_request->getParam('uuid');
+ if (!empty($uuid))
+ {
+ $sql="select x.data,m.title,m.description,g.id from xml x left join metadata m on m.id=x.id left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid);
+ $row=$this->db->fetchRow($sql);
+ }
+
+ $dom = new DOMDocument();
+ $dom->loadXML($row['data']);
+ //提前对表格进行预处理
+ $abs=$this->parseTable($this->view->escape($row["description"]));
+ //处理外部链接
+ $abs=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','$2',$abs);
+ $abs=str_replace(array("\r\n", "\n", "\r"),'
',$abs);
+ $abs=str_replace("'","'",$abs);//not needed?
+ $id = $row['id'];
+ $xslt = new XSLTProcessor();
+ $xslt->registerPHPFunctions();
+ $xslt->setParameter('', 'id', $id);
+ $xslt->setParameter('', 'abstract', $abs);
+ $XSL = new DOMDocument();
+ $XSL->load( '../data/doc.xsl', LIBXML_NOCDATA);
+ $xslt->importStylesheet($XSL);
+ $content='
+
';
+ $content.=''.$row['title'].'';
+ $content.='
+
+ ';
+ $content.=$xslt->transformToXML($dom);
+ $content.="";
+ $this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
+ ->setHeader('Content-Disposition','attachment; filename="'.$row['title'].'.doc"')
+ ->setHeader('Content-Length', strlen($content))
+ ->setHeader('Content-Type','application/force-download')
+ ->setHeader('Content-Type','application/download')
+ ->setHeader('Content-Description','File Transfer')
+ ->setHeader('Content-Transfer-Encoding','binary')
+ ->setHeader('Expires',0)
+ ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
+ ->setHeader('Pragma','public')
+ ->setBody($content);
+ }
/**
* parse the wiki syntax used to render tables, code modified from mediawiki
*
diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml
index 31af2d62..991d6633 100755
--- a/application/default/views/scripts/data/view.phtml
+++ b/application/default/views/scripts/data/view.phtml
@@ -139,7 +139,7 @@ endforeach;
- - 元数据更新时间:ts_created)); ?>
+ - 元数据更新时间:ts_created)); ?>