Beispiel #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.BoardID == 0)
            {
                this.BoardID = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("BoardID").ToType <int>();
            }

            if (HttpContext.Current != null)
            {
                this.BoardSettings = this.PageContext.BoardSettings.BoardID.Equals(this.BoardID)
                                         ? this.PageContext.BoardSettings
                                         : new LoadBoardSettings(this.BoardID);
            }
            else
            {
                this.BoardSettings = new LoadBoardSettings(this.BoardID);
            }

            this.Get <StartupInitializeDb>().Run();

            var token = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("token");

            if (token.IsNotSet() || !token.Equals(this.BoardSettings.WebServiceToken))
            {
                if (this.ShowErrors)
                {
                    this.OutputError(
                        "Invalid Web Service Token. Please go into your host settings and save them committing a unique web service token to the database.");
                }

                this.Get <HttpResponseBase>().End();
                return;
            }

            if (Config.ForceScriptName.IsNotSet())
            {
                // fail... ForceScriptName required for Digest.
                if (this.ShowErrors)
                {
                    this.OutputError(
                        @"Cannot generate digest unless YAF.ForceScriptName AppSetting is specified in your app.config (default). Please specify the full page name for YAF.NET -- usually ""default.aspx"".");
                }

                this.Get <HttpResponseBase>().End();
                return;
            }

            if (this.CurrentUserID == 0)
            {
                this.CurrentUserID = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("UserID").ToType <int>();
            }

            // get topic hours...
            this.topicHours = -this.BoardSettings.DigestSendEveryXHours;

            this.forumData = this.Get <DataBroker>().GetSimpleForumTopic(
                this.BoardID,
                this.CurrentUserID,
                System.DateTime.Now.AddHours(this.topicHours),
                9999);

            if (!this.NewTopics.Any() && !this.ActiveTopics.Any())
            {
                if (this.ShowErrors)
                {
                    this.OutputError($"No topics for the last {this.BoardSettings.DigestSendEveryXHours} hours.");

                    this.Get <HttpResponseBase>().Write(this.GetDebug());
                }

                this.Get <HttpResponseBase>().End();
                return;
            }

            this.languageFile = UserHelper.GetUserLanguageFile(
                this.CurrentUserID);

            var theme = UserHelper.GetUserThemeFile(
                this.CurrentUserID,
                this.BoardSettings.AllowUserTheme,
                this.BoardSettings.Theme);

            var subject = string.Format(this.GetText("SUBJECT"), this.BoardSettings.Name);

            this.YafHead.Controls.Add(
                ControlHelper.MakeCssIncludeControl(
                    BoardInfo.GetURLToContentThemes(theme.CombineWith("bootstrap-forum.min.css"))));

            if (subject.IsSet())
            {
                this.YafHead.Title = subject;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets full path to the given theme file.
        /// </summary>
        /// <param name="filename">
        /// Short name of theme file.
        /// </param>
        /// <returns>
        /// The build theme path.
        /// </returns>
        public string BuildThemePath([NotNull] string filename)
        {
            CodeContracts.VerifyNotNull(filename, "filename");

            return(BoardInfo.GetURLToContentThemes(this.ThemeFile.CombineWith(filename)));
        }