Exemple #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());
        }
Exemple #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());
        }
        protected override void Render(HtmlTextWriter writer)
        {
            CmsLanguage   lang               = CmsContext.currentLanguage;
            string        imgText            = CmsConfig.getConfigValue("UserImageGallery.ImageText", "Number of images", lang);
            string        noGalleryText      = CmsConfig.getConfigValue("UserImageGallery.NoGalleryText", "No image galleries are currently available", lang);
            CmsPage       galleryPage        = CmsContext.currentPage;
            int           numGalleriesOutput = 0;
            StringBuilder html               = new StringBuilder();

            CmsPage[] sortedPages = CmsPage.SortPagesBySortOrdinal(galleryPage.ChildPages);
            for (int i = sortedPages.Length - 1; i >= 0; i--)
            {
                CmsPage g = sortedPages[i];
                if (true) // g.showInMenu
                {
                    UserImageGalleryDb db = new UserImageGalleryDb();
                    UserImageGalleryPlaceholderData data = new UserImageGalleryPlaceholderData();
                    data = db.getUserImageGalleryPlaceholderData(g, 1, CmsContext.currentLanguage, true);

                    string dirOnDiskToView = data.getImageStorageDirectory(g);

                    if (Directory.Exists(dirOnDiskToView))
                    {
                        DirectoryInfo di = new DirectoryInfo(dirOnDiskToView);

                        int update = Hatfield.Web.Portal.PageUtils.getFromForm("update", 0);
                        if (update == 1 && g.currentUserCanWrite)
                        {
                            CmsLocalImageOnDisk[] updates = CmsLocalImageOnDisk.UpdateFolderInDatabase(di);
                        }

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

                        if (allResources.Length >= 1)
                        {
                            numGalleriesOutput++;

                            string thumbUrl = showThumbPage.getThumbDisplayUrl(allResources[0], 100, 100);;
                            html.Append("<tr><td><a href=\"" + g.Url + "\"><img border=\"0\" src=\"" + thumbUrl + "\"></a></td><td><a href=\"" + g.Url + "\">" + g.Title + "</a><br />(" + allResources.Length + " images)</td></tr>");
                        }
                    }
                }
            } // foreach

            if (numGalleriesOutput > 0)
            {
                writer.Write("<table cellspacing=\"10\">");
                writer.Write(html.ToString());

                writer.Write("</table>");
            }
            else
            {
                writer.Write("<em>" + noGalleryText + "</em>");
            }
        }
Exemple #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());
        }