void SetLayout(LayoutTypeEnum type) { ServiceProvider.Settings.SelectedLayout = type.ToString(); switch (type) { case LayoutTypeEnum.Normal: { StackLayout.Children.Clear(); LayoutNormal control = new LayoutNormal(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.Grid: { StackLayout.Children.Clear(); LayoutGrid control = new LayoutGrid(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.GridRight: { StackLayout.Children.Clear(); LayoutGridRight control = new LayoutGridRight(); StackLayout.Children.Add(control); } break; } }
/// <summary> /// Loads form layout of document, bizform, systemtable or alternative form. /// </summary> protected void LoadData() { if (DataClassID > 0) { if (!IsAlternative) { classInfo = DataClassInfoProvider.GetDataClassInfo(DataClassID); UIContext.EditedObject = classInfo; } else { altFormInfo = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); UIContext.EditedObject = altFormInfo; } if (!RequestHelper.IsPostBack()) { LayoutTypeEnum layoutType = LayoutTypeEnum.Html; InitTypeSelector(); if (!IsAlternative) { if (classInfo != null) { // Load layout of document, bizform or systemtable FormLayout = classInfo.ClassFormLayout; layoutType = classInfo.ClassFormLayoutType; } } else { if (altFormInfo != null) { // Load layout of alternative form FormLayout = altFormInfo.FormLayout; layoutType = altFormInfo.FormLayoutType; } } radCustomLayout.Checked = LayoutIsSet; drpLayoutType.SelectedValue = layoutType.ToString(); // Switch visibility of layout editors based on layout type plcHTML.Visible = drpLayoutType.SelectedValue.EqualsCSafe(LayoutTypeEnum.Html.ToString(), StringComparison.InvariantCultureIgnoreCase); plcASCX.Visible = !plcHTML.Visible; } if (radCustomLayout.Checked) { InitDialog(); } radAutoLayout.Checked = !radCustomLayout.Checked; } else { UIContext.EditedObject = null; } }
/// <summary> /// Valida parametros gerais da mensagem (campos obrigatorios, tamanho do texto, etc). /// </summary> /// <param name="type"></param> /// <param name="linha"></param> private void validateMessage(LayoutTypeEnum type, String linha) { String[] fields = linha.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (LayoutTypeEnum.TYPE_A.Equals(type)) { if (fields.Length != 2) { throw new ClientHumanException("File format invalid."); } base.validateMessage(fields[0], fields[1]); } else if (LayoutTypeEnum.TYPE_B.Equals(type)) { if (fields.Length != 3) { throw new ClientHumanException("File format invalid."); } base.validateMessage(fields[0], fields[1], fields[2]); } else if (LayoutTypeEnum.TYPE_C.Equals(type)) { if (fields.Length != 3) { throw new ClientHumanException("File format invalid."); } base.validateMessage(fields[0], fields[1], fields[2], null); } else if (LayoutTypeEnum.TYPE_D.Equals(type)) { if (fields.Length != 4) { throw new ClientHumanException("File format invalid."); } base.validateMessage(fields[0], fields[1], fields[2], fields[3]); } else if (LayoutTypeEnum.TYPE_E.Equals(type)) { if (fields.Length != 5) { throw new ClientHumanException("File format invalid."); } base.validateMessage(fields[0], fields[1], fields[2], fields[3], fields[4]); } else { throw new ClientHumanException("Type of file format invalid."); } }
public void LayoutTypeTest() { //PrivateType type = new PrivateType(typeof(FilmLayout)); //Class1为要测试的类。 //PrivateObject param0 = new PrivateObject(new FilmLayout(3, 2, "3x2"), type); //FilmLayout_Accessor target = new FilmLayout_Accessor(param0); //LayoutTypeEnum expected = new LayoutTypeEnum(); //LayoutTypeEnum actual; //target.LayoutType = expected; //actual = target.LayoutType; //Assert.AreEqual(expected, actual); FilmLayout target = new FilmLayout(3, 2, "3x2"); LayoutTypeEnum expected = new LayoutTypeEnum(); LayoutTypeEnum actual; target.LayoutType = expected; actual = target.LayoutType; Assert.AreEqual(expected, actual); }
/// <summary> /// Save layout. /// </summary> public bool SaveLayout() { PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId); if (pti != null) { if (radShared.Checked) { // Shared layout pnlCheckOutInfo.Visible = false; pti.LayoutID = ValidationHelper.GetInteger(selectShared.Value, 0); pti.PageTemplateLayout = ""; pti.PageTemplateCSS = ""; } else { LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(this.drpType.SelectedValue); if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { // Custom layout pnlCheckOutInfo.Visible = true; pti.LayoutID = 0; pti.PageTemplateLayoutType = layoutType; pti.PageTemplateLayout = txtCustom.Text; pti.PageTemplateCSS = txtCustomCSS.Text; } } PageTemplateInfoProvider.SetPageTemplateInfo(pti); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); return(true); } return(false); }
private void SetLayout(LayoutTypeEnum type) { ServiceProvider.Settings.SelectedLayout = type.ToString(); if (StackLayout.Children.Count > 0) { var cnt = StackLayout.Children[0] as LayoutBase; if (cnt != null) { cnt.UnInit(); } } switch (type) { case LayoutTypeEnum.Normal: { StackLayout.Children.Clear(); LayoutNormal control = new LayoutNormal(); PreviewPanel.DataContext = control.ZoomAndPanControl; StackLayout.Children.Add(control); } break; case LayoutTypeEnum.Grid: { StackLayout.Children.Clear(); LayoutGrid control = new LayoutGrid(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.GridRight: { StackLayout.Children.Clear(); LayoutGridRight control = new LayoutGridRight(); StackLayout.Children.Add(control); } break; } }
private void SetLayout(LayoutTypeEnum type) { ServiceProvider.Settings.SelectedLayout = type.ToString(); switch (type) { case LayoutTypeEnum.Normal: { StackLayout.Children.Clear(); LayoutNormal control = new LayoutNormal(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.Grid: { StackLayout.Children.Clear(); LayoutGrid control = new LayoutGrid(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.GridRight: { StackLayout.Children.Clear(); LayoutGridRight control = new LayoutGridRight(); StackLayout.Children.Add(control); } break; } }
private void SetLayout(LayoutTypeEnum type) { ServiceProvider.Settings.SelectedLayout = type.ToString(); if (StackLayout.Children.Count > 0) { var cnt = StackLayout.Children[0] as LayoutBase; if (cnt != null) cnt.UnInit(); } switch (type) { case LayoutTypeEnum.Normal: { StackLayout.Children.Clear(); LayoutNormal control = new LayoutNormal(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.Grid: { StackLayout.Children.Clear(); LayoutGrid control = new LayoutGrid(); StackLayout.Children.Add(control); } break; case LayoutTypeEnum.GridRight: { StackLayout.Children.Clear(); LayoutGridRight control = new LayoutGridRight(); StackLayout.Children.Add(control); } break; } }
protected void btnSave_Click(object sender, EventArgs e) { if ((nodeId > 0) && (node != null)) { LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(drpType.SelectedValue); // Check the permissions if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { // Update the layout if (node.DocumentPageTemplateID > 0) { PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(node.DocumentPageTemplateID); if (pti != null) { // Get shared layout LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID); if (li != null) { // Update shared layout li.LayoutCode = txtLayout.Text; li.LayoutType = layoutType; LayoutInfoProvider.SetLayoutInfo(li); } else if (pti.PageTemplateLayoutCheckedOutByUserID <= 0) { // Update custom layout pti.PageTemplateLayout = txtLayout.Text; pti.PageTemplateLayoutType = layoutType; PageTemplateInfoProvider.SetPageTemplateInfo(pti); } } } } // Update fields node.NodeBodyElementAttributes = txtBodyCss.Text; node.NodeDocType = txtDocType.Text; node.NodeHeadTags = txtHeadTags.Value.ToString(); // Update the node node.Update(); // Update search index if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); // Clear cache PageInfoProvider.RemoveAllPageInfosFromCache(); } }
/// <summary> /// Save button is clicked. /// </summary> protected void SaveAction(object sender, EventArgs e) { // Check permissions if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "Design.EditLayout")) { RedirectToUIElementAccessDenied("CMS.Design", "Design.EditLayout"); } // New device profile int newDeviceProfileId = deviceProfileId; if (newDeviceProfileId == 0) { newDeviceProfileId = ValidationHelper.GetInteger(ucNewDeviceProfile.Value, 0); } if (newDeviceProfileId == 0) { // Show error - select device profile first ShowError(GetString("devicelayout.selectdeviceprofile.error")); rbtnDevice.Checked = true; return; } PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId); if ((pti != null) && (newDeviceProfileId > 0)) { string layoutCode = null; string layoutCSS = null; int layoutId = 0; LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx; if (rbtnDevice.Checked) { // Copy from device int selectedDeviceProfileId = ValidationHelper.GetInteger(ucDeviceProfile.Value, 0); if (selectedDeviceProfileId > 0) { // Existing device profile PageTemplateDeviceLayoutInfo selectedDeviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, selectedDeviceProfileId); if (selectedDeviceLayout != null) { layoutId = selectedDeviceLayout.LayoutID; layoutCode = selectedDeviceLayout.LayoutCode; layoutCSS = selectedDeviceLayout.LayoutCSS; layoutType = selectedDeviceLayout.LayoutType; } } else { // Default device layoutType = pti.PageTemplateLayoutType; if (pti.LayoutID > 0) { layoutId = pti.LayoutID; } else { layoutCode = pti.PageTemplateLayout; layoutCSS = pti.PageTemplateCSS; } } } else if (rbtnLayout.Checked) { // Use existing layout int selectedLayoutId = ValidationHelper.GetInteger(ucLayout.Value, 0); LayoutInfo selectedLayout = LayoutInfoProvider.GetLayoutInfo(selectedLayoutId); if (selectedLayout != null) { layoutType = selectedLayout.LayoutType; if (chkCopy.Checked) { // Copy layout code layoutCode = selectedLayout.LayoutCode; layoutCSS = selectedLayout.LayoutCSS; } else { // Copy layout id layoutId = selectedLayoutId; } } } else if (rbtnEmptyLayout.Checked) { layoutCode = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />"; } PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, newDeviceProfileId); if (deviceLayout == null) { // Create a new device profile layout object deviceLayout = new PageTemplateDeviceLayoutInfo(); deviceLayout.PageTemplateID = templateId; deviceLayout.ProfileID = newDeviceProfileId; } // Modify the device profile layout object with updated values deviceLayout.LayoutID = layoutId; deviceLayout.LayoutType = layoutType; deviceLayout.LayoutCode = layoutCode; deviceLayout.LayoutCSS = layoutCSS; // Save the device profile layout object PageTemplateDeviceLayoutInfoProvider.SetTemplateDeviceLayoutInfo(deviceLayout); UIContext.EditedObject = deviceLayout; CMSObjectManager.CheckOutNewObject(Page); // Register refresh page scripts ScriptHelper.RegisterStartupScript(this, typeof(string), "deviceLayoutSaved", "if (wopener) { wopener.location.replace(wopener.location); } CloseDialog();", true); } }
/// <summary> /// Construtor da classe informando a lista de sms e o tipo de layout da mesma. /// </summary> /// <param name="list"></param> /// <param name="type"></param> public ListResource(String list, LayoutTypeEnum type) : base(type) { content = list; }
/// <summary> /// Contrutor da classe informando o tipo de layout do arquivo ou lista /// </summary> /// <param name="type"></param> public MultipleMessage(LayoutTypeEnum type) : base() { this.type = type; }
/// <summary> /// Construtor da classe onde eh informado o arquivo e o tipo de layout /// </summary> /// <param name="file"></param> /// <param name="type"></param> public FileResource(FileInfo file, LayoutTypeEnum type) : base(type) { content = file; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); bool editingEnabled = true; LayoutInfo li = this.PagePlaceholder.LayoutInfo; PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo; // Layout save button script ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "LayoutSave", ScriptHelper.GetScript( "function SaveDocument() { layoutChanged = true; " + this.Page.ClientScript.GetPostBackEventReference(this.btnSaveLayout, "") + "; } \n" )); string tmpLayoutCode = ""; int tmpCheckUser = 0; string tmpMachine = ""; string tmpFilename = ""; string tmpLayoutUrl = ""; string layoutUrl = ""; LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx; if (li != null) { tmpLayoutCode = li.LayoutCode; tmpCheckUser = li.LayoutCheckedOutByUserID; tmpMachine = li.LayoutCheckedOutMachineName; tmpFilename = li.LayoutCheckedOutFilename; tmpLayoutUrl = LayoutInfoProvider.GetLayoutUrl(li.LayoutCodeName, null, li.LayoutType); layoutUrl = tmpLayoutUrl; layoutType = li.LayoutType; } // Get layout information if ((li == null) && (pti != null)) { tmpLayoutCode = pti.PageTemplateLayout; tmpCheckUser = pti.PageTemplateLayoutCheckedOutByUserID; tmpMachine = pti.PageTemplateLayoutCheckedOutMachineName; tmpFilename = pti.PageTemplateLayoutCheckedOutFileName; layoutUrl = PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType); layoutType = pti.PageTemplateLayoutType; if (pti.IsReusable) { tmpLayoutUrl = PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType); } else { tmpLayoutUrl = PageTemplateInfoProvider.GetAdhocLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType); } } if (!RequestHelper.IsPostBack()) { drpType.SelectedIndex = (layoutType == LayoutTypeEnum.Html ? 1 : 0); this.txtLayout.Text = tmpLayoutCode; } this.plcUndoCheckOut.Visible = false; this.plcCheckOut.Visible = false; this.plcCheckIn.Visible = false; // Check checked-out status if (tmpCheckUser > 0) { this.txtLayout.ReadOnly = true; string username = null; UserInfo ui = UserInfoProvider.GetUserInfo(tmpCheckUser); if (ui != null) { username = HTMLHelper.HTMLEncode(ui.FullName); } // Checked out by current machine if ((HttpContext.Current != null) && (tmpMachine.ToLower() == HTTPHelper.MachineName.ToLower())) { this.plcCheckIn.Visible = true; this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOut", culture), HttpContext.Current.Server.MapPath(tmpFilename)); } else { this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOutOnAnotherMachine", culture), HTMLHelper.HTMLEncode(tmpMachine), HTMLHelper.HTMLEncode(username)); } //this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOutOnAnotherMachine"), li.LayoutCheckedOutMachineName, username); if (user.IsGlobalAdministrator) { this.plcUndoCheckOut.Visible = true; } } else { if (HttpContext.Current != null) { this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckOutInfo", culture), HttpContext.Current.Server.MapPath(tmpLayoutUrl)); } this.plcCheckOut.Visible = true; this.txtLayout.ReadOnly = false; } bool isAscx = (this.drpType.SelectedValue.ToLower() == "ascx"); this.btnSaveLayout.Visible = !isAscx || SettingsKeyProvider.UsingVirtualPathProvider; // Disable items when virtual path provider is disabled if (isAscx && !SettingsKeyProvider.UsingVirtualPathProvider && (pti != null)) { this.lblVirtualInfo.Text = String.Format(ResHelper.GetString("TemplateLayout.VirtualPathProviderNotRunning", culture), PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null)); this.plcVirtualInfo.Visible = true; this.pnlCheckOutInfo.Visible = false; editingEnabled = false; } string info = null; // Setup the information and code type if (isAscx) { txtLayout.Editor.Language = LanguageEnum.ASPNET; txtLayout.UseAutoComplete = false; info = ResHelper.GetString("Administration-PageLayout_New.Hint", culture); // Check the edit code permission if (!user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { editingEnabled = false; info = ResHelper.GetString("EditCode.NotAllowed", culture); } } else { txtLayout.Editor.Language = LanguageEnum.HTMLMixed; txtLayout.UseAutoComplete = true; info = ResHelper.GetString("EditLayout.HintHtml", culture); } if (!String.IsNullOrEmpty(lblLayoutInfo.Text)) { lblLayoutInfo.Text += " "; } lblLayoutInfo.Text += info; this.lblLayoutInfo.Visible = (this.lblLayoutInfo.Text != ""); this.txtLayout.ReadOnly = !editingEnabled; this.plcActions.Visible = editingEnabled; // Disable editor for layout or template checked out if (li != null) { if (li.LayoutCheckedOutByUserID > 0) { txtLayout.ReadOnly = true; } } else if (pti != null) { if (pti.PageTemplateLayoutCheckedOutByUserID > 0) { txtLayout.ReadOnly = true; } } }
/// <summary> /// Check out layout event handler. /// </summary> protected void btnCheckOut_Click(object sender, EventArgs e) { // Ensure version before check-out using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; // Save first if (!SaveLayout()) { return; } } LayoutInfo li = this.PagePlaceholder.LayoutInfo; PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo; if ((li != null) || (pti != null)) { try { string filename = ""; string tmpCode = ""; LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx; if (li != null) { filename = LayoutInfoProvider.GetLayoutUrl(li.LayoutCodeName, null, li.LayoutType); layoutType = li.LayoutType; tmpCode = li.LayoutCode; } else { filename = PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType); layoutType = pti.PageTemplateLayoutType; tmpCode = pti.PageTemplateLayout; } // Write the code to the file string fullfilename = ""; if (HttpContext.Current != null) { fullfilename = HttpContext.Current.Server.MapPath(filename); DirectoryHelper.EnsureDiskPath(fullfilename, HttpContext.Current.Server.MapPath("~/")); } StringBuilder sb = new StringBuilder(); if (layoutType == LayoutTypeEnum.Ascx) { sb.Append(LayoutInfoProvider.GetLayoutDirectives()); } sb.Append(tmpCode); string content = HTMLHelper.EnsureLineEnding(sb.ToString(), "\r\n"); File.WriteAllText(fullfilename, content); // Set the layout data if (li != null) { // Shared layout li.LayoutCheckedOutByUserID = user.UserID; li.LayoutCheckedOutMachineName = ""; if (HttpContext.Current != null) { li.LayoutCheckedOutMachineName = HTTPHelper.MachineName; } li.LayoutCheckedOutFilename = filename; LayoutInfoProvider.SetLayoutInfo(li); } else { // Page template layout pti.PageTemplateLayoutCheckedOutByUserID = user.UserID; pti.PageTemplateLayoutCheckedOutMachineName = ""; if (HttpContext.Current != null) { pti.PageTemplateLayoutCheckedOutMachineName = HTTPHelper.MachineName; } pti.PageTemplateLayoutCheckedOutFileName = filename; PageTemplateInfoProvider.SetPageTemplateInfo(pti); } } catch { return; } } }
/// <summary> /// Saves the layout code. /// </summary> /// <returns>Returns true if save successful</returns> private bool SaveLayout() { LayoutInfo li = this.PagePlaceholder.LayoutInfo; PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo; if ((li != null) || (pti != null)) { string mPath = ""; if ((HttpContext.Current != null) && (HttpContext.Current.Server != null)) { mPath = HttpContext.Current.Server.UrlPathEncode(URLHelper.ApplicationPath); } LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(this.drpType.SelectedValue); // Check the permissions if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { if (li != null) { // Shared layout li.LayoutType = layoutType; li.LayoutCode = HTMLHelper.UnResolveUrls(this.txtLayout.Text, mPath); LayoutInfoProvider.SetLayoutInfo(li); } else { // Custom layout pti.PageTemplateLayoutType = layoutType; pti.PageTemplateLayout = HTMLHelper.UnResolveUrls(this.txtLayout.Text, mPath); PageTemplateInfoProvider.SetPageTemplateInfo(pti); } } this.lblLayoutInfo.Text = ResHelper.GetString("General.ChangesSaved", culture); // Resave page template XML if (layoutType == LayoutTypeEnum.Ascx) { PageTemplateInfo ti = this.PagePlaceholder.PageInfo.PageTemplateInfo; if ((ti != null) && (ti.PageTemplateId > 0)) { try { // Load the layout CMSAbstractLayout layout = (CMSAbstractLayout)this.Page.LoadControl(LayoutInfoProvider.GetLayoutUrl(li.LayoutCodeName, li.LayoutVersionGUID)); layout.ID = "abstractLayout"; // Remove zones without web parts ArrayList removeZones = new ArrayList(); foreach (WebPartZoneInstance zone in ti.WebPartZones) { if (zone.WebParts.Count <= 0) { removeZones.Add(zone); } } foreach (WebPartZoneInstance zone in removeZones) { ti.WebPartZones.Remove(zone); } // Ensure all zones foreach (DictionaryEntry zone in layout.WebPartZones) { ti.EnsureZone(((CMSWebPartZone)zone.Value).ID); } this.Controls.Remove(layout); // Save the page template PageTemplateInfoProvider.SetPageTemplateInfo(ti); } catch { } } } return(true); } else { return(false); } }