Exemple #1
0
        public void Process(
            Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Sitecore.Diagnostics.Assert.IsNotNullOrEmpty(this.SourceDatabase, "SourceDatabase");
            Sitecore.Diagnostics.Assert.IsNotNull(args, "args");
            Sitecore.Data.Items.Item sourceItem = args.Item;
            Sitecore.Diagnostics.Assert.IsNotNull(sourceItem, "args.Item");

            if (String.Compare(sourceItem.Database.Name, this.SourceDatabase, false) != 0)
            {
                return;
            }

            if (!this.IsLatest(sourceItem))
            {
                return;
            }

            string message = this.GetMessage(sourceItem);

            if (!String.IsNullOrEmpty(message))
            {
                this.AddWarning(message, sourceItem, args);
            }
        }
Exemple #2
0
        public void Process(SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            SC.Data.Items.Item item = args.Item;

            if (item == null)
            {
                return;
            }

            if (SC.Context.IsAdministrator || CheckIn.CanCheckIn(item))
            {
                if (item.Locking.IsLocked() && (string.Compare(item.Locking.GetOwner(), SC.Context.User.Name, StringComparison.InvariantCultureIgnoreCase) != 0))
                {
                    SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                    warning.Title = SC.Globalization.Translate.Text("'{0}' has locked this item.", new object[] { item.Locking.GetOwnerWithoutDomain() });
                    warning.AddOption(SC.Globalization.Translate.Text("Check In"), string.Format("item:checkin(id={0},language={1},version={2})", item.ID, item.Language, item.Version.Number));
                }
            }
            else if (item.Locking.IsLocked())
            {
                if (!item.Locking.HasLock())
                {
                    args.Add(SC.Globalization.Translate.Text("You cannot edit this item because '{0}' has locked it.", new object[] { item.Locking.GetOwnerWithoutDomain() }), string.Empty);
                }
            }
            else if (SC.Configuration.Settings.RequireLockBeforeEditing && SC.Data.Managers.TemplateManager.IsFieldPartOfTemplate(SC.FieldIDs.Lock, item))
            {
                SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                warning.Title = SC.Globalization.Translate.Text("You must lock this item before you can edit it.");
                warning.Text  = SC.Globalization.Translate.Text("To lock this item, click Edit on the Home tab.");
                warning.AddOption(SC.Globalization.Translate.Text("Lock and Edit"), "item:checkout");
            }
        }
 protected void AddNotification(string message, Item item, Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args, Item redirectitem)
 {
     Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning note = args.Add();
     note.Title = Translate.Text("Redirect Manager");
     note.Text  = string.Format(Translate.Text("The URL \"{0}\" is currently redirecting to this page."), redirectitem["Requested Url"]);
     note.AddOption(Translate.Text("Review the redirect definition"), string.Format("item:load(id={0}, language={1}, version={2})", redirectitem.ID, redirectitem.Language, redirectitem.Version));
     note.AddOption(Translate.Text("Delete the redirect definition"), string.Format("redirectmanager:delete(id={0}, language={1}, version={2}, item={3})", redirectitem.ID, redirectitem.Language, redirectitem.Version, item.ID));
 }
        protected void AddLinkToRedirectItem(string message, Item item, Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Database db     = Database.GetDatabase("master");
            Item     target = db.GetItem(item["Redirect To Item"]);

            if (target != null)
            {
                Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning note = args.Add();
                note.Title = Translate.Text("Redirect Manager");
                note.Text  = Translate.Text("This item is a redirect item.  Would you like to manage the redirect target?");
                note.AddOption(target.DisplayName, string.Format("item:load(id={0}, language={1}, version={2})", target.ID, target.Language, target.Version));
            }
        }
Exemple #5
0
        public void Process(
            Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Sitecore.Diagnostics.Assert.IsNotNull(args, "args");
            Sitecore.Data.Items.Item currentItem = args.Item;
            Sitecore.Diagnostics.Assert.IsNotNull(currentItem, "args.Item");

            if (ItemNamingHelper.AreContentEditorWarningsOn())
            {
                if (currentItem.Name != currentItem.DisplayName && ItemNamingHelper.StorePrettyNameInDisplayName() && ItemNamingHelper.HasPresentation(currentItem) && ItemNamingHelper.IsContentRoot(currentItem))
                {
                    this.AddNotification(message, currentItem, args);
                }
            }
        }
Exemple #6
0
        protected void AddWarning(
            string message,
            Sitecore.Data.Items.Item item,
            Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning
                          = args.Add();
            warning.Title = "Publishing Status";
            warning.Text  = message;
            string command = String.Format(
                "item:load(id={0},language={1},version={2})",
                item.ID,
                item.Language,
                item.Version.Number);

            warning.AddOption("Refresh", command);
        }
Exemple #7
0
        public void Process(Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Sitecore.Diagnostics.Assert.IsNotNull(args, "args");
            Sitecore.Data.Items.Item currentItem = args.Item;
            Sitecore.Diagnostics.Assert.IsNotNull(currentItem, "args.Item");

            List <Item> redirects = GetRedirectsForItem(currentItem.ID);

            // If this item is redirect to from another item, show the notification
            foreach (Item redirectitem in redirects)
            {
                AddNotification(string.Empty, currentItem, args, redirectitem);
            }

            // If this is a redirect item link to the item in the notification bar.
            if (currentItem["Redirect To Item"] != null && currentItem["Redirect To Item"] != string.Empty)
            {
                AddLinkToRedirectItem(string.Empty, currentItem, args);
            }
        }
Exemple #8
0
 protected void AddNotification(string message, Sitecore.Data.Items.Item item, Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
 {
     Sitecore.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
     warning.Title = "Item Naming";
     warning.Text  = message;
     warning.Icon  = "/assets/img/about.png";
 }