public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List<IContentLibraryListItem> items = new List<IContentLibraryListItem>(); if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { // get photosets foreach (FlickrInfo info in Provider.Flickr.GetPhotoSets()) { items.Add(new ListItem(parentFolderUri.PublicationId, info)); } // oops, no photosets if(items.Count == 0) { items.Add(new ErrorListItem(parentFolderUri.PublicationId, "There are no public photo sets in this Flickr account.")); } } // only return files if they are requested (itemTypes is EclItemTypes.File)) else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "set" && itemTypes.HasFlag(EclItemTypes.File)) { // get photos foreach (FlickrInfo info in Provider.Flickr.GetPhotosInSet(parentFolderUri.ItemId)) { //items.Add(new FlickrPhoto(parentFolderUri.PublicationId, info)); items.Add(new ListItem(parentFolderUri.PublicationId, info)); } } return Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)); }
/// <summary> /// Gets an <see cref="T:Tridion.ExternalContentLibrary.V2.IFolderContent" /> representing the content of an external content folder or mount point. This list is used to build a tree structure when the user browse the content of the external library. /// </summary> /// <param name="parentFolderUri">The <see cref="T:Tridion.ExternalContentLibrary.V2.IEclUri" /> of the parent item. If <see cref="P:Tridion.ExternalContentLibrary.V2.IEclUri.ItemType" /> is <see cref="F:Tridion.ExternalContentLibrary.V2.EclItemTypes.MountPoint" /> the top level items are requested.</param> /// <param name="pageIndex">The 0 based index of the page to retrieve if the folder supports pagination.</param> /// <param name="itemTypes">Filters the item types to return. This can be used to for example only retrieve Folders for building up the tree structure.</param> /// <returns> /// A list of child items that should be displayed under the specified Folder. /// </returns> /// <remarks> /// A provider can use <see cref="M:Tridion.ExternalContentLibrary.V2.IHostServices.CreateFolderContent(Tridion.ExternalContentLibrary.V2.IEclUri,System.Collections.Generic.IList{Tridion.ExternalContentLibrary.V2.IContentLibraryListItem},System.Boolean,System.Boolean)" /> /// or one of the overloaded methods to initialize an instance of <see cref="T:Tridion.ExternalContentLibrary.V2.IFolderContent" />. /// </remarks> public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { String prefix = parentFolderUri.ItemId == "root" ? String.Empty : parentFolderUri.ItemId; IList <IContentLibraryListItem> items = new List <IContentLibraryListItem>(); foreach (S3ItemData itemData in _provider.S3.GetListing(prefix)) { S3ListItem item = null; if (itemData.ItemType == S3ItemType.Folder && itemTypes.HasFlag(EclItemTypes.Folder)) { item = new S3Folder(_provider, _session, parentFolderUri, itemData); } else if (itemTypes.HasFlag(EclItemTypes.File)) { item = new S3File(_provider, _session, parentFolderUri, itemData); } if (item != null) { _provider.Cache(item); items.Add(item); } } return(_session.HostServices.CreateFolderContent( parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List<IContentLibraryListItem> items = new List<IContentLibraryListItem>(); // ToDo: consider using async calls for getting users and forms if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { // get users foreach (WufooData data in Provider.Wufoo.GetUsers()) { items.Add(new ListItem(parentFolderUri.PublicationId, data)); } } // only return files if they are requested (itemTypes is EclItemTypes.File)) else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "user" && itemTypes.HasFlag(EclItemTypes.File)) { // get forms foreach (WufooData data in Provider.Wufoo.GetForms(parentFolderUri.ItemId)) { items.Add(new ListItem(parentFolderUri.PublicationId, data)); } } return Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { int totalVideos = 0; var items = new List <IContentLibraryListItem>(); if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { items.AddRange(YouTubeProvider.Client.Users.Select(user => new YouTubeListItem(parentFolderUri.PublicationId, user))); } if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "usr" && itemTypes.HasFlag(EclItemTypes.File)) { canPaginate = true; items.AddRange(YouTubeProvider.Client.GetUploadsForUser(parentFolderUri.ItemId, pageIndex, out totalVideos).Select(v => new YouTubeListItem(parentFolderUri.PublicationId, v))); } if (pageIndex == 0 && items.Count < 50) { canPaginate = false; } if (canPaginate) { bool isLast = items.Count < 50 || ((pageIndex + 1) * 50 >= totalVideos); return(YouTubeProvider.HostServices.CreateFolderContent(parentFolderUri, pageIndex, isLast, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); } else { return(YouTubeProvider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); } }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List <IContentLibraryListItem> items = new List <IContentLibraryListItem>(); if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { // get photosets foreach (FlickrInfo info in Provider.Flickr.GetPhotoSets()) { items.Add(new ListItem(parentFolderUri.PublicationId, info)); } // oops, no photosets if (items.Count == 0) { items.Add(new ErrorListItem(parentFolderUri.PublicationId, "There are no public photo sets in this Flickr account.")); } } // only return files if they are requested (itemTypes is EclItemTypes.File)) else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "set" && itemTypes.HasFlag(EclItemTypes.File)) { // get photos foreach (FlickrInfo info in Provider.Flickr.GetPhotosInSet(parentFolderUri.ItemId)) { //items.Add(new FlickrPhoto(parentFolderUri.PublicationId, info)); items.Add(new ListItem(parentFolderUri.PublicationId, info)); } } return(Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List <IContentLibraryListItem> items = new List <IContentLibraryListItem>(); // ToDo: consider using async calls for getting users and forms if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { // get users foreach (WufooData data in Provider.Wufoo.GetUsers()) { items.Add(new ListItem(parentFolderUri.PublicationId, data)); } } // only return files if they are requested (itemTypes is EclItemTypes.File)) else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "user" && itemTypes.HasFlag(EclItemTypes.File)) { // get forms foreach (WufooData data in Provider.Wufoo.GetForms(parentFolderUri.ItemId)) { items.Add(new ListItem(parentFolderUri.PublicationId, data)); } } return(Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { FotoWareProvider.HostServices.LogMessage(LoggingSeverity.Debug, string.Format("Getting folder contents for {0}, page index {1} for item types {2}", parentFolderUri.ToString(), pageIndex, itemTypes.ToString() ) ); List<IContentLibraryListItem> result = new List<IContentLibraryListItem>(); if(parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { result.AddRange(GetRootFolderContent(parentFolderUri)); } bool canUpload = CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId); bool canSearch = CanSearch(parentFolderUri.PublicationId); return FotoWareProvider.HostServices.CreateFolderContent(parentFolderUri, result, canUpload, canSearch); }
public List <S3Info> GetDirectories(IEclUri parentFolderUri, EclItemTypes itemTypes) { List <S3Info> s3List = new List <S3Info>(); List <S3Info> myList = new List <S3Info>(); S3DirectoryInfo s3Root = null; GetObjectRequest getDirObjectRequest = null; if (parentFolderUri.ItemId == "root") { s3Root = new S3DirectoryInfo(s3Client, BucketName); } else { s3Root = new S3DirectoryInfo(s3Client, BucketName, parentFolderUri.ItemId.Replace('/', '\\').TrimEnd('/')); } if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder) && !itemTypes.HasFlag(EclItemTypes.File)) { foreach (var subdirectories in s3Root.GetDirectories()) { var item = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/'); var itemUrl = FullBucketUrl + item; myList.Add(new S3Info(subdirectories, itemUrl, "Folder")); } } else if (itemTypes.HasFlag(EclItemTypes.File) && itemTypes.HasFlag(EclItemTypes.Folder)) { foreach (var subdirectories in s3Root.GetDirectories()) { var item = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/'); var itemUrl = FullBucketUrl + item; myList.Add(new S3Info(subdirectories, itemUrl, "Folder")); } foreach (var file in s3Root.GetFiles()) { var item = file.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/'); var itemUrl = FullBucketUrl + item; myList.Add(new S3Info(file, itemUrl, "File")); } } else if (itemTypes.HasFlag(EclItemTypes.Folder)) { foreach (var subdirectories in s3Root.GetDirectories()) { var item = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/'); var itemUrl = FullBucketUrl + item; myList.Add(new S3Info(subdirectories, itemUrl, "Folder")); } } else if (itemTypes.HasFlag(EclItemTypes.File)) { foreach (var file in s3Root.GetFiles()) { var item = file.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/'); var itemUrl = FullBucketUrl + item; myList.Add(new S3Info(file, itemUrl, "File")); } } else { throw new NotSupportedException(); } return(myList); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List <IContentLibraryListItem> items = new List <IContentLibraryListItem>(); int numberOfPages = 1; // If root -> list all root categories // if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { items.Add(new TypeItem(parentFolderUri.PublicationId, "Categories")); items.Add(new TypeItem(parentFolderUri.PublicationId, "Products")); } else if (parentFolderUri.ItemType == EclItemTypes.Folder && itemTypes.HasFlag(EclItemTypes.Folder)) { if (parentFolderUri.ItemId.StartsWith("Type_")) { if (parentFolderUri.ItemId.Equals("Type_Products")) { foreach (var category in EclProvider.GetRootCategory(parentFolderUri.PublicationId).Categories) { if (!String.IsNullOrEmpty(category.CategoryId)) { items.Add(new CategoryItem(parentFolderUri.PublicationId, category)); } } } else // Type_Categories { /* * List<string> allCategories = EclProvider.GetAllCategoryIds(); * foreach ( var categoryId in allCategories ) * { * items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, categoryId)); * } */ // TODO: Can we somehow build up a structure here instead??? // TODO: Have a hook for providers to hook in their variant on the listing here??? var allCategories = EclProvider.GetAllCategories(parentFolderUri.PublicationId); foreach (var category in allCategories) { items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, category)); } } } else { // TODO: Always use the product catalog for retrieving the category??? var parentCategory = EclProvider.GetCategory(parentFolderUri.ItemId, parentFolderUri.PublicationId); if (parentCategory != null) { foreach (var category in parentCategory.Categories) { if (!String.IsNullOrEmpty(category.CategoryId)) { // TODO: Have possibility to have concrete category items for each provider items.Add(new CategoryItem(parentFolderUri.PublicationId, category)); } } var result = EclProvider.ProductCatalog.GetProducts(parentFolderUri.ItemId, parentFolderUri.PublicationId, pageIndex); if (result != null) { numberOfPages = result.NumberOfPages; foreach (var product in result.Products) { items.Add(this.CreateProductItem(parentFolderUri.PublicationId, parentCategory, product)); } } } } } return(EclProvider.HostServices.CreateFolderContent(parentFolderUri, pageIndex, numberOfPages, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); }
public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes) { List <IContentLibraryListItem> items = new List <IContentLibraryListItem>(); // If root -> list all root categories // if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder)) { items.Add(new TypeItem(parentFolderUri.PublicationId, "Categories")); items.Add(new TypeItem(parentFolderUri.PublicationId, "Products")); } else if (parentFolderUri.ItemType == EclItemTypes.Folder && itemTypes.HasFlag(EclItemTypes.Folder)) { if (parentFolderUri.ItemId.StartsWith("Type_")) { if (parentFolderUri.ItemId.Equals("Type_Products")) { foreach (var category in EclProvider.RootCategory.Categories) { if (!String.IsNullOrEmpty(category.CategoryId)) { items.Add(new CategoryItem(parentFolderUri.PublicationId, category)); } } } else // Type_Categories { /* * List<string> allCategories = EclProvider.GetAllCategoryIds(); * foreach ( var categoryId in allCategories ) * { * items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, categoryId)); * } * */ var allCategories = EclProvider.GetAllCategories(); foreach (var category in allCategories) { items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, category)); } } } else { // TODO: Always use the product catalog for retrieving the category??? var parentCategory = EclProvider.GetCategory(parentFolderUri.ItemId); if (parentCategory != null) { foreach (var category in parentCategory.Categories) { if (!String.IsNullOrEmpty(category.CategoryId)) { // TODO: Have possibility to have concrete category items for each provider items.Add(new CategoryItem(parentFolderUri.PublicationId, category)); } } var products = EclProvider.ProductCatalog.GetProducts(parentFolderUri.ItemId, parentFolderUri.PublicationId); if (products != null) { // TODO: Have some kind of pagination here??? // At a leaf category -> list all products in that category // foreach (var product in products) { items.Add(this.CreateProductItem(parentFolderUri.PublicationId, parentCategory, product)); } } } } } return(EclProvider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId))); }