/// <summary>
        /// Renders the specified tags.
        /// </summary>
        /// <param name="tags">The tags.</param>
        /// <param name="username">The username.</param>
        /// <returns></returns>
        public static string Render(IList <Tag> tags, string username)
        {
            IUserUrlService urlService = UserUrlService.GetInstance();
            StringBuilder   builder    = new StringBuilder();

            if (tags == null)
            {
                throw new System.ArgumentNullException("tags", "Parameter 'tags' is null, value expected");
            }

            if (tags.Count > 0)
            {
                builder.AppendLine(string.Format("<div class=\"marginbottom40\" ><h3 class=\"tagallhack\" ><a href=\"{0}\">tags</a></h3> ", urlService.CreateUrl(username, "tags")));
                builder.AppendLine("<p style='text-align:right;margin-top:3px;' ><label id='filtertags' >filter:</label><input type='text' id='tagfilter' /></p> ");

                const string tagFormat = "<span class=\"tagWrapper\" ><a href=\"/{0}/tagged/{1}\" rel=\"{2}\" title=\"view photos tagged '{1}'\" class=\"tag\">{1}</a>{3}</span>";
                for (int index = 0; index < tags.Count; index++)
                {
                    builder.AppendLine(string.Format(tagFormat, username, tags[index].TagText, tags[index].Count, (index < tags.Count - 1 ? "<span class=\"comma\" >,</span>" : string.Empty)));
                }

                builder.AppendLine("</div>");
            }

            return(builder.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Renders the specified media.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="user">The user.</param>
        /// <param name="set">The set.</param>
        /// <returns></returns>
        public static string Render(IList <Media> media, User user, string set)
        {
            IUserUrlService urlService = UserUrlService.GetInstance(user);
            StringBuilder   builder    = new StringBuilder();

            const string thumbFormat = @"
                                        <div class=""thumbnails"" {3}>
                                            <span >
                                                <a href=""{9}"" rel=""{0}"" name=""{4}"" class=""showimage lightbox"" title=""{2}"" ><img src=""{1}""  alt=""{2}"" /></a>
                                            </span>
                                        
                                            <ul class=""largethumbnailmetadata"" >
                                                <li class=""title"" >{5}</li>
                                                <li>{6}</li>
                                                <li class=""comment hyperlinks"" ><a href=""{8}/comments/leave/{4}"">comments ({7})</a></li>
                                            </ul>
                                        </div>";

            if (media == null)
            {
                throw new System.ArgumentNullException("media", "Parameter 'media' is null, value expected");
            }

            if (media.Count > 0)
            {
                string imagePath = PhotoHtmlHelper.GetImageDetailLinkForFirst(media[0], "homepagefullsize", set, PhotoType.Websize);
                builder.AppendLine(string.Format("<div class=\"firstimage\" >{0} <div > <h3 class=\"firstphototitle\" >{1}</h3> <p>{2}</p></div> <br class=\"clearboth\" /> </div>", imagePath, media[0].Title, media[0].Description));

                if (media.Count > 15)
                {
                    builder.AppendLine("<div class=\"largethumbs\" >");

                    for (int index = 1; index < media.Count && index < 16; index++)
                    {
                        string    showUrl    = urlService.UserUrl("photos/show/" + set + "/#/photo/" + media[index].MediaId);
                        MediaFile webSize    = media[index].GetImageByPhotoType(PhotoType.Websize);
                        string    websizeUrl = urlService.CreateImageUrl(webSize.FilePath);
                        builder.AppendLine(string.Format(thumbFormat,
                                                         websizeUrl,
                                                         websizeUrl,
                                                         media[index].Title,
                                                         (index % 3 == 0 ? "style=\"margin-right:0px;\"" : string.Empty),
                                                         media[index].MediaId,
                                                         TruncateText(media[index].Title, 20),
                                                         TruncateText(media[index].Description, 35),
                                                         media[index].CommentCount,
                                                         urlService.UserRoot(),
                                                         showUrl));
                    }

                    builder.AppendLine("<div class=\"clearboth\" ></div>");
                    builder.AppendLine("</div>");
                }
            }

            return(builder.ToString());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManagePhotoBase"/> class.
 /// </summary>
 /// <param name="urlService">The URL service.</param>
 /// <param name="user">The user.</param>
 /// <param name="mediaRepository">The media repository.</param>
 /// <param name="tagRepsitory">The tag repsitory.</param>
 /// <param name="paginationService">The pagination service.</param>
 /// <param name="authorization">The authorization.</param>
 protected ManagePhotoBase(
     IUserUrlService urlService,
     Domain.Model.User user,
     IMediaRepository mediaRepository,
     ITagRepository tagRepsitory, IPaginationService<Media> paginationService, Authorization authorization)
 {
     this.urlService = urlService;
     _paginationService = paginationService;
     this.tagRepsitory = tagRepsitory;
     this.mediaRepository = mediaRepository;
     this.user = user;
     this.authorization = authorization;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManagePhotoBase"/> class.
 /// </summary>
 /// <param name="urlService">The URL service.</param>
 /// <param name="user">The user.</param>
 /// <param name="mediaRepository">The media repository.</param>
 /// <param name="tagRepsitory">The tag repsitory.</param>
 /// <param name="paginationService">The pagination service.</param>
 /// <param name="authorization">The authorization.</param>
 protected ManagePhotoBase(
     IUserUrlService urlService,
     Domain.Model.User user,
     IMediaRepository mediaRepository,
     ITagRepository tagRepsitory, IPaginationService <Media> paginationService, Authorization authorization)
 {
     this.urlService      = urlService;
     _paginationService   = paginationService;
     this.tagRepsitory    = tagRepsitory;
     this.mediaRepository = mediaRepository;
     this.user            = user;
     this.authorization   = authorization;
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetThumbnailImage(Media media)
        {
            string link = string.Empty;

            if (media != null)
            {
                IUserUrlService userUrlService = GetUserUrlService();

                MediaFile    thumbnail  = media.GetImageByPhotoType(PhotoType.Thumbnail);
                const string linkFormat = "<img src=\"{0}\" alt=\"{1}\" /></a>";
                link = string.Format(linkFormat, userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath), media.Description);
            }

            return(link);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="set">The set.</param>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetImageLink(string set, Media media)
        {
            MediaFile       thumbnail      = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile       websize        = media.GetImageByPhotoType(PhotoType.Websize);
            IUserUrlService userUrlService = GetUserUrlService();


            const string linkFormat = "<a id=\"{4}\" class=\"showimage lightbox\" name=\"{3}\" rel=\"{2}\" href=\"{5}\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" /></a>";
            string       link       = string.Format(linkFormat,
                                                    userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath),
                                                    media.Title,
                                                    userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath),
                                                    media.MediaId,
                                                    media.Owner.Username,
                                                    userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId));

            return(link);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="friend">The friend.</param>
        /// <returns></returns>
        public static string GetFriendImageThumbnailForUserHomepage(Friend friend)
        {
            string val = string.Empty;

            if (friend.Media != null)
            {
                IUserUrlService userUrlService = GetUserUrlService();

                MediaFile    thumbnail  = friend.Media.GetImageByPhotoType(PhotoType.Thumbnail);
                const string linkFormat = "<li><span><a class=\"showimage\" href=\"{0}\" title=\"{1}\"><img src=\"{2}\" alt=\"{3}\" /></a></span><span class=\"albumtitle\">{4}<span></li>";
                val = string.Format(linkFormat,
                                    userUrlService.UserRoot(friend.Username),
                                    friend.DisplayName,
                                    userUrlService.CreateImageUrl(friend.Media.Owner.Username, thumbnail.FilePath),
                                    friend.Media.Description,
                                    friend.DisplayName);
            }
            return(val);
        }
Esempio n. 8
0
 public UserService(
     EruContext context,
     IUserAvatarService avatarService,
     IUserUrlService urlService,
     IUserProfileService profileService,
     AuthenticationService authenticationService,
     RoleService roleService,
     PermissionService permissionService
     )
 {
     _context               = context;
     _passwordHasher        = new PasswordHasher <string>();
     _avatarService         = avatarService;
     _urlService            = urlService;
     _profileService        = profileService;
     _authenticationService = authenticationService;
     _permissionService     = permissionService;
     _roleService           = roleService;
 }
Esempio n. 9
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="set">The set.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static string GetImageDetailLinkForFirst(Media media, string cssClass, string set, PhotoType type)
        {
            IUserUrlService       userUrlService = GetUserUrlService();
            Func <string, string> title          =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile    thumbnail  = media.GetImageByPhotoType(type);
            const string linkFormat = "<a class=\"{5} lightbox\" name=\"{6}\"  href=\"{0}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string       link       = string.Format(linkFormat,
                                                    userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId),
                                                    title(media.Title),
                                                    userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                                                    media.Title,
                                                    title(media.Title),
                                                    cssClass,
                                                    media.MediaId);

            return(link);
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the photo detail links.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="isAuthenticated">if set to <c>true</c> [is authenticated].</param>
        /// <returns></returns>
        public static string GetPhotoDetailLinks(Media media, bool isAuthenticated)
        {
            IUserUrlService userUrlService = GetUserUrlService();
            ITagService     tagService     = DependencyInjection.Resolve <ITagService>();

            const string perminateLinkFormat = @"<li><a href=""{0}"" title=""{1}"" >permalink</a></li>";
            string       perminateLink       = string.Format(perminateLinkFormat, userUrlService.UserUrl(media.Owner.Username, "photos/show/" + media.MediaId), media.Title);

            string html = @"<ul>
                        <li>
                        <span>";

            html += (isAuthenticated ? @"<a id=""editlink""  href=""{0}/photos/edit/{1}"">edit</a>" : string.Empty);
            html += @"</span>            
                    </li>";
            html += "{2}";
            html += @"          
                    </li>
                     {3}  
                     {5}                  
                    <li><span><a href=""{0}/comments/leave/{1}"">comments ({4})</a></span> 
                </ul>";

            string tags = string.Empty;

            if (!string.IsNullOrEmpty(media.Tags))
            {
                const string tagFormat    = @"<li><span>tags:</span> {0}</li>";
                string       renderedTags = tagService.HyperlinkTheTags(media.Tags, media.Owner.Username);
                tags = string.Format(tagFormat, renderedTags);
            }

            string date = GetDate(media);

            string content = string.Format(html, userUrlService.UserRoot(media.Owner.Username), HttpUtility.HtmlEncode(media.MediaId.ToString()), date, tags, media.CommentCount, perminateLink);

            return(content);
        }
        /// <summary>
        /// Renders the numeric paging.
        /// </summary>
        /// <param name="numericPaging">The numeric paging.</param>
        /// <param name="user">The user.</param>
        /// <param name="letter">The letter.</param>
        /// <returns></returns>
        public static string RenderNumericPaging(NumericPaging numericPaging, User user, char letter)
        {
            string paging = string.Empty;

            if (!(numericPaging.PageSize > numericPaging.TotalCount))
            {
                IUserUrlService urlService = UserUrlService.GetInstance(user);
                int             pages      = Convert.ToInt32(Math.Ceiling(numericPaging.TotalCount / Convert.ToDecimal(numericPaging.PageSize)));

                const string  linkFormat = "<li><a href=\"{0}\" title=\"View page {1}\" {3} >{2}</a></li>";
                StringBuilder builder    = new StringBuilder();

                for (int index = 1; index <= pages; index++)
                {
                    string selectedText = (numericPaging.CurrentPage == index ? "class=\"active\"" : string.Empty);
                    builder.AppendLine(string.Format(linkFormat, urlService.CreateUrl("tags/show/" + letter + "?page=" + index), index, index, selectedText));
                }

                paging = builder.ToString();
            }

            return(paging);
        }
        /// <summary>
        /// Renders the alphabet paging.
        /// </summary>
        /// <param name="alphabetPages">The alphabet pages.</param>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public static string RenderAlphabetPaging(AlphabetPagingView alphabetPages, User user)
        {
            IUserUrlService urlService = UserUrlService.GetInstance(user);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("<ul class=\"alphabet\">");
            const string haveTagsFormat       = "<li {1} ><a  href=\"{2}\" >{0}</a></li>";
            const string doesntHaveTagsFormat = "<li>{0}</li>";

            foreach (AlphabetPage alphabetPage in alphabetPages.AlphabetPages)
            {
                string isSelected = (alphabetPage.Letter.Equals(alphabetPages.SelectedLetter.ToString(), StringComparison.InvariantCultureIgnoreCase)
                                         ? "class=\"selected\""
                                         : string.Empty);

                builder.AppendLine(alphabetPage.MediaCount > 0
                    ? string.Format(haveTagsFormat, alphabetPage.Letter, isSelected, urlService.CreateUrl("tags/show/" + alphabetPage.Letter))
                    : string.Format(doesntHaveTagsFormat, alphabetPage.Letter));
            }

            builder.AppendLine("</ul>");
            return(builder.ToString());
        }
 /// <summary>
 /// Method called when authorization occurs.
 /// </summary>
 /// <param name="filterContext">Contains information about the current request and action.</param>
 protected override void OnAuthorization(AuthorizationContext filterContext)
 {
     Owner      = _userAuthorization.GetOwner(filterContext.HttpContext, filterContext.RouteData);
     UrlService = UserUrlService.GetInstance(Owner);
     base.OnAuthorization(filterContext);
 }