Exemple #1
0
 /// <summary>
 /// 根据channel_name取得模型
 /// </summary>
 /// <param name="id">ID</param>
 /// <returns>String</returns>
 public Model.article get_article_model(string channel_name, int id)
 {
     if (id > 0)
     {
         BLL.article bll = new BLL.article();
         if (bll.ArticleExists(channel_name, id))
         {
             return(bll.ArticleModel(channel_name, id));
         }
     }
     return(null);
 }
Exemple #2
0
        /// <summary>
        /// OnInit事件,让频道名称变量先赋值
        /// </summary>
        void article_show_Init(object sender, EventArgs e)
        {
            id   = DTRequest.GetQueryInt("id");
            page = DTRequest.GetQueryString("page");
            BLL.article bll = new BLL.article();

            if (id > 0) //如果ID获取到,将使用ID
            {
                if (!bll.ArticleExists(channel, id))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除!")));
                    return;
                }
                model = bll.ArticleModel(channel, id);
            }
            else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名
            {
                if (!bll.ArticleExists(channel, page))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除!")));
                    return;
                }
                model = bll.ArticleModel(channel, page);
            }
            else
            {
                return;
            }
            //跳转URL
            if (model.link_url != null)
            {
                model.link_url = model.link_url.Trim();
            }
            if (!string.IsNullOrEmpty(model.link_url))
            {
                HttpContext.Current.Response.Redirect(model.link_url);
            }
        }
Exemple #3
0
        /// <summary>
        /// 验证频道列表数据
        /// </summary>
        /// <param name="channel_name"></param>
        public void validate_channel_data(string channel_name)
        {
            this.channel = channel_name;
            channelModel = new BLL.site_channel().GetModel(channel_name);
            if (null != channelModel && !channelModel.name.Equals(channel_name))
            {
                Response.Redirect(linkurl("error"));
                return;
            }

            BLL.article bll = new BLL.article();
            if (id > 0) //如果ID获取到,将使用ID
            {
                if (!bll.ArticleExists(channel, id))
                {
                    Response.Redirect(linkurl("error"));
                    return;
                }
                model = bll.ArticleModel(channel, id);
            }
            else if (!string.IsNullOrEmpty(call_index)) //否则检查设置的别名
            {
                if (!bll.ArticleExists(channel, call_index))
                {
                    Response.Redirect(linkurl("error"));
                    return;
                }
                model = bll.ArticleModel(channel, call_index);
                //赋值文章ID
                id = model.id;
            }
            else
            {
                Response.Redirect(linkurl("error"));
                return;
            }
            if (model.status == 1)
            {
                Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("浏览得该信息审核还未通过!")));
                return;
            }
            //判断是否是链接
            if (!string.IsNullOrEmpty(model.link_url))
            {
                Response.Redirect(model.link_url);
                return;
            }
            //判断SEO标题
            if (string.IsNullOrEmpty(model.seo_title))
            {
                model.seo_title = site.seo_title;
            }
            if (string.IsNullOrEmpty(model.seo_keywords))
            {
                model.seo_keywords = site.seo_keywords;
            }
            if (string.IsNullOrEmpty(model.seo_description))
            {
                model.seo_description = site.seo_description;
            }
            //获取频道内容
            channelModel = new BLL.site_channel().GetModel(model.channel_id);

            //获取类别内容
            categoryModel = new BLL.article_category().GetModel(model.category_id);

            ViewBag.model = model;
        }