Esempio n. 1
0
        /// <summary>
        /// 重新加载并初始化表情正则对象数组
        /// </summary>
        /// <param name="smiliesList">表情对象数组</param>
        public static void ResetRegexSmilies(SmiliesInfo[] smiliesList)
        {
            int smiliesCount = smiliesList.Length;

            // 如果数目不同则重新创建数组, 以免发生数组越界
            if (regexSmile == null || regexSmile.Length != smiliesCount)
                regexSmile = new Regex[smiliesCount];

            for (int i = 0; i < smiliesCount; i++)
            {
                regexSmile[i] = new Regex(@Regex.Escape(smiliesList[i].Code), RegexOptions.None);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 装载表情信息
 /// </summary>
 /// <param name="dt"></param>
 /// <returns></returns>
 private static SmiliesInfo[] LoadSmiliesInfo(DataTable dt)
 {
     if (dt == null || dt.Rows.Count < 1)
         return null;
     SmiliesInfo[] smilieslistinfo = new SmiliesInfo[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         smilieslistinfo[i] = new SmiliesInfo();
         smilieslistinfo[i].Id = TypeConverter.ObjectToInt(dt.Rows[i]["id"], 0);
         smilieslistinfo[i].Code = dt.Rows[i]["Code"].ToString();
         smilieslistinfo[i].Displayorder = TypeConverter.ObjectToInt(dt.Rows[i]["Displayorder"], 0);
         smilieslistinfo[i].Type = TypeConverter.ObjectToInt(dt.Rows[i]["Type"], 0);
         smilieslistinfo[i].Url = dt.Rows[i]["Url"].ToString();
     }
     return smilieslistinfo;
 }
Esempio n. 3
0
        /// <summary>
        /// 得到不带分类的表情符数据
        /// </summary>
        /// <returns>表情符表</returns>
        public static SmiliesInfo[] GetSmiliesListWithoutType()
        {
            DataTable dt = DatabaseProvider.GetInstance().GetSmiliesListWithoutType();
            if (dt == null || dt.Rows.Count < 1)
                return null;

            SmiliesInfo[] smilieslistinfo = new SmiliesInfo[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                smilieslistinfo[i] = new SmiliesInfo();
                smilieslistinfo[i].Id = TypeConverter.ObjectToInt(dt.Rows[i]["id"], 0);
                smilieslistinfo[i].Code = dt.Rows[i]["Code"].ToString();
                smilieslistinfo[i].Displayorder = TypeConverter.ObjectToInt(dt.Rows[i]["Displayorder"], 0);
                smilieslistinfo[i].Type = TypeConverter.ObjectToInt(dt.Rows[i]["Type"], 0);
                smilieslistinfo[i].Url = dt.Rows[i]["Url"].ToString();
            }
            return smilieslistinfo;
        }
Esempio n. 4
0
		/// <summary>
		/// 将缓存中的表情信息返回为SmiliesInfo[],不包括表情分类
		/// </summary>
		/// <returns></returns>
		public static SmiliesInfo[] GetSmiliesListWithInfo()
		{
			Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
			SmiliesInfo[] smilieslistinfo = cache.RetrieveObject("/UI/SmiliesListWithInfo") as SmiliesInfo[];
			if (smilieslistinfo == null)
			{
				DataTable dt = GetSmiliesListWithoutType();
				if (dt == null)
				{
					return null;
				}
				if (dt.Rows.Count <= 0)
				{
					return null;
				}

				smilieslistinfo = new SmiliesInfo[dt.Rows.Count];
				for (int i = 0; i < dt.Rows.Count; i++)
				{
					smilieslistinfo[i] = new SmiliesInfo();
					smilieslistinfo[i].Id = Utils.StrToInt(dt.Rows[i]["id"],0);
					smilieslistinfo[i].Code = dt.Rows[i]["Code"].ToString();
					smilieslistinfo[i].Displayorder = Utils.StrToInt(dt.Rows[i]["Displayorder"],0);
					smilieslistinfo[i].Type = Utils.StrToInt(dt.Rows[i]["Type"],0);
					smilieslistinfo[i].Url = dt.Rows[i]["Url"].ToString();

				}
				cache.AddObject("/UI/SmiliesListWithInfo", smilieslistinfo);

                //表情缓存重新加载时重新初始化表情正则对象数组
                ResetRegexSmilies(smilieslistinfo);
			}
			return smilieslistinfo;
		}
Esempio n. 5
0
        /// <summary>
        /// 转换表情
        /// </summary>
        /// <param name="sDetail">帖子内容</param>
        /// <param name="__smiliesinfo">表情数组</param>
        /// <param name="smiliesmax">每种表情的最大使用数</param>
        /// <returns>帖子内容</returns>
        private static string ParseSmilies(string sDetail, SmiliesInfo[] smiliesinfo, int smiliesmax)
        {
            if (smiliesinfo == null)
                return sDetail;

            string smilieformatstr = "[smilie]{0}editor/images/smilies/{1}[/smilie]";
            for (int i = 0; i < Smilies.regexSmile.Length; i++)
            {
                if (smiliesmax > 0)
                    sDetail = Smilies.regexSmile[i].Replace(sDetail, string.Format(smilieformatstr, BaseConfigs.GetForumPath, smiliesinfo[i].Url), smiliesmax);
                else
                    sDetail = Smilies.regexSmile[i].Replace(sDetail, string.Format(smilieformatstr, BaseConfigs.GetForumPath, smiliesinfo[i].Url));
            }
            return sDetail;
        }
Esempio n. 6
0
 /// <summary>
 /// 添加SmiliesInfo类型数据缓存
 /// </summary>
 /// <param name="xpath">分级对象的路径</param>
 /// <param name="smiliesInfoArray">缓存的数据</param>
 public virtual void AddObject(string xpath, SmiliesInfo[] smiliesInfoArray)
 {
     lock (lockHelper)
     {
         if (smiliesInfoArray.Length > 0)
         {
             AddObject(xpath + "flag", CacheFlag.CacheHaveData);
         }
         else
         {
             AddObject(xpath + "flag", CacheFlag.CacheNoData);
         }
         AddObject(xpath, (object)smiliesInfoArray);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// ���¼��ز���ʼ�����������������
        /// </summary>
        /// <param name="smiliesList">�����������</param>
        public static void ResetRegexSmilies(SmiliesInfo[] smiliesList)
        {
            int smiliesCount = smiliesList.Length;

            // �����Ŀ��ͬ�����´�������, ���ⷢ������Խ��
            if (regexSmile == null || regexSmile.Length != smiliesCount)
                regexSmile = new Regex[smiliesCount];

            for (int i = 0; i < smiliesCount; i++)
            {
                regexSmile[i] = new Regex(@Regex.Escape(smiliesList[i].Code), RegexOptions.None);
            }
        }