private static PublishItemContext CreateItemContext(PublishingCandidate entry, PublishContext context)
 {
     Assert.ArgumentNotNull(entry, "entry");
     var context2 = PublishManager.CreatePublishItemContext(entry.ItemId, entry.PublishOptions);
     context2.Job = context.Job;
     context2.User = context.User;
     context2.PublishContext = context;
     return context2;
 }
Example #2
0
 private void ProcessCandidate(PublishingCandidate candidate, PublishContext context, int depth)
 {
     PublishItemResult result = PublishItemPipeline.Run(CreateItemContext(candidate, context));
     if (!SkipReferrers(result, context))
     {
         ProcessEntries(result.ReferredItems, context, depth + 1);
     }
     if (!SkipChildren(result, candidate, context))
     {
         ProcessEntries(candidate.ChildEntries, context, depth + 1);
     }
 }
Example #3
0
 private bool SkipChildren(PublishItemResult result, PublishingCandidate entry, PublishContext context)
 {
     if (result.ChildAction == PublishChildAction.Skip)
     {
         return true;
     }
     if (result.ChildAction != PublishChildAction.Allow)
     {
         return false;
     }
     if ((entry.PublishOptions.Mode != PublishMode.SingleItem) && (result.Operation == PublishOperation.Created))
     {
         return false;
     }
     return !entry.PublishOptions.Deep;
 }
        /// <summary>
        /// Returns the additional items to be published from the velir images field
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public List<PublishingCandidate> GetAdditionalPublishingCandidates(PublishContext context)
        {
            List<PublishingCandidate> additionalItems = new List<PublishingCandidate>();

            Item item = context.PublishOptions.RootItem;
            TemplateItem template = item.Template;
            foreach (TemplateFieldItem field in template.Fields)
            {
                //verify not a standard/system field
                if (field.InnerItem.IsNotNull() && field.InnerItem.Paths.FullPath.ToLower().StartsWith("/sitecore/templates/system"))
                {
                    continue;
                }

                //get field value
                string fieldValue = item[field.Name];
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                //split into guid array
                string[] values = fieldValue.Split('|');
                if (values.Length == 0)
                {
                    continue;
                }

                foreach (string fieldValueItemId in values)
                {
                    if (string.IsNullOrEmpty(fieldValueItemId))
                    {
                        continue;
                    }

                    ID additionalItemId;
                    if (!ID.TryParse(fieldValueItemId, out additionalItemId))
                    {
                        continue;
                    }

                    PublishOptions options = new PublishOptions(context.PublishOptions.SourceDatabase,
                                                                context.PublishOptions.TargetDatabase,
                                                                PublishMode.Smart,
                                                                item.Language, context.PublishOptions.PublishDate);
                    PublishingCandidate publishingCandidate = new PublishingCandidate(additionalItemId, options);
                    additionalItems.Add(publishingCandidate);
                }
            }

            return additionalItems;
        }
Example #5
0
        /// <summary>
        /// Returns the additional items to be published from the images field
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public List<PublishingCandidate> GetAdditionalPublishingCandidates(PublishContext context)
        {
            List<PublishingCandidate> additionalItems = new List<PublishingCandidate>();

            Item item = context.PublishOptions.RootItem;
            IEnumerable<Item> relatedItems = item.GetRelatedItems();
            foreach (Item relatedItem in relatedItems)
            {
                if (relatedItem.IsNull())
                {
                    continue;
                }

                PublishOptions options = new PublishOptions(context.PublishOptions.SourceDatabase,
                                                                        context.PublishOptions.TargetDatabase,
                                                                        PublishMode.Smart,
                                                                        item.Language, context.PublishOptions.PublishDate);
                PublishingCandidate publishingCandidate = new PublishingCandidate(relatedItem.ID, options);
                additionalItems.Add(publishingCandidate);
            }

            return additionalItems;
        }