/// <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()); }
/// <summary> /// Indexes this instance. /// </summary> /// <returns></returns> public ActionResult Index() { List <Member> members = _memberRepository.RetrieveMembers(); return(View(new DirectoryView { Members = members, UrlService = UserUrlService.GetInstance() })); }
/// <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> /// Indexes this instance. /// </summary> /// <returns></returns> public ActionResult Index() { List <Media> mediae = _mediaRepository.RetrieveRandom90Photos(); _persistentCollectionService.SetBackUrl("", SiteCookie); return(View(new HomeView { Media = mediae, UrlService = UserUrlService.GetInstance() })); }
/// <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> /// Gets the user URL service. /// </summary> /// <returns></returns> private static IUserUrlService GetUserUrlService() { return(UserUrlService.GetInstance()); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="ManagePhotoBase"/> class. /// </summary> /// <param name="user">The user.</param> /// <param name="authorization">The authorization.</param> protected ManagePhotoBase(Domain.Model.User user, Authorization authorization) : this(UserUrlService.GetInstance(authorization.Owner), user, DependencyInjection.Resolve <IMediaRepository>(), DependencyInjection.Resolve <ITagRepository>(), DependencyInjection.Resolve <IPaginationService <Media> >(), authorization) { }