private static List <Photo> GetVideos(IApiProvider apiProvider, PhotoListParameters photoListParameters) { var photoService = new PhotoService(apiProvider); var p = photoListParameters; if (photoListParameters == null) { p = new PhotoListParameters(); } p.IncludeUnpublished = false; p.PageOffset = 1; p.Size = 20; p.Video = true; var allPhotos = new List <Photo>(); var completed = false; while (!completed) { var photos = photoService.GetList(p); allPhotos.AddRange(photos); completed = photos.Count < p.Size; p.PageOffset++; } return(allPhotos); }
/// <summary> /// Create all your controls here for rendering. /// Try to avoid using the RenderWebPart() method. /// </summary> protected override void CreateChildControls() { try { base.CreateChildControls(); // * Make the query PhotoListParameters listParameters = new PhotoListParameters { AlbumId = null, IncludeUnpublished = false, Size = _count }; if (!String.IsNullOrEmpty(_albumInfo)) { string[] albumParams = _albumInfo.Split('|'); listParameters.AlbumId = Convert.ToInt32(albumParams[0]); listParameters.Token = albumParams[1]; } switch (_order) { case "CreatedAscending": case "PublishedAscending": case "UploadedAscending": case "ViewsAscending": listParameters.Order = GenericSort.Ascending; break; default: listParameters.Order = GenericSort.Descending; break; } switch (_order) { case "CreatedAscending": case "CreatedDescending": listParameters.OrderBy = PhotoListSort.Created; break; case "UploadedAscending": case "UploadedDescending": listParameters.OrderBy = PhotoListSort.Uploaded; break; case "ViewsAscending": case "ViewsDescending": listParameters.OrderBy = PhotoListSort.Views; break; default: listParameters.OrderBy = PhotoListSort.Published; break; } if ((_tags != null) && (_tags.Count > 0)) { listParameters.TagMode = (_tagMode == "All" ? PhotoTagMode.And : PhotoTagMode.Any); listParameters.Tags = _tags; } this.Controls.Add(new LiteralControl("<ul class=\"visual-list\">")); IApiProvider apiProvider = Utilities.ApiProvider; if (apiProvider != null) { IPhotoService photoService = new PhotoService(apiProvider); List <Domain.Photo> photos = photoService.GetList(listParameters); string protocol = Configuration.HttpSecure ? "https://" : "http://"; foreach (Domain.Photo photo in photos) { PhotoBlock size = Utilities.GetVideoSize(photo, Size); string pid = "photo" + photo.PhotoId.ToString(); string showVideoCall; // Figure out exact code to put in string token = _tokenFreeEmebds ? "" : photo.Token; if (_clickToPlay) { showVideoCall = "showVideo('" + pid + "','" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), token, size.Width.Value, null, true).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; } else { showVideoCall = "showVideo('" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), token, 640, null, false).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; } this.Controls.Add(new LiteralControl("<li>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-image\"><a href=\"#\" id=\"" + pid + "\" onclick=\"" + showVideoCall + "\"><img src=\"" + protocol + Configuration.Domain + size.Download + "\" /></a></div>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-meta\">")); this.Controls.Add(new LiteralControl(photo.Title)); this.Controls.Add(new LiteralControl("<p>" + photo.ContentText + "</p>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-date\">" + photo.OriginalDateDate + "</div>")); if (photo.ViewCount != null) { this.Controls.Add(new LiteralControl("<div class=\"visual-list-views\">" + photo.ViewCount.Value.ToString() + " views</div>")); } this.Controls.Add(new LiteralControl("</div>")); this.Controls.Add(new LiteralControl("</li>")); } } this.Controls.Add(new LiteralControl("</ul>")); if (_clickToPlay) { this.Controls.Add(new LiteralControl("<script src=\"/_layouts/23video/23video.js\"></script>")); } } catch (Exception ex) { HandleException(ex); } }
/// <summary> /// Create all your controls here for rendering. /// Try to avoid using the RenderWebPart() method. /// </summary> protected override void CreateChildControls() { try { base.CreateChildControls(); // * Make the query PhotoListParameters listParameters = new PhotoListParameters { AlbumId = null, IncludeUnpublished = false, Size = _count }; if (!String.IsNullOrEmpty(_albumId)) listParameters.AlbumId = Convert.ToInt32(_albumId); switch (_order) { case "CreatedAscending": case "PublishedAscending": case "UploadedAscending": case "ViewsAscending": listParameters.Order = GenericSort.Ascending; break; default: listParameters.Order = GenericSort.Descending; break; } switch (_order) { case "CreatedAscending": case "CreatedDescending": listParameters.OrderBy = PhotoListSort.Created; break; case "UploadedAscending": case "UploadedDescending": listParameters.OrderBy = PhotoListSort.Uploaded; break; case "ViewsAscending": case "ViewsDescending": listParameters.OrderBy = PhotoListSort.Views; break; default: listParameters.OrderBy = PhotoListSort.Published; break; } if ((_tags != null) && (_tags.Count > 0)) { listParameters.TagMode = (_tagMode == "All" ? PhotoTagMode.And : PhotoTagMode.Any); listParameters.Tags = _tags; } this.Controls.Add(new LiteralControl("<table class=\"visual-grid\">")); IApiProvider apiProvider = Utilities.ApiProvider; if (apiProvider != null) { IPhotoService photoService = new PhotoService(apiProvider); List<Domain.Photo> photos = photoService.GetList(listParameters); int rowNumber = 0; int rowCount = (int)Math.Ceiling((decimal)photos.Count / (decimal)_rowCount); int colNumber = 0; foreach (Domain.Photo photo in photos) { string showVideoCall = "showVideo('" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), photo.Token, 640, null).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; if (colNumber == 0) this.Controls.Add(new LiteralControl("<tr" + (rowNumber + 1 == rowCount ? " class=\"last\"" : "") + ">")); this.Controls.Add(new LiteralControl("<td onclick=\"" + showVideoCall + "\"" + ((colNumber == _rowCount - 1) ? " class=\"last\"" : "") + ">")); this.Controls.Add(new LiteralControl("<div class=\"visual-grid-image\"><img src=\"http://" + Configuration.Domain + photo.Small.Download + "\" /></div>")); this.Controls.Add(new LiteralControl("<div class=\"visual-grid-meta\">")); this.Controls.Add(new LiteralControl("<a href=\"#\" onclick=\"" + showVideoCall + "\">" + photo.Title + "</a>")); this.Controls.Add(new LiteralControl("<p>" + photo.ContentText + "</p>")); this.Controls.Add(new LiteralControl("<div class=\"visual-grid-date\">" + photo.OriginalDateDate + "</div>")); if (photo.ViewCount != null) this.Controls.Add(new LiteralControl("<div class=\"visual-grid-views\">" + photo.ViewCount.Value.ToString() + " views</div>")); this.Controls.Add(new LiteralControl("</div>")); this.Controls.Add(new LiteralControl("</td>")); colNumber++; if (colNumber == _rowCount) { this.Controls.Add(new LiteralControl("</tr>")); colNumber = 0; rowNumber++; } } if (colNumber > 0) { while (colNumber < _rowCount) { this.Controls.Add(new LiteralControl("<td class=\"visual-grid-empty\"> </td>")); colNumber++; } this.Controls.Add(new LiteralControl("</tr>")); } } this.Controls.Add(new LiteralControl("</table>")); } catch (Exception ex) { HandleException(ex); } }
/// <summary> /// Create all your controls here for rendering. /// Try to avoid using the RenderWebPart() method. /// </summary> protected override void CreateChildControls() { try { base.CreateChildControls(); // * Make the query PhotoListParameters listParameters = new PhotoListParameters { AlbumId = null, IncludeUnpublished = false, Size = _count }; if (!String.IsNullOrEmpty(_albumId)) { listParameters.AlbumId = Convert.ToInt32(_albumId); } switch (_order) { case "CreatedAscending": case "PublishedAscending": case "UploadedAscending": case "ViewsAscending": listParameters.Order = GenericSort.Ascending; break; default: listParameters.Order = GenericSort.Descending; break; } switch (_order) { case "CreatedAscending": case "CreatedDescending": listParameters.OrderBy = PhotoListSort.Created; break; case "UploadedAscending": case "UploadedDescending": listParameters.OrderBy = PhotoListSort.Uploaded; break; case "ViewsAscending": case "ViewsDescending": listParameters.OrderBy = PhotoListSort.Views; break; default: listParameters.OrderBy = PhotoListSort.Published; break; } if ((_tags != null) && (_tags.Count > 0)) { listParameters.TagMode = (_tagMode == "All" ? PhotoTagMode.And : PhotoTagMode.Any); listParameters.Tags = _tags; } this.Controls.Add(new LiteralControl("<ul class=\"visual-list\">")); IApiProvider apiProvider = Utilities.ApiProvider; if (apiProvider != null) { IPhotoService photoService = new PhotoService(apiProvider); List <Domain.Photo> photos = photoService.GetList(listParameters); foreach (Domain.Photo photo in photos) { string showVideoCall = "showVideo('" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), photo.Token, 640, null).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; this.Controls.Add(new LiteralControl("<li onclick=\"" + showVideoCall + "\">")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-image\"><img src=\"http://" + Configuration.Domain + photo.Small.Download + "\" /></div>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-meta\">")); this.Controls.Add(new LiteralControl("<a href=\"#\" onclick=\"" + showVideoCall + "\">" + photo.Title + "</a>")); this.Controls.Add(new LiteralControl("<p>" + photo.ContentText + "</p>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-date\">" + photo.OriginalDateDate + "</div>")); if (photo.ViewCount != null) { this.Controls.Add(new LiteralControl("<div class=\"visual-list-views\">" + photo.ViewCount.Value.ToString() + " views</div>")); } this.Controls.Add(new LiteralControl("</div>")); this.Controls.Add(new LiteralControl("</li>")); } } this.Controls.Add(new LiteralControl("</ul>")); } catch (Exception ex) { HandleException(ex); } }
/// <summary> /// Create all your controls here for rendering. /// Try to avoid using the RenderWebPart() method. /// </summary> protected override void CreateChildControls() { try { base.CreateChildControls(); // * Make the query PhotoListParameters listParameters = new PhotoListParameters { AlbumId = null, IncludeUnpublished = false, Size = _count }; if (!String.IsNullOrEmpty(_albumInfo)) { string[] albumParams = _albumInfo.Split('|'); listParameters.AlbumId = Convert.ToInt32(albumParams[0]); listParameters.Token = albumParams[1]; } switch (_order) { case "CreatedAscending": case "PublishedAscending": case "UploadedAscending": case "ViewsAscending": listParameters.Order = GenericSort.Ascending; break; default: listParameters.Order = GenericSort.Descending; break; } switch (_order) { case "CreatedAscending": case "CreatedDescending": listParameters.OrderBy = PhotoListSort.Created; break; case "UploadedAscending": case "UploadedDescending": listParameters.OrderBy = PhotoListSort.Uploaded; break; case "ViewsAscending": case "ViewsDescending": listParameters.OrderBy = PhotoListSort.Views; break; default: listParameters.OrderBy = PhotoListSort.Published; break; } if ((_tags != null) && (_tags.Count > 0)) { listParameters.TagMode = (_tagMode == "All" ? PhotoTagMode.And : PhotoTagMode.Any); listParameters.Tags = _tags; } this.Controls.Add(new LiteralControl("<ul class=\"visual-list\">")); IApiProvider apiProvider = Utilities.ApiProvider; if (apiProvider != null) { IPhotoService photoService = new PhotoService(apiProvider); List<Domain.Photo> photos = photoService.GetList(listParameters); string protocol = Configuration.HttpSecure ? "https://" : "http://"; foreach (Domain.Photo photo in photos) { PhotoBlock size = Utilities.GetVideoSize(photo, Size); string pid = "photo" + photo.PhotoId.ToString(); string showVideoCall; // Figure out exact code to put in string token = _tokenFreeEmebds ? "" : photo.Token; if (_clickToPlay) { showVideoCall = "showVideo('" + pid + "','" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), token, size.Width.Value, null, true).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; } else { showVideoCall = "showVideo('" + Utilities.EmbedCode(photo.PhotoId.Value.ToString(), token, 640, null, false).Replace("\"", """).Replace("'", "\\'") + "'); return false;"; } this.Controls.Add(new LiteralControl("<li>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-image\"><a href=\"#\" id=\"" + pid + "\" onclick=\"" + showVideoCall + "\"><img src=\"" + protocol + Configuration.Domain + size.Download + "\" /></a></div>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-meta\">")); this.Controls.Add(new LiteralControl(photo.Title)); this.Controls.Add(new LiteralControl("<p>" + photo.ContentText + "</p>")); this.Controls.Add(new LiteralControl("<div class=\"visual-list-date\">" + photo.OriginalDateDate + "</div>")); if (photo.ViewCount != null) this.Controls.Add(new LiteralControl("<div class=\"visual-list-views\">" + photo.ViewCount.Value.ToString() + " views</div>")); this.Controls.Add(new LiteralControl("</div>")); this.Controls.Add(new LiteralControl("</li>")); } } this.Controls.Add(new LiteralControl("</ul>")); if (_clickToPlay) { this.Controls.Add(new LiteralControl("<script src=\"/_layouts/23video/23video.js\"></script>")); } } catch (Exception ex) { HandleException(ex); } }