Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser    = Request.QueryString["CurrentUser"];
            CurrentPhotoId = Request.QueryString["photo_id"];
            if (string.IsNullOrEmpty(CurrentUser) || string.IsNullOrEmpty(CurrentPhotoId))
            {
                photoalbum.Visible = false;
                Response.Write("<p width='100%' align='center'>\"This page requires specific parameters and can only be reached from a Album Detail page\"</p>");
                return;
            }

            this.currPageItem   = Sitecore.Context.Item;
            XslFile1.Parameters = String.Format(CultureInfo.CurrentCulture, "username={0}", CurrentUser);
            this.currPhoto      = PhotoAlbumObject.RestoreItemFromQueryString(CurrentPhotoId);

            this.ImagesContent.InnerHtml = this.BuildImagesHtml(this.currPhoto);
            this.albumInst = new PhotoAlbumObject(null)
            {
                CurrentAlbumItem = (Item)HttpContext.Current.Session["CurrentAlbum"]
            };
            // Generate album view link
            this.ReturnToAlbumLink.HRef = PhotoAlbumObject.GetItemPath(Sitecore.Configuration.Settings.GetSetting("detailAlbumPageID")) + "?CurrentAlbum=" + this.albumInst.CurrentAlbumItem.ID.ToString() + "&CurrentUser=" + CurrentUser;
            this.ShowReviews();

            this.HideReviewFormForOwner();

            if (PhotoRateClicked())
            {
                this.PostReview();
                Response.Redirect(Request.RawUrl);
            }
            EditZoomPicture();
        }
        private void MAdapterOnItemClick(object sender, PhotosAdapterClickEventArgs e)
        {
            try
            {
                PhotoAlbumObject item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    var index = ImageData.PhotoAlbum.IndexOf(item);
                    //var intent = new Intent(this, typeof(ImagePostViewerActivity));
                    //intent.PutExtra("itemIndex", index.ToString()); //PhotoAlbumObject
                    //intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(ImageData)); // PostDataObject
                    //StartActivity(intent);

                    var intent = new Intent(this, typeof(MultiImagesPostViewerActivity));
                    intent.PutExtra("indexImage", index.ToString());                        // Index Image Show
                    intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(ImageData)); // PostDataObject
                    OverridePendingTransition(Resource.Animation.abc_popup_enter, Resource.Animation.popup_exit);
                    StartActivity(intent);
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Example #3
0
        /// <summary>
        /// Handles the Create N upload_ click event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void CreateNUpload_Click(object sender, EventArgs e)
        {
            var album = new PhotoAlbumObject(AlbumName.Text.TrimEnd(' '));

            ErrMsg.Visible = false;
            if (AlbumName.Text.TrimEnd(' ').Length >= 20)
            {
                ErrMsg.Text    = "The length of album name has to be less then 20 characters.";
                ErrMsg.Visible = true;
            }
            else
            {
                if (!album.CreatePhotoAlbumItem(AlbumName.Text.TrimEnd(' '), string.Empty))
                {
                    if (!string.IsNullOrEmpty(album.PageErrorMsg))
                    {
                        ErrMsg.Text    = album.PageErrorMsg;
                        ErrMsg.Visible = true;
                    }
                    // check message property in class and show this message on registration page
                }
                else
                {
                    FeedHelper.CreateUserAlbumsFeed(album.CurrentAlbumItem);
                    FeedHelper.CreateAlbumFeed(album.CurrentAlbumItem);
                    // redirect to upload page
                    PhotoAlbumObject.RedirectToAlbumPage(Sitecore.Configuration.Settings.GetSetting("uploadPhotosPageItemID"), album.CurrentAlbumItem.ID.ToString());
                }
            }
        }
Example #4
0
        /// <summary>
        /// Posts the review.
        /// </summary>
        private void PostReview()
        {
            string s1             = PhotoAlbumReviewHelper.SafeRequest("photo_rate_title");
            string s2             = PhotoAlbumReviewHelper.SafeRequest("photo_rate_text");
            string s3             = PhotoAlbumReviewHelper.SafeRequest("photo_rate_rate");
            Item   photoForRating = this.currPhoto;// this.paginator.GetPageItems()[0];

            if (photoForRating != null)
            {
                PhotoAlbumObject.AddPhotoRatingComment(s1, s2, s3, photoForRating);
                PhotoAlbumHelper.AddPhotoToSessionNonRateable(photoForRating.ID.ToString(), Request.QueryString["CurrentUser"]);//this.albumInst.CurrUserName);
            }
            // Triger goal Rate Photo
            //  AnalyticsTrackerHelper.TriggerEvent("Rate photos", "Photo was rated", string.Empty, string.Empty, "CurrentPage");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text        = Translate.Text("Album");
            Label2.Text        = Translate.Text("Upload");
            SelectNUpload.Text = Translate.Text("Upload");

            currPageItem = Sitecore.Context.Item;

            if (!Page.IsPostBack)
            {
                // If query string variable CurrentAlbum is set then copy it to session
                if (Request.QueryString["CurrentAlbum"] != null)
                {
                    System.Web.HttpContext.Current.Session["CurrentAlbum"] = PhotoAlbumObject.RestoreItemFromQueryString(Request.QueryString["CurrentAlbum"]);
                }
                _albumInst = new PhotoAlbumObject(null);
                if (_albumInst.CurrentPhotoAlbumFolder != null)
                {
                    ChildList albums        = _albumInst.CurrentPhotoAlbumFolder.Children;
                    var       lstUserAlbums = new List <UserAlbum>();
                    foreach (Item alb in albums.InnerChildren)
                    {
                        if (alb.Name != "AlbumsListFeed")
                        {
                            lstUserAlbums.Add(new UserAlbum {
                                Id = alb.ID, Name = alb.Name
                            });
                        }
                    }
                    if (albums != null)
                    {
                        AlbumsList.DataSource     = lstUserAlbums;
                        AlbumsList.DataTextField  = "Name";
                        AlbumsList.DataValueField = "ID";
                        AlbumsList.DataBind();
                        if (Request.QueryString["CurrentAlbum"] != null)
                        {
                            AlbumsList.SelectedValue = Request.QueryString["CurrentAlbum"];
                        }
                        if (_albumInst.CurrentAlbumItem != null)
                        {
                            AlbumsList.SelectedValue = _albumInst.CurrentAlbumItem.Name;
                        }
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Posts the review.
        /// </summary>
        /// <param name="albumForRating">The album for rating.</param>
        private void PostReview(Item albumForRating)
        {
            string s1 = PhotoAlbumReviewHelper.SafeRequest("photo_rate_title");
            string s2 = PhotoAlbumReviewHelper.SafeRequest("photo_rate_text");
            string s3 = PhotoAlbumReviewHelper.SafeRequest("photo_rate_rate");

            if (albumForRating != null)
            {
                PhotoAlbumObject.AddPhotoRatingComment(s1, s2, s3, albumForRating);

                // register session when user already rated image
                PhotoAlbumHelper.AddPhotoToSessionNonRateable(albumForRating.ID.ToString(), this.albumInst.CurrUserName);
            }

            // Triger goal Rate Photo
            //AnalyticsTrackerHelper.TriggerEvent("Rate photos", "Album was rated", string.Empty, string.Empty, "CurrentPage");
        }
Example #7
0
        /// <summary>
        /// Generates the first photo HTML.
        /// </summary>
        /// <param name="item">The source item.</param>
        /// <returns>The first photo HTML.</returns>
        private string GenerateFirstPhotoHtml(Item item)
        {
            const string Template = @"
      <a href='{0}'><img class='img-shadow' width='230px' src='{1}'></a>
      <div class='title'>{2}</div>
      <div class='slideshow'><a href='{3}'>{4}</a></div>
      <div class='sub'>{5}</div>";

            var bigPhotoLink = GetPhotoPageLink(item);
            var bigPhotoSrc  = GetPhotoSrc(item, 230);
            var count        = this.album.GetAlbumPhotos().Count();
            var countText    = count == 1 ? string.Format(CultureInfo.InvariantCulture, "{0} photo", count) : string.Format(CultureInfo.InvariantCulture, "{0} photos", count);
            var viewSlider   = PhotoAlbumObject.GetItemPath(Sitecore.Configuration.Settings.GetSetting("albumSliderPageItemID")) + "?CurrentAlbum=" + this.album.CurrentAlbumItem.ID + "&CurrentUser="******"View Slideshow", countText);

            return(result);
        }
Example #8
0
        /// <summary>
        /// Generates the data source.
        /// </summary>
        /// <param name="album">The album.</param>
        /// <returns>The data source.</returns>
        private static DataTable GenerateDataSource(PhotoAlbumObject album)
        {
            var table = new DataTable("Thumbnails");

            table.Columns.Add("link");
            table.Columns.Add("srcLink");

            var images = album.GetAlbumPhotos();

            foreach (var item in images)
            {
                //  const string Template = @"/Photo_album/Custom/View_Album.aspx?CurrentAlbum={0}&CurrentPhoto={1}";

                const string Template = @"{0}?CurrentAlbum={1}&CurrentPhoto={2}&CurrentUser={3}";
                var          link     = string.Format(CultureInfo.InvariantCulture, Template, PhotoAlbumObject.GetItemPath(Sitecore.Configuration.Settings.GetSetting("detailAlbumPageID")),
                                                      album.CurrentAlbumItem.ID, item.ID, CurrentUser);
                var srcLink = GetPhotoSrc(item, 80);

                table.Rows.Add(link, srcLink);
            }

            return(table);
        }
Example #9
0
        private void MAdapterOnItemClick(object sender, PhotosAdapterClickEventArgs e)
        {
            try
            {
                PhotoAlbumObject item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    var index = ImageData.PhotoAlbum.IndexOf(item);
                    //var intent = new Intent(this, typeof(ImagePostViewerActivity));
                    //intent.PutExtra("itemIndex", index.ToString()); //PhotoAlbumObject
                    //intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(ImageData)); // PostDataObject
                    //StartActivity(intent);

                    var intent = new Intent(this, typeof(MultiImagesPostViewerActivity));
                    intent.PutExtra("indexImage", index.ToString());                        // Index Image Show
                    intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(ImageData)); // PostDataObject
                    StartActivity(intent);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        /// <summary>
        /// Handles the Select N upload_ click event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SelectNUpload_Click(object sender, EventArgs e)
        {
            // base.Request.Files
            _albumInst       = new PhotoAlbumObject(AlbumsList.SelectedItem.Text);
            ErrorMsg.Visible = false;

            if (!_albumInst.UploadNCreate(FileUpload1, Request.Files, AlbumsList.SelectedValue) && !string.IsNullOrEmpty(_albumInst.PageErrorMsg))
            {
                ErrorMsg.Text    = _albumInst.PageErrorMsg;
                ErrorMsg.Visible = true;
            }
            else
            {
                /*  var albumUrl = @"/Photo_album/Custom/View_Album.aspx?CurrentAlbum=" + _albumInst.CurrentAlbumItem.ID;
                 * var uriString = string.Format(CultureInfo.InvariantCulture, @"http://{0}/{1}", Request.Url.Host, albumUrl);
                 * var shortener = new UrlShortener.BusinessLayer.GoogleUrlShortener();
                 * var shortUri = shortener.ShortenUrl(new Uri(uriString));
                 * var sharableEvent = new SharableEvent(Sitecore.Context.User, SharableEventType.PhotoUploaded, SharingTarget.All, shortUri, Request.Files[0].FileName);
                 * EventsDispatcher.ProcessEvent(sharableEvent);*/

                // Tracking Goal Upload photos
                // AnalyticsTrackerHelper.TriggerEvent("Upload photos", "User has uploaded photos", string.Empty, string.Empty, "CurrentPage");
            }
        }
Example #11
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            CurrentUser  = Request.QueryString["CurrentUser"];
            CurrentAlbum = Request.QueryString["CurrentAlbum"];

            if (string.IsNullOrEmpty(CurrentUser) || string.IsNullOrEmpty(CurrentAlbum))
            {
                photoalbum.Visible = false;
                Response.Write("<p width='100%' align='center'>\"This page requires specific parameters and can only be reached from a All Albums or My Albums pages\"</p>");
                return;
            }

            System.Web.HttpContext.Current.Session["CurrentAlbum"] = PhotoAlbumObject.RestoreItemFromQueryString(CurrentAlbum);
            System.Web.HttpContext.Current.Session["CurrentUser"]  = CurrentUser;
            this.album = new PhotoAlbumObject("new Album");
            this.album.CurrentAlbumItem = PhotoAlbumObject.RestoreItemFromQueryString(Request.QueryString["CurrentAlbum"]);
            var thumbnailsDataSource = GenerateDataSource(this.album);
            var pagePosition         = 0;
            var i = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["CurrentPhoto"]))
            {
                foreach (var p in this.album.GetAlbumPhotos())
                {
                    if (string.Equals(p.ID.ToString(), Request.QueryString["CurrentPhoto"].ToString()))
                    {
                        pagePosition = i / photosInPage;
                    }
                    i++;
                }
                if (!string.Equals(preSelectPhoto, Request.QueryString["CurrentPhoto"].ToString()))
                {
                    preSelectPhoto = Request.QueryString["CurrentPhoto"];
                    dpPhotoAlbum.SetPageProperties(pagePosition * photosInPage, photosInPage, true);
                }
            }

            if (thumbnailsDataSource.Rows.Count <= photosInPage)
            {
                dpPhotoAlbum.Visible = false;
            }

            this.ThumbnailsRepeater.DataSource = thumbnailsDataSource;
            this.ThumbnailsRepeater.DataBind();

            var currentPhotoId   = Request.QueryString["CurrentPhoto"];
            var currentPhotoItem = !string.IsNullOrEmpty(currentPhotoId) ? Sitecore.Context.Database.GetItem(currentPhotoId) : this.album.GetAlbumPhotos().FirstOrDefault();

            if (currentPhotoItem != null)
            {
                this.BigPhoto.Text = this.GenerateFirstPhotoHtml(currentPhotoItem);
            }

            this.albumInst = new PhotoAlbumObject(null);
            var albumItm = PhotoAlbumObject.RestoreItemFromQueryString(Request.QueryString["CurrentAlbum"]);

            this.ShowReviews(albumItm);
            this.HideReviewFormForOwner(albumItm);

            if (Page.IsPostBack)
            {
                if (PhotoRateClicked())
                {
                    this.PostReview(albumItm);
                    Response.Redirect(Request.RawUrl);
                }
            }

            XslFile1.Parameters = String.Format(CultureInfo.CurrentCulture, "username={0}", CurrentUser);
        }
Example #12
0
        /// <summary>
        /// Gets the photo page link.
        /// </summary>
        /// <param name="item">The photo item.</param>
        /// <returns>The photo page link.</returns>
        private static string GetPhotoPageLink(Item item)
        {
            var link = PhotoAlbumObject.GetItemPath(Sitecore.Configuration.Settings.GetSetting("detailPhotoPageItemID")) + "?photo_id=" + item.ID + "&CurrentUser=" + CurrentUser;

            return(link);
        }