Пример #1
0
 /**
  * Create sitemap index
  *
  * @return  string
  */
 public function sitemapIndex()
 {
     $pageLimit = 10000;
     if (isset($this->tsSetup['pageLimit']) && $this->tsSetup['pageLimit'] != '') {
         $pageLimit = (int) $this->tsSetup['pageLimit'];
     }
     $sitemaps = array();
     $pageItems = count($this->sitemapPages);
     $pageCount = ceil($pageItems / $pageLimit);
     $linkConf = array('parameter' => \Metaseo\Metaseo\Utility\GeneralUtility::getCurrentPid() . ',' . $GLOBALS['TSFE']->type, 'additionalParams' => '', 'useCacheHash' => 1);
     for ($i = 0; $i < $pageCount; $i++) {
         if ($this->indexPathTemplate) {
             $link = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl(str_replace('###PAGE###', $i, $this->indexPathTemplate));
             $sitemaps[] = $link;
         } else {
             $linkConf['additionalParams'] = '&page=' . ($i + 1);
             $sitemaps[] = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($GLOBALS['TSFE']->cObj->typoLink_URL($linkConf));
         }
     }
     $ret = '<?xml version="1.0" encoding="UTF-8"?>';
     $ret .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
     $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-xml-index-sitemap-list', $this, $sitemaps);
     foreach ($sitemaps as $sitemapPage) {
         $ret .= '<sitemap><loc>' . htmlspecialchars($sitemapPage) . '</loc></sitemap>';
     }
     $ret .= '</sitemapindex>';
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-xml-index-output', $this, $ret);
     return $ret;
 }