/// <summary>
        /// Creates an isolated template class for the module to render
        /// inside.
        /// </summary>
        public new void CreateTemplate()
        {
            template = new Template(core.Http.TemplatePath, "1301.html");
            template.Parse("U_ACCOUNT", core.Hyperlink.AppendSid(Owner.AccountUriStub, true));
            if (assembly != null)
            {
                template.AddPageAssembly(assembly);
                template.SetProse(core.Prose);
            }

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "forum", core.Prose.GetString("FORUM") });
            breadCrumbParts.Add(new string[] { "mcp", core.Prose.GetString("MODERATOR_CONTROL_PANEL") });

            Owner.ParseBreadCrumbs(core.Template, "BREADCRUMBS", breadCrumbParts);
        }
        /// <summary>
        /// Creates an isolated template class for the module to render
        /// inside.
        /// </summary>
        private new void CreateTemplate()
        {
            string formSubmitUri = string.Empty;
            template = new Template(core.Http.TemplatePath, "1301.html");
            if (Owner != null)
            {
                formSubmitUri = core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp", true);
                template.Parse("U_MCP", core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp/", true));
                template.Parse("S_MCP", core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp/", true));
            }
            template.AddPageAssembly(Assembly.GetCallingAssembly());
            template.SetProse(core.Prose);

            Form = new Form("control-panel", formSubmitUri);
            Form.SetValues(core.Http.Form);
            if (core.Http.Form["save"] != null)
            {
                Form.IsFormSubmission = true;
            }

            core.Template.Parse("IS_CONTENT", "FALSE");

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "forum", core.Prose.GetString("FORUM") });
            breadCrumbParts.Add(new string[] { "mcp", core.Prose.GetString("MODERATOR_CONTROL_PANEL") });

            Owner.ParseBreadCrumbs(core.Template, "BREADCRUMBS", breadCrumbParts);
        }
Пример #3
0
        /// <summary>
        /// Creates an isolated template class for the module to render
        /// inside.
        /// </summary>
        private void CreateTemplate()
        {
            string formSubmitUri = string.Empty;
            template = new Template(core.Http.TemplatePath, "1301.html");
            template.Medium = core.Template.Medium;
            if (Owner != null)
            {
                formSubmitUri = core.Hyperlink.AppendSid(Owner.AccountUriStub, true);
                template.Parse("U_ACCOUNT", formSubmitUri);
                template.Parse("S_ACCOUNT", formSubmitUri);
            }
            template.AddPageAssembly(Assembly.GetCallingAssembly());
            template.SetProse(core.Prose);

            Form = new Form("control-panel", formSubmitUri);
            Form.SetValues(core.Http.Form);
            if (core.Http.Form["save"] != null)
            {
                Form.IsFormSubmission = true;
            }

            core.Template.Parse("IS_CONTENT", "FALSE");

            template.Parse("SITE_TITLE", core.Settings.SiteTitle);
        }
Пример #4
0
        /// <summary>
        /// Creates an isolated template class for the module to render
        /// inside.
        /// </summary>
        public void CreateTemplate()
        {
            template = new Template(core.Http.TemplatePath, "1301.html");
            template.Parse("U_ACCOUNT", core.Hyperlink.AppendSid(Owner.AccountUriStub, true));
            if (assembly != null)
            {
                template.AddPageAssembly(assembly);
                template.SetProse(core.Prose);
            }

            core.Template.Parse("IS_CONTENT", "FALSE");
        }
Пример #5
0
        public TPage()
        {
            timer = new Stopwatch();
            timer.Start();
            rand = new Random();

            Stopwatch initTimer = new Stopwatch();
            initTimer.Start();

            db = new Mysql(WebConfigurationManager.AppSettings["mysql-user"],
                WebConfigurationManager.AppSettings["mysql-password"],
                WebConfigurationManager.AppSettings["mysql-database"],
                WebConfigurationManager.AppSettings["mysql-host"]);
            template = new Template(Server.MapPath("./templates/"), "");

            HttpContext.Current.Response.AppendHeader("x-ua-compatible", "IE=edge,chrome=1");

            string u = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
            if ((!string.IsNullOrEmpty(u)) && ((b.IsMatch(u) || v.IsMatch(u.Substring(0, 4)))))
            {
                isMobile = true;
                template.Medium = DisplayMedium.Mobile;
                template.Parse("IS_MOBILE", "TRUE");
            }
            else
            {
                isMobile = false;
            }

            ResponseFormats responseFormat = ResponseFormats.Html;
            isAjax = (HttpContext.Current.Request.QueryString["ajax"] == "true");
            if (!isAjax)
            {
                isAjax = (HttpContext.Current.Request.Form["ajax"] == "true");
            }
            if (isAjax)
            {
                responseFormat = ResponseFormats.Xml;
            }

            isJson = (HttpContext.Current.Request.QueryString["json"] == "true");
            if (!isJson)
            {
                isJson = (HttpContext.Current.Request.Form["json"] == "true");
            }
            if (isJson)
            {
                responseFormat = ResponseFormats.Json;
            }

            core = new Core(this, responseFormat, db, template);

            pageTitle = core.Settings.SiteTitle + (!string.IsNullOrEmpty(core.Settings.SiteSlogan) ? " • " + core.Settings.SiteSlogan : string.Empty);

            HttpContext httpContext = HttpContext.Current;
            string[] redir = httpContext.Request.RawUrl.Split(';');

            if (redir.Length > 1)
            {
                core.PagePath = redir[1];
                Uri cUri = new Uri(core.PagePath);
                core.PagePath = cUri.AbsolutePath.TrimEnd(new char[] { '/' });
            }
            else
            {
                if (httpContext.Request.Url.Host.ToLower() == Hyperlink.Domain)
                {
                    Core.PagePath = httpContext.Request.RawUrl.TrimEnd(new char[] { '/' });
                }
                else
                {
                    Core.PagePath = "/";
                }
            }

            #if DEBUG
            Stopwatch httpTimer = new Stopwatch();
            httpTimer.Start();
            #endif
            session = new SessionState(Core, db, User, HttpContext.Current.Request, HttpContext.Current.Response);
            loggedInMember = session.LoggedInMember;
            #if DEBUG
            httpTimer.Stop();
            HttpContext.Current.Response.Write(string.Format("<!-- section A in {0} -->\r\n", httpTimer.ElapsedTicks / 10000000.0));
            #endif

            long loadStart = initTimer.ElapsedTicks;

            tz = new UnixTime(core, UnixTime.UTC_CODE);

            core.Session = session;
            core.CoreDomain = AppDomain.CurrentDomain;

            if (loggedInMember != null)
            {
                tz = loggedInMember.UserInfo.GetTimeZone;
            }

            // move it here
            core.Tz = tz;

            // As a security measure we use the http object to prevent
            // applications hijacking the response output
            core.Http = new Http();
            Template.Path = core.Http.TemplatePath;

            core.Prose = new Prose();
            core.Prose.Initialise(core, "en");

            //List<string> asmNames = core.GetLoadedAssemblyNames();
            foreach (string asm in BoxSocial.Internals.Application.AssemblyNames.Keys)
            {
                core.Prose.AddApplication(asm);
            }

            //List<Assembly> asms = core.GetLoadedAssemblies();
            foreach (Assembly asm in BoxSocial.Internals.Application.LoadedAssemblies.Values)
            {
                template.AddPageAssembly(asm);
            }

            template.SetProse(core.Prose);

            string pageString = core.Http.Query["p"];
            if (!string.IsNullOrEmpty(pageString))
            {
                string[] pages = pageString.Split(new char[] { ',' });
                page = new int[pages.Length];

                for (int i = 0; i < pages.Length; i++)
                {
                    if (!int.TryParse(pages[i], out page[i]))
                    {
                        page[i] = 1;
                    }
                }
            }
            else
            {
                page = new int[] { 1 };
            }

            string offsetString = core.Http.Query["o"];
            if (!string.IsNullOrEmpty(offsetString))
            {
                string[] offsets = offsetString.Split(new char[] { ',' });
                offset = new long[offsets.Length];

                for (int i = 0; i < offsets.Length; i++)
                {
                    if (!long.TryParse(offsets[i], out offset[i]))
                    {
                        offset[i] = 0;
                    }
                }
            }
            else
            {
                offset = new long[] { 0 };
            }

               if (session != null && session.SignedIn && core.IsMobile && core.ResponseFormat == ResponseFormats.Html)
               {
                List<ApplicationEntry> applications = BoxSocial.Internals.Application.GetApplications(core, core.Session.LoggedInMember);

                foreach (ApplicationEntry ae in applications)
                {
                    BoxSocial.Internals.Application.LoadApplication(core, AppPrimitives.Member, ae);
                }

                core.InvokePostHooks(new HookEventArgs(core, AppPrimitives.Member, core.Session.LoggedInMember));
            }

            loadTime = (initTimer.ElapsedTicks - loadStart);
            initTimer.Stop();
            initTime += initTimer.ElapsedTicks;
        }