public static VisualInfo GetInstance() { var visualInfo = new VisualInfo(); if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["s"])) { visualInfo.publishmentSystemID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["s"]); } if (visualInfo.publishmentSystemID == 0) { visualInfo.publishmentSystemID = PathUtility.GetCurrentPublishmentSystemId(); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["n"])) { visualInfo.channelID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["n"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["c"])) { visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["c"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["f"])) { visualInfo.fileTemplateID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["f"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["p"])) { visualInfo.pageIndex = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["p"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["isPreview"])) { visualInfo.isPreview = TranslateUtils.ToBool(HttpContext.Current.Request.QueryString["isPreview"]); if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["previewID"])) { visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["previewID"]);//编辑界面预览 } } if (visualInfo.channelID > 0) { visualInfo.templateType = ETemplateType.ChannelTemplate; } if (visualInfo.contentID > 0 || visualInfo.isPreview) { visualInfo.templateType = ETemplateType.ContentTemplate; } if (visualInfo.fileTemplateID > 0) { visualInfo.templateType = ETemplateType.FileTemplate; } if (visualInfo.channelID == 0) { visualInfo.channelID = visualInfo.publishmentSystemID; } var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(visualInfo.publishmentSystemID); if (visualInfo.templateType == ETemplateType.IndexPageTemplate) { var templateInfo = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, 0, ETemplateType.IndexPageTemplate); var isHeadquarters = publishmentSystemInfo.IsHeadquarters; visualInfo.filePath = PathUtility.GetIndexPageFilePath(publishmentSystemInfo, templateInfo.CreatedFileFullName, isHeadquarters, visualInfo.pageIndex); } else if (visualInfo.templateType == ETemplateType.ChannelTemplate) { visualInfo.filePath = PathUtility.GetChannelPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.pageIndex); } else if (visualInfo.templateType == ETemplateType.ContentTemplate) { visualInfo.filePath = PathUtility.GetContentPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.contentID, visualInfo.pageIndex); } else if (visualInfo.templateType == ETemplateType.FileTemplate) { var templateInfo = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, visualInfo.fileTemplateID); visualInfo.filePath = PathUtility.MapPath(publishmentSystemInfo, templateInfo.CreatedFileFullName); } return(visualInfo); }
public static VisualInfo GetInstance(int siteId, int channelId, int contentId, int fileTemplateId, int pageIndex, int previewId) { if (siteId == 0) { siteId = PathUtility.GetCurrentSiteId(); } var visualInfo = new VisualInfo { SiteInfo = SiteManager.GetSiteInfo(siteId), ChannelId = channelId, ContentId = contentId, TemplateInfo = null, ContextType = EContextType.Undefined, IsPreview = false, FilePath = string.Empty, PageIndex = pageIndex }; if (visualInfo.SiteInfo == null) { return(visualInfo); } if (previewId > 0) { visualInfo.IsPreview = true; visualInfo.ContentId = previewId; } TemplateType templateType; if (visualInfo.ContentId > 0 || visualInfo.IsPreview) { templateType = TemplateType.ContentTemplate; } else if (fileTemplateId > 0) { templateType = TemplateType.FileTemplate; } else if (visualInfo.ChannelId > 0) { templateType = TemplateType.ChannelTemplate; } else { templateType = TemplateType.IndexPageTemplate; } if (visualInfo.ChannelId == 0) { visualInfo.ChannelId = visualInfo.SiteInfo.Id; } if (templateType == TemplateType.IndexPageTemplate) { visualInfo.TemplateInfo = TemplateManager.GetIndexPageTemplateInfo(visualInfo.SiteInfo.Id); visualInfo.ContextType = EContextType.Channel; visualInfo.FilePath = PathUtility.GetIndexPageFilePath(visualInfo.SiteInfo, visualInfo.TemplateInfo.CreatedFileFullName, visualInfo.SiteInfo.IsRoot, visualInfo.PageIndex); } else if (templateType == TemplateType.ChannelTemplate) { visualInfo.TemplateInfo = TemplateManager.GetChannelTemplateInfo(visualInfo.SiteInfo.Id, visualInfo.ChannelId); visualInfo.ContextType = EContextType.Channel; visualInfo.FilePath = PathUtility.GetChannelPageFilePath(visualInfo.SiteInfo, visualInfo.ChannelId, visualInfo.PageIndex); } else if (templateType == TemplateType.ContentTemplate) { visualInfo.TemplateInfo = TemplateManager.GetContentTemplateInfo(visualInfo.SiteInfo.Id, visualInfo.ChannelId); visualInfo.ContextType = EContextType.Content; visualInfo.FilePath = PathUtility.GetContentPageFilePath(visualInfo.SiteInfo, visualInfo.ChannelId, visualInfo.ContentId, visualInfo.PageIndex); } else if (templateType == TemplateType.FileTemplate) { visualInfo.TemplateInfo = TemplateManager.GetFileTemplateInfo(visualInfo.SiteInfo.Id, fileTemplateId); visualInfo.ContextType = EContextType.Undefined; visualInfo.FilePath = PathUtility.MapPath(visualInfo.SiteInfo, visualInfo.TemplateInfo.CreatedFileFullName); } return(visualInfo); }
//public static VisualInfo GetInstance() //{ // var siteId = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["s"]); ; // var channelId = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["n"]); ; // var contentId = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["c"]); // var fileTemplateId = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["f"]); // var pageIndex = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["p"]); // var previewId = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["previewId"]);//编辑界面预览 // return GetInstance(siteId, channelId, contentId, fileTemplateId, pageIndex, previewId); //} public static VisualInfo GetInstance(int siteId, int channelId, int contentId, int fileTemplateId, int pageIndex, int previewId) { var visualInfo = new VisualInfo { SiteId = siteId, ChannelId = channelId, ContentId = contentId, FileTemplateId = fileTemplateId, PageIndex = pageIndex }; if (visualInfo.SiteId == 0) { visualInfo.SiteId = PathUtility.GetCurrentSiteId(); } if (previewId > 0) { visualInfo.IsPreview = true; visualInfo.ContentId = previewId; } if (visualInfo.ChannelId > 0) { visualInfo.TemplateType = TemplateType.ChannelTemplate; } if (visualInfo.ContentId > 0 || visualInfo.IsPreview) { visualInfo.TemplateType = TemplateType.ContentTemplate; } if (visualInfo.FileTemplateId > 0) { visualInfo.TemplateType = TemplateType.FileTemplate; } if (visualInfo.ChannelId == 0) { visualInfo.ChannelId = visualInfo.SiteId; } var siteInfo = SiteManager.GetSiteInfo(visualInfo.SiteId); if (visualInfo.TemplateType == TemplateType.IndexPageTemplate) { var templateInfo = TemplateManager.GetIndexPageTemplateInfo(visualInfo.SiteId); var isHeadquarters = siteInfo.IsRoot; visualInfo.FilePath = PathUtility.GetIndexPageFilePath(siteInfo, templateInfo.CreatedFileFullName, isHeadquarters, visualInfo.PageIndex); } else if (visualInfo.TemplateType == TemplateType.ChannelTemplate) { visualInfo.FilePath = PathUtility.GetChannelPageFilePath(siteInfo, visualInfo.ChannelId, visualInfo.PageIndex); } else if (visualInfo.TemplateType == TemplateType.ContentTemplate) { visualInfo.FilePath = PathUtility.GetContentPageFilePath(siteInfo, visualInfo.ChannelId, visualInfo.ContentId, visualInfo.PageIndex); } else if (visualInfo.TemplateType == TemplateType.FileTemplate) { var templateInfo = TemplateManager.GetFileTemplateInfo(visualInfo.SiteId, visualInfo.FileTemplateId); visualInfo.FilePath = PathUtility.MapPath(siteInfo, templateInfo.CreatedFileFullName); } return(visualInfo); }