Example #1
0
        /// <summary>
        /// 商品信息字段(message)转换
        /// </summary>
        /// <param name="goodsPramsInfo">要转换的信息和相关参数设置</param>
        /// <param name="attColl">当前商品所包括的附件集合</param>
        /// <returns>返回转换后的信息</returns>
        public static string MessgeTranfer(GoodspramsInfo goodsPramsInfo, GoodsattachmentinfoCollection attColl)
        {
            goodsPramsInfo.Hide = 0;
            //先简单判断是否是动网兼容模式
            if (!goodsPramsInfo.Ubbmode)
                goodsPramsInfo.Sdetail = UBB.UBBToHTML((PostpramsInfo)goodsPramsInfo);
            else
                goodsPramsInfo.Sdetail = Utils.HtmlEncode(goodsPramsInfo.Sdetail);

            string message = goodsPramsInfo.Sdetail;
            if (GoodsAttachments.GetGoodsAttachmentsByGoodsid(goodsPramsInfo.Goodsid).Count > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message))
            {
                //获取在[hide]标签中的附件id
                string[] attHidArray = GetHiddenAttachIdList(goodsPramsInfo.Sdetail, goodsPramsInfo.Hide);

                for (int i = 0; i < attColl.Count; i++)
                {
                    message = GetMessageWithAttachInfo(goodsPramsInfo, 1, attHidArray, attColl[i], message);
                    if (Utils.InArray(attColl[i].Aid.ToString(), attHidArray))
                        attColl.RemoveAt(i);
                }
                goodsPramsInfo.Sdetail = message;
            }
            return goodsPramsInfo.Sdetail;
        }
Example #2
0
        /// <summary>
        /// 获取加载附件信息的商品内容
        /// </summary>
        /// <param name="goodspramsinfo">参数列表</param>
        /// <param name="allowGetAttach">是否允许获取附件</param>
        /// <param name="attHidArray">隐藏在hide标签中的附件数组</param>
        /// <param name="attinfo">附件信息</param>
        /// <param name="message">内容信息</param>
        /// <returns>商品内容信息</returns>
        private static string GetMessageWithAttachInfo(GoodspramsInfo goodsPramsInfo, int allowGetAttach, string[] attHidArray, Goodsattachmentinfo attInfo, string message)
        {
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string filesize;
            string replacement;
            if (Utils.InArray(attInfo.Aid.ToString(), attHidArray))
                return message;
        
            attInfo.Filename = attInfo.Filename.ToString().Replace("\\", "/");

            if (message.IndexOf("[attach]" + attInfo.Aid.ToString() + "[/attach]") != -1 || message.IndexOf("[attachimg]" + attInfo.Aid.ToString() + "[/attachimg]") != -1)
            {
                if (attInfo.Filesize > 1024)
                    filesize = Convert.ToString(Math.Round(Convert.ToDecimal(attInfo.Filesize) / 1024, 2)) + " K";
                else
                    filesize = attInfo.Filesize + " B";

                if (Utils.IsImgFilename(attInfo.Attachment))
                {
                    if (attInfo.Filename.ToLower().IndexOf("http") == 0)
                        replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attInfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + attInfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 0, event)\" /><div id=\"attach_" + attInfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + attInfo.Filename + "\"><strong>" + attInfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attInfo.Postdatetime + "</div></div>";
                    else
                        replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attInfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + forumPath + "upload/" + attInfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 0, event)\" /><div id=\"attach_" + attInfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + forumPath + "upload/" + attInfo.Filename + "\"><strong>" + attInfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attInfo.Postdatetime + "</div></div>";
                }
                else
                {
                    if (attInfo.Filename.ToLower().IndexOf("http") == 0)
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/attachment.gif\" border=\"0\" /><span class=\"bold\">附件</span>: <a href=\""+ attInfo.Filename +"\" target=\"_blank\">{2}</a> ({3}, {4})", forumPath, attInfo.Aid.ToString(), attInfo.Attachment.ToString().Trim(), attInfo.Postdatetime, filesize);
                    else
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/attachment.gif\" border=\"0\" /><span class=\"bold\">附件</span>: <a href=\"" + forumPath + "upload/" + attInfo.Filename + "\" target=\"_blank\">{2}</a> ({3}, {4})", forumPath, attInfo.Aid.ToString(), attInfo.Attachment.ToString().Trim(), attInfo.Postdatetime, filesize);
                }

                Regex r = new Regex(string.Format(@"\[attach\]{0}\[/attach\]|\[attachimg\]{0}\[/attachimg\]", attInfo.Aid));
                message = r.Replace(message, replacement, 1);
                message = message.Replace("[attach]" + attInfo.Aid.ToString() + "[/attach]", string.Empty);
                message = message.Replace("[attachimg]" + attInfo.Aid.ToString() + "[/attachimg]", string.Empty);
            }
            else if (attInfo.Goodsid == goodsPramsInfo.Goodsid)
            {
                ;
            }
            return message;
        }