예제 #1
0
        //public static Regex regex_allAttach = new Regex(@"\[attach[imgeda=\d+,]*\](?<id>\d+)\[/attach[imgeda]*\]", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);

        /// <summary>
        /// 保存的时候 处理UBB 处理表情 不处理[local]标签
        /// </summary>
        /// <param name="posterUserID"></param>
        /// <param name="userEmoticon"></param>
        /// <param name="forumID"></param>
        /// <param name="content"></param>
        /// <param name="allowHtml"></param>
        /// <param name="allowMaxcode3"></param>
        /// <returns></returns>
        public static string ParseWhenSave(int posterUserID, bool useEmoticon, int forumID, string content, bool allowHtml, bool allowMaxcode3, AttachmentCollection attachments)
        {
            User currentUser = User.Current;

            content = content.Replace("[/quote]\r", "[/quote]");
            content = content.Replace("[/quote]\n", "[/quote]");

            content = new PostUbbParserV5(UserBO.Instance.GetUser(posterUserID,GetUserOption.WithAll), forumID, allowHtml, allowMaxcode3, true).UbbToHtml(content);

            bool allowEmoticon = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(forumID).CreatePostAllowEmoticon.GetValue(currentUser);

            if (useEmoticon && allowEmoticon)
            {
                content = EmoticonParser.ParseToHtml(posterUserID, content);
            }

            //attachments  同一个附件出现多次 只显示一个?

            return content;
        }
예제 #2
0
        public static string ParseWhenDisplay(int posterUserID, int forumID, int postID, string content, bool allowHtmlForV2, bool allowMaxcodeForV2, bool isV5_0, AttachmentCollection attachmemts)
        {
            content = StringUtil.EncodeInnerUrl(content);

            User postUser = UserBO.Instance.GetUser(posterUserID, GetUserOption.WithAll);

            if (attachmemts != null && attachmemts.Count > 0)
            {
                ForumSettingItem forumSetting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(forumID);
                AuthUser my = User.Current;

                bool? hasViewAttachPermission = null, canAlwaysViewContents = null, allowImageTag = null
                    , allowAudioTag = null, allowVideoTag = null, allowFlashTag = null;
                content = regex_allAttach.Replace(content, delegate(Match match)
                {
                    return OnMatchAllAttach(match, my, postUser, forumID, attachmemts, forumSetting, ref hasViewAttachPermission
                        , ref canAlwaysViewContents, ref allowImageTag, ref allowAudioTag, ref allowVideoTag, ref allowFlashTag);
                });

                if (isV5_0 == false)
                {
                    content = ReplaceV30AttachTag(content, postID);

                    content = regex_fileInfo.Replace(content, string.Empty);
                }

            }

            if (isV5_0 == false)
                content = new PostUbbParserV5(postUser, forumID, true, allowMaxcodeForV2, false).UbbToHtml(content);

            return UrlUtil.ReplaceRootVar(content);
        }