#180 解决输出doc格式文档时IE中乱码的问题

This commit is contained in:
Li Jianxuan 2012-09-19 03:02:52 +00:00
parent edf2cfca6b
commit 872b31732c
1 changed files with 71 additions and 58 deletions

View File

@ -332,11 +332,24 @@ class ServiceController extends Zend_Controller_Action
</style> </style>
</head> </head>
<body>'; <body>';
$dispostion = 'attachment; filename*="utf8\' \''.urlencode($row['title']).'.doc"';
$ua = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/MSIE/", $ua)) {
$dispostion = 'attachment; filename="'.urlencode($row['title']).'.doc"';
} else if (preg_match("/Firefox/", $ua)) {
$dispostion;
} else {
$dispostion = 'attachment; filename*="'.urlencode($row['title']).'.doc"';
}
$content.=$xslt->transformToXML($dom); $content.=$xslt->transformToXML($dom);
if ($review==1) $content.=file_get_contents('../data/review-table.htm',true); if ($review==1) $content.=file_get_contents('../data/review-table.htm',true);
$content.="</body></html>"; $content.="</body></html>";
$this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc') $this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
->setHeader('Content-Disposition','attachment; filename="'.$row['title'].'.doc"') ->setHeader('Content-Disposition',$dispostion)
->setHeader('Content-Length', strlen($content)) ->setHeader('Content-Length', strlen($content))
->setHeader('Content-Type','application/force-download') ->setHeader('Content-Type','application/force-download')
->setHeader('Content-Type','application/download') ->setHeader('Content-Type','application/download')
@ -1052,7 +1065,7 @@ class ServiceController extends Zend_Controller_Action
{ {
if($page > 0) if($page > 0)
{ {
$pre = '<div class="pagnv"><a href="javascript:void(0);" onclick="recommend('. ($page-1) .')" class="pleft"><img src="/images/scroll_left.gif" /></a></div>'; $pre = '<div class="pagnv"><a href="javascript:void(0);" onClick="recommend('. ($page-1) .')" class="pleft"><img src="/images/scroll_left.gif" /></a></div>';
} }
if($num > $pageSize*($page+1)) if($num > $pageSize*($page+1))
{ {
@ -1187,7 +1200,7 @@ class ServiceController extends Zend_Controller_Action
{ {
$pre = '<span class="disabled">&lt;</span>'; $pre = '<span class="disabled">&lt;</span>';
}else{ }else{
$pre = '<a href="javascript:void(0);" onclick="showdata('.$id.','. ($page-1) .')">&lt;</a>'; $pre = '<a href="javascript:void(0);" onClick="showdata('.$id.','. ($page-1) .')">&lt;</a>';
} }
if($num <= $pageSize*($page+1)) if($num <= $pageSize*($page+1))
{ {