예제 #1
0
 /**
  * @Title: playSWF
  * @Description: todo(文件在线查看方法)
  * @author liminggang
  * @date 2014-8-12 下午5:29:50
  * @throws
  */
 function playSWF()
 {
     $file_type = "file";
     $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
     $uid = $_REQUEST['uid'];
     $file_path = $resource_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
     $this->assign("resource_path", $resource_path);
     if (!file_exists($file_path)) {
         $this->display("Public:playswfno");
         exit;
     }
     $info = pathinfo($file_path);
     $filesArr = C('TRANSFORM_SWF');
     $filesArr[] = 'pdf';
     $photoArr = C('IMG_file');
     $file_extension_lower = strtolower($info['extension']);
     if ($file_extension_lower == "docx" || $file_extension_lower == "doc") {
         $action = $this->getActionName();
         // 			$ip = gethostbyname($_SERVER['SERVER_NAME']);
         $ip = C("DB_HOST_WORD");
         //"192.168.0.238";
         require_once "http://{$ip}:8088/JavaBridge/java/Java.inc";
         //此行必须
         $PageOfficeCtrl = new Java("com.zhuozhengsoft.pageoffice.PageOfficeCtrlPHP");
         //此行必须
         $PageOfficeCtrl->setServerPage("http://{$ip}:8088/JavaBridge/poserver.zz");
         //此行必须,设置服务器页面
         $url = __ROOT__ . "/Admin/index.php/{$action}/saveOnlineEditWord/name/" . $_REQUEST['name'];
         java_set_file_encoding("utf8");
         //设置中文编码,若涉及到中文必须设置中文编码
         // 			//添加自定义按钮
         // 			$PageOfficeCtrl->addCustomToolButton("保存","Save",1);
         // 			//设置保存页面
         $PageOfficeCtrl->setSaveFilePage($url);
         $PageOfficeCtrl->addCustomToolButton("保存", "Save", 1);
         $PageOfficeCtrl->addCustomToolButton("显示/隐藏修改记录", "Show_HidRevisions", 7);
         // 			$PageOfficeCtrl->setAllowCopy(false);//禁止拷贝
         //$PageOfficeCtrl->setMenubar(false);//隐藏菜单栏
         // 			$PageOfficeCtrl->setOfficeToolbars(false);//隐藏Office工具条
         // 			$PageOfficeCtrl->setCustomToolbar(false);//隐藏自定义工具栏
         //打开excel文档
         $PageOfficeCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
         //若使用谷歌浏览器此行代码必须有,其他浏览器此行代码可不加
         $OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
         $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
         $file_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "/Public/", $file_path);
         // 			$PageOfficeCtrl->webOpen($file_path, $OpenMode->docNormalEdit, "张三");//此行必须
         //获取用户名称
         $loginUserName = getFieldBy($uid, "id", "name", "user");
         $PageOfficeCtrl->webOpen($file_path, $OpenMode->docRevisionOnly, $loginUserName);
         //此行必须
         $this->assign('PageOfficeCtrl', $PageOfficeCtrl->getDocumentView("PageOfficeCtrl1"));
         $this->display("Public:showEditWord");
     } else {
         if (in_array($file_extension_lower, $filesArr)) {
             $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "../Public", $info["dirname"]);
             if ('pdf' == $file_extension_lower) {
                 $file_path .= '/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 import('@.ORG.OfficeOnline.OfficeOnlineView');
                 $OfficeOnlineView = new OfficeOnlineView();
                 if (!file_exists(str_replace("pdf", "swf", $file_path))) {
                     $OfficeOnlineView->pdf2swf($resource_path, str_replace("MisFileManagerPlaySWF", "MisFileManager", $info['dirname']), 1);
                 }
                 $result = 0;
             } else {
                 $result = 0;
                 $file_path .= '/pdf/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 if (!file_exists($file_path)) {
                     $result = 1;
                     //调用文件IO操作,生成文件
                     $HttpSoctetIOAction = A('Http');
                     $HttpSoctetIOAction->createPDF(str_replace("MisFileManager", "MisFileManagerPlaySWF", $info['dirname']), $resource_path);
                     $file_path = str_replace("MisFileManager", "MisFileManagerPlaySWF", $file_path);
                     $file_path = str_replace("pdf", "swf", $file_path);
                 }
             }
             $this->assign('result', $result);
             $this->assign('file_name', $_REQUEST['filename']);
         }
         if (in_array($file_extension_lower, $photoArr)) {
             $file_type = "photo";
         }
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "__PUBLIC__", $file_path);
         $this->assign("file_type", $file_type);
         $this->assign('file_path', str_replace("pdf", "swf", $file_path));
         $this->display("Public:playswf");
     }
 }
java_set_file_encoding("utf8");
$doc = new Java("com.zhuozhengsoft.pageoffice.wordwriter.WordDocument");
$dataRegion1 = $doc->openDataRegion("PO_question");
$dataRegion1->setEditing(true);
$dataRegion1->setValue("");
$dataRegion1->setSubmitAsFile(true);
$dataRegion2 = $doc->openDataRegion("PO_answer");
$dataRegion2->setEditing(true);
$dataRegion2->setValue("");
$dataRegion2->setSubmitAsFile(true);
$dataRegion3 = $doc->openDataRegion("PO_jiexi");
$dataRegion3->setEditing(true);
$dataRegion3->setValue("");
$dataRegion3->setSubmitAsFile(true);
$PageOfficeCtrl->setWriter($doc);
$PageOfficeCtrl->addCustomToolButton("uTeach编题区", "Save", 9);
$PageOfficeCtrl->setSaveDataPage("/Word/SaveData.php?id=" . $_SESSION['uid']);
$PageOfficeCtrl->setMenubar(false);
$PageOfficeCtrl->setTitlebar(false);
$PageOfficeCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
$OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
$PageOfficeCtrl->webOpen($questionDocPath, $OpenMode->docSubmitForm, "张三");
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>指南树</title>