Beispiel #1
0
        public override Rss.RssItem[] GetRssFeedItems(CmsPage page, CmsPlaceholderDefinition placeholderDefinition, CmsLanguage langToRenderFor)
        {
            List <Rss.RssItem> ret = new List <Rss.RssItem>();

            UserImageGalleryDb db = (new UserImageGalleryDb());

            UserImageGalleryPlaceholderData placeholderData = db.getUserImageGalleryPlaceholderData(page, placeholderDefinition.Identifier, langToRenderFor, true);
            string imageStorageDir = placeholderData.getImageStorageDirectory(page);

            CmsLocalImageOnDisk[] allResources = CmsLocalImageOnDisk.FetchAllImagesInDirectory(imageStorageDir, UserImageGalleryPlaceholderData.ImageExtensionsToDisplay);

            foreach (CmsLocalImageOnDisk image in allResources)
            {
                Rss.RssItem item  = new Rss.RssItem();
                string      title = image.getImageCaption();
                if (title == "")
                {
                    title = image.FileName;
                }
                item.Title = title;

                Dictionary <string, string> pageParams = new Dictionary <string, string>();
                pageParams.Add(UrlParamName, image.ResourceId.ToString());
                item.Link = new Uri(page.getUrl(pageParams));


                item.Description = renderFullSize(placeholderData, image, page, langToRenderFor);

                ret.Add(item);
            } // foreach


            return(ret.ToArray());
        }
Beispiel #2
0
        public void RenderSelectedItem_InViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            UserImageGalleryDb db   = (new UserImageGalleryDb());
            StringBuilder      html = new StringBuilder();

            UserImageGalleryPlaceholderData placeholderData = db.getUserImageGalleryPlaceholderData(page, identifier, langToRenderFor, true);
            CmsLocalImageOnDisk             currentImage    = getCurrentImageResource();

            CmsLocalImageOnDisk[] allResources = CmsLocalImageOnDisk.FetchAllImagesInDirectory(placeholderData.getImageStorageDirectory(page), UserImageGalleryPlaceholderData.ImageExtensionsToDisplay);

            string action = PageUtils.getFromForm("action_" + currentImage.ResourceId.ToString(), "");

            if (String.Compare(action, "updateCaption", true) == 0)
            {
                string newCaption = PageUtils.getFromForm("caption_" + currentImage.ResourceId.ToString(), "");
                currentImage.setImageCaption(newCaption);
                currentImage.SaveToDatabase();
            }
            else if (String.Compare(action, "deleteImage", true) == 0)
            {
                bool b = CmsLocalImageOnDisk.Delete(currentImage, true);
                html.Append("<div class=\"UserImageGallery\">" + getImageRemovedText(langToRenderFor) + " <a href=\"" + page.Url + "\">" + getReturnToGalleryText(langToRenderFor) + "</a></div>");
                writer.Write(html.ToString());
                return;
            }

            html.Append("<div class=\"UserImageGallery\">");
            html.Append(getSelectedItem_NextPrevLinks(placeholderData, currentImage, allResources, langToRenderFor));
            html.Append(renderFullSize(placeholderData, currentImage, page, langToRenderFor));
            html.Append("</div>");

            writer.Write(html.ToString());
        }
Beispiel #3
0
        public void RenderSelectedItem_InEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            UserImageGalleryDb db   = (new UserImageGalleryDb());
            StringBuilder      html = new StringBuilder();

            UserImageGalleryPlaceholderData placeholderData = db.getUserImageGalleryPlaceholderData(page, identifier, langToRenderFor, true);
            CmsLocalImageOnDisk             currentImage    = getCurrentImageResource();

            html.Append("<div class=\"UserImageGallery\">");
            html.Append(renderFullSize(placeholderData, currentImage, page, langToRenderFor));
            html.Append("</div>");

            writer.Write(html.ToString());
        }
Beispiel #4
0
        public void RenderMultipleItems_InViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            UserImageGalleryDb db   = (new UserImageGalleryDb());
            StringBuilder      html = new StringBuilder();

            UserImageGalleryPlaceholderData placeholderData = db.getUserImageGalleryPlaceholderData(page, identifier, langToRenderFor, true);
            string imageStorageDir = placeholderData.getImageStorageDirectory(page);

            if (!System.IO.Directory.Exists(imageStorageDir))
            {
                bool b = placeholderData.createImageStorageDirectory(page);
                if (!b)
                {
                    if (CmsContext.currentUserIsSuperAdmin)
                    {
                        html.Append("<h1>System Error: could not create image storage directory: '" + imageStorageDir + "'</h1>");
                    }
                    else
                    {
                        html.Append("<h1>System Error: could not create image storage directory!!</h1>");
                    }
                    writer.Write(html.ToString());
                    return;
                }
            }

            CmsLocalImageOnDisk[] allResources = CmsLocalImageOnDisk.FetchAllImagesInDirectory(imageStorageDir, UserImageGalleryPlaceholderData.ImageExtensionsToDisplay);

            if (allResources.Length == 0 && page.currentUserCanWrite)
            {
                CmsLocalImageOnDisk.UpdateFolderInDatabase(new System.IO.DirectoryInfo(imageStorageDir));
                allResources = CmsLocalImageOnDisk.FetchAllImagesInDirectory(imageStorageDir, UserImageGalleryPlaceholderData.ImageExtensionsToDisplay);
            }

            html.Append("<div class=\"UserImageGallery\">");
            html.Append(getGalleryView(placeholderData, allResources, page, langToRenderFor));
            html.Append("</div>");

            if (page.currentUserCanWrite)
            {
                html.Append(getSwfUploadHtml(page, placeholderData, langToRenderFor));
            }

            writer.Write(html.ToString());
        }
Beispiel #5
0
        public void RenderMultipleItems_InEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            UserImageGalleryDb db   = (new UserImageGalleryDb());
            StringBuilder      html = new StringBuilder();

            string phId = "UserGallery_" + page.ID.ToString() + "_" + identifier.ToString() + "_" + langToRenderFor.shortCode + "_";

            UserImageGalleryPlaceholderData placeholderData = db.getUserImageGalleryPlaceholderData(page, identifier, langToRenderFor, true);

            if (PageUtils.getFromForm(phId + "action", "") == "update")
            {
                placeholderData.NumThumbsPerPage          = PageUtils.getFromForm(phId + "NumThumbsPerPage", placeholderData.NumThumbsPerPage);
                placeholderData.NumThumbsPerRow           = PageUtils.getFromForm(phId + "NumThumbsPerRow", placeholderData.NumThumbsPerRow);
                placeholderData.ThumbnailDisplayBoxWidth  = PageUtils.getFromForm(phId + "ThumbnailDisplayBoxWidth", placeholderData.ThumbnailDisplayBoxWidth);
                placeholderData.ThumbnailDisplayBoxHeight = PageUtils.getFromForm(phId + "ThumbnailDisplayBoxHeight", placeholderData.ThumbnailDisplayBoxHeight);
                placeholderData.FullSizeDisplayBoxWidth   = PageUtils.getFromForm(phId + "FullSizeDisplayBoxWidth", placeholderData.FullSizeDisplayBoxWidth);
                placeholderData.FullSizeDisplayBoxHeight  = PageUtils.getFromForm(phId + "FullSizeDisplayBoxHeight", placeholderData.FullSizeDisplayBoxHeight);

                placeholderData.CaptionLocation  = (UserImageGalleryPlaceholderData.CaptionDisplayLocation)PageUtils.getFromForm(phId + "CaptionLocation", typeof(UserImageGalleryPlaceholderData.CaptionDisplayLocation), placeholderData.CaptionLocation);
                placeholderData.FullSizeLinkMode = (UserImageGalleryPlaceholderData.FullSizeImageDisplayMode)PageUtils.getFromForm(phId + "FullSizeLinkMode", typeof(UserImageGalleryPlaceholderData.FullSizeImageDisplayMode), placeholderData.FullSizeLinkMode);

                db.saveUpdatedUserImageGalleryPlaceholderData(page, identifier, langToRenderFor, placeholderData);
            } // if update


            html.Append("<table>");
            html.Append("<tr><td>Num Thumbs Per Page</td><td>" + PageUtils.getInputTextHtml(phId + "NumThumbsPerPage", phId + "NumThumbsPerPage", placeholderData.NumThumbsPerPage.ToString(), 3, 3) + "</td></tr>");
            html.Append("<tr><td>Num Thumbs Per Row</td><td>" + PageUtils.getInputTextHtml(phId + "NumThumbsPerRow", phId + "NumThumbsPerRow", placeholderData.NumThumbsPerRow.ToString(), 3, 3) + "</td></tr>");
            html.Append("<tr><td>Thumbnail Display Box Width</td><td>" + PageUtils.getInputTextHtml(phId + "ThumbnailDisplayBoxWidth", phId + "ThumbnailDisplayBoxWidth", placeholderData.ThumbnailDisplayBoxWidth.ToString(), 3, 3) + "</td></tr>");
            html.Append("<tr><td>Thumbnail Display Box Height</td><td>" + PageUtils.getInputTextHtml(phId + "ThumbnailDisplayBoxHeight", phId + "ThumbnailDisplayBoxHeight", placeholderData.ThumbnailDisplayBoxHeight.ToString(), 3, 3) + "</td></tr>");
            html.Append("<tr><td>Full Size Display Box Width</td><td>" + PageUtils.getInputTextHtml(phId + "FullSizeDisplayBoxWidth", phId + "FullSizeDisplayBoxWidth", placeholderData.FullSizeDisplayBoxWidth.ToString(), 3, 3) + "</td></tr>");
            html.Append("<tr><td>Full Size Display Box Height</td><td>" + PageUtils.getInputTextHtml(phId + "FullSizeDisplayBoxHeight", phId + "FullSizeDisplayBoxHeight", placeholderData.FullSizeDisplayBoxHeight.ToString(), 3, 3) + "</td></tr>");

            html.Append("<tr><td>Caption Location</td><td>" + PageUtils.getDropDownHtml(phId + "CaptionLocation", phId + "CaptionLocation", typeof(UserImageGalleryPlaceholderData.CaptionDisplayLocation), placeholderData.CaptionLocation) + "</td></tr>");
            html.Append("<tr><td>Full Size Link Mode</td><td>" + PageUtils.getDropDownHtml(phId + "FullSizeLinkMode", phId + "FullSizeLinkMode", typeof(UserImageGalleryPlaceholderData.FullSizeImageDisplayMode), placeholderData.FullSizeLinkMode) + "</td></tr>");

            html.Append("</table>");
            html.Append(PageUtils.getHiddenInputHtml(phId + "action", "update"));
            writer.Write(html.ToString());
        }
Beispiel #6
0
        /// <summary>
        /// returns the number of image galleries updated.
        /// </summary>
        /// <returns></returns>
        public static int UpdateDatabaseCacheOfImageInfos()
        {
            // -- Update the CmsLocalImageOnDisk database cache from the disk source.
            int ret = 0;
            UserImageGalleryDb db = (new UserImageGalleryDb());

            UserImageGalleryPlaceholderData[] phs = db.getAllUserImageGalleryPlaceholderDatas();
            foreach (UserImageGalleryPlaceholderData ph in phs)
            {
                CmsPage p = CmsContext.getPageById(ph.PageId);
                if (p.ID >= 0)
                {
                    string dir = ph.getImageStorageDirectory(p);
                    if (dir != String.Empty)
                    {
                        CmsLocalImageOnDisk[] updates = CmsLocalImageOnDisk.UpdateFolderInDatabase(new System.IO.DirectoryInfo(dir));
                        ret++;
                    } // if
                }     // if
            }         // foreach
            return(ret);
        }
Beispiel #7
0
        public override CmsDependency[] getDependencies()
        {
            List <CmsDependency> ret = new List <CmsDependency>();

            try
            {
                ret.Add(new CmsDatabaseTableDependency(@"
                CREATE TABLE  `userimagegallery` (
                  `PageId` int(10) unsigned NOT NULL,
                  `Identifier` int(10) unsigned NOT NULL,
                  `LangCode` varchar(5) NOT NULL,
                  `NumThumbsPerPage` int(10) NOT NULL,
                  `NumThumbsPerRow` int(10) NOT NULL,
                  `ThumbnailDisplayBoxWidth` int(10) NOT NULL,
                  `ThumbnailDisplayBoxHeight` int(10) NOT NULL,
                  `FullSizeDisplayBoxWidth` int(10) NOT NULL,
                  `FullSizeDisplayBoxHeight` int(10) NOT NULL,
                  `FullSizeLinkMode` varchar(255) NOT NULL,
                  `CaptionDisplayLocation` varchar(255) NOT NULL,
                  PRIMARY KEY (`PageId`,`Identifier`,`LangCode`)
                ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
            "));

                ret.AddRange(SWFUploadHelpers.SWFUploadDependencies);

                // -- writable directories
                ret.Add(CmsWritableDirectoryDependency.UnderAppPath("UserFiles/ImageGalleries"));

                // -- each placeholder directory should be writable.
                UserImageGalleryDb db = (new UserImageGalleryDb());
                UserImageGalleryPlaceholderData[] phs = db.getAllUserImageGalleryPlaceholderDatas();
                foreach (UserImageGalleryPlaceholderData ph in phs)
                {
                    CmsPage p = CmsContext.getPageById(ph.PageId);
                    if (p.ID >= 0)
                    {
                        string dir = ph.getImageStorageDirectory(p);
                        if (dir != String.Empty)
                        {
                            ret.Add(new CmsWritableDirectoryDependency(dir));
                            // -- check if the image gallery files on disk are in the database.
                            if (CmsLocalFileOnDisk.FetchAllFilesInDirectory(dir).Length > 0)
                            {
                                foreach (string fn in System.IO.Directory.GetFiles(dir))
                                {
                                    if (!fn.StartsWith(CmsLocalFileOnDisk.DeletedFileFilenamePrefix))
                                    {
                                        ret.Add(new CmsMessageDependency("The UserImageGallery directory '" + dir + "' has files, but are not in the database"));
                                        break;
                                    }
                                } // foreach
                            }
                        }
                    }
                }

                // -- REQUIRED config entries
                ret.Add(new CmsConfigItemDependency("UserImageGallery.PageXofYText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.PrevLinkText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.NextLinkText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.ReturnToGalleryText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.NoImageText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.ImageRemovedText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.SetCaptionButtonText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.RemoveImageButtonText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.SetCaptionButtonText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.RemoveImageButtonText"));
                ret.Add(new CmsConfigItemDependency("UserImageGallery.UploadImageButtonText"));
            }
            catch (Exception ex)
            {
                ret.Add(new CmsMessageDependency("Error gathering UserImageGallery dependencies: " + ex.Message));
            }

            return(ret.ToArray());
        }