Example #1
0
        public void DoCustomBinding(List <VisualEditorCommand> jsonCommands)
        {
            Dictionary <int, VisualEditorCommand> oldVeCommands = null;

            if (VeCommands != null)
            {
                oldVeCommands = VeCommands.ToDictionary(n => n.Id, m => m);
            }

            var rowOrder            = VisualEditorRepository.GetCommandMaxRowOrder();
            var toolbarInRowOrder   = BaseCommandOrder + Order;
            var commandInGroupOrder = 0;

            foreach (var command in jsonCommands)
            {
                command.RowOrder            = rowOrder;
                command.ToolbarInRowOrder   = toolbarInRowOrder;
                command.GroupInToolbarOrder = 0;
                command.CommandInGroupOrder = commandInGroupOrder;

                command.PluginId = Id;
                if (command.Id != 0 && oldVeCommands != null)
                {
                    var oldCommand = oldVeCommands[command.Id];
                    command.Created  = oldCommand.Created;
                    command.Modified = oldCommand.Modified;
                }

                commandInGroupOrder++;
            }

            VeCommands = jsonCommands;
        }
Example #2
0
        private void ValidateVeCommand(VisualEditorCommand command, RulesException errors, int index, IEnumerable <string> dupNames, IEnumerable <string> dupAliases)
        {
            if (!string.IsNullOrWhiteSpace(command.Name) && dupNames.Contains(command.Name))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandNameDuplicate, index));
                command.IsInvalid = true;
            }

            if (!string.IsNullOrWhiteSpace(command.Alias) && dupAliases.Contains(command.Alias))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandAliasDuplicate, index));
                command.IsInvalid = true;
            }

            if (string.IsNullOrWhiteSpace(command.Name))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandNameRequired, index));
                command.IsInvalid = true;
            }

            if (!string.IsNullOrWhiteSpace(command.Name) && Regex.IsMatch(command.Name, RegularExpressions.InvalidEntityName))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandNameInvalidFormat, index));
                command.IsInvalid = true;
            }

            if (string.IsNullOrWhiteSpace(command.Alias))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandAliasRequired, index));
                command.IsInvalid = true;
            }

            if (command.Name.Length > 255)
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandNameMaxLengthExceeded, index));
                command.IsInvalid = true;
            }

            if (command.Alias.Length > 255)
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandAliasMaxLengthExceeded, index));
                command.IsInvalid = true;
            }

            if (!VisualEditorRepository.IsCommandNameFree(command.Name, Id))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandNameNonUnique, index));
                command.IsInvalid = true;
            }

            if (!VisualEditorRepository.IsCommandAliasFree(command.Alias, Id))
            {
                errors.ErrorForModel(string.Format(VisualEditorStrings.CommandAliasNonUnique, index));
                command.IsInvalid = true;
            }
        }
Example #3
0
        public ListResult <VisualEditorStyleListItem> GetVisualEditorStyles(ListCommand cmd, int contentId)
        {
            var list = VisualEditorRepository.ListStyles(cmd, contentId, out var totalRecords);

            return(new ListResult <VisualEditorStyleListItem>
            {
                Data = list.ToList(),
                TotalRecords = totalRecords
            });
        }
Example #4
0
        public VisualEditorPlugin ReadVisualEditorPluginProperties(int id)
        {
            var plugin = VisualEditorRepository.GetPluginPropertiesById(id);

            if (plugin == null)
            {
                throw new ApplicationException(string.Format(VisualEditorStrings.VisualEditorPluginNotFound, id));
            }

            return(plugin);
        }
Example #5
0
        public VisualEditorStyle ReadVisualEditorStyleProperties(int id)
        {
            var style = VisualEditorRepository.GetStylePropertiesById(id);

            if (style == null)
            {
                throw new ApplicationException(string.Format(VisualEditorStrings.VisualEditorStyleNotFound, id));
            }

            return(style);
        }
Example #6
0
        public MessageResult Remove(int id)
        {
            var plugin = VisualEditorRepository.GetPluginPropertiesById(id);

            if (plugin == null)
            {
                throw new ApplicationException(string.Format(VisualEditorStrings.VisualEditorPluginNotFound, id));
            }

            VisualEditorRepository.Delete(id);
            return(null);
        }
Example #7
0
        public static IEnumerable <VisualEditorCommand> GetResultVisualEditorCommands(int fieldId, int siteId)
        {
            if (QPContext.IsAdmin)
            {
                var defaultCommands = VisualEditorRepository.GetDefaultCommands();
                var siteCommands    = VisualEditorRepository.GetSiteCommands(siteId);

                return(VisualEditorHelpers.Merge(defaultCommands, siteCommands));
            }

            return(VisualEditorRepository.GetResultCommands(fieldId, siteId));
        }
Example #8
0
        public MessageResult RemoveVisualEditorStyle(int id)
        {
            var style = VisualEditorRepository.GetStylePropertiesById(id);

            if (style == null)
            {
                throw new ApplicationException(string.Format(VisualEditorStrings.VisualEditorStyleNotFound, id));
            }

            if (style.IsSystem)
            {
                throw new ApplicationException(string.Format(VisualEditorStrings.SystemWarning, id));
            }

            VisualEditorRepository.DeleteStyle(id);
            return(null);
        }
Example #9
0
 public VisualEditorStyle UpdateVisualEditorStyleProperties(VisualEditorStyle visualEditorStyle) => VisualEditorRepository.UpdateStyleProperties(visualEditorStyle);
Example #10
0
 internal static VisualEditorStyle Create() => new VisualEditorStyle
 {
     Order = VisualEditorRepository.GetStyleMaxOrder() + 1
 };
Example #11
0
 public VisualEditorPlugin SaveVisualEditorPluginProperties(VisualEditorPlugin visualEditorPlugin) => VisualEditorRepository.SavePluginProperties(visualEditorPlugin);
Example #12
0
 internal static VisualEditorPlugin Create() => new VisualEditorPlugin
 {
     Order = VisualEditorRepository.GetPluginMaxOrder() + 1
 };
Example #13
0
 public VisualEditorPlugin UpdateVisualEditorProperties(VisualEditorPlugin visualEditorPlugin) => VisualEditorRepository.UpdatePluginProperties(visualEditorPlugin);
Example #14
0
 public static IEnumerable <VisualEditorStyle> GetAllVeStyles()
 {
     return(VisualEditorRepository.GetAllStyles().OrderBy(s => s.Order).ToList());
 }
Example #15
0
 public static Dictionary <int, bool> GetStyleBinding(int siteId) => VisualEditorRepository.GetStyleBindingBySiteId(siteId);
Example #16
0
 public static IEnumerable <VisualEditorCommand> GetDefaultVisualEditorCommands() => VisualEditorRepository.GetDefaultCommands();
Example #17
0
 public VisualEditorStyle SaveVisualEditorStyleProperties(VisualEditorStyle visualEditorStyle) => VisualEditorRepository.SaveStyleProperties(visualEditorStyle);
Example #18
0
 public static IEnumerable <VisualEditorCommand> GetResultVisualEditorCommands(int fieldId, int siteId) => VisualEditorRepository.GetResultCommands(fieldId, siteId);
Example #19
0
 public static IEnumerable <VisualEditorStyle> GetResultStyles(int fieldId, int siteId) => VisualEditorRepository.GetResultStyles(fieldId, siteId);