private void rptPhotos_ItemDataBound(object sender, RepeaterItemEventArgs e) { Photo photo = (Photo)e.Item.DataItem; Literal litDateModified = e.Item.FindControl("litDateModified") as Literal; if (litDateModified != null) { litDateModified.Text = TimeZoneUtil.AdjustDateToUserTimeZone(photo.DateModified, User.Identity).ToString(); } HyperLink hplEdit = e.Item.FindControl("hpledit") as HyperLink; if (hplEdit != null) { hplEdit.NavigateUrl = String.Format("~/Modules/Gallery/AdminPhoto.aspx{0}&AlbumId={1}&PhotoId={2}", GetBaseQueryString(), photo.Album.Id, photo.Id); } Literal litThumb = e.Item.FindControl("litThumb") as Literal; if (litThumb != null) { litThumb.Text = "<img"; litThumb.Text += " src=\"" + base.Page.ResolveUrl( _galleryModule.VirtualPath( _galleryModule.PathBuilder.GetThumbPath(photo))) + "\""; // half sized thumbs the dirty way litThumb.Text += " width=\"" + Convert.ToInt16(photo.ThumbWidth / 2) + "\""; litThumb.Text += " height=\"" + Convert.ToInt16(photo.ThumbHeight / 2) + "\""; litThumb.Text += " />"; } }
private void Page_Load(object sender, EventArgs e) { this._galleryModule = base.Module as GalleryModule; _albumService = _galleryModule.GetAlbumService(); _photoService = _galleryModule.GetPhotoService(); if (Request.QueryString["AlbumId"] != null) { this._albumId = Int32.Parse(Request.QueryString["AlbumId"]); } if (Request.QueryString["PhotoId"] != null) { this._photoId = Int32.Parse(Request.QueryString["PhotoId"]); } if (this._photoId > 0) { this._photo = _photoService.GetPhotoById(this._photoId); if (!this.IsPostBack) { BindPhoto(); } imThumb.ImageUrl = base.Page.ResolveUrl( _galleryModule.VirtualPath( _galleryModule.PathBuilder.GetThumbPath(_photo))); this.btnDelete.Visible = true; this.btnDelete.Attributes.Add("onclick", "return confirm('Are you sure?');"); } else { // It is possible that a new file is already uploaded and in the database. The // tempPhotoId parameter in the viewstate should indicate this. if (ViewState["tempPhotoId"] != null) { int tempPhotoId = (int)ViewState["tempPhotoId"]; this._photo = _photoService.GetPhotoById(tempPhotoId); } else { // New file. this._photo = new Photo(); } this.btnDelete.Visible = false; this.imThumb.Visible = false; } }
private void PhotoDetailsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } Photo photo = e.Item.DataItem as Photo; if (photo == null) { return; } Literal litImage = e.Item.FindControl("litImage") as Literal; if (litImage != null) { litImage.Text = "<img"; litImage.Text += " src=\"" + base.Page.ResolveUrl( base.GalleryModule.VirtualPath( base.GalleryModule.PathBuilder.GetPath(photo))) + "\""; litImage.Text += " width=\"" + photo.ImageWidth + "\""; litImage.Text += " height=\"" + photo.ImageHeight + "\""; litImage.Text += " alt=\"" + photo.Size + " " + base.GetText("strBytes") + "\""; litImage.Text += " class=\"photo_198\""; litImage.Text += " style=\"border:4px solid white\""; litImage.Text += " />"; } litTitle = e.Item.FindControl("litTitle") as Literal; if (litTitle != null) { litTitle.Text = photo.DisplayTitle; litTitle.Text += " (" + Convert.ToString(CurrentPage + 1) + '/' + _photolist.Count + ")"; } using (HyperLink hplDownload = e.Item.FindControl("hplDownload") as HyperLink) { if (hplDownload != null) { hplDownload.NavigateUrl = base.Page.ResolveUrl(GalleryModule.VirtualPath(GalleryModule.PathBuilder.GetPhotoOriginPath(photo))); } } base.PhotoService.IncreaseNrOfViews(photo); }
protected void PhotoDataList_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Photo photo = (Photo)e.Item.DataItem; string vieuwUrl = UrlHelper.GetUrlFromSection(GalleryModule.Section) + "/" + photo.Album.Id + "/" + photo.Id; HyperLink hplFile = (HyperLink)e.Item.FindControl("hplFile"); hplFile.NavigateUrl = vieuwUrl; if (!(Page is PageEngine)) { hplFile.Target = "_blank"; } Literal litImage = (Literal)e.Item.FindControl("litImage"); litImage.Text = "<img"; litImage.Text += " src=\"" + base.Page.ResolveUrl( GalleryModule.VirtualPath( GalleryModule.PathBuilder.GetThumbPath(photo))) + "\""; litImage.Text += " width=\"" + photo.ThumbWidth + "\""; litImage.Text += " height=\"" + photo.ThumbHeight + "\""; litImage.Text += " alt=\"" + photo.Title + "\""; litImage.Text += " />"; Literal litImageLabel = (Literal)e.Item.FindControl("litImageLabel"); litImageLabel.Text = photo.DisplayTitle; // only add number of views if configuration is set to show it if (GalleryModule.AlbumSettings.ShowNumberOfViews) { // no point showing it when there's no views if (photo.NrOfViews > 0) { litImageLabel.Text += " (" + photo.NrOfViews + base.GetText("strViews") + ")"; } } } }
public string GetXmlPath() { return(Page.ResolveUrl(_galleryModule.VirtualPath(GetXmlPath(_album)))); }