@Override
 public void applyBtnAction() {
   cmsPageRevision.saveDetails();
 }
 public PlaceholderContent getPlaceholderContent() {
   return cmsPageRevision.getPlaceholderContent(getCphName());
 }
 public void setPageById(String id) {
   long lid = Long.parseLong(id);
   cmsPageRevision = (CmsPageRevision) new BeanDao(CmsPageRevision.class).get(lid);
   cmsPageRevision.addToScope();
 }
 public ContentPlaceholderType getCphType() {
   return cmsPageRevision.getPlaceholderContent(getCphName()).getCphType();
 }
示例#5
0
  public void generateSiteMap(File file) {
    List<CmsPage> cmsPages = new BeanDao(CmsPage.class).getAll();
    StringBuffer sitemapStrBuf = new StringBuffer();
    sitemapStrBuf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    sitemapStrBuf.append("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
    CmsPageRevision tempCmsPageRevision;
    removeUnusedPages(cmsPages, getUnusedMenu().getChildren());
    removeUnusedPages(cmsPages, getErrorMenu().getChildren());
    for (int i = 0, n = cmsPages.size(); i < n; i++) {
      tempCmsPageRevision = cmsPages.get(i).getLatestRevision();
      if (tempCmsPageRevision != null && cmsPages.get(i).getClass().equals(CmsPage.class)) {
        sitemapStrBuf.append("<url>");
        sitemapStrBuf.append("<loc>");
        CmsPageUrl cmsPageUrl = new CmsPageUrl(cmsPages.get(i));
        cmsPageUrl.setHost(this);
        sitemapStrBuf.append(cmsPageUrl.toString());
        sitemapStrBuf.append("</loc>");
        sitemapStrBuf.append("<lastmod>");
        sitemapStrBuf.append(FormatUtil.formatDateForDB(tempCmsPageRevision.getDateLastModified()));
        sitemapStrBuf.append("</lastmod>");
        sitemapStrBuf.append("<priority>");
        sitemapStrBuf.append(cmsPages.get(i).getSiteMapPriority());
        sitemapStrBuf.append("</priority>");
        sitemapStrBuf.append("</url>");

        for (CmsAtom tempCmsAtom : tempCmsPageRevision.getCmsAtomList()) {
          if (tempCmsAtom instanceof BasicCmsContentAtom) {
            addBasicCmsContentUrls(
                sitemapStrBuf,
                (BasicCmsContentFeDmb)
                    ((BasicCmsContentAtom) tempCmsAtom).getFrontendModuleBacking(),
                tempCmsPageRevision);
          }
        }
      }
    }

    List<BlogEntry> blogEntryList = new BeanDao(BlogEntry.class).getAll();
    for (int i = 0, n = blogEntryList.size(); i < n; i++) {
      sitemapStrBuf.append("<url>");
      sitemapStrBuf.append("<loc>");
      sitemapStrBuf.append(
          StringEscapeUtils.escapeXml(
              BlogFeDmb.getBlogEntryUrl(
                  blogEntryList.get(i), CmsConfiguration.getCmsConfiguration().getBlogCpr())));
      sitemapStrBuf.append("</loc>");
      sitemapStrBuf.append("<lastmod>");
      sitemapStrBuf.append(FormatUtil.formatDateForDB(blogEntryList.get(i).getDateLastModified()));
      sitemapStrBuf.append("</lastmod>");
      sitemapStrBuf.append("</url>");
    }

    sitemapStrBuf.append("</urlset>");

    try {
      file.createNewFile();
      FileWriter writer = new FileWriter(file);
      writer.write(sitemapStrBuf.toString());
      writer.flush();
      writer.close();
    } catch (IOException ioex) {
      ApplicationUtil.handleError(ioex);
    }
  }