using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class list : Ycbw.Data.OleDbClient
{
	public int Width = 640, Height = 400;
	public int TitleLength = 50, ContentLength = 400;

    protected void Page_Load(object sender, EventArgs e)
    {	
        string sql = "select * from [v_articles]";
		string filter = " where id > 0";
		string order = " order by state desc, addtime desc";

		if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
		{
			filter += " and cid in (" + new Ycbw.Categories(this, Convert.ToInt32(Request.QueryString["id"])).GetFamily() +")";

			//¿Ø¼þ
			Ycbw.Articles A = new Ycbw.Articles(this);

			this.navigation.Cid = A.Cid;
			this.category.Text  = A.ClassName;
			this.path.Text  	= "ÄúµÄÎ»ÖÃ£º<a href=\"/index.aspx\">Ê×Ò³</a> > " + A.Path;

			//SEO
			this.Head.Title 	= A.ClassName;
			this.Head.Keywords  = "ÒË²ý" + A.ClassName + "," + this.Configuration["keywords"].ToString();
		}
		
		if( Request.QueryString["key"] != null && Request.QueryString["key"] != "" )
			filter += " and title like '%"+ Request.QueryString["key"] +"%'";

		this.BindList( sql + filter + order, "b_articles", data_articles, 20, text_pages);
    }

    public string GetLink(object id, object link, object filename)
    {
        if (link.ToString() != "")
            return link.ToString();
        else
            return "../"+ filename.ToString() +"-"+ id.ToString() + ".aspx";//<%# DataBinder.Eval(Container.DataItem, "id") %>
    }
	
	public string GetPicture(string picture, int width, int height)
	{
		if( picture != "" )
			return "<img src="+ picture +" width="+ width +" border=0 onerror=\"this.onerror=null;this.src='/images/nopic.jpg';\" />";
		else
			return "";
	}
}
