コード例 #1
0
 private void SmilesGridBind()
 {
     #region 绑定数据
     string          emptySmilieList = Discuz.Forum.Smilies.ClearEmptySmiliesType();
     DirectoryInfo[] dirInfo         = GetSmilesDirList();
     foreach (DirectoryInfo dir in dirInfo)
     {
         dirList.Add(dir.Name);
     }
     string d = "";
     foreach (DataRow dr in Discuz.Forum.Smilies.GetSmiliesTypes().Rows)
     {
         dirList.Remove(dr["url"]);
         d += dr["code"].ToString() + ",";
     }
     smilesgrid.TableHeaderName = "论坛表情列表";
     smilesgrid.BindData(Smilies.GetSmilies());
     ViewState["dir"]     = d;
     ViewState["dirList"] = dirList;
     if (emptySmilieList != "")
     {
         base.RegisterStartupScript("", "<script>alert('" + emptySmilieList + " 为空,已经被移除!');</script>");
     }
     #endregion
 }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string smilieUrl = "";
         foreach (DataRow dr in Smilies.GetSmilies().Rows)
         {
             if (dr["id"].ToString() == DNTRequest.GetString("typeid"))
             {
                 smilieUrl = dr["url"].ToString();
             }
         }
         url.UpFilePath = Server.MapPath(string.Format("../../editor/images/smilies/{0}/", smilieUrl));
     }
 }
コード例 #3
0
        private void InitializeRegularExpressionAndCss(int smileyWidth, int smileyHeight)
        {
            StringBuilder regExMatchString = new StringBuilder();
            StringBuilder cssToRender      = new StringBuilder();

            cssToRender.Append("span.smiley-common span{display:none;} ");

            foreach (Smiley smily in Smilies.GetSmilies())
            {
                string smileyCode = smily.SmileyCode;

                if (!string.IsNullOrWhiteSpace(smily.SmileyText) && !string.IsNullOrWhiteSpace(smileyCode))
                {
                    if (regExMatchString.Length > 0)
                    {
                        regExMatchString.Append("|");
                    }

                    if (smileyCode.Length == 1 || smileyCode.All(char.IsLetterOrDigit))
                    {
                        smileyCode = "[" + smileyCode + "]";
                    }

                    regExMatchString.Append(Regex.Escape(Transforms.Encode.HtmlEncode(smileyCode)).Replace("'", "(?:'|\\&\\#39;)"));

                    string cssClassName = "smiley-" + _replaceCssErrors.Replace(PublicApi.UI.MakeCssClassName(smily.SmileyText), ""); //bug in telligents make css class

                    CreateCss(cssToRender, cssClassName, smily.SmileyUrl, smileyWidth, smileyHeight);

                    _emoticonReplacementLookup[smileyCode] = string.Format("<span class=\"smiley-common {0}\" title=\"{1}\"><span>{{0}}</span></span>", cssClassName, Transforms.Encode.HtmlEnsureEncoded(smily.SmileyText));

                    if (smileyCode.Contains("'"))
                    {
                        _emoticonReplacementLookup[smileyCode.Replace("'", "&#39;")] = _emoticonReplacementLookup[smileyCode];
                    }
                }
            }

            if (regExMatchString.Length > 0)
            {
                _emoticonReplacementMatch = new Regex(@"(?<!<[^>]*)(?<!\<script\>.*)(" + regExMatchString + @")(?<![^>].*<)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                _cssToRender = cssToRender.ToString();
            }
        }