Beispiel #1
0
        /// <summary>Finds items linked by the supplied item. This method only finds links in html text to items within the site.</summary>
        /// <param name="item">The item to examine for links.</param>
        /// <returns>A list of items referenced in html text by the supplied item.</returns>
        public virtual IList <ContentItem> FindLinkedItems(ContentItem item)
        {
            N2.Collections.ItemList items = new N2.Collections.ItemList();
            foreach (ContentDetail detail in item.Details)
            {
                if (detail.StringValue != null)
                {
                    foreach (string link in FindLinks(detail.StringValue))
                    {
                        if (string.IsNullOrEmpty(link))
                        {
                            continue;
                        }
                        else if (!(link.StartsWith("/") || link.StartsWith("~") || link.Contains("://")))
                        {
                            continue;
                        }

                        try
                        {
                            ContentItem referencedItem = urlParser.Parse(link);
                            if (referencedItem != null && referencedItem.ID != 0 && !items.Contains(referencedItem))
                            {
                                items.Add(referencedItem);
                            }
                        }
                        catch (Exception ex)
                        {
                            errorHandler.Notify(ex);
                        }
                    }
                }
            }
            return(items);
        }
Beispiel #2
0
        /// <summary>Finds items linked by the supplied item. This method only finds links in html text to items within the site.</summary>
        /// <param name="item">The item to examine for links.</param>
        /// <returns>A list of items referenced in html text by the supplied item.</returns>
        public virtual IList<ContentItem> FindLinkedItems(ContentItem item)
        {
            N2.Collections.ItemList items = new N2.Collections.ItemList();
            foreach (ContentDetail detail in item.Details.Values)
            {
                if (detail is N2.Details.StringDetail)
                {
                    foreach (string link in FindLinks(((StringDetail)detail).StringValue))
                    {
                        if (string.IsNullOrEmpty(link))
                            continue;
                        else if (!(link.StartsWith("/") || link.StartsWith("~") || link.Contains("://")))
                            continue;

                        try
                        {
                            ContentItem referencedItem = urlParser.Parse(link);
                            if (referencedItem != null && referencedItem.ID != 0 && !items.Contains(referencedItem))
                            {
                                items.Add(referencedItem);
                            }
                        }
                        catch (Exception ex)
                        {
                            errorHandler.Notify(ex);
                        }
                    }
                }
            }
            return items;
        }
 protected virtual Collections.ItemList GetItemsFromIdentifiers(System.Collections.IDictionary keys)
 {
     Collections.ItemList items = new N2.Collections.ItemList();
     foreach (int itemID in keys.Values)
     {
         items.Add(Engine.Persister.Get(itemID));
     }
     return(items);
 }
Beispiel #4
0
 protected virtual Collections.ItemList GetItemsFromIdentifiers(System.Collections.IDictionary keys)
 {
     Collections.ItemList items = new N2.Collections.ItemList();
     foreach (int itemID in keys.Values)
         items.Add(Engine.Persister.Get(itemID));
     return items;
 }