/// <summary> /// PreRender event handler. /// </summary> private void Page_PreRender(object sender, EventArgs e) { if (!StopProcessing) { switch (ViewMode) { case ViewModeEnum.Edit: case ViewModeEnum.EditDisabled: // Set enabled if (selPath != null) { selPath.Enabled = (ViewMode.IsEdit()); } if (lblError != null) { lblError.Visible = (lblError.Text != ""); } if (lblTitle != null) { lblTitle.Text = HTMLHelper.HTMLEncode(ImageTitle); } break; } } }
private bool SetupIsNeeded() { if (IsPostBack || ViewMode.IsDesign() || ViewMode.IsEdit()) { return(false); } if (!TransactionLibrary.HasBasket()) { return(false); } return(true); }
private bool SetupIsNeeded() { if (IsPostBack || ViewMode.IsDesign() || ViewMode.IsEdit()) { return(false); } if (!TransactionLibrary.HasBasket()) { cartIsEmpty.Visible = true; Address.Visible = false; return(false); } return(true); }
/// <summary> /// Handles reset button click. Resets zones of specified type to default settings. /// </summary> protected void btnReset_Click(object sender, EventArgs e) { // Security check if (!DisplayResetButton || !resetAllowed) { return; } PageInfo pi = DocumentContext.CurrentPageInfo; if (pi == null) { return; } // Delete user personalization info PersonalizationInfo up = PersonalizationInfoProvider.GetDashBoardPersonalization(MembershipContext.AuthenticatedUser.UserID, PortalContext.DashboardName, PortalContext.DashboardSiteName); PersonalizationInfoProvider.DeletePersonalizationInfo(up); // Clear cached page template if (pi.UsedPageTemplateInfo != null) { CacheHelper.TouchKey("cms.pagetemplate|byid|" + pi.UsedPageTemplateInfo.PageTemplateId); } // Make redirect to see changes after load string url = RequestContext.CurrentURL; if (ViewMode.IsEdit(true) || ViewMode.IsEditLive()) { // Ensure that the widgets will be loaded from the session layer (not from database) url = URLHelper.UpdateParameterInUrl(url, "cmscontentchanged", "true"); } URLHelper.Redirect(url); }
/// <summary> /// Overridden CreateChildControls method. /// </summary> protected override void CreateChildControls() { Controls.Clear(); base.CreateChildControls(); if (!StopProcessing) { if (!CMSAbstractEditableControl.RequestEditViewMode(ViewMode, ContentID)) { ViewMode = ViewModeEnum.Preview; } // Create controls by actual page mode switch (ViewMode) { case ViewModeEnum.Edit: case ViewModeEnum.EditDisabled: { // Main editor panel pnlEditor = new Panel(); pnlEditor.ID = "pnlEditor"; pnlEditor.CssClass = "EditableImageEdit EditableImage_" + ContentID; pnlEditor.Attributes.Add("data-tracksavechanges", "true"); if (ImageWidth > 0) { pnlEditor.Style.Add(HtmlTextWriterStyle.Width, ImageWidth.ToString() + "px;"); } Controls.Add(pnlEditor); // Title label lblTitle = new Label(); lblTitle.EnableViewState = false; lblTitle.CssClass = "EditableTextTitle"; pnlEditor.Controls.Add(lblTitle); // Error label lblError = new Label(); lblError.EnableViewState = false; lblError.CssClass = "EditableTextError"; pnlEditor.Controls.Add(lblError); // Add image selector selPath = new ImageSelector(null, false); selPath.Culture = MembershipContext.AuthenticatedUser.PreferredUICultureCode; selPath.EnableOpenInFull = false; selPath.ID = "selPath"; selPath.UseImagePath = true; selPath.ImageCssClass = ImageCssClass; selPath.ImageStyle = ImageStyle; selPath.ShowTextBox = DisplaySelectorTextBox; selPath.DefaultValue = DefaultImage; selPath.AddCssClass("cms-bootstrap"); // Dialog configuration selPath.DialogConfig.ResizeToHeight = ResizeToHeight; selPath.DialogConfig.ResizeToWidth = ResizeToWidth; selPath.DialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize; pnlEditor.Controls.Add(selPath); selPath.Enabled = ViewMode.IsEdit(); selPath.IsLiveSite = ViewMode.IsLiveSite(); } break; default: { // Display content in non editing modes imgImage = new Image(); imgImage.ID = "imgImage"; imgImage.GenerateEmptyAlternateText = true; if (ImageCssClass != "") { imgImage.CssClass = ImageCssClass; } if (ImageStyle != "") { imgImage.Attributes.Add("style", ImageStyle); } imgImage.AlternateText = AlternateText; imgImage.ToolTip = AlternateText; imgImage.EnableViewState = false; Controls.Add(imgImage); } break; } } }
/// <summary> /// Handles reset button click. Resets zones of specified type to default settings. /// </summary> protected void btnReset_Click(object sender, EventArgs e) { // Disable the reset action when document editing is not allowed (i.e. non-editable workflow step) if (!WidgetActionsEnabled) { resetAllowed = false; } // Security check if (!DisplayResetButton || !resetAllowed) { return; } PageInfo pi = CurrentPageInfo; if (pi == null) { return; } if ((zoneType == WidgetZoneTypeEnum.Editor) || (zoneType == WidgetZoneTypeEnum.Group)) { // Clear document webparts/group webparts TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider); if (node != null) { bool updateDocument = true; if (zoneType == WidgetZoneTypeEnum.Editor) { if (ViewMode.IsEdit(true) || ViewMode.IsEditLive()) { // Do not save the document to the database, keep it in only in the memory updateDocument = false; // Get the default template widgets PortalContext.SaveEditorWidgets(pi.DocumentID, pi.UsedPageTemplateInfo.TemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor)); } else { node.SetValue("DocumentWebParts", String.Empty); } ClearEditorWidgetsContent(node, pi.UsedPageTemplateInfo.TemplateInstance, updateDocument); // Delete all variants if (pi.UsedPageTemplateInfo != null) { foreach (WebPartZoneInstance zoneInstance in zoneInstances) { if (zoneInstance.WebPartsContainVariants) { VariantHelper.DeleteWidgetVariants(zoneInstance.ZoneID, pi.UsedPageTemplateInfo.PageTemplateId, node.DocumentID); } } } } else if (zoneType == WidgetZoneTypeEnum.Group) { node.SetValue("DocumentGroupWebParts", String.Empty); } if (updateDocument) { // Save the document DocumentHelper.UpdateDocument(node, TreeProvider); } } } else if (zoneType == WidgetZoneTypeEnum.User) { // Delete user personalization info PersonalizationInfo up = PersonalizationInfoProvider.GetUserPersonalization(MembershipContext.AuthenticatedUser.UserID, pi.DocumentID); PersonalizationInfoProvider.DeletePersonalizationInfo(up); // Clear cached values TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider); if (node != null) { node.ClearCache(); } } else if (zoneType == WidgetZoneTypeEnum.Dashboard) { // Delete user personalization info PersonalizationInfo up = PersonalizationInfoProvider.GetDashBoardPersonalization(MembershipContext.AuthenticatedUser.UserID, PortalContext.DashboardName, PortalContext.DashboardSiteName); PersonalizationInfoProvider.DeletePersonalizationInfo(up); // Clear cached page template if (pi.UsedPageTemplateInfo != null) { CacheHelper.TouchKey("cms.pagetemplate|byid|" + pi.UsedPageTemplateInfo.PageTemplateId); } } // Make redirect to see changes after load string url = RequestContext.CurrentURL; if (ViewMode.IsEdit(true) || ViewMode.IsEditLive()) { // Ensure that the widgets will be loaded from the session layer (not from database) url = URLHelper.UpdateParameterInUrl(url, "cmscontentchanged", "true"); } URLHelper.Redirect(url); }