/// <summary>
        /// Creates and displays the page editor notification
        /// </summary>
        /// <param name="arguments"></param>
        public override void Process(GetPageEditorNotificationsArgs arguments)
        {
            Assert.ArgumentNotNull(arguments, "arguments");
            if (arguments.ContextItem == null)
            {
                return;
            }

            Log.Info($"Sauron Page Editor Notification service called", this.GetType());

            var contextItem  = arguments.ContextItem;
            var templateName = contextItem.TemplateName;
            var templateId   = contextItem.TemplateID;
            var helpText     = PageEditorNotificationsService.GetPageEditorNotification(templateId);
            var intro        = Settings.GetSetting("SauronPageInfoIntro");

            if (!string.IsNullOrEmpty(helpText))
            {
                Log.Info($"Getting Sauron Page Editor Notification for template: {templateId}", this.GetType());

                //add page editor notification
                //var pageEditorNotificationType = new PageEditorNotificationType(); //TODO: ideally we would set a custom type here and make the view aware of it
                var notification = new PageEditorNotification($"<div class=\"sauron-page-editor-notification\">{string.Format(intro, templateName)}{helpText}</div>", (PageEditorNotificationType)ExtendedPageEditorNotificationType.Information);
                arguments.Notifications.Add(notification);
            }
        }
Example #2
0
        public override void Process(GetPageEditorNotificationsArgs arguments)
        {
            Assert.ArgumentNotNull((object)arguments, "arguments");
            var contextItem      = arguments.ContextItem;
            var database         = contextItem.Database;
            var workflowProvider = database.WorkflowProvider;

            if (workflowProvider == null)
            {
                return;
            }
            var workflow = workflowProvider.GetWorkflow(contextItem);

            if (workflow == null)
            {
                return;
            }
            WorkflowState state = workflow.GetState(contextItem);

            if (state == null)
            {
                return;
            }

            var repository = new WorxboxItemsRepository(workflow);

            var worxBoxIcon = "/~/icon/worxbox/32x32/worxbox.png";
            var displayIcon =
                $"<span><img src='{worxBoxIcon}'  style='vertical-align:middle; padding-right: 1px;'/></span>";

            using (new LanguageSwitcher(WebUtility.ClientLanguage))
            {
                string description        = GetDescription(workflow, state, database);
                string icon               = state.Icon;
                var    editorNotification = new PageEditorNotification(description, PageEditorNotificationType.Information)
                {
                    Icon = icon
                };
                var commands = WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(contextItem), contextItem);
                if (CanShowCommands(contextItem, commands))
                {
                    foreach (WorkflowCommand command in commands)
                    {
                        var notificationOption = new PageEditorNotificationOption(command.DisplayName, new WorkflowCommandBuilder(contextItem, workflow, command).ToString());
                        editorNotification.Options.Add(notificationOption);
                    }
                    editorNotification.Options.Add(new PageEditorNotificationOption("|", ""));
                    foreach (WorkflowCommand command in commands)
                    {
                        if (repository.IsWorxboxItem(state, new DataUri(contextItem.Uri)) &&
                            repository.GetWorkflowCommandIDs().Contains(ID.Parse(command.CommandID)))
                        {
                            var notificationOption = new PageEditorNotificationOption(displayIcon + command.DisplayName, new WorxBoxWorkflowCommandBuilder(contextItem, workflow, command).ToString());
                            editorNotification.Options.Add(notificationOption);
                        }
                    }
                }
                arguments.Notifications.Add(editorNotification);
            }
        }
Example #3
0
        public void Process(GetPageEditorNotificationsArgs args)
        {
            Item contextItem = args.ContextItem;

            if (contextItem.IsProjectItem())
            {
                string command = string.Format("Sitecore Project: This item is part of the '{0}' project", contextItem.ProjectTitle());
                PageEditorNotification editorNotification = new PageEditorNotification(command, PageEditorNotificationType.Information);
                args.Notifications.Add(editorNotification);
            }
        }
 private void SetNotification(GetPageEditorNotificationsArgs arguments, ItemWorkflowModel wfModel)
 {
     var editorNotification = new PageEditorNotification(wfModel.GetEditorDescription(), PageEditorNotificationType.Warning)
     {
         Icon = wfModel.WorkflowState.Icon
     };
     if (wfModel.HasWriteAccess())
     {
         foreach (var notificationOption in wfModel.Commands.Select(command => new PageEditorNotificationOption(command.DisplayName, new WorkflowCommandBuilder(wfModel.ContextItem, wfModel.Workflow, command).ToString())))
         {
             editorNotification.Options.Add(notificationOption);
         }
     }
     arguments.Notifications.Add(editorNotification);
 }
Example #5
0
        private void SetNotification(GetPageEditorNotificationsArgs arguments, ItemWorkflowModel wfModel)
        {
            var editorNotification = new PageEditorNotification(wfModel.GetEditorDescription(), PageEditorNotificationType.Warning)
            {
                Icon = wfModel.WorkflowState.Icon
            };

            if (wfModel.HasWriteAccess())
            {
                foreach (var notificationOption in wfModel.Commands.Select(command => new PageEditorNotificationOption(command.DisplayName, new WorkflowCommandBuilder(wfModel.ContextItem, wfModel.Workflow, command).ToString())))
                {
                    editorNotification.Options.Add(notificationOption);
                }
            }
            arguments.Notifications.Add(editorNotification);
        }
        public List <PageEditorNotification> GetPageEditorNotifications(Item item, bool checkDatasources = true)
        {
            List <PageEditorNotification> model         = new List <PageEditorNotification>();
            List <Notification>           notifications = Get(item, checkDatasources);

            if (notifications.Count > 0)
            {
                foreach (Notification notification in notifications)
                {
                    var editorNotification = new PageEditorNotification(notification.Message, PageEditorNotificationType.Warning)
                    {
                        Icon = Constants.WarningIcon,
                    };
                    editorNotification.Options.Add(new PageEditorNotificationOption(notification.CommandDisplayName, notification.Command));

                    model.Add(editorNotification);
                }
            }

            return(model);
        }