protected string PagedArticles() { string oldent = GetGlobalResourceObject("language", "OlderEntries").ToString(); string newent = GetGlobalResourceObject("language", "NewerEntries").ToString(); string auth = null; string tags = null; string category = null; string year = null; string month = null; string result = ""; string spname = ""; anm_Utility ut = new anm_Utility(); string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); if (Request.QueryString["year"] != null) { year = Request.QueryString["year"]; month = Request.QueryString["month"]; } if (Request.QueryString["tag"] == null) { if (Request.QueryString["author"] == null) { if (Request.QueryString["category"] != null) { category = Request.QueryString["category"]; if (year == null) { spname = "anm_showAllNewsByCatPaged"; } else { spname = "anm_showAllNewsByCatDatePaged"; } } else { if (year == null) { spname = "anm_showAllNewsPaged"; } else { spname = "anm_showAllNewsByDatePaged"; } } } else { auth = Request.QueryString["author"]; spname = "anm_getNewsByAuthorPaged"; } } else { tags = Request.QueryString["tag"]; spname = "anm_getNewsByTagPaged"; } int maximumRows = 15; int numarticles = 0; if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { numarticles = ut.GetNumberArticle(Convert.ToInt32(month), Convert.ToInt32(year), Convert.ToInt32(category)); } else { numarticles = ut.GetNumberArticles(Convert.ToInt32(category)); } } else if (year != null) { numarticles = ut.GetNumberArticle(Convert.ToInt32(month), Convert.ToInt32(year)); } else { numarticles = ut.GetNumberArticles(); } } else { numarticles = ut.GetNumberArticles(ut.UrlDecode(auth)); } } else { numarticles = ut.GetNumberArticle(ut.UrlDecode(tags)); } if (ut.GetSetting("NumArticles") != "") { maximumRows = Convert.ToInt32(ut.GetSetting("NumArticles")); } int maxpage = (numarticles / maximumRows) + 1; if (numarticles % maximumRows == 0) { maxpage = numarticles / maximumRows; } SqlCommand myCommand = new SqlCommand(spname, myConnection); myCommand.CommandType = CommandType.StoredProcedure; if (auth == null && tags == null) { myCommand.Parameters.Add("@highlight", SqlDbType.VarChar).Value = "False"; myCommand.Parameters.Add("@sidenews", SqlDbType.VarChar).Value = "False"; } if (Request.QueryString["page"] != null) { myCommand.Parameters.Add("@startRowIndex", SqlDbType.VarChar).Value = maximumRows * (Convert.ToInt32(Request.QueryString["page"]) - 1); } else { myCommand.Parameters.Add("@startRowIndex", SqlDbType.VarChar).Value = "0"; } myCommand.Parameters.Add("@maximumRows", SqlDbType.VarChar).Value = maximumRows; if (category != null) { myCommand.Parameters.Add("@idcategory", SqlDbType.VarChar).Value = category; } if (year != null) { myCommand.Parameters.Add("@year", SqlDbType.VarChar).Value = year; myCommand.Parameters.Add("@month", SqlDbType.VarChar).Value = month; } if (auth != null) { myCommand.Parameters.Add("@author", SqlDbType.NVarChar).Value = ut.UrlDecode(auth); } if (tags != null) { string value = ut.UrlDecode(tags); value = value.Replace("[", "[[]"); value = value.Replace("%", "[%]"); value = value.Replace("_", "[_]"); myCommand.Parameters.Add("@tag", SqlDbType.NVarChar).Value = value; } myConnection.Open(); SqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { string idnews = reader["idnews"].ToString(); string title = reader["title"].ToString(); string author = reader["Author"].ToString(); string date = reader["date"].ToString(); string postedby = reader["postedby"].ToString(); string image = reader["image"].ToString(); string summary = reader["Summary"].ToString(); string news = reader["News"].ToString(); string commentcheck = reader["commentcheck"].ToString(); string comments = reader["comments"].ToString(); result += "<div class='post'>" + "<h3 class='title'><a href='" + apath + "/articles/" + idnews + "/" + RNA(title) + ".aspx'>" + title + "</a> <span class='right'>" + Edit(idnews) + "</span></h3>" + "<div class='anmbyline'>" + PostedBy(author, date, postedby) + "</div>" + "<div class='postcontent'><a href='" + apath + "/articles/" + idnews + "/" + RNA(title) + ".aspx'>" + ShowImage(image) + "</a>" + ViewNews(summary, news) + "</div>" + "<div class='meta'>" + "<span class='links'>" + ReadMore(summary, idnews, title, commentcheck) + " " + Comments(idnews, commentcheck, comments, title) + "</span><br />" + "<div class='addthis_toolbox addthis_default_style '></div>" + "</div>" + "</div>"; } myConnection.Close(); string newold = "<div class='center'>"; int page = 1; if (Request.QueryString["page"] != null) { page = Convert.ToInt32(Request.QueryString["page"].ToString()); if (numarticles > maximumRows) { if (page > 1 && page < maxpage) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { newold += "<a href='" + apath + "/page" + (page - 1) + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' rel='nofollow'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/category" + category + ".aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/category" + category + ".aspx' rel='nofollow'>" + oldent + "</a>"; } } else { if (year != null) { newold += "<a href='" + apath + "/page" + (page - 1) + "/year_" + year + "/month_" + month + ".aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/year_" + year + "/month_" + month + ".aspx' rel='nofollow'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/news.aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/news.aspx' rel='nofollow'>" + oldent + "</a>"; } } } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' rel='nofollow'>" + oldent + "</a>"; } } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/tag/" + ut.UrlEncode(tags) + ".aspx' rel='nofollow'>" + newent + "</a> "; newold += "<a href='" + apath + "/page" + (page + 1) + "/tag/" + ut.UrlEncode(tags) + ".aspx' rel='nofollow'>" + oldent + "</a>"; } } if (page == 1 && page < maxpage) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { newold += "<a href='" + apath + "/page" + (page + 1) + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page" + (page + 1) + "/category" + category + ".aspx'>" + oldent + "</a>"; } } else { if (year != null) { newold += "<a href='" + apath + "/page" + (page + 1) + "/year_" + year + "/month_" + month + ".aspx'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page" + (page + 1) + "/news.aspx'>" + oldent + "</a>"; } } } else { newold += "<a href='" + apath + "/page" + (page + 1) + "/articles/author/" + ut.UrlEncode(auth) + ".aspx'>" + oldent + "</a>"; } } else { newold += "<a href='" + apath + "/page" + (page + 1) + "/tag/" + ut.UrlEncode(tags) + ".aspx'>" + oldent + "</a>"; } } if (page > 1 && page == maxpage) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { newold += "<a href='" + apath + "/page" + (page - 1) + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx'>" + newent + "</a> "; } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/category" + category + ".aspx'>" + newent + "</a> "; } } else { if (year != null) { newold += "<a href='" + apath + "/page" + (page - 1) + "/year_" + year + "/month_" + month + ".aspx'>" + newent + "</a> "; } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/news.aspx'>" + newent + "</a> "; } } } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/articles/author/" + ut.UrlEncode(auth) + ".aspx'>" + newent + "</a> "; } } else { newold += "<a href='" + apath + "/page" + (page - 1) + "/tag/" + ut.UrlEncode(tags) + ".aspx'>" + newent + "</a> "; } } } } else { if (numarticles > maximumRows) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { newold += "<a href='" + apath + "/page2/month_" + month + "/year_" + year + "/cat" + category + ".aspx'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page2/category" + category + ".aspx'>" + oldent + "</a>"; } } else { if (year != null) { newold += "<a href='" + apath + "/page2/year_" + year + "/month_" + month + ".aspx'>" + oldent + "</a>"; } else { newold += "<a href='" + apath + "/page2/news.aspx'>" + oldent + "</a>"; } } } else { newold += "<a href='" + apath + "/page2/articles/author/" + ut.UrlEncode(auth) + ".aspx'>" + oldent + "</a>"; } } else { newold += "<a href='" + apath + "/page2/tag/" + ut.UrlEncode(tags) + ".aspx'>" + oldent + "</a>"; } } } if (newold != "<div class='center'>") { newold += "</div>"; } else { newold = ""; } string linknav = "<div class='linkpage'>"; if (Request.QueryString["page"] != null) { page = Convert.ToInt32(Request.QueryString["page"].ToString()); if (numarticles > maximumRows) { for (int i = (page - 5); i < (page + 10); i++) { if (i >= 1 && i <= (maxpage)) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' class='pagenav'>" + i + "</a> "; } } else { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/category" + category + ".aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/category" + category + ".aspx' class='pagenav'>" + i + "</a> "; } } } else { if (year != null) { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/year_" + year + "/month_" + month + ".aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/year_" + year + "/month_" + month + ".aspx' class='pagenav'>" + i + "</a> "; } } else { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/news.aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/news.aspx' class='pagenav'>" + i + "</a> "; } } } } else { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' class='pagenav'>" + i + "</a> "; } } } else { if (page == i) { linknav += "<a href='" + apath + "/page" + i + "/tag/" + ut.UrlEncode(tags) + ".aspx' class='pagenavselected'>" + i + "</a> "; } else { linknav += "<a href='" + apath + "/page" + i + "/tag/" + ut.UrlEncode(tags) + ".aspx' class='pagenav'>" + i + "</a> "; } } } } } } else { for (int i = 1; i < 11; i++) { if (tags == null) { if (auth == null) { if (category != null) { if (year != null) { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/month_" + month + "/year_" + year + "/cat" + category + ".aspx' class='pagenav'>" + i + "</a> "; } } else { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/category" + category + ".aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/category" + category + ".aspx' class='pagenav'>" + i + "</a> "; } } } else { if (year != null) { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/year_" + year + "/month_" + month + ".aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/year_" + year + "/month_" + month + ".aspx' class='pagenav'>" + i + "</a> "; } } else { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/news.aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/news.aspx' class='pagenav'>" + i + "</a> "; } } } } else { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/articles/author/" + ut.UrlEncode(auth) + ".aspx' class='pagenav'>" + i + "</a> "; } } } else { if (i == 1) { linknav += "<a href='" + apath + "/page" + i + "/tag/" + ut.UrlEncode(tags) + ".aspx' class='pagenavselected'>" + i + "</a> "; } if (i > 1 && i <= maxpage) { linknav += "<a href='" + apath + "/page" + i + "/tag/" + ut.UrlEncode(tags) + ".aspx' class='pagenav'>" + i + "</a> "; } } } } if (linknav != "<div class='linkpage'>") { linknav += "- " + GetGlobalResourceObject("language", "Page") + " " + page + " " + GetGlobalResourceObject("language", "Of") + " " + maxpage + "</div>"; } else { linknav = ""; } LTpagelink.Text = linknav; if (result == "" || maxpage == 1) { LTpagelink.Visible = false; } return(result + newold); }