Example #1
0
        private void LoadSettings()
        {
            appRoot = WebUtils.GetApplicationRoot();

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new GalleryConfiguration(moduleSettings);

            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            //if (WebConfigSettings.ImageGalleryUseMediaFolder)
            //{
            imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/";

            thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            //}
            //else
            //{
            //    imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/";

            //    thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            //}

            fullSizeImageFolderPath = VirtualPathUtility.Combine(imageFolderPath, "FullSizeImages/");

            edDescription.WebEditor.ToolBar = ToolBar.Full;

            AddClassToBody("galleryeditimage");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                return;
            }

            fileSystem = p.GetFileSystem();

            GalleryHelper.VerifyGalleryFolders(fileSystem, imageFolderPath);

            uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(SiteUtils.ImageFileExtensions());

            uploader.ServiceUrl = SiteRoot + "/ImageGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                                  + "&mid=" + moduleId.ToInvariantString()
                                  + "&ItemID=" + itemId.ToInvariantString();
            // itemid will be returned into this field
            uploader.ReturnValueFormFieldClientId = hdnState.ClientID;

            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { $('#" + btnUpdate.ClientID + "').click(); } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);
        }
        private void LoadSettings()
        {
            moduleSettings        = ModuleSettings.GetModuleSettings(moduleId);
            config                = new GalleryConfiguration(moduleSettings);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }
            else
            {
                imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }

            fullSizeImageFolderPath = imageFolderPath + "FullSizeImages/";

            AddClassToBody("gallerybulkupload");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                return;
            }

            fileSystem = p.GetFileSystem();

            GalleryHelper.VerifyGalleryFolders(fileSystem, imageFolderPath);

            uploader.MaxFilesAllowed      = GalleryConfiguration.MaxFilesToUploadAtOnce;
            uploader.AcceptFileTypes      = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(WebConfigSettings.ImageFileExtensions);
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl           = SiteRoot + "/ImageGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                                            + "&mid=" + moduleId.ToInvariantString();
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { window.location.href = '" + SiteUtils.GetCurrentPageUrl() + "'; } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);
        }
Example #3
0
        private void LoadSettings()
        {
            gallery = new mojoPortal.Business.Gallery(ModuleId);
            try
            {
                // this keeps the action from changing during ajax postback in folder based sites
                SiteUtils.SetFormAction(Page, Request.RawUrl);
            }
            catch (MissingMethodException)
            {
                //this method was introduced in .NET 3.5 SP1
            }

            Title1.EditUrl  = SiteRoot + "/ImageGallery/EditImage.aspx";
            Title1.EditText = GalleryResources.GalleryAddImageLabel;
            Title1.Visible  = !this.RenderInWebPartMode;


            config = new GalleryConfiguration(Settings);

            if (IsEditable)
            {
                Title1.LiteralExtraMarkup = "&nbsp;<a href='"
                                            + SiteRoot
                                            + "/ImageGallery/BulkUpload.aspx?pageid=" + PageId.ToInvariantString()
                                            + "&amp;mid=" + ModuleId.ToInvariantString()
                                            + "' class='ModuleEditLink' title='" + GalleryResources.BulkUploadLink + "'>" + GalleryResources.BulkUploadLink + "</a>";
            }

            if (this.ModuleConfiguration != null)
            {
                Title       = this.ModuleConfiguration.ModuleTitle;
                Description = this.ModuleConfiguration.FeatureName;
            }

            UseSilverlightSlideshow = config.UseSlideShow;


            if (config.CustomCssClass.Length > 0)
            {
                pnlOuterWrap.SetOrAppendCss(config.CustomCssClass);
            }

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                baseUrl = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }
            else
            {
                baseUrl = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }

            thumnailBaseUrl = baseUrl + "Thumbnails/";
            webSizeBaseUrl  = baseUrl + "WebImages/";
            fullSizeBaseUrl = baseUrl + "FullSizeImages/";

            imageFolderPath = HttpContext.Current.Server.MapPath(baseUrl);
            thumbsPerPage   = config.ThumbsPerPage;
            UseCompactMode  = config.UseCompactMode;

            if (RenderInWebPartMode)
            {
                UseCompactMode          = false;
                UseSilverlightSlideshow = false;
                thumbsPerPage           = 6;
            }

            if (UseCompactMode)
            {
                UseLightboxMode         = false;
                pnlImageDetails.Visible = false;
            }
            else
            {
                UseLightboxMode            = true;
                useViewState               = false;
                rptGallery.EnableViewState = false;
            }

            if (UseLightboxMode)
            {
                mojoBasePage basePage = Page as mojoBasePage;
                if (basePage != null)
                {
                    basePage.ScriptConfig.IncludeColorBox = true;
                    basePage.ScriptConfig.IncludeImageFit = false; // this seems needed for win7 phone
                }
            }

            imageBaseUrl = ImageSiteRoot;

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                return;
            }

            fileSystem = p.GetFileSystem();
            if (fileSystem != null)
            {
                imageBaseUrl = fileSystem.FileBaseUrl;
            }
        }
Example #4
0
        private void LoadSettings()
        {
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config = new GalleryConfiguration(moduleSettings);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }
            else
            {
                imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/";
            }

            fullSizeImageFolderPath = imageFolderPath + "FullSizeImages/";

            AddClassToBody("gallerybulkupload");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];
            if (p == null) { return; }

            fileSystem = p.GetFileSystem();

            GalleryHelper.VerifyGalleryFolders(fileSystem, imageFolderPath);

            uploader.MaxFilesAllowed = GalleryConfiguration.MaxFilesToUploadAtOnce;
            uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(SiteUtils.ImageFileExtensions());
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl = SiteRoot + "/ImageGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString() ;
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                    + " () { window.location.href = '" + SiteUtils.GetCurrentPageUrl() + "'; } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, Gallery.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (FileSystem == null)
            {
                log.Info("FileSystem is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > GalleryConfiguration.MaxFilesToUploadAtOnce)
            {
                log.Info("Posted File Count is higher than allowed so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, Gallery.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId);

            //if (Request.Form.Count > 0)
            //{
            //    string submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post
            //    log.Info("submitted data: " + submittedContent);
            //}

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);
            config = new GalleryConfiguration(moduleSettings);

            string imageFolderPath;
            string fullSizeImageFolderPath;
            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                imageFolderPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/media/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }
            else
            {
                imageFolderPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }

            fullSizeImageFolderPath = imageFolderPath + "FullSizeImages/";
            string thumbnailPath = imageFolderPath + "Thumbnails/";

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List<UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            for (int f = 0; f < Request.Files.Count; f++)
            {
                HttpPostedFile file = Request.Files[f];

                string ext = Path.GetExtension(file.FileName);
                if (SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                {
                    GalleryImage galleryImage;

                    if((itemId > -1)&&(Request.Files.Count == 1))
                    {
                        galleryImage = new GalleryImage(ModuleId, itemId);
                    }
                    else
                    {
                        galleryImage = new GalleryImage(ModuleId);
                    }

                    galleryImage.ModuleGuid = module.ModuleGuid;
                    galleryImage.WebImageHeight = config.WebSizeHeight;
                    galleryImage.WebImageWidth = config.WebSizeWidth;
                    galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                    galleryImage.ThumbNailWidth = config.ThumbnailWidth;
                    galleryImage.UploadUser = CurrentUser.Name;

                    galleryImage.UserGuid = CurrentUser.UserGuid;

                    string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                    string newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);

                    if (galleryImage.ImageFile == newFileName)
                    {
                        // an existing gallery image delete the old one
                        FileSystem.DeleteFile(newImagePath);
                    }
                    else
                    {
                        // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                        int i = 1;
                        while (FileSystem.FileExists(VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName)))
                        {
                            newFileName = i.ToInvariantString() + newFileName;
                            i += 1;
                        }

                    }

                    newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);

                    using (Stream s = file.InputStream)
                    {
                        FileSystem.SaveFile(newImagePath, s, file.ContentType, true);
                    }

                    galleryImage.ImageFile = newFileName;
                    galleryImage.WebImageFile = newFileName;
                    galleryImage.ThumbnailFile = newFileName;
                    galleryImage.Save();
                    GalleryHelper.ProcessImage(galleryImage, FileSystem, imageFolderPath, file.FileName, config.ResizeBackgroundColor);

                    r.Add(new UploadFilesResult()
                    {
                        Thumbnail_url = WebUtils.ResolveServerUrl(thumbnailPath + newFileName),
                        Name = newFileName,
                        Length = file.ContentLength,
                        Type = file.ContentType,
                        ReturnValue = galleryImage.ItemId.ToInvariantString()
                    });

                }

            }

            var uploadedFiles = new
            {
                files = r.ToArray()
            };
            var jsonObj = js.Serialize(uploadedFiles);
            context.Response.Write(jsonObj.ToString());
        }
Example #6
0
        private void LoadSettings()
        {
            appRoot = WebUtils.GetApplicationRoot();

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config = new GalleryConfiguration(moduleSettings);

            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            //if (WebConfigSettings.ImageGalleryUseMediaFolder)
            //{
                imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/";

                thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            //}
            //else
            //{
            //    imageFolderPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/";

            //    thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            //}

            fullSizeImageFolderPath = VirtualPathUtility.Combine(imageFolderPath, "FullSizeImages/");

            edDescription.WebEditor.ToolBar = ToolBar.Full;

            AddClassToBody("galleryeditimage");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];
            if (p == null) { return; }

            fileSystem = p.GetFileSystem();

            GalleryHelper.VerifyGalleryFolders(fileSystem, imageFolderPath);

            uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(SiteUtils.ImageFileExtensions());

            uploader.ServiceUrl = SiteRoot + "/ImageGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString()
                + "&ItemID=" + itemId.ToInvariantString();
            // itemid will be returned into this field
            uploader.ReturnValueFormFieldClientId = hdnState.ClientID;

            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                    + " () { $('#" + btnUpdate.ClientID + "').click(); } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);
        }
Example #7
0
        private void LoadSettings()
        {
            gallery = new mojoPortal.Business.Gallery(ModuleId);
            try
            {
                // this keeps the action from changing during ajax postback in folder based sites
                SiteUtils.SetFormAction(Page, Request.RawUrl);
            }
            catch (MissingMethodException)
            {
                //this method was introduced in .NET 3.5 SP1
            }

            Title1.EditUrl = SiteRoot + "/ImageGallery/EditImage.aspx";
            Title1.EditText = GalleryResources.GalleryAddImageLabel;
            Title1.Visible = !this.RenderInWebPartMode;

            config = new GalleryConfiguration(Settings);

            if (IsEditable)
            {
                Title1.LiteralExtraMarkup = "&nbsp;<a href='"
                        + SiteRoot
                        + "/ImageGallery/BulkUpload.aspx?pageid=" + PageId.ToInvariantString()
                        + "&amp;mid=" + ModuleId.ToInvariantString()
                        + "' class='ModuleEditLink' title='" + GalleryResources.BulkUploadLink + "'>" + GalleryResources.BulkUploadLink + "</a>";
            }

            if (this.ModuleConfiguration != null)
            {
                Title = this.ModuleConfiguration.ModuleTitle;
                Description = this.ModuleConfiguration.FeatureName;
            }

            UseSilverlightSlideshow = config.UseSlideShow;

            if (config.CustomCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.CustomCssClass); }

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                baseUrl = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }
            else
            {
                baseUrl = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }

            thumnailBaseUrl = baseUrl + "Thumbnails/";
            webSizeBaseUrl = baseUrl + "WebImages/";
            fullSizeBaseUrl = baseUrl + "FullSizeImages/";

            imageFolderPath = HttpContext.Current.Server.MapPath(baseUrl);
            thumbsPerPage = config.ThumbsPerPage;
            UseCompactMode = config.UseCompactMode;

            if (RenderInWebPartMode)
            {
                UseCompactMode = false;
                UseSilverlightSlideshow = false;
                thumbsPerPage = 6;
            }

            if (UseCompactMode)
            {
                UseLightboxMode = false;
                pnlImageDetails.Visible = false;
            }
            else
            {
                UseLightboxMode = true;
                useViewState = false;
                rptGallery.EnableViewState = false;
            }

            if (UseLightboxMode)
            {
                mojoBasePage basePage = Page as mojoBasePage;
                if (basePage != null)
                {
                    basePage.ScriptConfig.IncludeColorBox = true;
                    basePage.ScriptConfig.IncludeImageFit = false; // this seems needed for win7 phone
                }
            }

            imageBaseUrl = ImageSiteRoot;

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];
            if (p == null) { return; }

            fileSystem = p.GetFileSystem();
            if (fileSystem != null) { imageBaseUrl = fileSystem.FileBaseUrl; }
        }