⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doc_show.jsp

📁 这是论坛原代码,希望大家能好好看看,说明需要的太多了吧
💻 JSP
字号:
<%@ page contentType="text/html;charset=utf-8" language="java" errorPage="" %>
<%@ page import="cn.js.fan.web.*"%>
<%@ page import="cn.js.fan.util.*"%>
<%@ page import="cn.js.fan.db.*"%>
<%@ page import="cn.js.fan.web.*"%>
<%@ page import="cn.js.fan.module.cms.*"%>
<%@ page import="cn.js.fan.module.pvg.*"%>
<%@ page import="cn.js.fan.security.*"%>
<%
int id = 0;
String dirCode = ParamUtil.get(request, "dir_code");
boolean isDirArticle = false;
Leaf lf = new Leaf();

if (!dirCode.equals("")) {
	lf = lf.getLeaf(dirCode);
	if (lf!=null) {
		if (lf.getType()==1) {
			id = lf.getDocID();
			isDirArticle = true;
		}
	}
}

if (id==0) {
	try {
		id = ParamUtil.getInt(request, "id");
	}
	catch (ErrMsgException e) {
		out.print(SkinUtil.makeErrMsg(request, e.getMessage()));
		return;
	}
}
Document doc = null;
DocumentMgr docmgr = new DocumentMgr();
doc = docmgr.getDocument(id);
if (!doc.isLoaded()) {
	out.print(SkinUtil.makeErrMsg(request, "该文章不存在!"));
	return;
}
if (!isDirArticle)
	lf = lf.getLeaf(doc.getDirCode());

String CPages = ParamUtil.get(request, "CPages");
int pageNum = 1;
if (StrUtil.isNumeric(CPages))
	pageNum = Integer.parseInt(CPages);

String op = ParamUtil.get(request, "op");
String view = ParamUtil.get(request, "view");
CommentMgr cm = new CommentMgr();
if (op.equals("addcomment")) {
	try {
		cm.insert(request);
	}
	catch (ErrMsgException e) {
		out.print(StrUtil.Alert(e.getMessage()));
	}
}

if (op.equals("vote")) {
	try {
		docmgr.vote(request,id);
		response.sendRedirect("doc_show.jsp?id=" + id);
		return;		
	}
	catch (ErrMsgException e) {
		out.print(StrUtil.Alert(e.getMessage()));
	}
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%=Global.AppName%> - <%=doc.getTitle()%></title>
<link rel="stylesheet" href="index.css" type="text/css">
</head>
<body>
<%@ include file="header.jsp"%>
<TABLE width="760" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
  <TR valign="top" bgcolor="#FFFFFF">
    <TD width="898" height="260"><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width=""><table width="100%" border="0" align="center" class=p9>
          <tr>
            <td width="100%" height="24" background="images/bg_middle.gif">&nbsp;当前位置: <a href="index.jsp" class="mainA">首页</a> >>
                    <%if (lf.getType()==2) {%>
                    <a href="doc_list.jsp?op=list&dir_code=<%=StrUtil.UrlEncode(lf.getCode())%>"><%=lf.getName()%></a>
                    <%}else{%>
                    <%=lf.getName()%>
                    <%}%>            </td>
          </tr>
          <tr>
            <td height="1" bgcolor="#e4e4e4"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="79" align="center"><table cellSpacing="0" cellPadding="5" width="100%" align="center" border="0">
                <tbody>
                  <tr>
                    <td height="39" align="center"><%if (doc.isLoaded()) {%>
                      <b><font size="3"> <%=doc.getTitle()%></font></b>&nbsp; </td>
                  </tr>
                  <tr>
                    <td height="28" align="right" bgcolor="#e4e4e4"><%if (!doc.getAuthor().equals("")){%>
作者:<%=doc.getAuthor()%>&nbsp;
<%}%>&nbsp;&nbsp;日期:<%=cn.js.fan.util.DateUtil.format(doc.getModifiedDate(), "yy-MM-dd")%>&nbsp;&nbsp;访问次数:<%=doc.getHit()%>
<%}else{%>
未找到该文章!
<%}%>
&nbsp;&nbsp;&nbsp;&nbsp;</td>
                  </tr>
                </tbody>
            </table>
          <br></td>
      </tr>
      <tr>
        <td><%
	cn.js.fan.module.pvg.Privilege privilege = new cn.js.fan.module.pvg.Privilege();
    LeafPriv lp = new LeafPriv();
	lp.setDirCode(doc.getDirCode());
    if (!lp.canUserSee(privilege.getUser(request))) {
		out.print(StrUtil.makeErrMsg(privilege.MSG_INVALID) + "<BR><BR>");
	}
	else {
		if (doc!=null && pageNum==1) {
			// 使点击量增1
			doc.increaseHit();
		}
	%>
              <%if (doc.isLoaded()) {%>
              <%=doc.getContent(pageNum)%>
              <%}%>
              <br>
              <br>
              <%
			  if (doc!=null) {
				  java.util.Vector attachments = doc.getAttachments(pageNum);
				  java.util.Iterator ir = attachments.iterator();
				  while (ir.hasNext()) {
				  	Attachment am = (Attachment) ir.next(); %>
              <table width="569"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="91" height="26" align="right"><img src=images/attach.gif></td>
                  <td>&nbsp; <a target=_blank href="doc_getfile.jsp?id=<%=doc.getID()%>&attachId=<%=am.getId()%>"><%=am.getName()%></a> &nbsp;下载次数&nbsp;<%=am.getDownloadCount()%></td>
                </tr>
              </table>
          <%}
			  }
			  %>
              <%if (doc.getType()==1 && (op.equals("") || !op.equals("vote"))) {
					String[] voptions = doc.getVoteOption().split("\\|");
					int len = voptions.length; %>
              <table width="100%" >
                <form action="?op=vote" name=formvote method="post">
                  <input type=hidden name=op value="vote">
                  <input type=hidden name=id value="<%=doc.getID()%>">
                  <%for (int k=0; k<len; k++) { %>
                  <tr>
                    <td width="5%"><%=k+1%>、 </td>
                    <td width="73%"><input class="n" type=radio name=votesel value="<%=k%>">
                        <%=voptions[k]%> </td>
                    <td>&nbsp;</td>
                  </tr>
                  <% } %>
                  <tr>
                    <td colspan="2" align="center"><input name="Submit" type="submit" class="singleboarder" value=" 投  票 ">
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="btn" type="button" class="singleboarder" value="查看结果" onClick="window.location.href='doc_show.jsp?id=<%=id%>&view=result'"></td>
                    <td width="22%">&nbsp;</td>
                  </tr>
                </form>
              </table>
          <%}%>
              <br>
              <%if (view.equals("result") || op.equals("vote")) {
					String[] result = doc.getVoteResult().split("\\|");
					int len = result.length;
					int[] re = new int[len];
					int[] bfb = new int[len];
					int total = 0;
					for (int k=0; k<len; k++) {
						re[k] = Integer.parseInt(result[k]);
						total += re[k];
					}
					if (total!=0) {
						for (int k=0; k<len; k++) {
							bfb[k] = (int)Math.round((double)re[k]/total*100);
						}
					}
		%>
              <table class=p9 width="98%" border="0" cellpadding="0" cellspacing="1" height="100">
                <% 
				int barId = 0;
				for (int k=0; k<len; k++) { %>
                <tr bgcolor="#FEF2E9">
                  <td width="5%"><%=k+1%>、</td>
                  <td width="59%">
				  <img src="forum/images/vote/bar<%=barId%>.gif" width=<%=bfb[k]*2%> height=10>
				  </td>
                  <td width="17%" align="right"><%=re[k]%>人</td>
                  <td width="19%" align="right"><%=bfb[k]%>%</td>
                </tr>
                <%
					barId ++;
					if (barId==10)
						barId = 0;				
				}%>
                <tr bgcolor="#FEF2E9">
                  <td colspan="4" align="center">共有<%=total%>人参加调查</td>
                </tr>
              </table>
          <%}%>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="24" align="center">文章共<%=doc.getPageCount()%>页&nbsp;&nbsp;页码
                    <%
					int pagesize = 1;
					int total = DocContent.getContentCount(doc.getID());
					int curpage,totalpages;
					Paginator paginator = new Paginator(request, total, pagesize);
					// 设置当前页数和总页数
					totalpages = paginator.getTotalPages();
					curpage	= paginator.getCurrentPage();
					if (totalpages==0)
					{
						curpage = 1;
						totalpages = 1;
					}
					
					String querystr = "op=edit&id=" + id;
					out.print(paginator.getCurPageBlock("doc_show.jsp?"+querystr));
					%></td>
                </tr>
              </table>
          <table height="20" cellSpacing="0" cellPadding="5" width="99%" align="center" bgColor="#e4e4e4" border="0">
                <tbody>
                  <tr>
                    <td><%if (doc.getCanComment()) {%>
                        <img height="15" src="images/comment.gif" width="19" align="absMiddle"><a href="#comment">发表评论</a>
                        <%}%>
                        <img height="15" src="images/question.gif" width="19" align="absMiddle"><a href="forum/index.jsp">提出问题</a> <img height="15" src="images/close.gif" width="19" align="absMiddle"><a href="javascript:window.close()">关闭</a> </td>
                  </tr>
                </tbody>
            </table>
          <%
	      cn.js.fan.module.cms.Config cfg = new cn.js.fan.module.cms.Config();
    	  boolean isShow = cfg.getBooleanProperty("cms.isRelateShow"); 
		  if (isShow && doc.getIsRelateShow()) {%>
              <table width="568"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="26"></td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="6" height="26"></td>
                  <td width="562" background="images/correlation.gif">&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td align="left"><table width=100% border=0 align="left" cellpadding="0" cellspacing="0" class="p9">
                      <%
	String keywords = StrUtil.getNullStr(doc.getKeywords());
	if (!keywords.equals("")) {
		// String ft_sql = "select id from document WHERE CONTAINS( keywords, " + StrUtil.sqlstr(keys) + " )"; // 用于SQL SERVER全文检索
		String ft_sql = SQLBuilder.getDocRelateSql(keywords);
%>
                      <%@ taglib uri="/WEB-INF/tlds/DocListTag.tld" prefix="dl" %>
                      <dl:DocListTag action="" query="<%=ft_sql%>" dirCode="<%=DocCacheMgr.FULLTEXT%>" start="0" end="7">
                        <dl:DocListItemTag field="title" mode="detail">
                          <tr>
                            <td height=20 align="left">&nbsp;&nbsp;<a href="doc_show.jsp?id=$id">$title</a>&nbsp;&nbsp;&nbsp;[$modifiedDate]</td>
                          </tr>
                        </dl:DocListItemTag>
                      </dl:DocListTag>
                      <%}%>
                  </table></td>
                </tr>
              </table>
          <%}%>
              <br>
              <table width="98%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="5"></td>
                  <td><%
java.util.Iterator ir = cm.getList(id);
while (ir.hasNext()) {
	Comment cmt = (Comment) ir.next();
%>
                      <table width="480" >
                        <tr>
                          <td width="607" height="27"><span class="style1">评论</span>:</td>
                        </tr>
                      </table>
                    <table width="480" cellpadding="0" cellspacing="0" >
                        <tr>
                          <td height="43" align="center" class="tableframe_comment"><table width="99%" align="center" >
                              <tr>
                                <td height="22" bgcolor="#F2F2F2"><span class="style1"><a target="_blank" href="<%=cmt.getLink()%>"><%=cmt.getNick()%></a>&nbsp;发表于&nbsp;<%=cmt.getAddDate()%> </span></td>
                              </tr>
                              <tr>
                                <td><%=cmt.getContent()%></td>
                              </tr>
                          </table></td>
                        </tr>
                    </table>
                    <%	
}
%>
                      <br>
                      <%if (doc.isCanComment()) {%>
                      <table width="44%" cellpadding="0" cellspacing="0" class="tableframe_gray" >
                        <tr>
                          <td><table width="100%" >
                              <form name="form1" method="post" action="?op=addcomment">
                                <tr align="left" bgcolor="#CCCCCC">
                                  <td height="24" colspan="3"><span class="style1">&nbsp;发表评论<a name="comment"></a></span></td>
                                </tr>
                                <tr>
                                  <td height="24" colspan="2" align="left">姓&nbsp;名
                                    <input type="text" name="nick" size="15">
                                      <input type="hidden" name="doc_id" value="<%=doc.getID()%>">
                                      <input type="hidden" name="id" value="<%=doc.getID()%>">
                                  </td>
                                  <td width="46%" align="left"> 来&nbsp;自
                                    <input name="link" type="text" size="15"></td>
                                </tr>
                                <tr>
                                  <td width="9%" align="center">内&nbsp;容 </td>
                                  <td colspan="2" align="left"><textarea name="content" cols="45" rows="8"></textarea></td>
                                </tr>
                                <tr>
                                  <td colspan="3" align="center"><input name="Submit" type="submit" class="singleboarder" value="提交">
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <input name="Submit" type="reset" class="singleboarder" value="重置"></td>
                                </tr>
                              </form>
                          </table></td>
                        </tr>
                      </table>
                    <%}%>
                      <%}%>
                  </td>
                </tr>
            </table></td>
      </tr>
    </table></TD>
  </TR>
</TABLE>
<%@ include file="forum/inc/footer.jsp"%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -