protected void Page_Load(object sender, EventArgs e)
        {
            _galleryModule = Module as GalleryModule;
            if (_galleryModule == null)
            {
                _galleryModule = _moduleLoader.GetModuleFromClassName("CMS.Modules.Gallery.GalleryModule") as GalleryModule;
            }
            _albumService = _galleryModule.GetAlbumService();
            _photoService = _galleryModule.GetPhotoService();

            if (Module != null)
            {
                btnCancel.Attributes.Add("onclick",
                                         String.Format("document.location.href='AdminGallery.aspx{0}'",
                                                       GetBaseQueryString()));
                btnMassImport.Click += btnMassImport_Click;

                if (Request.QueryString["AlbumId"] == null)
                {
                    return;
                }

                int albumId = Int32.Parse(Request.QueryString["AlbumId"]);

                if (albumId == 0 || albumId == -1)
                {
                    return;
                }

                _album = _albumService.GetAlbumById(albumId);

                if (!IsPostBack)
                {
                    BindAlbum();
                }

                btnDelete.Visible = true;
                btnDelete.Attributes.Add("onclick", "return confirm('Are you sure?');");

                if (!IsPostBack)
                {
                    DisplayFastImportPanel();
                }

                if (_album.Id > 0)
                {
                    FileUploaderAJAXPhotos.Visible = true;
                }
                else
                {
                    FileUploaderAJAXPhotos.Visible = false;
                }
                Session["GalleryPath"] = _galleryModule.PathBuilder.GetAlbumVirtualDirectory(_album.Id);
            }

            if (FileUploaderAJAXPhotos.IsPosting && Session["GalleryPath"] != null)
            {
                FileHelper.ManageAjaxPost(FileUploaderAJAXPhotos, 2000, Session["GalleryPath"] + "\\ToImport", HttpPostedFileAJAX.fileType.image, false, false);
            }
        }
        private void Page_Load(object sender, EventArgs e)
        {
            // The base page has already created the module, we only have to cast it here to the right type.
            _galleryModule = Module as GalleryModule;

            _photoService = _galleryModule.GetPhotoService();

            if (Request.QueryString["AlbumId"] != null)
            {
                _albumid = Int32.Parse(Request.QueryString["AlbumId"]);
            }

            if (_albumid > 0)
            {
                btnNew.Attributes.Add("onclick",
                                      String.Format(
                                          "document.location.href='AdminPhoto.aspx{0}&AlbumId={1}&PhotoId=-1'",
                                          GetBaseQueryString(), _albumid));

                if (!IsPostBack)
                {
                    BindFiles();
                }
            }
        }
예제 #3
0
        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;
            }
        }