public void Load() { this.TheSite = SiteData.CurrentSite; if (SecurityData.AdvancedEditMode && !this.IsPageLocked) { using (ContentPageHelper pageHelper = new ContentPageHelper()) { bool bRet = pageHelper.RecordPageLock(this.ThePage.Root_ContentID, this.TheSite.SiteID, SecurityData.CurrentUserGuid); } } CMSConfigHelper.IdentifyLinkAsInactive(this.ThePage); Guid guidContentID = Guid.Empty; if (this.ThePage != null) { guidContentID = this.ThePage.Root_ContentID; this.TheWidgets = SiteData.GetCurrentPageWidgets(guidContentID); } else { this.ThePage = new ContentPage(); this.TheWidgets = new List <Widget>(); } }
public List <ContentCategory> GetPageCategories(int takeTop) { if (takeTop < 0) { takeTop = 300000; } if (SecurityData.AdvancedEditMode && !this.IsPageLocked) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.ThePage.FileName); if (cmsHelper.cmsAdminContent != null) { return(cmsHelper.cmsAdminContent.ContentCategories.Take(takeTop).ToList()); } } } else { using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { return(navHelper.GetCategoryListForPost(this.TheSite.SiteID, takeTop, this.ThePage.Root_ContentID)); } } return(new List <ContentCategory>()); }
public void GrabAttachments(string folderName, WordPressSite wpSite) { int iPost = this.PostID; List <WordPressPost> lstA = (from a in wpSite.Content where a.PostType == WordPressPost.WPPostType.Attachment && a.ParentPostID == iPost select a).Distinct().ToList(); lstA.ToList().ForEach(q => q.ImportFileSlug = folderName + "/" + q.ImportFileSlug); lstA.ToList().ForEach(q => q.ImportFileSlug = q.ImportFileSlug.Replace("//", "/").Replace("//", "/")); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { foreach (var img in lstA) { img.ImportFileSlug = img.ImportFileSlug.Replace("//", "/").Replace("//", "/"); cmsHelper.GetFile(img.AttachmentURL, img.ImportFileSlug); string sURL1 = img.AttachmentURL.Substring(img.AttachmentURL.IndexOf("://") + 3); string sURLLess = sURL1.Substring(sURL1.IndexOf("/")); this.PostContent = this.PostContent.Replace(img.AttachmentURL, img.ImportFileSlug); } } }
public static string GetSampleBody(Control X, string sContentSampleNumber) // SampleContent2 { if (String.IsNullOrEmpty(sContentSampleNumber)) { sContentSampleNumber = "SampleContent2"; } string sFile2 = " <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi arcu, lacinia scelerisque blandit nec, mattis non nibh.</p> \r\n <p> Curabitur quis urna at massa placerat auctor. Quisque et mauris sapien, a consectetur nulla.</p>"; try { Assembly _assembly = Assembly.GetExecutingAssembly(); using (StreamReader oTextStream = new StreamReader(_assembly.GetManifestResourceStream("Carrotware.CMS.Core.SiteContent.Mock." + sContentSampleNumber + ".txt"))) { sFile2 = oTextStream.ReadToEnd(); } List <string> imageNames = (from i in _assembly.GetManifestResourceNames() where i.Contains("SiteContent.Mock.sample") && i.EndsWith(".png") select i).ToList(); foreach (string img in imageNames) { var imgURL = CMSConfigHelper.GetWebResourceUrl(X, typeof(SiteNav), img); sFile2 = sFile2.Replace(img, imgURL); } } catch { } return(sFile2); }
public PostTemplateUpdateModel() : base() { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { this.SiteTemplateList = cmsHelper.Templates; } }
public SiteImportNativeModel() { this.CreateUsers = true; this.MapUsers = true; this.HasLoaded = false; using (ContentPageHelper pageHelper = new ContentPageHelper()) { this.PageCount = pageHelper.GetSitePageCount(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { this.Templates = cmsHelper.Templates; float iThird = (float)(this.PageCount - 1) / (float)3; Dictionary<string, float> dictTemplates = null; dictTemplates = pageHelper.GetPopularTemplateList(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry); if (dictTemplates.Count > 0 && dictTemplates.First().Value >= iThird) { try { this.PageTemplate = dictTemplates.First().Key; } catch { } } dictTemplates = pageHelper.GetPopularTemplateList(SiteData.CurrentSiteID, ContentPageType.PageType.BlogEntry); if (dictTemplates.Count > 0) { try { this.PostTemplate = dictTemplates.First().Key; } catch { } } } } }
protected void Page_Load(object sender, EventArgs e) { DatabaseUpdate du = new DatabaseUpdate(true); if (!String.IsNullOrEmpty(Request.QueryString["signout"])) { FormsAuthentication.SignOut(); } List<DatabaseUpdateMessage> lst = new List<DatabaseUpdateMessage>(); btnLogin.Visible = false; btnCreate.Visible = false; if (DatabaseUpdate.LastSQLError != null) { du.HandleResponse(lst, DatabaseUpdate.LastSQLError); DatabaseUpdate.LastSQLError = null; } else { bool bUpdate = true; if (!du.DoCMSTablesExist()) { bUpdate = false; } bUpdate = du.DatabaseNeedsUpdate(); if (bUpdate) { DatabaseUpdateStatus status = du.PerformUpdates(); lst = du.MergeMessages(lst, status.Messages); } else { DataInfo ver = DatabaseUpdate.GetDbSchemaVersion(); du.HandleResponse(lst, "Database up-to-date [" + ver.DataValue + "] "); } bUpdate = du.DatabaseNeedsUpdate(); if (!bUpdate && DatabaseUpdate.LastSQLError == null) { if (DatabaseUpdate.UsersExist) { btnLogin.Visible = true; } else { btnCreate.Visible = true; } } } if (DatabaseUpdate.LastSQLError != null) { du.HandleResponse(lst, DatabaseUpdate.LastSQLError); } if (lst.Where(x => !String.IsNullOrEmpty(x.ExceptionText)).Count() > 0) { bOK = false; } else { bOK = true; } GeneralUtilities.BindRepeater(rpMessages, lst.OrderBy(x => x.Order)); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.ResetConfigs(); } }
private void SaveSerialized(string sKey, string sData) { LoadGuids(); if (filePage != null) { CMSConfigHelper.SaveSerialized(filePage.Root_ContentID, sKey, sData); } }
protected void Page_Load(object sender, EventArgs e) { Master.ActivateTab(AdminBaseMasterPage.SectionID.TextWidget); if (!IsPostBack) { using (CMSConfigHelper cfg = new CMSConfigHelper()) { PickerValues = cfg.GetAllWidgetSettings(SiteID); gvContent.DataSource = PickerValues; gvContent.DataBind(); } } }
private bool ClearSerialized(string sKey) { LoadGuids(); if (filePage != null) { return(CMSConfigHelper.ClearSerialized(filePage.Root_ContentID, sKey)); } else { return(false); } }
private string GetSerialized(string sKey) { string sData = String.Empty; LoadGuids(); if (filePage != null) { sData = CMSConfigHelper.GetSerialized(filePage.Root_ContentID, sKey); } return(sData); }
// ====================================== private List <SiteNav> TweakData(List <SiteNav> nav) { if (nav != null) { nav.RemoveAll(x => x.ShowInSiteNav == false && x.ContentType == ContentPageType.PageType.ContentEntry); //nav.RemoveAll(x => x.ShowInSiteMap == false && x.ContentType == ContentPageType.PageType.ContentEntry); nav.ForEach(q => CMSConfigHelper.IdentifyLinkAsInactive(q)); } return(nav); }
public ContentPageModel() { this.InitSelections(); this.Mode = "html"; this.VisitPage = false; this.VersionHistory = new Dictionary<string, string>(); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { this.SiteTemplates = cmsHelper.Templates; } }
public SiteSkinModel(string encodedPath) : this() { this.EncodedPath = encodedPath; this.TemplateFile = CMSConfigHelper.DecodeBase64(encodedPath); this.FullFilePath = HttpContext.Current.Server.MapPath(this.TemplateFile); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { this.Template = cmsHelper.Templates.Where(x => x.TemplatePath.ToLower() == this.TemplateFile.ToLower()).FirstOrDefault(); } var ifo = new FileInfo(this.TemplateFile); this.TemplateFolder = ifo.Directory.FullName; this.EditFile = this.TemplateFile; }
public static PagePayload GetContent(string uri) { PagePayload page = new PagePayload(); if (SecurityData.AdvancedEditMode) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(uri); if (cmsHelper.cmsAdminContent == null) { page.ThePage = SiteData.GetPage(uri); if (!page.ThePage.IsPageLocked) { if (page.ThePage.ContentType == ContentPageType.PageType.BlogEntry) { var c = page.ThePage.ContentCategories; var t = page.ThePage.ContentTags; } cmsHelper.cmsAdminContent = page.ThePage; } else { cmsHelper.cmsAdminContent = null; } } else { page.ThePage = cmsHelper.cmsAdminContent; if (page.IsPageLocked) { cmsHelper.cmsAdminContent = null; page.ThePage = SiteData.GetPage(uri); } } } } else { page.ThePage = SiteData.GetPage(uri); } page.Load(); return(page); }
public static void SaveSerializedDataExport <T>(Guid guidKey, T theData) { if (theData == null) { CMSConfigHelper.ClearSerialized(guidKey, keyPageImport); } else { XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); string sXML = String.Empty; using (StringWriter stringWriter = new StringWriter()) { xmlSerializer.Serialize(stringWriter, theData); sXML = stringWriter.ToString(); } CMSConfigHelper.SaveSerialized(guidKey, keyPageImport, sXML); } }
protected void GetCtrlName() { string sName = String.Empty; if (this.Widget != null) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { CMSPlugin plug = (from p in cmsHelper.ToolboxPlugins where p.FilePath.ToLower() == this.Widget.ControlPath.ToLower() select p).FirstOrDefault(); if (plug != null) { sName = plug.Caption; } } } this.WidgetCaption = sName; }
public List <Widget> GetAllWidgetsOrUnsaved() { List <Widget> widgets = new List <Widget>(); using (CMSConfigHelper ch = new CMSConfigHelper()) { if (ch.cmsAdminContent == null) { widgets = this.GetWidgetList(); } else { widgets = (from w in ch.cmsAdminWidget orderby w.WidgetOrder, w.EditDate select w).ToList(); } } return(widgets); }
public static ContentPage GetCurrentPage() { ContentPage pageContents = null; if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminContent == null) { pageContents = GetCurrentLivePage(); pageContents.LoadAttributes(); cmsHelper.cmsAdminContent = pageContents; } else { pageContents = cmsHelper.cmsAdminContent; } } else { pageContents = GetCurrentLivePage(); if (pageContents == null && (!SiteData.CurretSiteExists || DatabaseUpdate.AreCMSTablesIncomplete())) { pageContents = ContentPageHelper.GetEmptyHome(); } if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminContent = null; } } } } else { pageContents = ContentPageHelper.GetSamplerView(); } return(pageContents); }
public ModuleInfo() { this.OpenTab = 0; this.SelectedTab = 0; this.SelectedCssClass = "notSelectedModule"; this.SelectedArea = CMSConfigHelper.PluginAreaPath; this.SelectedAreaName = String.Empty; this.SelectedPluginAreaName = String.Empty; this.SelectedPluginActionName = String.Empty; this.CurrentAction = String.Empty; this.CurrentController = String.Empty; this.CurrentActionFull = String.Empty; this.Modules = new List<CMSAdminModule>(); this.RouteValues = new RouteValueDictionary(); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { this.Modules = cmsHelper.AdminModules; } }
public static ContentPage GetCurrentPage() { ContentPage pageContents = null; if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminContent == null) { pageContents = GetCurrentLivePage(); pageContents.LoadAttributes(); cmsHelper.cmsAdminContent = pageContents; } else { pageContents = cmsHelper.cmsAdminContent; } } else { pageContents = GetCurrentLivePage(); if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminContent = null; } } } } else { pageContents = ContentPageHelper.GetSamplerView(); } return(pageContents); }
public void Save() { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { Widget ww = null; if (this.Root_ContentID.HasValue) { cmsHelper.OverrideKey(this.Root_ContentID.Value); this.Widgets = cmsHelper.cmsAdminWidget; ww = (from w in this.Widgets where w.Root_WidgetID == this.Root_WidgetID select w).FirstOrDefault(); } else { using (WidgetHelper widgetHelper = new WidgetHelper()) { ww = widgetHelper.Get(this.Root_WidgetID); } } if (ww != null) { ww.IsPendingChange = true; ww.IsWidgetActive = this.Widget.IsWidgetActive; ww.IsWidgetPendingDelete = this.Widget.IsWidgetPendingDelete; ww.EditDate = SiteData.CurrentSite.Now; ww.GoLiveDate = this.Widget.GoLiveDate; ww.RetireDate = this.Widget.RetireDate; if (this.Root_ContentID.HasValue) { this.Widgets.RemoveAll(x => x.Root_WidgetID == this.Root_WidgetID); this.Widgets.Add(ww); cmsHelper.cmsAdminWidget = this.Widgets.OrderBy(x => x.WidgetOrder).ToList(); } else { ww.Save(); } } } }
public static PagePayload GetContent(string uri) { PagePayload page = new PagePayload(); if (SecurityData.AdvancedEditMode) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(uri); if (cmsHelper.cmsAdminContent == null) { page.ThePage = SiteData.GetPage(uri); if (!page.ThePage.IsPageLocked) { if (page.ThePage.ContentType == ContentPageType.PageType.BlogEntry) { var c = page.ThePage.ContentCategories; var t = page.ThePage.ContentTags; } cmsHelper.cmsAdminContent = page.ThePage; } else { cmsHelper.cmsAdminContent = null; } } else { page.ThePage = cmsHelper.cmsAdminContent; if (page.IsPageLocked) { cmsHelper.cmsAdminContent = null; page.ThePage = SiteData.GetPage(uri); } } } } else { page.ThePage = SiteData.GetPage(uri); } page.Load(); return page; }
public static List <Widget> GetCurrentPageWidgets(Guid guidContentID) { List <Widget> pageWidgets = new List <Widget>(); if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminWidget == null) { pageWidgets = GetCurrentPageLiveWidgets(guidContentID); cmsHelper.cmsAdminWidget = (from w in pageWidgets orderby w.WidgetOrder, w.EditDate select w).ToList(); } else { pageWidgets = (from w in cmsHelper.cmsAdminWidget orderby w.WidgetOrder, w.EditDate select w).ToList(); } } else { pageWidgets = GetCurrentPageLiveWidgets(guidContentID); if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminWidget = null; } } } } return(pageWidgets); }
public void SaveTextWidgets() { if (this.ContentPage != null && this.ContentPage.Root_ContentID != Guid.Empty) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.ContentPage.Root_ContentID); if (cmsHelper.cmsAdminWidget != null) { var ww = (from w in cmsHelper.cmsAdminWidget where w.IsLatestVersion == true && w.IsPendingChange == true && (w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Components.ContentRichText,") || w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Components.ContentPlainText,")) select w); foreach (Widget w in ww) { w.Save(); } } cmsHelper.cmsAdminContent = null; cmsHelper.cmsAdminWidget = null; } } }
public void LoadPageControls() { this.CurrentWebPage.Header.Controls.Add(new Literal { Text = "\r\n" }); List<HtmlMeta> lstMD = GetHtmlMeta(this.CurrentWebPage.Header); HtmlMeta metaGenerator = new HtmlMeta(); metaGenerator.Name = "generator"; metaGenerator.Content = SiteData.CarrotCakeCMSVersion; this.CurrentWebPage.Header.Controls.Add(metaGenerator); this.CurrentWebPage.Header.Controls.Add(new Literal { Text = "\r\n" }); if (guidContentID == SiteData.CurrentSiteID && SiteData.IsPageReal) { IsPageTemplate = true; } if (theSite != null && pageContents != null) { if (theSite.BlockIndex || pageContents.BlockIndex) { bool bCrawlExist = false; HtmlMeta metaNoCrawl = new HtmlMeta(); metaNoCrawl.Name = "robots"; if (lstMD.Where(x => x.Name == "robots").Count() > 0) { metaNoCrawl = lstMD.Where(x => x.Name == "robots").FirstOrDefault(); bCrawlExist = true; } metaNoCrawl.Content = "noindex,nofollow,noarchive"; if (!bCrawlExist) { this.CurrentWebPage.Header.Controls.Add(metaNoCrawl); this.CurrentWebPage.Header.Controls.Add(new Literal { Text = "\r\n" }); } } } if (pageContents != null) { HtmlMeta metaDesc = new HtmlMeta(); HtmlMeta metaKey = new HtmlMeta(); bool bDescExist = false; bool bKeyExist = false; if (lstMD.Where(x => x.Name == "description").Count() > 0) { metaDesc = lstMD.Where(x => x.Name == "description").FirstOrDefault(); bDescExist = true; } if (lstMD.Where(x => x.Name == "keywords").Count() > 0) { metaKey = lstMD.Where(x => x.Name == "keywords").FirstOrDefault(); bKeyExist = true; } metaDesc.Name = "description"; metaKey.Name = "keywords"; metaDesc.Content = string.IsNullOrEmpty(pageContents.MetaDescription) ? theSite.MetaDescription : pageContents.MetaDescription; metaKey.Content = string.IsNullOrEmpty(pageContents.MetaKeyword) ? theSite.MetaKeyword : pageContents.MetaKeyword; int indexPos = 6; if (this.CurrentWebPage.Header.Controls.Count > indexPos) { if (!string.IsNullOrEmpty(metaDesc.Content) && !bDescExist) { this.CurrentWebPage.Header.Controls.AddAt(indexPos, new Literal { Text = "\r\n" }); this.CurrentWebPage.Header.Controls.AddAt(indexPos, metaDesc); } if (!string.IsNullOrEmpty(metaKey.Content) && !bKeyExist) { this.CurrentWebPage.Header.Controls.AddAt(indexPos, new Literal { Text = "\r\n" }); this.CurrentWebPage.Header.Controls.AddAt(indexPos, metaKey); } } else { if (!string.IsNullOrEmpty(metaDesc.Content) && !bDescExist) { this.CurrentWebPage.Header.Controls.Add(metaDesc); this.CurrentWebPage.Header.Controls.Add(new Literal { Text = "\r\n" }); } if (!string.IsNullOrEmpty(metaKey.Content) && !bKeyExist) { this.CurrentWebPage.Header.Controls.Add(metaKey); this.CurrentWebPage.Header.Controls.Add(new Literal { Text = "\r\n" }); } } metaDesc.Visible = !string.IsNullOrEmpty(metaDesc.Content); metaKey.Visible = !string.IsNullOrEmpty(metaKey.Content); } contCenter = new ContentContainer(); contLeft = new ContentContainer(); contRight = new ContentContainer(); if (pageContents != null) { using (ContentPageHelper pageHelper = new ContentPageHelper()) { PageViewType pvt = pageHelper.GetBlogHeadingFromURL(theSite, SiteData.CurrentScriptName); string sTitleAddendum = pvt.ExtraTitle; if (!string.IsNullOrEmpty(sTitleAddendum)) { if (!string.IsNullOrEmpty(pageContents.PageHead)) { pageContents.PageHead = pageContents.PageHead.Trim() + ": " + sTitleAddendum; } else { pageContents.PageHead = sTitleAddendum; } pageContents.TitleBar = pageContents.TitleBar.Trim() + ": " + sTitleAddendum; } PagedDataSummary pd = (PagedDataSummary)cu.FindControl(typeof(PagedDataSummary), this.CurrentWebPage); if (pd != null) { PagedDataSummaryTitleOption titleOpts = pd.TypeLabelPrefixes.Where(x => x.KeyValue == pvt.CurrentViewType).FirstOrDefault(); if (titleOpts == null && (pvt.CurrentViewType == PageViewType.ViewType.DateDayIndex || pvt.CurrentViewType == PageViewType.ViewType.DateMonthIndex || pvt.CurrentViewType == PageViewType.ViewType.DateYearIndex)) { titleOpts = pd.TypeLabelPrefixes.Where(x => x.KeyValue == PageViewType.ViewType.DateIndex).FirstOrDefault(); } if (titleOpts != null && !string.IsNullOrEmpty(titleOpts.FormatText)) { pvt.ExtraTitle = string.Format(titleOpts.FormatText, pvt.RawValue); sTitleAddendum = pvt.ExtraTitle; } if (titleOpts != null && !string.IsNullOrEmpty(titleOpts.LabelText)) { pageContents.PageHead = titleOpts.LabelText + " " + sTitleAddendum; pageContents.NavMenuText = pageContents.PageHead; pageContents.TitleBar = pageContents.PageHead; } } } this.CurrentWebPage.Title = SetPageTitle(pageContents); DateTime dtModified = theSite.ConvertSiteTimeToLocalServer(pageContents.EditDate); string strModifed = dtModified.ToString("r"); HttpContext.Current.Response.AppendHeader("Last-Modified", strModifed); HttpContext.Current.Response.Cache.SetLastModified(dtModified); DateTime dtExpire = DateTime.Now.AddSeconds(15); contCenter.Text = pageContents.PageText; contLeft.Text = pageContents.LeftPageText; contRight.Text = pageContents.RightPageText; contCenter.DatabaseKey = pageContents.Root_ContentID; contLeft.DatabaseKey = pageContents.Root_ContentID; contRight.DatabaseKey = pageContents.Root_ContentID; pageContents = CMSConfigHelper.IdentifyLinkAsInactive(pageContents); if (this.CurrentWebPage.User.Identity.IsAuthenticated) { HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); dtExpire = DateTime.Now.AddMinutes(-10); HttpContext.Current.Response.Cache.SetExpires(dtExpire); if (!SecurityData.AdvancedEditMode) { if (SecurityData.IsAdmin || SecurityData.IsSiteEditor) { if (!SiteData.IsPageSampler && !IsPageTemplate) { Control editor = this.CurrentWebPage.LoadControl(SiteFilename.EditNotifierControlPath); this.CurrentWebPage.Form.Controls.Add(editor); } } } else { contCenter.IsAdminMode = true; contLeft.IsAdminMode = true; contRight.IsAdminMode = true; contCenter.ZoneChar = "c"; contLeft.ZoneChar = "l"; contRight.ZoneChar = "r"; contCenter.TextZone = ContentContainer.TextFieldZone.TextCenter; contLeft.TextZone = ContentContainer.TextFieldZone.TextLeft; contRight.TextZone = ContentContainer.TextFieldZone.TextRight; contCenter.Text = pageContents.PageText; contLeft.Text = pageContents.LeftPageText; contRight.Text = pageContents.RightPageText; Control editor = this.CurrentWebPage.LoadControl(SiteFilename.AdvancedEditControlPath); this.CurrentWebPage.Form.Controls.Add(editor); MarkWidgets(this.CurrentWebPage, true); } } else { HttpContext.Current.Response.Cache.SetExpires(dtExpire); } if (pageWidgets.Count > 0) { CMSConfigHelper cmsHelper = new CMSConfigHelper(); //find each placeholder in use ONCE! List<LabeledControl> lstPlaceholders = (from ph in pageWidgets where ph.Root_ContentID == pageContents.Root_ContentID select new LabeledControl { ControlLabel = ph.PlaceholderName, KeyControl = FindTheControl(ph.PlaceholderName, this.CurrentWebPage) }).Distinct().ToList(); List<Widget> lstWidget = null; if (SecurityData.AdvancedEditMode) { lstWidget = (from w in pageWidgets orderby w.WidgetOrder, w.EditDate where w.Root_ContentID == pageContents.Root_ContentID && w.IsWidgetActive == true && w.IsWidgetPendingDelete == false select w).ToList(); } else { lstWidget = (from w in pageWidgets orderby w.WidgetOrder, w.EditDate where w.Root_ContentID == pageContents.Root_ContentID && w.IsWidgetActive == true && w.IsRetired == false && w.IsUnReleased == false && w.IsWidgetPendingDelete == false select w).ToList(); } Assembly a = Assembly.GetExecutingAssembly(); foreach (Widget theWidget in lstWidget) { WidgetContainer plcHolder = (WidgetContainer)(from d in lstPlaceholders where d.ControlLabel == theWidget.PlaceholderName select d.KeyControl).FirstOrDefault(); if (plcHolder != null) { plcHolder.EnableViewState = true; Control widget = new Control(); if (theWidget.ControlPath.EndsWith(".ascx")) { if (File.Exists(this.CurrentWebPage.Server.MapPath(theWidget.ControlPath))) { try { widget = this.CurrentWebPage.LoadControl(theWidget.ControlPath); } catch (Exception ex) { Literal lit = new Literal(); lit.Text = "<b>ERROR: " + theWidget.ControlPath + "</b> <br />\r\n" + ex.ToString(); widget = lit; } } else { Literal lit = new Literal(); lit.Text = "MISSING FILE: " + theWidget.ControlPath + "<br />\r\n"; widget = lit; } } if (theWidget.ControlPath.ToLower().StartsWith("class:")) { try { string className = theWidget.ControlPath.Replace("CLASS:", ""); Type t = Type.GetType(className); Object o = Activator.CreateInstance(t); if (o != null) { widget = o as Control; } else { Literal lit = new Literal(); lit.Text = "OOPS: " + theWidget.ControlPath + "<br />\r\n"; widget = lit; } } catch (Exception ex) { Literal lit = new Literal(); lit.Text = "<b>ERROR: " + theWidget.ControlPath + "</b> <br />\r\n" + ex.ToString(); widget = lit; } } widget.EnableViewState = true; IWidget w = null; if (widget is IWidget) { w = widget as IWidget; w.SiteID = SiteData.CurrentSiteID; w.PageWidgetID = theWidget.Root_WidgetID; w.RootContentID = theWidget.Root_ContentID; } if (widget is IWidgetParmData) { IWidgetParmData wp = widget as IWidgetParmData; List<WidgetProps> lstProp = theWidget.ParseDefaultControlProperties(); wp.PublicParmValues = lstProp.ToDictionary(t => t.KeyName, t => t.KeyValue); } if (widget is IWidgetRawData) { IWidgetRawData wp = widget as IWidgetRawData; wp.RawWidgetData = theWidget.ControlProperties; } if (widget is IWidgetEditStatus) { IWidgetEditStatus wes = widget as IWidgetEditStatus; wes.IsBeingEdited = SecurityData.AdvancedEditMode; } Dictionary<string, string> lstMenus = new Dictionary<string, string>(); if (widget is IWidgetMultiMenu) { IWidgetMultiMenu wmm = widget as IWidgetMultiMenu; lstMenus = wmm.JSEditFunctions; } if (SecurityData.AdvancedEditMode) { WidgetWrapper plcWrapper = plcHolder.AddWidget(widget, theWidget); CMSPlugin plug = (from p in cmsHelper.ToolboxPlugins where p.FilePath.ToLower() == plcWrapper.ControlPath.ToLower() select p).FirstOrDefault(); if (plug != null) { plcWrapper.ControlTitle = plug.Caption; } plcWrapper.ID = WrapCtrlId; if (w != null) { if (w.EnableEdit) { if (lstMenus.Count < 1) { string sScript = w.JSEditFunction; if (string.IsNullOrEmpty(sScript)) { sScript = "cmsGenericEdit('" + pageContents.Root_ContentID + "','" + plcWrapper.DatabaseKey + "')"; } plcWrapper.JSEditFunction = sScript; } else { plcWrapper.JSEditFunctions = lstMenus; } } } } else { plcHolder.AddWidget(widget); } widget.ID = CtrlId; } } cmsHelper.Dispose(); } } }
public void RefreshWidgetList() { this.WidgetListHtml = new List<Widget>(); this.WidgetListText = new List<Widget>(); if (this.ContentPage != null && this.ContentPage.Root_ContentID != Guid.Empty) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.ContentPage.Root_ContentID); this.WidgetListHtml = (from w in cmsHelper.cmsAdminWidget where w.IsLatestVersion == true && w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Components.ContentRichText,") select w).ToList(); this.WidgetListText = (from w in cmsHelper.cmsAdminWidget where w.IsLatestVersion == true && w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Components.ContentPlainText,") select w).ToList(); } } }
public static string GetSerialized(Guid itemID) { return(CMSConfigHelper.GetSerialized(itemID, keyPageImport)); }
public static ContentPage GetCurrentPage() { ContentPage pageContents = null; if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminContent == null) { pageContents = GetCurrentLivePage(); pageContents.LoadAttributes(); cmsHelper.cmsAdminContent = pageContents; } else { pageContents = cmsHelper.cmsAdminContent; } } else { pageContents = GetCurrentLivePage(); if (pageContents == null && (!SiteData.CurretSiteExists || DatabaseUpdate.AreCMSTablesIncomplete())) { pageContents = ContentPageHelper.GetEmptyHome(); } if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminContent = null; } } } } else { pageContents = ContentPageHelper.GetSamplerView(); } return pageContents; }
public static bool HasAdminModules() { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { return(cmsHelper.AdminModules.Any()); } }
public static void RemoveSerializedExportData(Guid rootContentID) { CMSConfigHelper.ClearSerialized(rootContentID, keyPageImport); }
public ActionResult ResetVars() { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.ResetConfigs(); } return RedirectToAction("SiteInfo"); }
public ActionResult DatabaseSetup(string signout) { DatabaseSetupModel model = new DatabaseSetupModel(); DatabaseUpdate du = new DatabaseUpdate(true); if (!String.IsNullOrEmpty(signout)) { SignOut(); } List<DatabaseUpdateMessage> lst = new List<DatabaseUpdateMessage>(); model.Messages = lst; if (DatabaseUpdate.LastSQLError != null) { du.HandleResponse(lst, DatabaseUpdate.LastSQLError); DatabaseUpdate.LastSQLError = null; } else { bool bUpdate = true; if (!du.DoCMSTablesExist()) { bUpdate = false; } bUpdate = du.DatabaseNeedsUpdate(); try { model.CreateUser = !DatabaseUpdate.UsersExist; } catch { } if (bUpdate) { DatabaseUpdateStatus status = du.PerformUpdates(); lst = du.MergeMessages(lst, status.Messages); } else { DataInfo ver = DatabaseUpdate.GetDbSchemaVersion(); du.HandleResponse(lst, "Database up-to-date [" + ver.DataValue + "] "); } bUpdate = du.DatabaseNeedsUpdate(); if (!bUpdate && DatabaseUpdate.LastSQLError == null) { model.CreateUser = !DatabaseUpdate.UsersExist; } } if (DatabaseUpdate.LastSQLError != null) { du.HandleResponse(lst, DatabaseUpdate.LastSQLError); } model.HasExceptions = lst.Where(x => !String.IsNullOrEmpty(x.ExceptionText)).Any(); model.Messages = lst; using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.ResetConfigs(); } return View(model); }
public static ContentPage GetCurrentPage() { ContentPage pageContents = null; if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminContent == null) { pageContents = GetCurrentLivePage(); pageContents.LoadAttributes(); cmsHelper.cmsAdminContent = pageContents; } else { pageContents = cmsHelper.cmsAdminContent; } } else { pageContents = GetCurrentLivePage(); if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminContent = null; } } } } else { pageContents = ContentPageHelper.GetSamplerView(); } return pageContents; }
public void GrabAttachments(string folderName, WordPressSite wpSite) { int iPost = this.PostID; List<WordPressPost> lstA = (from a in wpSite.Content where a.PostType == WordPressPost.WPPostType.Attachment && a.ParentPostID == iPost select a).Distinct().ToList(); lstA.ToList().ForEach(q => q.ImportFileSlug = folderName + "/" + q.ImportFileSlug); lstA.ToList().ForEach(q => q.ImportFileSlug = q.ImportFileSlug.Replace("//", "/").Replace("//", "/")); using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { foreach (var img in lstA) { img.ImportFileSlug = img.ImportFileSlug.Replace("//", "/").Replace("//", "/"); cmsHelper.GetFile(img.AttachmentURL, img.ImportFileSlug); string sURL1 = img.AttachmentURL.Substring(img.AttachmentURL.IndexOf("://") + 3); string sURLLess = sURL1.Substring(sURL1.IndexOf("/")); this.PostContent = this.PostContent.Replace(img.AttachmentURL, img.ImportFileSlug); } } }
public void ProcessRequest(HttpContext context) { using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { SiteNav navData = null; string sFileRequested = context.Request.Path; sRequestedURL = sFileRequested; string sScrubbedURL = sFileRequested; sRequestedURL = SiteData.AppendDefaultPath(sRequestedURL); try { sScrubbedURL = SiteData.AlternateCurrentScriptName; if (sScrubbedURL.ToLower() != sRequestedURL.ToLower()) { sFileRequested = sScrubbedURL; bURLOverride = true; } VirtualDirectory.RegisterRoutes(); } catch (Exception ex) { //assumption is database is probably empty / needs updating, so trigger the under construction view if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete()) { if (navData == null) { navData = SiteNavHelper.GetEmptyHome(); } } else { //something bad has gone down, toss back the error throw; } } sFileRequested = SiteData.AppendDefaultPath(sFileRequested); if (context.User.Identity.IsAuthenticated) { try { if (context.Request.UrlReferrer != null && !string.IsNullOrEmpty(context.Request.UrlReferrer.AbsolutePath)) { if (context.Request.UrlReferrer.AbsolutePath.ToLower().Contains(FormsAuthentication.LoginUrl.ToLower()) || FormsAuthentication.LoginUrl.ToLower() == sFileRequested.ToLower()) { if (SiteFilename.DashboardURL.ToLower() != sFileRequested.ToLower() && SiteFilename.SiteInfoURL.ToLower() != sFileRequested.ToLower()) { sFileRequested = SiteData.AdminDefaultFile; } } } } catch (Exception ex) { } } if (sFileRequested.ToLower().EndsWith(".aspx") || SiteData.IsLikelyHomePage(sFileRequested)) { bool bIgnorePublishState = SecurityData.AdvancedEditMode || SecurityData.IsAdmin || SecurityData.IsSiteEditor; string queryString = String.Empty; queryString = context.Request.QueryString.ToString(); if (string.IsNullOrEmpty(queryString)) { queryString = String.Empty; } if (!CMSConfigHelper.CheckRequestedFileExistence(sFileRequested, SiteData.CurrentSiteID) || SiteData.IsLikelyHomePage(sFileRequested)) { context.Items[REQ_PATH] = context.Request.PathInfo; context.Items[REQ_QUERY] = context.Request.QueryString.ToString(); // handle a case where this site was migrated from a format where all pages varied on a consistent querystring // allow this QS parm to be set in a config file. if (SiteData.IsLikelyHomePage(sFileRequested)) { string sParm = String.Empty; if (SiteData.OldSiteQuerystring != string.Empty) { if (context.Request.QueryString[SiteData.OldSiteQuerystring] != null) { sParm = context.Request.QueryString[SiteData.OldSiteQuerystring].ToString(); } } if (!string.IsNullOrEmpty(sParm)) { sFileRequested = "/" + sParm + ".aspx"; SiteData.Show301Message(sFileRequested); context.Response.Redirect(sFileRequested); context.Items[REQ_PATH] = sFileRequested; context.Items[REQ_QUERY] = String.Empty; } } try { //periodic test of database up-to-dated-ness if (DatabaseUpdate.TablesIncomplete) { navData = SiteNavHelper.GetEmptyHome(); } else { bool bIsHomePage = false; if (SiteData.IsLikelyHomePage(sFileRequested)) { navData = navHelper.FindHome(SiteData.CurrentSiteID, !bIgnorePublishState); if (SiteData.IsLikelyHomePage(sFileRequested) && navData != null) { sFileRequested = navData.FileName; bIsHomePage = true; } } if (!bIsHomePage) { string pageName = sFileRequested; navData = navHelper.GetLatestVersion(SiteData.CurrentSiteID, !bIgnorePublishState, pageName); } if (SiteData.IsLikelyHomePage(sFileRequested) && navData == null) { navData = SiteNavHelper.GetEmptyHome(); } } } catch (Exception ex) { //assumption is database is probably empty / needs updating, so trigger the under construction view if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete()) { if (navData == null) { navData = SiteNavHelper.GetEmptyHome(); } } else { //something bad has gone down, toss back the error throw; } } if (navData != null) { string sSelectedTemplate = navData.TemplateFile; // selectivly engage the cms helper only if in advance mode if (SecurityData.AdvancedEditMode) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (cmsHelper.cmsAdminContent != null) { try { sSelectedTemplate = cmsHelper.cmsAdminContent.TemplateFile.ToLower(); } catch { } } } } if (!CMSConfigHelper.CheckFileExistence(sSelectedTemplate)) { sSelectedTemplate = SiteData.DefaultTemplateFilename; } sVirtualReqFile = sFileRequested; if (bURLOverride) { sVirtualReqFile = sRequestedURL; sFileRequested = sRequestedURL; } RewriteCMSPath(context, sSelectedTemplate, queryString); } else { SiteData.PerformRedirectToErrorPage(404, sFileRequested); SiteData.Show404MessageFull(true); } } else { sVirtualReqFile = sFileRequested; RewriteCMSPath(context, sVirtualReqFile, queryString); } } context.ApplicationInstance.CompleteRequest(); } }
protected void OverrideCache(ContentPage pageContents) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(pageContents.Root_ContentID); cmsHelper.cmsAdminContent = pageContents; cmsHelper.cmsAdminWidget = pageContents.GetWidgetList(); } }
protected void LoadData() { if (this.Root_ContentID.HasValue) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.Root_ContentID.Value); this.Widgets = cmsHelper.cmsAdminWidget; this.CachedWidget = true; if (this.Widget == null) { this.Widget = (from w in this.Widgets where w.Root_WidgetID == this.Root_WidgetID select w).FirstOrDefault(); } } } else { using (WidgetHelper widgetHelper = new WidgetHelper()) { if (this.Widget == null) { this.Widget = widgetHelper.Get(this.Root_WidgetID); this.Root_ContentID = this.Widget.Root_ContentID; } } } GetCtrlName(); }
public void Save() { this.CopyCount = 0; if (this.Widgets != null) { List<Guid> lstSel = this.Widgets.Where(x => x.Selected).Select(x => x.Root_WidgetID).ToList(); using (ContentPageHelper pageHelper = new ContentPageHelper()) { this.SelectedPage = pageHelper.FindContentByID(SiteData.CurrentSiteID, this.SelectedItem); this.Widgets = this.SelectedPage.GetWidgetList(); } using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.Root_ContentID); if (cmsHelper.cmsAdminWidget != null) { List<Widget> cacheWidget = cmsHelper.cmsAdminWidget; List<Widget> ww = (from w in this.SelectedPage.GetWidgetList() where lstSel.Contains(w.Root_WidgetID) && w.IsLatestVersion == true select w).ToList(); if (ww != null) { this.CopyCount = ww.Count; foreach (var w in ww) { Guid newWidget = Guid.NewGuid(); Widget wCpy = new Widget { Root_ContentID = this.Root_ContentID, Root_WidgetID = newWidget, WidgetDataID = Guid.NewGuid(), PlaceholderName = this.PlaceholderName, ControlPath = w.ControlPath, ControlProperties = w.ControlProperties, IsLatestVersion = true, IsPendingChange = true, IsWidgetActive = true, IsWidgetPendingDelete = false, WidgetOrder = w.WidgetOrder, GoLiveDate = w.GoLiveDate, RetireDate = w.RetireDate, EditDate = SiteData.CurrentSite.Now }; cacheWidget.Add(wCpy); } } cmsHelper.cmsAdminWidget = cacheWidget; } } } }
public static List<Widget> GetCurrentPageWidgets(Guid guidContentID) { List<Widget> pageWidgets = new List<Widget>(); if (IsWebView) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { if (SecurityData.AdvancedEditMode) { if (cmsHelper.cmsAdminWidget == null) { pageWidgets = GetCurrentPageLiveWidgets(guidContentID); cmsHelper.cmsAdminWidget = (from w in pageWidgets orderby w.WidgetOrder, w.EditDate select w).ToList(); } else { pageWidgets = (from w in cmsHelper.cmsAdminWidget orderby w.WidgetOrder, w.EditDate select w).ToList(); } } else { pageWidgets = GetCurrentPageLiveWidgets(guidContentID); if (SecurityData.CurrentUserGuid != Guid.Empty) { cmsHelper.cmsAdminWidget = null; } } } } return pageWidgets; }
public List<ContentCategory> GetPageCategories(int takeTop) { if (takeTop < 0) { takeTop = 300000; } if (SecurityData.AdvancedEditMode && !this.IsPageLocked) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.OverrideKey(this.ThePage.FileName); if (cmsHelper.cmsAdminContent != null) { return cmsHelper.cmsAdminContent.ContentCategories.Take(takeTop).ToList(); } } } else { using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { return navHelper.GetCategoryListForPost(this.TheSite.SiteID, takeTop, this.ThePage.Root_ContentID); } } return new List<ContentCategory>(); }
public ActionResult TextWidgetIndex() { List<CMSTextWidgetPicker> model = new List<CMSTextWidgetPicker>(); using (CMSConfigHelper cfg = new CMSConfigHelper()) { model = cfg.GetAllWidgetSettings(this.SiteID); } return View(model); }
public List<Widget> GetAllWidgetsOrUnsaved() { List<Widget> widgets = new List<Widget>(); using (CMSConfigHelper ch = new CMSConfigHelper()) { if (ch.cmsAdminContent == null) { widgets = this.GetWidgetList(); } else { widgets = (from w in ch.cmsAdminWidget orderby w.WidgetOrder, w.EditDate select w).ToList(); } } return widgets; }
public static bool HasAdminModules() { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { return cmsHelper.AdminModules.Count > 0; } }
protected void btnResetVars_Click(object sender, EventArgs e) { using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) { cmsHelper.ResetConfigs(); } }