%@page language="java" contentType="text/javascript; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.hanweb.common.util.DateUtil"%>
<%@page import="com.hanweb.common.util.NumberUtil"%>
<%@page import="com.hanweb.common.util.StringUtil"%>
<%@page import="com.hanweb.common.util.mvc.Script"%>
<%@page import="com.hanweb.jcms.build.service.makeunit.Info"%>
<%@page import="com.hanweb.jcms.constant.CacheType"%>
<%@page import="com.hanweb.jcms.constant.Caches"%>
<%@page import="com.hanweb.jcms.constant.Tables"%>
<%@page import="com.hanweb.jcms.entity.Jcms_DefEntity"%>
<%@page import="com.hanweb.jcms.entity.Jcms_InfoEntity"%>
<%@page import="com.hanweb.jcms.entity.Jcms_InforefEntity"%>
<%@page import="com.hanweb.jcms.service.column.Jcms_CataloginfoBLF"%>
<%@page import="com.hanweb.jcms.service.info.CustomizeInfoBLF"%>
<%@page import="com.hanweb.jcms.service.info.Jcms_InfoBLF"%>
<%@page import="com.hanweb.jcms.service.info.Jcms_InforefBLF"%>
<%@page import="com.hanweb.jcms.service.info.generalformat.GeneralFormatBLF"%>
<%@page import="com.hanweb.jcms.service.website.Jcms_WebinfomationBLF"%>
<%@page import="com.hanweb.jcms.sys.service.SysInfo"%>
<%@page import="com.hanweb.jcms.sys.service.SysInit"%>
<%@page import="com.hanweb.jcms.util.CacheUtil"%>
<%@page import="com.hanweb.jcms.util.SafeUtil"%>
<%@page import="com.hanweb.jcms.util.xml.XMLFile"%>
<%@ page import="org.apache.commons.logging.Log"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@ page import="java.util.ArrayList"%><%@ page import="com.hanweb.jcms.util.HttpUrl"%>
<%@include file="./config.jsp" %>
<%
Script script = Script.getInstanceOnly();
String referer = request.getHeader("Referer");
if (StringUtil.isEmpty(referer)) { //阻止跨站点请求伪造
out.print(script.addScript("location.href='../../';").getScript());
return;
}
Log logger = LogFactory.getLog(getClass());
int iWebId = NumberUtil.getInt(request.getParameter("webid"));
int iCataId = NumberUtil.getInt(request.getParameter("cataid"));
int iCataType = NumberUtil.getInt(request.getParameter("catatype"));
int iOrderId = NumberUtil.getInt(request.getParameter("orderid"));
int infoId = NumberUtil.getInt(request.getParameter("infoid"));
infoId = Math.max(infoId, 0);
String strPosition = SafeUtil.getSafeString(request.getParameter("position"));
String showTip = SafeUtil.getSafeString(request.getParameter("showtip"));
if (showTip.equals("")) {
showTip = "0";
}
int titlelimit = NumberUtil.getInt(request.getParameter("titlelimit"), 20);
if (titlelimit < 0) {
logger.error("标题长度限制不正确");
return;
}
if (iWebId == 0 || iCataId == 0 || iCataType == 0 || strPosition.equals("") || infoId == 0) {
logger.error("网站id或者栏目id或者栏目类型或者信息id或者位置存在为0或者空的情况");
return;
}
int iPosition = 0;
if ("next".equals(strPosition)) {
iPosition = 1;
}
String strPath = application.getRealPath("") + "/jcms_files/jcms1/web" + iWebId + "/site/module/changepage/";
String strConfigPath = strPath + "config/config.xml";
XMLFile xmlFile = new XMLFile();
String strwebtype = xmlFile.getContent("webtype", strConfigPath);
String cacheName = Caches.GETTITLE.name();
String keyName = iWebId + "_" + iCataId + "_" + infoId + "_" + iPosition;
String vc_meg ="" ;
if(strwebtype.equals("2")){
vc_meg = CacheUtil.getValue(cacheName, keyName, CacheType.str);
}
if(StringUtil.isEmpty(vc_meg)){
ArrayList al_info;
String strCurrentDate = DateUtil.currDay();
String strTableName;
SysInfo sys = new SysInfo();
sys.initSysPara(request);
Jcms_InfoBLF infoBLF = Jcms_InfoBLF.getInstance().init(strAppID, NumberUtil.getInt(strWebID));
//自定义
if (3 == iCataType) {
//根据信息id重新获取排序id,避免文章排序后未重新发布导致翻页混乱
CustomizeInfoBLF customizeInfoBlf = CustomizeInfoBLF.getInstance().init(strAppID, NumberUtil.getInt(strWebID));
Jcms_DefEntity defEntity = customizeInfoBlf.getDefEntity(String.valueOf(infoId), iCataId, "jcms_" + iWebId + "_" + iCataId);
if (defEntity != null) {
iOrderId = defEntity.getI_orderid();
} else {
logger.error("信息不存在");
return;
}
al_info = infoBLF.getTitleByDef(iPosition, iOrderId, iCataId, iWebId);
//指定表
} else if (6 == iCataType) {
return;
//元数据
} else if (7 == iCataType) {
Jcms_CataloginfoBLF catablf = Jcms_CataloginfoBLF.getInstance();
strTableName = catablf.getTableName(iCataId + "");
//}
GeneralFormatBLF generalFormatBlf = GeneralFormatBLF.getInstance().init(strAppID, NumberUtil.getInt(strWebID));
Jcms_DefEntity gfdefEntity = generalFormatBlf.getEntity(infoId, iCataId, strTableName);
if (gfdefEntity != null) {
iOrderId = gfdefEntity.getI_orderid();
} else {
logger.error("信息不存在");
return;
}
al_info = infoBLF.getTitleByGfdef(iPosition, iOrderId, iCataId, strTableName, iWebId);
//多信息
} else {
//根据信息id重新获取排序id,避免文章排序后未重新发布导致翻页混乱
Jcms_InfoEntity infoEntity = infoBLF.getEntityES(strAppID, infoId, Tables.INFO + "_" + iWebId);
if (infoEntity != null) {
iOrderId = infoEntity.getI_orderid();
} else {
logger.error("信息不存在");
return;
}
al_info = infoBLF.getTitleByMore(iPosition, strCurrentDate, iOrderId, iCataId, iWebId);
}
//系统路径
String strSysPath;
if (strwebtype.equals("1")) {
String strWebServerName = SysInit.getM_strAppPath();
strSysPath = "/" + strWebServerName + "/jcms_files/jcms" + strAppID + "/web" + iWebId + "/site/view/";
} else {
strSysPath = "/";
}
String strUrl = "";
String vc_title ;
String showtitle ;
int oInfoId = 0;
String strDomain = "";
if (null != al_info && al_info.size() > 0) {
//自定义、元数据
if (3 == iCataType || 7 == iCataType) {
Jcms_DefEntity defEn = (Jcms_DefEntity) al_info.get(0);
oInfoId = defEn.getI_id();
vc_title = StringUtil.trim(defEn.getVc_name());
vc_title = StringUtil.removeHTML(vc_title);
showtitle = vc_title.trim().length() > titlelimit ? vc_title.substring(0, titlelimit) + "..." : vc_title;
//处理链接网址
if (defEn.getVc_href().trim().length() > 0) {
//链接信息处理
if (defEn.getB_ref() == 2) {
//找当前信息的源信息的网站域名
Jcms_InforefEntity refEn = new Jcms_InforefEntity();
Jcms_InforefBLF refblf = Jcms_InforefBLF.getInstance().init(sys.appId);
refEn = refblf.getSEntity(oInfoId, iCataId);
if (refEn != null) {
strDomain = Jcms_WebinfomationBLF.modifyAndGetWebDomain(strAppID, refEn.getI_swebid());
if (strDomain.trim().length() > 0) {
if(HttpUrl.isStartWithHttp(strDomain)){
strUrl = strDomain + "/" + StringUtil.trim(defEn.getVc_href());
}else{
strUrl = "http://" + strDomain + "/" + StringUtil.trim(defEn.getVc_href());
}
}
}
//非链接信息处理
} else {
strUrl = StringUtil.trim(defEn.getVc_href());
}
//组织输出
if (1 == iPosition) {
String tipsdown = "";
if (showTip.equals("0")) {
tipsdown = "下一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsdown + showtitle + "";
} else {
String tipsup = "";
if (showTip.equals("0")) {
tipsup = "上一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsup + showtitle + "";
}
vc_meg = vc_meg.replaceAll("'", "\"");
//常规信息处理
} else {
strUrl = Info.getInfoUrl(strSysPath, iCataId, defEn.getI_id(), defEn.getC_deploytime());
//组织输出
if (1 == iPosition) {
String tipsdown = "";
if (showTip.equals("0")) {
tipsdown = "下一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsdown + showtitle + "";
} else {
String tipsup = "";
if (showTip.equals("0")) {
tipsup = "上一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsup + showtitle + "";
}
vc_meg = vc_meg.replaceAll("'", "\"");
}
//多信息
} else {
Jcms_InfoEntity infoEn = (Jcms_InfoEntity) al_info.get(0);
String strHref = StringUtil.trim(infoEn.getVc_href());
String strLink = StringUtil.trim(infoEn.getVc_linktitle());
vc_title = StringUtil.trim(infoEn.getVc_title());
vc_title = StringUtil.removeHTML(vc_title);
showtitle = vc_title.length() > titlelimit ? vc_title.substring(0, titlelimit) + "..." : vc_title;
oInfoId = infoEn.getI_id();
//处理链接标题、链接网址
if (strHref.trim().length() > 0) {
if (infoEn.getB_ref() == 2) {
//链接标题优先
if (strLink.trim().length() > 0) {
strUrl = strLink;
//链接信息处理
} else if (strHref.startsWith("http")) {
strUrl = strHref;
} else {
//找当前信息的源信息的网站域名
Jcms_InforefEntity refEn = new Jcms_InforefEntity();
Jcms_InforefBLF refblf = Jcms_InforefBLF.getInstance().init(sys.appId);
refEn = refblf.getSEntity(oInfoId, iCataId);
if (refEn != null) {
strDomain = Jcms_WebinfomationBLF.modifyAndGetWebDomain(strAppID, refEn.getI_swebid());
if (strDomain.trim().length() > 0) {
if(HttpUrl.isStartWithHttp(strDomain)){
strUrl = strDomain + "/" + strHref;
}else{
strUrl = "http://" + strDomain + "/" + strHref;
}
}
}
}
//链接网址处理
} else {
if (strLink.trim().length() > 0) {
strUrl = strLink;
} else {
strUrl = strHref;
}
}
//组织输出
if (1 == iPosition) {
String tipsdown = "";
if (showTip.equals("0")) {
tipsdown = "下一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsdown + showtitle + "";
} else {
String tipsup = "";
if (showTip.equals("0")) {
tipsup = "上一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsup + showtitle + "";
}
vc_meg = vc_meg.replaceAll("'", "\"");
//常规信息
} else {
strUrl = Info.getInfoUrl(strSysPath, iCataId, infoEn.getI_id(), infoEn.getC_deploytime());
//组织输出
if (1 == iPosition) {
String tipsdown = "";
if (showTip.equals("0")) {
tipsdown = "下一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsdown + showtitle + "";
} else {
String tipsup = "";
if (showTip.equals("0")) {
tipsup = "上一篇:";
}
if (!("").equals(showtitle))
vc_meg = "" + tipsup + showtitle + "";
}
vc_meg = vc_meg.replaceAll("'", "\"");
}
}
}
if (strwebtype.equals("2")) {
vc_meg = vc_meg.replaceAll(strSysPath, "/");
}
//所有的"http://" + strDomain +"/"改为相对路径输出!
//vc_meg = vc_meg.replaceAll("http://" + strDomain + "/", "../../");
if(strwebtype.equals("2")){
CacheUtil.setValue(cacheName, keyName, vc_meg);
}
}
out.println("document.write('" + vc_meg + "');");
%>