protected void HandleArticleDate(
            Sitecore.Data.Items.Item article,
            DateTime articleDate)
        {
            Sitecore.Data.Items.Item root = this.GetNewsRoot(article);
            root = this.GetOrCreateChild(
                root,
                String.Format("{0:yyyy}", articleDate),
                this._yearTemplate,
                -articleDate.Year);

            if (this._monthTemplate != null)
            {
                root = this.GetOrCreateChild(
                    root,
                    String.Format("{0:MMMM}", articleDate),
                    this._monthTemplate,
                    -articleDate.Month);

                if (this._dayTemplate != null)
                {
                    root = this.GetOrCreateChild(
                        root,
                        String.Format("{0:dd}", articleDate),
                        this._dayTemplate,
                        -articleDate.Day);
                }
            }

            if (String.Compare(article.Parent.Paths.FullPath, root.Paths.FullPath, true) == 0)
            {
                return;
            }

            Sitecore.Data.Items.Item orphaned = article.Parent;
            article.MoveTo(root);

            while ((!orphaned.HasChildren) &&
                   (orphaned.TemplateID == this._yearTemplate.ID ||
                    (this._monthTemplate != null && orphaned.TemplateID == this._monthTemplate.ID) ||
                    (this._dayTemplate != null && orphaned.Template.ID == this._dayTemplate.ID)))
            {
                Sitecore.Data.Items.Item parent = orphaned.Parent;
                orphaned.Delete();
                orphaned = parent;
            }

            if ((!Sitecore.Context.IsBackgroundThread) && Sitecore.Context.ClientPage.IsEvent)
            {
                string message = String.Format("item:refreshchildren(id={0})", article.Database.GetRootItem().ID);
                Sitecore.Context.ClientPage.SendMessage(this, message);
            }
        }
        public override void Process(
            SC.Publishing.Pipelines.PublishItem.PublishItemContext context)
        {
            SC.Diagnostics.Assert.ArgumentNotNull(context, "context");
            SC.Diagnostics.Assert.ArgumentNotNull(context.ItemId, "ItemId");
            SC.Diagnostics.Assert.ArgumentNotNull(
                context.PublishOptions,
                "PublishOptions");
            SC.Diagnostics.Assert.ArgumentNotNull(
                context.PublishOptions.TargetDatabase,
                "TargetDatabase");

            // retrieve the item from the publishing target database
            SC.Data.Items.Item item = context.PublishOptions.TargetDatabase.GetItem(
                context.ItemId);

            // if the item does not exist (or the context user does not have read access)
            if (item == null)
            {
                return;
            }

            foreach (SC.Globalization.Language language in item.Languages)
            {
                SC.Data.Items.Item version = item.Database.GetItem(
                    item.ID,
                    language);

                if (version != null && version.Versions.Count > 0)
                {
                    return;
                }
            }

            SC.Diagnostics.Log.Warn(
                this + " : delete " + item.Paths.FullPath + " from " + item.Database.Name,
                this);
            item.Delete();
        }