public static T GetTaxon <T>(this RealEstateItem realEstateItem, TaxonType taxonType) where T : Taxon { var ids = (TrackedList <Guid>)realEstateItem.GetValue(taxonType.ToString()); if (ids != null && ids.Count > 0) { return(taxonomyManager.GetTaxon <T>(ids[0])); } return(null); }
public string GetTaxonTitleById(Guid id) { var taxon = manager.GetTaxon(id); if (taxon != null) { return(taxon.Title); } return(""); }
private IEnumerable <Classification> MapClassificationData(TrackedList <Guid> classifications) { var classificationData = new List <Classification>(); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); if (classifications != null) { foreach (var cat in classifications) { classificationData.Add(new Classification { Id = taxonomyManager.GetTaxon(cat).Id, Title = taxonomyManager.GetTaxon(cat).Title, Url = taxonomyManager.GetTaxon(cat).UrlName }); } } return(classificationData); }
public void NewsWidget_SelectByCategoryNewsFunctionality() { int newsCount = 4; string newsTitle = "Title"; string categoryTitle = "Category "; var newsController = new NewsController(); string[] categoryTitles = new string[newsCount + 1]; try { this.serverOperationsTaxonomies.CreateCategory(categoryTitle + "0"); for (int i = 0; i <= newsCount; i++) { categoryTitles[i] = categoryTitle + i; this.serverOperationsTaxonomies.CreateCategory(categoryTitle + (i + 1), categoryTitle + i); ServerOperationsFeather.NewsOperations().CreatePublishedNewsItem(NewsTitle + i, "Content", "AuthorName", "SourceName", new List <string> { categoryTitle + i }, null, null); } TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); for (int i = 0; i < newsCount; i++) { var category = taxonomyManager.GetTaxa <HierarchicalTaxon>().SingleOrDefault(t => t.Title == categoryTitle + i); ITaxon taxonomy = taxonomyManager.GetTaxon(category.Id); var items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); for (int j = 0; j < items.Length; j++) { Assert.IsTrue(items[j].Fields.Title.Equals(newsTitle + i, StringComparison.CurrentCulture), "The news with this title was not found!"); } } } finally { this.serverOperationsTaxonomies.DeleteCategories(categoryTitles); } }
public void NewsWidget_SelectByCategoryNewsFunctionalityAndLimits() { var newsController = new NewsController(); newsController.Model.DisplayMode = ListDisplayMode.Limit; int itemsPerPage = 3; newsController.Model.ItemsPerPage = itemsPerPage; string categoryTitle = "Category"; string[] newsTitles = { "Boat", "Cat", "Angel", "Kitty", "Dog" }; Guid[] newsId = new Guid[newsTitles.Count()]; try { this.serverOperationsTaxonomies.CreateCategory(categoryTitle + "0"); this.serverOperationsTaxonomies.CreateCategory(categoryTitle + "1", categoryTitle + "0"); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); var category0 = taxonomyManager.GetTaxa <HierarchicalTaxon>().SingleOrDefault(t => t.Title == categoryTitle + "0"); var category1 = taxonomyManager.GetTaxa <HierarchicalTaxon>().SingleOrDefault(t => t.Title == categoryTitle + "1"); for (int i = 0; i < newsTitles.Count(); i++) { if (i <= 3) { newsId[i] = this.serverOperationsNews.CreatePublishedNewsItem(newsTitles[i]); this.serverOperationsNews.AssignTaxonToNewsItem(newsId[i], "Category", category0.Id); } else { newsId[i] = this.serverOperationsNews.CreatePublishedNewsItem(newsTitles[i]); this.serverOperationsNews.AssignTaxonToNewsItem(newsId[i], "Category", category1.Id); } } ITaxon taxonomy = taxonomyManager.GetTaxon(category0.Id); var items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); Assert.IsTrue(items.Length.Equals(3), "Number of news items is not correct"); for (int i = 0; i <= 2; i++) { Assert.IsTrue(items[i].Fields.Title.Equals(newsTitles[3 - i], StringComparison.CurrentCulture), "The news with this title was found!"); } taxonomy = taxonomyManager.GetTaxon(category1.Id); items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); Assert.IsTrue(items.Length.Equals(1), "Number of news items is not correct"); Assert.IsTrue(items[0].Fields.Title.Equals(newsTitles[4], StringComparison.CurrentCulture), "The news with this title was found!"); newsController.Model.DisplayMode = ListDisplayMode.All; taxonomy = taxonomyManager.GetTaxon(category0.Id); items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); Assert.IsTrue(items.Length.Equals(4), "Number of news items is not correct"); for (int i = 0; i <= 3; i++) { Assert.IsTrue(items[i].Fields.Title.Equals(newsTitles[3 - i], StringComparison.CurrentCulture), "The news with this title was found!"); } taxonomy = taxonomyManager.GetTaxon(category1.Id); items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); Assert.IsTrue(items.Length.Equals(1), "Number of news items is not correct"); Assert.IsTrue(items[0].Fields.Title.Equals(newsTitles[4], StringComparison.CurrentCulture), "The news with this title was found!"); } finally { this.serverOperationsTaxonomies.DeleteCategories("Category0", "Category1"); } }
public void NewsWidget_SelectByTagAndSortNewsFunctionality() { int tagsCount = 3; Guid[] taxonId = new Guid[tagsCount]; string tagTitle = "Tag "; string sortExpession = "Title ASC"; string[] newsTitles = { "Boat", "Cat", "Angel", "Kitty", "Dog" }; string[] sortedTitles = { "Angel", "Boat", "Cat" }; Guid[] newsId = new Guid[newsTitles.Count()]; var newsController = new NewsController(); newsController.Model.SortExpression = sortExpession; string[] tagTitles = new string[tagsCount]; try { for (int i = 0; i < tagsCount; i++) { taxonId[i] = this.serverOperationsTaxonomies.CreateFlatTaxon(Telerik.Sitefinity.TestUtilities.CommonOperations.TaxonomiesConstants.TagsTaxonomyId, tagTitle + i); tagTitles[i] = tagTitle + i; } for (int i = 0; i < newsTitles.Count(); i++) { if (i <= 2) { newsId[i] = this.serverOperationsNews.CreatePublishedNewsItem(newsTitles[i]); this.serverOperationsNews.AssignTaxonToNewsItem(newsId[i], "Tags", taxonId[0]); } else { newsId[i] = this.serverOperationsNews.CreatePublishedNewsItem(newsTitles[i]); this.serverOperationsNews.AssignTaxonToNewsItem(newsId[i], "Tags", taxonId[i - 2]); } } newsController.Index(null); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); for (int i = 0; i < tagsCount; i++) { ITaxon taxonomy = taxonomyManager.GetTaxon(taxonId[i]); var items = newsController.Model.CreateListViewModel(taxonomy, 1).Items.ToArray(); if (i == 0) { for (int j = 0; j < items.Length; j++) { Assert.IsTrue(items[j].Fields.Title.Equals(sortedTitles[j], StringComparison.CurrentCulture), "The news with this title was not found!"); } } else { for (int j = 0; j < items.Length; j++) { Assert.IsTrue(items[j].Fields.Title.Equals(newsTitles[i + 2], StringComparison.CurrentCulture), "The news with this title was not found!"); } } } } finally { this.serverOperationsTaxonomies.DeleteTags(tagTitles); } }
protected void NewsExport_Click(object sender, EventArgs e) { StringBuilder newsItems = new StringBuilder(); NewsManager man = NewsManager.GetManager(); var tagString = string.Empty; List <string> tags = null; TaxonomyManager tMan = TaxonomyManager.GetManager(); foreach (var newsItem in man.GetNewsItems().Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master)) { tags = newsItem.GetValue <TrackedList <Guid> >("Tags").ToList().Select(i => tMan.GetTaxon(i).Title.Value).ToList(); newsItems.AppendLine(String.Format("{0}|{1}|{2}", newsItem.Title, String.Join(",", tags), newsItem.Content.Value.Replace("\n", ""))); } var file = new StreamWriter(ServerPath + "\\news.txt"); file.Write(newsItems); file.Close(); }
private void AddMetaDataTagsFromArticle(DynamicContent dynamicContent) { Page.RemoveExistingPublishedTags(); // add published date tags Page.AddCustomMetaTags("Published", dynamicContent.PublicationDate.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture)); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); if (dynamicContent.DoesFieldExist("Category")) { TrackedList <Guid> categoryIds = dynamicContent.GetValue("Category") as TrackedList <Guid>; if (categoryIds != null && categoryIds.Any()) { var categoryList = string.Join(",", categoryIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("webcategory", categoryList); } } if (dynamicContent.DoesFieldExist("resourcetypes")) { TrackedList <Guid> resourcetypesIds = dynamicContent.GetValue("resourcetypes") as TrackedList <Guid>; if (resourcetypesIds != null && resourcetypesIds.Any()) { var resourcetypesList = string.Join(",", resourcetypesIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("resourcetypes", resourcetypesList); } } Page.RemoveExistingModuleTags(); string modulePage = dynamicContent.GetType().Name; try { if (!AppSettingsUtility.GetValue <string>("MetaDataTags.Article.Name").IsNullOrWhitespace()) { modulePage = AppSettingsUtility.GetValue <string>("MetaDataTags.Article.Name"); } } catch (Exception) { } Page.AddCustomMetaTags("Module", modulePage); Type type; if (dynamicContent.SystemParentItem != null) { type = dynamicContent.SystemParentItem.GetType(); } else { type = dynamicContent.GetType(); } string articleType = type.FullName.Split('.')[4]; //Could change this to work with On-Scene Articles... if (articleType.ToLower().Contains("healthprogress")) { Page.AddCustomMetaTags("Publication", "Health Progress"); //Health Progress } if (dynamicContent.DoesFieldExist("author")) { var authorname = dynamicContent.Author; if (authorname != null) { Page.AddCustomMetaTags("ContentAuthor", authorname); } } var authorsFieldName = "organizationalauthors"; if (dynamicContent.DoesFieldExist(authorsFieldName)) { TrackedList <Guid> authorIds = dynamicContent.GetValue(authorsFieldName) as TrackedList <Guid>; if (authorIds != null) { var authorList = string.Join(",", authorIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("contentauthor", authorList); } } }