public void OutputPageLinks() { bool forcePageSearch = true; StringBuilder html = new StringBuilder(); Dictionary <int, CmsPage> allPages = CmsContext.HomePage.getLinearizedPages(); if (!forcePageSearch && !DoPageSearch) { html.Append("<p><a onclick=\"document.getElementById('spinnerImg').display='block'; return true;\" href=\"DeleteResourcePopup.aspx?DoPageSearch=true&FileUrl=" + FileUrl + "\">Search entire site (" + allPages.Keys.Count + " pages) for this link</a> (slow!)"); html.Append(" <img style=\"display: none\" id=\"spinnerImg\" src=\"" + CmsContext.ApplicationPath + "images/_system/ajax-loader_16x16.gif\">"); html.Append("</p>"); } else { int numPagesFound = 0; html.Append("<strong>This link has been found on the following pages:</strong>"); html.Append("<ul>"); foreach (CmsPage pageToSearch in allPages.Values) { foreach (CmsLanguage lang in CmsConfig.Languages) { string[] linksToFind = new string[] { FileUrl }; string phContent = pageToSearch.renderAllPlaceholdersToString(lang, CmsPage.RenderPlaceholderFilterAction.RunAllPageAndPlaceholderFilters); string[] linksInPage = ContentUtils.FindFileLinksInHtml(phContent, linksToFind); if (linksInPage.Length > 0) { numPagesFound++; html.Append("<li><a href=\"" + pageToSearch.getUrl(CmsUrlFormat.FullIncludingProtocolAndDomainName, lang) + "\" target=\"_blank\">" + pageToSearch.getTitle(lang) + "</a> (" + pageToSearch.getPath(lang) + ")</li>" + Environment.NewLine); } } // foreach language } // foreach page html.Append("</ul>"); if (numPagesFound == 0) { html.Append("<p><strong>" + allPages.Keys.Count + " pages have been searched, and this link has not been found</strong></p>"); } else { html.Append("<p><strong>" + allPages.Keys.Count + " pages have been searched, and this link has been found on " + numPagesFound + " pages</strong></p>"); } } Response.Write(html.ToString()); }
private List <string> removeUrlsUsedOnPage(CmsPage pageToScan, CmsLanguage pageLanguageToScan, List <string> allUrlsToVerify) { string[] linksToFind = allUrlsToVerify.ToArray(); string pageHtml = pageToScan.renderAllPlaceholdersToString(pageLanguageToScan, CmsPage.RenderPlaceholderFilterAction.RunAllPageAndPlaceholderFilters); string[] foundLinks = ContentUtils.FindFileLinksInHtml(pageHtml, linksToFind); if (foundLinks.Length > 0) { foreach (string url in foundLinks) { allUrlsToVerify.Remove(url); } // foreach } return(allUrlsToVerify); }