示例#1
0
        /// <summary>
        /// 获取访问过的版块信息
        /// </summary>
        /// <returns></returns>
        public static SimpleForumInfo[] GetVisitedForums()
        {
            string visitedForums = Utils.GetCookie("visitedforums");

            if (visitedForums == "")
            {
                return(new SimpleForumInfo[0]);
            }

            List <SimpleForumInfo> simpleForumList = new List <SimpleForumInfo>();

            foreach (string fid in visitedForums.Split(','))
            {
                foreach (ForumInfo forumInfo in Forums.GetForumList())
                {
                    if (forumInfo.Fid.ToString() == fid)
                    {
                        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;
                        simpleForumList.Add(simpleForumInfo);
                        break;
                    }
                }
            }
            return(simpleForumList.ToArray());
        }
示例#2
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);
        }
示例#3
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);
                    }
                }
            }
        }
示例#4
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);
        }
示例#5
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());
        }
示例#6
0
 protected string ShowForumAspxRewrite(int forumid, int pageid, string rewritename)
 {
     return(Urls.ShowForumAspxRewrite(forumid, pageid, rewritename));
 }
示例#7
0
 protected string ShowForumAspxRewrite(string pathlist, int forumid, int pageid)
 {
     return(Urls.ShowForumAspxRewrite(pathlist, forumid, pageid));
 }
示例#8
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);
        }