/// <summary> /// Load event handler. /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); var viewMode = ViewModeCode.FromString(QueryHelper.GetString("viewmode", String.Empty)); var hash = QueryHelper.GetString("hash", String.Empty); LiveSiteWidgetsParameters dialogParameters = new LiveSiteWidgetsParameters(aliasPath, viewMode) { ZoneId = zoneId, ZoneType = zoneType, InstanceGuid = instanceGuid, TemplateId = templateId, IsInlineWidget = inline }; if (!dialogParameters.ValidateHash(hash)) { return; } // Register the OnSave event handler FramesManager.OnSave += (sender, arg) => { return(widgetProperties.OnSave()); }; // Register the OnApply event handler FramesManager.OnApply += (sender, arg) => { return(widgetProperties.OnApply()); }; }
private static void SetViewMode() { var viewMode = QueryHelper.GetString("viewMode", string.Empty); if (!string.IsNullOrEmpty(viewMode)) { ViewModeEnum mode = ViewModeCode.FromString(viewMode); if (mode != ViewModeEnum.Unknown) { PortalContext.SetRequestViewMode(mode); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Public user is not allowed for widgets if (!AuthenticationHelper.IsAuthenticated()) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } var aliasPath = QueryHelper.GetString("aliaspath", String.Empty); var zoneId = QueryHelper.GetString("zoneid", String.Empty); var zoneType = QueryHelper.GetString("zonetype", "").ToEnum <WidgetZoneTypeEnum>(); var templateId = QueryHelper.GetInteger("templateid", 0); var instanceGuid = QueryHelper.GetGuid("instanceguid", Guid.Empty); var viewMode = ViewModeCode.FromString(QueryHelper.GetString("viewmode", String.Empty)); var hash = QueryHelper.GetString("hash", String.Empty); var inline = QueryHelper.GetBoolean("inline", false); LiveSiteWidgetsParameters dialogParameters = new LiveSiteWidgetsParameters(aliasPath, viewMode) { ZoneId = zoneId, ZoneType = zoneType, InstanceGuid = instanceGuid, TemplateId = templateId, IsInlineWidget = inline }; if (!dialogParameters.ValidateHash(hash)) { return; } selectElem.AliasPath = aliasPath; selectElem.CultureCode = QueryHelper.GetString("culture", LocalizationContext.PreferredCultureCode); selectElem.ZoneId = zoneId; selectElem.ZoneType = zoneType; bool isInline = QueryHelper.GetBoolean("inline", false); selectElem.IsInline = isInline; // Base tag is added in master page AddBaseTag = false; // Proceeds the current item selection StringBuilder script = new StringBuilder(); script.Append(@" function SelectCurrentWidget() {"); if (isInline) { // Skip initial configuration for inline widgets is not supported on the live site script.Append(@" selectedSkipDialog = false;"); } script.Append(@" SelectWidget(selectedValue, selectedSkipDialog); } function SelectWidget(value, skipDialog) { if ((value != null) && (value != '')) {"); if (isInline) { script.Append(@" var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor; if (editor) { editor.getCommand('InsertWidget').open(value); } CloseDialog(false);"); } else { script.Append(@" if (wopener.OnSelectWidget) { wopener.OnSelectWidget(value, skipDialog); } CloseDialog();"); } script.Append(@" } else { alert(document.getElementById('", hdnMessage.ClientID, @"').value); } } "); ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", script.ToString(), true); selectElem.SelectFunction = "SelectWidget"; selectElem.IsLiveSite = true; // Set the title and icon PageTitle.TitleText = GetString("widgets.selectortitle"); // Remove default css class if (CurrentMaster.PanelBody != null) { Panel pnl = CurrentMaster.PanelContent; if (pnl != null) { pnl.CssClass = String.Empty; } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Public user is not allowed for widgets if (!AuthenticationHelper.IsAuthenticated()) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } var viewMode = ViewModeCode.FromString(QueryHelper.GetString("viewmode", String.Empty)); var hash = QueryHelper.GetString("hash", String.Empty); LiveSiteWidgetsParameters dialogparameters = new LiveSiteWidgetsParameters(aliasPath, viewMode) { ZoneId = zoneId, ZoneType = zoneType, InstanceGuid = instanceGuid, TemplateId = templateId, IsInlineWidget = inline }; if (!dialogparameters.ValidateHash(hash)) { return; } // Set page title Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title"); if ((widgetId != string.Empty) && (aliasPath != string.Empty)) { // Get page info var siteName = SiteContext.CurrentSiteName; PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi == null) { return; } // Get template instance PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); // Get widget from instance WidgetInfo wi = null; if (!isNewWidget) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGuid, widgetId); if (widgetInstance == null) { return; } // Get widget info by widget name(widget type) wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } // Widget instance hasn't created yet else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0)); } if (wi != null) { WebPartZoneInstance zone = templateInstance.GetZone(zoneId); if (zone != null) { var currentUser = MembershipContext.AuthenticatedUser; bool checkSecurity = true; // Check security // It is group zone type but widget is not allowed in group if (zone.WidgetZoneType == WidgetZoneTypeEnum.Group) { // Should always be, only group widget are allowed in group zone if (wi.WidgetForGroup) { if (!currentUser.IsGroupAdministrator(pi.NodeGroupID)) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } // All ok, don't check classic security checkSecurity = false; } } if (checkSecurity && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, AuthenticationHelper.IsAuthenticated())) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } } } } // If all ok, set up frames rowsFrameset.Attributes.Add("rows", string.Format("{0}, *", TitleOnlyHeight)); frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + RequestContext.CurrentQueryString); if (inline && !isNewWidget) { frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm")); } else { frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + RequestContext.CurrentQueryString); } }