private Form GetAlbumForm(string context, long elementId) { // Get current album settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); AlbumSettings albumSettings = (AlbumSettings)elementService.New(_authenticationService.TenantId); albumSettings.ElementId = elementId; elementService.Read(albumSettings); // Get album photo view models List <AlbumPhotoViewModel> photoViewModels = new List <AlbumPhotoViewModel>(); foreach (AlbumPhoto photo in albumSettings.Photos) { AlbumPhotoViewModel photoViewModel = new AlbumPhotoViewModel { AlbumPhotoId = photo.AlbumPhotoId.ToString(), PreviewImageUploadId = photo.PreviewImageUploadId.ToString(), Name = photo.Name, Description = photo.Description, ImageUrl = string.Format("/elements/{0}/uploads/{1}?format=preview&t={1}", photo.ElementId, photo.AlbumPhotoId) }; photoViewModels.Add(photoViewModel); } string data = JsonConvert.SerializeObject(photoViewModels); // Return form with data return(new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context, Data = data }); }
private Form GetSlidesForm(string context, long elementId) { // Get current carousel settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); CarouselSettings carouselSettings = (CarouselSettings)elementService.New(_authenticationService.TenantId); carouselSettings.ElementId = elementId; elementService.Read(carouselSettings); // Get carousel slide view models List <CarouselSlideViewModel> slideViewModels = new List <CarouselSlideViewModel>(); foreach (CarouselSlide slide in carouselSettings.Slides) { slideViewModels.Add(GetSlideViewModel(slide, false)); } string data = JsonConvert.SerializeObject(slideViewModels); // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context, Data = data }; form.SubmitLabel = ElementResource.CarouselButtonLabel; // Return result return(form); }
private Form GetUserForm(string context) { // Get page and element identifiers string[] parts = context.Split('|'); long pageId = Convert.ToInt64(parts[1]); long elementId = Convert.ToInt64(parts[2]); // Get form settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); FormSettings formSettings = (FormSettings)elementService.New(_authenticationService.TenantId); formSettings.ElementId = elementId; elementService.Read(formSettings); // Construct form Form form = new Form { FieldSets = new List <FormFieldSet>(), Id = FormId.ToString(), Context = context, SubmitLabel = formSettings.SubmitButtonLabel }; // Populate fields from form settings foreach (FormElementField formElementField in formSettings.Fields) { FormFieldSet fieldSet = new FormFieldSet { Fields = new Dictionary <string, IFormField>() }; switch (formElementField.FieldType) { case FormElementFieldType.TextField: fieldSet.Fields.Add("field", new TextField { Name = "field_" + formElementField.FormFieldId, Label = formElementField.Label, Required = formElementField.Required, RequiredErrorMessage = string.Format(ElementResource.FormFieldRequiredMessage, formElementField.Label) }); break; case FormElementFieldType.MultiLineTextField: fieldSet.Fields.Add("field", new MultiLineTextField { Name = "field_" + formElementField.FormFieldId, Label = formElementField.Label, Required = formElementField.Required, RequiredErrorMessage = string.Format(ElementResource.FormFieldRequiredMessage, formElementField.Label), Rows = 5 }); break; } form.FieldSets.Add(fieldSet); } // 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 map settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); MapSettings mapSettings = (MapSettings)elementService.New(_authenticationService.TenantId); mapSettings.ElementId = elementId; elementService.Read(mapSettings); // 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.MapDisplayNameLabel, MaxLength = MapLengths.DisplayNameMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.MapDisplayNameMaxLengthMessage, "displayName", MapLengths.DisplayNameMaxLength), Value = mapSettings.DisplayName }); form.Fields.Add("latitude", new TextField { // TODO: Implement this using numeric form field that accepts decimals Name = "latitude", Label = ElementResource.MapLatitudeLabel, MaxLength = MapLengths.LatitudeMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.MapLatitudeMaxLengthMessage, "latitude", MapLengths.LatitudeMaxLength), Value = mapSettings.Latitude.ToString(), Required = true, RequiredErrorMessage = ElementResource.MapLatitudeRequiredMessage }); form.Fields.Add("longitude", new TextField { // TODO: Implement this using numeric form field that accepts decimals Name = "longitude", Label = ElementResource.MapLongitudeLabel, MaxLength = MapLengths.LongitudeMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.MapLongitudeMaxLengthMessage, "longitude", MapLengths.LongitudeMaxLength), Value = mapSettings.Longitude.ToString(), Required = true, RequiredErrorMessage = ElementResource.MapLongitudeRequiredMessage }); form.SubmitLabel = ElementResource.MapButtonLabel; // 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 nav bar settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); NavBarSettings navBarSettings = (NavBarSettings)elementService.New(_authenticationService.TenantId); navBarSettings.ElementId = elementId; elementService.Read(navBarSettings); // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context }; form.Fields.Add("navBarName", new TextField { Name = "navBarName", Label = ElementResource.NavBarNameLabel, Value = navBarSettings.NavBarName }); form.Fields.Add("showLoggedOffUserOptions", new BooleanField { Name = "showLoggedOffUserOptions", Label = ElementResource.ShowLoggedOffUserOptionsLabel, Value = navBarSettings.ShowLoggedOffUserOptions }); form.Fields.Add("showLoggedOnUserOptions", new BooleanField { Name = "showLoggedOnUserOptions", Label = ElementResource.ShowLoggedOnUserOptionsLabel, Value = navBarSettings.ShowLoggedOnUserOptions }); form.SubmitLabel = ElementResource.NavBarButtonLabel; // Get form field sets IEnumerable <Page> foldersAndDocuments = GetFoldersAndDocuments(); form.FieldSets = GetFieldSets(navBarSettings, foldersAndDocuments); form.NamedFieldSets = GetNamedFieldSets(foldersAndDocuments); // 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 footer settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); FooterSettings footerSettings = (FooterSettings)elementService.New(_authenticationService.TenantId); footerSettings.ElementId = elementId; elementService.Read(footerSettings); // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context }; form.Fields.Add("message", new MultiLineTextField { Name = "message", Label = ElementResource.FooterMessageLabel, Value = footerSettings.Message, Rows = 10 }); form.Fields.Add("showLoggedOffUserOptions", new BooleanField { Name = "showLoggedOffUserOptions", Label = ElementResource.ShowLoggedOffUserOptionsLabel, Value = footerSettings.ShowLoggedOffUserOptions }); form.Fields.Add("showLoggedOnUserOptions", new BooleanField { Name = "showLoggedOnUserOptions", Label = ElementResource.ShowLoggedOnUserOptionsLabel, Value = footerSettings.ShowLoggedOnUserOptions }); form.SubmitLabel = ElementResource.FooterButtonLabel; // 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 HTML settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); HtmlSettings htmlSettings = (HtmlSettings)elementService.New(_authenticationService.TenantId); htmlSettings.ElementId = elementId; elementService.Read(htmlSettings); // Construct form Form form = new Form { Fields = new Dictionary<string, IFormField>(), Id = FormId.ToString(), Context = context }; form.Fields.Add("html", new MultiLineTextField { Name = "html", Label = ElementResource.HtmlHtmlLabel, Value = htmlSettings.Html, Rows = 15 }); form.Fields.Add("upload", new UploadField { Name = "upload", Label = ElementResource.HtmlUploadLabel }); form.SubmitLabel = ElementResource.HtmlButtonLabel; // Return result return form; }
private Form GetPhotosForm(string context, long elementId) { // Get current album settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); AlbumSettings albumSettings = (AlbumSettings)elementService.New(_authenticationService.TenantId); albumSettings.ElementId = elementId; elementService.Read(albumSettings); // Get album photo view models List <AlbumPhotoViewModel> photoViewModels = new List <AlbumPhotoViewModel>(); foreach (AlbumPhoto photo in albumSettings.Photos) { photoViewModels.Add(GetPhotoViewModel(photo, false)); } string data = JsonConvert.SerializeObject(photoViewModels); // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context, Data = data }; form.Fields.Add("displayName", new TextField { Name = "displayName", Label = ElementResource.AlbumDisplayNameLabel, MaxLength = AlbumLengths.DisplayNameMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.AlbumDisplayNameMaxLengthMessage, "displayName", AlbumLengths.DisplayNameMaxLength), Value = albumSettings.DisplayName }); form.SubmitLabel = ElementResource.AlbumButtonLabel; // Return result return(form); }
private Form GetAdminForm(string context) { // Check permissions _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements); // Get page and element identifiers string[] parts = context.Split('|'); long pageId = Convert.ToInt64(parts[1]); long elementId = Convert.ToInt64(parts[2]); // Get current form settings IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId); FormSettings formSettings = (FormSettings)elementService.New(_authenticationService.TenantId); formSettings.ElementId = elementId; elementService.Read(formSettings); // Construct main form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context, FieldSets = new List <FormFieldSet>() }; form.Fields.Add("recipientEmail", new MultiLineTextField { Name = "recipientEmail", Label = ElementResource.FormRecipientEmailLabel, Required = true, RequiredErrorMessage = ElementResource.FormRecipientEmailRequiredMessage, Value = formSettings.RecipientEmail, Rows = 4 }); form.Fields.Add("submitButtonLabel", new TextField { Name = "submitButtonLabel", Label = ElementResource.FormSubmitButtonLabelLabel, Required = true, RequiredErrorMessage = ElementResource.FormSubmitButtonLabelRequiredMessage, MaxLength = FormLengths.SubmitButtonLabelMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.FormSubmitButtonLabelMaxLengthMessage, "submitButtonLabel", FormLengths.SubmitButtonLabelMaxLength), Value = formSettings.SubmitButtonLabel }); form.Fields.Add("submittedMessage", new TextField { Name = "submittedMessage", Label = ElementResource.FormSubmittedMessageLabel, Required = true, RequiredErrorMessage = ElementResource.FormSubmittedMessageRequiredMessage, Value = formSettings.SubmittedMessage }); form.SubmitLabel = ElementResource.FormButtonLabel; // Add form fields foreach (FormElementField field in formSettings.Fields) { FormFieldSet fieldSet = new FormFieldSet { Fields = new Dictionary <string, IFormField>() }; fieldSet.Fields.Add("label", new TextField { Name = string.Format("field_{0}_label", field.FormFieldId), Label = ElementResource.FormFieldLabelLabel, Required = true, RequiredErrorMessage = ElementResource.FormFieldLabelRequiredMessage, Value = field.Label }); fieldSet.Fields.Add("type", new SelectListField <string> { Name = string.Format("field_{0}_type", field.FormFieldId), Label = ElementResource.FormFieldTypeLabel, Value = field.FieldType.ToString(), Items = new List <ListFieldItem <string> > { new ListFieldItem <string> { Name = ElementResource.FormFieldTypeTextLabel, Value = FormElementFieldType.TextField.ToString() }, new ListFieldItem <string> { Name = ElementResource.FormFieldTypeMultiLineLabel, Value = FormElementFieldType.MultiLineTextField.ToString() }, } }); fieldSet.Fields.Add("required", new BooleanField { Name = string.Format("field_{0}_required", field.FormFieldId), Label = ElementResource.FormFieldRequiredLabel, Value = field.Required }); form.FieldSets.Add(fieldSet); } // Fields set containing default fields for a new form field form.NamedFieldSets = new Dictionary <string, FormFieldSet>(); FormFieldSet namedFieldSet = new FormFieldSet { Fields = new Dictionary <string, IFormField>() }; long formFieldId = 0; namedFieldSet.Fields.Add("label", new TextField { Name = string.Format("field_{0}_label", formFieldId), Label = ElementResource.FormFieldLabelLabel, Required = true, RequiredErrorMessage = ElementResource.FormFieldLabelRequiredMessage, Value = ElementResource.FormFieldLabelDefaultValue }); namedFieldSet.Fields.Add("type", new SelectListField <string> { Name = string.Format("field_{0}_type", formFieldId), Label = ElementResource.FormFieldTypeLabel, Value = FormElementFieldType.TextField.ToString(), Items = new List <ListFieldItem <string> > { new ListFieldItem <string> { Name = ElementResource.FormFieldTypeTextLabel, Value = FormElementFieldType.TextField.ToString() }, new ListFieldItem <string> { Name = ElementResource.FormFieldTypeMultiLineLabel, Value = FormElementFieldType.MultiLineTextField.ToString() }, } }); namedFieldSet.Fields.Add("required", new BooleanField { Name = string.Format("field_{0}_required", formFieldId), Label = ElementResource.FormFieldRequiredLabel, Value = false }); form.NamedFieldSets.Add("newField", namedFieldSet); // 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 page header settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); PageHeaderSettings pageHeaderSettings = (PageHeaderSettings)elementService.New(_authenticationService.TenantId); pageHeaderSettings.ElementId = elementId; elementService.Read(pageHeaderSettings); // Get possible pages for page header 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> folderResult = _pageService.List(tenantId, searchParameters, null, PageSortBy.Name, true, true, PageType.Folder, false); ISearchResult <Page> documentResult = _pageService.List(tenantId, searchParameters, null, PageSortBy.Name, true, true, PageType.Document, false); IEnumerable <Page> foldersAndDocuments = folderResult.Items.Concat(documentResult.Items).OrderBy(p => p.Name); // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), Id = FormId.ToString(), Context = context }; form.Fields.Add("showName", new BooleanField { Name = "showName", Label = ElementResource.PageHeaderShowNameLabel, Value = pageHeaderSettings.ShowName }); form.Fields.Add("showDescription", new BooleanField { Name = "showDescription", Label = ElementResource.PageHeaderShowDescriptionLabel, Value = pageHeaderSettings.ShowDescription }); form.Fields.Add("showImage", new BooleanField { Name = "showImage", Label = ElementResource.PageHeaderShowImageLabel, Value = pageHeaderSettings.ShowImage }); form.Fields.Add("showCreated", new BooleanField { Name = "showCreated", Label = ElementResource.PageHeaderShowCreatedLabel, Value = pageHeaderSettings.ShowCreated }); form.Fields.Add("showUpdated", new BooleanField { Name = "showUpdated", Label = ElementResource.PageHeaderShowUpdatedLabel, Value = pageHeaderSettings.ShowUpdated }); form.Fields.Add("showOccurred", new BooleanField { Name = "showOccurred", Label = ElementResource.PageHeaderShowOccurredLabel, Value = pageHeaderSettings.ShowUpdated }); form.Fields.Add("showBreadcrumbs", new BooleanField { Name = "showBreadcrumbs", Label = ElementResource.PageHeaderShowBreadcrumbsLabel, Value = pageHeaderSettings.ShowBreadcrumbs }); form.Fields.Add("page", new SelectListField <string> { Name = "page", Label = ElementResource.PageHeaderPageLabel, Value = pageHeaderSettings.PageId == null ? string.Empty : pageHeaderSettings.PageId.Value.ToString(), Items = new List <ListFieldItem <string> > { new ListFieldItem <string> { Name = ElementResource.PageDefaultOption, Value = string.Empty } } }); foreach (Page page in foldersAndDocuments) { ((SelectListField <string>)form.Fields["page"]).Items.Add(new ListFieldItem <string> { Name = page.Name, Value = page.PageId.ToString() }); } form.SubmitLabel = ElementResource.PageHeaderButtonLabel; // 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 latest thread settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); LatestThreadSettings latestThreadSettings = (LatestThreadSettings)elementService.New(_authenticationService.TenantId); latestThreadSettings.ElementId = elementId; elementService.Read(latestThreadSettings); // Get possible parent pages for latest thread 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.LatestThreadDisplayNameLabel, MaxLength = LatestThreadLengths.DisplayNameMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.LatestThreadDisplayNameMaxLengthMessage, "displayName", LatestThreadLengths.DisplayNameMaxLength), Value = latestThreadSettings.DisplayName }); form.Fields.Add("preamble", new MultiLineTextField { Name = "preamble", Label = ElementResource.LatestThreadPreambleLabel, Value = latestThreadSettings.Preamble, Rows = 4 }); form.Fields.Add("page", new SelectListField <string> { Name = "page", Label = ElementResource.LatestThreadPageLabel, Value = latestThreadSettings.PageId == null ? string.Empty : latestThreadSettings.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("pageSize", new IntegerField { Name = "pageSize", Label = ElementResource.LatestThreadPageSizeLabel, Min = LatestThreadLengths.PageSizeMinValue, Max = LatestThreadLengths.PageSizeMaxValue, Value = latestThreadSettings.PageSize, Required = true, RequiredErrorMessage = ElementResource.LatestThreadPageSizeRequiredMessage, MinErrorMessage = string.Format(ElementResource.PageListPageSizeRangeMessage, "pageSize", LatestThreadLengths.PageSizeMinValue, LatestThreadLengths.PageSizeMaxValue), MaxErrorMessage = string.Format(ElementResource.PageListPageSizeRangeMessage, "pageSize", LatestThreadLengths.PageSizeMinValue, LatestThreadLengths.PageSizeMaxValue) }); form.Fields.Add("recursive", new BooleanField { Name = "recursive", Label = ElementResource.LatestThreadRecursiveLabel, Value = latestThreadSettings.Recursive }); form.Fields.Add("noThreadsMessage", new TextField { Name = "noThreadsMessage", Label = ElementResource.LatestThreadNoThreadsMessageLabel, Value = latestThreadSettings.NoThreadsMessage, Required = true, RequiredErrorMessage = ElementResource.LatestThreadNoThreadsMessageRequiredMessage }); form.SubmitLabel = ElementResource.LatestThreadButtonLabel; // 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 share settings Guid elementTypeId = FormId; IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId); ShareSettings shareSettings = (ShareSettings)elementService.New(_authenticationService.TenantId); shareSettings.ElementId = elementId; elementService.Read(shareSettings); // 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.ShareDisplayNameLabel, MaxLength = ShareLengths.DisplayNameMaxLength, MaxLengthErrorMessage = string.Format(ElementResource.ShareDisplayNameMaxLengthMessage, "displayName", ShareLengths.DisplayNameMaxLength), Value = shareSettings.DisplayName }); form.Fields.Add("shareOnDigg", new BooleanField { Name = "shareOnDigg", Label = ElementResource.ShareShareOnDiggLabel, Value = shareSettings.ShareOnDigg }); form.Fields.Add("shareOnFacebook", new BooleanField { Name = "shareOnFacebook", Label = ElementResource.ShareShareOnFacebookLabel, Value = shareSettings.ShareOnFacebook }); form.Fields.Add("shareOnGoogle", new BooleanField { Name = "shareOnGoogle", Label = ElementResource.ShareShareOnGoogleLabel, Value = shareSettings.ShareOnGoogle }); form.Fields.Add("shareOnLinkedIn", new BooleanField { Name = "shareOnLinkedIn", Label = ElementResource.ShareShareOnLinkedInLabel, Value = shareSettings.ShareOnLinkedIn }); form.Fields.Add("shareOnPinterest", new BooleanField { Name = "shareOnPinterest", Label = ElementResource.ShareShareOnPinterestLabel, Value = shareSettings.ShareOnPinterest }); form.Fields.Add("shareOnReddit", new BooleanField { Name = "shareOnReddit", Label = ElementResource.ShareShareOnRedditLabel, Value = shareSettings.ShareOnReddit }); form.Fields.Add("shareOnStumbleUpon", new BooleanField { Name = "shareOnStumbleUpon", Label = ElementResource.ShareShareOnStumbleUponLabel, Value = shareSettings.ShareOnStumbleUpon }); form.Fields.Add("shareOnTumblr", new BooleanField { Name = "shareOnTumblr", Label = ElementResource.ShareShareOnTumblrLabel, Value = shareSettings.ShareOnTumblr }); form.Fields.Add("shareOnTwitter", new BooleanField { Name = "shareOnTwitter", Label = ElementResource.ShareShareOnTwitterLabel, Value = shareSettings.ShareOnTwitter }); form.SubmitLabel = ElementResource.ShareButtonLabel; // 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 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); }