/// <summary> /// Initializes a new instance of the ControlPanelSubModule class. /// </summary> /// <param name="core">The Core token.</param> public ControlPanelSubModule(Core core, Primitive owner) { this.core = core; this.db = core.Db; this.session = core.Session; this.tz = core.Tz; this.LoggedInMember = session.LoggedInMember; this.Owner = owner; core.Prose.AddApplication(Assembly.GetAssembly(this.GetType()).GetName().Name); }
/// <summary> /// We do this so we don't have to keep re-declaring the same /// constructor /// </summary> /// <param name="core">Core token</param> /// <param name="owner">Owner</param> public void ModuleVector(Core core, Primitive owner, VariableCollection vc) { if (core == null) { throw new NullCoreException(); } this.core = core; this.db = core.Db; this.session = core.Session; this.tz = core.Tz; this.Owner = owner; this.LoggedInMember = session.LoggedInMember; this.parentModulesVariableCollection = vc; CreateTemplate(); string mode = core.Http["mode"]; EventHandler loadHandler = Load; if (loadHandler != null) { loadHandler(this, new EventArgs()); } if (string.IsNullOrEmpty(mode) || !HasModeHandler(mode)) { EventHandler showHandler = Show; if (showHandler != null) { showHandler(this, new EventArgs()); } } else if (!string.IsNullOrEmpty(mode)) { ShowMode(mode); } RenderTemplate(); }
/// <summary> /// Bind the module to the account panel. /// </summary> /// <param name="account"></param> private void Bind(Account account) { account.RegisterModule += new Account.RegisterModuleHandler(RegisterModule); core = account.core; page = account.core.page; db = account.core.Db; loggedInMember = account.core.Session.LoggedInMember; tz = account.core.Tz; session = account.core.Session; }
/// <summary> /// Creates a new session and associates it with Core /// </summary> /// <param name="user"></param> /// <remarks>Use by Installer to initiate a session into Core</remarks> public void CreateNewSession(User user) { session = new SessionState(this, user); }
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; }