<%@page contentType="text/xml;charset=UTF-8" %><%@page import="jcms.util.SafeUtil"%><%@page 
import="jcms.blf.webinfo.Jcms_WebinfomationBLF"%><%@page 
import="jcms.entity.Jcms_WebinfomationEntity"%><%@page 
import="com.hanweb.common.util.Convert"%><%@page 
import="jcms.blf.column.Jcms_CataloginfoBLF"%><%@page 
import="jcms.entity.Jcms_CataloginfoEntity"%><%@page 
import="jcms.extramodule.rss.RssFun"%><%@page 
import="com.hanweb.common.log.LogWriter"%><%@page 
import="jcms.makenewpage.ArticleFile"%><%@page 
import="jcms.blf.info.Jcms_InforefBLF"%><%@page 
import="jcms.make.makeunit.Info"%><%@page 
import="jcms.entity.Jcms_InforefEntity"%><%@page 
import="java.text.SimpleDateFormat"%><%@page 
import="java.util.Date"%><%@page 
import="java.util.Locale"%><%@include file="config.jsp" %><%
	String errtext = "";
	strAppID = Convert.getValue( strAppID );
	if( strAppID.trim().length() == 0 )
		strAppID = "1";
	
	strWebID = Convert.getValue( strWebID );
	//栏目ID
	String strColID = Convert.getParameter(request,"colid","",true,true );  
	if(SafeUtil.isSqlAndXss(strColID)) {
		out.println("参数包含非法字符,禁止访问");
		return;
	}
	if( strColID.length() == 0  ){
        out.println(errtext);
        LogWriter.debug( " ressfeed :未指定栏目ID");
		return;
	}
	int maxItems = Convert.getParameterInt(request,"maxitems",100);
	
	Jcms_WebinfomationBLF webblf = new Jcms_WebinfomationBLF( strAppID );
	Jcms_WebinfomationEntity webentity = webblf.getWebEntity( Convert.getStringValueInt( strWebID ));
	if( webentity == null )	{
        out.println(errtext);
		return;
	}
	Jcms_InforefBLF refblf = new Jcms_InforefBLF( strAppID );
    String magurl = "http://"+Jcms_WebinfomationBLF.getWebDomain( strAppID,Convert.getStringValueInt(strWebID));  //网站域名
    String maginfo = Jcms_WebinfomationBLF.getWebName( strAppID,Convert.getStringValueInt(strWebID) ); //网站描述
	
    //判断当前栏目是否支持RSS属性
	Jcms_CataloginfoBLF catablf = new Jcms_CataloginfoBLF( strAppID,strWebID );
	Jcms_CataloginfoEntity cataentity = catablf.getRssCataEntity( strColID );
	
	if( cataentity == null )
	{
		errtext = "
此栏目不支持RSS!
";
        out.println(errtext);
		return;
	}
	String strColName;
	String strColUrl;
	//判断是否多栏目聚合
	if(strColID.indexOf(",")<0){
		strColName = cataentity.getVc_cataname();
		strColUrl = cataentity.getVc_url();
		if( strColUrl.indexOf("/col") == 0 ){
			strColUrl = magurl + strColUrl;
		}
	}else{
		strColName = Jcms_WebinfomationBLF.getWebName(strAppID,Convert.getStringValueInt(strWebID));
		strColUrl = magurl;
	}
	
	rss.setVersion("2.0");
	rss.setXmlstylesheet("type=\"text/css\" href=\"./rsscopy.css\"");
	//第二部 设置XML参数
	rss.setXmlParas("UTF-8", "1.0", false);
	//第三部 添加频道
	rss.setChannel(strColName,							//频道名称
				   maginfo,							//频道属性或者网站说明
				   strColUrl,						//频道的链接地址
				   magurl,							//频道统一资源标志符
				   "zh-cn",							//频道语言版本
				   "",								//频道的版权
				   "",								//频道的发布日期
				   ""								//频道的编辑
				   );
	RssFun rssfun = new RssFun( strAppID,Convert.getStringValueInt( strWebID ));
	java.util.ArrayList list = rssfun.getRssData( strColID,0,maxItems );
	String strDiscription = "";		//摘要
	String title = "";				//标题
	String link = "";				//URL
	String createdate = "";			//创建时间
	String strAuthor = "";
	jcms.entity.SearchInfoEntity entity = null; 
	Jcms_InforefEntity refEn = null;
	String strInfoHref = "";
	for( int i=0;list!=null&&i0  )
					link = "http://" + strDomain +"/"+ strInfoHref;
			}
		}else{
			link = Info.getInfoUrl( link, strInfoHref );
		}
		
		createdate = Convert.getValue( this.dateFormat(entity.getC_createdate()) );
		strDiscription = Convert.getValue( entity.getVc_abs() );
		strAuthor = Convert.getValue( entity.getVc_author() );
		title=Convert.limitLen(title,100,"UTF-8");
		rss.setItems( title,link,strDiscription,strAuthor,createdate,"","" );
	}
	String strXml = rss.getXml();
    out.println(strXml);
%>
<%!
private String dateFormat(String dateString){
	try{
		SimpleDateFormat sdf = new java.text.SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z",Locale.US);
		java.text.SimpleDateFormat sdf2 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = sdf2.parse(dateString);
		return sdf.format(date);
	}catch(Exception e){
		System.out.println("rssfeed.jsp exception!!");
		e.printStackTrace();
		return "";
	}
}
%>