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

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
  2. <%@ page import="com.fan.redmoon.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="cn.js.fan.db.*"%>
  5. <%@ page import="cn.js.fan.module.cms.*"%>
  6. <%@ page import="cn.js.fan.security.*"%>
  7. <%
  8. int id = 0;
  9. String dirCode = ParamUtil.get(request, "dir_code");
  10. boolean isDirArticle = false;
  11. Leaf lf = new Leaf();
  12. if (!dirCode.equals("")) {
  13. lf = lf.getLeaf(dirCode);
  14. if (lf!=null) {
  15. if (lf.getType()==1) {
  16. id = lf.getDocID();
  17. isDirArticle = true;
  18. }
  19. }
  20. }
  21. if (id==0) {
  22. try {
  23. id = ParamUtil.getInt(request, "id");
  24. }
  25. catch (ErrMsgException e) {
  26. out.print(StrUtil.makeErrMsg(e.getMessage()));
  27. return;
  28. }
  29. }
  30. Document doc = null;
  31. DocumentMgr docmgr = new DocumentMgr();
  32. doc = docmgr.getDocument(id);
  33. if (doc!=null) {
  34. // 使点击量增1
  35. doc.increaseHit();
  36. }
  37. if (!isDirArticle)
  38. lf = lf.getLeaf(doc.getDirCode());
  39. String op = ParamUtil.get(request, "op");
  40. String view = ParamUtil.get(request, "view");
  41. CommentMgr cm = new CommentMgr();
  42. if (op.equals("addcomment")) {
  43. try {
  44. cm.insert(request);
  45. }
  46. catch (ErrMsgException e) {
  47. out.print(StrUtil.Alert(e.getMessage()));
  48. }
  49. }
  50. if (op.equals("vote")) {
  51. try {
  52. docmgr.vote(request,id);
  53. }
  54. catch (ErrMsgException e) {
  55. out.print(StrUtil.Alert(e.getMessage()));
  56. }
  57. }
  58. %>
  59. <html>
  60. <head>
  61. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  62. <title>查看模板 - <%=doc.getTitle()%></title>
  63. <link href="../common.css" rel="stylesheet" type="text/css">
  64. <style type="text/css">
  65. <!--
  66. .style1 {
  67. font-size: 14px;
  68. font-weight: bold;
  69. }
  70. -->
  71. </style>
  72. </head>
  73. <body>
  74. <table width="769" border="0" cellpadding="0" cellspacing="0" >
  75.   <tr>
  76.     <td width="1" bgcolor="#CCCCCC"></td>
  77.     <td width="593" valign="top"><TABLE BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
  78.       <TR valign="top" bgcolor="#FFFFFF">
  79.         <TD width="662" height="260"><table width="581"  border="0" align="center" cellpadding="0" cellspacing="0">
  80.             <tr>
  81.               <td width="581">&nbsp;</td>
  82.             </tr>
  83.             <tr>
  84.               <td height="40" align="center">
  85.   
  86.   <%if (doc.isLoaded()) {%>
  87.   <b><font size="3"> <%=doc.getTitle()%></font></b>&nbsp;[<%=doc.getModifiedDate()%>]
  88.   <%}else{%>
  89.   未找到该文章!
  90.   <%}%>
  91.   </td>
  92.             </tr>
  93.             <tr>
  94.               <td height="35"><%=doc.getContent(1)%><br>
  95.                 <br>
  96.                 </td>
  97.             </tr>
  98.             <tr>
  99.               <td valign="top"><%if (doc.getType()==1 && (op.equals("") || !op.equals("vote"))) {
  100. String[] voptions = doc.getVoteOption().split("\|");
  101. int len = voptions.length; %>
  102.                   <table width="100%" >
  103.                     <form action="../?op=vote" name=formvote method="post">
  104.                       <input type=hidden name=op value="vote">
  105.                       <input type=hidden name=id value="<%=doc.getID()%>">
  106.                       <%for (int k=0; k<len; k++) { %>
  107.                       <tr>
  108.                         <td width="5%"><%=k+1%>、 </td>
  109.                         <td width="73%"><input class="n" type=radio name=votesel value="<%=k%>">
  110.                             <%=voptions[k]%> </td>
  111.                         <td>&nbsp;</td>
  112.                       </tr>
  113.                       <% } %>
  114.                       <tr>
  115.                         <td colspan="2" align="center"><input name="Submit" type="submit" class="singleboarder" value=" 投  票 ">
  116. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  117.                     <input name="btn" type="button" class="singleboarder" value="查看结果" onClick="window.location.href='doc_show.jsp?id=<%=id%>?view=result'"></td>
  118.                         <td width="22%">&nbsp;</td>
  119.                       </tr>
  120.                     </form>
  121.                   </table>
  122.                   <%}%>
  123.                   <br>
  124.                   <%if (view.equals("result") || op.equals("vote")) {
  125. String[] result = doc.getVoteResult().split("\|");
  126. int len = result.length;
  127. int[] re = new int[len];
  128. int[] bfb = new int[len];
  129. int total = 0;
  130. for (int k=0; k<len; k++) {
  131. re[k] = Integer.parseInt(result[k]);
  132. total += re[k];
  133. }
  134. if (total!=0) {
  135. for (int k=0; k<len; k++) {
  136. bfb[k] = (int)Math.round((double)re[k]/total*100);
  137. }
  138. }
  139. %>
  140.                   <table class=p9 width="98%" border="0" cellpadding="0" cellspacing="1" height="100">
  141.                     <% for (int k=0; k<len; k++) { %>
  142.                     <tr bgcolor="#FEF2E9">
  143.                       <td width="5%"><%=k+1%>、</td>
  144.                       <td width="59%"><img src=../images/bar.gif width=<%=bfb[k]*2%> height=10></td>
  145.                       <td width="17%" align="right"><%=re[k]%>人</td>
  146.                       <td width="19%" align="right"><%=bfb[k]%>%</td>
  147.                     </tr>
  148.                     <%}%>
  149.                     <tr bgcolor="#FEF2E9">
  150.                       <td colspan="4" align="center">共有<%=total%>人参加调查</td>
  151.                     </tr>
  152.                   </table>
  153.                   <%}%>
  154.               </td>
  155.             </tr>
  156.             <tr>
  157.               <td height="34" valign="top">&nbsp;</td>
  158.             </tr>
  159.         </table></TD>
  160.       </TR>
  161.     </TABLE>
  162.       <br>
  163.       
  164.     </td>
  165.   </tr>
  166. </table>
  167. </body>
  168. </html>