Ejemplo n.º 1
0
        private string ParseDataRow(IDataRecord row, string tmp)
        {
            try
            {
                tmp = tmp.Replace("[AVATAR]", "[AF:AVATAR]");
                for (int i = 0; i < row.FieldCount; i++)
                {
                    string name  = row.GetName(i);
                    string k     = "[" + name.ToUpperInvariant() + "]";
                    string value = row[i].ToString();
                    switch (row[i].GetType().ToString())
                    {
                    case "System.DateTime":
                        value = Utilities.GetDate(Convert.ToDateTime(row[i].ToString()), ModuleId, TimeZoneOffset);
                        break;
                    }
                    tmp = tmp.Replace(k, value);
                }

                ControlUtils cUtils       = new ControlUtils();
                Author       auth         = new Author();
                string       columnPrefix = "Topic";
                if (Convert.ToInt32(row["ReplyId"].ToString()) > 0)
                {
                    columnPrefix     = "Reply";
                    auth.DisplayName = row[columnPrefix + "AuthorDisplayName"].ToString();
                }
                else
                {
                    auth.DisplayName = row["TopicAuthorName"].ToString();
                }
                auth.AuthorId = int.Parse(row[columnPrefix + "AuthorId"].ToString());

                auth.LastName  = row[columnPrefix + "AuthorLastName"].ToString();
                auth.FirstName = row[columnPrefix + "AuthorFirstName"].ToString();
                auth.Username  = row[columnPrefix + "AuthorUsername"].ToString();

                tmp = tmp.Replace("[TOPICURL]", cUtils.TopicURL(row, TabId, ModuleId));
                tmp = tmp.Replace("[FORUMURL]", cUtils.ForumURL(row, TabId, ModuleId));
                if (int.Parse(row["LastAuthorId"].ToString()) == -1)
                {
                    try
                    {
                        tmp = tmp.Replace("[LASTAUTHOR]", UserProfiles.GetDisplayName(ModuleId, true, ForumUser.Profile.IsMod, ForumUser.IsAdmin || ForumUser.IsSuperUser, -1, auth.Username, auth.FirstName, auth.LastName, auth.DisplayName));
                    }
                    catch (Exception ex)
                    {
                        tmp = tmp.Replace("[LASTAUTHOR]", "anon");
                    }
                }
                else
                {
                    tmp = tmp.Replace("[LASTAUTHOR]", UserProfiles.GetDisplayName(ModuleId, true, ForumUser.Profile.IsMod, ForumUser.IsAdmin || ForumUser.IsSuperUser, int.Parse(row["LastAuthorId"].ToString()), auth.Username, auth.FirstName, auth.LastName, auth.DisplayName));
                }

                if (_canEdit)
                {
                    tmp = tmp.Replace("[AF:QUICKEDITLINK]", "<span class=\"af-icon16 af-icon16-gear\" onclick=\"amaf_quickEdit(" + row["TopicId"].ToString() + ");\"></span>");
                }
                else
                {
                    tmp = tmp.Replace("[AF:QUICKEDITLINK]", string.Empty);
                }
                //

                tmp = tmp.Replace("[TOPICSTATE]", cUtils.TopicState(row));
                var sAvatar = UserProfiles.GetAvatar(auth.AuthorId, _mainSettings.AvatarWidth, _mainSettings.AvatarHeight);

                tmp = tmp.Replace("[AF:AVATAR]", sAvatar);
                return(tmp);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void TopicDisplay_Init(object sender, System.EventArgs e)
        {
            SettingsInfo MainSettings = DataCache.MainSettings(ControlConfig.InstanceId);

            PageSize = MainSettings.PageSize;
            string sTemp = string.Empty;

            if ((ControlConfig != null))
            {
                object obj = DataCache.CacheRetrieve(ControlConfig.InstanceId + CurrentView);
                if (obj == null)
                {
                    sTemp = ParseTemplate();
                }
                else
                {
                    sTemp = Convert.ToString(obj);
                }
                if (sTemp.Contains("[NOPAGING]"))
                {
                    RowIndex = 0;
                    PageSize = int.MaxValue;
                    sTemp    = sTemp.Replace("[NOPAGING]", string.Empty);
                }
                sTemp = Utilities.ParseTokenConfig(sTemp, "topic", ControlConfig);

                string          Subject      = string.Empty;
                string          Body         = string.Empty;
                System.DateTime CreateDate   = null;
                System.DateTime EditDate     = null;
                string          Tags         = string.Empty;
                string          AuthorRoles  = string.Empty;
                string          IPAddress    = string.Empty;
                System.DateTime LastPostDate = null;
                string          LastPostData = string.Empty;
                UserProfileInfo tAuthor      = null;
                int             ReplyCount   = 0;
                Data.Topics     tc           = new Data.Topics();
                int             rowCount     = 0;
                int             nextTopic    = 0;
                int             prevTopic    = 0;
                int             statusId     = -1;
                double          topicRating  = 0;
                IDataReader     dr           = tc.TopicForDisplay(ControlConfig.SiteId, ControlConfig.InstanceId, -1, TopicId, UserId, RowIndex, PageSize, "ASC");
                while (dr.Read())
                {
                    ForumId      = int.Parse(dr["ForumId"].ToString());
                    Subject      = dr["Subject"].ToString();
                    Body         = dr["Body"].ToString();
                    CreateDate   = Convert.ToDateTime(dr["DateCreated"].ToString());
                    EditDate     = Convert.ToDateTime(dr["DateUpdated"].ToString());
                    Tags         = dr["Tags"].ToString();
                    IPAddress    = dr["IPAddress"].ToString();
                    LastPostDate = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["LastPostDate"].ToString()), ControlConfig.InstanceId));
                    LastPostData = dr["LastPostData"].ToString();
                    ReplyCount   = int.Parse(dr["ReplyCount"].ToString());
                    nextTopic    = int.Parse(dr["NextTopic"].ToString());
                    prevTopic    = int.Parse(dr["PrevTopic"].ToString());
                    topicRating  = double.Parse(dr["TopicRating"].ToString());
                    UserProfileInfo profile = new UserProfileInfo();
                    var             _with1  = profile;
                    _with1.UserID = int.Parse(dr["AuthorId"].ToString());
                    if (string.IsNullOrEmpty(dr["DisplayName"].ToString()))
                    {
                        _with1.DisplayName = dr["AuthorName"].ToString();
                    }
                    else
                    {
                        _with1.DisplayName = dr["DisplayName"].ToString();
                    }
                    _with1.FirstName        = dr["FirstName"].ToString();
                    _with1.LastName         = dr["LastName"].ToString();
                    _with1.Username         = dr["Username"].ToString();
                    _with1.UserCaption      = dr["UserCaption"].ToString();
                    _with1.AnswerCount      = int.Parse(dr["AnswerCount"].ToString());
                    _with1.AOL              = dr["AOL"].ToString();
                    _with1.Avatar           = dr["Avatar"].ToString();
                    _with1.AvatarType       = (AvatarTypes)int.Parse(dr["AvatarType"].ToString());
                    _with1.DateCreated      = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateCreated"].ToString()), ControlConfig.InstanceId));
                    _with1.DateLastActivity = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastActivity"].ToString()), ControlConfig.InstanceId));
                    _with1.DateLastPost     = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastPost"].ToString()), ControlConfig.InstanceId));
                    if (!string.IsNullOrEmpty(dr["UserDateUpdated"].ToString()))
                    {
                        _with1.DateUpdated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateUpdated"].ToString()), ControlConfig.InstanceId));
                    }
                    _with1.Interests    = dr["Interests"].ToString();
                    _with1.IsUserOnline = bool.Parse(dr["IsUserOnline"].ToString());
                    _with1.Location     = dr["Location"].ToString();
                    _with1.MSN          = dr["MSN"].ToString();
                    _with1.Occupation   = dr["Occupation"].ToString();
                    _with1.TopicCount   = int.Parse(dr["UserTopicCount"].ToString());
                    _with1.ReplyCount   = int.Parse(dr["UserReplyCount"].ToString());
                    _with1.RewardPoints = int.Parse(dr["RewardPoints"].ToString());
                    _with1.Roles        = dr["UserRoles"].ToString();
                    _with1.Signature    = dr["Signature"].ToString();
                    _with1.TrustLevel   = int.Parse(dr["TrustLevel"].ToString());
                    _with1.WebSite      = dr["WebSite"].ToString();
                    _with1.Yahoo        = dr["Yahoo"].ToString();
                    tAuthor             = profile;

                    if (DataPageId == 1)
                    {
                        sTemp     = ParseTopic(sTemp, Subject, CreateDate, Body, Tags, Convert.ToString(EditDate), IPAddress, ForumUser, rowCount);
                        rowCount += 1;
                    }
                    else
                    {
                        sTemp = TemplateUtils.ReplaceSubSection(sTemp, string.Empty, "[TOPIC]", "[/TOPIC]");
                    }
                }
                if (ForumInfo == null)
                {
                    ForumController fc = new ForumController();
                    Forum           fi = null;
                    fi        = fc.Forums_Get(ForumId, UserId, true, true);
                    ForumInfo = fi;
                }
                sTemp = sTemp.Replace("[FORUMID]", ForumId.ToString);
                sTemp = sTemp.Replace("[FORUMNAME]", ForumInfo.ForumName);
                sTemp = sTemp.Replace("[TOPICID]", TopicId.ToString);
                sTemp = sTemp.Replace("[CREATEROLES]", ForumInfo.Security.Create);
                sTemp = sTemp.Replace("[USERROLES]", ForumUser.UserRoles);
                sTemp = sTemp.Replace("[THEMEPATH]", ThemePath);
                sTemp = sTemp.Replace("[SUBJECT]", Subject);
                sTemp = sTemp.Replace("[PAGEID]", PageId.ToString);
                sTemp = sTemp.Replace("[REPLYROLES]", ForumInfo.Security.Reply);
                sTemp = sTemp.Replace("AF:SECURITY:MODROLES]", "AF:SECURITY:MODROLES:" + ForumInfo.Security.ModApprove + "]");
                sTemp = sTemp.Replace("AF:SECURITY:MODAPPROVE]", "AF:SECURITY:MODAPPROVE:" + ForumInfo.Security.ModApprove + "]");
                sTemp = sTemp.Replace("AF:SECURITY:DELETE]", "AF:SECURITY:DELETE:" + ForumInfo.Security.Delete + ForumInfo.Security.ModDelete + "]");
                sTemp = sTemp.Replace("AF:SECURITY:EDIT]", "AF:SECURITY:EDIT:" + ForumInfo.Security.Edit + ForumInfo.Security.ModEdit + "]");
                sTemp = sTemp.Replace("AF:SECURITY:LOCK]", "AF:SECURITY:LOCK:" + ForumInfo.Security.Lock + ForumInfo.Security.ModLock + "]");
                sTemp = sTemp.Replace("AF:SECURITY:MOVE]", "AF:SECURITY:MOVE:" + ForumInfo.Security.ModMove + "]");
                sTemp = sTemp.Replace("AF:SECURITY:PIN]", "AF:SECURITY:PIN:" + ForumInfo.Security.Pin + ForumInfo.Security.ModPin + "]");
                sTemp = sTemp.Replace("AF:SECURITY:SPLIT]", "AF:SECURITY:SPLIT:" + ForumInfo.Security.ModSplit + "]");
                sTemp = sTemp.Replace("AF:SECURITY:REPLY]", "AF:SECURITY:REPLY:" + ForumInfo.Security.Reply + "]");
                if (LastPostDate == null)
                {
                    LastPostDate = CreateDate;
                }
                string LastPostAuthor = string.Empty;
                if (((bRead & tAuthor.UserID == this.UserId)) & statusId >= 0)
                {
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", "<asp:placeholder id=\"plhStatus\" runat=\"server\" />");
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + ThemePath + "status" + statusId.ToString() + ".png\" />");
                }
                else if (statusId >= 0)
                {
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", string.Empty);
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + ThemePath + "status" + statusId.ToString() + ".png\" />");
                }
                else
                {
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", string.Empty);
                    sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", string.Empty);
                    sTemp = sTemp.Replace("[ACTIONS:ANSWER]", string.Empty);
                }
                if (string.IsNullOrEmpty(LastPostData))
                {
                    LastPostAuthor = UserProfiles.GetDisplayName(ControlConfig.InstanceId, MainSettings.ProfileVisibility, false, tAuthor.UserID, MainSettings.UserNameDisplay, MainSettings.DisableUserProfiles, tAuthor.Username, tAuthor.FirstName, tAuthor.LastName, tAuthor.DisplayName);
                }
                else
                {
                    Author la = new Author();
                    System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                    xDoc.LoadXml(LastPostData);
                    System.Xml.XmlNode xNode = xDoc.SelectSingleNode("//root/lastpost");
                    if ((xNode != null))
                    {
                        var _with2 = la;
                        _with2.AuthorId    = int.Parse(xNode["authorid"].InnerText.ToString());
                        _with2.DisplayName = xNode["displayname"].InnerText;
                        _with2.FirstName   = xNode["firstname"].InnerText;
                        _with2.LastName    = xNode["lastname"].InnerText;
                        _with2.Username    = xNode["username"].InnerText;
                    }
                    LastPostAuthor = UserProfiles.GetDisplayName(ControlConfig.InstanceId, MainSettings.ProfileVisibility, false, la.AuthorId, MainSettings.UserNameDisplay, MainSettings.DisableUserProfiles, la.Username, la.FirstName, la.LastName, la.DisplayName);
                }
                //TODO:Fix LastPostDate Format
                sTemp = sTemp.Replace("[AF:LABEL:LastPostDate]", LastPostDate.ToString());
                sTemp = sTemp.Replace("[AF:LABEL:LastPostAuthor]", LastPostAuthor);
                sTemp = sTemp.Replace("[AF:LABEL:ReplyCount]", ReplyCount.ToString());
                string sURL = "<a rel=\"nofollow\" href=\"" + Utilities.NavigateUrl(PageId, "", ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, "mid=" + ControlConfig.InstanceId.ToString, "dnnprintmode=true") + "?skinsrc=" + HttpUtility.UrlEncode("[G]" + DotNetNuke.UI.Skins.SkinInfo.RootSkin + "/" + DotNetNuke.Common.glbHostSkinFolder + "/" + "No Skin") + "&amp;containersrc=" + HttpUtility.UrlEncode("[G]" + DotNetNuke.UI.Skins.SkinInfo.RootContainer + "/" + DotNetNuke.Common.glbHostSkinFolder + "/" + "No Container") + "\" target=\"_blank\">";
                sURL += "<img src=\"" + ThemePath + "images/spacer.gif\" alt=\"[RESX:PrinterFriendly]\" class=\"aficon aficonprint\" /></a>";
                sTemp = sTemp.Replace("[AF:CONTROL:PRINTER]", sURL);
                if (HttpContext.Current.Request.IsAuthenticated)
                {
                    sURL = Utilities.NavigateUrl(PageId, "", new string[] {
                        ParamKeys.ViewType + "=sendto",
                        ParamKeys.ForumId + "=" + ForumId,
                        ParamKeys.TopicId + "=" + TopicId
                    });
                    sTemp = sTemp.Replace("[AF:CONTROL:EMAIL]", "<a href=\"" + sURL + "\" rel=\"nofollow\"><img src=\"" + ThemePath + "images/spacer.gif\" class=\"aficon aficonemail\" alt=\"[RESX:EmailThis]\" /></a>");
                }
                else
                {
                    sTemp = sTemp.Replace("[AF:CONTROL:EMAIL]", string.Empty);
                }
                if (ForumInfo.AllowRSS)
                {
                    string Url = null;
                    Url   = DotNetNuke.Common.AddHTTP(DotNetNuke.Common.GetDomainName(HttpContext.Current.Request)) + "/DesktopModules/ActiveForums/feeds.aspx?portalid=" + ControlConfig.SiteId + "&forumid=" + ForumId + "&tabid=" + PageId + "&moduleid=" + ControlConfig.InstanceId;
                    sTemp = sTemp.Replace("[RSSLINK]", "<a href=\"" + Url + "\"><img src=\"" + ThemePath + "images/rss.png\" runat=server border=\"0\" alt=\"[RESX:RSS]\" /></a>");
                }
                else
                {
                    sTemp = sTemp.Replace("[RSSLINK]", string.Empty);
                }
                if (nextTopic == 0)
                {
                    sTemp = sTemp.Replace("[NEXTTOPICID]", string.Empty);
                    sTemp = sTemp.Replace("[HASNEXTTOPIC]", "False");
                }
                else
                {
                    sTemp = sTemp.Replace("[NEXTTOPICID]", nextTopic.ToString());
                    sTemp = sTemp.Replace("[HASNEXTTOPIC]", "True");
                }
                if (prevTopic == 0)
                {
                    sTemp = sTemp.Replace("[PREVTOPICID]", string.Empty);
                    sTemp = sTemp.Replace("[HASPREVTOPIC]", "False");
                }
                else
                {
                    sTemp = sTemp.Replace("[PREVTOPICID]", prevTopic.ToString());
                    sTemp = sTemp.Replace("[HASPREVTOPIC]", "True");
                }
                dr.NextResult();
                //Process Replies
                StringBuilder sb = new StringBuilder();
                sb.Append(string.Empty);
                int replyId = 0;
                while (dr.Read())
                {
                    Subject    = dr["Subject"].ToString();
                    Body       = dr["Body"].ToString();
                    CreateDate = Convert.ToDateTime(dr["DateCreated"].ToString());
                    EditDate   = Convert.ToDateTime(dr["DateUpdated"].ToString());
                    IPAddress  = dr["IPAddress"].ToString();
                    replyId    = int.Parse(dr["ReplyId"].ToString());
                    UserProfileInfo profile = new UserProfileInfo();
                    var             _with3  = profile;
                    _with3.UserID = int.Parse(dr["AuthorId"].ToString());
                    if (string.IsNullOrEmpty(dr["DisplayName"].ToString()))
                    {
                        _with3.DisplayName = dr["AuthorName"].ToString();
                    }
                    else
                    {
                        _with3.DisplayName = dr["DisplayName"].ToString();
                    }
                    _with3.FirstName        = dr["FirstName"].ToString();
                    _with3.LastName         = dr["LastName"].ToString();
                    _with3.Username         = dr["Username"].ToString();
                    _with3.UserCaption      = dr["UserCaption"].ToString();
                    _with3.AnswerCount      = int.Parse(dr["AnswerCount"].ToString());
                    _with3.AOL              = dr["AOL"].ToString();
                    _with3.Avatar           = dr["Avatar"].ToString();
                    _with3.AvatarType       = (AvatarTypes)int.Parse(dr["AvatarType"].ToString());
                    _with3.DateCreated      = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateCreated"].ToString()), ControlConfig.InstanceId));
                    _with3.DateLastActivity = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastActivity"].ToString()), ControlConfig.InstanceId));
                    if (!string.IsNullOrEmpty(dr["DateLastPost"].ToString()))
                    {
                        _with3.DateLastPost = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastPost"].ToString()), ControlConfig.InstanceId));
                    }

                    if (!string.IsNullOrEmpty(dr["UserDateUpdated"].ToString()))
                    {
                        _with3.DateUpdated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateUpdated"].ToString()), ControlConfig.InstanceId));
                    }
                    _with3.Interests    = dr["Interests"].ToString();
                    _with3.IsUserOnline = bool.Parse(dr["IsUserOnline"].ToString());
                    _with3.Location     = dr["Location"].ToString();
                    _with3.MSN          = dr["MSN"].ToString();
                    _with3.Occupation   = dr["Occupation"].ToString();
                    _with3.TopicCount   = int.Parse(dr["UserTopicCount"].ToString());
                    _with3.ReplyCount   = int.Parse(dr["UserReplyCount"].ToString());
                    _with3.RewardPoints = int.Parse(dr["RewardPoints"].ToString());
                    _with3.Roles        = dr["UserRoles"].ToString();
                    _with3.Signature    = dr["Signature"].ToString();
                    _with3.TrustLevel   = int.Parse(dr["TrustLevel"].ToString());
                    _with3.WebSite      = dr["WebSite"].ToString();
                    _with3.Yahoo        = dr["Yahoo"].ToString();
                    sb.Append(ParseReply(sTemp, replyId, Subject, CreateDate, Body, Convert.ToString(EditDate), IPAddress, ForumUser, rowCount));
                    rowCount += 1;
                }
                dr.Close();
                sTemp = TemplateUtils.ReplaceSubSection(sTemp, sb.ToString(), "[REPLIES]", "[/REPLIES]");
                sTemp = Utilities.LocalizeControl(sTemp);
                sTemp = sTemp.Replace("[TOPICID]", TopicId.ToString);
                sTemp = sTemp.Replace("[GROUPNAME]", ForumInfo.GroupName);
                sTemp = sTemp.Replace("[FORUMNAME]", ForumInfo.ForumName);
                sTemp = sTemp.Replace("[TOPICRATING]", topicRating.ToString());
                sTemp = sTemp.Replace("[CURRENTUSERID]", UserId.ToString);

                sTemp = Utilities.ParseSecurityTokens(sTemp, ForumUser.UserRoles);
                if (!sTemp.Contains(Globals.ControlRegisterAFTag))
                {
                    sTemp = Globals.ControlRegisterAFTag + sTemp;
                }
                Control ctl = Page.ParseControl(sTemp);
                LinkControls(ctl.Controls);
                this.Controls.Add(ctl);
            }
        }
Ejemplo n.º 3
0
        private string ParseForumRow(string Template, Forum fi, int currForumIndex, string ThemePath, int totalForums)
        {
            if (Template.Contains("[SUBFORUMS]") && Template.Contains("[/SUBFORUMS]"))
            {
                Template = GetSubForums(Template, fi.ForumID, ModuleId, TabId, ThemePath);
            }
            else
            {
                Template = Template.Replace("[SUBFORUMS]", GetSubForums(fi.ForumID, ModuleId, TabId));
            }
            string[] css      = null;
            string   cssmatch = string.Empty;

            if (Template.Contains("[CSS:"))
            {
                string pattern = "(\\[CSS:.+?\\])";
                if (Regex.IsMatch(Template, pattern))
                {
                    cssmatch = Regex.Match(Template, pattern).Value;
                    css      = cssmatch.Split(':'); //0=CSS,1=TopRow, 2=mid rows, 3=lastRow
                }
            }
            if (cssmatch != string.Empty)
            {
                if (currForumIndex == 1)
                {
                    Template = Template.Replace(cssmatch, css[1]);
                }
                else if (currForumIndex > 1 & currForumIndex < totalForums)
                {
                    Template = Template.Replace(cssmatch, css[2]);
                }
                else
                {
                    Template = Template.Replace(cssmatch, css[3].Replace("]", string.Empty));
                }
            }

            bool   canView      = Permissions.HasPerm(fi.Security.View, ForumUser.UserRoles);
            bool   canSubscribe = Permissions.HasPerm(fi.Security.Subscribe, ForumUser.UserRoles);
            bool   canRead      = Permissions.HasPerm(fi.Security.Read, ForumUser.UserRoles);
            string sIcon        = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, fi.LastRead, fi.LastPostID);
            string sIconImage   = "<img alt=\"" + fi.ForumName + "\" src=\"" + ThemePath + "images/" + sIcon + "\" />";

            if (Template.Contains("[FORUMICON]"))
            {
                Template = Template.Replace("[FORUMICON]", sIconImage);
            }
            else if (Template.Contains("[FORUMICONCSS]"))
            {
                string sFolderCSS = "fa-folder fa-blue";
                switch (sIcon.ToLower())
                {
                case "folder.png":
                    sFolderCSS = "fa-folder fa-blue";
                    break;

                case "folder_new.png":
                    sFolderCSS = "fa-folder fa-red";
                    break;

                case "folder_forbidden.png":
                    sFolderCSS = "fa-folder fa-grey";
                    break;

                case "folder_closed.png":
                    sFolderCSS = "fa-folder-o fa-grey";
                    break;
                }
                Template = Template.Replace("[FORUMICONCSS]", "<div style=\"height:30px;margin-right:10px;\"><i class=\"fa " + sFolderCSS + " fa-2x\"></i></div>");
            }

            var ctlUtils = new ControlUtils();

            ForumURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, -1, string.Empty, -1, -1, string.Empty, 1, -1, SocialGroupId);

            //ForumURL = GetForumLink(.ForumID, TabId, canView, MainSettings.UseShortUrls, .PrefixURL)
            Template = Template.Replace("[FORUMNAME]", GetForumLink(fi.ForumName, fi.ForumID, TabId, canView, ForumURL));
            Template = Template.Replace("[FORUMNAMENOLINK]", fi.ForumName);
            Template = Template.Replace("[FORUMID]", fi.ForumID.ToString());
            if (Template.Contains("[RSSLINK]"))
            {
                if (fi.AllowRSS && canRead)
                {
                    string Url;
                    Url      = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/DesktopModules/ActiveForums/feeds.aspx?portalid=" + PortalId + "&forumid=" + fi.ForumID + "&tabid=" + TabId + "&moduleid=" + ModuleId;
                    Template = Template.Replace("[RSSLINK]", "<a href=\"" + Url + "\" target=\"_blank\"><img src=\"" + ThemePath + "images/rss.png\" border=\"0\" alt=\"[RESX:RSS]\" /></a>");
                }
                else
                {
                    Template = Template.Replace("[RSSLINK]", "<img src=\"" + ThemePath + "images/rss_disabled.png\" border=\"0\" alt=\"[RESX:RSSDisabled]\" />");
                }
            }

            if (Template.Contains("[AF:CONTROL:TOGGLESUBSCRIBE]"))
            {
                if (canSubscribe)
                {
                    bool   IsSubscribed = Subscriptions.IsSubscribed(PortalId, ModuleId, fi.ForumID, 0, SubscriptionTypes.Instant, CurrentUserId);
                    string sAlt         = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]";
                    string sImg         = ThemePath + "images/email_unchecked.png";
                    if (IsSubscribed)
                    {
                        sImg = ThemePath + "images/email_checked.png";
                    }
                    var subControl = new ToggleSubscribe(0, fi.ForumID, -1);
                    subControl.Checked     = IsSubscribed;
                    subControl.DisplayMode = 1;
                    subControl.UserId      = CurrentUserId;
                    subControl.ImageURL    = sImg;
                    subControl.Text        = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]";
                    string subOption = subControl.Render();

                    //Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", "<a href=""javascript:af_toggleSubscribe(" & .ForumID & ",'" & PortalId & "|" & ModuleId & "|" & .ForumID & "|" & CurrentUserId & "');""><img id=""toggleSub" & .ForumID & """ src=""" & sImg & """ border=""0"" alt=""" & sAlt & """ /></a>")
                    Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", subOption);
                }
                else
                {
                    Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", "<img src=\"" + ThemePath + "email_disabled.png\" border=\"0\" alt=\"[RESX:ForumSubscribe:Disabled]\" />");
                }
            }

            Template = canRead ? Template.Replace("[AF:CONTROL:ADDFAVORITE]", "<a href=\"javascript:afAddBookmark('" + fi.ForumName + "','" + ForumURL + "');\"><img src=\"" + ThemePath + "images/favorites16_add.png\" border=\"0\" alt=\"[RESX:AddToFavorites]\" /></a>") : Template.Replace("[AF:CONTROL:ADDFAVORITE]", string.Empty);
            if (Template.Contains("[AF:CONTROL:ADDTHIS"))
            {
                Template = TemplateUtils.ParseSpecial(Template, SpecialTokenTypes.AddThis, ForumURL, fi.ForumName, canRead, MainSettings.AddThisAccount);
            }

            if (fi.ForumDesc != "")
            {
                Template = Template.Replace("[FORUMDESCRIPTION]", "<i class=\"fa fa-file-o fa-grey\"></i>&nbsp;" + fi.ForumDesc);
            }
            else
            {
                Template = Template.Replace("[FORUMDESCRIPTION]", "");
            }

            Template = Template.Replace("[TOTALTOPICS]", fi.TotalTopics.ToString());
            Template = Template.Replace("[TOTALREPLIES]", fi.TotalReplies.ToString());
            //Last Post Section
            int intLength = 0;

            if ((Template.IndexOf("[LASTPOSTSUBJECT:", 0) + 1) > 0)
            {
                int    inStart = (Template.IndexOf("[LASTPOSTSUBJECT:", 0) + 1) + 17;
                int    inEnd   = (Template.IndexOf("]", inStart - 1) + 1);
                string sLength = Template.Substring(inStart - 1, inEnd - inStart);
                intLength = Convert.ToInt32(sLength);
            }
            string ReplaceTag = "[LASTPOSTSUBJECT:" + intLength.ToString() + "]";

            if (fi.LastPostID == 0)
            {
                Template = Template.Replace("[RESX:BY]", string.Empty);
                Template = Template.Replace("[DISPLAYNAME]", string.Empty);
                Template = Template.Replace("[LASTPOSTDATE]", string.Empty);
                Template = Template.Replace(ReplaceTag, string.Empty);
                //Template = TemplateUtils.ParseUserDetails(PortalId, -1, Template, String.Empty)
            }
            else
            {
                if (canView)
                {
                    if (fi.LastPostUserID <= 0)
                    {
                        //Template = Template.Replace("[RESX:BY]", String.Empty)
                        Template = Template.Replace("[DISPLAYNAME]", "<i class=\"fa fa-user fa-fw fa-blue\"></i>&nbsp;" + fi.LastPostDisplayName);
                        //Template = TemplateUtils.ParseUserDetails(PortalId, -1, Template, "FG")
                    }
                    else
                    {
                        bool isMod   = CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.ForumMod || CurrentUserType == CurrentUserTypes.SuperUser;
                        bool isAdmin = CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser;
                        Template = Template.Replace("[DISPLAYNAME]", "<i class=\"fa fa-user fa-fw fa-blue\"></i>&nbsp;" + UserProfiles.GetDisplayName(ModuleId, true, isMod, isAdmin, fi.LastPostUserID, fi.LastPostUserName, fi.LastPostFirstName, fi.LastPostLastName, fi.LastPostDisplayName));
                        //Template = TemplateUtils.ParseUserDetails(PortalId, .LastPostUserID, Template, "FG")
                    }
                    DateTime dtLastPostDate = fi.LastPostDateTime;
                    Template = Template.Replace("[LASTPOSTDATE]", Utilities.GetDate(dtLastPostDate, ModuleId, TimeZoneOffset));
                    string Subject = fi.LastPostSubject;
                    if (Subject == "")
                    {
                        Subject = GetSharedResource("[RESX:SubjectPrefix]") + " " + fi.TopicSubject;
                    }
                    if (Subject != string.Empty)
                    {
                        string sDots = "";
                        if (Subject.Length > intLength)
                        {
                            sDots = "...";
                        }

                        Template = Template.Replace(ReplaceTag, GetLastPostSubject(fi.LastPostID, fi.TopicId, fi.ForumID, TabId, Subject, intLength, MainSettings.PageSize, fi));
                    }
                    else
                    {
                        Template = Template.Replace("[RESX:BY]", string.Empty);
                        Template = Template.Replace(ReplaceTag, string.Empty);
                    }
                }
                else
                {
                    Template = Template.Replace("[DISPLAYNAME]", string.Empty);
                    Template = Template.Replace("[LASTPOSTDATE]", string.Empty);
                    Template = Template.Replace("[RESX:BY]", string.Empty);
                    Template = Template.Replace(ReplaceTag, string.Empty);
                }
            }

            return(Template);
        }
Ejemplo n.º 4
0
        private string ParseTemplate()
        {
            SettingsInfo MainSettings = DataCache.MainSettings(ControlConfig.InstanceId);
            string       sOut         = DisplayTemplate;
            //sOut = ParseForumData(sOut)
            string sort = SortColumns.ReplyCreated;

            if (sOut.Contains("[AF:SORT:TOPICCREATED]"))
            {
                sort = SortColumns.TopicCreated;
                sOut = sOut.Replace("[AF:SORT:TOPICCREATED]", string.Empty);
            }
            int    Replies           = 0;
            int    Views             = 0;
            string Subject           = string.Empty;
            string summary           = string.Empty;
            string body              = string.Empty;
            int    replyCount        = 0;
            int    viewCount         = 0;
            int    topicid           = 0;
            string topicIcon         = string.Empty;
            int    UserLastTopicRead = 0;
            int    UserLastReplyRead = 0;
            int    topicRating       = 0;
            int    LastReplyId       = 0;
            bool   isLocked          = false;
            bool   isPinned          = false;
            int    AuthorId          = -1;
            string AuthorName        = string.Empty;
            string AuthorFirstName   = string.Empty;
            string AuthorLastName    = string.Empty;
            string AuthorUserName    = string.Empty;
            string AuthorDisplayName = string.Empty;
            string LastPostData      = string.Empty;

            System.DateTime LastPostDate = default(System.DateTime);
            System.DateTime DateCreated  = default(System.DateTime);
            string          sTopicURL    = string.Empty;
            string          sBodyTitle   = string.Empty;
            int             statusId     = -1;
            bool            isAnnounce   = false;

            System.DateTime AnnounceStart = default(System.DateTime);
            System.DateTime AnnounceEnd   = default(System.DateTime);
            int             topicType     = 0;
            Author          la            = null;
            string          ModApprove    = string.Empty;
            string          ModDelete     = string.Empty;
            string          ModEdit       = string.Empty;
            string          ModPin        = string.Empty;
            string          ModLock       = string.Empty;
            string          ModMove       = string.Empty;
            string          ModSplit      = string.Empty;
            string          Reply         = string.Empty;
            string          Lock          = string.Empty;
            string          Pin           = string.Empty;
            string          Delete        = string.Empty;
            string          Edit          = string.Empty;
            string          groupName     = string.Empty;
            //Dim t As New Data.Topics
            string topics = TemplateUtils.GetTemplateSection(sOut, "[TOPICS]", "[/TOPICS]");

            System.Text.StringBuilder sb      = new System.Text.StringBuilder();
            System.Xml.XmlNodeList    xTopics = null;

            xTopics = topicsData.SelectNodes("//topics/topic");
            int rowCount = 0;

            foreach (System.Xml.XmlNode xNode in xTopics)
            {
                string ForumName = string.Empty;

                ForumId   = int.Parse(xNode.Attributes["forumid"].Value.ToString());
                ForumName = xNode["forumname"].InnerText;
                groupName = xNode["groupname"].InnerText;

                topicid       = int.Parse(xNode.Attributes["topicid"].Value.ToString());
                LastReplyId   = int.Parse(xNode.Attributes["lastreplyid"].Value.ToString());
                viewCount     = int.Parse(xNode.Attributes["viewcount"].Value.ToString());
                replyCount    = int.Parse(xNode.Attributes["replycount"].Value.ToString());
                isLocked      = bool.Parse(xNode.Attributes["islocked"].Value.ToString());
                isPinned      = bool.Parse(xNode.Attributes["ispinned"].Value.ToString());
                topicIcon     = xNode.Attributes["topicicon"].Value.ToString();
                statusId      = int.Parse(xNode.Attributes["statusid"].Value.ToString());
                isAnnounce    = bool.Parse(xNode.Attributes["isannounce"].Value.ToString());
                AnnounceStart = Convert.ToDateTime(xNode.Attributes["announcestart"].Value.ToString());
                AnnounceEnd   = Convert.ToDateTime(xNode.Attributes["announceend"].Value.ToString());
                topicType     = int.Parse(xNode.Attributes["topictype"].Value.ToString());
                AuthorId      = int.Parse(xNode.Attributes["authorid"].Value.ToString());
                DateCreated   = Convert.ToDateTime(xNode.Attributes["datecreated"].Value.ToString());
                if (!string.IsNullOrEmpty(xNode.Attributes["lastpostdate"].Value.ToString()))
                {
                    LastPostDate = Convert.ToDateTime(xNode.Attributes["lastpostdate"].Value.ToString());
                }
                else
                {
                    LastPostDate = DateCreated;
                }
                UserLastReplyRead = int.Parse(xNode.Attributes["userlastreplyread"].Value.ToString());
                UserLastTopicRead = int.Parse(xNode.Attributes["userlasttopicread"].Value.ToString());
                topicRating       = int.Parse(xNode.Attributes["topicrating"].Value.ToString());
                Subject           = xNode["subject"].InnerText;
                Subject           = Utilities.StripHTMLTag(Subject);
                Subject           = Subject.Replace("&#91;", "[");
                Subject           = Subject.Replace("&#93;", "]");
                summary           = xNode["summary"].InnerText;
                body              = xNode["body"].InnerText;
                AuthorName        = xNode["authorname"].InnerText;
                AuthorUserName    = xNode["username"].InnerText;
                AuthorFirstName   = xNode["firstname"].InnerText;
                AuthorLastName    = xNode["lastname"].InnerText;
                AuthorDisplayName = xNode["displayname"].InnerText;
                XmlNode secNode = xNode["security"];
                ModApprove = secNode["modapprove"].InnerText;
                ModDelete  = secNode["moddelete"].InnerText;
                ModEdit    = secNode["modedit"].InnerText;
                ModPin     = secNode["modpin"].InnerText;
                ModLock    = secNode["modlock"].InnerText;
                ModMove    = secNode["modmove"].InnerText;
                Reply      = secNode["reply"].InnerText;
                Lock       = secNode["lock"].InnerText;
                Pin        = secNode["pin"].InnerText;
                Delete     = secNode["delete"].InnerText;
                Edit       = secNode["edit"].InnerText;
                if ((xNode["lastpost"] != null))
                {
                    LastPostData = xNode["lastpost"].OuterXml;
                }
                else
                {
                    LastPostData = string.Empty;
                }

                if (!string.IsNullOrEmpty(LastPostData))
                {
                    la = new Author();
                    System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                    xDoc.LoadXml(LastPostData);
                    System.Xml.XmlNode xLast = xDoc.SelectSingleNode("//lastpost");
                    if ((xLast != null))
                    {
                        var _with1 = la;
                        _with1.AuthorId    = int.Parse(xLast["authorid"].InnerText.ToString());
                        _with1.DisplayName = xLast["displayname"].InnerText;
                        _with1.FirstName   = xLast["firstname"].InnerText;
                        _with1.LastName    = xLast["lastname"].InnerText;
                        _with1.Username    = xLast["username"].InnerText;
                    }
                }
                int    BodyLength = -1;
                string BodyTrim   = "";
                sTopicURL = URL.ForTopic(TabId, PortalId, ForumId, topicid, groupName, ForumName, Subject, 1);
                string tmp       = topics;
                string sLastPost = TemplateUtils.GetTemplateSection(tmp, "[LASTPOST]", "[/LASTPOST]");
                if ((la != null))
                {
                    sLastPost = sLastPost.Replace("[LASTPOSTDISPLAYNAME]", UserProfiles.GetDisplayName(ModuleId, ProfileVisibility, false, la.AuthorId, UserNameDisplay, DisableUserProfiles, la));
                    sLastPost = sLastPost.Replace("[AF:PROFILE:AVATAR]", UserProfiles.GetAvatar(la.AuthorId, PortalId, ThemePath, MainSettings.Theme, string.Empty, 0, MainSettings.AvatarWidth, MainSettings.ProfileType, MainSettings.AvatarDefault));

                    sLastPost = sLastPost.Replace("[LASTPOSTDATE]", Utilities.GetDate(LastPostDate, ModuleId));
                    if (bRead)
                    {
                        //TODO: Replace with link
                        sLastPost = sLastPost.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty);
                    }
                    else
                    {
                        sLastPost = sLastPost.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty);
                    }
                    tmp = TemplateUtils.ReplaceSubSection(tmp, sLastPost, "[LASTPOST]", "[/LASTPOST]");
                }
                else
                {
                    tmp = TemplateUtils.ReplaceSubSection(tmp, string.Empty, "[LASTPOST]", "[/LASTPOST]");
                }

                //Dim sLastReplyURL As String = NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & topicid, ParamKeys.ViewType & "=topic", ParamKeys.ContentJumpId & "=" & LastReplyId})
                string sLastReadURL = string.Empty;
                string sUserJumpUrl = string.Empty;
                //If UserLastReplyRead > 0 Then
                //sLastReadURL = NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & topicid, ParamKeys.ViewType & "=topic", ParamKeys.FirstNewPost & "=" & UserLastReplyRead})
                //End If

                //If UserPrefJumpLastPost And sLastReadURL <> String.Empty Then
                //    '   sTopicURL = sLastReadURL
                //    sUserJumpUrl = sLastReadURL
                //End If
                if (tmp.Contains("[BODY:"))
                {
                    int    inStart = Strings.InStr(tmp, "[BODY:") + 5;
                    int    inEnd   = Strings.InStr(inStart, tmp, "]") - 1;
                    string sLength = tmp.Substring(inStart, inEnd - inStart);
                    BodyLength = Convert.ToInt32(sLength);
                    BodyTrim   = "[BODY:" + BodyLength.ToString() + "]";
                }
                if (!(BodyTrim == string.Empty))
                {
                    string BodyPlain = body.Replace("<br>", Constants.vbCrLf);
                    BodyPlain = BodyPlain.Replace("<br />", Constants.vbCrLf);
                    BodyPlain = Utilities.StripHTMLTag(BodyPlain);
                    if (BodyLength > 0 & BodyPlain.Length > BodyLength)
                    {
                        BodyPlain = BodyPlain.Substring(0, BodyLength);
                    }
                    BodyPlain = BodyPlain.Replace(Constants.vbCrLf, "<br />");
                    tmp       = tmp.Replace(BodyTrim, BodyPlain);
                }
                if (isLocked)
                {
                    tmp = tmp.Replace("[RESX:LockTopic]", "[RESX:UnLockTopic]");
                    tmp = tmp.Replace("[RESX:Confirm:Lock]", "[RESX:Confirm:UnLock]");
                }
                if (isPinned)
                {
                    tmp = tmp.Replace("[RESX:PinTopic]", "[RESX:UnPinTopic]");
                    tmp = tmp.Replace("[RESX:Confirm:Pin]", "[RESX:Confirm:UnPin]");
                }
                tmp = tmp.Replace("[BODY]", GetBody(body, AuthorId));
                tmp = tmp.Replace("[BODYTITLE]", GetTitle(body, AuthorId));
                tmp = tmp.Replace("[AUTHORID]", AuthorId.ToString());
                tmp = tmp.Replace("[USERID]", UserId.ToString);
                if (string.IsNullOrEmpty(Subject))
                {
                    Subject = "(no subject)";
                }
                string LastSubject = Subject;
                if (LastReplyId > 0)
                {
                    LastSubject = "[RESX:RE]" + LastSubject;
                }

                tmp = tmp.Replace("[SUBJECT]", Subject);
                string sSubjectLink    = GetTopic(topicid, Subject, sBodyTitle, UserId, AuthorId, replyCount, -1, sUserJumpUrl, groupName, ForumName);
                string lastSubjectLink = GetTopic(topicid, Subject, string.Empty, UserId, AuthorId, replyCount, -1, sUserJumpUrl, groupName, ForumName);
                tmp = tmp.Replace("[SUBJECTLINK]", sSubjectLink);
                tmp = tmp.Replace("[THEMEPATH]", ThemePath);
                tmp = tmp.Replace("[TOPICID]", topicid.ToString());
                tmp = tmp.Replace("[MODEDIT]", string.Empty);
                tmp = tmp.Replace("[MODDELETE]", string.Empty);
                tmp = tmp.Replace("[MODMOVE]", string.Empty);
                tmp = tmp.Replace("[MODLOCK]", string.Empty);
                tmp = tmp.Replace("[MODPIN]", string.Empty);
                tmp = tmp.Replace("[REPLIES]", replyCount.ToString());
                tmp = tmp.Replace("[VIEWS]", viewCount.ToString());
                tmp = tmp.Replace("[POSTICONIMAGE]", GetIcon(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, topicIcon, isPinned, isLocked));

                tmp = tmp.Replace("[POSTICONCSS]", GetIconCSS(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, topicIcon, isPinned, isLocked));
                if (tmp.Contains("[STATUSCSS]"))
                {
                    string sImg = string.Empty;
                    if (statusId == -1)
                    {
                        tmp = tmp.Replace("[STATUSCSS]", string.Empty);
                    }
                    else
                    {
                        sImg = "<span title=\"[RESX:PostStatus" + statusId.ToString() + "]\" class=\"afstatus afstatus" + statusId.ToString() + "\"></span>";
                    }
                    tmp = tmp.Replace("[STATUSCSS]", sImg);
                }
                tmp = tmp.Replace("[STARTEDBY]", UserProfiles.GetDisplayName(ModuleId, ProfileVisibility, false, AuthorId, UserNameDisplay, DisableUserProfiles, AuthorUserName, AuthorFirstName, AuthorLastName, AuthorDisplayName));
                tmp = tmp.Replace("[DATECREATED]", Utilities.GetDate(DateCreated, ModuleId));
                tmp = tmp.Replace("[TOPICURL]", sTopicURL);
                //TODO: Still need to process
                tmp = tmp.Replace("[AF:ICONLINK:LASTREAD]", string.Empty);
                tmp = tmp.Replace("[AF:URL:LASTREAD]", string.Empty);
                if (tmp.Contains("[STATUS]"))
                {
                    string sImg = string.Empty;
                    if (statusId == -1)
                    {
                        tmp = tmp.Replace("[STATUS]", string.Empty);
                    }
                    else
                    {
                        sImg = "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + Utilities.AppPath + "themes/images/status" + statusId.ToString() + ".png\" />";
                    }
                    tmp = tmp.Replace("[STATUS]", sImg);
                }


                //sTopicsTemplate = sTopicsTemplate.Replace("[AF:UI:MINIPAGER]", GetSubPages(TabId, ModuleId, ReplyCount, ForumId, TopicId))
                tmp = tmp.Replace("[AF:UI:MINIPAGER]", string.Empty);
                tmp = tmp.Replace("[POSTRATINGDISPLAY]", string.Empty);
                tmp = tmp.Replace("[TOPICRATING]", topicRating.ToString());
                tmp = tmp.Replace("[ROWCSS]", GetRowCSS(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, rowCount));

                tmp = tmp.Replace("[AF:TOPIC:FRIENDLYDATE]", Utilities.HumanFriendlyDate(DateCreated, ModuleId));
                tmp = tmp.Replace("[AF:REPLY:FRIENDLYDATE]", Utilities.HumanFriendlyDate(LastPostDate, ModuleId));
                tmp = tmp.Replace("[AF:TOPIC:FORUMNAME]", ForumName);
                tmp = tmp.Replace("[AF:TOPIC:LASTSUBJECT:LINK]", lastSubjectLink);
                tmp = tmp.Replace("[AF:TOPIC:LASTSUBJECT]", LastSubject);
                tmp = tmp.Replace("[AF:TOPIC:FORUMNAME:LINK]", "<a href=\"" + URL.ForForum(PageId, ForumId, groupName[ForumId], ForumName) + "\" title=\"" + ForumName + "\">" + ForumName + "</a>");
                tmp = tmp.Replace("AF:SECURITY:MODROLES]", "AF:SECURITY:MODROLES:" + ModApprove + "]");
                tmp = tmp.Replace("AF:SECURITY:MODAPPROVE]", "AF:SECURITY:MODAPPROVE:" + ModApprove + "]");
                tmp = tmp.Replace("AF:SECURITY:DELETE]", "AF:SECURITY:DELETE:" + Delete + ModDelete + "]");
                tmp = tmp.Replace("AF:SECURITY:EDIT]", "AF:SECURITY:EDIT:" + Edit + ModEdit + "]");
                tmp = tmp.Replace("AF:SECURITY:LOCK]", "AF:SECURITY:LOCK:" + Lock + ModLock + "]");
                tmp = tmp.Replace("AF:SECURITY:MOVE]", "AF:SECURITY:MOVE:" + ModMove + "]");
                tmp = tmp.Replace("AF:SECURITY:PIN]", "AF:SECURITY:PIN:" + Pin + ModPin + "]");
                tmp = tmp.Replace("AF:SECURITY:SPLIT]", "AF:SECURITY:SPLIT:" + ModSplit + "]");
                tmp = tmp.Replace("AF:SECURITY:REPLY]", "AF:SECURITY:REPLY:" + Reply + "]");

                sb.Append(tmp);
                rowCount += 1;
            }

            sOut = TemplateUtils.ReplaceSubSection(sOut, sb.ToString(), "[TOPICS]", "[/TOPICS]");
            sOut = sOut.Replace("[TOPICS]", string.Empty);
            sOut = sOut.Replace("[/TOPICS]", string.Empty);

            DataCache.CacheStore(ModuleId + "topicsview", sOut);
            return(sOut);
        }