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

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=utf-8" language="java" errorPage="" %>
  2. <%@ page import="cn.js.fan.web.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="cn.js.fan.db.*"%>
  5. <%@ page import="cn.js.fan.web.*"%>
  6. <%@ page import="cn.js.fan.module.web.*"%>
  7. <%@ page import="cn.js.fan.module.cms.*"%>
  8. <%@ page import="com.redmoon.oa.pvg.*"%>
  9. <%@ page import="cn.js.fan.security.*"%>
  10. <%
  11. com.redmoon.oa.pvg.Privilege privilege = new com.redmoon.oa.pvg.Privilege();
  12. int id = 0;
  13. String dirCode = ParamUtil.get(request, "dir_code");
  14. boolean isDirArticle = false;
  15. Leaf lf = new Leaf();
  16. Document doc = null;
  17. DocumentMgr docmgr = new DocumentMgr();
  18. if (!dirCode.equals("")) {
  19. lf = lf.getLeaf(dirCode);
  20. if (lf!=null) {
  21. if (lf.getType()==1) {
  22. // id = lf.getDocID();
  23. doc = docmgr.getDocumentByCode(request, dirCode, privilege);
  24. id = doc.getID();
  25. isDirArticle = true;
  26. }
  27. }
  28. }
  29. if (id==0) {
  30. try {
  31. id = ParamUtil.getInt(request, "id");
  32. doc = docmgr.getDocument(id);
  33. }
  34. catch (ErrMsgException e) {
  35. out.print(SkinUtil.makeErrMsg(request, e.getMessage()));
  36. return;
  37. }
  38. }
  39. if (!doc.isLoaded()) {
  40. out.print(SkinUtil.makeErrMsg(request, "该文章不存在!"));
  41. return;
  42. }
  43. if (!isDirArticle)
  44. lf = lf.getLeaf(doc.getDirCode());
  45. String CPages = ParamUtil.get(request, "CPages");
  46. int pageNum = 1;
  47. if (StrUtil.isNumeric(CPages))
  48. pageNum = Integer.parseInt(CPages);
  49. String op = ParamUtil.get(request, "op");
  50. String view = ParamUtil.get(request, "view");
  51. CommentMgr cm = new CommentMgr();
  52. if (op.equals("addcomment")) {
  53. try {
  54. cm.insert(request);
  55. }
  56. catch (ErrMsgException e) {
  57. out.print(StrUtil.Alert(e.getMessage()));
  58. }
  59. }
  60. if (op.equals("vote")) {
  61. try {
  62. docmgr.vote(request,id);
  63. response.sendRedirect("doc_show.jsp?id=" + id);
  64. return;
  65. }
  66. catch (ErrMsgException e) {
  67. out.print(StrUtil.Alert(e.getMessage()));
  68. }
  69. }
  70. %>
  71. <html>
  72. <head>
  73. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  74. <title><%=Global.AppName%> - <%=doc.getTitle()%></title>
  75. <link rel="stylesheet" href="common.css" type="text/css">
  76. </head>
  77. <body>
  78. <%
  79. if (!privilege.isUserPrivValid(request, "read"))
  80. {
  81. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  82. return;
  83. }
  84.     LeafPriv lp = new LeafPriv();
  85. lp.setDirCode(doc.getDirCode());
  86.     if (!lp.canUserSee(privilege.getUser(request))) {
  87. out.print(SkinUtil.makeErrMsg(request, SkinUtil.LoadString(request, "pvg_invalid")));
  88. return;
  89. }
  90. else {
  91. if (doc!=null && pageNum==1) {
  92. // 使点击量增1
  93. doc.increaseHit();
  94. }
  95. %>
  96. <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="0" class="tableframe">
  97.   <tr>
  98.     <td width="86%" class="right-title">&nbsp;
  99.       <a href="doc_list.jsp?dir_code=<%=StrUtil.UrlEncode(lf.getCode())%>" class="title_white"><%=lf.getName()%></a></td>
  100.     <td width="14%" align="center" class="right-title"><%
  101. if (lp.canUserModify(privilege.getUser(request))) {
  102. %>
  103.       <a href="fwebedit.jsp?op=edit&id=<%=doc.getID()%>&dir_code=<%=StrUtil.UrlEncode(doc.getDirCode())%>&dir_name=<%=StrUtil.UrlEncode(lf.getName())%>" class="title_white">编辑</a>
  104.       <%
  105. }
  106. %></td>
  107.   </tr>
  108.   <tr>
  109.     <td height="79" colspan="2" align="center" bgcolor="#FFFFFF"><table cellSpacing="0" cellPadding="5" width="100%" align="center" border="0">
  110.       <tbody>
  111.         <tr>
  112.           <td height="39" align="center"><%if (doc.isLoaded()) {%>
  113.                 <b><font size="3"> <%=doc.getTitle()%></font></b>&nbsp; </td>
  114.         </tr>
  115.         <tr>
  116.           <td height="28" align="right" bgcolor="#e4e4e4"><%if (!doc.getAuthor().equals("")){%>
  117.             作者:<%=doc.getAuthor()%>&nbsp;
  118.             <%}%>
  119.             &nbsp;&nbsp;日期:<%=doc.getModifiedDate()%>&nbsp;&nbsp;访问次数:<%=doc.getHit()%>
  120.             <%}else{%>
  121.             未找到该文章!
  122.             <%}%>
  123.             &nbsp;&nbsp;&nbsp;&nbsp;</td>
  124.         </tr>
  125.       </tbody>
  126.     </table>
  127.     <br></td>
  128.   </tr>
  129.   <tr>
  130.     <td colspan="2" bgcolor="#FFFFFF">
  131.   <%
  132.                 java.util.Vector attachments = doc.getAttachments(pageNum);
  133.                 java.util.Iterator ir = attachments.iterator();
  134.                 String str = "";
  135. int m=0;
  136.                 while (ir.hasNext()) {
  137.                     Attachment am = (Attachment)
  138.                                     ir.next();
  139.                     // 根据其diskName取出ext
  140.                     String ext = StrUtil.getFileExt(am.getDiskName());
  141.                     String link = am.getVisualPath() + "/" + am.getDiskName();
  142.                     if (ext.equals("mp3") || ext.equals("wma")) {
  143.                         // 使用realplay会导致IE崩溃
  144.                         // str += "<div><OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=500 height=80><PARAM NAME=SRC VALUE='" + link + "'><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=true></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=500><PARAM NAME=SRC VALUE='" + link + "'><PARAM NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT></div>";
  145.                         if (m==0) {
  146.                             str += "<table align=center width=500><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=500 height=70><param name=ShowStatusBar value=-1><param name=Filename value='" +
  147.                                     link + "'><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src='" +
  148.                                     link +
  149.                                     "'  width=500 height=70></embed></object></td></tr></table><BR>";
  150.                         } else {
  151.                             str += "<table align=center width=500><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=500 height=70><param name=ShowStatusBar value=-1><param name=Filename value='" +
  152.                                     link + "'><param name='AutoStart' value=0><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src='" +
  153.                                     link +
  154.                                     "'  width=500 height=70></embed></object></td></tr></table><BR>";
  155.                         }
  156.                     }else if (ext.equals("wmv") || ext.equals("mpg") || ext.equals("avi")) {
  157.                         // 使用realplay会导致IE崩溃
  158.                         // str += "<div><OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=500 height=80><PARAM NAME=SRC VALUE='" + link + "'><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=true></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=500><PARAM NAME=SRC VALUE='" + link + "'><PARAM NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT></div>";
  159.                         if (m==0) {
  160.                             str += "<table align=center width=500><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=500 height=400><param name=ShowStatusBar value=-1><param name=Filename value='" +
  161.                                     link + "'><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src='" +
  162.                                     link +
  163.                                     "'  width=500 height=70></embed></object></td></tr></table><BR>";
  164.                         } else {
  165.                             str += "<table align=center width=500><object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=500 height=400><param name=ShowStatusBar value=-1><param name=Filename value='" +
  166.                                     link + "'><param name='AutoStart' value=0><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src='" +
  167.                                     link +
  168.                                     "'  width=500 height=70></embed></object></td></tr></table><BR>";
  169.                         }
  170.                     } else if (ext.equals("rm") || ext.equals("rmvb")) {
  171.                         if (m==0)
  172.                             str += "<table align=center width=500><OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=500 height=380><PARAM NAME=SRC VALUE='" +
  173.                                     link + "'><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=true></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=500><PARAM NAME=SRC VALUE='" +
  174.                                     link + "'><PARAM NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT></td></tr></table><BR>";
  175.                         else
  176.                             str += "<table align=center width=500><OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=500 height=380><PARAM NAME=SRC VALUE='" +
  177.                                     link + "'><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=false></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=500><PARAM NAME=SRC VALUE='" +
  178.                                     link + "'><PARAM NAME=AUTOSTART VALUE=0><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT></td></tr></table><BR>";
  179.                     }
  180. m++;
  181.                 }
  182. out.print(str);
  183.   %>
  184. <%if (doc.isLoaded()) {%>
  185.         <%=doc.getContent(pageNum)%>
  186.         <%}%>
  187.         <br>
  188.         <br>
  189.         <%
  190.   if (doc!=null) {
  191.   //java.util.Vector attachments = doc.getAttachments(pageNum);
  192.   ir = attachments.iterator();
  193.   while (ir.hasNext()) {
  194.    Attachment am = (Attachment) ir.next(); %>
  195.         <table width="569"  border="0" cellspacing="0" cellpadding="0">
  196.           <tr>
  197.             <td width="91" align="right"><img src=images/attach.gif></td>
  198.             <td width="478">&nbsp;<a target=_blank href="doc_getfile.jsp?pageNum=<%=pageNum%>&id=<%=doc.getID()%>&attachId=<%=am.getId()%>"><%=am.getName()%></a>&nbsp;下载次数&nbsp;<%=am.getDownloadCount()%></td>
  199.           </tr>
  200.         </table>
  201.       <%}
  202.   }
  203.   %>
  204.         <%if (doc.getType()==1 && (op.equals("") || !op.equals("vote"))) {
  205. String[] voptions = doc.getVoteOption().split("\|");
  206. int len = voptions.length; %>
  207.         <table width="100%" >
  208.           <form action="?op=vote" name=formvote method="post">
  209.             <input type=hidden name=op value="vote">
  210.             <input type=hidden name=id value="<%=doc.getID()%>">
  211.             <%for (int k=0; k<len; k++) { %>
  212.             <tr>
  213.               <td width="5%"><%=k+1%>、 </td>
  214.               <td width="73%"><input class="n" type=radio name=votesel value="<%=k%>">
  215.                   <%=voptions[k]%> </td>
  216.               <td>&nbsp;</td>
  217.             </tr>
  218.             <% } %>
  219.             <tr>
  220.               <td colspan="2" align="center"><input name="Submit" type="submit" class="singleboarder" value=" 投  票 ">
  221.                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  222.                 <input name="btn" type="button" class="singleboarder" value="查看结果" onClick="window.location.href='doc_show.jsp?id=<%=id%>&view=result'"></td>
  223.               <td width="22%">&nbsp;</td>
  224.             </tr>
  225.           </form>
  226.         </table>
  227.       <%}%>
  228.         <br>
  229.         <%if (view.equals("result") || op.equals("vote")) {
  230. String[] result = doc.getVoteResult().split("\|");
  231. int len = result.length;
  232. int[] re = new int[len];
  233. int[] bfb = new int[len];
  234. int total = 0;
  235. for (int k=0; k<len; k++) {
  236. re[k] = Integer.parseInt(result[k]);
  237. total += re[k];
  238. }
  239. if (total!=0) {
  240. for (int k=0; k<len; k++) {
  241. bfb[k] = (int)Math.round((double)re[k]/total*100);
  242. }
  243. }
  244. %>
  245.         <table class=p9 width="98%" border="0" cellpadding="0" cellspacing="1" height="100">
  246.           <%
  247.   int barId = 0;
  248.   for (int k=0; k<len; k++) { %>
  249.           <tr bgcolor="#FEF2E9">
  250.             <td width="5%"><%=k+1%>、</td>
  251.             <td width="59%">
  252.   <img src="forum/images/vote/bar<%=barId%>.gif" width=<%=bfb[k]*2%> height=10>
  253. </td>
  254.             <td width="17%" align="right"><%=re[k]%>人</td>
  255.             <td width="19%" align="right"><%=bfb[k]%>%</td>
  256.           </tr>
  257.           <%
  258. barId ++;
  259. if (barId==10)
  260. barId = 0;   
  261.   }%>
  262.           <tr bgcolor="#FEF2E9">
  263.             <td colspan="4" align="center">共有<%=total%>人参加调查</td>
  264.           </tr>
  265.         </table>
  266.       <%}%>
  267.         <table width="100%"  border="0" cellspacing="0" cellpadding="0">
  268.           <tr>
  269.             <td height="24" align="center">文章共<%=doc.getPageCount()%>页&nbsp;&nbsp;页码
  270.               <%
  271. int pagesize = 1;
  272. int total = DocContent.getContentCount(doc.getID());
  273. int curpage,totalpages;
  274. Paginator paginator = new Paginator(request, total, pagesize);
  275. // 设置当前页数和总页数
  276. totalpages = paginator.getTotalPages();
  277. curpage = paginator.getCurrentPage();
  278. if (totalpages==0)
  279. {
  280. curpage = 1;
  281. totalpages = 1;
  282. }
  283. String querystr = "op=edit&id=" + id;
  284. out.print(paginator.getCurPageBlock("doc_show.jsp?"+querystr));
  285. %></td>
  286.           </tr>
  287.         </table>
  288.       <table height="20" cellSpacing="0" cellPadding="5" width="99%" align="center" bgColor="#e4e4e4" border="0">
  289.           <tbody>
  290.             <tr>
  291.               <td><%if (doc.getCanComment()) {%>
  292.                   <img height="15" src="images/comment.gif" width="19" align="absMiddle"><a href="#comment">发表评论</a>
  293.                   <%}%>
  294.                   <img height="15" src="images/question.gif" width="19" align="absMiddle"><a target="_blank" href="jump.jsp?fromWhere=oa&toWhere=forum">提出问题</a></td>
  295.             </tr>
  296.           </tbody>
  297.       </table>
  298.       <br>
  299.         <table width="98%"  border="0" cellspacing="0" cellpadding="0">
  300.           <tr>
  301.             <td width="5"></td>
  302.             <td><%
  303. ir = cm.getList(id);
  304. while (ir.hasNext()) {
  305. Comment cmt = (Comment) ir.next();
  306. %>
  307.                 <table width="480" >
  308.                   <tr>
  309.                     <td width="607" height="27"><span class="style1">评论</span>:</td>
  310.                   </tr>
  311.                 </table>
  312.               <table width="480" cellpadding="0" cellspacing="0" >
  313.                   <tr>
  314.                     <td height="43" align="center" class="tableframe_comment"><table width="99%" align="center" >
  315.                         <tr>
  316.                           <td height="22" bgcolor="#F2F2F2"><span class="style1"><a target="_blank" href="user_info.jsp?userName=<%=StrUtil.UrlEncode(cmt.getNick())%>"><%=cmt.getNick()%></a>&nbsp;发表于&nbsp;<%=cmt.getAddDate()%> </span></td>
  317.                         </tr>
  318.                         <tr>
  319.                           <td><%=cmt.getContent()%></td>
  320.                         </tr>
  321.                     </table></td>
  322.                   </tr>
  323.               </table>
  324.               <%
  325. }
  326. %>
  327.                 <br>
  328.                 <%if (doc.isCanComment()) {%>
  329.                 <table width="44%" cellpadding="0" cellspacing="0" class="tableframe_gray" >
  330.                   <tr>
  331.                     <td><table width="100%" class="tableframe" >
  332.                         <form name="form1" method="post" action="?op=addcomment">
  333.                           <tr align="left" bgcolor="#CCCCCC">
  334.                             <td height="24" colspan="3"><span class="style1">发表评论<a name="comment"></a></span></td>
  335.                           </tr>
  336.                           <tr>
  337.                             <td height="24" colspan="2" align="left">姓&nbsp;名
  338.                               <input type="text" name="nick" size="15" value="<%=privilege.getUser(request)%>" readonly="">
  339.                                 <input type="hidden" name="doc_id" value="<%=doc.getID()%>">
  340.                                 <input type="hidden" name="id" value="<%=doc.getID()%>">                            </td>
  341.                             <td width="46%" align="left"> 
  342. <input name="link" type="hidden" value="<%=Global.AppName%>"> </td>
  343.                           </tr>
  344.                           <tr>
  345.                             <td width="9%" align="center">内&nbsp;容 </td>
  346.                             <td colspan="2" align="left"><textarea name="content" cols="45" rows="8"></textarea></td>
  347.                           </tr>
  348.                           <tr>
  349.                             <td colspan="3" align="center"><input name="Submit" type="submit" class="singleboarder" value="提交">
  350.                               &nbsp;&nbsp;&nbsp;&nbsp;
  351.                               <input name="Submit" type="reset" class="singleboarder" value="重置"></td>
  352.                           </tr>
  353.                         </form>
  354.                     </table></td>
  355.                   </tr>
  356.                 </table>
  357.               <%}%>
  358.                 <%}%>            </td>
  359.           </tr>
  360.       </table></td>
  361.   </tr>
  362. </table>
  363. </body>
  364. </html>