Beispiel #1
0
        public static void ProcessImage(GalleryImage galleryImage, IFileSystem fileSystem, string virtualRoot, string originalFileName, Color backgroundColor)
        {
            string originalPath = virtualRoot + "FullSizeImages/" + galleryImage.ImageFile;
            string webSizeImagePath = virtualRoot + "WebImages/" + galleryImage.WebImageFile;
            string thumbnailPath = virtualRoot + "Thumbnails/" + galleryImage.ThumbnailFile;

            using (Stream stream = fileSystem.GetAsStream(originalPath))
            {
                using (Bitmap originalImage = new Bitmap(stream))
                {
                    SetExifData(galleryImage, originalImage, originalFileName);
                }
            }

            fileSystem.CopyFile(originalPath, webSizeImagePath, true);

            mojoPortal.Web.ImageHelper.ResizeImage(
                webSizeImagePath,
                IOHelper.GetMimeType(Path.GetExtension(webSizeImagePath)),
                galleryImage.WebImageWidth,
                galleryImage.WebImageHeight,
                backgroundColor);

            fileSystem.CopyFile(originalPath, thumbnailPath, true);

            mojoPortal.Web.ImageHelper.ResizeImage(
                thumbnailPath,
                IOHelper.GetMimeType(Path.GetExtension(thumbnailPath)),
                galleryImage.ThumbNailWidth,
                galleryImage.ThumbNailHeight,
                backgroundColor);
        }
Beispiel #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if(moduleId > -1)
            {
                if(itemId > -1)
                {
                    GalleryImage galleryImage = new GalleryImage(moduleId, itemId);
                    if (galleryImage.ModuleId != moduleId)
                    {
                        SiteUtils.RedirectToAccessDeniedPage(this);
                        return;
                    }

                    galleryImage.ContentChanged += new ContentChangedEventHandler(galleryImage_ContentChanged);

                    GalleryHelper.DeleteImages(galleryImage, fileSystem, imageFolderPath);
                    galleryImage.Delete();
                    CurrentPage.UpdateLastModifiedTime();
                    CacheHelper.ClearModuleCache(moduleId);
                    SiteUtils.QueueIndexing();

                }
            }

            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
Beispiel #3
0
        public static void DeleteImages(GalleryImage image, IFileSystem fileSystem, string virtualRoot)
        {
            string imageVirtualPath = virtualRoot + "FullSizeImages/" + image.ImageFile;

            fileSystem.DeleteFile(imageVirtualPath);

            imageVirtualPath = virtualRoot + "WebImages/" + image.WebImageFile;

            fileSystem.DeleteFile(imageVirtualPath);

            imageVirtualPath = virtualRoot + "Thumbnails/" + image.ThumbnailFile;

            fileSystem.DeleteFile(imageVirtualPath);
        }
        public void InstallContent(Module module, string configInfo)
        {
            if (string.IsNullOrEmpty(configInfo)) { return; }

            string basePath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/media/";

            if (!Directory.Exists(HostingEnvironment.MapPath(basePath)))
            {
                Directory.CreateDirectory(HostingEnvironment.MapPath(basePath));
            }

            basePath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/media/GalleryImages/";

            if (!Directory.Exists(HostingEnvironment.MapPath(basePath)))
            {
                Directory.CreateDirectory(HostingEnvironment.MapPath(basePath));
            }

            basePath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/media/GalleryImages/" + module.ModuleId.ToInvariantString() + "/";

            if (!Directory.Exists(HostingEnvironment.MapPath(basePath)))
            {
                Directory.CreateDirectory(HostingEnvironment.MapPath(basePath));
            }

            IOHelper.CopyFolderContents(HostingEnvironment.MapPath(configInfo), HostingEnvironment.MapPath(basePath));

            basePath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/media/GalleryImages/" + module.ModuleId.ToInvariantString() + "/FullSizeImages/";

            string[] files = Directory.GetFiles(HostingEnvironment.MapPath(basePath));
            foreach (string file in files)
            {
                GalleryImage img = new GalleryImage();
                img.ModuleGuid = module.ModuleGuid;
                img.ModuleId = module.ModuleId;
                img.ImageFile = Path.GetFileName(file);
                img.ThumbnailFile = img.ImageFile;
                img.WebImageFile = img.ImageFile;
                img.Save();
            }
        }
Beispiel #5
0
        private static void SetExifData(GalleryImage galleryImage, Bitmap originalImage, string filePath)
        {
            XmlDocument metaData = new XmlDocument();
            if (metaData.DocumentElement == null)
            {
                metaData.AppendChild(metaData.CreateElement("MetaData"));
            }

            mojoPortal.Web.ImageHelper.SetMetadata("ImageFile", galleryImage.ImageFile, metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("WebImageFile", galleryImage.WebImageFile, metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("ThumbnailFile", galleryImage.ThumbnailFile, metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("Caption", galleryImage.Caption, metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("Description", galleryImage.Description, metaData);

            mojoPortal.Web.ImageHelper.SetMetadata("OriginalFilename", filePath, metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("WebImageWidth", galleryImage.WebImageWidth.ToInvariantString(), metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("WebImageHeight", galleryImage.WebImageHeight.ToInvariantString(), metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("ThumbNailWidth", galleryImage.ThumbNailWidth.ToInvariantString(), metaData);
            mojoPortal.Web.ImageHelper.SetMetadata("ThumbNailHeight", galleryImage.ThumbNailHeight.ToInvariantString(), metaData);

            try
            {
                mojoPortal.Web.ImageHelper.SetExifInformation(originalImage, metaData);
            }
            catch(Exception ex)
            {
                log.Error(ex);
            }

            galleryImage.MetaDataXml = metaData.OuterXml;

            //if (mojoPortal.Web.ImageHelper.GetMetadata("GPSLatitude", metaData).Length > 0)
            //{

            //}

            //if (mojoPortal.Web.ImageHelper.GetMetadata("GPSLongitude", metaData).Length > 0)
            //{

            //}

            //if (mojoPortal.Web.ImageHelper.GetMetadata("GPSAltitude", metaData).Length > 0)
            //{

            //}

            galleryImage.Save();
        }
        void btnUpload_Click(object sender, EventArgs e)
        {
            // as long as javascript is available this code should never execute
            // because the standard file input ir replaced by javascript and the file upload happens
            // at the service url /ImageGallery/upload.ashx
            // this is fallback implementation

            Module module = GetModule(moduleId, Gallery.FeatureGuid);

            if (module == null)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            try
            {

                if (uploader.HasFile)
                {

                    string ext = Path.GetExtension(uploader.FileName);
                    if (SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        GalleryImage galleryImage = new GalleryImage(this.moduleId);
                        galleryImage.ModuleGuid = module.ModuleGuid;
                        galleryImage.WebImageHeight = config.WebSizeHeight;
                        galleryImage.WebImageWidth = config.WebSizeWidth;
                        galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                        galleryImage.ThumbNailWidth = config.ThumbnailWidth;
                        galleryImage.UploadUser = Context.User.Identity.Name;

                        if (siteUser != null) galleryImage.UserGuid = siteUser.UserGuid;

                        //string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                        string newFileName = Path.GetFileName(uploader.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 = uploader.FileContent)
                        {
                            //fileSystem.SaveFile(newImagePath, s, uploader.FileContentType, true);
                            fileSystem.SaveFile(newImagePath, s, IOHelper.GetMimeType(Path.GetExtension(ext).ToLower()), true);
                        }

                        galleryImage.ImageFile = newFileName;
                        galleryImage.WebImageFile = newFileName;
                        galleryImage.ThumbnailFile = newFileName;
                        galleryImage.Save();
                        GalleryHelper.ProcessImage(galleryImage, fileSystem, imageFolderPath, uploader.FileName, config.ResizeBackgroundColor);
                    }

                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());

            }
            catch (UnauthorizedAccessException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (ArgumentException ex)
            {
                lblError.Text = ex.Message;
            }
        }
Beispiel #7
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());
        }
Beispiel #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid) return;

            GalleryImage galleryImage;
            if (moduleId > -1)
            {
                if (itemId > -1)
                {
                    galleryImage = new GalleryImage(moduleId, itemId);
                }
                else
                {
                    galleryImage = new GalleryImage(moduleId);
                }

                if (galleryImage.ModuleId != moduleId)
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                Module module = GetModule(moduleId, Gallery.FeatureGuid);
                galleryImage.ModuleGuid = module.ModuleGuid;

                galleryImage.ContentChanged += new ContentChangedEventHandler(galleryImage_ContentChanged);

                int displayOrder;
                if (!Int32.TryParse(txtDisplayOrder.Text, out displayOrder))
                {
                    displayOrder = -1;
                }

                if (displayOrder > -1)
                {
                    galleryImage.DisplayOrder = displayOrder;
                }

                galleryImage.WebImageHeight = config.WebSizeHeight;
                galleryImage.WebImageWidth = config.WebSizeWidth;
                galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                galleryImage.ThumbNailWidth = config.ThumbnailWidth;
                galleryImage.Description = edDescription.Text;
                galleryImage.Caption = txtCaption.Text;
                galleryImage.UploadUser = Context.User.Identity.Name;
                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                if (siteUser != null) galleryImage.UserGuid = siteUser.UserGuid;

                // as long as javascript is available this code should never execute
                // because the standard file input ir replaced by javascript and the file upload happens
                // at the service url /ImageGallery/upload.ashx
                // this is fallback implementation

                if (uploader.HasFile)
                {
                    string ext = Path.GetExtension(uploader.FileName);
                    if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        lblMessage.Text = GalleryResources.InvalidFile;

                        return;
                    }

                    string newFileName = Path.GetFileName(uploader.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);

                    if (galleryImage.ItemId > -1)
                    {
                        //updating with a new image so delete the previous version
                        GalleryHelper.DeleteImages(galleryImage, fileSystem, imageFolderPath);

                    }

                    //using (Stream s = flImage.FileContent)
                    //{
                    //    fileSystem.SaveFile(newImagePath, s, flImage.ContentType, true);
                    //}
                    using (Stream s = uploader.FileContent)
                    {

                        fileSystem.SaveFile(newImagePath, s, IOHelper.GetMimeType(Path.GetExtension(ext).ToLower()), true);
                    }

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

                    CurrentPage.UpdateLastModifiedTime();
                    CacheHelper.ClearModuleCache(moduleId);

                    SiteUtils.QueueIndexing();
                    if (hdnReturnUrl.Value.Length > 0)
                    {
                        WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                        return;
                    }

                }
                else // not hasfile
                {	//updating a previously uploaded image
                    if (itemId > -1)
                    {
                        if (galleryImage.Save())
                        {
                            CurrentPage.UpdateLastModifiedTime();
                            CacheHelper.ClearModuleCache(moduleId);
                            SiteUtils.QueueIndexing();
                            if (newItem)
                            {
                                string thisUrl = SiteRoot + "/ImageGallery/EditImage.aspx?pageid="
                                    + pageId.ToInvariantString()
                                    + "&mid=" + moduleId.ToInvariantString()
                                    + "&ItemID=" + galleryImage.ItemId.ToInvariantString();

                                WebUtils.SetupRedirect(this, thisUrl);
                                return;

                            }
                            else
                            {
                                if (hdnReturnUrl.Value.Length > 0)
                                {
                                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                                    return;
                                }

                                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                            }

                        }
                    }
                }
            }
        }
Beispiel #9
0
        private void PopulateControls()
        {
            if(moduleId > -1)
            {
                if(itemId > -1)
                {
                    GalleryImage galleryImage = new GalleryImage(moduleId, itemId);

                    if (galleryImage.ModuleId != moduleId)
                    {
                        SiteUtils.RedirectToAccessDeniedPage(this);
                        return;
                    }

                    txtCaption.Text = Server.HtmlDecode(galleryImage.Caption);
                    edDescription.Text = galleryImage.Description;
                    txtDisplayOrder.Text = galleryImage.DisplayOrder.ToString();
                    imgThumb.Src = fileSystem.FileBaseUrl + thumbnailBaseUrl + galleryImage.ThumbnailFile;

                }

            }
        }
        private void ShowImage()
        {
            if (moduleId == -1) { return; }

            Gallery gallery = new Gallery(moduleId);
            DataTable dt = gallery.GetWebImageByPage(pageNumber);

            if (dt.Rows.Count > 0)
            {
                itemId = Convert.ToInt32(dt.Rows[0]["ItemID"]);
                totalPages = Convert.ToInt32(dt.Rows[0]["TotalPages"]);
            }

            showTechnicalData = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GalleryShowTechnicalDataSetting", false);

            if (itemId == -1) { return; }

            Literal topPageLinks = new Literal();
            string pageUrl = SiteRoot
                + "/ImageGallery/GalleryBrowse.aspx?"
                + "pageid=" + pageId.ToInvariantString()
                + "&amp;mid=" + moduleId.ToInvariantString()
                + "&amp;pagenumber=";

            topPageLinks.Text = UIHelper.GetPagerLinksWithPrevNext(
                pageUrl,1,
                this.totalPages,
                this.pageNumber,
                "modulepager",
                "SelectedPage");

            this.spnTopPager.Controls.Add(topPageLinks);

            GalleryImage galleryImage = new GalleryImage(moduleId, itemId);

            imageLink.Text = "<a onclick=\"window.open(this.href,'_blank');return false;\"  href='" + ImageSiteRoot
                + fullSizeBaseUrl + galleryImage.ImageFile + "' ><img  src='"
                + ImageSiteRoot + webSizeBaseUrl
                + galleryImage.WebImageFile + "' alt='"
                + Resources.GalleryResources.GalleryWebImageAltText + "' /></a>";

            this.pnlGallery.Controls.Add(imageLink);
            this.lblCaption.Text = Server.HtmlEncode(galleryImage.Caption);
            this.lblDescription.Text = galleryImage.Description;

            if(showTechnicalData)
            {
                if(galleryImage.MetaDataXml.Length > 0)
                {
                    xmlMeta.DocumentContent = galleryImage.MetaDataXml;
                    string xslPath = System.Web.HttpContext.Current.Server.MapPath(SiteRoot + "/ImageGallery/GalleryMetaData.xsl");
                    xmlMeta.TransformSource = xslPath;
                }
            }
        }
Beispiel #11
0
        private void BindImage()
        {
            if (!UseCompactMode) { return; }
            if (itemId == -1) { return; }

            imageLink = new Literal();

            GalleryImage galleryImage = new GalleryImage(ModuleId, itemId);

            imageLink.Text = "<a onclick=\"window.open(this.href,'_blank');return false;\"  "
                + " title=\"" + Server.HtmlEncode(GalleryResources.GalleryWebImageAltText).HtmlEscapeQuotes()
                + "\" href=\"" + imageBaseUrl
                + Page.ResolveUrl(fullSizeBaseUrl
                + galleryImage.ImageFile) + "\" ><img src=\""
                + Page.ResolveUrl(webSizeBaseUrl
                + galleryImage.WebImageFile) + "\" alt=\""
                + Server.HtmlEncode(GalleryResources.GalleryWebImageAltText).HtmlEscapeQuotes() + "\" /></a>";

            pnlGallery.Controls.Clear();
            pnlGallery.Controls.Add(imageLink);
            lblCaption.Text = Page.Server.HtmlEncode(galleryImage.Caption);
            lblDescription.Text = galleryImage.Description;

            if ((config.ShowTechnicalData) && (galleryImage.MetaDataXml.Length > 0))
            {
                xmlMeta.DocumentContent = galleryImage.MetaDataXml;
                string xslPath = HttpContext.Current.Server.MapPath(WebUtils.GetApplicationRoot() + "/ImageGallery/GalleryMetaData.xsl");
                xmlMeta.TransformSource = xslPath;

            }
        }
        private static void IndexItem(GalleryImage galleryImage)
        {
            if (WebConfigSettings.DisableSearchIndex) { return; }
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            if ((siteSettings == null)
                    || (galleryImage == null))
            {
                return;
            }

            Guid galleryFeatureGuid = new Guid("d572f6b4-d0ed-465d-ad60-60433893b401");
            ModuleDefinition galleryFeature = new ModuleDefinition(galleryFeatureGuid);
            Module module = new Module(galleryImage.ModuleId);

            // get list of pages where this module is published
            List<PageModule> pageModules
                = PageModule.GetPageModulesByModule(galleryImage.ModuleId);

            foreach (PageModule pageModule in pageModules)
            {
                PageSettings pageSettings
                = new PageSettings(
                siteSettings.SiteId,
                pageModule.PageId);

                //don't index pending/unpublished pages
                if (pageSettings.IsPending) { continue; }

                mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem();
                indexItem.SiteId = siteSettings.SiteId;
                indexItem.PageId = pageSettings.PageId;
                indexItem.PageName = pageSettings.PageName;
                indexItem.ViewRoles = pageSettings.AuthorizedRoles;
                indexItem.ModuleViewRoles = module.ViewRoles;
                indexItem.FeatureId = galleryFeatureGuid.ToString();
                indexItem.FeatureName = galleryFeature.FeatureName;
                indexItem.FeatureResourceFile = galleryFeature.ResourceFile;
                indexItem.CreatedUtc = galleryImage.UploadDate;
                indexItem.LastModUtc = galleryImage.UploadDate;

                indexItem.ItemId = galleryImage.ItemId;
                indexItem.ModuleId = galleryImage.ModuleId;

                indexItem.QueryStringAddendum = "&ItemID"
                    + galleryImage.ModuleId.ToString()
                    + "=" + galleryImage.ItemId.ToString();

                indexItem.ModuleTitle = module.ModuleTitle;
                indexItem.Title = galleryImage.Caption;
                indexItem.Content = galleryImage.Description;
                indexItem.PublishBeginDate = pageModule.PublishBeginDate;
                indexItem.PublishEndDate = pageModule.PublishEndDate;

                mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem);

                if (debugLog) log.Debug("Indexed " + galleryImage.Caption);
            }
        }