Ejemplo n.º 1
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>
        /// Sets the bread crumb.
        /// </summary>
        /// <param name="currentView">The current view.</param>
        /// <param name="text">The text.</param>
        private List <BreadCrumb> SetBreadCrumb(string currentView, string text)
        {
            List <BreadCrumb> crumbs = new List <BreadCrumb>
            {
                new BreadCrumb {
                    Href = urlService.UserRoot(), Text = "home"
                },
                new BreadCrumb {
                    Text = "photos"
                },
                new BreadCrumb {
                    Href = urlService.UserUrl("photos/" + currentView), Text = text
                }
            };

            return(crumbs);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }