예제 #1
0
        ///// <summary>
        ///// 添加 形象图 按钮事件 Handles the Click event of the Button_add_img control.
        ///// </summary>
        ///// <param name="sender">The source of the event.</param>
        ///// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        //protected void Button_add_img_Click(object sender, EventArgs e)
        //{

        //    if (ROYcms.Common.Session.Get("user") != null)
        //    {
        //        AddImg(ROYcms.Common.Session.Get("user") + "/");
        //    }
        //    else
        //    {
        //        AddImg((this.txtauthor.Text.Trim() == "" ? "admin" : this.txtauthor.Text.Trim()) + "/");
        //    }
        //}
        ///// <summary>
        ///// 添加 形象图 方法 Adds the img.
        ///// </summary>
        ///// <param name="path">The path.</param>
        //void AddImg(string path)
        //{
        //    UP_img up_img = new UP_img();
        //    if (FileUpload1.HasFile)
        //    {
        //        string fileContentType = FileUpload1.PostedFile.ContentType;
        //        if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
        //        {
        //            string name = FileUpload1.PostedFile.FileName;                         // 客户端文件路径
        //            FileInfo file = new FileInfo(name);
        //            string fileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + name.Substring(name.LastIndexOf("."), name.Length - name.LastIndexOf("."));                                           // 文件名称
        //            string webFilePath = Server.MapPath(this.WEBSITE_UP_FILES + path);          // 服务器端文件路径

        //            string webFilePath_s = Server.MapPath(this.WEBSITE_UP_FILES + path + "s_");    // 服务器端缩略图路径

        //            if (!Directory.Exists(webFilePath))//判断是否存在
        //            {
        //                Directory.CreateDirectory(webFilePath);//创建新路径
        //            }
        //            try
        //            {
        //                this.FileUpload1.SaveAs(webFilePath + "_" + fileName);                                 // 使用 SaveAs 方法保存文件
        //                string[] Size = DropDownList_ImgSize.SelectedValue.Split(',');
        //                up_img.MakeThumbnail(webFilePath + "_" + fileName, webFilePath_s + fileName, Convert.ToInt32(Size[0]), Convert.ToInt32(Size[1]), "W");          // 生成缩略图方法
        //                up_img.AddWaterPic(webFilePath + "_" + fileName, webFilePath + fileName, Server.MapPath("~/App_Data/Water.png"));          // 生成缩略图方法

        //                // FCKeditor1.Value = FCKeditor1.Value + "<img src=" + Config.ROYcmsConfig.Get_Config().web_host + this.AppendixPath.Replace("~/", "") + path + fileName + " />";
        //                txtpic.Text = fileName;
        //                ROYcms.Common.MessageBox.Show(this, "上载成功!");
        //            }
        //            catch
        //            {
        //                ROYcms.Common.MessageBox.Show(this, "文件上传失败!");
        //                // Response.Write("文件上传失败!");
        //            }
        //        }
        //        else
        //        {
        //            ROYcms.Common.MessageBox.Show(this, "文件类型不符!");
        //            // Response.Write("文件类型不符!");
        //        }
        //    }
        //}

        #region 数据绑定
        /// <summary>
        /// DDLs the menu_bind.
        /// </summary>
        void DdlMenu_bind()
        {
            DataSet ds = new ROYcms.Sys.Bll.ROYcms_class().GetClassList(this.ClassKind);

            this.DdlMenu.Items.Clear();
            this.DdlMenu.Items.Add(new ListItem("请选择所属分类", ""));
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                int    ClassTj   = Convert.ToInt32(dr["ClassTj"]);
                string Id        = dr["Id"].ToString().Trim();
                string ClassName = dr["ClassName"].ToString().Trim();

                if (ClassTj == 1)
                {
                    this.DdlMenu.Items.Add(new ListItem(ClassName, Id));
                }
                else
                {
                    ClassName = "├ " + ClassName;
                    ClassName = ROYcms.Common.StringPlus.StringOfChar(ClassTj - 1, " ") + ClassName;

                    this.DdlMenu.Items.Add(new System.Web.UI.WebControls.ListItem(ClassName, Id));
                }
            }
        }
예제 #2
0
        ///// <summary>
        ///// loop标签的匹配替换
        ///// </summary>
        ///// <param name="template">模板内容</param>
        public string LoopClass(string template)
        {
            string Attributes = "";
            string Text       = "";
            string AllText    = "";
            Regex  r          = new Regex(@"(\[SG:class\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:class\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            foreach (Match m in r.Matches(template))
            {
                Attributes = m.Groups["attributes"].ToString(); //循环属性集
                Text       = m.Groups["text"].ToString();       //循环的内容不包含SG:Loop
                AllText    = m.Groups[0].Value.ToString();      //整个匹配的内容包含SG:Loop

                #region  取得相关属性
                string Count   = null;   //调用数量
                string classID = null;
                string Templet = null;   // 模板ID

                Templet = TagVal(Attributes, "Templet");
                Count   = TagVal(Attributes, "Count");

                classID = TagVal(Attributes, "classID");

                #endregion

                #region 对循环的内容进行替换
                string content = "";
                ROYcms.Sys.Bll.ROYcms_class bll = new ROYcms.Sys.Bll.ROYcms_class();
                DataSet dt = bll.GetClassList(0);
                if (classID != null)
                {
                    dt = bll.GetSubClassList(bll.GetClassId(Convert.ToInt32(classID)));
                }
                if (dt.Tables[0].Rows.Count > 0)
                {
                    int rowsCount = dt.Tables[0].Rows.Count;
                    if (Count != null && rowsCount > Convert.ToInt32(Count))
                    {
                        rowsCount = Convert.ToInt32(Count);
                    }
                    for (int n = 0; n < rowsCount; n++)
                    {
                        string str = Text;
                        str      = Replace(str, @"\[SG:ClassName\]", dt.Tables[0].Rows[n]["ClassName"].ToString());
                        str      = Replace(str, @"\[SG:Link\]", config.web_host + TemplateZone.Zpath(this.pageHost) + "list" + Templet + "-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge);
                        str      = Replace(str, @"\[SG:_Link\]", "list-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge);
                        content += str;
                    }
                }
                else
                {
                    content = "";
                }
                #endregion
                template = template.Replace(AllText, content);
            }
            return(template);
        }
예제 #3
0
        ///// <summary>
        ///// loopPage分页标签的匹配替换
        ///// </summary>
        ///// <param name="template">模板内容</param>
        public string loopPage(string template)
        {
            string Attributes = "";
            string Text       = "";
            string AllText    = "";
            Regex  r          = new Regex(@"(\[SG:loopPage\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:loopPage\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            foreach (Match m in r.Matches(template))
            {
                Attributes = m.Groups["attributes"].ToString(); //循环属性集
                Text       = m.Groups["text"].ToString();       //循环的内容不包含SG:Loop
                AllText    = m.Groups[0].Value.ToString();      //整个匹配的内容包含SG:Loop

                #region  取得相关属性
                string NewsCount = null;     //调用数量
                string TitleNum  = null;     //新闻标题的显示字符数量
                string ding      = null;
                string tuijian   = null;
                string NewsType  = null;     //调用新闻的类型
                string Templet   = null;     // 模板ID
                string Pagesize  = null;     //

                string SQL = null;

                NewsCount = TagVal(Attributes, "NewsCount");
                if (NewsCount == null)
                {
                    NewsCount = "1000";
                }
                TitleNum = TagVal(Attributes, "TitleNum");
                if (TitleNum == null)
                {
                    TitleNum = "100";
                }
                ding = TagVal(Attributes, "ding");
                if (ding == null)
                {
                    ding = "false";
                }
                tuijian = TagVal(Attributes, "tuijian");
                if (tuijian == null)
                {
                    tuijian = "false";
                }

                NewsType = TagVal(Attributes, "NewsType");
                if (NewsType == null)
                {
                    NewsType = "0";
                }
                if (this.classs != null)
                {
                    NewsType = this.classs;
                }

                Templet = TagVal(Attributes, "Templet");

                Pagesize = TagVal(Attributes, "Pagesize");
                if (Pagesize == null)
                {
                    Pagesize = "30";
                }

                SQL = TagVal(Attributes, "SQL");
                #endregion

                #region 构造 查询SQL语句
                //SQL语句拼接
                string        strWher = "";
                StringBuilder strSql  = new StringBuilder();
                if (SQL == null)
                {
                    strWher = "classname='" + NewsType + "'";

                    strSql.Append("select top ");
                    strSql.Append(NewsCount);
                    strSql.Append(" * from [" + config.date_prefix + "news] where ");
                    strSql.Append(strWher);
                    strSql.Append(" AND switchs='0'");
                    if (ding == "true")
                    {
                        strSql.Append(" AND ding='0'");
                    }
                    if (tuijian == "true")
                    {
                        strSql.Append(" AND tuijian='0'");
                    }
                    strSql.Append(" order by switchs,bh DESC");
                }
                else
                {
                    strSql.Append(SQL);
                }


                #endregion
                #region 对循环的内容进行替换
                string    content     = "";
                DataSet   Pa          = Bll.GetDataSet(strSql.ToString());
                int       PageContent = Pa.Tables[0].Rows.Count;//数据总数 分页用
                int       PS          = Convert.ToInt32(Pagesize);
                int       p           = Convert.ToInt32(pageNum == null ? "1" : pageNum) - 1;
                DataTable dt          = new DataTable();
                dt = Pa.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    int rowsCount = p * PS + PS;
                    if ((p * PS + PS) - dt.Rows.Count > 0)
                    {
                        rowsCount = dt.Rows.Count;
                    }

                    for (int n = p * PS; n < rowsCount; n++)
                    {
                        string str = Text;
                        str = Replace(str, @"\[SG:Title\]", ROYcms.Common.input.GetSubString(dt.Rows[n]["title"].ToString(), Convert.ToInt32(TitleNum)));
                        str = Replace(str, @"\[SG:Id\]", dt.Rows[n]["bh"].ToString());
                        str = Replace(str, @"\[SG:Url\]", dt.Rows[n]["url"].ToString());

                        str = Replace(str, @"\[SG:Link\]", dt.Rows[n]["jumpurl"].ToString() == "" ? (config.web_host + TemplateZone.Zpath(this.pageHost) + "show" + Templet + "-" + dt.Rows[n]["bh"].ToString() + "-" + Convert.ToDateTime(dt.Rows[n]["time"]).ToString("yyyyMM") + config.web_forge) : dt.Rows[n]["jumpurl"].ToString());
                        str = Replace(str, @"\[SG:_Link\]", dt.Rows[n]["jumpurl"].ToString() == "" ? ("show-" + dt.Rows[n]["bh"].ToString() + "-" + Convert.ToDateTime(dt.Rows[n]["time"]).ToString("yyyyMM") + config.web_forge) : dt.Rows[n]["jumpurl"].ToString());
                        str = Replace(str, @"\[SG:Pic\]", dt.Rows[n]["pic"].ToString());
                        str = Replace(str, @"\[SG:Zhaiyao\]", dt.Rows[n]["zhaiyao"].ToString());
                        str = Replace(str, @"\[SG:Keyword\]", dt.Rows[n]["keyword"].ToString());
                        str = Replace(str, @"\[SG:classname\]", dt.Rows[n]["classname"].ToString());

                        str = Replace(str, @"\[SG:Content\]", dt.Rows[n]["contents"].ToString());
                        str = Replace(str, @"\[SG:Infor\]", dt.Rows[n]["infor"].ToString());
                        str = Replace(str, @"\[SG:Author\]", dt.Rows[n]["author"].ToString());
                        str = Replace(str, @"\[SG:Tag\]", dt.Rows[n]["tag"].ToString());
                        str = Replace(str, @"\[SG:Dig\]", dt.Rows[n]["dig"].ToString());
                        str = Replace(str, @"\[SG:Hits\]", dt.Rows[n]["hits"].ToString());
                        str = Replace(str, @"\[SG:Time\]", dt.Rows[n]["time"].ToString());
                        str = Replace(str, @"\[SG:Year\]", Convert.ToDateTime(dt.Rows[n]["time"]).Date.Year.ToString());
                        str = Replace(str, @"\[SG:Month\]", Convert.ToDateTime(dt.Rows[n]["time"]).Date.Month.ToString());
                        str = Replace(str, @"\[SG:Day\]", Convert.ToDateTime(dt.Rows[n]["time"]).Date.Day.ToString());

                        content += str;
                    }
                }
                else
                {
                    content = "";
                }
                #endregion

                template = template.Replace(AllText, content);
                template = template.Replace(@"[SG:Page]", PageContent.ToString());
                if (this.classs != null)
                {
                    ROYcms.Sys.Bll.ROYcms_class ROYcms_classBLL = new ROYcms.Sys.Bll.ROYcms_class();

                    template = template.Replace(@"[SG:ClassTitle]", ROYcms_classBLL.GetClassTitle(Convert.ToInt32(this.classs)));
                }
            }
            return(template);
        }