protected override void OnPreRender(EventArgs e) { DeviceProfileInfo dpi = CMSContext.CurrentDeviceProfile; if (!((dpi != null) && (dpi.ProfilePreviewWidth > 0) && (dpi.ProfilePreviewHeight > 0))) { chkRotate.Visible = false; } base.OnPreRender(e); }
protected void Page_PreRender(object sender, EventArgs e) { DeviceProfileInfo oldDevice = (currentDevice != null ? currentDevice.Clone() : null); currentDevice = DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(CMSContext.CurrentSiteName, true); // Reload device menu if profile changed by postback. Apply this, only if no device was selected from outside enviroment via 'SelectedDevice' property. if ((SelectedDevice == null) && DeviceChanged(oldDevice, currentDevice)) { buttons.Buttons.Clear(); LoadDevicesMenu(); buttons.ReloadButtons(); } }
/// <summary> /// Initialize device preview frame. /// </summary> private void InitializeDevicePreview() { // Get device ID from query string String deviceName = QueryHelper.GetString(DeviceProfileInfoProvider.DEVICENAME_QUERY_PARAM, String.Empty); // If device profile not set, use current device profile DeviceProfileInfo deviceProfile = DeviceContext.CurrentDeviceProfile; // Add hash control for X-Frame-Option if (deviceName != String.Empty) { ViewPage = URLHelper.UpdateParameterInUrl(ViewPage, DeviceProfileInfoProvider.DEVICENAME_QUERY_PARAM, deviceName); String query = URLHelper.GetQuery(ViewPage); string hash = ValidationHelper.GetHashString(query, new HashSettings { HashSalt = RequestContext.UserName }); ViewPage += String.Format("&clickjackinghash={0}", hash); } // If device's boundaries are set, use iframe if ((deviceProfile != null) && (deviceProfile.ProfilePreviewWidth > 0) && (deviceProfile.ProfilePreviewHeight > 0)) { // Remove frame scrolling mFramescroll = "no"; // Register device css from site name folder or design folder RegisterDeviceProfileCss(deviceProfile.ProfileName); pnlDevice.CssClass += " " + deviceProfile.ProfileName; string deviceScript = "CMSView.RotateCookieName = '" + CookieName.CurrentDeviceProfileRotate + "';"; deviceScript += String.Format("CMSView.InitializeFrame({0}, {1}, {2}); CMSView.ResizeContentArea();", deviceProfile.ProfilePreviewWidth, deviceProfile.ProfilePreviewHeight, (RotateDevice ? "true" : "false")); ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeDeviceFrame", deviceScript, true); } else { // Hide all device frame divs pnlTop.Visible = false; pnlBottom.Visible = false; pnlLeft.Visible = false; pnlRight.Visible = false; pnlCenter.CssClass = String.Empty; pnlCenterLine.CssClass = String.Empty; } }
/// <summary> /// Initializes tabs. /// </summary> protected void InitializeMenu() { int tabIndex = 1; DeviceProfileInfo profileInfo = EditedObject as DeviceProfileInfo; // Don't display theme tab when using external storage if (!StorageHelper.IsExternalStorage(profileInfo.GetThemePath())) { // Theme tab SetTab(tabIndex++, GetString("Stylesheet.Theme"), "Theme.aspx?profileid=" + QueryHelper.GetInteger("profileid", 0), "SetHelpTopic('helpTopic', 'device_profile_theme');"); } SetTab(tabIndex++, GetString("Device_Profile.PageLayouts"), "PageLayouts.aspx?profileid=" + QueryHelper.GetInteger("profileid", 0), "SetHelpTopic('helpTopic', 'device_profile_pagelayouts');"); }
/// <summary> /// Handles the PreRender event of the Page control. /// </summary> protected void Page_PreRender(object sender, EventArgs e) { DeviceProfileInfo oldDevice = (currentDevice != null ? currentDevice.Clone() : null); currentDevice = DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true); // Reload device menu if profile changed by postback. Apply this, only if no device was selected from outside environment via 'SelectedDevice' property. if ((SelectedDevice == null) && DeviceChanged(oldDevice, currentDevice)) { buttons.Buttons.Clear(); LoadDevicesMenu(); buttons.ReloadButtons(); } }
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> /// PreInit event handler /// </summary> protected override void OnPreInit(EventArgs e) { deviceProfile = CMSContext.CurrentDeviceProfile; templateId = QueryHelper.GetInteger("templateid", 0); pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId); dialogMode = QueryHelper.GetBoolean("dialogmode", false); tabMode = QueryHelper.GetBoolean("tabmode", false); // Page template dialog in CMS Desk if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "Design.EditLayout")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.EditLayout"); } if (dialogMode) { // Set proper master page for dialog mode MasterPageFile = "~/CMSMasterPages/UI/Dialogs/ModalSimplePage.master"; if (!tabMode) { CurrentMaster.Title.TitleText = GetTitleText(); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Layout/object.png"); CurrentMaster.Title.TitleInformation = GetTitleInformation(); CurrentMaster.Title.HelpTopicName = "CMS_Design_page_layout"; CurrentMaster.Title.HelpName = "helpTopic"; } } int layoutId = QueryHelper.GetInteger("layoutid", 0); int newSharedLayoutId = QueryHelper.GetInteger("newshared", -1); int oldSharedLayoutId = QueryHelper.GetInteger("oldshared", -1); int deviceProfileId = (deviceProfile != null) ? deviceProfile.ProfileID : 0; CMSContext.EditedObject = GetEditedObject(templateId, layoutId, newSharedLayoutId, oldSharedLayoutId, deviceProfileId); base.OnPreInit(e); }
/// <summary> /// Returns true if device changed. /// </summary> /// <param name="oldDevice">Old device profile info</param> /// <param name="newDevice">Current device profile info</param> private bool DeviceChanged(DeviceProfileInfo oldDevice, DeviceProfileInfo newDevice) { if (oldDevice != null) { if (newDevice != null) { return(oldDevice.ProfileName != newDevice.ProfileName); } else { return(true); } } else { if (newDevice != null) { return(true); } } return(false); }
protected void Page_Load(object sender, EventArgs e) { // Setup the file system browser if (EditedObject != null) { DeviceProfileInfo profileInfo = EditedObject as DeviceProfileInfo; if (profileInfo != null) { // Ensure the theme folder themeElem.Path = profileInfo.GetThemePath(); } else { themeElem.StopProcessing = true; themeElem.Visible = false; } } else { themeElem.StopProcessing = true; themeElem.Visible = false; } }
/// <summary> /// Returns true if device changed. /// </summary> /// <param name="oldDevice">Old device profile info</param> /// <param name="newDevice">Current device profile info</param> private bool DeviceChanged(DeviceProfileInfo oldDevice, DeviceProfileInfo newDevice) { if (oldDevice != null) { if (newDevice != null) { return oldDevice.ProfileName != newDevice.ProfileName; } else { return true; } } else { if (newDevice != null) { return true; } } return false; }
protected void Page_Load(object sender, EventArgs e) { currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(CMSContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice); LoadDevicesMenu(); }
/// <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> /// 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); }
internal InternalProfileInfo(DeviceProfileInfo info, string path) { Info = info; Path = path; }
/// <summary> /// Gets the edited object. /// </summary> private object GetEditedObject() { object editedObject = null; if (PageTemplate != null) { DeviceProfileInfo profileInfo = DeviceProfile; int newSharedLayoutId = QueryHelper.GetInteger("newshared", -1); int oldSharedLayoutId = QueryHelper.GetInteger("oldshared", -1); // Check modify shared templates permission if (PageTemplate.IsReusable && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "Design.ModifySharedTemplates")) { RedirectToUIElementAccessDenied("CMS.Design", "Design.ModifySharedTemplates"); } // Default state - no radio buttons used if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1)) { editedObject = PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplate, profileInfo); } 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 if (profileInfo != null) { // Get the current device layout if exists PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(PageTemplate.PageTemplateId, profileInfo.ProfileID); 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(PageTemplate, oldSharedLayoutId) as PageTemplateInfo; } } } } // Load the layout object else { var layoutId = QueryHelper.GetInteger("layoutid", 0); if (layoutId > 0) { editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId); } } return(editedObject); }
/// <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); } }