Exemplo n.º 1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // Check and see if it should make panels enable or not
            this.PanelReindex.Visible      = LegacyDb.PanelReindex;
            this.PanelShrink.Visible       = LegacyDb.PanelShrink;
            this.PanelRecoveryMode.Visible = LegacyDb.PanelRecoveryMode;
            this.PanelGetStats.Visible     = LegacyDb.PanelGetStats;

            this.Shrink.ReturnConfirmText       = this.GetText("ADMIN_REINDEX", "CONFIRM_SHRINK");
            this.Reindex.ReturnConfirmText      = this.GetText("ADMIN_REINDEX", "CONFIRM_REINDEX");
            this.RecoveryMode.ReturnConfirmText = this.GetText("ADMIN_REINDEX", "CONFIRM_RECOVERY");

            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY1")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY2")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY3")));

            this.RadioButtonList1.SelectedIndex = 0;

            this.BindData();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all jQuery-UI Themes
        /// </summary>
        /// <returns>
        /// Returns a Data Table with all jQuery-UI Themes
        /// </returns>
        public static DataTable JqueryUIThemes()
        {
            using (var dt = new DataTable("JqueryUIThemes"))
            {
                dt.Columns.Add("Theme", typeof(string));

                var themeDir = new DirectoryInfo(HttpContext.Current.Request.MapPath(YafForumInfo.GetURLToContent("themes")));

                foreach (DirectoryInfo dir in themeDir.GetDirectories())
                {
                    try
                    {
                        DataRow dr = dt.NewRow();
                        dr["Theme"] = dir.Name;

                        dt.Rows.Add(dr);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                return(dt);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The On PreRender event.
        /// </summary>
        /// <param name="e">
        /// the Event Arguments
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this.LoadingImage.ImageUrl      = YafForumInfo.GetURLToContent("images/loader.gif");
            this.LoadingImage.AlternateText = this.Get <ILocalization>().GetText("COMMON", "LOADING");
            this.LoadingImage.ToolTip       = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            base.OnPreRender(e);
        }
Exemplo n.º 4
0
        /// <summary>
        /// The on pre render.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this._okayButton.Text = this.GetText("COMMON", "OK");

            // add js for client-side error settings...
            string jsFunction;

            if (this.Get <YafBoardSettings>().MessageNotificationSystem.Equals(0))
            {
                // Show as Modal Dialog
                jsFunction =
                    @"function {2}(newErrorStr, newErrorType) {{  if (newErrorStr != null && newErrorStr != """" && {4}('#{1}') != null) {{
                     {4}('#{1}').html(newErrorStr);
                     {4}().YafModalDialog.Show({{Dialog : '#{0}',ImagePath : '{3}', Type : newErrorType}});
                }} }}"
                    .FormatWith(
                        this.ClientID,
                        this.MainTextClientID,
                        this.ShowModalFunction,
                        YafForumInfo.GetURLToContent("images/"),
                        Config.JQueryAlias);
            }
            else
            {
                // Show as Notification Bar
                jsFunction =
                    @"function {2}(newErrorStr, newErrorType) {{ if (newErrorStr != null && newErrorStr != """") {{
                      showNotification({{
                            type : newErrorType,
                            message: newErrorStr,
                            autoClose: true,
                            duration: {4},
                            imagepath : '{3}'
                        }});}} }}"
                    .FormatWith(
                        this.ClientID,
                        this.MainTextClientID,
                        this.ShowModalFunction,
                        YafForumInfo.GetURLToContent("icons/"),
                        this.Get <YafBoardSettings>().MessageNotifcationDuration,
                        Config.JQueryAlias);
            }

            // Override Notification Setting if Mobile Device is used
            if (this.Get <YafBoardSettings>().NotifcationNativeOnMobile&& this.Get <HttpRequestBase>().Browser.IsMobileDevice)
            {
                // Show as Modal Dialog
                jsFunction =
                    @"function {2}(newErrorStr) {{  if (newErrorStr != null && newErrorStr != """") {{ 
                                                    alert(newErrorStr);
                      }} }}"
                    .FormatWith(this.ClientID, this.MainTextClientID, this.ShowModalFunction);
            }

            YafContext.Current.PageElements.RegisterJsBlock(this, this.ShowModalFunction, jsFunction);

            base.OnPreRender(e);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // Check and see if it should make panels enable or not
            this.PanelReindex.Visible      = LegacyDb.PanelReindex;
            this.PanelShrink.Visible       = LegacyDb.PanelShrink;
            this.PanelRecoveryMode.Visible = LegacyDb.PanelRecoveryMode;
            this.PanelGetStats.Visible     = LegacyDb.PanelGetStats;

            // Get the name of buttons
            this.btnReindex.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "REINDEXTBL_BTN"));
            this.btnGetStats.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "TBLINDEXSTATS_BTN"));
            this.btnShrink.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "SHRINK_BTN"));
            this.btnRecoveryMode.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "SETRECOVERY_BTN"));

            this.btnShrink.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_SHRINK"));

            this.btnReindex.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_REINDEX"));

            this.btnRecoveryMode.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_RECOVERY"));

            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"),
                YafBuildLink.GetLink(ForumPages.admin_admin));
            this.PageLinks.AddLink(this.GetText("ADMIN_REINDEX", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("ADMIN_REINDEX", "TITLE"));

            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY1")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY2")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY3")));

            this.RadioButtonList1.SelectedIndex = 0;

            this.BindData();
        }
Exemplo n.º 6
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            if (Config.IsAnyPortal)
            {
                this.ImportUsers.Visible = false;
                this.SyncUsers.Visible   = false;
            }

            // intialize since filter items
            this.InitSinceDropdown();

            // set since filter to last item "All time"
            this.Since.SelectedIndex   = this.Since.Items.Count - 1;
            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // get list of user groups for filtering
            var groups = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID);

            groups.Insert(0, new Group {
                Name = this.GetText("FILTER_NO"), ID = 0
            });

            this.group.DataTextField  = "Name";
            this.group.DataValueField = "ID";

            this.group.DataBind();

            // get list of user ranks for filtering
            using (var dt = LegacyDb.rank_list(this.PageContext.PageBoardID, null))
            {
                // add empty for for no filtering
                var newRow = dt.NewRow();
                newRow["Name"]   = this.GetText("FILTER_NO");
                newRow["RankID"] = 0;
                dt.Rows.InsertAt(newRow, 0);

                this.rank.DataSource     = dt;
                this.rank.DataTextField  = "Name";
                this.rank.DataValueField = "RankID";
                this.rank.DataBind();
            }

            // TODO : page size difinable?
            this.PagerTop.PageSize = 25;

            // Hide "New User" & Sync Button on DotNetNuke
            this.ImportAndSyncHolder.Visible = !Config.IsDotNetNuke;

            this.BindData();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.BindData();

                if (this.Request.QueryString.GetFirstOrDefault("r") != null)
                {
                    var rankId = this.Request.QueryString.GetFirstOrDefaultAs <int>("r");


                    var rank = this.GetRepository <Rank>()
                               .GetSingle(r => r.ID == rankId);

                    var flags = new RankFlags(rank.Flags);
                    this.Name.Text           = rank.Name;
                    this.IsStart.Checked     = flags.IsStart;
                    this.IsLadder.Checked    = flags.IsLadder;
                    this.MinPosts.Text       = rank.MinPosts.ToString();
                    this.PMLimit.Text        = rank.PMLimit.ToString();
                    this.Style.Text          = rank.Style;
                    this.RankPriority.Text   = rank.SortOrder.ToString();
                    this.UsrAlbums.Text      = rank.UsrAlbums.ToString();
                    this.UsrAlbumImages.Text = rank.UsrAlbumImages.ToString();
                    this.UsrSigChars.Text    = rank.UsrSigChars.ToString();
                    this.UsrSigBBCodes.Text  = rank.UsrSigBBCodes;
                    this.UsrSigHTMLTags.Text = rank.UsrSigHTMLTags;
                    this.Description.Text    = rank.Description;

                    var item = this.RankImage.Items.FindByText(rank.RankImage);

                    if (item != null)
                    {
                        item.Selected    = true;
                        this.Preview.Src = "{0}{1}/{2}".FormatWith(
                            YafForumInfo.ForumClientFileRoot,
                            YafBoardFolders.Current.Ranks,
                            rank.RankImage);
                    }
                    else
                    {
                        this.Preview.Src =
                            YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                    }
                }
                else
                {
                    this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                }
            }

            this.RankImage.Attributes["onchange"] =
                "getElementById('{2}').src='{0}{1}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, this.Preview.ClientID);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.BindData();

                if (this.Request.QueryString.GetFirstOrDefault("r") != null)
                {
                    using (
                        var dt = LegacyDb.rank_list(
                            this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("r")))
                    {
                        var row   = dt.Rows[0];
                        var flags = new RankFlags(row["Flags"]);
                        this.Name.Text           = (string)row["Name"];
                        this.IsStart.Checked     = flags.IsStart;
                        this.IsLadder.Checked    = flags.IsLadder;
                        this.MinPosts.Text       = row["MinPosts"].ToString();
                        this.PMLimit.Text        = row["PMLimit"].ToString();
                        this.Style.Text          = row["Style"].ToString();
                        this.RankPriority.Text   = row["SortOrder"].ToString();
                        this.UsrAlbums.Text      = row["UsrAlbums"].ToString();
                        this.UsrAlbumImages.Text = row["UsrAlbumImages"].ToString();
                        this.UsrSigChars.Text    = row["UsrSigChars"].ToString();
                        this.UsrSigBBCodes.Text  = row["UsrSigBBCodes"].ToString();
                        this.UsrSigHTMLTags.Text = row["UsrSigHTMLTags"].ToString();
                        this.Description.Text    = row["Description"].ToString();

                        var item = this.RankImage.Items.FindByText(row["RankImage"].ToString());

                        if (item != null)
                        {
                            item.Selected    = true;
                            this.Preview.Src = "{0}{1}/{2}".FormatWith(
                                YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, row["RankImage"]);
                        }
                        else
                        {
                            this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                        }
                    }
                }
                else
                {
                    this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                }
            }

            this.RankImage.Attributes["onchange"] =
                "getElementById('{2}').src='{0}{1}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, this.Preview.ClientID);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Add Flag Images to Items
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render(HtmlTextWriter writer)
        {
            foreach (ListItem item in this.Items.Cast <ListItem>().Where(item => item.Value.IsSet()))
            {
                item.Attributes.Add("data-class", "customicon");
                item.Attributes.Add(
                    "data-style",
                    "background-image: url('{0}');".FormatWith(
                        YafForumInfo.GetURLToContent("images/flags/{0}.png").FormatWith(item.Value)));
            }

            base.Render(writer);
        }
Exemplo n.º 10
0
        /// <summary>
        /// The On PreRender event.
        /// </summary>
        /// <param name="e">
        /// the Event Arguments
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this.LoadingImage.ImageUrl      = YafForumInfo.GetURLToContent("images/loader.gif");
            this.LoadingImage.AlternateText = this.Get <ILocalization>().GetText("COMMON", "LOADING");
            this.LoadingImage.ToolTip       = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            this.LoadingText.Text = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            // Setup Pagination js
            YafContext.Current.PageElements.RegisterJsBlock("paginationloadjs", JavaScriptBlocks.PaginationLoadJs);

            base.OnPreRender(e);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Register the CSS Files in the header.
        /// </summary>
        /// <param name="version">
        /// The version.
        /// </param>
        private void RegisterCssFiles(int version)
        {
            var element = YafContext.Current.CurrentForumPage.TopPageControl;

            element.Controls.Add(
                ControlHelper.MakeCssIncludeControl(
                    $"{this.Get<ITheme>().BuildThemePath("bootstrap-forum.min.css")}?v={version}"));

            // make the style sheet link controls.
            element.Controls.Add(
                ControlHelper.MakeCssIncludeControl(
                    YafForumInfo.GetURLToContent(
                        this.PageContext.CurrentForumPage.IsAdminPage
                            ? $"forum-admin.min.css?v={version}"
                            : $"forum.min.css?v={version}")));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            DataRow row;

            using (var dt = this.GetRepository <Board>().List(this.PageContext.PageBoardID))
            {
                row = dt.Rows[0];
            }

            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                var dr = dt.NewRow();
                dr["FileID"]      = 0;
                dr["FileName"]    = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = this.GetText("BOARD_LOGO_SELECT");
                dt.Rows.Add(dr);

                var dir =
                    new DirectoryInfo(
                        this.Request.MapPath($"{YafForumInfo.ForumServerFileRoot}{YafBoardFolders.Current.Logos}"));
                var  files  = dir.GetFiles("*.*");
                long fileID = 1;

                foreach (var file in from file in files
                         let extension = file.Extension.ToLower()
                                         where extension == ".png" || extension == ".gif" || extension == ".jpg" || extension == ".svg"
                                         select file)
                {
                    dr                = dt.NewRow();
                    dr["FileID"]      = fileID++;
                    dr["FileName"]    = $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Logos}/{file.Name}";
                    dr["Description"] = file.Name;
                    dt.Rows.Add(dr);
                }

                this.BoardLogo.DataSource     = dt;
                this.BoardLogo.DataValueField = "FileName";
                this.BoardLogo.DataTextField  = "Description";
            }

            this.DataBind();
            this.Name.Text             = row["Name"].ToString();
            this.AllowThreaded.Checked = Convert.ToBoolean(row["AllowThreaded"]);
        }
        /// <summary>
        /// Gets HTML IMG code representing given log event icon.
        /// </summary>
        /// <param name="dataRow">
        /// Data row containing event log entry data.
        /// </param>
        /// <returns>
        /// return HTML code of event log entry image
        /// </returns>
        protected string EventImageCode([NotNull] object dataRow)
        {
            // cast object to the DataRowView
            var row = (DataRowView)dataRow;

            // set defaults
            string imageType = Enum.GetName(typeof(EventLogTypes), (int)row["Type"]);

            if (imageType.IsNotSet())
            {
                imageType = "Error";
            }

            // return HTML code of event log entry image
            return
                (@"<img src=""{0}"" alt=""{1}"" title=""{1}"" />".FormatWith(
                     YafForumInfo.GetURLToContent("icons/{0}.png".FormatWith(imageType.ToLowerInvariant())), imageType));
        }
Exemplo n.º 14
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"<div class=""AttachmentListMenu dropdown-item"" id=""{0}"">",
                this.ClientID);

            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");

            sb.Append("<div id=\"AttachmentsListPager\"></div>");
            sb.Append("<div id=\"PostAttachmentLoader\">");
            sb.AppendFormat(
                "<p style=\"text-align:center\"><span>{1}</span><br /><img title=\"{1}\" src=\"{0}\" alt=\"{1}\" /></p>",
                YafForumInfo.GetURLToContent("images/loader.gif"),
                this.Get <ILocalization>().GetText("COMMON", "LOADING"));
            sb.Append("</div>");
            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");
            sb.AppendFormat(
                "<div id=\"PostAttachmentListPlaceholder\" data-url=\"{0}\" data-userid=\"{1}\" data-notext=\"{2}\" style=\"clear: both;\">",
                YafForumInfo.ForumClientFileRoot,
                YafContext.Current.PageUserID,
                this.Get <ILocalization>().GetText("ATTACHMENTS", "NO_ATTACHMENTS"));
            sb.Append("<ul class=\"AttachmentList\">");
            sb.Append("</ul>");
            sb.Append("</div>");
            sb.Append("<div class=\"m-x-auto OpenUploadDialog\">");
            sb.AppendFormat(
                "<button type=\"button\" class=\"btn btn-primary btn-sm\" data-toggle=\"modal\" data-target=\".UploadDialog\">{0}</button>",
                this.Get <ILocalization>().GetText("ATTACHMENTS", "UPLOAD_NEW"));
            sb.Append("</div>");

            sb.Append("</div>");
            sb.AppendFormat("</div>");

            writer.WriteLine(sb.ToString());

            base.Render(writer);
        }
Exemplo n.º 15
0
        /// <summary>
        /// The create images data table.
        /// </summary>
        protected void CreateImagesDataTable()
        {
            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                var dr = dt.NewRow();
                dr["FileID"]   = 0;
                dr["FileName"] =
                    YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = this.GetText("COMMON", "NONE");
                dt.Rows.Add(dr);

                var dir = new DirectoryInfo(
                    this.Request.MapPath($"{YafForumInfo.ForumServerFileRoot}{YafBoardFolders.Current.Forums}"));
                if (dir.Exists)
                {
                    var  files  = dir.GetFiles("*.*");
                    long fileId = 1;

                    var filesList = from file in files
                                    let sExt = file.Extension.ToLower()
                                               where sExt == ".png" || sExt == ".gif" || sExt == ".jpg"
                                               select file;

                    filesList.ForEach(
                        file =>
                    {
                        dr             = dt.NewRow();
                        dr["FileID"]   = fileId++;
                        dr["FileName"] =
                            $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Forums}/{file.Name}";
                        dr["Description"] = file.Name;
                        dt.Rows.Add(dr);
                    });
                }

                this.ForumImages.DataSource     = dt;
                this.ForumImages.DataValueField = "FileName";
                this.ForumImages.DataTextField  = "Description";
                this.ForumImages.DataBind();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums));
            this.PageLinks.AddLink(this.GetText("ADMIN_DELETEFORUM", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("TEAM", "FORUMS"),
                this.GetText("ADMIN_DELETEFORUM", "TITLE"));

            this.Delete.Text = "<i class=\"fa fa-trash fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("ADMIN_DELETEFORUM", "DELETE_FORUM"));
            this.Cancel.Text = "<i class=\"fa fa-remove fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("CANCEL"));

            this.Delete.Attributes["onclick"] =
                "return (confirm('{0}') && confirm('{1}'));".FormatWith(
                    this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE"),
                    this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE_POSITIVE"));

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa");

            using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value))
            {
                DataRow row = dt.Rows[0];

                this.ForumNameTitle.Text = (string)row["Name"];

                // populate parent forums list with forums according to selected category
                this.BindParentList();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Change Smiley Image Preview
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void ChangePreview(object sender, EventArgs e)
        {
            if (this.Icon.SelectedValue == null)
            {
                return;
            }

            this.Icon.ImageLocation = "{0}{1}/{2}".FormatWith(
                YafForumInfo.ForumClientFileRoot,
                YafBoardFolders.Current.Emoticons,
                "{0}");

            this.Preview.Src = this.Icon.SelectedValue.IsSet()
                                   ? "{0}{1}/{2}".FormatWith(
                YafForumInfo.ForumClientFileRoot,
                YafBoardFolders.Current.Emoticons,
                this.Icon.SelectedValue)
                                   : YafForumInfo.GetURLToContent("images/spacer.gif");
        }
Exemplo n.º 18
0
        /// <summary>
        /// Select image in dropdown list and sets appropriate preview.
        /// </summary>
        /// <param name="list">
        /// DropDownList where to search.
        /// </param>
        /// <param name="preview">
        /// Preview image.
        /// </param>
        /// <param name="imageUrl">
        /// URL to search for.
        /// </param>
        private void SelectImage([NotNull] DropDownList list, [NotNull] HtmlImage preview, [NotNull] string imageUrl)
        {
            // try to find item in a list
            var item = list.Items.FindByText(imageUrl);

            if (item != null)
            {
                // select found item
                item.Selected = true;

                // set preview image
                preview.Src = $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Medals}/{imageUrl}";
            }
            else
            {
                // if we found nothing, set blank image as preview
                preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// The create images data table.
        /// </summary>
        protected void CreateImagesDataTable()
        {
            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                DataRow dr = dt.NewRow();
                dr["FileID"]      = 0;
                dr["FileName"]    = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = "None";
                dt.Rows.Add(dr);

                var dir =
                    new DirectoryInfo(
                        this.Request.MapPath(
                            "{0}{1}".FormatWith(YafForumInfo.ForumServerFileRoot, YafBoardFolders.Current.Categories)));
                if (dir.Exists)
                {
                    FileInfo[] files   = dir.GetFiles("*.*");
                    long       nFileID = 1;

                    foreach (FileInfo file in from file in files
                             let sExt = file.Extension.ToLower()
                                        where sExt == ".png" || sExt == ".gif" || sExt == ".jpg"
                                        select file)
                    {
                        dr                = dt.NewRow();
                        dr["FileID"]      = nFileID++;
                        dr["FileName"]    = file.Name;
                        dr["Description"] = file.Name;
                        dt.Rows.Add(dr);
                    }
                }

                this.CategoryImages.DataSource     = dt;
                this.CategoryImages.DataValueField = "FileName";
                this.CategoryImages.DataTextField  = "Description";
                this.CategoryImages.DataBind();
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"<div class=""yafpopupmenu AttachmentListMenu"" id=""{0}"" style=""position:absolute;z-index:100;left:0;top:0;display:none;"">",
                this.ClientID);

            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");

            sb.Append("<div id=\"AttachmentsListPager\"></div>");
            sb.Append("<div id=\"PostAttachmentLoader\">");
            sb.AppendFormat(
                "<p style=\"text-align:center\"><span>{1}</span><br /><img title=\"{1}\" src=\"{0}\" alt=\"{1}\" /></p>",
                YafForumInfo.GetURLToContent("images/loader.gif"),
                this.Get <ILocalization>().GetText("COMMON", "LOADING"));
            sb.Append("</div>");
            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");
            sb.AppendFormat(
                "<div id=\"PostAttachmentListPlaceholder\" data-url=\"{0}\" style=\"clear: both;\">",
                YafForumInfo.ForumClientFileRoot);
            sb.Append("<ul class=\"AttachmentList\">");
            sb.Append("</ul>");
            sb.Append("</div>");
            sb.AppendFormat(
                "<span class=\"UploadNewFileLine\"><a class=\"OpenUploadDialog yaflittlebutton\" onclick=\"jQuery('.UploadDialog').dialog('open');\"><span>{0}</span></a></span>",
                this.Get <ILocalization>().GetText("ATTACHMENTS", "UPLOAD_NEW"));

            sb.Append("</div>");
            sb.AppendFormat("</div>");

            writer.WriteLine(sb.ToString());

            base.Render(writer);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                var dr = dt.NewRow();
                dr["FileID"]      = 0;
                dr["FileName"]    = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = this.GetText("ADMIN_EDITRANK", "SELECT_IMAGE");
                dt.Rows.Add(dr);

                var dir =
                    new DirectoryInfo(
                        this.Request.MapPath(
                            "{0}{1}".FormatWith(YafForumInfo.ForumServerFileRoot, YafBoardFolders.Current.Ranks)));
                var  files   = dir.GetFiles("*.*");
                long nFileID = 1;

                foreach (var file in from file in files
                         let sExt = file.Extension.ToLower()
                                    where sExt == ".png" || sExt == ".gif" || sExt == ".jpg"
                                    select file)
                {
                    dr                = dt.NewRow();
                    dr["FileID"]      = nFileID++;
                    dr["FileName"]    = file.Name;
                    dr["Description"] = file.Name;
                    dt.Rows.Add(dr);
                }

                this.RankImage.DataSource     = dt;
                this.RankImage.DataValueField = "FileName";
                this.RankImage.DataTextField  = "Description";
            }

            this.DataBind();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa");

            using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value))
            {
                var row = dt.Rows[0];

                this.ForumNameTitle.Text = (string)row["Name"];

                // populate parent forums list with forums according to selected category
                this.BindParentList();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Inserts the CSS refresh.
        /// </summary>
        /// <param name="addTo">The control to add.</param>
        protected void InsertCssRefresh([NotNull] Control addTo)
        {
            // make the style sheet link controls.
#if DEBUG
            addTo.Controls.Add(ControlHelper.MakeCssIncludeControl(YafForumInfo.GetURLToContent("forum.css")));
#else
            addTo.Controls.Add(ControlHelper.MakeCssIncludeControl(YafForumInfo.GetURLToContent("forum.min.css")));
#endif

            addTo.Controls.Add(ControlHelper.MakeCssIncludeControl(this.Get <ITheme>().BuildThemePath("theme.css")));

            if (this.RefreshURL == null || this.RefreshTime < 0)
            {
                return;
            }

            var refresh = new HtmlMeta
            {
                HttpEquiv = "Refresh", Content = "{1};url={0}".FormatWith(this.RefreshURL, this.RefreshTime)
            };

            addTo.Controls.Add(refresh);
        }
Exemplo n.º 24
0
        private string MatchUserBoxCountryImages([NotNull] string userBox)
        {
            string filler = string.Empty;
            var    rx     = this.GetRegex(Constants.UserBox.CountryImage);

            if (this.Get <YafBoardSettings>().ShowCountryInfoInUserBox&& this.UserProfile.Country.IsSet() && !this.UserProfile.Country.Equals("N/A"))
            {
                string imagePath = this.PageContext.Get <ITheme>().GetItem(
                    "FLAGS",
                    "{0}_MEDIUM".FormatWith(this.UserProfile.Country.ToUpperInvariant()),
                    YafForumInfo.GetURLToContent("images/flags/{0}.png".FormatWith(this.UserProfile.Country.Trim())));

                string imageAlt = this.GetText("COUNTRY", this.UserProfile.Country.ToUpperInvariant());

                filler =
                    this.Get <YafBoardSettings>().UserBoxCountryImage.FormatWith(
                        @"<a><img src=""{0}"" alt=""{1}"" title=""{1}"" /></a>".FormatWith(imagePath, imageAlt));
            }

            // replaces template placeholder with actual rank image
            userBox = rx.Replace(userBox, filler);
            return(userBox);
        }
Exemplo n.º 25
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"<div class=""yafpopupmenu yafalbumlistmenu"" id=""{0}"" style=""position:absolute;z-index:100;left:0;top:0;display:none;"">",
                ClientID);

            sb.Append("<div id=\"AlbumsListPager\"></div>");
            sb.Append("<div id=\"PostAlbumsLoader\">");
            sb.AppendFormat(
                "<p style=\"text-align:center\"><span>{1}</span><br /><img title=\"{1}\" src=\"{0}\" alt=\"{1}\" /></p>",
                YafForumInfo.GetURLToContent("images/loader.gif"),
                this.Get <ILocalization>().GetText("COMMON", "LOADING"));
            sb.Append("</div>");
            sb.Append("<div id=\"AlbumsListBox\" class=\"content\">");
            sb.AppendFormat(
                "<div id=\"PostAlbumsListPlaceholder\" data-url=\"{0}\" data-userid=\"{1}\" data-notext=\"{2}\" style=\"clear: both;\">",
                YafForumInfo.ForumClientFileRoot,
                YafContext.Current.PageUserID,
                this.Get <ILocalization>().GetText("ATTACHMENTS", "NO_ATTACHMENTS"));
            sb.Append("<ul class=\"AlbumsList\">");
            sb.Append("</ul>");
            sb.Append("</div>");

            sb.AppendFormat("</div></div>");

            writer.WriteLine(sb.ToString());

            base.Render(writer);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="EventArgs"/> instance containing the event data.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.CreateUserWizard1.MembershipProvider = Config.MembershipProvider;

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(this.GetText("TITLE"));

            // handle the CreateUser Step localization
            this.SetupCreateUserStep();

            // handle other steps localization
            ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ProfileNextButton")).Text =
                this.GetText("SAVE");
            ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ContinueButton")).Text =
                this.GetText("CONTINUE");

            var dstUser = (CheckBox)this.CreateUserWizard1.FindWizardControlRecursive("DSTUser");

            dstUser.Text = this.GetText("CP_EDITPROFILE", "DST");

            var facebookRegister = (LinkButton)this.CreateUserWizard1.FindWizardControlRecursive("FacebookRegister");
            var twitterRegister  = (LinkButton)this.CreateUserWizard1.FindWizardControlRecursive("TwitterRegister");
            var googleRegister   = (LinkButton)this.CreateUserWizard1.FindWizardControlRecursive("GoogleRegister");

            var loginButton = (LinkButton)this.CreateUserWizard1.FindWizardControlRecursive("LoginButton");

            var authPanel = (Panel)this.CreateUserWizard1.FindWizardControlRecursive("AuthPanel");

            if (this.PageContext.IsGuest && !Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                loginButton.Visible = true;
                loginButton.Text    = this.GetText("LOGIN_INSTEAD");
            }

            if (Config.FacebookAPIKey.IsSet() && Config.FacebookSecretKey.IsSet())
            {
                facebookRegister.Visible = authPanel.Visible = true;
                facebookRegister.Text    = this.GetTextFormatted("REGISTER_AUTH", "Facebook");
            }

            if (Config.TwitterConsumerKey.IsSet() && Config.TwitterConsumerSecret.IsSet())
            {
                twitterRegister.Visible = authPanel.Visible = true;
                twitterRegister.Text    = this.GetTextFormatted("REGISTER_AUTH", "Twitter");
            }

            if (Config.GoogleClientID.IsSet() && Config.GoogleClientSecret.IsSet())
            {
                googleRegister.Visible = authPanel.Visible = true;
                googleRegister.Text    = this.GetTextFormatted("REGISTER_AUTH", "Google");
            }

            // get the time zone data source
            var timeZones = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("TimeZones");

            timeZones.DataSource = StaticDataHelper.TimeZones();

            // get the country data source
            var country = (ImageListBox)this.CreateUserWizard1.FindWizardControlRecursive("Country");

            country.ImageLocation = YafForumInfo.GetURLToContent("images/flags/{0}.png");
            country.DataSource    = StaticDataHelper.Country();

            if (this.Get <YafBoardSettings>().EnableIPInfoService&& this.UserIpLocator == null)
            {
                // vzrus: we should always get not null class here
                this.UserIpLocator = new IPDetails().GetData(
                    this.Get <HttpRequestBase>().GetUserRealIPAddress(),
                    "text",
                    false,
                    this.PageContext().CurrentForumPage.Localization.Culture.Name,
                    string.Empty,
                    string.Empty);
            }

            if (!this.Get <YafBoardSettings>().EmailVerification)
            {
                // automatically log in created users
                this.CreateUserWizard1.LoginCreatedUser   = false;
                this.CreateUserWizard1.DisableCreatedUser = false;

                // success notification localization
                ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                    this.Get <IBBCode>().MakeHtml(this.GetText("ACCOUNT_CREATED"), false, true, false);
            }
            else
            {
                this.CreateUserWizard1.LoginCreatedUser   = false;
                this.CreateUserWizard1.DisableCreatedUser = true;

                // success notification localization
                ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                    this.Get <IBBCode>().MakeHtml(this.GetText("ACCOUNT_CREATED_VERIFICATION"), false, true, false);
            }

            this.CreateUserWizard1.ContinueDestinationPageUrl = YafForumInfo.ForumURL;
            this.CreateUserWizard1.FinishDestinationPageUrl   = YafForumInfo.ForumURL;

            this.DataBind();

            // fill location field
            if (this.Get <YafBoardSettings>().EnableIPInfoService)
            {
                try
                {
                    this.FillLocationData(country);
                }
                catch (Exception exception)
                {
                    this.Logger.Log(
                        null,
                        this,
                        "Error whith Location Data for IP: {0}, exception is: {1}".FormatWith(
                            this.Get <HttpRequestBase>().GetUserRealIPAddress(),
                            exception));
                }
            }

            // Auto Fill user time zone
            timeZones.Items.FindByValue(TimeZoneInfo.Local.Id).Selected = true;

            this.CreateUserWizard1.FindWizardControlRecursive("UserName").Focus();

            if (this.Get <YafBoardSettings>().CaptchaTypeRegister == 2)
            {
                this.SetupRecaptchaControl();
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// The setup user profile info.
        /// </summary>
        /// <param name="userID">The user id.</param>
        /// <param name="user">The user.</param>
        /// <param name="userData">The user data.</param>
        /// <param name="userDisplayName">The user display name.</param>
        private void SetupUserProfileInfo(
            int userID,
            [NotNull] MembershipUser user,
            [NotNull] IUserData userData,
            [NotNull] string userDisplayName)
        {
            this.UserLabel1.UserID = userData.UserID;

            if (this.PageContext.IsAdmin && userData.DisplayName != user.UserName)
            {
                this.Name.Text = this.HtmlEncode("{0} ({1})".FormatWith(userData.DisplayName, user.UserName));
            }
            else
            {
                this.Name.Text = this.HtmlEncode(userDisplayName);
            }

            this.Joined.Text =
                "{0}".FormatWith(this.Get <IDateTime>().FormatDateLong(Convert.ToDateTime(userData.Joined)));

            // vzrus: Show last visit only to admins if user is hidden
            if (!this.PageContext.IsAdmin && Convert.ToBoolean(userData.DBRow["IsActiveExcluded"]))
            {
                this.LastVisit.Text    = this.GetText("COMMON", "HIDDEN");
                this.LastVisit.Visible = true;
            }
            else
            {
                this.LastVisitDateTime.DateTime = userData.LastVisit;
                this.LastVisitDateTime.Visible  = true;
            }

            if (this.User != null && userData.RankName.IsSet())
            {
                this.RankTR.Visible = true;
                this.Rank.Text      = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.RankName));
            }

            if (this.User != null && userData.Profile.Location.IsSet())
            {
                this.LocationTR.Visible = true;
                this.Location.Text      = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Location));
            }

            if (this.User != null && userData.Profile.Country.Trim().IsSet() && !userData.Profile.Country.Equals("N/A"))
            {
                this.CountryTR.Visible = true;
                this.CountryLabel.Text =
                    this.HtmlEncode(
                        this.Get <IBadWordReplace>().Replace(this.GetText("COUNTRY", userData.Profile.Country.Trim())));

                this.CountryFlagImage.Src = this.Get <ITheme>()
                                            .GetItem(
                    "FLAGS",
                    "{0}_MEDIUM".FormatWith(userData.Profile.Country.Trim()),
                    YafForumInfo.GetURLToContent("images/flags/{0}.png".FormatWith(userData.Profile.Country.Trim())));

                this.CountryFlagImage.Alt = userData.Profile.Country.Trim();
                this.CountryFlagImage.Attributes.Add("title", this.CountryLabel.Text);
            }

            if (this.User != null && userData.Profile.Region.IsSet())
            {
                this.RegionTR.Visible = true;

                try
                {
                    var tag =
                        "RGN_{0}_{1}".FormatWith(
                            userData.Profile.Country.Trim().IsSet()
                                ? userData.Profile.Country.Trim()
                                : this.Get <ILocalization>().Culture.Name.Remove(0, 3).ToUpperInvariant(),
                            userData.Profile.Region);
                    this.RegionLabel.Text =
                        this.HtmlEncode(this.Get <IBadWordReplace>().Replace(this.GetText("REGION", tag)));
                }
                catch (Exception)
                {
                    this.RegionTR.Visible = false;
                }
            }

            if (this.User != null && userData.Profile.City.IsSet())
            {
                this.CityTR.Visible = true;
                this.CityLabel.Text = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.City));
            }

            if (this.User != null && userData.Profile.Location.IsSet())
            {
                this.LocationTR.Visible = true;
                this.Location.Text      = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Location));
            }

            if (this.User != null && userData.Profile.RealName.IsSet())
            {
                this.RealNameTR.Visible = true;
                this.RealName.InnerText = this.HtmlEncode(
                    this.Get <IBadWordReplace>().Replace(userData.Profile.RealName));
            }

            if (this.User != null && userData.Profile.Interests.IsSet())
            {
                this.InterestsTR.Visible = true;
                this.Interests.InnerText =
                    this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Interests));
            }

            if (this.User != null && (userData.Profile.Gender > 0))
            {
                string imagePath = string.Empty;
                string imageAlt  = string.Empty;

                this.GenderTR.Visible = true;
                switch (userData.Profile.Gender)
                {
                case 1:
                    imagePath = this.PageContext.Get <ITheme>().GetItem("ICONS", "GENDER_MALE", null);
                    imageAlt  = this.GetText("USERGENDER_MAS");
                    break;

                case 2:
                    imagePath = this.PageContext.Get <ITheme>().GetItem("ICONS", "GENDER_FEMALE", null);
                    imageAlt  = this.GetText("USERGENDER_FEM");
                    break;
                }

                this.Gender.InnerHtml =
                    @"<a><img src=""{0}"" alt=""{1}"" title=""{1}"" /></a>&nbsp;{1}".FormatWith(imagePath, imageAlt);
            }

            if (this.User != null && userData.Profile.Occupation.IsSet())
            {
                this.OccupationTR.Visible = true;
                this.Occupation.InnerText =
                    this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Occupation));
            }

            this.ThanksFrom.Text =
                LegacyDb.user_getthanks_from(userData.DBRow["userID"], this.PageContext.PageUserID).ToString();
            int[] thanksToArray = LegacyDb.user_getthanks_to(userData.DBRow["userID"], this.PageContext.PageUserID);
            this.ThanksToTimes.Text      = thanksToArray[0].ToString();
            this.ThanksToPosts.Text      = thanksToArray[1].ToString();
            this.ReputationReceived.Text = YafReputation.GenerateReputationBar(userData.Points.Value, userData.UserID);

            if (this.Get <YafBoardSettings>().ShowUserOnlineStatus)
            {
                this.OnlineStatusImage1.UserID  = userID;
                this.OnlineStatusImage1.Visible = true;

                var suspended = userData.DBRow["Suspended"].ToType <DateTime?>();

                if (suspended.HasValue && suspended.Value > DateTime.UtcNow)
                {
                    this.ThemeImgSuspended.LocalizedTitle =
                        this.GetText("POSTS", "USERSUSPENDED")
                        .FormatWith(this.Get <IDateTime>().FormatDateTimeShort(suspended.Value));

                    this.ThemeImgSuspended.Visible  = true;
                    this.OnlineStatusImage1.Visible = false;
                }
                else
                {
                    this.ThemeImgSuspended.Visible = false;
                }
            }
            else
            {
                this.ThemeImgSuspended.Visible  = false;
                this.OnlineStatusImage1.Visible = false;
            }

            if (this.User != null && userData.Profile.XMPP.IsSet())
            {
                this.XmppTR.Visible = true;
                this.lblxmpp.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.XMPP));
            }

            if (this.User != null && userData.Profile.AIM.IsSet())
            {
                this.AimTR.Visible = true;
                this.lblaim.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.AIM));
            }

            if (this.User != null && userData.Profile.ICQ.IsSet())
            {
                this.IcqTR.Visible = true;
                this.lblicq.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.ICQ));
            }

            if (this.User != null && userData.Profile.MSN.IsSet())
            {
                this.MsnTR.Visible = true;
                this.lblmsn.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.MSN));
            }

            if (this.User != null && userData.Profile.Skype.IsSet())
            {
                this.SkypeTR.Visible = true;
                this.lblskype.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Skype));
            }

            if (this.User != null && userData.Profile.YIM.IsSet())
            {
                this.YimTR.Visible = true;
                this.lblyim.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.YIM));
            }

            var loadHoverCardJs = false;

            if (this.User != null && userData.Profile.Facebook.IsSet())
            {
                this.FacebookTR.Visible = true;
                this.lblfacebook.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Facebook));

                if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards)
                {
                    this.lblfacebook.Attributes.Add("data-hovercard", this.lblfacebook.Text);
                    this.Facebook.Attributes.Add("data-hovercard", this.lblfacebook.Text);

                    this.lblfacebook.CssClass += " Facebook-HoverCard";
                    this.Facebook.CssClass    += " Facebook-HoverCard";

                    loadHoverCardJs = true;
                }
            }

            if (this.User != null && userData.Profile.Twitter.IsSet())
            {
                this.TwitterTR.Visible = true;
                this.lbltwitter.Text   = this.HtmlEncode(this.Get <IBadWordReplace>().Replace(userData.Profile.Twitter));

                if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards&& Config.IsTwitterEnabled)
                {
                    this.lbltwitter.Attributes.Add("data-hovercard", this.lbltwitter.Text);
                    this.Twitter.Attributes.Add("data-hovercard", this.lbltwitter.Text);

                    this.lbltwitter.CssClass += " Twitter-HoverCard";
                    this.Twitter.CssClass    += " Twitter-HoverCard";

                    loadHoverCardJs = true;
                }
            }

            if (loadHoverCardJs && this.Get <YafBoardSettings>().EnableUserInfoHoverCards&& Config.IsTwitterEnabled)
            {
                var hoverCardLoadJs = new StringBuilder();

                hoverCardLoadJs.Append(
                    JavaScriptBlocks.HoverCardLoadJs(
                        ".Facebook-HoverCard",
                        "Facebook",
                        this.GetText("DEFAULT", "LOADING_FB_HOVERCARD").ToJsString(),
                        this.GetText("DEFAULT", "ERROR_FB_HOVERCARD").ToJsString()));

                hoverCardLoadJs.Append(
                    JavaScriptBlocks.HoverCardLoadJs(
                        ".Twitter-HoverCard",
                        "Twitter",
                        this.GetText("DEFAULT", "LOADING_TWIT_HOVERCARD").ToJsString(),
                        this.GetText("DEFAULT", "ERROR_TWIT_HOVERCARD").ToJsString(),
                        "{0}{1}resource.ashx?twitterinfo=".FormatWith(
                            BaseUrlBuilder.BaseUrl.TrimEnd('/'),
                            BaseUrlBuilder.AppPath)));

                // Setup Hover Card JS
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "hovercardtwitterfacebookjs",
                    hoverCardLoadJs.ToString());
            }

            if (this.User != null && userData.Profile.Birthday >= DateTimeHelper.SqlDbMinTime())
            {
                this.BirthdayTR.Visible = true;
                this.Birthday.Text      =
                    this.Get <IDateTime>()
                    .FormatDateLong(userData.Profile.Birthday.AddMinutes((double)(-userData.TimeZone)));
            }
            else
            {
                this.BirthdayTR.Visible = false;
            }

            // Show User Medals
            if (this.Get <YafBoardSettings>().ShowMedals)
            {
                var userMedalsTable = this.Get <YafDbBroker>().UserMedals(this.UserId);

                if (userMedalsTable.Rows.Count <= 0)
                {
                    this.MedalsRow.Visible = false;

                    return;
                }

                var ribbonBar = new StringBuilder(500);
                var medals    = new StringBuilder(500);

                DataRow    r;
                MedalFlags f;

                int i     = 0;
                int inRow = 0;

                // do ribbon bar first
                while (userMedalsTable.Rows.Count > i)
                {
                    r = userMedalsTable.Rows[i];
                    f = new MedalFlags(r["Flags"]);

                    // do only ribbon bar items first
                    if (!r["OnlyRibbon"].ToType <bool>())
                    {
                        break;
                    }

                    // skip hidden medals
                    if (!f.AllowHiding || !r["Hide"].ToType <bool>())
                    {
                        if (inRow == 3)
                        {
                            // add break - only three ribbons in a row
                            ribbonBar.Append("<br />");
                            inRow = 0;
                        }

                        var title = "{0}{1}".FormatWith(
                            r["Name"],
                            f.ShowMessage ? ": {0}".FormatWith(r["Message"]) : string.Empty);

                        ribbonBar.AppendFormat(
                            "<img src=\"{0}{5}/{1}\" width=\"{2}\" height=\"{3}\" alt=\"{4}\" title=\"{4}\" />",
                            YafForumInfo.ForumClientFileRoot,
                            r["SmallRibbonURL"],
                            r["SmallRibbonWidth"],
                            r["SmallRibbonHeight"],
                            title,
                            YafBoardFolders.Current.Medals);

                        inRow++;
                    }

                    // move to next row
                    i++;
                }

                // follow with the rest
                while (userMedalsTable.Rows.Count > i)
                {
                    r = userMedalsTable.Rows[i];
                    f = new MedalFlags(r["Flags"]);

                    // skip hidden medals
                    if (!f.AllowHiding || !r["Hide"].ToType <bool>())
                    {
                        medals.AppendFormat(
                            "<img src=\"{0}{6}/{1}\" width=\"{2}\" height=\"{3}\" alt=\"{4}{5}\" title=\"{4}{5}\" />",
                            YafForumInfo.ForumClientFileRoot,
                            r["SmallMedalURL"],
                            r["SmallMedalWidth"],
                            r["SmallMedalHeight"],
                            r["Name"],
                            f.ShowMessage ? ": {0}".FormatWith(r["Message"]) : string.Empty,
                            YafBoardFolders.Current.Medals);
                    }

                    // move to next row
                    i++;
                }

                this.MedalsPlaceHolder.Text = "{0}<br />{1}".FormatWith(ribbonBar, medals);
                this.MedalsRow.Visible      = true;
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

                this.PageLinks.AddLink(
                    this.GetText("ADMIN_RANKS", "TITLE"), YafBuildLink.GetLink(ForumPages.admin_ranks));

                // current page label (no link)
                this.PageLinks.AddLink(this.GetText("ADMIN_EDITRANK", "TITLE"), string.Empty);

                this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                    this.GetText("ADMIN_ADMIN", "Administration"),
                    this.GetText("ADMIN_RANKS", "TITLE"),
                    this.GetText("ADMIN_EDITRANK", "TITLE"));

                this.Save.Text   = this.GetText("COMMON", "SAVE");
                this.Cancel.Text = this.GetText("COMMON", "CANCEL");

                this.BindData();

                if (this.Request.QueryString.GetFirstOrDefault("r") != null)
                {
                    using (
                        DataTable dt = LegacyDb.rank_list(
                            this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("r")))
                    {
                        DataRow row   = dt.Rows[0];
                        var     flags = new RankFlags(row["Flags"]);
                        this.Name.Text           = (string)row["Name"];
                        this.IsStart.Checked     = flags.IsStart;
                        this.IsLadder.Checked    = flags.IsLadder;
                        this.MinPosts.Text       = row["MinPosts"].ToString();
                        this.PMLimit.Text        = row["PMLimit"].ToString();
                        this.Style.Text          = row["Style"].ToString();
                        this.RankPriority.Text   = row["SortOrder"].ToString();
                        this.UsrAlbums.Text      = row["UsrAlbums"].ToString();
                        this.UsrAlbumImages.Text = row["UsrAlbumImages"].ToString();
                        this.UsrSigChars.Text    = row["UsrSigChars"].ToString();
                        this.UsrSigBBCodes.Text  = row["UsrSigBBCodes"].ToString();
                        this.UsrSigHTMLTags.Text = row["UsrSigHTMLTags"].ToString();
                        this.Description.Text    = row["Description"].ToString();

                        ListItem item = this.RankImage.Items.FindByText(row["RankImage"].ToString());

                        if (item != null)
                        {
                            item.Selected    = true;
                            this.Preview.Src = "{0}{1}/{2}".FormatWith(
                                YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, row["RankImage"]);
                        }
                        else
                        {
                            this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                        }
                    }
                }
                else
                {
                    this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                }
            }

            this.RankImage.Attributes["onchange"] =
                "getElementById('{2}_ctl01_Preview').src='{0}{1}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, this.Parent.ID);
        }
Exemplo n.º 29
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.Page.Form.DefaultButton = this.search.UniqueID;

            this.search.Focus();

            if (this.IsPostBack)
            {
                return;
            }

            // create page links
            this.CreatePageLinks();

            this.search.Text = this.GetText("ADMIN_USERS", "SEARCH");

            this.NewUser.Text   = this.GetText("ADMIN_USERS", "NEW_USER");
            this.SyncUsers.Text = this.GetText("ADMIN_USERS", "SYNC_ALL");

            this.ImportUsers.Text    = this.GetText("ADMIN_USERS", "IMPORT");
            this.ExportUsersXml.Text = this.GetText("ADMIN_USERS", "EXPORT_XML");
            this.ExportUsersCsv.Text = this.GetText("ADMIN_USERS", "EXPORT_CSV");

            this.SuspendedOnly.Text = this.GetText("ADMIN_USERS", "SUSPENDED_ONLY");

            if (Config.IsAnyPortal)
            {
                this.ImportUsers.Visible = false;
                this.SyncUsers.Visible   = false;
            }

            ControlHelper.AddOnClickConfirmDialog(this.SyncUsers, this.GetText("ADMIN_USERS", "CONFIRM_SYNC"));

            // intialize since filter items
            this.InitSinceDropdown();

            // set since filter to last item "All time"
            this.Since.SelectedIndex   = this.Since.Items.Count - 1;
            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // get list of user groups for filtering
            using (DataTable dt = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID))
            {
                // add empty item for no filtering
                DataRow newRow = dt.NewRow();

                newRow["Name"]    = this.GetText("FILTER_NO");
                newRow["GroupID"] = 0;

                dt.Rows.InsertAt(newRow, 0);

                this.group.DataSource     = dt;
                this.group.DataTextField  = "Name";
                this.group.DataValueField = "GroupID";

                this.group.DataBind();
            }

            // get list of user ranks for filtering
            using (DataTable dt = LegacyDb.rank_list(this.PageContext.PageBoardID, null))
            {
                // add empty for for no filtering
                DataRow newRow = dt.NewRow();
                newRow["Name"]   = this.GetText("FILTER_NO");
                newRow["RankID"] = 0;
                dt.Rows.InsertAt(newRow, 0);

                this.rank.DataSource     = dt;
                this.rank.DataTextField  = "Name";
                this.rank.DataValueField = "RankID";
                this.rank.DataBind();
            }

            // TODO : page size difinable?
            this.PagerTop.PageSize = 25;

            // Hide "New User" & Sync Button on DotNetNuke
            this.ImportAndSyncHolder.Visible = !Config.IsDotNetNuke;
        }
Exemplo n.º 30
0
 /// <summary>
 /// Add the given CSS to the page header within a style tag
 /// </summary>
 /// <param name="cssUrlContent">Content of the CSS URL.</param>
 public void RegisterCssIncludeContent(string cssUrlContent)
 {
     this.RegisterCssInclude(
         YafContext.Current.CurrentForumPage.TopPageControl,
         YafForumInfo.GetURLToContent(cssUrlContent));
 }