protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull((object)e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         Item currentItem = GalleryPublishedTargetsForm.GetCurrentItem();
         if (currentItem != null)
         {
             var targets = new PublishingHelper().ListTargets(currentItem);
             foreach (var target in targets.Keys)
             {
                 var menuItem = new MenuItem();
                 menuItem.Header = target;
                 if(targets[target].Equals(PublishingHelper.PublishState.Published))
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_green.png";
                 }
                 else if (targets[target].Equals(PublishingHelper.PublishState.Changed))
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_yellow.png";
                 }
                 else
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_red.png";
                 }
                 this.Targets.Controls.Add(menuItem);
             }
         }
     }
 }
 protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull((object)e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         Item currentItem = GalleryPublishedTargetsForm.GetCurrentItem();
         if (currentItem != null)
         {
             var targets = new PublishingHelper().ListTargets(currentItem);
             foreach (var target in targets.Keys)
             {
                 var menuItem = new MenuItem();
                 menuItem.Header = target;
                 if (targets[target].Equals(PublishingHelper.PublishState.Published))
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_green.png";
                 }
                 else if (targets[target].Equals(PublishingHelper.PublishState.Changed))
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_yellow.png";
                 }
                 else
                 {
                     menuItem.Icon = "Other/32x32/bullet_ball_glass_red.png";
                 }
                 this.Targets.Controls.Add(menuItem);
             }
         }
     }
 }
        public override CommandState QueryState(CommandContext context)
        {
            if (!PublishingHelper.CanPublishDatabase(Sitecore.Context.ContentDatabase))
            {
                return(CommandState.Disabled);
            }

            return(base.QueryState(context));
        }
        public static new void Run(ClientPipelineArgs args)
        {
            if (!PublishingHelper.CanPublishDatabase(Sitecore.Context.ContentDatabase))
            {
                string msg = Translate.Text("You cannot publish this database.");
                Sitecore.Context.ClientPage.ClientResponse.Alert(msg);
                return;
            }

            Sitecore.Shell.Framework.Commands.System.Publish.Run(args);
        }
Esempio n. 5
0
        public override CommandState QueryState(CommandContext context)
        {
            if (context.Items.Length == 1 &&
                context.Items[0] != null &&
                !PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User))
            {
                return(CommandState.Disabled);
            }

            return(base.QueryState(context));
        }
Esempio n. 6
0
        protected override bool Execute(string data, FormSubmitContext formSubmitContext)
        {
            Assert.ArgumentNotNull(formSubmitContext, nameof(formSubmitContext));

            //bouncers
            if (!formSubmitContext.HasErrors)
            {
                Logger.Info(Invariant($"Form {formSubmitContext.FormId} submitted successfully."), this);
            }
            else
            {
                Logger.Warn(Invariant($"Form {formSubmitContext.FormId} submitted with errors: {string.Join(", ", formSubmitContext.Errors.Select(t => t.ErrorMessage))}."), this);
            }

            var db = Factory.GetDatabase("master");

            using (new SecurityDisabler())
            {
                var meetupsRootItem = db.GetItem(ItemIds.MeetupsPoisRoot);
                if (meetupsRootItem == null)
                {
                    Log.Error("Meetups root item does not exist", this); return(false);
                }

                //create Meetup POI item
                var newMeetupItem = meetupsRootItem.Add("Meetup " + DateTime.Now.ToString("hh-mm-ss"), TemplateIds.MeetupPoi);

                //add the new POI item to the map item
                var mapItem = db.GetItem(ItemIds.MeetupsMap);
                if (mapItem == null)
                {
                    Log.Error("Meetups map item does not exist", this); return(false);
                }

                var poiFieldOnMapItem = (MultilistField)mapItem.Fields[FieldIds.MapPoi];
                if (poiFieldOnMapItem == null)
                {
                    Log.Error("Poi field does not exist. You may have forgetten to install SXA!", this); return(false);
                }

                using (new EditContext(mapItem)) { poiFieldOnMapItem.Add(newMeetupItem.ID.ToString()); }

                //copy form values onto the newly created item
                //TODO replace with the GUI mapper unless need computed fields
                MapMeetupFormValuesToItem(newMeetupItem, formSubmitContext);

                //publish the updated and the created items
                PublishingHelper.Publish(mapItem);
                PublishingHelper.Publish(newMeetupItem);
            }

            return(true);
        }
Esempio n. 7
0
        public override void Execute(CommandContext context)
        {
            if (context.Items.Length != 1 ||
                context.Items[0] == null ||
                !PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User))
            {
                string msg = Translate.Text("You cannot publish this item.");
                Sitecore.Context.ClientPage.ClientResponse.Alert(msg);
                return;
            }

            base.Execute(context);
        }
        public override CommandState QueryState(CommandContext context)
        {
            Assert.IsNotNull(context, "context");

            if (PublishingHelper.CanPublishDatabase(Sitecore.Context.ContentDatabase) &&
                context.Items.Length == 1 &&
                context.Items[0] != null &&
                (PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User) || context.Items[0].HasChildren))
            {
                return(base.QueryState(context));
            }

            return(CommandState.Disabled);
        }
        public override void Apply(T ruleContext)
        {
            FinishTestRuleContext finishTestRuleContext = ruleContext as FinishTestRuleContext;

            if (finishTestRuleContext != null)
            {
                ITestConfiguration           configuration      = finishTestRuleContext.Configuration;
                IEnumerable <TestExperience> testExperience     = configuration.Experiences;
                IContentTestPerformance      performanceForTest = finishTestRuleContext.ContentTestPerformanceFactory.GetPerformanceForTest(configuration);

                StopTestArgs stopTestArgs = new StopTestArgs();
                stopTestArgs.Configuration = finishTestRuleContext.Configuration;

                List <float>          list = new List <float>();
                List <TestExperience> listTestExperience = new List <TestExperience>();

                foreach (var experience in testExperience)
                {
                    SiteStatistics siteStatistics = performanceForTest.GetExperienceSiteStatistics(experience.Combination);
                    list.Add(siteStatistics.BounceRate);
                    listTestExperience.Add(experience);
                }

                if (list.Count != 0)
                {
                    int indexOfMinBounceRate = GetIndexOfLowestBounceRate(list);

                    if (indexOfMinBounceRate != 0)
                    {
                        TestCombination testCombination = new TestCombination(listTestExperience[indexOfMinBounceRate].Combination, configuration.TestSet);

                        if (testCombination == null)
                        {
                            return;
                        }
                        using (new Sitecore.Data.Items.EditContext(configuration.TestDefinitionItem))
                        {
                            configuration.TestDefinitionItem.WinnerCombination = testCombination.Combination.MultiplexToString("-");
                        }
                        Sitecore.Data.Items.Item item    = configuration.TestDefinitionItem;
                        Sitecore.Data.Database[] targets = PublishingHelper.GetTargets(item).ToArray <Sitecore.Data.Database>();
                        Sitecore.Publishing.PublishManager.PublishItem(item, targets, item.Languages, true, true);
                        stopTestArgs.Combination = testCombination;
                        SettingsDependantPipeline <StopTestPipeline, StopTestArgs> .Instance.Run(stopTestArgs);
                    }
                }
            }
        }
        public override void Process(PublishItemContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            Item item = context.PublishHelper.GetSourceItem(context.ItemId);

            if (item != null &&
                !PublishingHelper.CanPublishItem(item, Sitecore.Context.User))
            {
                string msg = String.Format(
                    "{0} does not have permission to publish {1}",
                    Sitecore.Context.User.Name,
                    item.Paths.FullPath);
                context.AbortPipeline(
                    PublishOperation.Skipped,
                    PublishChildAction.Allow,
                    Translate.Text(msg));
            }
        }
        protected new void Run(ClientPipelineArgs args)
        {
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["id"], "id");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["language"], "language");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["version"], "version");

            if (!SheerResponse.CheckModified())
            {
                return;
            }

            Item item = Context.ContentDatabase.GetItem(
                args.Parameters["id"],
                Language.Parse(args.Parameters["language"]),
                Version.Parse(args.Parameters["version"]));

            if (item == null ||
                PublishingHelper.CanPublishItem(item, Sitecore.Context.User))
            {
                base.Run(args);
                return;
            }

            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    base.Run(args);
                }

                return;
            }
            else
            {
                string msg = "You cannot publish this item.\n\nDo you want to publish any descendants that you can publish?";
                SheerResponse.Confirm(Translate.Text(msg));
                args.WaitForPostBack();
                return;
            }
        }
        public override void Execute(CommandContext context)
        {
            if (context != null && context.Items.Length > 0 && context.Items[0] != null)
            {
                var item = context.Items[0];

                if (item.Publishing.NeverPublish)
                {
                    item.Editing.BeginEdit();
                    item.Publishing.NeverPublish = false;
                    item.Editing.EndEdit();
                }

                var publishingHelper = new PublishingHelper();

                Globals.LinkDatabase.UpdateReferences(item);
                var itemReferences = Globals.LinkDatabase.GetReferences(item);
                foreach (var itemLink in itemReferences)
                {
                    if (itemLink != null)
                    {
                        var referencedItem = itemLink.GetTargetItem();
                        if (referencedItem != null)
                        {
                            publishingHelper.PublishAll(referencedItem, false, false);
                            if (referencedItem.Parent != null)
                            {
                                publishingHelper.PublishReversedRecursive(referencedItem.Parent);
                            }
                        }
                    }
                }

                publishingHelper.PublishAll(item, false, false);

                Sitecore.Context.ClientPage.ClientResponse.Alert("The item and its resources are being published");
            }
        }
        public override void Execute(CommandContext context)
        {
            if (context != null && context.Items.Length > 0 && context.Items[0] != null)
            {
                var item = context.Items[0];

                if (item.Publishing.NeverPublish)
                {
                    item.Editing.BeginEdit();
                    item.Publishing.NeverPublish = false;
                    item.Editing.EndEdit();
                }

                var publishingHelper = new PublishingHelper();

                Globals.LinkDatabase.UpdateReferences(item);
                var itemReferences = Globals.LinkDatabase.GetReferences(item);
                foreach (var itemLink in itemReferences)
                {
                    if (itemLink != null)
                    {
                        var referencedItem = itemLink.GetTargetItem();
                        if (referencedItem != null)
                        {
                            publishingHelper.PublishAll(referencedItem, false, false);
                            if (referencedItem.Parent != null)
                            {
                                publishingHelper.PublishReversedRecursive(referencedItem.Parent);
                            }
                        }
                    }
                }

                publishingHelper.PublishAll(item, false, false);

                Sitecore.Context.ClientPage.ClientResponse.Alert("The item and its resources are being published");
            }
        }