/// <summary>
        /// The build node name.
        /// </summary>
        /// <param name="item">
        /// The item.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private static string BuildNodeName(Item item)
        {
            if (item == null)
            {
                return(string.Empty);
            }

            var templateId = item.TemplateID.ToString();

            switch (templateId)
            {
            case ItemToItem.TemplateId:
                var itemToItem = new ItemToItem(item);
                return(BuildItemToItemNodeName(itemToItem));

            case SectionToItem.TemplateId:
                var sectionToItem = new SectionToItem(item);
                return(BuildSectionToItemNode(sectionToItem));

            case SectionToSection.TemplateId:
                var sectionToSection = new SectionToSection(item);
                return(BuildSectionToSectionNode(sectionToSection));

            case RegExRedirect.TemplateId:
                var regExRedirect = new RegExRedirect(item);
                return(BuildRegExNodeName(regExRedirect));
            }

            return(string.Format("<p>{0}</p>", item.Name));
        }
Beispiel #2
0
        /// <summary>
        /// Adds the section to item redirect.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Redirect item</returns>
        private static RedirectItem AddSectionToItemRedirect(Item item)
        {
            if (item == null)
            {
                return(null);
            }

            var sectionToItem = new SectionToItem(item);

            if (string.IsNullOrEmpty(sectionToItem.BaseSection.Value) ||
                sectionToItem.TargetItem == null ||
                (sectionToItem.TargetItem.TargetItem == null && string.IsNullOrEmpty(sectionToItem.TargetItem.Url)))
            {
                return(null);
            }

            var external  = true;
            var targetUrl = sectionToItem.TargetItem.Url;

            if (sectionToItem.TargetItem.IsInternal)
            {
                if (!CheckPresentation(sectionToItem.TargetItem.TargetItem))
                {
                    return(null);
                }

                targetUrl = UrlNormalizer.CheckPageExtension(UrlNormalizer.GetItemUrl(sectionToItem.TargetItem.TargetItem));
                external  = false;
            }

            var redirectItem = new RedirectItem
            {
                ItemId            = sectionToItem.ID,
                Target            = targetUrl,
                TargetQueryString = sectionToItem.TargetItem.QueryString,
                Base         = UrlNormalizer.RemovePageExtension(UrlNormalizer.Normalize(sectionToItem.BaseSection.Value)),
                External     = external,
                RedirectCode = sectionToItem.RedirectCode,
                Multisites   = ConvertMultisites(sectionToItem.Multisites),
                UseOnDefault = sectionToItem.UseOnDefault.Checked
            };

            return(redirectItem);
        }
        /// <summary>
        /// Builds the section to item node.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>section to item node</returns>
        private static string BuildSectionToItemNode(SectionToItem item)
        {
            if (item == null)
            {
                return(string.Empty);
            }

            var targetUrl = "Empty";

            if (!string.IsNullOrEmpty(item.TargetItem.Url) || item.TargetItem.TargetItem != null)
            {
                targetUrl = item.TargetItem.IsInternal ? UrlNormalizer.CheckPageExtension(UrlNormalizer.GetItemUrl(item.TargetItem.TargetItem)) : UrlNormalizer.CheckPageExtension(item.TargetItem.Url);
            }

            return(string.Format(
                       "<div class=\"block-name\"><div class=\"name\">{0}</div><div class=\"title\">Base Section Url: {2}, Target Url: {3}</div></div><div class=\"description\">Redirect Code: {4}, Multisites: {6}, Last Use: {5}, ID: {1}</div>",
                       item.Name,
                       item.ID,
                       string.IsNullOrEmpty(item.BaseSection.Value) ? "Empty" : UrlNormalizer.EncodeUrl(UrlNormalizer.CheckPageExtension(UrlNormalizer.Normalize(item.BaseSection.Value))),
                       UrlNormalizer.EncodeUrl(targetUrl),
                       item.RedirectCode != 0 ? item.RedirectCode : Configuration.RedirectStatusCode,
                       item.LastUse.DateTime.ToString("MM/dd/yy") != "01/01/01" ? item.LastUse.DateTime.ToString("MM/dd/yy") : "Never",
                       UrlNormalizer.EncodeUrl(RedirectProcessor.ConvertMultisites(item.Multisites))));
        }
        /// <summary>
        /// Adds the section to item redirect.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Redirect item</returns>
        private static RedirectItem AddSectionToItemRedirect(Item item)
        {
            if (item == null)
              {
            return null;
              }

              var sectionToItem = new SectionToItem(item);
              if (string.IsNullOrEmpty(sectionToItem.BaseSection.Value)
            || (string.IsNullOrEmpty(sectionToItem.TargetItem.Url) && sectionToItem.TargetItem.TargetItem == null))
              {
            return null;
              }

              var external = true;
              var targetUrl = sectionToItem.TargetItem.Url;
              if (sectionToItem.TargetItem.IsInternal)
              {
            if (!CheckPresentation(sectionToItem.TargetItem.TargetItem))
            {
              return null;
            }

            targetUrl = UrlNormalizer.GetItemUrl(sectionToItem.TargetItem.TargetItem);
            external = false;
              }

              var redirectItem = new RedirectItem
              {
            ItemId = sectionToItem.ID,
            Target = targetUrl,
            TargetQueryString = sectionToItem.TargetItem.QueryString,
            Base = UrlNormalizer.RemovePageExtension(UrlNormalizer.Normalize(sectionToItem.BaseSection.Value)),
            External = external,
            RedirectCode = sectionToItem.RedirectCode,
            Multisites = ConvertMultisites(sectionToItem.Multisites),
            UseOnDefault = sectionToItem.UseOnDefault.Checked
              };

              return redirectItem;
        }