Beispiel #1
0
        /// <summary>
        /// Retrieves form for master page zone update.
        /// </summary>
        /// <param name="context">Form context.</param>
        /// <returns>Form object.</returns>
        private Form GetMasterPageZoneForm(string context)
        {
            // Get tenant identifier
            long tenantId = _authenticationService.TenantId;

            // Get identifier of master page zone that is being updated
            string[] parts = context.Split('|');
            long masterPageId = Convert.ToInt64(parts[0]);
            long masterPageZoneId = Convert.ToInt64(parts[1]);

            // Get existing master page details
            MasterPage masterPage = _masterPageService.Read(tenantId, masterPageId);
            MasterPageZone masterPageZone = masterPage.MasterPageZones.Where(mpz => mpz.MasterPageZoneId == masterPageZoneId).FirstOrDefault();

            // Construct form
            Form form = new Form { Fields = new Dictionary<string, IFormField>(), Id = FormId.ToString(), Context = context, SubmitLabel = MasterPageResource.UpdateZoneButtonLabel };
            form.Fields.Add("name", new TextField
            {
                Name = "zoneName",
                Label = MasterPageResource.ZoneNameLabel,
                Required = true,
                RequiredErrorMessage = MasterPageResource.ZoneNameRequiredMessage,
                MaxLength = MasterPageLengths.ZoneNameMaxLength,
                MaxLengthErrorMessage = string.Format(MasterPageResource.ZoneNameMaxLengthMessage, "name", MasterPageLengths.ZoneNameMaxLength)
            });
            form.Fields.Add("adminType", new SelectListField<string>
            {
                Name = "adminType",
                Label = MasterPageResource.AdminTypeLabel,
                Items = new List<ListFieldItem<string>> {
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneAdminType>(MasterPageZoneAdminType.Static), Value = ((int)MasterPageZoneAdminType.Static).ToString() },
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneAdminType>(MasterPageZoneAdminType.Editable), Value = ((int)MasterPageZoneAdminType.Editable).ToString() },
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneAdminType>(MasterPageZoneAdminType.Configurable), Value = ((int)MasterPageZoneAdminType.Configurable).ToString() }
                },
                Required = true,
                RequiredErrorMessage = MasterPageResource.AdminTypeRequiredMessage
            });
            form.Fields.Add("contentType", new SelectListField<string>
            {
                Name = "contentType",
                Label = MasterPageResource.ContentTypeLabel,
                Items = new List<ListFieldItem<string>> {
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneContentType>(MasterPageZoneContentType.Standard), Value = ((int)MasterPageZoneContentType.Standard).ToString() },
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneContentType>(MasterPageZoneContentType.Main), Value = ((int)MasterPageZoneContentType.Main).ToString() },
                    new ListFieldItem<string> { Name = _dataAnnotationsService.GetEnumDisplayName<MasterPageZoneContentType>(MasterPageZoneContentType.Comment), Value = ((int)MasterPageZoneContentType.Comment).ToString() }
                },
                Required = true,
                RequiredErrorMessage = MasterPageResource.ContentTypeRequiredMessage
            });
            form.Fields.Add("beginRender", new MultiLineTextField
            {
                Name = "beginRenderZone",
                Label = MasterPageResource.ZoneBeginRenderLabel,
                Rows = 4
            });
            form.Fields.Add("endRender", new MultiLineTextField
            {
                Name = "endRenderZone",
                Label = MasterPageResource.ZoneEndRenderLabel,
                Rows = 4,
                Value = masterPageZone.EndRender
            });

            // Create sub forms
            form.SubForms = new Dictionary<string, Form>();
            form.SubForms.Add("zoneElement", GetMasterPageZoneElementForm(context));
            form.SubForms.Add("zoneElementNew", GetMasterPageZoneElementNewForm(context));
            form.SubForms.Add("zoneElementType", GetMasterPageZoneElementTypeForm(context));

            // Set master page zone as form data
            form.Data = JsonConvert.SerializeObject(masterPageZone);

            // Return form
            return form;
        }
        /// <summary>
        /// Gets form for updating main master page details.
        /// </summary>
        /// <param name="context">Form context.</param>
        /// <returns>Form for updating main master page details.</returns>
        private Form GetMasterPageForm(string context)
        {
            // Get tenant identifier
            long tenantId = _authenticationService.TenantId;

            // Get possible parent pages for ancestor page
            ISearchParameters searchParameters = new SearchParameters {
                PageIndex = 0, PageSize = 1000
            };                                                                                            // TODO: Need way to return all pages, not have some max bound upper limit
            ISearchResult <Page> result = _pageService.List(tenantId, searchParameters, null, PageSortBy.Name, true, true, PageType.Folder, false);

            // Construct view model
            Form form = new Form {
                Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context
            };

            form.Fields.Add("name", new TextField
            {
                Name                  = "name",
                Label                 = MasterPageResource.NameLabel,
                Required              = true,
                RequiredErrorMessage  = MasterPageResource.NameRequiredMessage,
                MaxLength             = MasterPageLengths.NameMaxLength,
                MaxLengthErrorMessage = string.Format(MasterPageResource.NameMaxLengthMessage, "name", MasterPageLengths.NameMaxLength)
            });
            form.Fields.Add("pageName", new TextField
            {
                Name                  = "pageName",
                Label                 = MasterPageResource.PageNameLabel,
                Required              = true,
                RequiredErrorMessage  = MasterPageResource.PageNameRequiredMessage,
                MaxLength             = MasterPageLengths.PageNameMaxLength,
                MaxLengthErrorMessage = string.Format(MasterPageResource.PageNameMaxLengthMessage, "pageName", MasterPageLengths.PageNameMaxLength)
            });
            form.Fields.Add("pageDescription", new MultiLineTextField
            {
                Name  = "pageDescription",
                Label = MasterPageResource.PageDescriptionLabel,
                Rows  = 4
            });
            form.Fields.Add("ancestorPageId", new SelectListField <string>
            {
                Name  = "ancestorPageId",
                Label = MasterPageResource.AncestorPageIdLabel,
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = MasterPageResource.AncestorPageIdDefaultOption, Value = string.Empty
                    }
                }
            });
            foreach (Page page in result.Items)
            {
                ((SelectListField <string>)form.Fields["ancestorPageId"]).Items.Add(new ListFieldItem <string> {
                    Name = page.Name, Value = page.PageId.ToString()
                });
            }
            form.Fields.Add("ancestorPageLevel", new SelectListField <string>
            {
                Name  = "ancestorPageLevel",
                Label = MasterPageResource.AncestorPageLevelLabel,
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = MasterPageResource.AncestorPageLevelDefaultOption, Value = string.Empty
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageLevel>(PageLevel.Parent), Value = ((int)PageLevel.Parent).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageLevel>(PageLevel.Grandparent), Value = ((int)PageLevel.Grandparent).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageLevel>(PageLevel.GreatGrandparent), Value = ((int)PageLevel.GreatGrandparent).ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = MasterPageResource.AncestorPageLevelRequiredMessage
            });
            form.Fields.Add("pageType", new SelectListField <string>
            {
                Name  = "pageType",
                Label = MasterPageResource.PageTypeLabel,
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageType>(PageType.Document), Value = ((int)PageType.Document).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageType>(PageType.Folder), Value = ((int)PageType.Folder).ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = MasterPageResource.PageTypeRequiredMessage
            });
            form.Fields.Add("hasOccurred", new BooleanField
            {
                Name  = "hasOccurred",
                Label = MasterPageResource.HasOccurredLabel
            });
            form.Fields.Add("hasImage", new BooleanField
            {
                Name  = "hasImage",
                Label = MasterPageResource.HasImageLabel
            });
            form.Fields.Add("thumbnailImageWidth", new IntegerField
            {
                Name                 = "thumbnailImageWidth",
                Label                = MasterPageResource.ThumbnailImageWidthLabel,
                Min                  = MasterPageValues.MinThumbnailImageWidth,
                MinErrorMessage      = string.Format(MasterPageResource.ThumbnailImageWidthMinErrorMessage, "thumbnailImageWidth", MasterPageValues.MinThumbnailImageWidth),
                Max                  = MasterPageValues.MaxThumbnailImageWidth,
                MaxErrorMessage      = string.Format(MasterPageResource.ThumbnailImageWidthMaxErrorMessage, "thumbnailImageWidth", MasterPageValues.MaxThumbnailImageWidth),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.ThumbnailImageWidthRequiredMessage
            });
            form.Fields.Add("thumbnailImageHeight", new IntegerField
            {
                Name                 = "thumbnailImageHeight",
                Label                = MasterPageResource.ThumbnailImageHeightLabel,
                Min                  = MasterPageValues.MinThumbnailImageHeight,
                MinErrorMessage      = string.Format(MasterPageResource.ThumbnailImageHeightMinErrorMessage, "thumbnailImageHeight", MasterPageValues.MinThumbnailImageHeight),
                Max                  = MasterPageValues.MaxThumbnailImageHeight,
                MaxErrorMessage      = string.Format(MasterPageResource.ThumbnailImageHeightMaxErrorMessage, "thumbnailImageHeight", MasterPageValues.MaxThumbnailImageHeight),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.ThumbnailImageHeightRequiredMessage
            });
            form.Fields.Add("thumbnailImageResizeMode", new SelectListField <string>
            {
                Name  = "thumbnailImageResizeMode",
                Label = MasterPageResource.ThumbnailImageResizeModeLabel,
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = MasterPageResource.ResizeModeDefaultOption, Value = string.Empty
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.Simple), Value = ((int)ResizeMode.Simple).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.MaintainAspect), Value = ((int)ResizeMode.MaintainAspect).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.Crop), Value = ((int)ResizeMode.Crop).ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = MasterPageResource.ThumbnailImageResizeModeRequiredMessage
            });
            form.Fields.Add("previewImageWidth", new IntegerField
            {
                Name                 = "previewImageWidth",
                Label                = MasterPageResource.PreviewImageWidthLabel,
                Min                  = MasterPageValues.MinPreviewImageWidth,
                MinErrorMessage      = string.Format(MasterPageResource.PreviewImageWidthMinErrorMessage, "previewImageWidth", MasterPageValues.MinPreviewImageWidth),
                Max                  = MasterPageValues.MaxPreviewImageWidth,
                MaxErrorMessage      = string.Format(MasterPageResource.PreviewImageWidthMaxErrorMessage, "previewImageWidth", MasterPageValues.MaxPreviewImageWidth),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.PreviewImageWidthRequiredMessage
            });
            form.Fields.Add("previewImageHeight", new IntegerField
            {
                Name                 = "previewImageHeight",
                Label                = MasterPageResource.PreviewImageHeightLabel,
                Min                  = MasterPageValues.MinPreviewImageHeight,
                MinErrorMessage      = string.Format(MasterPageResource.PreviewImageHeightMinErrorMessage, "previewImageHeight", MasterPageValues.MinPreviewImageHeight),
                Max                  = MasterPageValues.MaxPreviewImageHeight,
                MaxErrorMessage      = string.Format(MasterPageResource.PreviewImageHeightMaxErrorMessage, "previewImageHeight", MasterPageValues.MaxPreviewImageHeight),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.PreviewImageHeightRequiredMessage
            });
            form.Fields.Add("previewImageResizeMode", new SelectListField <string>
            {
                Name  = "previewImageResizeMode",
                Label = MasterPageResource.PreviewImageResizeModeLabel,
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = MasterPageResource.ResizeModeDefaultOption, Value = string.Empty
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.Simple), Value = ((int)ResizeMode.Simple).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.MaintainAspect), Value = ((int)ResizeMode.MaintainAspect).ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <ResizeMode>(ResizeMode.Crop), Value = ((int)ResizeMode.Crop).ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = MasterPageResource.PreviewImageResizeModeRequiredMessage
            });
            form.Fields.Add("imageMinWidth", new IntegerField
            {
                Name                 = "imageMinWidth",
                Label                = MasterPageResource.ImageMinWidthLabel,
                Min                  = MasterPageValues.MinImageMinWidth,
                MinErrorMessage      = string.Format(MasterPageResource.ImageMinWidthMinErrorMessage, "imageMinWidth", MasterPageValues.MinImageMinWidth),
                Max                  = MasterPageValues.MaxImageMinWidth,
                MaxErrorMessage      = string.Format(MasterPageResource.ImageMinWidthMaxErrorMessage, "imageMinWidth", MasterPageValues.MaxImageMinWidth),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.ImageMinWidthRequiredMessage
            });
            form.Fields.Add("imageMinHeight", new IntegerField
            {
                Name                 = "imageMinHeight",
                Label                = MasterPageResource.ImageMinHeightLabel,
                Min                  = MasterPageValues.MinImageMinHeight,
                MinErrorMessage      = string.Format(MasterPageResource.ImageMinHeightMinErrorMessage, "imageMinHeight", MasterPageValues.MinImageMinHeight),
                Max                  = MasterPageValues.MaxImageMinWidth,
                MaxErrorMessage      = string.Format(MasterPageResource.ImageMinHeightMaxErrorMessage, "imageMinHeight", MasterPageValues.MaxImageMinHeight),
                Required             = true,
                RequiredErrorMessage = MasterPageResource.ImageMinHeightRequiredMessage
            });
            form.Fields.Add("creatable", new BooleanField
            {
                Name  = "creatable",
                Label = MasterPageResource.CreatableLabel
            });
            form.Fields.Add("deletable", new BooleanField
            {
                Name  = "deletable",
                Label = MasterPageResource.DeletableLabel
            });
            form.Fields.Add("taggable", new BooleanField
            {
                Name  = "taggable",
                Label = MasterPageResource.TaggableLabel
            });
            form.Fields.Add("administration", new BooleanField
            {
                Name  = "administration",
                Label = MasterPageResource.AdministrationLabel
            });
            form.Fields.Add("beginRender", new MultiLineTextField
            {
                Name  = "beginRender",
                Label = MasterPageResource.BeginRenderLabel,
                Rows  = 4
            });
            form.Fields.Add("endRender", new MultiLineTextField
            {
                Name  = "endRender",
                Label = MasterPageResource.EndRenderLabel,
                Rows  = 4
            });

            // Return form
            return(form);
        }
        public Form GetForm(string context)
        {
            // Check permissions
            _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

            // Get page and element identifiers
            string[] parts     = context.Split('|');
            long     pageId    = Convert.ToInt64(parts[0]);
            long     elementId = Convert.ToInt64(parts[1]);

            // Get current page list settings
            Guid elementTypeId = FormId;
            IAdvancedElementService elementService   = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId);
            PageListSettings        pageListSettings = (PageListSettings)elementService.New(_authenticationService.TenantId);

            pageListSettings.ElementId = elementId;
            elementService.Read(pageListSettings);

            // Get possible parent pages for page list
            long tenantId = _authenticationService.TenantId;
            ISearchParameters searchParameters = new SearchParameters {
                PageIndex = 0, PageSize = 1000
            };                                                                                            // TODO: Need way to return all pages, not have some max bound upper limit
            ISearchResult <Page> result = _pageService.List(tenantId, searchParameters, null, PageSortBy.Name, true, true, PageType.Folder, false);

            // Construct form
            Form form = new Form {
                Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context
            };

            form.Fields.Add("displayName", new TextField
            {
                Name                  = "displayName",
                Label                 = ElementResource.PageListDisplayNameLabel,
                MaxLength             = PageListLengths.DisplayNameMaxLength,
                MaxLengthErrorMessage = string.Format(ElementResource.PageListDisplayNameMaxLengthMessage, "displayName", PageListLengths.DisplayNameMaxLength),
                Value                 = pageListSettings.DisplayName
            });
            form.Fields.Add("preamble", new MultiLineTextField
            {
                Name  = "preamble",
                Label = ElementResource.PageListPreambleLabel,
                Value = pageListSettings.Preamble,
                Rows  = 4
            });
            form.Fields.Add("page", new SelectListField <string>
            {
                Name  = "page",
                Label = ElementResource.PageListPageLabel,
                Value = pageListSettings.PageId == null ? string.Empty : pageListSettings.PageId.Value.ToString(),
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = ElementResource.FolderDefaultOption, Value = string.Empty
                    }
                }
            });
            foreach (Page page in result.Items)
            {
                ((SelectListField <string>)form.Fields["page"]).Items.Add(new ListFieldItem <string> {
                    Name = page.Name, Value = page.PageId.ToString()
                });
            }
            form.Fields.Add("sortBy", new SelectListField <string>
            {
                Name  = "sortBy",
                Label = ElementResource.PageListSortByLabel,
                Value = pageListSettings.SortBy.ToString(),
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageSortBy>(PageSortBy.Created), Value = PageSortBy.Created.ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageSortBy>(PageSortBy.Updated), Value = PageSortBy.Updated.ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageSortBy>(PageSortBy.Occurred), Value = PageSortBy.Occurred.ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageSortBy>(PageSortBy.Name), Value = PageSortBy.Name.ToString()
                    },
                },
                Required             = true,
                RequiredErrorMessage = ElementResource.PageListSortByRequiredMessage
            });
            form.Fields.Add("sortAsc", new SelectListField <string>
            {
                Name  = "sortAsc",
                Label = ElementResource.PageListSortAscLabel,
                Value = pageListSettings.SortAsc.ToString(),
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = ElementResource.PageListSortAscendingOption, Value = true.ToString()
                    },
                    new ListFieldItem <string> {
                        Name = ElementResource.PageListSortDescendingOption, Value = false.ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = ElementResource.PageListSortAscRequiredMessage
            });
            form.Fields.Add("showRelated", new BooleanField
            {
                Name  = "showRelated",
                Label = ElementResource.PageListShowRelatedLabel,
                Value = pageListSettings.ShowRelated
            });
            form.Fields.Add("showDescription", new BooleanField
            {
                Name  = "showDescription",
                Label = ElementResource.PageListShowDescriptionLabel,
                Value = pageListSettings.ShowDescription
            });
            form.Fields.Add("showImage", new BooleanField
            {
                Name  = "showImage",
                Label = ElementResource.PageListShowImageLabel,
                Value = pageListSettings.ShowImage
            });
            form.Fields.Add("showBackgroundImage", new BooleanField
            {
                Name  = "showBackgroundImage",
                Label = ElementResource.PageListShowBackgroundImageLabel,
                Value = pageListSettings.ShowBackgroundImage
            });
            form.Fields.Add("showCreated", new BooleanField
            {
                Name  = "showCreated",
                Label = ElementResource.PageListShowCreatedLabel,
                Value = pageListSettings.ShowCreated
            });
            form.Fields.Add("showUpdated", new BooleanField
            {
                Name  = "showUpdated",
                Label = ElementResource.PageListShowUpdatedLabel,
                Value = pageListSettings.ShowUpdated
            });
            form.Fields.Add("showOccurred", new BooleanField
            {
                Name  = "showOccurred",
                Label = ElementResource.PageListShowOccurredLabel,
                Value = pageListSettings.ShowOccurred
            });
            form.Fields.Add("showComments", new BooleanField
            {
                Name  = "showComments",
                Label = ElementResource.PageListShowCommentsLabel,
                Value = pageListSettings.ShowComments
            });
            form.Fields.Add("showTags", new BooleanField
            {
                Name  = "showTags",
                Label = ElementResource.PageListShowTagsLabel,
                Value = pageListSettings.ShowTags
            });
            form.Fields.Add("pageSize", new IntegerField
            {
                Name                 = "pageSize",
                Label                = ElementResource.PageListPageSizeLabel,
                Min                  = PageListLengths.PageSizeMinValue,
                Max                  = PageListLengths.PageSizeMaxValue,
                Value                = pageListSettings.PageSize,
                Required             = true,
                RequiredErrorMessage = ElementResource.PageListPageSizeRequiredMessage,
                MinErrorMessage      = string.Format(ElementResource.PageListPageSizeRangeMessage, "pageSize", PageListLengths.PageSizeMinValue, PageListLengths.PageSizeMaxValue),
                MaxErrorMessage      = string.Format(ElementResource.PageListPageSizeRangeMessage, "pageSize", PageListLengths.PageSizeMinValue, PageListLengths.PageSizeMaxValue)
            });
            form.Fields.Add("showPager", new BooleanField
            {
                Name  = "showPager",
                Label = ElementResource.PageListShowPagerLabel,
                Value = pageListSettings.ShowPager
            });
            form.Fields.Add("moreMessage", new TextField
            {
                Name                  = "moreMessage",
                Label                 = ElementResource.PageListMoreMessageLabel,
                MaxLength             = PageListLengths.MoreMessageMaxLength,
                MaxLengthErrorMessage = string.Format(ElementResource.PageListMoreMessageMaxLengthMessage, "moreMessage", PageListLengths.MoreMessageMaxLength),
                Value                 = pageListSettings.MoreMessage
            });
            form.Fields.Add("recursive", new BooleanField
            {
                Name  = "recursive",
                Label = ElementResource.PageListRecursiveLabel,
                Value = pageListSettings.Recursive
            });
            form.Fields.Add("pageType", new SelectListField <string>
            {
                Name  = "pageType",
                Label = ElementResource.PageListPageTypeLabel,
                Value = pageListSettings.PageType.ToString(),
                Items = new List <ListFieldItem <string> > {
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageType>(PageType.Document), Value = PageType.Document.ToString()
                    },
                    new ListFieldItem <string> {
                        Name = _dataAnnotationsService.GetEnumDisplayName <PageType>(PageType.Folder), Value = PageType.Folder.ToString()
                    }
                },
                Required             = true,
                RequiredErrorMessage = ElementResource.PageListPageTypeRequiredMessage
            });
            form.Fields.Add("noPagesMessage", new TextField
            {
                Name  = "noPagesMessage",
                Label = ElementResource.PageListNoPagesMessageLabel,
                Value = pageListSettings.NoPagesMessage
            });
            form.SubmitLabel = ElementResource.PageListButtonLabel;

            // Return result
            return(form);
        }
        public Form GetForm(string context)
        {
            // Check permissions
            _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

            // Get page and element identifiers
            string[] parts     = context.Split('|');
            long     pageId    = Convert.ToInt64(parts[0]);
            long     elementId = Convert.ToInt64(parts[1]);

            // Get current code snippet settings
            Guid elementTypeId = FormId;
            IAdvancedElementService elementService      = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId);
            CodeSnippetSettings     codeSnippetSettings = (CodeSnippetSettings)elementService.New(_authenticationService.TenantId);

            codeSnippetSettings.ElementId = elementId;
            elementService.Read(codeSnippetSettings);

            // Construct form
            Form form = new Form {
                Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context
            };

            form.Fields.Add("code", new MultiLineTextField
            {
                Name                 = "code",
                Label                = ElementResource.CodeSnippetCodeLabel,
                Value                = codeSnippetSettings.Code,
                Rows                 = 10,
                Required             = true,
                RequiredErrorMessage = ElementResource.CodeSnippetCodeRequiredMessage
            });

            form.Fields.Add("language", new SelectListField <string>
            {
                Name  = "language",
                Label = ElementResource.CodeSnippetLanguageLabel,
                Value = Convert.ToString((int)codeSnippetSettings.Language),
                Items = new List <ListFieldItem <string> >()
            });
            SelectListField <string> selectListField = (SelectListField <string>)form.Fields["language"];

            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Apache), Value = Convert.ToString((int)Language.Apache)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Bash), Value = Convert.ToString((int)Language.Bash)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.CoffeeScript), Value = Convert.ToString((int)Language.CoffeeScript)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.CPlusPlus), Value = Convert.ToString((int)Language.CPlusPlus)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.CSharp), Value = Convert.ToString((int)Language.CSharp)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Css), Value = Convert.ToString((int)Language.Css)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Diff), Value = Convert.ToString((int)Language.Diff)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Html), Value = Convert.ToString((int)Language.Html)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Http), Value = Convert.ToString((int)Language.Http)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Ini), Value = Convert.ToString((int)Language.Ini)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Java), Value = Convert.ToString((int)Language.Java)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.JavaScript), Value = Convert.ToString((int)Language.JavaScript)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Json), Value = Convert.ToString((int)Language.Json)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Makefile), Value = Convert.ToString((int)Language.Makefile)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Markdown), Value = Convert.ToString((int)Language.Markdown)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Nginx), Value = Convert.ToString((int)Language.Nginx)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.ObjectiveC), Value = Convert.ToString((int)Language.ObjectiveC)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Perl), Value = Convert.ToString((int)Language.Perl)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Php), Value = Convert.ToString((int)Language.Php)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Python), Value = Convert.ToString((int)Language.Python)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Ruby), Value = Convert.ToString((int)Language.Ruby)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Sql), Value = Convert.ToString((int)Language.Sql)
            });
            selectListField.Items.Add(new ListFieldItem <string> {
                Name = _dataAnnotationsService.GetEnumDisplayName <Language>(Language.Xml), Value = Convert.ToString((int)Language.Xml)
            });
            form.SubmitLabel = ElementResource.CodeSnippetButtonLabel;

            // Return result
            return(form);
        }