public override PageDataCollection SearchRelations(Rule rule, int pageID, string searchKeyWord, PageReference hierarchyStart, bool isLeftRule) { string pageTypes = HttpUtility.UrlDecode(isLeftRule ? rule.PageTypeRight : rule.PageTypeLeft); PageDataCollection result = new PageDataCollection(); if (!string.IsNullOrEmpty(pageTypes)) { string[] pageTypeCollection = pageTypes.Split(';'); PropertyCriteriaCollection pageTypeCriterias = new PropertyCriteriaCollection(); if (hierarchyStart == null || hierarchyStart == PageReference.EmptyReference) { hierarchyStart = PageReference.RootPage; } foreach (string s in pageTypeCollection) { if (!string.IsNullOrEmpty(s)) { PropertyCriteria criteria = new PropertyCriteria(); criteria.Condition = EPiServer.Filters.CompareCondition.Equal; criteria.Name = "PageTypeName"; criteria.Type = PropertyDataType.String; criteria.Value = s; pageTypeCriterias.Add(criteria); } } PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(hierarchyStart, pageTypeCriterias); PageData rootPage = DataFactory.Instance.GetPage(hierarchyStart); if (pageTypeCollection.Contains <string>(rootPage.PageTypeName) && !pages.Contains(rootPage)) { pages.Add(rootPage); } new EPiServer.Filters.FilterSort(EPiServer.Filters.FilterSortOrder.Alphabetical).Sort(pages); if (!string.IsNullOrEmpty(searchKeyWord)) { for (int i = 0; i < pages.Count; i++) { if (pages[i].PageName.ToLower().Contains(searchKeyWord.ToLower())) { result.Add(pages[i]); } } } else { result = pages; } } return(result); }
/* * public static PageDataCollection GetRelatedPagesRoundTripHierarchy(Rule rule, Relation relation, int pageID) * { * PageReference pr = new PageReference(pageID); * PageData origPage = DataFactory.Instance.GetPage(pr); * List<int> relationPages = RelationEngine.GetRelationsForPageRoundTripHierarchy(pageID, rule, relation); * return PageIDListToPages(relationPages); * }*/ /// <summary> /// Helper method for page relation getters to convert relations to pages. /// </summary> /// <param name="pageIDList">Collection of page IDs</param> /// <returns>Collection of pages</returns> public static PageDataCollection PageIDListToPages(List <int> pageIDList) { PageDataCollection pages = new PageDataCollection(); foreach (int pgid in pageIDList) { PageData pd = PageEngine.GetPage(pgid); if (pd != null && !pages.Contains(pd)) { pages.Add(pd); } } return(pages); }
/* public static PageDataCollection GetRelatedPagesRoundTripHierarchy(Rule rule, Relation relation, int pageID) { PageReference pr = new PageReference(pageID); PageData origPage = DataFactory.Instance.GetPage(pr); List<int> relationPages = RelationEngine.GetRelationsForPageRoundTripHierarchy(pageID, rule, relation); return PageIDListToPages(relationPages); }*/ /// <summary> /// Helper method for page relation getters to convert relations to pages. /// </summary> /// <param name="pageIDList">Collection of page IDs</param> /// <returns>Collection of pages</returns> public static PageDataCollection PageIDListToPages(List<int> pageIDList) { PageDataCollection pages = new PageDataCollection(); foreach (int pgid in pageIDList) { PageData pd = PageEngine.GetPage(pgid); if (pd != null && !pages.Contains(pd)) pages.Add(pd); } return pages; }