Exemple #1
0
        private FormResult PostAdminForm(Form form)
        {
            // Check permissions
            _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

            // Get the tag cloud element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated form settings
            FormSettings formSettings = (FormSettings)elementService.New(_authenticationService.TenantId);

            formSettings.ElementId         = elementId;
            formSettings.Fields            = GetFields(elementId, form);
            formSettings.RecipientEmail    = ((MultiLineTextField)form.Fields["recipientEmail"]).Value;
            formSettings.SubmitButtonLabel = ((TextField)form.Fields["submitButtonLabel"]).Value;
            formSettings.SubmittedMessage  = ((TextField)form.Fields["submittedMessage"]).Value;

            // Perform the update
            elementService.Update(formSettings);

            // Return form result with no errors
            return(_formHelperService.GetFormResult());
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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
            });
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get the HTML element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated map settings
                MapSettings mapSettings = (MapSettings)elementService.New(_authenticationService.TenantId);
                mapSettings.ElementId   = elementId;
                mapSettings.DisplayName = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;

                // Get longitude and latitude
                double latitude;
                double longitude;
                string latitudeText     = ((TextField)form.Fields["latitude"]).Value;
                string longitudeText    = ((TextField)form.Fields["longitude"]).Value;
                bool   latitudeSuccess  = Double.TryParse(latitudeText, out latitude);
                bool   longitudeSuccess = Double.TryParse(longitudeText, out longitude);
                if (!latitudeSuccess)
                {
                    throw new ValidationErrorException(new ValidationError("latitude", ElementResource.MapLatitudeInvalidMessage));
                }
                if (!longitudeSuccess)
                {
                    throw new ValidationErrorException(new ValidationError("longitude", ElementResource.MapLongitudeInvalidMessage));
                }
                mapSettings.Latitude  = latitude;
                mapSettings.Longitude = longitude;

                // Perform the update
                elementService.Update(mapSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get page header page
                string pageValue          = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  pageHeaderPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  pageHeaderTenantId = pageHeaderPageId.HasValue ? (long?)tenantId : null;

                // Get the page header element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated page header settings
                PageHeaderSettings pageHeaderSettings = (PageHeaderSettings)elementService.New(_authenticationService.TenantId);
                pageHeaderSettings.ElementId       = elementId;
                pageHeaderSettings.PageId          = pageHeaderPageId;
                pageHeaderSettings.PageTenantId    = pageHeaderTenantId;
                pageHeaderSettings.ShowCreated     = ((BooleanField)form.Fields["showCreated"]).Value;
                pageHeaderSettings.ShowDescription = ((BooleanField)form.Fields["showDescription"]).Value;
                pageHeaderSettings.ShowImage       = ((BooleanField)form.Fields["showImage"]).Value;
                pageHeaderSettings.ShowName        = ((BooleanField)form.Fields["showName"]).Value;
                pageHeaderSettings.ShowOccurred    = ((BooleanField)form.Fields["showOccurred"]).Value;
                pageHeaderSettings.ShowUpdated     = ((BooleanField)form.Fields["showUpdated"]).Value;
                pageHeaderSettings.ShowBreadcrumbs = ((BooleanField)form.Fields["showBreadcrumbs"]).Value;

                // Perform the update
                elementService.Update(pageHeaderSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        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 FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get latest thread page
                string pageValue            = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  latestThreadPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  latestThreadTenantId = latestThreadPageId.HasValue ? (long?)tenantId : null;

                // Get the latest thread element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated latest thread settings
                LatestThreadSettings latestThreadSettings = (LatestThreadSettings)elementService.New(_authenticationService.TenantId);
                latestThreadSettings.ElementId        = elementId;
                latestThreadSettings.DisplayName      = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                latestThreadSettings.Preamble         = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? null : ((MultiLineTextField)form.Fields["preamble"]).Value;
                latestThreadSettings.PageId           = latestThreadPageId;
                latestThreadSettings.PageTenantId     = latestThreadTenantId;
                latestThreadSettings.PageSize         = ((IntegerField)form.Fields["pageSize"]).Value.Value;
                latestThreadSettings.Recursive        = ((BooleanField)form.Fields["recursive"]).Value;
                latestThreadSettings.NoThreadsMessage = ((TextField)form.Fields["noThreadsMessage"]).Value;

                // Perform the update
                elementService.Update(latestThreadSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
Exemple #10
0
        /// <summary>
        /// Creates a new element.
        /// </summary>
        /// <param name="settings">New element settings.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <returns>Newly allocated element identifier.</returns>
        public long Create(IElementSettings settings, IUnitOfWork unitOfWork = null)
        {
            try
            {
                IAdvancedElementService customElementService   = (IAdvancedElementService)_elementFactory.GetElementService(settings.ElementTypeId);
                ICustomElementValidator customElementValidator = _elementFactory.GetElementValidator(settings.ElementTypeId);
                IUnitOfWork             localUnitOfWork        = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

                try
                {
                    if (customElementValidator != null)
                    {
                        customElementValidator.ValidateCreate(settings, unitOfWork ?? localUnitOfWork);
                    }
                    settings.ElementId = _elementRepository.Create(settings, unitOfWork ?? localUnitOfWork);
                    if (customElementService != null)
                    {
                        customElementService.Create(settings, unitOfWork ?? localUnitOfWork);
                    }
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Commit();
                    }
                    return(settings.ElementId);
                }
                catch
                {
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Rollback();
                    }
                    throw;
                }
                finally
                {
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Dispose();
                    }
                }
            }
            catch (ValidationErrorException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
            }
        }
Exemple #11
0
 /// <summary>
 /// Deletes an element.
 /// </summary>
 /// <param name="tenantId">The tenant that element to delete belongs to.</param>
 /// <param name="elementTypeId">Identifies the type of element to delete.</param>
 /// <param name="elementId">Identifies the element to delete.</param>
 /// <param name="unitOfWork">Unit of work.</param>
 public void Delete(long tenantId, Guid elementTypeId, long elementId, IUnitOfWork unitOfWork = null)
 {
     try
     {
         IAdvancedElementService customElementService   = (IAdvancedElementService)_elementFactory.GetElementService(elementTypeId);
         ICustomElementValidator customElementValidator = _elementFactory.GetElementValidator(elementTypeId);
         IUnitOfWork             localUnitOfWork        = (unitOfWork == null && customElementService != null) ? _unitOfWorkFactory.CreateUnitOfWork() : null;
         try
         {
             if (customElementValidator != null)
             {
                 customElementValidator.ValidateDelete(tenantId, elementTypeId, elementId, unitOfWork ?? localUnitOfWork);
             }
             if (customElementService != null)
             {
                 customElementService.Delete(tenantId, elementId, unitOfWork ?? localUnitOfWork);
             }
             _elementRepository.Delete(tenantId, elementId, unitOfWork ?? localUnitOfWork);
             if (localUnitOfWork != null)
             {
                 localUnitOfWork.Commit();
             }
         }
         catch
         {
             if (localUnitOfWork != null)
             {
                 localUnitOfWork.Rollback();
             }
             throw;
         }
         finally
         {
             if (localUnitOfWork != null)
             {
                 localUnitOfWork.Dispose();
             }
         }
     }
     catch (ValidationErrorException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
     }
 }
        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);
        }
Exemple #13
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get the share element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated share settings
                ShareSettings shareSettings = (ShareSettings)elementService.New(_authenticationService.TenantId);
                shareSettings.ElementId          = elementId;
                shareSettings.DisplayName        = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                shareSettings.ShareOnDigg        = ((BooleanField)form.Fields["shareOnDigg"]).Value;
                shareSettings.ShareOnFacebook    = ((BooleanField)form.Fields["shareOnFacebook"]).Value;
                shareSettings.ShareOnGoogle      = ((BooleanField)form.Fields["shareOnGoogle"]).Value;
                shareSettings.ShareOnLinkedIn    = ((BooleanField)form.Fields["shareOnLinkedIn"]).Value;
                shareSettings.ShareOnPinterest   = ((BooleanField)form.Fields["shareOnPinterest"]).Value;
                shareSettings.ShareOnReddit      = ((BooleanField)form.Fields["shareOnReddit"]).Value;
                shareSettings.ShareOnStumbleUpon = ((BooleanField)form.Fields["shareOnStumbleUpon"]).Value;
                shareSettings.ShareOnTumblr      = ((BooleanField)form.Fields["shareOnTumblr"]).Value;
                shareSettings.ShareOnTwitter     = ((BooleanField)form.Fields["shareOnTwitter"]).Value;

                // Perform the update
                elementService.Update(shareSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get the nav bar element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get existing nav bar settings
                NavBarSettings navBarSettings = (NavBarSettings)elementService.New(_authenticationService.TenantId);
                navBarSettings.ElementId = elementId;

                // Update nav bar settings
                navBarSettings.Tabs       = GetTabs(tenantId, elementId, form);
                navBarSettings.NavBarName = string.IsNullOrWhiteSpace(((TextField)form.Fields["navBarName"]).Value) ? null : ((TextField)form.Fields["navBarName"]).Value;
                navBarSettings.ShowLoggedOffUserOptions = ((BooleanField)form.Fields["showLoggedOffUserOptions"]).Value;
                navBarSettings.ShowLoggedOnUserOptions  = ((BooleanField)form.Fields["showLoggedOnUserOptions"]).Value;

                // Perform the update
                elementService.Update(navBarSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
Exemple #15
0
        /// <summary>
        /// Creates new element based on existing element.
        /// </summary>
        /// <param name="sourceTenantId">The source tenant.</param>
        /// <param name="sourceElementId">Identifies element instance to copy.</param>
        /// <param name="destTenantId">The destination tenant.</param>
        /// <param name="sourceElementTypeId">The type of the element that is copied (destination will be same type).</param>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <returns>Newly allocated element identifier.</returns>
        public long Copy(long sourceTenantId, long sourceElementId, long destTenantId, Guid sourceElementTypeId, IUnitOfWork unitOfWork = null)
        {
            try
            {
                IAdvancedElementService customElementService = (IAdvancedElementService)_elementFactory.GetElementService(sourceElementTypeId);
                IUnitOfWork             localUnitOfWork      = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

                try
                {
                    long destElementId = _elementRepository.Copy(sourceTenantId, sourceElementId, destTenantId, unitOfWork ?? localUnitOfWork);
                    customElementService.Copy(sourceTenantId, sourceElementId, destTenantId, destElementId, unitOfWork ?? localUnitOfWork);
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Commit();
                    }
                    return(destElementId);
                }
                catch
                {
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Rollback();
                    }
                    throw;
                }
                finally
                {
                    if (localUnitOfWork != null)
                    {
                        localUnitOfWork.Dispose();
                    }
                }
            }
            catch (ValidationErrorException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
            }
        }
Exemple #16
0
        private void PostSlidesForm(Form form, long pageId, long elementId)
        {
            // Get tenant ID
            long tenantId = _authenticationService.TenantId;

            // Get element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated carousel settings
            CarouselSettings carouselSettings = (CarouselSettings)elementService.New(_authenticationService.TenantId);

            carouselSettings.ElementId = elementId;
            carouselSettings.Slides    = new List <CarouselSlide>();
            List <CarouselSlideViewModel> slideViewModels = JsonConvert.DeserializeObject <List <CarouselSlideViewModel> >(form.Data);

            for (int index = 0; index < slideViewModels.Count; index++)
            {
                CarouselSlideViewModel slideViewModel = slideViewModels[index];
                carouselSettings.Slides.Add(new CarouselSlide
                {
                    CarouselSlideId        = Convert.ToInt64(slideViewModel.CarouselSlideId),
                    Description            = slideViewModel.Description,
                    ElementId              = elementId,
                    ImageTenantId          = tenantId,
                    ImageUploadId          = Convert.ToInt64(slideViewModel.ImageUploadId),
                    Name                   = slideViewModel.Name,
                    PageId                 = string.IsNullOrWhiteSpace(slideViewModel.PageId) ? null : (long?)Convert.ToInt64(slideViewModel.PageId),
                    PageText               = string.IsNullOrWhiteSpace(slideViewModel.PageText) ? null : slideViewModel.PageText,
                    PageTenantId           = string.IsNullOrWhiteSpace(slideViewModel.PageId) ? null : (long?)tenantId,
                    PreviewImageUploadId   = Convert.ToInt64(slideViewModel.PreviewImageUploadId),
                    SortOrder              = index,
                    TenantId               = tenantId,
                    ThumbnailImageUploadId = Convert.ToInt64(slideViewModel.ThumbnailImageUploadId)
                });
            }

            // Perform the update
            elementService.Update(carouselSettings);
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get the code snippet element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated code snippet settings
                CodeSnippetSettings codeSnippetSettings = (CodeSnippetSettings)elementService.New(_authenticationService.TenantId);
                codeSnippetSettings.ElementId = elementId;
                codeSnippetSettings.Code      = ((MultiLineTextField)form.Fields["code"]).Value;
                codeSnippetSettings.Language  = (Language)Convert.ToInt32(((SelectListField <string>)form.Fields["language"]).Value);

                // Perform the update
                elementService.Update(codeSnippetSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get the HTML element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated HTML settings
                HtmlSettings htmlSettings = (HtmlSettings)elementService.New(_authenticationService.TenantId);
                htmlSettings.ElementId = elementId;
                htmlSettings.Html = ((MultiLineTextField)form.Fields["html"]).Value;

                // Perform the update
                elementService.Update(htmlSettings);

                // Return form result with no errors
                return _formHelperService.GetFormResult();
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return _formHelperService.GetFormResultWithValidationErrors(ex.Errors);
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return _formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage);
            }
        }
Exemple #19
0
        private void PostPhotosForm(Form form, long pageId, long elementId)
        {
            // Get tenant ID
            long tenantId = _authenticationService.TenantId;

            // Get element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated album settings
            AlbumSettings albumSettings = (AlbumSettings)elementService.New(_authenticationService.TenantId);

            albumSettings.ElementId   = elementId;
            albumSettings.DisplayName = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
            albumSettings.Photos      = new List <AlbumPhoto>();
            List <AlbumPhotoViewModel> photoViewModels = JsonConvert.DeserializeObject <List <AlbumPhotoViewModel> >(form.Data);

            for (int index = 0; index < photoViewModels.Count; index++)
            {
                AlbumPhotoViewModel photoViewModel = photoViewModels[index];
                albumSettings.Photos.Add(new AlbumPhoto {
                    AlbumPhotoId           = Convert.ToInt64(photoViewModel.AlbumPhotoId),
                    Description            = photoViewModel.Description,
                    ElementId              = elementId,
                    ImageTenantId          = tenantId,
                    ImageUploadId          = Convert.ToInt64(photoViewModel.ImageUploadId),
                    Name                   = photoViewModel.Name,
                    PreviewImageUploadId   = Convert.ToInt64(photoViewModel.PreviewImageUploadId),
                    SortOrder              = index,
                    TenantId               = tenantId,
                    ThumbnailImageUploadId = Convert.ToInt64(photoViewModel.ThumbnailImageUploadId)
                });
            }

            // Perform the update
            elementService.Update(albumSettings);
        }
Exemple #20
0
        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);
        }
        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;
        }
Exemple #22
0
 /// <summary>
 /// Updates an element's details.
 /// </summary>
 /// <param name="settings">Updated element details.</param>
 /// <param name="unitOfWork">Unit of work.</param>
 public void Update(IElementSettings settings, IUnitOfWork unitOfWork = null)
 {
     try
     {
         IAdvancedElementService customElementService   = (IAdvancedElementService)_elementFactory.GetElementService(settings.ElementTypeId);
         ICustomElementValidator customElementValidator = _elementFactory.GetElementValidator(settings.ElementTypeId);
         if (customElementValidator != null)
         {
             customElementValidator.ValidateUpdate(settings, unitOfWork);
         }
         if (customElementService != null)
         {
             customElementService.Update(settings, unitOfWork);
         }
     }
     catch (ValidationErrorException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
     }
 }
Exemple #23
0
        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 FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get sort by enumeration value
                PageSortBy sortBy;
                Enum.TryParse <PageSortBy>(((SelectListField <string>)form.Fields["sortBy"]).Value, out sortBy);

                // Get page type enumeration value
                PageType pageType;
                Enum.TryParse <PageType>(((SelectListField <string>)form.Fields["pageType"]).Value, out pageType);

                // Get Booleans
                bool sortAsc;
                Boolean.TryParse(((SelectListField <string>)form.Fields["sortAsc"]).Value, out sortAsc);

                // Get page list page
                string pageValue        = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  pageListPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  pageListTenantId = pageListPageId.HasValue ? (long?)tenantId : null;

                // Get the page list element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated page list settings
                PageListSettings pageListSettings = (PageListSettings)elementService.New(_authenticationService.TenantId);
                pageListSettings.ElementId           = elementId;
                pageListSettings.DisplayName         = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                pageListSettings.PageId              = pageListPageId;
                pageListSettings.PageTenantId        = pageListTenantId;
                pageListSettings.SortBy              = sortBy;
                pageListSettings.SortAsc             = sortAsc;
                pageListSettings.ShowRelated         = ((BooleanField)form.Fields["showRelated"]).Value;
                pageListSettings.ShowDescription     = ((BooleanField)form.Fields["showDescription"]).Value;
                pageListSettings.ShowImage           = ((BooleanField)form.Fields["showImage"]).Value;
                pageListSettings.ShowBackgroundImage = ((BooleanField)form.Fields["showBackgroundImage"]).Value;
                pageListSettings.ShowCreated         = ((BooleanField)form.Fields["showCreated"]).Value;
                pageListSettings.ShowUpdated         = ((BooleanField)form.Fields["showUpdated"]).Value;
                pageListSettings.ShowOccurred        = ((BooleanField)form.Fields["showOccurred"]).Value;
                pageListSettings.ShowComments        = ((BooleanField)form.Fields["showComments"]).Value;
                pageListSettings.ShowTags            = ((BooleanField)form.Fields["showTags"]).Value;
                pageListSettings.PageSize            = ((IntegerField)form.Fields["pageSize"]).Value.Value;
                pageListSettings.ShowPager           = ((BooleanField)form.Fields["showPager"]).Value;
                pageListSettings.MoreMessage         = ((TextField)form.Fields["moreMessage"]).Value;
                pageListSettings.Recursive           = ((BooleanField)form.Fields["recursive"]).Value;
                pageListSettings.PageType            = pageType;
                pageListSettings.NoPagesMessage      = string.IsNullOrWhiteSpace(((TextField)form.Fields["noPagesMessage"]).Value) ? null : ((TextField)form.Fields["noPagesMessage"]).Value;
                pageListSettings.Preamble            = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? null : ((MultiLineTextField)form.Fields["preamble"]).Value;

                // Perform the update
                elementService.Update(pageListSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        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 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);
        }
Exemple #27
0
        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 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);
        }
        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);
        }