Ejemplo n.º 1
0
        /// <summary>
        /// 获得热门回复主题html
        /// </summary>
        /// <returns></returns>
        public static string GetHotReplyTopicsHtml()
        {
            StringBuilder sbhtml = new StringBuilder();

            foreach (TopicInfo topicInfo in Discuz.Data.Stats.GetHotReplyTopicsHtml())
            {
                sbhtml.AppendFormat("<li><em>{0}</em><a href=\"{1}\">{2}</a>\r\n",
                                    topicInfo.Replies,
                                    Urls.ShowTopicAspxRewrite(topicInfo.Tid, 0),
                                    topicInfo.Title);
            }
            return(sbhtml.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 转换热门图片为数组
        /// </summary>
        /// <param name="topNumber">获取的数量</param>
        /// <param name="orderBy">排序方式</param>
        /// <param name="cachetime">缓存时间</param>
        /// <returns></returns>
        public static string HotImagesArray(ForumHotItemInfo forumHotItemInfo)
        {
            string        imagesItemTemplate = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
            string        imagesPageTemplate = "<a href=\"#\" rel=\"{0}\">{0}</a>";
            StringBuilder hotImagesLi        = new StringBuilder();
            StringBuilder hotImagePage       = new StringBuilder();

            //如果没有缩略图目录,则去生成
            if (!Directory.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")))
            {
                Utils.CreateDir(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/"));
            }

            //如果版块idlist设置为空,则默认读取所有可见板块的idlist
            string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;
            int    i         = 1;

            foreach (DataRow dr in HotImages(forumHotItemInfo.Dataitemcount, forumHotItemInfo.Cachetimeout, forumHotItemInfo.Sorttype, forumHotItemInfo.Id, forumList, forumHotItemInfo.Enabled).Rows)
            {
                int    tid      = TypeConverter.ObjectToInt(dr["tid"]);
                string fileName = dr["filename"].ToString().Trim();
                string title    = dr["title"].ToString().Trim();

                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                if (fileName.StartsWith("http://"))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeRemoteThumbnailImage(fileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName)), 360, 240);
                    hotImagesLi.AppendFormat(imagesItemTemplate, Urls.ShowTopicAspxRewrite(tid, 0), "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName), title);
                }
                else
                {
                    //图片文件名称
                    string fullFileName = BaseConfigs.GetForumPath + "upload/" + fileName.Replace('\\', '/').Trim();
                    //图片缩略后的名称
                    string thumbnailFileName = "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName);

                    if (!File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName)) && File.Exists(Utils.GetMapPath(fullFileName)))
                    {
                        DeleteCacheImageFile();
                        Thumbnail.MakeThumbnailImage(Utils.GetMapPath(fullFileName), Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName), 360, 240);
                    }
                    hotImagesLi.AppendFormat(imagesItemTemplate, Urls.ShowTopicAspxRewrite(tid, 0), "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName), title);
                }
                hotImagePage.AppendFormat(imagesPageTemplate, i);
                i++;
            }

            return("<div class=\"image_reel\"><ul>" + hotImagesLi.ToString() + "</ul></div><div class=\"paging\"><span></span>" + hotImagePage.ToString() + "</div>");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 前台版块列表弹出菜单
        /// </summary>
        /// <param name="usergroupid">用户组id</param>
        /// <param name="userid">当前用户id</param>
        /// <param name="extname">扩展名称</param>
        /// <returns>版块列表弹出菜单</returns>
        public static string GetForumListMenuDivCache(int usergroupid, int userid, string extname)
        {
            DNTCache cache = DNTCache.GetCacheService();
            string   str   = cache.RetrieveObject("/Forum/ForumListMenuDiv") as string;

            if (Utils.StrIsNullOrEmpty(str))
            {
                StringBuilder    sb        = new StringBuilder();
                List <ForumInfo> forumList = Forums.GetForumList();

                if (forumList.Count > 0)
                {
                    sb.Append("<div class=\"popupmenu_popup\" id=\"forumlist_menu\" style=\"overflow-y: auto; display:none\">");

                    foreach (ForumInfo info in forumList)
                    {
                        if (info.Layer >= 0 && info.Layer <= 1 && info.Status == 1)
                        {
                            //判断是否为私密论坛
                            //if (info.Viewperm != "" && !Utils.InArray(usergroupid.ToString(), info.Viewperm))
                            //如果对当前执行该程序的用户组权限进行判断,则会将整站的导航下拉缓存都以当前用户组权限去设置,
                            //这样会出现用户有时能看到自己并没有权限访问的论坛板块
                            if (info.Viewperm.Trim() == string.Empty || Utils.InArray("7", info.Viewperm))
                            {
                                if (info.Layer == 0)
                                {
                                    sb.AppendFormat("<dl><dt><a href=\"{0}\">{1}</a></dt><dd><ul>",
                                                    BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(info.Fid, 0, info.Rewritename),
                                                    info.Name);

                                    foreach (ForumInfo forum in forumList)
                                    {
                                        if (Utils.StrToInt(forum.Parentidlist.Split(',')[0], 0) == info.Fid && forum.Layer == 1 && forum.Status == 1)
                                        {
                                            sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>",
                                                            BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(forum.Fid, 0, forum.Rewritename),
                                                            forum.Name.Trim());
                                        }
                                    }
                                    sb.Append("</ul></dd></dl>");
                                }
                            }
                        }
                    }
                }
                sb.Append("</div>");
                str = sb.ToString().Replace("<dd><ul></ul></dd>", "");
                cache.AddObject("/Forum/ForumListMenuDiv", str);
            }
            return(str);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 绑定feed模板中的变量值
        /// </summary>
        /// <param name="template"></param>
        /// <param name="dataJson"></param>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static string MergeFeedTemplateData(string template, string dataJson, UserInfo userInfo)
        {
            Dictionary <string, string> dataList = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(dataJson))
            {
                dataList = JavaScriptConvert.DeserializeObject <Dictionary <string, string> >(dataJson);
            }

            string actorData = string.Format("<a href=\"{0}\">{1}</a>", Urls.UserInfoAspxRewrite(userInfo.Uid), userInfo.Username);

            dataList.Add("actor", actorData);

            foreach (string key in dataList.Keys)
            {
                template = template.Replace("{" + key + "}", dataList[key]);
            }

            return(template);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 按指定的文件扩展名称设置版块列表中论坛路径(pathlist)字段
        /// </summary>
        /// <param name="extname">扩展名称,如:aspx , html 等</param>
        public static void SetForumsPathList(bool isaspxrewrite, string extname)
        {
            DataTable dt        = Forums.GetForumListForDataTable();
            string    forumPath = BaseConfigs.GetForumPath;

            foreach (DataRow dr in dt.Rows)
            {
                string pathList = "";

                if (dr["parentidlist"].ToString().Trim() == "0")
                {
                    pathList = "<a href=\"" + (dr["rewritename"].ToString().Trim() == string.Empty ? string.Empty : forumPath) + Urls.ShowForumAspxRewrite(Utils.StrToInt(dr["fid"], 0), 0, dr["rewritename"].ToString()) + "\">" + dr["name"].ToString().Trim() + "</a>";
                }
                else
                {
                    foreach (string parentid in dr["parentidlist"].ToString().Trim().Split(','))
                    {
                        if (parentid.Trim() != "")
                        {
                            DataRow[] drs = dt.Select("[fid]=" + parentid);
                            if (drs.Length > 0)
                            {
                                pathList += "<a href=\"" + (drs[0]["rewritename"].ToString().Trim() == string.Empty ? string.Empty : forumPath) + Urls.ShowForumAspxRewrite(Utils.StrToInt(drs[0]["fid"], 0), 0, drs[0]["rewritename"].ToString()) + "\">" + drs[0]["name"].ToString().Trim() + "</a>";
                            }
                        }
                    }
                    string url = Urls.ShowForumAspxRewrite(Utils.StrToInt(dr["fid"], 0), 0, dr["rewritename"].ToString());
                    pathList += "<a href=\"" + (dr["rewritename"].ToString().Trim() == "" ? "" : forumPath) + Urls.ShowForumAspxRewrite(Utils.StrToInt(dr["fid"], 0), 0, dr["rewritename"].ToString()) + "\">" + dr["name"].ToString().Trim() + "</a>";
                }
                foreach (ForumInfo forumInfo in Discuz.Data.Forums.GetForumList())
                {
                    if (forumInfo.Fid == int.Parse(dr["fid"].ToString()))
                    {
                        forumInfo.Pathlist = pathList;
                        Data.Forums.UpdateForumInfo(forumInfo);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取最后发帖版块信息
        /// </summary>
        /// <returns></returns>
        public static SimpleForumInfo GetLastPostedForum()
        {
            string lastPostedForum = Utils.GetCookie("lastpostedforum");

            if (lastPostedForum == "")
            {
                return(null);
            }
            foreach (ForumInfo forumInfo in Forums.GetForumList())
            {
                if (forumInfo.Fid.ToString() == lastPostedForum)
                {
                    SimpleForumInfo simpleForumInfo = new SimpleForumInfo();
                    simpleForumInfo.Fid             = forumInfo.Fid;
                    simpleForumInfo.Name            = Utils.RemoveHtml(forumInfo.Name); //如果不过滤掉HTML代码,则如果版块名称中存在html代码,会出现js错误,并且快速发帖出显示也不正常
                    simpleForumInfo.Url             = Urls.ShowForumAspxRewrite(forumInfo.Fid, 1, forumInfo.Rewritename);
                    simpleForumInfo.Postbytopictype = forumInfo.Postbytopictype;
                    simpleForumInfo.Topictypes      = forumInfo.Topictypes;
                    return(simpleForumInfo);
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
 protected string ShowGoodsListAspxRewrite(int categoryid, int pageid)
 {
     return(Urls.ShowGoodsListAspxRewrite(categoryid, pageid));
 }
Ejemplo n.º 8
0
 protected string ShowGoodsAspxRewrite(int goodsid)
 {
     return(Urls.ShowGoodsAspxRewrite(goodsid));
 }
Ejemplo n.º 9
0
 protected string RssAspxRewrite(int forumid)
 {
     return(Urls.RssAspxRewrite(forumid));
 }
Ejemplo n.º 10
0
 protected string UserInfoAspxRewrite(int userid)
 {
     return(Urls.UserInfoAspxRewrite(userid));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 前台版块列表弹出菜单
        /// </summary>
        /// <param name="usergroupid">用户组id</param>
        /// <param name="userid">当前用户id</param>
        /// <param name="extname">扩展名称</param>
        /// <returns>版块列表弹出菜单</returns>
        public static string GetForumListMenuDivCache(int usergroupid, int userid, string extname)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string str = cache.RetrieveObject("/ForumListMenuDiv") as string;

            if (str != null)
            {
                return(str);
            }

            StringBuilder sb = new StringBuilder();

            ForumInfo[] foruminfoarray = Forums.GetForumList();

            if (foruminfoarray.Length > 0)
            {
                sb.Append("<div class=\"popupmenu_popup\" id=\"forumlist_menu\" style=\"overflow-y: auto; display:none\">");

                foreach (ForumInfo info in foruminfoarray)
                {
                    if (info.Layer >= 0 && info.Layer <= 1 && info.Status == 1)
                    {
                        //判断是否为私密论坛
                        if (info.Viewperm != "" && !Utils.InArray(usergroupid.ToString(), info.Viewperm))
                        {
                            //
                        }
                        else
                        {
                            if (info.Layer == 0)
                            {
                                sb.Append("<dl>");
                                sb.Append("<dt>");
                                sb.Append("<a href=\"");
                                sb.Append(Urls.ShowForumAspxRewrite(info.Fid, 0));
                                sb.Append("\">");

                                sb.Append(info.Name);
                                sb.Append("</a></dt>");

                                sb.Append("<dd><ul>");
                                foreach (ForumInfo forum in foruminfoarray)
                                {
                                    if (int.Parse(forum.Parentidlist.Split(',')[0]) == info.Fid && forum.Layer == 1)
                                    {
                                        sb.Append("<li><a href=\"");
                                        sb.Append(Urls.ShowForumAspxRewrite(forum.Fid, 0));
                                        sb.Append("\">");
                                        sb.Append(forum.Name);
                                        sb.Append("</a></li>");
                                    }
                                }
                                sb.Append("</ul></dd>");
                                sb.Append("</dl>");
                            }
                        }
                    }
                }
            }
            sb.Append("</div>");
            str = sb.ToString().Replace("<dd><ul></ul></dd>", "");
            cache.AddObject("/ForumListMenuDiv", str);

            return(str);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获得用户排行的html
        /// </summary>
        /// <param name="users"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetUserRankHtml(ShortUserInfo[] users, string type, int maxrows)
        {
            StringBuilder builder   = new StringBuilder();
            string        unit      = "";
            int           blankrows = maxrows;

            foreach (ShortUserInfo u in users)
            {
                string count = string.Empty;
                switch (type)
                {
                case "credits":
                    count = u.Credits.ToString();
                    break;

                case "extcredits1":
                    count = u.Extcredits1.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[1];
                    break;

                case "extcredits2":
                    count = u.Extcredits2.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[2];
                    break;

                case "extcredits3":
                    count = u.Extcredits3.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[3];
                    break;

                case "extcredits4":
                    count = u.Extcredits4.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[4];
                    break;

                case "extcredits5":
                    count = u.Extcredits5.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[5];
                    break;

                case "extcredits6":
                    count = u.Extcredits6.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[6];
                    break;

                case "extcredits7":
                    count = u.Extcredits7.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[7];
                    break;

                case "extcredits8":
                    count = u.Extcredits8.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[8];
                    break;

                case "digestposts":
                    count = u.Digestposts.ToString();
                    break;

                case "onlinetime":
                    count = Math.Round(((double)u.Oltime) / 60, 2).ToString();
                    unit  = "小时";
                    break;

                default:
                    count = u.Posts.ToString();
                    break;
                }

                builder.AppendFormat("<li><em>{0}</em><a href=\"{1}\" target=\"_blank\">{2}</a></li>", count + (unit == string.Empty ? string.Empty : " " + unit), Urls.UserInfoAspxRewrite(u.Uid), u.Username);
                blankrows--;
            }
            for (int i = 0; i < blankrows; i++)
            {
                builder.Append("<li>&nbsp;</li>");
            }
            return(builder.ToString());
        }
Ejemplo n.º 13
0
 protected string ShowForumAspxRewrite(int forumid, int pageid, string rewritename)
 {
     return(Urls.ShowForumAspxRewrite(forumid, pageid, rewritename));
 }
Ejemplo n.º 14
0
 protected string ShowForumAspxRewrite(string pathlist, int forumid, int pageid)
 {
     return(Urls.ShowForumAspxRewrite(pathlist, forumid, pageid));
 }
Ejemplo n.º 15
0
 protected string ShowDebateAspxRewrite(int topicid)
 {
     return(Urls.ShowDebateAspxRewrite(topicid));
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 获得板块排行的html
        /// </summary>
        /// <param name="forums"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetForumsRankHtml(List <ForumInfo> forums, string type, int maxrows)
        {
            StringBuilder builder = new StringBuilder();

            foreach (ForumInfo f in forums)
            {
                builder.AppendFormat("<li><em>{0}</em><a href=\"{1}\" target=\"_blank\">{2}</a></li>", type == "topics" ? f.Topics : f.Posts, Urls.ShowForumAspxRewrite(f.Fid, 0), f.Name);
                maxrows--;
            }
            for (int i = 0; i < maxrows; i++)
            {
                builder.Append("<li>&nbsp;</li>");
            }
            return(builder.ToString());
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 设置关于showbonus页面链接的显示样式
 /// </summary>
 /// <param name="topicid"></param>
 /// <param name="pageid"></param>
 /// <returns></returns>
 protected string ShowBonusAspxRewrite(int topicid, int pageid)
 {
     return(Urls.ShowBonusAspxRewrite(topicid, pageid));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 转换热门图片为数组
        /// </summary>
        /// <param name="topNumber">获取的数量</param>
        /// <param name="orderBy">排序方式</param>
        /// <param name="cachetime">缓存时间</param>
        /// <returns></returns>
        public static string HotImagesArray(ForumHotItemInfo forumHotItemInfo)
        {
            string        imagesItemTemplate = "title:\"{0}\",img:\"{1}\",url:\"{2}\"";
            StringBuilder hotImagesArray     = new StringBuilder();

            //如果没有缩略图目录,则去生成
            if (!Directory.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")))
            {
                Utils.CreateDir(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/"));
            }

            //如果版块idlist设置为空,则默认读取所有可见板块的idlist
            string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;

            foreach (DataRow dr in HotImages(forumHotItemInfo.Dataitemcount, forumHotItemInfo.Cachetimeout, forumHotItemInfo.Sorttype, forumHotItemInfo.Id, forumList, forumHotItemInfo.Enabled).Rows)
            {
                int    tid      = TypeConverter.ObjectToInt(dr["tid"]);
                string fileName = dr["filename"].ToString().Trim();
                string title    = dr["title"].ToString().Trim();

                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                if (fileName.StartsWith("http://"))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeRemoteThumbnailImage(fileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName)), 360, 240);
                    hotImagesArray.Append("{");
                    hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName), Urls.ShowTopicAspxRewrite(tid, 0));
                    hotImagesArray.Append("},");
                    continue;
                }
                //图片文件名称
                string fullFileName = BaseConfigs.GetForumPath + "upload/" + fileName.Replace('\\', '/').Trim();
                //图片缩略后的名称
                string thumbnailFileName = "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName);

                if (!File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName)) && File.Exists(Utils.GetMapPath(fullFileName)))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeThumbnailImage(Utils.GetMapPath(fullFileName), Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName), 360, 240);
                }
                hotImagesArray.Append("{");
                hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName), Urls.ShowTopicAspxRewrite(tid, 0));
                hotImagesArray.Append("},");
            }

            return("[" + hotImagesArray.ToString().TrimEnd(',') + "]");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获得热门回复主题html
        /// </summary>
        /// <returns></returns>
        public static string GetHotReplyTopicsHtml()
        {
            string      html   = string.Empty;
            IDataReader reader = DatabaseProvider.GetInstance().GetHotReplyTopics(20);

            while (reader.Read())
            {
                html += "<li><em>" + reader["replies"].ToString() + "</em><a href=\"" + Urls.ShowTopicAspxRewrite(Convert.ToInt32(reader["tid"]), 0) + "\">" + reader["title"].ToString() + "</a>\r\n";
            }
            reader.Close();
            return(html);
        }