示例#1
0
 /// <summary>
 /// 返回文章数据
 /// </summary>
 /// <param name="IndexModels"></param>
 /// <returns></returns>
 public string ArticleDate(IndexModel IndexModels)
 {
     try
     {
         IndexModels.type = Convert.ToInt32(NewsBll.GetClassName(IndexModels.id));       //获取分类ID
         string TemplateShow = ClassBll.GetClassField(IndexModels.type, "TemplateShow"); //对应的模板文件
         string QPre         = "?id=" + IndexModels.id + "&type=" + IndexModels.type;    //参数
         string MyUrl        = "http://" + this.GetDoMain() + TemplateShow + QPre;       //拼接后的地址
         string MyHtml       = ROYcms.Common.GetUrlText.GetText(MyUrl, EncodIng);
         return(MyHtml);
     }
     catch
     {
         new ROYcms.Sys.BLL.ROYcms_Log().InsertSystemLog("5", "获取返回文章数据失败", "获取返回文章数据失败");//写入日志
         return(null);
     }
 }
示例#2
0
        /// <summary>
        /// 文章详细页面重写
        /// </summary>
        /// <param name="URL"></param>
        /// <returns></returns>
        public static string IsShowUrl(string URL)
        {
            ROYcms.Sys.BLL.ROYcms_news  NewBll   = new ROYcms.Sys.BLL.ROYcms_news();
            ROYcms.Sys.BLL.ROYcms_class ClassBll = new ROYcms.Sys.BLL.ROYcms_class();


            string NewUrlModel = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("new_url_model");

            if (NewUrlModel == "" || NewUrlModel == null)
            {
                NewUrlModel = "show";
            }

            if (URL.Contains("/" + NewUrlModel + "_"))
            {
                string[] Parameters = URL.Substring(URL.LastIndexOf("/" + NewUrlModel + "_") + 6, URL.LastIndexOf(".") - (URL.LastIndexOf("/" + NewUrlModel + "_") + 6)).Split('_');
                string   ClassId    = Convert.ToString(NewBll.GetClassName(Convert.ToInt32(Parameters[0])));

                string NewPath = ClassBll.GetClassField(Convert.ToInt32(ClassId), "TemplateShow");;
                if (NewPath != "")
                {
                    if (Parameters.Length > 1)
                    {
                        NewPath = NewPath + String.Format("?id={0}&class={1}&page={2}", Parameters[0], ClassId, Parameters[1]);
                    }
                    else
                    {
                        NewPath = NewPath + String.Format("?id={0}&class={1}", Parameters[0], ClassId);
                    }

                    return(NewPath);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(URL);
            }
        }
示例#3
0
        /// <summary>
        /// 输出
        /// </summary>
        /// <param name="output">The output.</param>
        protected override void Render(HtmlTextWriter output)
        {
            ROYcms.Sys.BLL.ROYcms_news   ___ROYcms_news   = new ROYcms.Sys.BLL.ROYcms_news();
            ROYcms.Sys.BLL.ROYcms_Custom ROYcms_CustomBLL = new ROYcms.Sys.BLL.ROYcms_Custom();

            string MainField = null;

            try
            {
                if (Array.IndexOf(ROYcms.Common.Zn_En.MainField(), Name) != -1) //是默认字段
                {
                    MainField = ___ROYcms_news.GetField(Convert.ToInt32(Rid), ROYcms.Common.Zn_En.Fy(Name));
                }
                else
                {
                    int Class = Convert.ToInt32(___ROYcms_news.GetClassName(Convert.ToInt32(Rid))); //获取Class
                    MainField = ROYcms_CustomBLL.GetVal(Convert.ToInt32(Rid), Class, Name);         //获取自定义字段的名字
                }
                output.Write(MainField);
            }
            catch { output.Write("<!--输出错误!-->"); }
        }
示例#4
0
        /// <summary>
        /// 返回文章URL静态地址
        /// </summary>
        /// <param name="Rid"></param>
        /// <returns></returns>
        public string GetStaticArticle(int Rid)
        {
            try
            {
                string   Url       = null;
                int      ClassId   = Convert.ToInt32(NewBll.GetClassName(Rid));                                             //频道ID
                string   ShowRules = ClassBll.GetClassField(ClassId, "ShowRules");                                          //文章生成规则
                string   jumpurl   = NewBll.GetField(Rid, "jumpurl") == null ? "" : NewBll.GetField(Rid, "jumpurl").Trim(); //跳转地址
                string   url       = NewBll.GetField(Rid, "url") == null ? "" : NewBll.GetField(Rid, "url").Trim();         //
                string   FilePath  = ClassBll.GetClassField(ClassId, "FilePath");                                           //频道目录
                DateTime Time      = Convert.ToDateTime(NewBll.GetField(Rid, "TIME"));                                      //文章的ID
                //参数替换
                FilePath  = FilePath.ToLower().Replace("{cmspath}", "/");                                                   //替换参数
                ShowRules = ShowRules.ToLower().Replace("{cmspath}", "/");                                                  //替换参数
                ShowRules = ShowRules.ToLower().Replace("{channel}", FilePath);                                             //替换参数
                ShowRules = ShowRules.ToLower().Replace("{id}", Rid.ToString());
                ShowRules = ShowRules.Replace("{yyyy}", Time.Year.ToString());                                              //替换年参数
                ShowRules = ShowRules.Replace("{MM}", Time.Month.ToString());                                               //替换月参数
                ShowRules = ShowRules.Replace("{dd}", Time.Day.ToString());                                                 //替换日参数


                Url = ShowRules;
                if (url.Length > 2)//自定义地址
                {
                    Url = url;
                }
                if (jumpurl.Length > 2)//跳转地址
                {
                    Url = jumpurl;
                }
                Url = Url.Replace("//", "/").Replace("///", "/");//替换
                return(Url);
            }
            catch {
                return(null);
            }
        }
示例#5
0
        /// <summary>
        /// Dels the HTML.
        /// </summary>
        /// <param name="Model">The model.</param>
        /// <returns></returns>
        public void DelHtml(int id)
        {
            try
            {
                ROYcms.Sys.BLL.ROYcms_news    BLL      = new ROYcms.Sys.BLL.ROYcms_news();
                ROYcms.Sys.BLL.ROYcms_class   ClassBLL = new ROYcms.Sys.BLL.ROYcms_class();
                ROYcms.Sys.Model.ROYcms_class Model    = ClassBLL.GetModel(ClassBLL.GetClassId(Convert.ToInt32(BLL.GetClassName(id))));
                ROYcms.Sys.Model.ROYcms_news  NewModel = BLL.GetModel(id);
                string Path = null;
                Model.FilePath = Model.FilePath.Replace("{cmspath}", "~");
                Path           = (Model.ShowRules.Contains("~/") ? Model.ShowRules : (Model.FilePath + Model.ShowRules)); //文件生成地址
                Path           = Path.Replace("{yyyy}", Convert.ToDateTime(NewModel.time).ToString("yyyy"));
                Path           = Path.Replace("{MM}", Convert.ToDateTime(NewModel.time).ToString("MM"));
                Path           = Path.Replace("{dd}", Convert.ToDateTime(NewModel.time).ToString("dd"));
                Path           = Path.Replace("{id}", id.ToString());

                using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))))
                {
                    // File.Delete(HttpContext.Current.Server.MapPath(Path));

                    sw.WriteLine("文件已经删除!<a href='/inde.aspx'>到首页</a>");
                    sw.Flush();
                }
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
            }
        }