Exemplo n.º 1
0
        /// <summary>
        /// 获取上一条下一条的链接
        /// </summary>
        /// <param name="urlkey">urlkey</param>
        /// <param name="type">-1代表上一条,1代表下一条</param>
        /// <param name="defaultvalue">默认文本</param>
        /// <param name="callIndex">是否使用别名,0使用ID,1使用别名</param>
        /// <returns>A链接</returns>
        protected string get_prevandnext_article(string urlkey, int type, string defaultvalue, int callIndex)
        {
            string symbol = (type == -1 ? "<" : ">");

            BLL.article bll = new BLL.article();
            string      str = string.Empty;

            str = " and category_id=" + model.category_id;

            string  orderby = type == -1 ? "id desc" : "id asc";
            DataSet ds      = bll.ArticleList(channel, 1, "channel_id=" + model.channel_id + " " + str + " and status=0 and Id" + symbol + id, orderby);

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                return(defaultvalue);
            }
            string tip = "下一条:";

            if (type == 1)
            {
                tip = "上一条:";
            }
            if (callIndex == 1 && !string.IsNullOrEmpty(ds.Tables[0].Rows[0]["call_index"].ToString()))
            {
                return("<a href=\"" + linkurl(urlkey, ds.Tables[0].Rows[0]["call_index"].ToString()) + "\">" + tip + ds.Tables[0].Rows[0]["title"] + "</a>");
            }

            return("<a href=\"" + linkurl(urlkey, ds.Tables[0].Rows[0]["id"].ToString()) + "\">" + tip + ds.Tables[0].Rows[0]["title"] + "</a>");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 返回频道下所有的文章URL地址
        /// </summary>
        ///  <param name="lang">频道分类</param>
        /// <param name="channelname">频道Name</param>
        /// <returns>返回频道下所有的文章URL地址</returns>
        private string GetDetailUrlList(string lang, string channelname, string page, string pattern, string path, string querystring)
        {
            StringBuilder sburl = new StringBuilder();
            DataTable     dt    = objarticle.ArticleList(channelname, 0, string.Empty, "id desc").Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string strvalue    = string.IsNullOrEmpty(dt.Rows[i]["call_index"].ToString()) ? dt.Rows[i]["id"].ToString() : dt.Rows[i]["call_index"].ToString();
                    string querystr    = Regex.Replace(string.Format(path, strvalue), pattern, querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                    string linkurl     = string.Format("{0}/{1}/{2}?{3}", DTKeys.DIRECTORY_REWRITE_ASPX, lang, page, querystr);
                    string HTMLPattern = string.Format("{0}/{1}/{2}", DTKeys.DIRECTORY_REWRITE_HTML, lang, Utils.GetUrlExtension(string.Format(path, strvalue), config.staticextension)); //替换扩展名
                    if (!string.IsNullOrEmpty(sburl.ToString()))
                    {
                        sburl.Append(",");
                    }
                    sburl.AppendFormat(urlstr, config.webpath, lang, linkurl, HTMLPattern);
                }
            }

            return(sburl.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 返回频道下所有的文章URL地址
        /// </summary>
        ///  <param name="lang">频道分类</param>
        /// <param name="channelname">频道Name</param>
        /// <returns>返回频道下所有的文章URL地址</returns>
        private string GetDetailUrlList(string lang, string channelname, string page, string pattern, string path, string querystring)
        {
            //默认值
            int    top         = 0;
            int    category_id = 0;
            string strWhere    = "status=0";
            string order       = "id desc";

            //条件处理
            int hanld = DTRequest.GetQueryInt("hanld");

            switch (hanld)
            {
            case 4:
                category_id = DTRequest.GetQueryInt("lst");
                break;

            case 5:
                DateTime start = Utils.StrToDateTime(DTRequest.GetQueryString("start"));
                DateTime end   = Utils.StrToDateTime(DTRequest.GetQueryString("end"));
                strWhere += " and DateDiff(d,'" + start + "',update_time)>=0 And DateDiff(d,'" + end + "',update_time)<=0";
                break;

            case 6:
                top   = DTRequest.GetQueryInt("lst");
                order = "update_time desc,id desc";
                break;

            case 7:
                string id_list = DTRequest.GetQueryString("lst");
                Regex  myReg   = new Regex(@"[^0-9^,]");
                if (id_list != "")
                {
                    strWhere += " and id in (" + myReg.Replace(id_list, "") + ")";
                }
                break;
            }
            StringBuilder sburl = new StringBuilder();
            DataTable     dt    = objarticle.ArticleList(channelname, category_id, top, strWhere, order).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                bool status = false;
                if (querystring.IndexOf("call_index") > -1)
                {
                    status = true;
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string strvalue = dt.Rows[i]["call_index"].ToString();
                    if (status)
                    {
                        if (string.IsNullOrWhiteSpace(strvalue))
                        {
                            continue;
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(strvalue))
                    {
                        continue;
                    }
                    else
                    {
                        strvalue = dt.Rows[i]["id"].ToString();
                    }
                    string querystr    = Regex.Replace(string.Format(path, strvalue), pattern, querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                    string linkurl     = string.Format("{0}/{1}/{2}?{3}", DTKeys.DIRECTORY_REWRITE_MVC, lang, page, querystr);
                    string HTMLPattern = string.Format("{0}/{1}/{2}", DTKeys.DIRECTORY_REWRITE_HTML, lang, Utils.GetUrlExtension(string.Format(path, strvalue), config.staticextension)); //替换扩展名
                    if (!string.IsNullOrEmpty(sburl.ToString()))
                    {
                        sburl.Append(",");
                    }
                    sburl.AppendFormat(urlstr, config.webpath, lang, linkurl, HTMLPattern);
                }
            }

            return(sburl.ToString());
        }