/// <summary> /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields. /// </summary> private void UnsetTargetLayout() { int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0); using (var scope = new CMSTransactionScope()) { LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId); if (sourceLayout == null) { throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout")); } InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts() .WhereEquals("DeviceProfileID", DeviceProfile.ProfileID) .WhereEquals("SourceLayoutID", sourceLayout.LayoutId) .TypedResult .Items; if (bindings.Count > 0) { DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]); } scope.Commit(); } }
/// <summary> /// Initializes this layout binding control. /// </summary> private void Initialize() { // Initialize source layout controls ltrSourceLayoutIcon.Text = PortalHelper.GetIconHtml(SourceLayout.LayoutThumbnailGUID, ValidationHelper.GetString(SourceLayout.LayoutIconClass, PortalHelper.DefaultPageLayoutIconClass)); SourceLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(SourceLayout.LayoutDisplayName)); // Initialize target layout controls TargetLayout = DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(DeviceProfile, SourceLayout); if (TargetLayout != null) { ltrTargetLayoutIcon.Text = PortalHelper.GetIconHtml(TargetLayout.LayoutThumbnailGUID, ValidationHelper.GetString(TargetLayout.LayoutIconClass, PortalHelper.DefaultPageLayoutIconClass)); TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(TargetLayout.LayoutDisplayName)); } else { ltrTargetLayoutIcon.Text = PortalHelper.GetIconHtml(Guid.Empty, "icon-question-circle empty-device-layout-mapping"); TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sethint")); } // Initialize script to open target layout selection dialog string baseUrl = URLHelper.ResolveUrl("~/CMSModules/DeviceProfiles/Pages/SelectLayout.aspx"); string url = String.Format("{0}?deviceProfileId={1:D}&sourceLayoutId={2:D}&targetLayoutId={3:D}", baseUrl, DeviceProfile.ProfileID, SourceLayout.LayoutId, TargetLayout != null ? TargetLayout.LayoutId : 0); string script = String.Format("modalDialog('{0}', 'SelectLayout', '1000', '785', null)", URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url))); TargetLayoutItemControl.Attributes.Add("onclick", script); btnDelete.ToolTip = GetString("device_profile.layoutmapping.unset"); btnDelete.OnClientClick = "$cmsj.Event(event).stopPropagation(); Client_UnsetTargetLayout({sourceLayoutId:" + SourceLayout.LayoutId.ToString("D") + "}); return false;"; }
private void Initialize() { // Initialize source layout controls SourceLayoutThumbnail.AlternateText = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sourcelayoutthumbalt")); SourceLayoutThumbnail.ImageUrl = GetLayoutThumbnailUrl(SourceLayout); SourceLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(SourceLayout.LayoutDisplayName)); // Initialize target layout controls TargetLayoutThumbnail.AlternateText = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.targetlayoutthumbalt")); TargetLayout = DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(DeviceProfile, SourceLayout); if (TargetLayout != null) { TargetLayoutThumbnail.ImageUrl = GetLayoutThumbnailUrl(TargetLayout); TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(TargetLayout.LayoutDisplayName)); } else { TargetLayoutThumbnail.ImageUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/no_target_layout.png"); TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sethint")); } // Initialize script to open target layout selection dialog string baseUrl = URLHelper.ResolveUrl("~/CMSModules/DeviceProfile/Pages/SelectLayout.aspx"); string url = String.Format("{0}?deviceProfileId={1:D}&sourceLayoutId={2:D}&targetLayoutId={3:D}", baseUrl, DeviceProfile.ProfileID, SourceLayout.LayoutId, TargetLayout != null ? TargetLayout.LayoutId : 0); string script = String.Format("modalDialog('{0}', 'SelectLayout', '1000', '785', null)", URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url))); TargetLayoutItemControl.Attributes.Add("onclick", script); }
/// <summary> /// Executes the SetTragetLayout client action using parameters passed in hidden fields. /// </summary> private void SetTargetLayout() { int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0); int targetLayoutId = ValidationHelper.GetInteger(TargetLayoutIdentifierHiddenField.Value, 0); using (var scope = new CMSTransactionScope()) { LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId); if (sourceLayout == null) { throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout")); } LayoutInfo targetLayout = LayoutInfoProvider.GetLayoutInfo(targetLayoutId); if (targetLayout == null) { throw new ApplicationException(GetString("device_profile.layoutmapping.errors.notargetlayout")); } InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts() .Where("DeviceProfileID", QueryOperator.Equals, DeviceProfile.ProfileID) .Where("SourceLayoutID", QueryOperator.Equals, sourceLayout.LayoutId) .TypedResult .Items; DeviceProfileLayoutInfo binding = null; if (bindings.Count > 0) { binding = bindings[0]; } else { binding = new DeviceProfileLayoutInfo { DeviceProfileID = DeviceProfile.ProfileID, SourceLayoutID = sourceLayout.LayoutId }; } binding.TargetLayoutID = targetLayout.LayoutId; DeviceProfileLayoutInfoProvider.SetDeviceProfileLayoutInfo(binding); scope.Commit(); } }
/// <summary> // Shows warning for not mapped device profiles /// </summary> private void SetDeviceWarning() { if (CurrentDeviceProfile != null) { PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, CurrentDeviceProfile.ProfileID); bool layoutIsMapped = (deviceLayout != null); // Check layout auto mapping if (!layoutIsMapped && (TemplateID > 0) && (PageTemplateInfo != null)) { layoutIsMapped |= (DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(CurrentDeviceProfile.ProfileID, PageTemplateInfo.LayoutID) != null); } // Device layout not defined if (!layoutIsMapped) { ShowWarning(GetString("devicelayout.notdefined")); } } }
/// <summary> /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields. /// </summary> private void UnsetTargetLayout() { int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0); using (CMSTransactionScope scope = new CMSTransactionScope()) { LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId); if (sourceLayout == null) { throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout")); } string condition = String.Format("DeviceProfileID = {0:D} AND SourceLayoutID = {1:D}", DeviceProfile.ProfileID, sourceLayout.LayoutId); InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts(condition, null).Items; if (bindings.Count > 0) { DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]); } scope.Commit(); } }
/// <summary> /// Gets the title text. /// </summary> private string GetTitleInformation() { if (deviceProfile != null) { PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, deviceProfile.ProfileID); bool layoutIsMapped = (deviceLayout != null); // Check layout auto mapping if (!layoutIsMapped && (templateId > 0)) { layoutIsMapped |= (DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(deviceProfile.ProfileID, pti.LayoutID) != null); } if (!layoutIsMapped) { // Device layout not defined return(GetString("devicelayout.notdefined")); } } return(null); }