protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (PageTemplate == null) { return; } var deviceProfile = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceProfile == null) { return; } var currentDeviceProfile = HTMLHelper.HTMLEncode(deviceProfile.ProfileDisplayName); var aliasPath = QueryHelper.GetString("aliaspath", null); var aliasPathParam = string.IsNullOrEmpty(aliasPath) ? string.Empty : "&aliaspath=" + aliasPath; if (isDialog) { CurrentMaster.Title.TitleText = GetString("objecttype.cms_templatedevicelayout"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_DeviceProfile/object.png"); } else { var breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("devicelayout.devicelayouts"); breadcrumbs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + aliasPathParam); breadcrumbs[0, 2] = "_parent"; breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(currentDeviceProfile); breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; } CurrentMaster.Title.HelpTopicName = "page_template_device_layout"; CurrentMaster.Title.HelpName = "helpTopic"; // Initialize menu var i = 0; // Layout tab var layoutUrl = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageLayouts/PageLayout_Edit.aspx?allowswitch=1&templateid=" + PageTemplateID + "&deviceprofileid=" + deviceProfileId + "&devicename=" + deviceProfile.ProfileName + "&DeviceObjectLifeTime=request" + aliasPathParam); layoutUrl = EnsureDialogModeUrlParameter(layoutUrl); SetTab(i++, GetString("Administration-PageTemplate_Header.Layouts"), layoutUrl, "SetHelpTopic('helpTopic', 'page_template_device_layout');"); if (!isDialog) { // Design tab var designUrl = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Design.aspx?templateid=" + PageTemplateID + "&deviceprofileid=" + deviceProfileId + "&devicename=" + deviceProfile.ProfileName + "&DeviceObjectLifeTime=request" + aliasPathParam); SetTab(i++, GetString("edittabs.design"), designUrl, "SetHelpTopic('helpTopic', 'page_template_device_design');"); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0); if (deviceProfileId == 0) { var deviceLayoutId = QueryHelper.GetInteger("devicelayoutid", 0); var deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(deviceLayoutId); if (deviceLayout != null) { deviceProfileId = deviceLayout.ProfileID; } } var deviceProfile = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceProfile != null) { deviceLayoutHeaderUrl = string.Format(deviceLayoutHeaderUrl, PageTemplateID, deviceProfileId); deviceLayoutContentUrl = string.Format(deviceLayoutContentUrl, PageTemplateID, deviceProfileId, deviceProfile.ProfileName); } var editOnlyCode = QueryHelper.GetBoolean("editonlycode", false); if (editOnlyCode) { deviceLayoutHeaderUrl = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "editonlycode", "1"); deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "dialogmode", "1"); deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "tabmode", "1"); } var deviceActions = QueryHelper.GetBoolean("deviceactions", true); deviceLayoutHeaderUrl = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "deviceactions", deviceActions ? "1" : "0"); deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "deviceactions", deviceActions ? "1" : "0"); // Include the AliasPath parameter to ensure path pre-selection in the preview control string aliasPath = QueryHelper.GetString("aliaspath", null); if (!string.IsNullOrEmpty(aliasPath)) { deviceLayoutHeaderUrl = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "aliaspath", aliasPath); deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "aliaspath", aliasPath); } string aliasPathParam = (string.IsNullOrEmpty(aliasPath) ? string.Empty : "&aliaspath=" + aliasPath); string script = @" function RefreshAfterDelete() { location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + aliasPathParam) + @"'; }"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "refreshGrid", script, true); }
public override void OnInit() { Control.OnTabCreated += Control_OnTabCreated; var info = Control.UIContext.EditedObject as PageTemplateDeviceLayoutInfo; if (info != null) { DeviceProfileInfo dpi = DeviceProfileInfoProvider.GetDeviceProfileInfo(info.ProfileID); if (dpi != null) { deviceName = dpi.ProfileName; } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice); LoadDevicesMenu(); if (UseSmallButton && (currentDevice != null) && ((PortalContext.ViewMode == ViewModeEnum.Preview) || DisplayRotateButtons) ) { bool isHorizontalDevice = (currentDevice.ProfilePreviewWidth > currentDevice.ProfilePreviewHeight); bool isHorizontalOrientation = isHorizontalDevice; // Define the rotation buttons CMSButtonGroupAction hButton = new CMSButtonGroupAction { UseIconButton = true, Name = LAYOUT_HORIZONTAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-h", ToolTip = GetString("device.landscape") }; CMSButtonGroupAction vButton = new CMSButtonGroupAction { UseIconButton = true, Name = LAYOUT_VERTICAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-v", ToolTip = GetString("device.portrait") }; // Append the rotation buttons rotationButtons.Actions.Add(hButton); rotationButtons.Actions.Add(vButton); rotationButtons.Visible = true; // Get the current device rotation state isRotated = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.CurrentDeviceProfileRotate), false); if (isRotated) { isHorizontalOrientation = !isHorizontalOrientation; } // Highlight the currently selected rotation button rotationButtons.SelectedActionName = (isHorizontalOrientation) ? LAYOUT_HORIZONTAL : LAYOUT_VERTICAL; StringBuilder sb = new StringBuilder(); sb.Append(@" var CMSDeviceProfile = { Rotated: ", isRotated.ToString().ToLower(), @", Initialized: false, OnRotationFunction: null, PreviewUrl: null, Init: function () { if (!this.Initialized) { this.Initialized = true; var rotateBtns = $cmsj('.device-rotation').find('button'); var activeClass = '", activeButtonCssClass, @"'; rotateBtns.bind('click', function () { var jThis = $cmsj(this); var selected = jThis.hasClass(activeClass); if (!selected) { rotateBtns.removeClass(activeClass); jThis.addClass(activeClass); $cmsj.cookie('", CookieName.CurrentDeviceProfileRotate, @"', !CMSDeviceProfile.Rotated, { path: '/' } ); if (CMSDeviceProfile.OnRotationFunction != null) { CMSDeviceProfile.OnRotationFunction(this, !CMSDeviceProfile.Rotated); } } }); } } } $cmsj(document).ready(function () { CMSDeviceProfile.Init(); });"); ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "deviceProfileScript", sb.ToString(), true); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Setup the page variables templateId = QueryHelper.GetInteger("templateid", 0); deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0); if (deviceProfileId > 0) { // Display device profile label showNewDeviceSelector = false; DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceLayout != null) { lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>"; } } else { // Display device profile selector pnlNewDevice.Visible = true; lblNewDevice.Visible = false; } // Setup the page title PageTitle.TitleText = GetString("devicelayout.new"); // Source device profile selector ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")"; ucDeviceProfile.SpecialFields.Add(new SpecialField { Text = GetString("devicelayout.defaultdeviceprofile"), Value = "0" }); // New device profile selector // Do not display profiles which have layout already defined ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))"; ucNewDeviceProfile.OrderBy = "ProfileOrder"; ucNewDeviceProfile.SpecialFields.Add(new SpecialField { Text = GetString("devicelayout.selectdeviceprofile"), Value = "" }); ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(value.length > 0);"; // Javascript rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)"); rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)"); rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)"); if (!RequestHelper.IsPostBack()) { rbtnDevice.Checked = true; } // Register the page javascript string script = @" function EnableSelection(enabled) { var pnlContent = $cmsj('#" + pnlContent.ClientID + @" :input'); if (enabled) { pnlContent.removeAttr('disabled'); var rbtnDevice = $cmsj('#" + rbtnDevice.ClientID + @"'); var rbtnLayout = $cmsj('#" + rbtnLayout.ClientID + @"'); var pnlLayout = $cmsj('#" + pnlLayout.ClientID + @" :input'); var pnlDevice = $cmsj('#" + pnlDevice.ClientID + @" :input'); if (rbtnDevice.is(':checked')) { pnlLayout.attr('disabled', 'disabled'); } else if (rbtnLayout.is(':checked')) { pnlDevice.attr('disabled', 'disabled'); } else { pnlLayout.attr('disabled', 'disabled'); pnlDevice.attr('disabled', 'disabled'); } } else { pnlContent.attr('disabled', 'disabled'); } $cmsj('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled'); } $cmsj(document).ready(function () { EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @"); });"; ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true); ScriptHelper.RegisterJQuery(Page); Save += SaveAction; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Setup the page variables templateId = QueryHelper.GetInteger("templateid", 0); deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0); if (deviceProfileId > 0) { // Display device profile label showNewDeviceSelector = false; DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceLayout != null) { lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>"; } } else { // Display device profile selector pnlNewDevice.Visible = true; lblNewDevice.Visible = false; } // Setup the page title CurrentMaster.Title.TitleText = GetString("devicelayout.new"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_DeviceProfile/new.png"); CurrentMaster.Title.HelpTopicName = "CMS_Design_page_device_layout"; CurrentMaster.Title.HelpName = "helpTopic"; // Source device profile selector ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")"; ucDeviceProfile.SpecialFields = new string[, ] { { GetString("devicelayout.defaultdeviceprofile"), "0" } }; // New device profile selector // Do not display profiles which have layout already defined ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))"; ucNewDeviceProfile.OrderBy = "ProfileOrder"; ucNewDeviceProfile.SpecialFields = new string[, ] { { GetString("devicelayout.selectdeviceprofile"), "" } }; ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(this.value.length > 0);"; // Javascript rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)"); rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)"); rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)"); if (!RequestHelper.IsPostBack()) { rbtnDevice.Checked = true; } // Register the page javascript string script = @" function EnableSelection(enabled) { var pnlContent = jQuery('#" + pnlContent.ClientID + @" :input'); if (enabled) { pnlContent.removeAttr('disabled'); var rbtnDevice = jQuery('#" + rbtnDevice.ClientID + @"'); var rbtnLayout = jQuery('#" + rbtnLayout.ClientID + @"'); var pnlLayout = jQuery('#" + pnlLayout.ClientID + @" :input'); var pnlDevice = jQuery('#" + pnlDevice.ClientID + @" :input'); if (rbtnDevice.is(':checked')) { pnlLayout.attr('disabled', 'disabled'); } else if (rbtnLayout.is(':checked')) { pnlDevice.attr('disabled', 'disabled'); } else { pnlLayout.attr('disabled', 'disabled'); pnlDevice.attr('disabled', 'disabled'); } } else { pnlContent.attr('disabled', 'disabled'); } jQuery('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled'); } jQuery(document).ready(function () { EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @"); });"; ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true); ScriptHelper.RegisterJQuery(Page); // Empty footer container if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Clear(); } // Add the Cancel button to the footer panel LocalizedButton btnOk = new LocalizedButton { ID = "btnOk", ResourceString = "general.ok", CssClass = "SubmitButton", }; btnOk.Click += new EventHandler(SaveAction); // Add the Cancel button to the footer panel LocalizedButton btnCancel = new LocalizedButton { ID = "btnCancel", ResourceString = "general.cancel", CssClass = "SubmitButton", OnClientClick = "CloseDialog(); return false;" }; // Button container panel Panel pnlRight = new Panel { ID = "pnlRight", CssClass = "TextRight" }; pnlRight.Controls.Add(btnOk); pnlRight.Controls.Add(btnCancel); // Add the Ok, Cancel buttons to the footer controls collection if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Add(pnlRight); } }
protected void Page_Load(object sender, EventArgs e) { currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(CMSContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice); LoadDevicesMenu(); }
/// <summary> /// Gets the edited object. /// </summary> /// <param name="templateId">The template id - if template/device layout is being edited</param> /// <param name="layoutId">The layout id - if shared layout is being edited</param> /// <param name="newSharedLayoutId">The new shared layout id - when changing shared layouts for template/device layouts</param> /// <param name="oldSharedLayoutId">The old shared layout id - when changing shared layouts for template/device layouts</param> /// <param name="deviceProfileId">The device profile id</param> private object GetEditedObject(int templateId, int layoutId, int newSharedLayoutId, int oldSharedLayoutId, int deviceProfileId) { object editedObject = null; if (templateId > 0) { PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId); DeviceProfileInfo profileInfo = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); PageTemplateLayoutTypeEnum type = PageTemplateLayoutTypeEnum.PageTemplateLayout; // Standard page template layout if (pti != null) { // Check modify shared templates permission if (pti.IsReusable && !CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "Design.ModifySharedTemplates")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.ModifySharedTemplates"); } // Default state - no radio buttons used if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1)) { editedObject = PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(pti, profileInfo, out type); } else { // If new shared layout is set, than it should be used as edited object // This happens when switched from custom to a shared layout if (newSharedLayoutId > 0) { // Standard page layout editedObject = LayoutInfoProvider.GetLayoutInfo(newSharedLayoutId); } else if (newSharedLayoutId == 0) { // This means user switched from shared layout to custom // Data has to be copied to PageTemplateInfo PageTemplateDeviceLayoutInfo deviceLayout = null; if (deviceProfileId > 0) { // Get the current device layout if exists deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, deviceProfileId); if (deviceLayout != null) { // Custom device layout (use old layout) editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(deviceLayout, oldSharedLayoutId) as PageTemplateDeviceLayoutInfo; } } else { // We have to work with the clone, because we need to change the data of the object // (copy from shared layout) editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(pti, oldSharedLayoutId) as PageTemplateInfo; } } } } } else { // Load the object if (layoutId > 0) { editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId); } } return(editedObject); }