public TileManagerPresenter(iApplicationContext oContext, IViewPageBase view) : base(oContext, view) { this.CurrentManager = new BaseModuleManager(oContext); }
/// <summary> /// If there is a PageTemplate instructions on the header, find the master page and set it /// </summary> /// <param name="site"></param> /// <param name="page">ViewPage / ViewMasterPage</param> private void SetMasterPageFile(cmSite site, IViewPageBase page) { if (!string.IsNullOrEmpty(page.PageTemplate) && page.PageTemplate.StartsWith("/")) { string cacheKey = string.Format("ViewPageEx.SetMasterPageFile.{0}.{1}.{2}" , site.DistinctName , page.AppRelativeVirtualPath , page.PageTemplate ); string masterPageFile = HttpRuntime.Cache[cacheKey] as string; if (masterPageFile == null) { { int count = 0; if (HttpContext.Current.Items["__master_page_count"] != null) { count = (int)HttpContext.Current.Items["__master_page_count"]; } HttpContext.Current.Items["__master_page_count"] = ++count; if (count > 10) { throw new Exception("Too many recurrences, please check the \"PageTemplate\" setting"); } } List <string> dependencyFiles = new List <string>(); { masterPageFile = string.Format("~/Views/{0}{1}", site.DistinctName, page.PageTemplate); string newPath = HostingEnvironment.MapPath(masterPageFile); dependencyFiles.Add(newPath); if (File.Exists(newPath)) { HttpRuntime.Cache.Insert(cacheKey , masterPageFile , new CacheDependencyEx(dependencyFiles.ToArray(), false) ); } else if (!string.IsNullOrWhiteSpace(site.TemplateDomainDistinctName)) { masterPageFile = string.Format("~/Views/{0}{1}", site.TemplateDomainDistinctName, page.PageTemplate); newPath = HostingEnvironment.MapPath(masterPageFile); dependencyFiles.Add(newPath); if (File.Exists(newPath)) { HttpRuntime.Cache.Insert(cacheKey , masterPageFile , new CacheDependencyEx(dependencyFiles.ToArray(), false) ); } else { masterPageFile = null; } } else { masterPageFile = null; } } } if (!string.IsNullOrEmpty(masterPageFile)) { page.MasterPageFile = masterPageFile; } } ViewMasterPageEx viewMasterPage = page.Master as ViewMasterPageEx; if (viewMasterPage != null) { viewMasterPage.SetPageTemplate(); SetMasterPageFile(site, viewMasterPage); } }