fwebedit.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:18k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ page import="cn.js.fan.security.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="java.util.*"%>
  5. <%@ page import="cn.js.fan.web.*"%>
  6. <%@ page import="cn.js.fan.module.cms.*"%>
  7. <%@ page import="java.util.Calendar" %>
  8. <html><head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  10. <link href="../common.css" rel="stylesheet" type="text/css">
  11. <link href="default.css" rel="stylesheet" type="text/css">
  12. <jsp:useBean id="strutil" scope="page" class="cn.js.fan.util.StrUtil"/>
  13. <jsp:useBean id="docmanager" scope="page" class="cn.js.fan.module.cms.DocumentMgr"/>
  14. <%
  15. String dir_code = ParamUtil.get(request, "dir_code");
  16. String dir_name = ParamUtil.get(request, "dir_name");
  17. int id = 0;
  18. if (!FSecurity.isValidSqlParam(dir_code)) {
  19. out.print(strutil.makeErrMsg("标识非法!"));
  20. return;
  21. }
  22. %>
  23. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  24. <jsp:setProperty name="privilege" property="defaulturl" value="../index.jsp"/>
  25. <%
  26. String priv="admin";
  27. if (!privilege.isUserPrivValid(request,priv))
  28. {
  29. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  30. return;
  31. }
  32. String correct_result = "操作成功!";
  33. Document doc = null;
  34. String op = ParamUtil.get(request, "op");
  35. if (op.equals("edit")) {
  36. try {
  37. id = ParamUtil.getInt(request, "id");
  38. doc = docmanager.getDocument(request, id, privilege);
  39. } catch (ErrMsgException e) {
  40. out.print(strutil.makeErrMsg(e.getMessage(),"red", "green"));
  41. return;
  42. }
  43. }
  44. if (op.equals("editarticle")) {
  45. op = "edit";
  46. try {
  47. doc = docmanager.getDocumentByCode(request, dir_code, privilege);
  48. } catch (ErrMsgException e) {
  49. out.print(strutil.makeErrMsg(e.getMessage(),"red", "green"));
  50. return;
  51. }
  52. }
  53. %>
  54. <title><%=doc!=null?doc.getTitle():""%></title>
  55. <style type="text/css">
  56. <!--
  57. td {  font-family: "Arial", "Helvetica", "sans-serif"; font-size: 14px; font-style: normal; line-height: 150%; font-weight: normal}
  58. -->
  59. </style>
  60. <script language="JavaScript">
  61. <!--
  62. <%
  63. if (doc!=null) {
  64. out.println("var id=" + doc.getID() + ";");
  65. }
  66. %>
  67. var op = "<%=op%>";
  68. function SubmitWithFile(){
  69. if (document.addform.title.value.length == 0) {
  70. alert("请输入文章标题.");
  71. document.addform.title.focus();
  72. return false;
  73. }
  74. if (op=="edit") {
  75. addform.webedit.Clear();
  76. addform.webedit.AddField("title",addform.title.value);
  77. addform.webedit.AddField("id", id);
  78. addform.webedit.AddField("op", "<%=op%>");
  79. if (addform.canComment.checked)
  80. addform.webedit.AddField("canComment", addform.canComment.value);
  81. if (addform.isHome.checked)
  82. addform.webedit.AddField("isHome", addform.isHome.value);
  83. if (addform.isvote.checked)
  84. {
  85. addform.webedit.AddField("isvote", addform.isvote.value);
  86. addform.webedit.AddField("vote", addform.vote.value);
  87. }
  88. addform.webedit.AddField("keywords", addform.keywords.value);
  89. if (addform.isRelateShow.checked)
  90. addform.webedit.AddField("isRelateShow", addform.isRelateShow.value);
  91. addform.webedit.AddField("examine", addform.examine.value);
  92. addform.webedit.SetHtmlCode(document.frames.webEditorFrame.getHTML());
  93. }
  94. if (op=="add") {
  95. addform.webedit.Clear();
  96. addform.webedit.AddField("title",addform.title.value);
  97. addform.webedit.AddField("op", "<%=op%>");
  98. addform.webedit.AddField("dir_code", "<%=dir_code%>");
  99. if (addform.canComment.checked)
  100. addform.webedit.AddField("canComment", addform.canComment.value);
  101. if (addform.isHome.checked)
  102. addform.webedit.AddField("isHome", addform.isHome.value);
  103. if (addform.isvote.checked)
  104. {
  105. addform.webedit.AddField("isvote", addform.isvote.value);
  106. addform.webedit.AddField("vote", addform.vote.value);
  107. }
  108. addform.webedit.AddField("examine", addform.examine.value);
  109. addform.webedit.AddField("keywords", addform.keywords.value);
  110. if (addform.isRelateShow.checked)
  111. addform.webedit.AddField("isRelateShow", addform.isRelateShow.value);
  112. addform.webedit.SetHtmlCode(document.frames.webEditorFrame.getHTML());
  113. }
  114. addform.webedit.UploadArticle();
  115. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  116. doAfter(true);
  117. else
  118. doAfter(false);
  119. }
  120. function SubmitWithoutFile() {
  121. if (document.addform.title.value.length == 0) {
  122. alert("请输入文章标题.");
  123. document.addform.title.focus();
  124. return false;
  125. }
  126. //addform.content.value = document.frames.webEditorFrame.getHTML();
  127. //addform.submit();
  128. addform.webedit.Clear();
  129. addform.webedit.UploadMode = 0;
  130. if (op=="edit") {
  131. addform.webedit.AddField("isuploadfile", "false");
  132. addform.webedit.AddField("title",addform.title.value);
  133. addform.webedit.AddField("id", id);
  134. if (addform.canComment.checked)
  135. addform.webedit.AddField("canComment", addform.canComment.value);
  136. if (addform.isHome.checked)
  137. addform.webedit.AddField("isHome", addform.isHome.value);
  138. addform.webedit.AddField("op", "<%=op%>");
  139. if (addform.isvote.checked)
  140. {
  141. addform.webedit.AddField("isvote", addform.isvote.value);
  142. addform.webedit.AddField("vote", addform.vote.value);
  143. }
  144. addform.webedit.AddField("examine", addform.examine.value);
  145. addform.webedit.AddField("keywords", addform.keywords.value);
  146. if (addform.isRelateShow.checked)
  147. addform.webedit.AddField("isRelateShow", addform.isRelateShow.value);
  148. addform.webedit.SetHtmlCode(document.frames.webEditorFrame.getHTML());
  149. }
  150. if (op=="add") {
  151. addform.webedit.AddField("isuploadfile", "false");
  152. addform.webedit.AddField("title",addform.title.value);
  153. addform.webedit.AddField("dir_code", "<%=dir_code%>");
  154. addform.webedit.AddField("op", "<%=op%>");
  155. if (addform.canComment.checked)
  156. addform.webedit.AddField("canComment", addform.canComment.value);
  157. if (addform.isHome.checked)
  158. addform.webedit.AddField("isHome", addform.isHome.value);
  159. if (addform.isvote.checked)
  160. {
  161. addform.webedit.AddField("isvote", addform.isvote.value);
  162. addform.webedit.AddField("vote", addform.vote.value);
  163. }
  164. addform.webedit.AddField("examine", addform.examine.value);
  165. addform.webedit.AddField("keywords", addform.keywords.value);
  166. if (addform.isRelateShow.checked)
  167. addform.webedit.AddField("isRelateShow", addform.isRelateShow.value);
  168. addform.webedit.SetHtmlCode(document.frames.webEditorFrame.getHTML());
  169. }
  170. addform.webedit.UploadArticle();
  171. if (addform.webedit.ReturnMessage == "<%=correct_result%>")
  172. doAfter(true);
  173. else
  174. doAfter(false);
  175. }
  176. function clearAll(){
  177. document.addform.title.value=""
  178. document.frames.webEditorFrame.setHTML('');
  179. }
  180. function doAfter(isSucceed) {
  181. if (isSucceed) {
  182. if (confirm("<%=correct_result%> 请点击确定按钮刷新页面。"))
  183. window.location.reload(true);
  184. }
  185. else {
  186. alert(addform.webedit.ReturnMessage);
  187. }
  188. }
  189. function showvote(isshow)
  190. {
  191. if (addform.isvote.checked)
  192. {
  193. addform.vote.style.display = "";
  194. }
  195. else
  196. {
  197. addform.vote.style.display = "none";
  198. }
  199. }
  200. //-->
  201. </script>
  202. </head>
  203. <body bgcolor="#FFFFFF" text="#000000" onLoad="window_onload()">
  204. <TABLE BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
  205.   <TR valign="top" bgcolor="#FFFFFF">
  206.     <TD width="590" height="430" colspan="2" style="background-attachment: fixed; background-image: url(images/bg_bottom.jpg); background-repeat: no-repeat">
  207. <form name="addform" action="fwebedit_do.jsp" method="post">
  208.           <TABLE cellSpacing=0 cellPadding=0 width="100%">
  209.             <TBODY>
  210.               <TR>
  211.                 <TD class=head>
  212. <%
  213. if (op.equals("add")) {%>
  214. 添加内容至--<a href="document_list_m.jsp?dir_code=<%=StrUtil.UrlEncode(dir_code)%>&dir_name=<%=StrUtil.UrlEncode(dir_name)%>"><%=dir_name%></a>
  215. <%}else{%>
  216. 修改--
  217. <%if (doc.getType()==2) {%>
  218. <a href="document_list_m.jsp?dir_code=<%=StrUtil.UrlEncode(dir_code)%>&dir_name=<%=StrUtil.UrlEncode(dir_name)%>"><%=dir_name%></a>
  219. <%}else{%>
  220. <%=dir_name%>
  221. <%}%>
  222. (<%=doc.getDirCode()%>)
  223. <%}%>
  224. </TD>
  225.               </TR>
  226.             </TBODY>
  227.           </TABLE>
  228.           <table border="0" cellspacing="1" width="100%" cellpadding="0" align="center">
  229.             <tr align="center" bgcolor="#F2F2F2">
  230.               <td height="20" colspan=2 align=center><b><%=doc!=null?doc.getTitle():""%></b>&nbsp;<input type="hidden" name=isuploadfile value="false">
  231.   <input type="hidden" name=id value="<%=doc!=null?doc.getID():""%>">
  232. <%=doc!=null?"(id:"+doc.getID()+")":""%>   </td>
  233.             </tr>
  234.             <tr>
  235.               <td align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">标&nbsp;&nbsp;&nbsp;&nbsp;题:</td>
  236.               <td width="89%" bgcolor="#FFFFFF">
  237.                   <input name="title" id=me type="TEXT" size=50 maxlength=100 style="background-color:ffffff;color:000000;border: 1 double" value="<%=doc!=null?doc.getTitle():""%>">                  <span class="unnamed2"><font color="#FF0000">*</font></span> </td>
  238.             </tr>
  239.             <tr>
  240.               <td align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">关键字:</td>
  241.               <td bgcolor="#FFFFFF"><input name="keywords" id=keywords type="TEXT" size=30 maxlength=100 style="background-color:ffffff;color:000000;border: 1 double" value="<%=StrUtil.getNullStr(doc==null?dir_code:doc.getKeywords())%>">
  242.               ( 请用&quot;,&quot;号分隔)
  243.                 <span class="unnamed2">
  244.                 <%
  245. String strRelateChecked = "";
  246. if (doc!=null && doc.getIsRelateShow())
  247. strRelateChecked = "checked";
  248. %>
  249. &nbsp;&nbsp;相关文章:
  250. <input type="checkbox" name="isRelateShow" value="1" <%=strRelateChecked%>>
  251. 显示</span></td>
  252.             </tr>
  253.             <tr align="left" bgcolor="#F2F2F2">
  254.               <td colspan="2" valign="middle" class="unnamed2">&nbsp;<%
  255. String strChecked = "";
  256. if (doc!=null) {
  257. if (doc.getCanComment())
  258. strChecked = "checked";
  259. }
  260. else
  261. strChecked = "checked";
  262. %>
  263. 评论:
  264.   <input type="checkbox" name="canComment" value="1" <%=strChecked%>>
  265. 允许
  266. <%if (doc!=null) {%>
  267. [<a href="comment_m.jsp?doc_id=<%=doc.getID()%>">管理评论</a>]
  268. <%}%>
  269. &nbsp;
  270. <%if (doc!=null) {%>
  271. <input type="checkbox" name="isHome" value="<%=doc.getIsHome()?"false":"true"%>" <%=doc.getIsHome()?"checked":""%>>
  272. <%}else{%>
  273. <input type="checkbox" name="isHome" value="true" checked>
  274. <%}%>
  275. 置于首页&nbsp;&nbsp;&nbsp;&nbsp;审核
  276. <select name="examine">
  277. <option value="0">未审核</option>
  278. <option value="1">未通过</option>
  279. <option value="2">已通过</option>
  280. </select>
  281. <%if (doc!=null) {%>
  282. <script>
  283. addform.examine.value = "<%=doc.getExamine()%>";
  284. </script>
  285. <%}%>
  286. </td>
  287.             </tr>
  288.             <tr bgcolor="#F2F2F2">
  289.               <td align="right" class="unnamed2" valign="middle">
  290.   <script>
  291.   var vp = "";
  292.   </script>
  293. <%
  294. String display="none",ischecked="false", isreadonly = "";
  295. if (doc!=null) {
  296. if (doc.getType()==1) {
  297. display = "";
  298. ischecked = "checked disabled";
  299. isreadonly = "readonly";
  300. %>
  301. <script>
  302. var voteoption = "<%=doc.getVoteOption()%>";
  303. var votes = voteoption.split("|");
  304. var len = votes.length;
  305. for (var i=0; i<len; i++) {
  306. if (vp=="")
  307. vp = votes[i];
  308. else
  309. vp += "rn" + votes[i];
  310. }
  311. </script>
  312. <%}
  313. }%>
  314.   <input type="checkbox" name="isvote" value="1" onClick="showvote()" <%=ischecked%>>
  315.               投票</td>
  316.               <td valign="middle"><textarea <%=isreadonly%> style="display:<%=display%>" cols="60" name="vote" rows="8" wrap="VIRTUAL" title="输入投票选项">
  317.   </textarea>
  318.   <script>
  319.    addform.vote.value = vp;
  320.   </script>
  321. 每行代表一个选项</td>
  322.             </tr>
  323.             <tr align="center">
  324.               <td colspan="2" valign="top" bgcolor="#F2F2F2" class="unnamed2">
  325.   <textarea id="content" name="content" style="display:none"><%=doc!=null?doc.getContent().replaceAll(""","'"):""%></textarea>
  326.                   <iframe style=border:none frameborder=0 allowtransparency=true name=webEditorFrame src=Editor.htm width=98% height=350></iframe>
  327.               </td>
  328.             </tr>
  329.             <tr>
  330.               <td width="11%" align="right" bgcolor="#FFFFFF">提示:</td>
  331.               <td bgcolor="#FFFFFF">
  332.   回车可用Shift+Enter   </td>
  333.             </tr>
  334.             <tr>
  335.               <td height="25" colspan=2 align="center" bgcolor="#FFFFFF"><font color="#FF0000">注:当可视化编辑器出现图标显示不全的问题,请重新进入,否则保存后内容会消失。</font></td>
  336.             </tr>
  337.             <tr>
  338.               <td height="25" colspan=2 align="center" bgcolor="#FFFFFF">
  339.   <%
  340.   if (doc!=null) {
  341.   Vector attachments = doc.getAttachments();
  342.   Iterator ir = attachments.iterator();
  343.   while (ir.hasNext()) {
  344.    Attachment am = (Attachment) ir.next(); %>
  345. <table width="98%"  border="0" cellspacing="0" cellpadding="0">
  346.                       <tr>
  347.                         <td width="7%" align="center"><img src=../images/attach.gif></td>
  348.                         <td width="93%">&nbsp;
  349.                           <input name="attach_name<%=am.getId()%>" value="<%=am.getName()%>" size="30">
  350. &nbsp;<a href="javascript:changeAttachName('<%=am.getId()%>', '<%=doc.getID()%>', '<%="attach_name"+am.getId()%>')">更改</a>                        &nbsp;<a href="javascript:delAttach('<%=am.getId()%>', '<%=doc.getID()%>')">删除</a>&nbsp;&nbsp;<a target=_blank href="../<%=am.getVisualPath() + "/" + am.getDiskName()%>">查看</a></td>
  351.                       </tr>
  352.                     </table>
  353. <%}
  354.   }
  355.   %>
  356.   </td>
  357.             </tr>
  358.             <tr>
  359.               <td height="153" colspan=2 align=center bgcolor="#FFFFFF">
  360.   <table  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  361.                 <tr>
  362.                   <td bgcolor="#FFFFFF"><%
  363. Calendar cal = Calendar.getInstance();
  364. String year = "" + (cal.get(cal.YEAR));
  365. String month = "" + (cal.get(cal.MONTH) + 1);
  366. String filepath = "upfile/webeditimg/" + year + "/" + month;
  367. %><object classid="CLSID:DE757F80-F499-48D5-BF39-90BC8BA54D8C" codebase="<%=request.getContextPath()%>/activex/webedit.cab#version=4,0,1,1" width=400 height=153 align="middle" id="webedit">
  368.                       <param name="Encode" value="utf-8">
  369.   <param name="MaxSize" value="<%=Global.MaxSize%>"> <!--上传字节-->
  370.                       <param name="ForeColor" value="(0,255,0)">
  371.                       <param name="BgColor" value="(0,0,0)">
  372.                       <param name="ForeColorBar" value="(255,255,255)">
  373.                       <param name="BgColorBar" value="(0,0,255)">
  374.                       <param name="ForeColorBarPre" value="(0,0,0)">
  375.                       <param name="BgColorBarPre" value="(200,200,200)">
  376.                       <param name="FilePath" value="<%=filepath%>">
  377.                       <!--上传后的文件需放在服务器上的路径-->
  378.                       <param name="Server" value="<%=Global.server%>">
  379.                       <param name="Port" value="<%=Global.port%>">
  380.                       <param name="VirtualPath" value="<%=Global.virtualPath%>">
  381.                       <param name="PostScript" value="<%=Global.virtualPath%>/admin/fwebedit_do.jsp">
  382.                     </object></td>
  383.                 </tr>
  384.               </table>
  385.               </td>
  386.             </tr>
  387.             <tr>
  388.               <td height="30" colspan=2 align=center bgcolor="#FFFFFF">
  389.   <%
  390.   String action = "";
  391.   if (op.equals("add"))
  392.    action = "添 加";
  393.   else
  394.    action = "修 改";
  395.   %>
  396.   <input name="cmdok" type="button" class="singleboarder" value=" <%=action%> " onClick="return SubmitWithFile()">
  397. &nbsp;
  398. <input name="notuploadfile" type="button" class="singleboarder" value="<%=action%>(不上传图片)" onClick="return SubmitWithoutFile()">
  399. &nbsp;
  400.       <input name="cmdcancel" type="button" class="singleboarder" onClick="clearAll()" value=" 清 空 ">
  401. &nbsp;
  402.       <%if (op.equals("edit")) {%>
  403.   <input name="editbtn" type="button" class="singleboarder" onClick="location.href='doc_abstract.jsp?id=<%=doc.getID()%>'" value=" 摘要 ">
  404.   <%}%>
  405. &nbsp;
  406. <input name="remsg" type="button" class="singleboarder" onClick='alert(webedit.ReturnMessage)' value="返回信息">
  407. &nbsp;
  408. <input name="remsg" type="button" class="singleboarder" onClick='window.open("../doc_show.jsp?id=<%=id%>")' value="预览"> </td>
  409.             </tr>
  410.           </table>
  411.     </form>
  412. <br></TD>
  413.   </TR>
  414. </TABLE>
  415. <iframe id="hideframe" name="hideframe" src="fwebedit_do.jsp" width=0 height=0></iframe>
  416. </body>
  417. <script>
  418. function findObj(theObj, theDoc)
  419. {
  420.   var p, i, foundObj;
  421.   
  422.   if(!theDoc) theDoc = document;
  423.   if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  424.   {
  425.     theDoc = parent.frames[theObj.substring(p+1)].document;
  426.     theObj = theObj.substring(0,p);
  427.   }
  428.   if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  429.   for (i=0; !foundObj && i < theDoc.forms.length; i++) 
  430.     foundObj = theDoc.forms[i][theObj];
  431.   for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
  432.     foundObj = findObj(theObj,theDoc.layers[i].document);
  433.   if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  434.   
  435.   return foundObj;
  436. }
  437. function window_onload() {
  438. document.frames.webEditorFrame.setHTML(addform.content.value);
  439. }
  440. function changeAttachName(attach_id, doc_id, nm) {
  441. var obj = findObj(nm);
  442. document.frames.hideframe.location.href = "fwebedit_do.jsp?op=changeattachname&doc_id=" + doc_id + "&attach_id=" + attach_id + "&newname=" + obj.value
  443. }
  444. function delAttach(attach_id, doc_id) {
  445. if (!window.confirm("您确定要删除吗?")) {
  446. return;
  447. }
  448. document.frames.hideframe.location.href = "fwebedit_do.jsp?op=delAttach&doc_id=" + doc_id + "&attach_id=" + attach_id
  449. }
  450. </script>
  451. </html>