private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); //if (Request.Form.Count > 0) //{ // submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post //} if (Request.Form["html"] != null) { submittedContent = Request.Form["html"]; //log.Info("html does = " + Request.Form["html"]); } //using (Stream s = Request.InputStream) //{ // using (StreamReader sr = new StreamReader(s)) // { // string requestBody = sr.ReadToEnd(); // requestBody = Server.UrlDecode(requestBody); // log.Info("requestBody was " + requestBody); // JObject jObj = JObject.Parse(requestBody); // submittedContent = (string)jObj["html"]; // } //} module = GetHtmlModule(); if (module == null) { return; } currentUser = SiteUtils.GetCurrentSiteUser(); repository = new HtmlRepository(); moduleSettings = ModuleSettings.GetModuleSettings(module.ModuleId); config = new HtmlConfiguration(moduleSettings); enableContentVersioning = config.EnableContentVersioning; if ((CurrentSite.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } userCanOnlyEditAsDraft = UserCanOnlyEditModuleAsDraft(module.ModuleId, HtmlContent.FeatureGuid); if ((WebConfigSettings.EnableContentWorkflow) && (CurrentSite.EnableContentWorkflow)) { workInProgress = ContentWorkflow.GetWorkInProgress(module.ModuleGuid); } if (workInProgress != null) { switch (workInProgress.Status) { case ContentWorkflowStatus.Draft: //there is a draft version currently available, therefore dont allow the non draft version to be edited: if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.ApprovalRejected: //rejected content - allow update as draft only if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.AwaitingApproval: //pending approval - dont allow any edited: // 2010-01-18 let editors update the draft if they want to before approving it. editDraft = !userCanOnlyEditAsDraft; break; } } //for (int i = 0; i < Request.QueryString.Count; i++) //{ // log.Info(Request.QueryString.GetKey(i) + " query param = " + Request.QueryString.Get(i)); //} //if (Request.Form["c"] != null) //{ // submittedContent = Request.Form["c"]; // log.Info("c does = " + Request.Form["c"]); //} // this shows that a large html content post appears as multiple params //for (int i = 0; i < Request.Form.Count; i++) //{ // log.Info(Request.Form.GetKey(i) + " form param " + i.ToInvariantString() + " = " + Request.Form.Get(i)); //} }
private void LoadModuleSettings() { moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new HtmlConfiguration(moduleSettings); }
/// <summary> /// Edits the page. /// </summary> /// <param name="blogId"> /// The blog id. /// </param> /// <param name="pageId"> /// The page id. /// </param> /// <param name="userName"> /// The user name. /// </param> /// <param name="password"> /// The password. /// </param> /// <param name="mwaPage"> /// The m page. /// </param> /// <param name="publish"> /// The publish. /// </param> /// <returns> /// The edit page. /// </returns> internal bool EditPage(string blogId, string pageId, string userName, string password, MWAPage mwaPage, bool publish) { if ((string.IsNullOrEmpty(pageId))||(pageId.Length != 36)) { throw new MetaWeblogException("11", MetaweblogResources.PageNotFound); } PageSettings page = CacheHelper.GetPage(new Guid(pageId)); if (page.PageId == -1) { //doesn't exist throw new MetaWeblogException("11", MetaweblogResources.PageNotFound); } if (page.SiteId != siteSettings.SiteId) { //doesn't exist throw new MetaWeblogException("11", MetaweblogResources.PageNotFound); } //if (!publish) //{ // throw new MetaWeblogException("11", "Sorry draft pages are not supported through this API."); //} Module m = GetFirstCenterPaneHtmlModule(page); if (m == null) { throw new MetaWeblogException("11", MetaweblogResources.ContentInstanceNotFound); } if (!UserCanEdit(page, m)) { throw new MetaWeblogException("11", MetaweblogResources.AccessDenied); } PageSettings parentPage = null; Hashtable moduleSettings = ModuleSettings.GetModuleSettings(m.ModuleId); HtmlConfiguration config = new HtmlConfiguration(moduleSettings); HtmlRepository repository = new HtmlRepository(); HtmlContent html = repository.Fetch(m.ModuleId); if (html == null) { html = new HtmlContent(); html.ModuleId = m.ModuleId; html.ModuleGuid = m.ModuleGuid; } bool titleChanged = (m.ModuleTitle != mwaPage.title); // updated 2011-11-30 don't change page name for existing pages // only update the module title // avoid changing the home page name // while most content pages should have the module title the same as the page name for best seo // this is usually not the case for the home page, ie the content is not titled "home" //if (!IsHomePage(page.PageId)) //{ // page.PageName = mwaPage.title; //} if (titleChanged) { m.ModuleTitle = mwaPage.title; m.Save(); } html.Body = mwaPage.description; if ((mwaPage.mt_keywords != null) &&(mwaPage.mt_keywords.Length > 0)) { page.PageMetaKeyWords = mwaPage.mt_keywords; } bool needToClearSiteMapCache = false; bool pageOrderChanged = false; if ((mwaPage.pageOrder != null)&&(mwaPage.pageOrder.Length > 0)) { int newPageOrder = Convert.ToInt32(mwaPage.pageOrder); if (page.PageOrder != newPageOrder) { page.PageOrder = newPageOrder; needToClearSiteMapCache = true; pageOrderChanged = true; } } bool makeDraft = !publish; if (page.IsPending != makeDraft) { page.IsPending = makeDraft; needToClearSiteMapCache = true; } if ((mwaPage.pageParentID != null) &&(mwaPage.pageParentID.Length == 36)) { Guid parentGuid = new Guid(mwaPage.pageParentID); if (page.PageGuid == parentGuid) { throw new MetaWeblogException("11", MetaweblogResources.PageCantBeItsOwnParent); } // if parent pageid hasn't changed no need to doo anything if (parentGuid != page.ParentGuid) { if (parentGuid == Guid.Empty) { if (UserCanCreateRootLevelPages()) { page.ParentId = -1; page.PageGuid = Guid.Empty; needToClearSiteMapCache = true; } else { throw new MetaWeblogException("11", MetaweblogResources.NotAllowedToCreateRootPages); } } else { parentPage = new PageSettings(parentGuid); if (parentPage.SiteId != siteSettings.SiteId) { throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound); } if ( (parentPage.PageId > -1) && (parentPage.PageId != page.PageId) // page cannot be its own parent && (parentPage.ParentId != page.PageId) // a child of the page cannot become its parent ) { // parent page exists //verify user can create pages below parent if (!UserCanCreateChildPages(parentPage)) { throw new MetaWeblogException("11", MetaweblogResources.NotAllowedParentPage); } // descendant of page (grandchildren cannot become parent) // so make sure selected parent is not a descendant of the current page if (IsValidParentPage(page, parentPage)) { page.ParentId = parentPage.PageId; page.PageGuid = parentPage.PageGuid; needToClearSiteMapCache = true; } else { throw new MetaWeblogException("11", MetaweblogResources.DescendentParentsNotAllowed); } } } } } // keep verison history if enabled bool enableContentVersioning = config.EnableContentVersioning; if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } if ((html.ItemId > -1)&&(enableContentVersioning)) { html.CreateHistory(siteSettings.SiteGuid); } html.LastModUserGuid = siteUser.UserGuid; html.LastModUtc = DateTime.UtcNow; page.LastModifiedUtc = DateTime.UtcNow; html.ModuleGuid = m.ModuleGuid; html.ContentChanged += new ContentChangedEventHandler(html_ContentChanged); repository.Save(html); CacheHelper.ClearModuleCache(m.ModuleId); switch (mwaPage.commentPolicy) { //closed case "0": case "2": page.EnableComments = false; break; // open case "1": // if the post was previously closed to comments // re-open it using the default allowed days page.EnableComments = true; break; //else unspecified, no change } if (page.UrlHasBeenAdjustedForFolderSites) { page.Url = page.UnmodifiedUrl; } page.Save(); if (pageOrderChanged) { if ((parentPage == null) && (page.ParentGuid != Guid.Empty)) { parentPage = new PageSettings(page.ParentGuid); } } if (parentPage != null) { parentPage.ResortPages(); } if (needToClearSiteMapCache) { CacheHelper.ResetSiteMapCache(siteSettings.SiteId); } SiteUtils.QueueIndexing(); return true; }
private void LoadSettings() { Title1.EditUrl = SiteRoot + "/HtmlEdit.aspx"; Title1.EditText = Resource.EditImageAltText; Title1.ToolTip = Resource.EditImageAltText; Title1.Visible = !this.RenderInWebPartMode; timeZone = SiteUtils.GetUserTimeZone(); if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor())) { isAdmin = true; Title1.IsAdminEditor = isAdmin; } if (IsEditable) { TitleUrl = SiteRoot + "/HtmlEdit.aspx" + "?mid=" + ModuleId.ToInvariantString() + "&pageid=" + currentPage.PageId.ToInvariantString(); } config = new HtmlConfiguration(Settings); if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if ((config.IncludeSwfObject)&&(Page is mojoBasePage)) { mojoBasePage p = Page as mojoBasePage; if (p != null) { p.ScriptConfig.IncludeSwfObject = true; } } if (this.ModuleConfiguration != null) { this.Title = this.ModuleConfiguration.ModuleTitle; this.Description = this.ModuleConfiguration.FeatureName; } if (config.EnableContentRatingSetting && !displaySettings.DisableContentRating) { if (displaySettings.UseBottomContentRating) { RatingBottom.Enabled = config.EnableContentRatingSetting; RatingBottom.AllowFeedback = config.EnableRatingCommentsSetting; RatingBottom.ContentGuid = ModuleGuid; } else { Rating.Enabled = config.EnableContentRatingSetting; Rating.AllowFeedback = config.EnableRatingCommentsSetting; Rating.ContentGuid = ModuleGuid; } } //pnlContainer.ModuleId = this.ModuleId; if (config.EnableSlideShow) { divContent.EnableSlideShow = true; divContent.EnableSlideClick = config.EnableSlideClick; divContent.Random = config.RandomizeSlides; divContent.CleartypeNoBg = !config.UseSlideClearTypeCorrections; divContent.SlideContainerClass = config.SlideContainerClass; divContent.PauseOnHover = config.PauseSlideOnHover; divContent.TransitionEffect = config.SlideTransitions; divContent.TransitionInterval = config.SlideDuration; divContent.Speed = config.TransitionSpeed; if (config.SlideContainerHeight > 0) { divContent.ContainerHeight = config.SlideContainerHeight.ToInvariantString() + "px"; } if (config.EnableSlideShowPager) { divContent.Pager = "cyclenav"; if (config.SlideShowPagerBefore) { divContent.PagerBefore = true; } } } if (displaySettings.UseHtml5Elements) { if (displaySettings.UseOuterBodyForHtml5Article) { pnlOuterBody.Element = "article"; } else { pnlInnerWrap.Element = "article"; } //if (!IsPostBack) //{ // Title1.LiteralExtraTopContent += "<header>"; // Title1.LiteralExtraBottomContent += "</header>"; // this was a bug just use the theme value //} } if (EnableWorkflow) { //use mojo base page to see if user has toggled draft content: CmsPage cmsPage = this.Page as CmsPage; if (cmsPage != null) { if (cmsPage.ViewMode == PageViewMode.WorkInProgress) { //try to get draft content: workInProgress = ContentWorkflow.GetWorkInProgress(this.ModuleGuid); } } } if ((IsEditable) && (WebConfigSettings.EnableInlineEditing)) { if((WebConfigSettings.TinyMceUseV4)&&(siteSettings.EditorProviderName == "TinyMCEProvider")) { SetupTinyMceInline(); } else { SetupCKEditorInline(); } } }