public override string Render()
        {
            CmsPage currentPage = CmsContext.currentPage;
            string  searchText  = PageUtils.getFromForm("AuditSearch", "");

            searchText = searchText.Trim();

            StringBuilder html = new StringBuilder();

            // -- start query form
            string formId = "searchImageCaptions";

            html.Append(currentPage.getFormStartHtml(formId));
            html.Append("<strong>Search Image Captions: </strong> ");
            html.Append(PageUtils.getInputTextHtml("AuditSearch", "AuditSearch", searchText, 40, 1024));
            html.Append("<input type=\"submit\" value=\"search\">");
            html.Append(PageUtils.getHiddenInputHtml("AdminTool", GetType().Name));
            html.Append(currentPage.getFormCloseHtml(formId));

            if (searchText != "")
            {
                Dictionary <int, CmsPage> allPages = CmsContext.HomePage.getLinearizedPages();
                List <CmsPage>            pages    = new List <CmsPage>(allPages.Values);

                SingleImageDb          db       = new SingleImageDb();
                List <SingleImageData> imgDatas = new List <SingleImageData>();
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    imgDatas.AddRange(db.getSingleImages(pages.ToArray(), lang));
                }

                html.Append("<p><strong>Images containing \"" + searchText + "\":</strong></p>");
                html.Append("<table border=\"1\">");
                html.Append("<tr><th>Image</th><th>Page Link</th></tr>");
                foreach (SingleImageData img in imgDatas)
                {
                    if (img.Caption.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) > -1 ||
                        img.Credits.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) > -1)
                    {
                        html.Append("<tr>");
                        html.Append("<td>");
                        html.Append(SingleImageHtmlDisplay(img));
                        html.Append("</td>");
                        CmsPage targetPage = CmsContext.getPageById(img.PageId);
                        html.Append("<td><a target=\"_blank\" href=\"" + targetPage.getUrl(CmsUrlFormat.FullIncludingProtocolAndDomainName) + "\">" + targetPage.Title + "</a></td>");
                        html.Append("</tr>");
                    } // if
                }     // foreach
                html.Append("</table>");
            }

            return(html.ToString());
        }
        public override string Render()
        {
            Dictionary <int, CmsPage> allPages = CmsContext.HomePage.getLinearizedPages();
            StringBuilder             html     = new StringBuilder();

            html.Append("<p><strong>Page - Image Summary</strong></p>");
            html.Append(TABLE_START_HTML);
            html.Append("<tr><th>Page</th><th>Images</th></tr>");
            SingleImageDb db = new SingleImageDb();

            foreach (int pageId in allPages.Keys)
            {
                CmsPage targetPage = allPages[pageId];
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    html.Append("<tr>");
                    html.Append("<td><a href=\"" + targetPage.getUrl(CmsUrlFormat.FullIncludingProtocolAndDomainName) + "\" target=\"_blank\">" + targetPage.Path + "</a> (\"" + targetPage.Title + "\")</td>");
                    html.Append("<td><table border=\"0\">");
                    SingleImageData[] pageImages = db.getSingleImages(new CmsPage[] { targetPage }, lang);
                    if (pageImages.Length > 0)
                    {
                        foreach (SingleImageData imgData in pageImages)
                        {
                            string thumbUrl = CmsContext.UserInterface.ShowThumbnailPage.getThumbDisplayUrl(imgData.ImagePath, 150, 150);
                            html.Append("<tr><td><img src=\"" + thumbUrl + "\"><br />Caption: " + imgData.Caption + "<br />Source:" + imgData.Credits + "<br />Path: " + imgData.ImagePath + "</td></tr>");
                        } // foreach
                    }
                    else
                    {
                        html.Append("<tr><td><em>Page doesn't have any images...</em></td></tr>");
                    }


                    html.Append("</table></td>");
                    html.Append("<tr>");
                } // foreach language
            }     // foreach page
            html.Append("</table>");
            return(html.ToString());
        } // Render
Example #3
0
        public override string Render()
        {
            Dictionary <int, CmsPage> allPages = CmsContext.HomePage.getLinearizedPages();

            SingleImageDb db = new SingleImageDb();

            List <PageImages> pageImages = new List <PageImages>();

            foreach (int pageId in allPages.Keys)
            {
                CmsPage pageToTest = allPages[pageId];
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    SingleImageData[] imgDataArr = db.getSingleImages(new CmsPage[] { allPages[pageId] }, lang);
                    PageImages        pi         = new PageImages(pageToTest, lang, imgDataArr);
                    pageImages.Add(pi);
                }
            }

            Dictionary <string, List <PageLanguage> > duplicates = new Dictionary <string, List <PageLanguage> >();

            foreach (PageImages pi in pageImages)
            {
                foreach (SingleImageData img in pi.Images)
                {
                    PageLanguage[] matchingPages = PageImages.GetMatchingPagesForImage(img, pageImages.ToArray());
                    if (matchingPages.Length > 1)
                    {
                        if (!duplicates.ContainsKey(img.ImagePath))
                        {
                            duplicates[img.ImagePath] = new List <PageLanguage>();
                        }

                        duplicates[img.ImagePath].AddRange(matchingPages);
                    }
                }
            }

            // -- remove duplicate PageLanguage items
            Dictionary <string, List <PageLanguage> > toReport = new Dictionary <string, List <PageLanguage> >();

            foreach (string imgPath in duplicates.Keys)
            {
                toReport[imgPath] = PageLanguage.RemoveDuplicates(duplicates[imgPath]);
            } // foreach


            // -- display results

            StringBuilder html = new StringBuilder();

            html.Append("<p><strong>Duplicate images used on this site:</strong></p>");
            html.Append(TABLE_START_HTML);
            html.Append("<tr><th>Image</th><th>Found on pages</th></tr>");
            if (toReport.Keys.Count > 0)
            {
                foreach (string imgPath in toReport.Keys)
                {
                    html.Append("<tr>");
                    string thumbUrl = CmsContext.UserInterface.ShowThumbnailPage.getThumbDisplayUrl(imgPath, 150, 150);
                    html.Append("<td><img src=\"" + thumbUrl + "\"><br />" + imgPath + "</td>");
                    html.Append("<td>");
                    html.Append("<ul>");
                    foreach (PageLanguage targetPage in toReport[imgPath])
                    {
                        html.Append("<li><a href=\"" + targetPage.Page.getUrl(CmsUrlFormat.FullIncludingProtocolAndDomainName, targetPage.Language) + "\" target=\"_blank\">" + targetPage.Page.getTitle(targetPage.Language) + " (" + targetPage.Language.shortCode + ") </li>");
                    }
                    html.Append("</ul>");
                    html.Append("</td>");
                    html.Append("</tr>");
                } // foreach
            }
            else
            {
                html.Append("<tr><td><em>No duplicate images found</em></td></tr>");
            }
            html.Append("</table>");

            return(html.ToString());
        }
        public override string Render()
        {
            StringBuilder html = new StringBuilder();

            html.Append("<p>The following images are missing captions:");

            Dictionary <int, CmsPage> allPages             = CmsContext.HomePage.getLinearizedPages();
            List <CmsPage>            pagesToGetImagesFrom = new List <CmsPage>();

            foreach (int pageId in allPages.Keys)
            {
                pagesToGetImagesFrom.Add(allPages[pageId]);
            }
            SingleImageDb          singleImageDb = new SingleImageDb();
            List <SingleImageData> imageDatas    = new List <SingleImageData>();

            foreach (CmsLanguage lang in CmsConfig.Languages)
            {
                imageDatas.AddRange(singleImageDb.getSingleImages(pagesToGetImagesFrom.ToArray(), lang));
            }

            List <SingleImageData> imageDatasWithoutCaptions = new List <SingleImageData>();

            foreach (SingleImageData img in imageDatas)
            {
                if (img.ImagePath.Trim() != "" && img.Caption.Trim() == "")
                {
                    imageDatasWithoutCaptions.Add(img);
                }
            }

            if (imageDatasWithoutCaptions.Count < 1)
            {
                html.Append("<br><strong>No images are missing captions! (" + imageDatas.Count.ToString() + " images audited)</strong>");
            }
            else
            {
                html.Append("<br>" + imageDatasWithoutCaptions.Count.ToString() + " images are missing captions (" + imageDatas.Count.ToString() + " images audited)");
                html.Append(TABLE_START_HTML + Environment.NewLine);
                html.Append("<tr><th>Image</th><th>On Page</th></tr>");
                foreach (SingleImageData img in imageDatasWithoutCaptions)
                {
                    html.Append("<tr>");
                    html.Append("<td>" + SingleImageHtmlDisplay(img) + "</td>");
                    html.Append("<td>");
                    CmsPage containingPage = img.getPageContainingImage(pagesToGetImagesFrom.ToArray());
                    if (containingPage != null)
                    {
                        html.Append("<a target=\"_blank\" href=\"" + containingPage.Url + "\">" + containingPage.Path + "</a>");
                    }
                    else
                    {
                        html.Append("Invalid page found!!");
                    }

                    html.Append("</td>");
                    html.Append("</tr>" + Environment.NewLine);
                }
                html.Append("</table>" + Environment.NewLine);
            }


            html.Append("</p>");

            return(html.ToString());
        }