MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

SN file gallery  (Mono Support )

Viewed 18843 time(s), 6 post(s) 9/25/2011 9:09:50 AMby rovvy

Related topics

rovvy

rovvy

9/25/2011 9:09:50 AM
Hi!

How can I make the SN file gallery module display items only from specified directory?

Thanks,
R
This content has not been rated yet. 
152 Reputation 21 Total posts
khorvat

khorvat

9/25/2011 5:20:28 PM
Hi,

file gallery's built-in functionality isn't oriented to MonoX file or folder structure but on MonoX subsystems such as Blog (Blog posts), Discussion (Topics and Posts), Wall posts etc. Basically every file uploaded to MonoX file system has some sort of Parent entity (you should take a look at the SnFile Database table) which holds a list of files uploaded. 

To get the list of files for specific directory you will need to programatically get the list of files for a directory and set the Files property of SnFileGallery Web Part.

If you need more assistance let us know.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
rovvy

rovvy

9/26/2011 1:09:33 PM
This was more or less my understanding in the first place. Thanks for clarifying.

How about the SN Photo Gallery container, is it possible to display only one photo album, that user specifies?
This content has not been rated yet. 
152 Reputation 21 Total posts
khorvat

khorvat

9/26/2011 2:50:26 PM
Hi,

To show photos from a specific album you could use PhotoListView WebPart and programatically set AlbumId property to filter out other albums. In the current version of MonoX PhotoGallery module doesn't support this as it hasn't have AlbumId property exposed, this will be available in next version of MonoX. 

BTW - can you please post your questions to your Priority forum so we can address them faster, thanks.

Let me know if you need anything else.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
rovvy

rovvy

9/26/2011 4:06:25 PM
Hi and thanks for the reply. I will try to use the priority forum starting from the next topic.
However I would like to have a bit more information/directions on how to use AlbumId in PhotoListView class to achive this.
Thanks,
R
This content has not been rated yet. 
152 Reputation 21 Total posts
khorvat

khorvat

9/27/2011 1:47:31 PM
Hi,

I'll try to show you how to implement this by following few steps:

1. Place the PhotoListView WebPart on the page where you want to show the photos from specific album
...
<%@ Register Src="/MonoX/ModuleGallery/SocialNetworking/PhotoGallery/PhotoListView.ascx" TagPrefix="MonoX" TagName="PhotoListView" %>   
...
<MonoX:PhotoListView ID="photoListView" runat="server">
</MonoX:PhotoListView>
...

2. Use AlbumRepository to get the album(s) you need and to show the photos from that album

This will return the albums for specified user or group with certain privacy levels (Public, Private, etc.) and the result will be pages so no need to worry about the optimization.  
...
MonoSoftware.MonoX.Repositories.AlbumRepository.GetInstance().GetAlbums(Guid? userId, Guid? groupId, List<Guid> privacyLevelIds, bool fullPrefetchPath, int pageIndex, int pageSize, out int recordCount)
...
or you can get the new albums by calling the following method
...
MonoSoftware.MonoX.Repositories.AlbumRepository.GetInstance().GetNewAlbums(List<Guid> privacyLevels, AlbumSortCriteria sortBy, bool onlyWithCover, int pageIndex, int pageSize, out int recordCount)
...

If you need to search for album with specific name you can use the code below to do so
...
/// <summary>
/// Retrieves a collection of album entities for the paging scenarios.
/// </summary>
/// <param name="searchPhrase">User ID.</param>
/// <param name="userId">User ID.</param>
/// <param name="groupId">Group ID.</param>
/// <param name="privacyLevelIds">Privacy level ids</param>
/// <param name="fullPrefetchPath">Include full prefetch path</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="recordCount">Record count.</param>
/// <returns>Collection of album entities that satisfy the criteria from the parameter list.</returns>
public virtual EntityCollection<SnAlbumEntity> GetAlbums(string searchPhrase, Guid? userId, Guid? groupId, List<Guid> privacyLevelIds, bool fullPrefetchPath, int pageIndex, int pageSize, out int recordCount)
{
    EntityCollection<SnAlbumEntity> albums = new EntityCollection<SnAlbumEntity>();
    RelationPredicateBucket filter = new RelationPredicateBucket();
 
    filter.PredicateExpression.Add(SnAlbumFields.ApplicationId == MembershipRepository.GetInstance().GetApplicationId());
    filter.PredicateExpression.Add(SnAlbumFields.LanguageId == LocalizationUtility.GetCurrentLanguageId());
 
    if (groupId.HasValue)
    {
        filter.PredicateExpression.Add(SnAlbumFields.SnGroupId == groupId.GetValueOrDefault());
        if (userId.HasValue && !Guid.Empty.Equals(userId.GetValueOrDefault()))
            filter.PredicateExpression.Add(SnAlbumFields.UserId == userId.GetValueOrDefault());
    }
    else
    {
        PredicateExpression peRoot = new PredicateExpression();
        //Filter in user photo albums but exclude the group photo albums
        PredicateExpression pe = new PredicateExpression();
        pe.Add(SnAlbumFields.UserId == userId.GetValueOrDefault());
        pe.Add(SnAlbumFields.SnGroupId == DBNull.Value);
        peRoot.Add(pe);
        if (privacyLevelIds.Count > 0)
        {
            filter.Relations.Add(SnAlbumEntity.Relations.AspnetUsersEntityUsingUserId);
            PredicateExpression pePrivacy = new PredicateExpression();
            PredicateExpression peGroup = new PredicateExpression();
            peGroup.Add(SnAlbumFields.SnGroupId == DBNull.Value);
 
            if (!(SecurityUtility.IsAdmin() || SecurityUtility.IsPhotoGalleryAdmin()))
            {
                PredicateExpression privacyFilter = new PredicateExpression();
 
                PredicateExpression friendFilter = new PredicateExpression();
                friendFilter.Add(SnAlbumFields.UserId == userId.GetValueOrDefault());
                friendFilter.AddWithOr(FriendRepository.GetInstance().GetFriendshipFilter(userId.GetValueOrDefault()));
 
                PredicateExpression friendPrivacyFilter = GetFriendPrivacyFilter();
                friendFilter.Add(friendPrivacyFilter);
 
                privacyFilter.AddWithOr(friendFilter);
 
 
                pePrivacy.Add(privacyFilter);
            }
            pePrivacy.Add(peGroup);
            peRoot.AddWithOr(pePrivacy);
        }
        filter.PredicateExpression.Add(peRoot);
    }           
 
    AddPartialPhraseSearch(filter, SnAlbumFields.Name, searchPhrase);
    AddWithOrPartialPhraseSearch(filter, SnAlbumFields.Description, searchPhrase);
     
    ISortExpression sorter = new SortExpression(SnAlbumFields.DateCreated | SortOperator.Descending);
    FetchEntityCollection(albums, filter, 0, sorter, GetPrefetchPath(fullPrefetchPath), pageIndex, pageSize);
 
    InitAlbumCovers(albums);
 
    recordCount = GetDbCount(albums, filter);
    return albums;
}
...

3. After you fetch the albums choose the album you want and set the AlbumId of the PhotoListView WebPart
if (!AlbumId.Equals(Guid.Empty))
    photoListView.AlbumId = AlbumId;
photoListView.ContentProviderTypeName = MonoSoftware.MonoX.FileSystem.FileContentManager.DefaultProviderTypeName;
photoListView.DataBind(isRebind);

BTW can you please open a separate topics for things like this - we are not talking about the Photo gallery and topic is related to File Gallery :)

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts