private static TagSearchOptions GetTagSearchOptions(TagSearchType searchType)
 {
     return(new TagSearchOptions
     {
         GalleryId = Utils.GetQueryStringParameterInt32("galleryId"),
         SearchType = searchType,
         SearchTerm = Utils.GetQueryStringParameterString("q"),
         IsUserAuthenticated = Utils.IsAuthenticated,
         Roles = RoleController.GetGalleryServerRolesForUser()
     });
 }
        private static string GetTagTreeRootNodeText(TagSearchType searchType)
        {
            switch (searchType)
            {
                case TagSearchType.AllTagsInGallery:
                case TagSearchType.TagsUserCanView:
                    return Resources.GalleryServerPro.Site_Tag_Tree_Root_Node_Title;

                case TagSearchType.AllPeopleInGallery:
                case TagSearchType.PeopleUserCanView:
                    return Resources.GalleryServerPro.Site_People_Tree_Root_Node_Title;

                default:
                    throw new ArgumentException(String.Format("This function is not expecting TagSearchType={0}", searchType));
            }
        }
        private static string GetTagTreeNavUrlQsParm(TagSearchType searchType)
        {
            switch (searchType)
            {
                case TagSearchType.AllTagsInGallery:
                case TagSearchType.TagsUserCanView:
                    return "tag";

                case TagSearchType.AllPeopleInGallery:
                case TagSearchType.PeopleUserCanView:
                    return "people";

                default:
                    throw new ArgumentException(String.Format("This function is not expecting TagSearchType={0}", searchType));
            }
        }
 private static TagSearchOptions GetTagSearchOptions(TagSearchType searchType, string searchTerm, int galleryId, int numTagsToRetrieve = int.MaxValue, TagSearchOptions.TagProperty sortProperty = TagSearchOptions.TagProperty.NotSpecified, bool sortAscending = true, bool expanded = false)
 {
     return new TagSearchOptions
     {
         GalleryId = galleryId,
         SearchType = searchType,
         SearchTerm = searchTerm,
         IsUserAuthenticated = Utils.IsAuthenticated,
         Roles = RoleController.GetGalleryServerRolesForUser(),
         NumTagsToRetrieve = numTagsToRetrieve,
         SortProperty = sortProperty,
         SortAscending = sortAscending,
         TagTreeIsExpanded = expanded
     };
 }
        /// <summary>
        /// Gets a JSON string representing the tags used in the specified gallery. The JSON can be used as the
        /// data source for the jsTree jQuery widget. Only tags the current user has permission to view are
        /// included. The tag tree has a root node containing a single level of tags.
        /// </summary>
        /// <param name="tagSearchType">Type of search.</param>
        /// <param name="galleryId">The gallery ID.</param>
        /// <param name="top">The number of tags to return. Values less than zero are treated the same as zero,
        /// meaning no tags will be returned. Specify <see cref="int.MaxValue" /> to return all tags.</param>
        /// <param name="sortBy">The property to sort the tags by. Specify <see cref="TagSearchOptions.TagProperty.Count" />
        /// to sort by tag frequency or <see cref="TagSearchOptions.TagProperty.Value" /> to sort by tag name. 
        /// When not specified, defaults to <see cref="TagSearchOptions.TagProperty.Count" />.</param>
        /// <param name="sortAscending">Specifies whether to sort the tags in ascending order. Specify <c>true</c>
        /// for ascending order or <c>false</c> for descending order. When not specified, defaults to <c>false</c>.</param>
        /// <param name="expanded">if set to <c>true</c> the tree is configured to display in an expanded form.</param>
        /// <returns>System.String.</returns>
        public static string GetTagTreeAsJson(TagSearchType tagSearchType, int galleryId, int top = int.MaxValue, TagSearchOptions.TagProperty sortBy = TagSearchOptions.TagProperty.Count, bool sortAscending = false, bool expanded = false)
        {
            var tagSearchOptions = GetTagSearchOptions(tagSearchType, null, galleryId, top, sortBy, sortAscending, expanded);

            return GetTagTree(tagSearchOptions).ToJson();
        }
 /// <summary>
 /// Gets a list of tags or people corresponding to the specified parameters.
 /// Guaranteed to not return null.
 /// </summary>
 /// <param name="tagSearchType">Type of the search.</param>
 /// <param name="searchTerm">The search term. Only tags that begin with this string are returned.
 /// Specify null or an empty string to return all tags.</param>
 /// <param name="galleryId">The gallery ID.</param>
 /// <param name="top">The number of tags to return. Values less than zero are treated the same as zero,
 /// meaning no tags will be returned. Specify <see cref="int.MaxValue" /> to return all tags.</param>
 /// <param name="sortBy">The property to sort the tags by. Specify <see cref="TagSearchOptions.TagProperty.Count" />
 /// to sort by tag frequency or <see cref="TagSearchOptions.TagProperty.Value" /> to sort by tag name. 
 /// When not specified, defaults to <see cref="TagSearchOptions.TagProperty.NotSpecified" />.</param>
 /// <param name="sortAscending">Specifies whether to sort the tags in ascending order. Specify <c>true</c>
 /// for ascending order or <c>false</c> for descending order. When not specified, defaults to <c>false</c>.</param>
 /// <returns>IEnumerable{Business.Entity.Tag}.</returns>
 public static IEnumerable<Business.Entity.Tag> GetTags(TagSearchType tagSearchType, string searchTerm, int galleryId, int top = int.MaxValue, TagSearchOptions.TagProperty sortBy = TagSearchOptions.TagProperty.NotSpecified, bool sortAscending = false)
 {
     return GetTags(GetTagSearchOptions(tagSearchType, searchTerm, galleryId, top, sortBy, sortAscending));
 }