Esempio n. 1
0
        protected void LatestPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            // populate the controls here...
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView currentRow = ( DataRowView )e.Item.DataItem;
                // make message url...
                string messageUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.posts, "m={0}#post{0}", currentRow ["LastMessageID"]);
                // get the controls
                HyperLink  textMessageLink     = (HyperLink)e.Item.FindControl("TextMessageLink");
                HyperLink  imageMessageLink    = (HyperLink)e.Item.FindControl("ImageMessageLink");
                ThemeImage lastPostedImage     = (ThemeImage)e.Item.FindControl("LastPostedImage");
                UserLink   lastUserLink        = ( UserLink )e.Item.FindControl("LastUserLink");
                Label      lastPostedDateLabel = ( Label )e.Item.FindControl("LastPostedDateLabel");
                HyperLink  forumLink           = ( HyperLink )e.Item.FindControl("ForumLink");

                // populate them...
                textMessageLink.Text         = YAF.Classes.Utils.General.BadWordReplace(currentRow["Topic"].ToString());
                textMessageLink.NavigateUrl  = messageUrl;
                imageMessageLink.NavigateUrl = messageUrl;
                // Just in case...
                if (currentRow ["LastUserID"] != DBNull.Value)
                {
                    lastUserLink.UserID   = Convert.ToInt32(currentRow ["LastUserID"]);
                    lastUserLink.UserName = currentRow ["LastUserName"].ToString();
                }
                if (currentRow ["LastPosted"] != DBNull.Value)
                {
                    lastPostedDateLabel.Text = YafDateTime.FormatDateTimeTopic(currentRow ["LastPosted"]);
                    lastPostedImage.ThemeTag = (DateTime.Parse(currentRow ["LastPosted"].ToString()) > YAF.Classes.Utils.Mession.GetTopicRead(Convert.ToInt32(currentRow ["TopicID"]))) ? "ICON_NEWEST" : "ICON_LATEST";
                }
                forumLink.Text        = currentRow["Forum"].ToString();
                forumLink.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.topics, "f={0}", currentRow ["ForumID"]);
            }
        }
        void ForumLastPost_PreRender(object sender, EventArgs e)
        {
            if (DataRow != null)
            {
                if (int.Parse(DataRow ["ReadAccess"].ToString()) == 0)
                {
                    TopicInPlaceHolder.Visible = false;
                }

                if (DataRow ["LastPosted"] != DBNull.Value)
                {
                    LastPosted.Text          = YafDateTime.FormatDateTimeTopic(DataRow ["LastPosted"]);
                    topicLink.NavigateUrl    = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.posts, "t={0}", DataRow ["LastTopicID"]);
                    topicLink.Text           = General.Truncate(General.BadWordReplace(DataRow ["LastTopicName"].ToString()), 50);
                    ProfileUserLink.UserID   = Convert.ToInt32(DataRow ["LastUserID"]);
                    ProfileUserLink.UserName = DataRow ["LastUser"].ToString();

                    LastTopicImgLink.ToolTip     = PageContext.Localization.GetText("GO_LAST_POST");
                    LastTopicImgLink.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.posts, "m={0}#post{0}", DataRow ["LastMessageID"]);
                    Icon.ThemeTag = (DateTime.Parse(Convert.ToString(DataRow ["LastPosted"])) > Mession.GetTopicRead(( int )DataRow ["LastTopicID"])) ? "ICON_NEWEST" : "ICON_LATEST";

                    LastPostedHolder.Visible = true;
                    NoPostsLabel.Visible     = false;
                }
                else
                {
                    // show "no posts"
                    LastPostedHolder.Visible = false;
                    NoPostsLabel.Visible     = true;
                }
            }
        }
        protected void BindData()
        {
            // Active users
            // Call this before forum_stats to clean up active users
            ActiveUsers1.ActiveUserTable = YAF.Classes.Data.DB.active_list(PageContext.PageBoardID, null);

            // "Active Users" Count and Most Users Count
            DataRow activeStats = YAF.Classes.Data.DB.active_stats(PageContext.PageBoardID);

            ActiveUserCount.Text = FormatActiveUsers(activeStats);

            // Forum Statistics
            string  key = YafCache.GetBoardCacheKey(Constants.Cache.BoardStats);
            DataRow statisticsDataRow = ( DataRow )Cache [key];

            if (statisticsDataRow == null)
            {
                statisticsDataRow = YAF.Classes.Data.DB.board_poststats(PageContext.PageBoardID);
                Cache.Insert(key, statisticsDataRow, null, DateTime.Now.AddMinutes(PageContext.BoardSettings.ForumStatisticsCacheTimeout), TimeSpan.Zero);
            }

            // show max users...
            if (!statisticsDataRow.IsNull("MaxUsers"))
            {
                MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), statisticsDataRow ["MaxUsers"], YafDateTime.FormatDateTimeTopic(statisticsDataRow ["MaxUsersWhen"]));
            }
            else
            {
                MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), activeStats ["ActiveUsers"], YafDateTime.FormatDateTimeTopic(DateTime.Now));
            }

            // Posts and Topic Count...
            StatsPostsTopicCount.Text = String.Format(PageContext.Localization.GetText("stats_posts"), statisticsDataRow ["posts"], statisticsDataRow ["topics"], statisticsDataRow ["forums"]);

            // Last post
            if (!statisticsDataRow.IsNull("LastPost"))
            {
                StatsLastPostHolder.Visible = true;

                LastPostUserLink.UserID   = Convert.ToInt32(statisticsDataRow ["LastUserID"]);
                LastPostUserLink.UserName = statisticsDataRow ["LastUser"].ToString();

                StatsLastPost.Text = String.Format(PageContext.Localization.GetText("stats_lastpost"), YafDateTime.FormatDateTimeTopic(( DateTime )statisticsDataRow ["LastPost"]));
            }
            else
            {
                StatsLastPostHolder.Visible = false;
            }

            // Member Count
            StatsMembersCount.Text = String.Format(PageContext.Localization.GetText("stats_members"), statisticsDataRow ["members"]);

            // Newest Member
            StatsNewestMember.Text        = PageContext.Localization.GetText("stats_lastmember");
            NewestMemberUserLink.UserID   = Convert.ToInt32(statisticsDataRow ["LastMemberID"]);
            NewestMemberUserLink.UserName = statisticsDataRow ["LastMember"].ToString();
        }