コード例 #1
0
    protected string FatherCat(string idcat)
    {
        anm_Utility ut = new anm_Utility();

        if (idcat == "0")
        {
            return("-");
        }
        else
        {
            return(ut.GetCategory(idcat));
        }
    }
コード例 #2
0
    protected string Category(string idcat, string date)
    {
        anm_Utility ut       = new anm_Utility();
        HtmlLink    myrss    = new HtmlLink();
        string      category = ut.GetCategory(idcat);
        string      res      = "";

        //myrss.Href = path + "?p=Rss&cat=" + idcat;
        myrss.Href = "subscribe/" + idcat + ".aspx";
        myrss.Attributes.Add("type", "application/rss+xml");
        myrss.Attributes.Add("rel", "alternate");
        myrss.Attributes.Add("title", category + " RSS" + " - " + ut.GetSetting("SiteName"));
        Page.Header.Controls.Add(myrss);
        res = "<strong><a href='" + apath + "/category" + idcat + ".aspx'>" + category + "</a></strong>";
        DateTime d = Convert.ToDateTime(date);

        HLContentArchive.NavigateUrl = apath + "/archive/month_" + d.Month + "/year_" + d.Year + "/category" + idcat + ".aspx";
        return(res);
    }
コード例 #3
0
    protected string ViewResult()
    {
        string category    = "";
        string res         = "";
        string spname      = "";
        int    numarticles = 0;
        string apath       = anm_Utility.GetWebAppRoot();

        if (Request.QueryString["category"] != null)
        {
            spname   = "anm_SearchNewsbyCatPaged";
            category = Request.QueryString["category"];
        }
        else
        {
            spname = "anm_SearchNewsPaged";
        }

        anm_Utility ut    = new anm_Utility();
        string      text  = ut.UrlDecode(Request.QueryString["title"].ToString()).Trim();
        string      value = text.Replace("[", "[[]");

        value       = value.Replace("%", "[%]");
        value       = value.Replace("_", "[_]");
        value       = value.Trim();
        Label1.Text = text;

        string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
        SqlConnection myConnection = new SqlConnection(strConn);
        SqlCommand    myCommand    = new SqlCommand(spname, myConnection);

        myCommand.CommandType = CommandType.StoredProcedure;
        if (category != "")
        {
            Page.Title = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetCategory(Request.QueryString["category"]) + " - " + ut.GetSetting("SiteName");
            myCommand.Parameters.Add("@idcategory", SqlDbType.VarChar).Value = category;
        }
        else
        {
            Page.Title = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetSetting("SiteName");
        }
        myCommand.Parameters.Add("@title", SqlDbType.NVarChar).Value = value;
        int startrow = 0;
        int rows     = 15;
        int page     = 1;

        if (Request.QueryString["page"] != null)
        {
            startrow = rows * (Convert.ToInt32(Request.QueryString["page"]) - 1);
        }
        myCommand.Parameters.Add("@startRowIndex", SqlDbType.VarChar).Value = startrow;
        myCommand.Parameters.Add("@maximumRows", SqlDbType.VarChar).Value   = rows;
        myConnection.Open();
        SqlDataReader reader = myCommand.ExecuteReader();

        while (reader.Read())
        {
            res += Result(reader["title"].ToString(), reader["idnews"].ToString(), reader["image"].ToString(), reader["summary"].ToString(), reader["news"].ToString());
        }
        myConnection.Close();

        if (res == "")
        {
            string[] words     = value.Split(' ');
            string   condition = "(";
            for (int i = 0; i < words.Length; i++)
            {
                if (words[i].Length > 3)
                {
                    string val = words[i].ToString();
                    condition += "((title LIKE '%' + '" + val + "' + '%') OR (news LIKE '%' + '" + val + "' + '%') OR (summary LIKE '%' + '" + val + "' + '%')) AND ";
                }
            }
            if (condition != "(")
            {
                condition = condition.Remove(condition.Length - 4, 4) + ") and";
            }
            else
            {
                condition = "";
            }
            if (Request.QueryString["category"] != null)
            {
                SqlCommand myCommand2 = new SqlCommand();
                myCommand2.Connection = myConnection;
                myConnection.Open();
                myCommand2.CommandText = "SELECT title,idnews,image,Summary,news FROM (SELECT title,idnews,image,Summary,news, ROW_NUMBER() OVER(ORDER BY idnews  DESC) AS RowNumber FROM anm_News,anm_Categories WHERE " + condition + " published='true' and anm_News.idcategory = anm_Categories.idcategory and (anm_News.idcategory = " + Request.QueryString["category"] + " or anm_Categories.idfather = " + Request.QueryString["category"] + " or anm_Categories.idrootcat = " + Request.QueryString["category"] + ")) AS NewsWithRowNumbers WHERE RowNumber > " + startrow + " AND RowNumber <= " + (startrow + rows) + "";
                SqlDataReader reader2 = myCommand2.ExecuteReader();
                while (reader2.Read())
                {
                    res += Result(reader2["title"].ToString(), reader2["idnews"].ToString(), reader2["image"].ToString(), reader2["summary"].ToString(), reader2["news"].ToString());
                }
                myConnection.Close();
                Page.Title          = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetCategory(Request.QueryString["category"]) + " - " + ut.GetSetting("SiteName");
                DDcat.SelectedValue = Request.QueryString["category"];
                numarticles         = ut.GetNumberSearchResults("SELECT COUNT(*) FROM anm_News,anm_Categories WHERE " + condition + " published='true' and anm_News.idcategory = anm_Categories.idcategory and (anm_News.idcategory = " + Request.QueryString["category"] + " or anm_Categories.idfather = " + Request.QueryString["category"] + " or anm_Categories.idrootcat = " + Request.QueryString["category"]);
            }
            else
            {
                SqlCommand myCommand3 = new SqlCommand();
                myCommand3.Connection = myConnection;
                myConnection.Open();
                myCommand3.CommandText = "SELECT title,idnews,image,Summary,news FROM (SELECT title,idnews,image,Summary,news, ROW_NUMBER() OVER(ORDER BY idnews  DESC) AS RowNumber FROM anm_News WHERE " + condition + " published='true') AS NewsWithRowNumbers WHERE RowNumber > " + startrow + " AND RowNumber <= " + (startrow + rows) + "";
                SqlDataReader reader3 = myCommand3.ExecuteReader();
                while (reader3.Read())
                {
                    res += Result(reader3["title"].ToString(), reader3["idnews"].ToString(), reader3["image"].ToString(), reader3["summary"].ToString(), reader3["news"].ToString());
                }
                myConnection.Close();
                Page.Title  = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetSetting("SiteName");
                numarticles = ut.GetNumberSearchResults("SELECT COUNT(*) FROM anm_News WHERE " + condition + " published='true'");
            }
            if (res == "")
            {
                condition = "(";
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].Length > 3)
                    {
                        string val = words[i].ToString();
                        condition += "(title LIKE '%' + '" + val + "' + '%') OR (news LIKE '%' + '" + val + "' + '%') OR (summary LIKE '%' + '" + val + "' + '%') OR ";
                    }
                }
                if (condition != "(")
                {
                    condition = condition.Remove(condition.Length - 4, 4) + ") and";
                }
                else
                {
                    condition = "";
                }
                if (Request.QueryString["category"] != null)
                {
                    SqlCommand myCommand2 = new SqlCommand();
                    myCommand2.Connection = myConnection;
                    myConnection.Open();
                    myCommand2.CommandText = "SELECT title,idnews,image,Summary,news FROM (SELECT title,idnews,image,Summary,news, ROW_NUMBER() OVER(ORDER BY idnews  DESC) AS RowNumber FROM anm_News,anm_Categories WHERE " + condition + " published='true' and anm_News.idcategory = anm_Categories.idcategory and (anm_News.idcategory = " + Request.QueryString["category"] + " or anm_Categories.idfather = " + Request.QueryString["category"] + " or anm_Categories.idrootcat = " + Request.QueryString["category"] + ")) AS NewsWithRowNumbers WHERE RowNumber > " + startrow + " AND RowNumber <= " + (startrow + rows) + "";
                    SqlDataReader reader2 = myCommand2.ExecuteReader();
                    while (reader2.Read())
                    {
                        res += Result(reader2["title"].ToString(), reader2["idnews"].ToString(), reader2["image"].ToString(), reader2["summary"].ToString(), reader2["news"].ToString());
                    }
                    myConnection.Close();
                    Page.Title          = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetCategory(Request.QueryString["category"]) + " - " + ut.GetSetting("SiteName");
                    DDcat.SelectedValue = Request.QueryString["category"];
                    numarticles         = ut.GetNumberSearchResults("SELECT COUNT(*) FROM anm_News,anm_Categories WHERE " + condition + " published='true' and anm_News.idcategory = anm_Categories.idcategory and (anm_News.idcategory = " + Request.QueryString["category"] + " or anm_Categories.idfather = " + Request.QueryString["category"] + " or anm_Categories.idrootcat = " + Request.QueryString["category"]);
                }
                else
                {
                    SqlCommand myCommand3 = new SqlCommand();
                    myCommand3.Connection = myConnection;
                    myConnection.Open();
                    myCommand3.CommandText = "SELECT title,idnews,image,Summary,news FROM (SELECT title,idnews,image,Summary,news, ROW_NUMBER() OVER(ORDER BY idnews  DESC) AS RowNumber FROM anm_News WHERE " + condition + " published='true') AS NewsWithRowNumbers WHERE RowNumber > " + startrow + " AND RowNumber <= " + (startrow + rows) + "";
                    SqlDataReader reader3 = myCommand3.ExecuteReader();
                    while (reader3.Read())
                    {
                        res += Result(reader3["title"].ToString(), reader3["idnews"].ToString(), reader3["image"].ToString(), reader3["summary"].ToString(), reader3["news"].ToString());
                    }
                    myConnection.Close();
                    Page.Title  = GetGlobalResourceObject("language", "Search") + ": " + text + " - " + ut.GetSetting("SiteName");
                    numarticles = ut.GetNumberSearchResults("SELECT COUNT(*) FROM anm_News WHERE " + condition + " published='true'");
                }
            }
        }
        else
        {
            if (category == "")
            {
                numarticles = ut.GetNumberSearchResults("SELECT COUNT(*) FROM [anm_News] WHERE (([title] LIKE '%' + '" + value + "' + '%') OR ([news] LIKE '%' + '" + value + "' + '%') OR ([summary] LIKE '%' + '" + value + "' + '%')) and published='true' and date<GETDATE()");
            }
            else
            {
                numarticles = ut.GetNumberSearchResults("SELECT COUNT(*) FROM [anm_News],[anm_Categories] WHERE (([title] LIKE '%' + '" + value + "' + '%') OR ([news] LIKE '%' + '" + value + "' + '%') OR ([summary] LIKE '%' + '" + value + "' + '%')) and published='true' and anm_News.idcategory = anm_Categories.idcategory and (anm_News.idcategory = " + category + " or anm_Categories.idfather = " + category + " or anm_Categories.idrootcat = " + category + ") and date<GETDATE()");
            }
        }
        if (res != "")
        {
            string linknav     = "<div class='linkpage'>";
            int    maximumRows = rows;
            int    maxpage     = (numarticles / maximumRows) + 1;
            if (numarticles % maximumRows == 0)
            {
                maxpage = numarticles / maximumRows;
            }
            if (currentpage != 0)
            {
                page = currentpage;
                if (numarticles > maximumRows)
                {
                    for (int i = (page - 5); i < (page + 10); i++)
                    {
                        if (i >= 1 && i <= (maxpage))
                        {
                            if (category != "")
                            {
                                if (page == i)
                                {
                                    linknav += "<a href='" + apath + "/page" + i + "_cat" + category + "_search/" + text + ".aspx' class='pagenavselected'>" + i + "</a> ";
                                }
                                else
                                {
                                    linknav += "<a href='" + apath + "/page" + i + "_cat" + category + "_search/" + text + ".aspx' class='pagenav'>" + i + "</a> ";
                                }
                            }
                            else
                            {
                                if (page == i)
                                {
                                    linknav += "<a href='" + apath + "/page" + i + "/search/" + text + ".aspx' class='pagenavselected'>" + i + "</a> ";
                                }
                                else
                                {
                                    linknav += "<a href='" + apath + "/page" + i + "/search/" + text + ".aspx' class='pagenav'>" + i + "</a> ";
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for (int i = 1; i < 11; i++)
                {
                    if (category != "")
                    {
                        if (i == 1)
                        {
                            linknav += "<a href='" + apath + "/page" + i + "_cat" + category + "_search/" + text + ".aspx' class='pagenavselected'>" + i + "</a> ";
                        }
                        if (i > 1 && i <= maxpage)
                        {
                            linknav += "<a href='" + apath + "/page" + i + "_cat" + category + "_search/" + text + ".aspx' class='pagenav'>" + i + "</a> ";
                        }
                    }
                    else
                    {
                        if (i == 1)
                        {
                            linknav += "<a href='" + apath + "/page" + i + "/search/" + text + ".aspx' class='pagenavselected'>" + i + "</a> ";
                        }
                        if (i > 1 && i <= maxpage)
                        {
                            linknav += "<a href='" + apath + "/page" + i + "/search/" + text + ".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 (res == "" || maxpage == 1)
            {
                LTpagelink.Visible = false;
            }
        }
        else
        {
            res = "- No results.";
        }

        return(res);
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            anm_Utility ut = new anm_Utility();
            if (Request.QueryString["tag"] == null)
            {
                if (Request.QueryString["author"] == null)
                {
                    if (Request.QueryString["category"] != null)
                    {
                        string category = Request.QueryString["category"];
                        if (Request.QueryString["year"] == null)
                        {
                            GridView2.DataSourceID = "SqlDataSource3";
                            GridView3.DataSourceID = "SqlDataSource5";
                            GridView4.DataSourceID = "SqlDataSource7";
                            Page.Title             = ut.GetCategory(Request.QueryString["category"]) + " - " + ut.GetSetting("SiteName");
                        }
                        else
                        {
                            int year  = Convert.ToInt32(Request.QueryString["year"].ToString());
                            int categ = Convert.ToInt32(category);
                            int month = Convert.ToInt32(Request.QueryString["month"].ToString());
                            if (ut.GetNumberArticles(month, year, categ) == 0)
                            {
                                int i = 1;
                                while (i < 13 && ut.GetNumberArticles(i, year, categ) == 0)
                                {
                                    i++;
                                }
                                if (i != 13)
                                {
                                    Response.Redirect(apath + "/month_" + i + "/year_" + year + "/category" + categ + ".aspx");
                                }
                            }
                            if (ut.GetNumberArticles(1, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "January").ToString() + " (" + ut.GetNumberArticles(1, year, categ) + ")", "1"));
                            }
                            if (ut.GetNumberArticles(2, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "February").ToString() + " (" + ut.GetNumberArticles(2, year, categ) + ")", "2"));
                            }
                            if (ut.GetNumberArticles(3, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "March").ToString() + " (" + ut.GetNumberArticles(3, year, categ) + ")", "3"));
                            }
                            if (ut.GetNumberArticles(4, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "April").ToString() + " (" + ut.GetNumberArticles(4, year, categ) + ")", "4"));
                            }
                            if (ut.GetNumberArticles(5, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "May").ToString() + " (" + ut.GetNumberArticles(5, year, categ) + ")", "5"));
                            }
                            if (ut.GetNumberArticles(6, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "June").ToString() + " (" + ut.GetNumberArticles(6, year, categ) + ")", "6"));
                            }
                            if (ut.GetNumberArticles(7, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "July").ToString() + " (" + ut.GetNumberArticles(7, year, categ) + ")", "7"));
                            }
                            if (ut.GetNumberArticles(8, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "August").ToString() + " (" + ut.GetNumberArticles(8, year, categ) + ")", "8"));
                            }
                            if (ut.GetNumberArticles(9, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "September").ToString() + "(" + ut.GetNumberArticles(9, year, categ) + ")", "9"));
                            }
                            if (ut.GetNumberArticles(10, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "October").ToString() + " (" + ut.GetNumberArticles(10, year, categ) + ")", "10"));
                            }
                            if (ut.GetNumberArticles(11, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "November").ToString() + " (" + ut.GetNumberArticles(11, year, categ) + ")", "11"));
                            }
                            if (ut.GetNumberArticles(12, year, categ) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "December").ToString() + " (" + ut.GetNumberArticles(12, year, categ) + ")", "12"));
                            }
                            int archiveYear = Convert.ToInt32(ut.GetSetting("Year").ToString());
                            int currentYear = DateTime.Now.Year;
                            while (archiveYear <= currentYear)
                            {
                                ddYear.Items.Add(new ListItem(archiveYear.ToString(), archiveYear.ToString()));
                                archiveYear++;
                            }
                            ddYear.Visible        = lblYear.Visible = lblMonth.Visible = ddMonth.Visible = true;
                            ddYear.SelectedValue  = Request.QueryString["year"].ToString();
                            ddMonth.SelectedValue = Request.QueryString["month"].ToString();
                            if (Request.QueryString["month"] != null)
                            {
                                Page.Title = ut.GetCategory(ut.GetIdFather(category)) + " - " + ut.GetCategory(category) + " - " + GetGlobalResourceObject("language", "Year") + ": " + Request.QueryString["year"].ToString() + " - " + GetGlobalResourceObject("language", "Month") + ": " + ut.SetLongMonth(Convert.ToInt32(Request.QueryString["month"].ToString())) + " - " + ut.GetSetting("SiteName");
                            }
                            else
                            {
                                Page.Title = ut.GetCategory(ut.GetIdFather(category)) + " - " + ut.GetCategory(category) + " - " + GetGlobalResourceObject("language", "Year") + ": " + Request.QueryString["year"].ToString() + " - " + ut.GetSetting("SiteName");
                            }
                            GridView2.DataSourceID = "SqlDataSource15";
                            GridView3.DataSourceID = "SqlDataSource11";
                            GridView4.DataSourceID = "SqlDataSource13";
                        }
                    }
                    else
                    {
                        if (Request.QueryString["year"] == null)
                        {
                            GridView2.DataSourceID = "SqlDataSource4";
                            GridView3.DataSourceID = "SqlDataSource6";
                            GridView4.DataSourceID = "SqlDataSource8";
                            Page.Title             = ut.GetSetting("SiteName");
                        }
                        else
                        {
                            int year  = Convert.ToInt32(Request.QueryString["year"].ToString());
                            int month = Convert.ToInt32(Request.QueryString["month"].ToString());
                            if (ut.GetNumberArticles(month, year) == 0)
                            {
                                int i = 1;
                                while (i < 13 && ut.GetNumberArticles(i, year) == 0)
                                {
                                    i++;
                                }
                                if (i != 13)
                                {
                                    Response.Redirect(apath + "/year_" + year + "/month_" + i + ".aspx");
                                }
                            }
                            if (ut.GetNumberArticles(1, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "January").ToString() + " (" + ut.GetNumberArticles(1, year) + ")", "1"));
                            }
                            if (ut.GetNumberArticles(2, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "February").ToString() + " (" + ut.GetNumberArticles(2, year) + ")", "2"));
                            }
                            if (ut.GetNumberArticles(3, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "March").ToString() + " (" + ut.GetNumberArticles(3, year) + ")", "3"));
                            }
                            if (ut.GetNumberArticles(4, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "April").ToString() + " (" + ut.GetNumberArticles(4, year) + ")", "4"));
                            }
                            if (ut.GetNumberArticles(5, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "May").ToString() + " (" + ut.GetNumberArticles(5, year) + ")", "5"));
                            }
                            if (ut.GetNumberArticles(6, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "June").ToString() + " (" + ut.GetNumberArticles(6, year) + ")", "6"));
                            }
                            if (ut.GetNumberArticles(7, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "July").ToString() + " (" + ut.GetNumberArticles(7, year) + ")", "7"));
                            }
                            if (ut.GetNumberArticles(8, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "August").ToString() + " (" + ut.GetNumberArticles(8, year) + ")", "8"));
                            }
                            if (ut.GetNumberArticles(9, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "September").ToString() + " (" + ut.GetNumberArticles(9, year) + ")", "9"));
                            }
                            if (ut.GetNumberArticles(10, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "October").ToString() + " (" + ut.GetNumberArticles(10, year) + ")", "10"));
                            }
                            if (ut.GetNumberArticles(11, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "November").ToString() + " (" + ut.GetNumberArticles(11, year) + ")", "11"));
                            }
                            if (ut.GetNumberArticles(12, year) != 0)
                            {
                                ddMonth.Items.Add(new ListItem(GetGlobalResourceObject("language", "December").ToString() + " (" + ut.GetNumberArticles(12, year) + ")", "12"));
                            }
                            int archiveYear = Convert.ToInt32(ut.GetSetting("Year").ToString());
                            int currentYear = DateTime.Now.Year;
                            while (archiveYear <= currentYear)
                            {
                                ddYear.Items.Add(new ListItem(archiveYear.ToString(), archiveYear.ToString()));
                                archiveYear++;
                            }
                            ddYear.Visible        = lblYear.Visible = lblMonth.Visible = ddMonth.Visible = true;
                            ddYear.SelectedValue  = Request.QueryString["year"].ToString();
                            ddMonth.SelectedValue = Request.QueryString["month"].ToString();
                            if (Request.QueryString["month"] != null)
                            {
                                Page.Title = GetGlobalResourceObject("language", "Year") + ": " + Request.QueryString["year"].ToString() + " - " + GetGlobalResourceObject("language", "Month") + ": " + ut.SetLongMonth(Convert.ToInt32(Request.QueryString["month"].ToString())) + " - " + ut.GetSetting("SiteName");
                            }
                            else
                            {
                                Page.Title = GetGlobalResourceObject("language", "Year") + ": " + Request.QueryString["year"].ToString() + " - " + ut.GetSetting("SiteName");
                            }

                            GridView2.DataSourceID = "SqlDataSource16";
                            GridView3.DataSourceID = "SqlDataSource12";
                            GridView4.DataSourceID = "SqlDataSource14";
                        }
                    }
                }
                else
                {
                    string value = ut.UrlDecode(Request.QueryString["author"].ToString());
                    Page.Title          = GetGlobalResourceObject("language", "PostedByAllArticles") + " " + value + " - " + ut.GetSetting("SiteName");
                    lblauthor.Text      = GetGlobalResourceObject("language", "PostedByAllArticles") + " <b>" + value + "</b>:";
                    lblauthor.Font.Size = 16;
                }
            }
            else
            {
                string text  = ut.UrlDecode(Request.QueryString["tag"].ToString());
                string value = text.Replace("[", "[[]");
                value               = value.Replace("%", "[%]");
                value               = value.Replace("_", "[_]");
                Page.Title          = GetGlobalResourceObject("language", "RelatedToAllArticles") + " " + value + " - " + ut.GetSetting("SiteName");
                lblauthor.Text      = GetGlobalResourceObject("language", "RelatedToAllArticles") + " <b>" + text + "</b>:";
                lblauthor.Font.Size = 16;
            }
            if (Request.QueryString["page"] != null)
            {
                Page.Title = Page.Title + " - " + GetGlobalResourceObject("language", "Page") + ": " + Request.QueryString["page"];
            }

            HtmlMeta keywords = new HtmlMeta();
            keywords.Name    = "description";
            keywords.Content = Page.Title;
            Page.Header.Controls.Add(keywords);
            if (Request.QueryString["category"] != null & Request.QueryString["month"] != null)
            {
                HLContentArchive.NavigateUrl = apath + "/archive/month_" + Request.QueryString["month"] + "/year_" + Request.QueryString["year"] + "/category" + Request.QueryString["category"] + ".aspx";
            }
            else if (Request.QueryString["category"] != null)
            {
                HLContentArchive.NavigateUrl = apath + "/archive/month_" + DateTime.Now.Month + "/year_" + DateTime.Now.Year + "/category" + Request.QueryString["category"] + ".aspx";
            }
            else if (Request.QueryString["month"] != null)
            {
                HLContentArchive.NavigateUrl = apath + "/archive/year_" + Request.QueryString["year"] + "/month_" + Request.QueryString["month"] + ".aspx";
            }
            else
            {
                HLContentArchive.NavigateUrl = apath + "/archive/year_" + DateTime.Now.Year + "/month_" + DateTime.Now.Month + ".aspx";
            }
        }
    }
コード例 #5
0
ファイル: Rss.ascx.cs プロジェクト: abuhmead1987/code2code
    protected void Page_Load(object sender, EventArgs e)
    {
        anm_Utility ut      = new anm_Utility();
        string      siteurl = ut.GetSetting("SiteUrl");

        try
        {
            if (siteurl.Substring(0, 4) != "http")
            {
                siteurl = "http://" + siteurl;
            }
        }
        catch
        {
            siteurl = "http://" + siteurl;
        }
        string sitetitle = ut.GetSetting("SiteName") + " RSS";
        string idc       = "";
        string idn       = "";
        string titlenews = "";

        if (Request.QueryString["cat"] != null)
        {
            idc       = Request.QueryString["cat"].ToString();
            sitetitle = ut.GetCategory(idc) + " RSS" + " - " + ut.GetSetting("SiteName");
        }
        if (Request.QueryString["news"] != null)
        {
            idn       = Request.QueryString["news"].ToString();
            sitetitle = ut.GetTitleNews(idn) + " - Comment RSS" + " - " + ut.GetSetting("SiteName");
        }
        Response.Clear();
        Response.ContentType = "text/xml";

        XmlTextWriter RSSFeed = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);

        RSSFeed.WriteStartDocument();

        RSSFeed.WriteStartElement("rss");
        RSSFeed.WriteAttributeString("version", "2.0");
        //RSSFeed.WriteAttributeString("xmlns:atom", "http://www.w3.org/2005/Atom");
        RSSFeed.WriteStartElement("channel");
        RSSFeed.WriteElementString("title", ut.FormatForXML(sitetitle));
        RSSFeed.WriteElementString("link", siteurl);

        string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
        SqlConnection myConnection = new SqlConnection(strConn);
        SqlCommand    myCommand    = new SqlCommand("anm_GetRss", myConnection);

        if (idc != "")
        {
            myCommand = new SqlCommand("anm_GetRssByCat", myConnection);
            myCommand.Parameters.Add("@idcategory", SqlDbType.VarChar).Value = idc;
            RSSFeed.WriteElementString("description", sitetitle + ": " + ut.GetCategory(idc));
        }
        else if (idn != "")
        {
            myCommand = new SqlCommand("anm_GetRssComments", myConnection);
            myCommand.Parameters.Add("@idn", SqlDbType.VarChar).Value = idn;
            titlenews = ut.GetTitleNews(idn);
            RSSFeed.WriteElementString("description", sitetitle + ": " + titlenews);
        }
        else
        {
            RSSFeed.WriteElementString("description", sitetitle);
        }

        myCommand.CommandType = CommandType.StoredProcedure;
        myConnection.Open();
        SqlDataReader reader = myCommand.ExecuteReader();

        string description = "";

        if (idn != "")
        {
            while (reader.Read())
            {
                string idcom = reader["idcomment"].ToString();
                RSSFeed.WriteStartElement("item");
                RSSFeed.WriteElementString("title", titlenews);
                RSSFeed.WriteElementString("description", reader["comment"].ToString());
                RSSFeed.WriteElementString("link", siteurl + "/comment/" + idcom + "/articles/" + idn + "/" + ut.RemoveNonAlfaNumeric(titlenews) + ".aspx#comment" + idcom);
                RSSFeed.WriteElementString("pubDate", (Convert.ToDateTime(reader["date"].ToString())).ToString("r"));
                RSSFeed.WriteElementString("category", "Comment");
                RSSFeed.WriteElementString("guid", siteurl + "/comment/" + idcom + "/articles/" + idn + "/" + ut.RemoveNonAlfaNumeric(titlenews) + ".aspx#comment" + idcom);
                RSSFeed.WriteEndElement();
            }
        }
        else
        {
            while (reader.Read())
            {
                RSSFeed.WriteStartElement("item");
                RSSFeed.WriteElementString("title", reader["title"].ToString());
                description = reader["summary"].ToString();
                if (description.Length < 9)
                {
                    description = reader["news"].ToString();
                }
                RSSFeed.WriteElementString("description", description);
                RSSFeed.WriteElementString("link", siteurl + "/articles/" + reader["idnews"].ToString() + "/" + ut.RemoveNonAlfaNumeric(reader["title"].ToString()) + ".aspx");
                RSSFeed.WriteElementString("pubDate", (Convert.ToDateTime(reader["date"].ToString())).ToString("r"));
                RSSFeed.WriteElementString("category", ut.GetCategory(reader["idcategory"].ToString()));
                RSSFeed.WriteElementString("guid", siteurl + "/articles/" + reader["idnews"].ToString() + "/" + ut.RemoveNonAlfaNumeric(reader["title"].ToString()) + ".aspx");
                RSSFeed.WriteEndElement();
            }
        }
        myConnection.Close();

        /*
         * RSSFeed.WriteStartElement("atom:link");
         * RSSFeed.WriteAttributeString("href", siteurl + Page.Request.Url.AbsolutePath.ToString() + "?p=Rss");
         * RSSFeed.WriteAttributeString("rel", "self");
         * RSSFeed.WriteAttributeString("type", "application/rss+xml");
         * RSSFeed.WriteEndElement();
         */
        RSSFeed.WriteEndElement();
        RSSFeed.WriteEndElement();
        RSSFeed.WriteEndDocument();
        RSSFeed.Flush();
        RSSFeed.Close();
        Response.End();
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            anm_Utility ut = new anm_Utility();
            if (Request.QueryString["category"] != null)
            {
                h2archive.Text = h2archive.Text + " " + ut.GetCategory(Request.QueryString["category"]);
            }
            else if (Request.QueryString["news"] != null)
            {
                category       = ut.GetCategoryFromNews(Request.QueryString["news"]);
                h2archive.Text = h2archive.Text + " " + ut.GetCategory(category);
            }
            string menu         = "";
            int    nart         = 0;
            int    InitialYear  = Convert.ToInt32(ut.GetSetting("Year"));
            int    InitialMonth = Convert.ToInt32(ut.GetSetting("Month"));
            string viewart      = ut.GetSetting("ViewNarticles");
            if (ut.GetSetting("ArchiveMenu") == "True")
            {
                PnlArchiveMenu.Visible = true;
                if (ut.GetSetting("ArchiveType") == "2")
                {
                    ddlarchive.Visible = true;
                    ddlarchive.Items.Add(new ListItem(GetGlobalResourceObject("language", "SelectMonth").ToString()));

                    if (Request.QueryString["category"] != null || Request.QueryString["news"] != null)
                    {
                        int cat = 0;
                        if (Request.QueryString["category"] != null)
                        {
                            cat = Convert.ToInt32(Request.QueryString["category"].ToString());
                        }
                        else
                        {
                            cat = Convert.ToInt32(ut.GetCategoryFromNews(Request.QueryString["news"].ToString()));
                        }
                        int currentYear = Convert.ToInt32(DateTime.Now.Year.ToString());
                        int currentMonth = Convert.ToInt32(DateTime.Now.Month.ToString());
                        int i, j;
                        if (currentYear == InitialYear)
                        {
                            for (i = currentMonth; i >= InitialMonth; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear, cat);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear + "-" + cat));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear + "-" + cat));
                                }
                            }
                        }
                        else
                        {
                            for (i = currentMonth; i > 0; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear, cat);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear + "-" + cat));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear + "-" + cat));
                                }
                            }
                        }
                        for (j = currentYear - 1; j >= InitialYear; j--)
                        {
                            if (j == InitialYear)
                            {
                                for (i = 12; i >= InitialMonth; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j, cat);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j + "-" + cat));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j + "-" + cat));
                                    }
                                }
                            }
                            else
                            {
                                for (i = 12; i > 0; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j, cat);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j + "-" + cat));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j + "-" + cat));
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        int currentYear = Convert.ToInt32(DateTime.Now.Year.ToString());
                        int currentMonth = Convert.ToInt32(DateTime.Now.Month.ToString());
                        int i, j;
                        if (currentYear == InitialYear)
                        {
                            for (i = currentMonth; i >= InitialMonth; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear));
                                }
                            }
                        }
                        else
                        {
                            for (i = currentMonth; i > 0; i--)
                            {
                                if (viewart == "True")
                                {
                                    nart = ut.GetNumberArticles(i, currentYear);
                                    if (nart != 0)
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear + " (" + nart + ")", i + "-" + currentYear));
                                    }
                                }
                                else
                                {
                                    ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + currentYear, i + "-" + currentYear));
                                }
                            }
                        }
                        for (j = currentYear - 1; j >= InitialYear; j--)
                        {
                            if (j == InitialYear)
                            {
                                for (i = 12; i >= InitialMonth; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j));
                                    }
                                }
                            }
                            else
                            {
                                for (i = 12; i > 0; i--)
                                {
                                    if (viewart == "True")
                                    {
                                        nart = ut.GetNumberArticles(i, j);
                                        if (nart != 0)
                                        {
                                            ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j + " (" + nart + ")", i + "-" + j));
                                        }
                                    }
                                    else
                                    {
                                        ddlarchive.Items.Add(new ListItem(SetMonth(i) + " " + j, i + "-" + j));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Response.Write(menu);
        }
    }
コード例 #7
0
    protected string ViewSideMenu()
    {
        anm_Utility ut       = new anm_Utility();
        string      category = "";

        if (Request.QueryString["news"] != null)
        {
            category = ut.GetCategoryFromNews(Request.QueryString["news"]);
        }
        if (Request.QueryString["category"] != null)
        {
            category = Request.QueryString["category"];
        }
        if (category == "")
        {
            string menu = "";
            if (ut.GetSetting("SideMenu") == "True")
            {
                menu = ut.GetSideMenu();
            }
            return(menu);
        }
        else
        {
            string   apath      = anm_Utility.GetWebAppRoot();
            string   idfather   = ut.GetIdFather(category);
            String[] categories = new String[20];
            string   res        = "";
            int      i          = 1;
            categories[0] = category;
            while (!idfather.Equals("0"))
            {
                categories[i] = idfather;
                idfather      = ut.GetIdFather(idfather);
                i++;
            }
            for (int j = 0; categories[j] != null; j++)
            {
                string cat = ut.GetCategory(categories[j]);
                string url = ut.GetCategoryUrl(categories[j]);
                if (url == "" || url == null)
                {
                    res = "<li><a href='" + apath + "/subscribe/" + categories[j] + ".aspx'><img src='" + apath + "/images/rssicon.gif' alt='rss' style='border: none;' /></a> <strong><a href='" + apath + "/category" + categories[j] + ".aspx'>" + cat + "</a></strong></li>" + res;
                }
                else
                {
                    res = "<li>&nbsp;&nbsp;&nbsp; <strong><a href='" + url + "'>" + cat + "</a></strong></li>" + res;
                }
            }
            string        linksons     = "";
            string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
            SqlConnection myConnection = new SqlConnection(strConn);
            SqlCommand    myCommand    = new SqlCommand("anm_getSonCategories", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@idcategory", SqlDbType.NVarChar).Value = category;
            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            while (reader.Read())
            {
                string url = reader["url"].ToString();
                string idc = reader["idcategory"].ToString();
                string cat = reader["category"].ToString();
                if (url == "" || url == null)
                {
                    linksons += "<li class='menulinksons'><a href='" + apath + "/subscribe/" + idc + ".aspx'><img src='" + apath + "/images/rssicon.gif' alt='rss' style='border: none;' /></a> <strong><a href='" + apath + "/category" + idc + ".aspx'>" + cat + "</a></strong></li>";
                }
                else
                {
                    linksons += "<li class='menulinksons'>&nbsp;&nbsp;&nbsp; <strong><a href='" + url + "'>" + cat + "</a></strong></li>";
                }
            }
            myConnection.Close();
            if (linksons != "")
            {
                //res += "<ul class='menulinksons'>" + linksons + "</ul>";
                res += linksons;
            }

            if (ut.GetSetting("SideMenu") == "True")
            {
                return("<h2>" + HttpContext.GetGlobalResourceObject("language", "Menu") + "</h2><div class='sp'><ul>" + res + "</ul></div>");
            }
            else
            {
                return("");
            }
        }
    }
コード例 #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DDcat.Items.Add(new ListItem(GetGlobalResourceObject("language", "All").ToString()));
         string        strConn      = ConfigurationManager.ConnectionStrings["anmcs"].ToString();
         SqlConnection myConnection = new SqlConnection(strConn);
         SqlCommand    myCommand    = new SqlCommand("anm_getCategories", myConnection);
         myCommand.CommandType = CommandType.StoredProcedure;
         myConnection.Open();
         SqlDataReader reader = myCommand.ExecuteReader();
         while (reader.Read())
         {
             string idc      = reader["idcategory"].ToString();
             string category = reader["category"].ToString();
             DDcat.Items.Add(new ListItem(category, idc));
         }
         myConnection.Close();
         if (Request.QueryString["month"] != null)
         {
             anm_Utility ut = new anm_Utility();
             if (Request.QueryString["category"] != null)
             {
                 GridView1.DataSourceID = "SqlDataSource9";
                 Page.Title             = GetGlobalResourceObject("language", "ContentArchive").ToString() + " - " + GetGlobalResourceObject("language", "Year").ToString() + ": " + y + " - " + GetGlobalResourceObject("language", "Month").ToString() + ": " + ut.SetLongMonth(Convert.ToInt32(m)) + " - " + GetGlobalResourceObject("language", "Category").ToString() + ": " + ut.GetCategory(Request.QueryString["category"]) + " - " + ut.GetSetting("SiteName");
                 lblmeseanno.Text       = GetGlobalResourceObject("language", "ContentArchive").ToString() + " - <i><b>" + GetGlobalResourceObject("language", "Year").ToString() + ": " + y + " - " + GetGlobalResourceObject("language", "Month").ToString() + ": " + ut.SetLongMonth(Convert.ToInt32(m)) + " - " + GetGlobalResourceObject("language", "Category").ToString() + ": " + ut.GetCategory(Request.QueryString["category"]) + "</b></i>";
                 DDcat.SelectedValue    = Request.QueryString["category"];
             }
             else
             {
                 GridView1.DataSourceID = "SqlDataSource10";
                 Page.Title             = GetGlobalResourceObject("language", "ContentArchive").ToString() + " - " + GetGlobalResourceObject("language", "Year").ToString() + ": " + y + " - " + GetGlobalResourceObject("language", "Month").ToString() + ": " + ut.SetLongMonth(Convert.ToInt32(m)) + " - " + ut.GetSetting("SiteName");
                 lblmeseanno.Text       = GetGlobalResourceObject("language", "ContentArchive").ToString() + " - <i><b>" + GetGlobalResourceObject("language", "Year").ToString() + ": " + y + " - " + GetGlobalResourceObject("language", "Month").ToString() + ": " + ut.SetLongMonth(Convert.ToInt32(m)) + "</b></i>";
             }
         }
         else
         {
             Response.Redirect(apath + "/archive/year_" + DateTime.Now.Year + "/month_" + DateTime.Now.Month);
         }
     }
 }
コード例 #9
0
    protected string Category(string idc)
    {
        anm_Utility ut = new anm_Utility();

        return("<a href='" + Page.Request.ApplicationPath.ToString() + "/category" + idc + ".aspx'>" + ut.GetCategory(idc) + "</a>");
    }