first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Base class for XmlSitemapProviders to extend
|
||||
*/
|
||||
abstract class AbstractXmlSitemapDataProvider implements XmlSitemapDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lastModified;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* @var ContentObjectRenderer
|
||||
*/
|
||||
protected $cObj;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $numberOfItemsPerPage = 1000;
|
||||
|
||||
/**
|
||||
* @var ServerRequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* AbstractXmlSitemapDataProvider constructor
|
||||
*
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
* @param string $key
|
||||
* @param array $config
|
||||
* @param ContentObjectRenderer $cObj
|
||||
*/
|
||||
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
|
||||
if ($cObj === null) {
|
||||
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
}
|
||||
$this->cObj = $cObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumberOfPages(): int
|
||||
{
|
||||
return (int)ceil(count($this->items) / $this->numberOfItemsPerPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLastModified(): int
|
||||
{
|
||||
$lastMod = 0;
|
||||
foreach ($this->items as $item) {
|
||||
if ((int)$item['lastMod'] > $lastMod) {
|
||||
$lastMod = (int)$item['lastMod'];
|
||||
}
|
||||
}
|
||||
|
||||
return $lastMod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function defineUrl(array $data): array
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
$pageNumber = (int)($this->request->getQueryParams()['page'] ?? 0);
|
||||
$page = $pageNumber > 0 ? $pageNumber : 0;
|
||||
$items = array_slice(
|
||||
$this->items,
|
||||
$page * $this->numberOfItemsPerPage,
|
||||
$this->numberOfItemsPerPage
|
||||
);
|
||||
|
||||
return array_map([$this, 'defineUrl'], $items);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap\Exception;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
class InvalidConfigurationException extends \TYPO3\CMS\Core\Resource\Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap\Exception;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
class MissingConfigurationException extends \TYPO3\CMS\Core\Resource\Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Context\Context;
|
||||
use TYPO3\CMS\Core\Context\LanguageAspect;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryHelper;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\Page\PageRepository;
|
||||
|
||||
/**
|
||||
* Class to generate a XML sitemap for pages
|
||||
* @internal this class is not part of TYPO3's Core API.
|
||||
*/
|
||||
class PagesXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
|
||||
{
|
||||
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
|
||||
{
|
||||
parent::__construct($request, $key, $config, $cObj);
|
||||
|
||||
$this->generateItems();
|
||||
}
|
||||
|
||||
protected function generateItems(): void
|
||||
{
|
||||
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);
|
||||
$pages = $pageRepository->getPagesOverlay($this->getPages());
|
||||
$languageAspect = $this->getCurrentLanguageAspect();
|
||||
foreach ($pages as $page) {
|
||||
if (!$pageRepository->isPageSuitableForLanguage($page, $languageAspect)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->items[] = [
|
||||
'uid' => $page['uid'],
|
||||
'lastMod' => (int)($page['SYS_LASTCHANGED'] ?: $page['tstamp'])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getPages(): array
|
||||
{
|
||||
if (!empty($this->config['rootPage'])) {
|
||||
$rootPageId = (int)$this->config['rootPage'];
|
||||
} else {
|
||||
$site = $this->request->getAttribute('site');
|
||||
$rootPageId = $site->getRootPageId();
|
||||
}
|
||||
|
||||
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
$treeList = $cObj->getTreeList(-$rootPageId, 99);
|
||||
$treeListArray = GeneralUtility::intExplode(',', $treeList);
|
||||
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
|
||||
->getQueryBuilderForTable('pages');
|
||||
|
||||
$constraints = [
|
||||
$queryBuilder->expr()->in('uid', $treeListArray)
|
||||
];
|
||||
|
||||
if (!empty($this->config['additionalWhere'])) {
|
||||
$constraints[] = QueryHelper::stripLogicalOperatorPrefix($this->config['additionalWhere']);
|
||||
}
|
||||
|
||||
if (!empty($this->config['excludedDoktypes'])) {
|
||||
$excludedDoktypes = GeneralUtility::intExplode(',', $this->config['excludedDoktypes']);
|
||||
if (!empty($excludedDoktypes)) {
|
||||
$constraints[] = $queryBuilder->expr()->notIn('doktype', implode(',', $excludedDoktypes));
|
||||
}
|
||||
}
|
||||
$pages = $queryBuilder->select('*')
|
||||
->from('pages')
|
||||
->where(...$constraints)
|
||||
->orderBy('uid', 'ASC')
|
||||
->execute()
|
||||
->fetchAll();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LanguageAspect
|
||||
*/
|
||||
protected function getCurrentLanguageAspect(): LanguageAspect
|
||||
{
|
||||
return GeneralUtility::makeInstance(Context::class)->getAspect('language');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function defineUrl(array $data): array
|
||||
{
|
||||
$typoLinkConfig = [
|
||||
'parameter' => $data['uid'],
|
||||
'forceAbsoluteUrl' => 1,
|
||||
];
|
||||
|
||||
$data['loc'] = $this->cObj->typoLink_URL($typoLinkConfig);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Context\Context;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryHelper;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Seo\XmlSitemap\Exception\MissingConfigurationException;
|
||||
|
||||
/**
|
||||
* XmlSiteDataProvider will provide information for the XML sitemap for a specific database table
|
||||
* @internal this class is not part of TYPO3's Core API.
|
||||
*/
|
||||
class RecordsXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
|
||||
{
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param string $key
|
||||
* @param array $config
|
||||
* @param ContentObjectRenderer|null $cObj
|
||||
* @throws MissingConfigurationException
|
||||
*/
|
||||
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
|
||||
{
|
||||
parent::__construct($request, $key, $config, $cObj);
|
||||
|
||||
$this->generateItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MissingConfigurationException
|
||||
*/
|
||||
public function generateItems(): void
|
||||
{
|
||||
$table = $this->config['table'];
|
||||
|
||||
if (empty($table)) {
|
||||
throw new MissingConfigurationException(
|
||||
'No configuration found for sitemap ' . $this->getKey(),
|
||||
1535576053
|
||||
);
|
||||
}
|
||||
|
||||
$pids = !empty($this->config['pid']) ? GeneralUtility::intExplode(',', $this->config['pid']) : [];
|
||||
$lastModifiedField = $this->config['lastModifiedField'] ?? 'tstamp';
|
||||
$sortField = $this->config['sortField'] ?? 'sorting';
|
||||
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
|
||||
->getQueryBuilderForTable($table);
|
||||
|
||||
$constraints = [];
|
||||
if (!empty($GLOBALS['TCA'][$table]['ctrl']['languageField'])) {
|
||||
$constraints[] = $queryBuilder->expr()->in(
|
||||
$GLOBALS['TCA'][$table]['ctrl']['languageField'],
|
||||
[
|
||||
-1, // All languages
|
||||
$this->getLanguageId() // Current language
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($pids)) {
|
||||
$recursiveLevel = isset($this->config['recursive']) ? (int)$this->config['recursive'] : 0;
|
||||
if ($recursiveLevel) {
|
||||
$newList = [];
|
||||
foreach ($pids as $pid) {
|
||||
$list = $this->cObj->getTreeList($pid, $recursiveLevel);
|
||||
if ($list) {
|
||||
$newList = array_merge($newList, explode(',', $list));
|
||||
}
|
||||
}
|
||||
$pids = array_merge($pids, $newList);
|
||||
}
|
||||
|
||||
$constraints[] = $queryBuilder->expr()->in('pid', $pids);
|
||||
}
|
||||
|
||||
if (!empty($this->config['additionalWhere'])) {
|
||||
$constraints[] = QueryHelper::stripLogicalOperatorPrefix($this->config['additionalWhere']);
|
||||
}
|
||||
|
||||
$queryBuilder->select('*')
|
||||
->from($table);
|
||||
|
||||
if (!empty($constraints)) {
|
||||
$queryBuilder->where(
|
||||
...$constraints
|
||||
);
|
||||
}
|
||||
|
||||
$rows = $queryBuilder->orderBy($sortField)
|
||||
->execute()
|
||||
->fetchAll();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$this->items[] = [
|
||||
'data' => $row,
|
||||
'lastMod' => (int)$row[$lastModifiedField]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function defineUrl(array $data): array
|
||||
{
|
||||
$pageId = $this->config['url']['pageId'] ?? $GLOBALS['TSFE']->id;
|
||||
$additionalParams = [];
|
||||
|
||||
$additionalParams = $this->getUrlFieldParameterMap($additionalParams, $data['data']);
|
||||
$additionalParams = $this->getUrlAdditionalParams($additionalParams);
|
||||
|
||||
$additionalParamsString = http_build_query(
|
||||
$additionalParams,
|
||||
'',
|
||||
'&',
|
||||
PHP_QUERY_RFC3986
|
||||
);
|
||||
|
||||
$typoLinkConfig = [
|
||||
'parameter' => $pageId,
|
||||
'additionalParams' => $additionalParamsString ? '&' . $additionalParamsString : '',
|
||||
'forceAbsoluteUrl' => 1,
|
||||
'useCacheHash' => $this->config['url']['useCacheHash'] ?? 0
|
||||
];
|
||||
|
||||
$data['loc'] = $this->cObj->typoLink_URL($typoLinkConfig);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $additionalParams
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function getUrlFieldParameterMap(array $additionalParams, array $data): array
|
||||
{
|
||||
if (!empty($this->config['url']['fieldToParameterMap']) &&
|
||||
\is_array($this->config['url']['fieldToParameterMap'])) {
|
||||
foreach ($this->config['url']['fieldToParameterMap'] as $field => $urlPart) {
|
||||
$additionalParams[$urlPart] = $data[$field];
|
||||
}
|
||||
}
|
||||
|
||||
return $additionalParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $additionalParams
|
||||
* @return array
|
||||
*/
|
||||
protected function getUrlAdditionalParams(array $additionalParams): array
|
||||
{
|
||||
if (!empty($this->config['url']['additionalGetParameters']) &&
|
||||
is_array($this->config['url']['additionalGetParameters'])) {
|
||||
foreach ($this->config['url']['additionalGetParameters'] as $extension => $extensionConfig) {
|
||||
foreach ($extensionConfig as $key => $value) {
|
||||
$additionalParams[$extension . '[' . $key . ']'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $additionalParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
|
||||
*/
|
||||
protected function getLanguageId(): int
|
||||
{
|
||||
$context = GeneralUtility::makeInstance(Context::class);
|
||||
return (int)$context->getPropertyFromAspect('language', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Interface for XmlSitemapDataProviders containing the methods that are called by the XmlSitemapRenderer
|
||||
*/
|
||||
interface XmlSitemapDataProviderInterface
|
||||
{
|
||||
public function __construct(ServerRequestInterface $request, string $name, array $config = [], ContentObjectRenderer $cObj = null);
|
||||
public function getKey(): string;
|
||||
public function getItems(): array;
|
||||
public function getLastModified(): int;
|
||||
public function getNumberOfPages(): int;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace TYPO3\CMS\Seo\XmlSitemap;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\PathUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
use TYPO3\CMS\Seo\XmlSitemap\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Class to render the XML Sitemap to be used as a UserFunction
|
||||
* @internal this class is not part of TYPO3's Core API.
|
||||
*/
|
||||
class XmlSitemapRenderer
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configuration;
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\Fluid\View\StandaloneView
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->configuration = $this->getConfiguration();
|
||||
$this->view = $this->getStandaloneView();
|
||||
$this->view->assign(
|
||||
'xslFile',
|
||||
PathUtility::stripPathSitePrefix(
|
||||
ExtensionManagementUtility::extPath('seo', 'Resources/Public/CSS/Sitemap.xsl')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws InvalidConfigurationException
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
// Inject request from globals until request will be available to cObj
|
||||
$request = $GLOBALS['TYPO3_REQUEST'];
|
||||
$this->view->assign('type', $GLOBALS['TSFE']->type);
|
||||
if (!empty($sitemap = $request->getQueryParams()['sitemap'])) {
|
||||
return $this->renderSitemap($request, $sitemap);
|
||||
}
|
||||
|
||||
return $this->renderIndex($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
* @return string
|
||||
*/
|
||||
protected function renderIndex(ServerRequestInterface $request): string
|
||||
{
|
||||
$sitemaps = [];
|
||||
foreach ($this->configuration['config']['xmlSitemap']['sitemaps'] ?? [] as $sitemap => $config) {
|
||||
if (class_exists($config['provider']) &&
|
||||
is_subclass_of($config['provider'], XmlSitemapDataProviderInterface::class)) {
|
||||
/** @var XmlSitemapDataProviderInterface $provider */
|
||||
$provider = GeneralUtility::makeInstance(
|
||||
$config['provider'],
|
||||
$request,
|
||||
$sitemap,
|
||||
(array)$config['config']
|
||||
);
|
||||
|
||||
$pages = $provider->getNumberOfPages();
|
||||
|
||||
for ($page = 0; $page < $pages; $page++) {
|
||||
$sitemaps[] = [
|
||||
'key' => $sitemap,
|
||||
'page' => $page,
|
||||
'lastMod' => $provider->getLastModified()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('sitemaps', $sitemaps);
|
||||
$this->view->setTemplate('Index');
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||
* @param string $sitemap
|
||||
* @return string
|
||||
* @throws \TYPO3\CMS\Seo\XmlSitemap\Exception\InvalidConfigurationException
|
||||
*/
|
||||
protected function renderSitemap(ServerRequestInterface $request, string $sitemap): string
|
||||
{
|
||||
if (!empty($sitemapConfig = $this->configuration['config']['xmlSitemap']['sitemaps'][$sitemap])) {
|
||||
if (class_exists($sitemapConfig['provider']) &&
|
||||
is_subclass_of($sitemapConfig['provider'], XmlSitemapDataProviderInterface::class)) {
|
||||
/** @var XmlSitemapDataProviderInterface $provider */
|
||||
$provider = GeneralUtility::makeInstance(
|
||||
$sitemapConfig['provider'],
|
||||
$request,
|
||||
$sitemap,
|
||||
(array)$sitemapConfig['config']
|
||||
);
|
||||
|
||||
$items = $provider->getItems();
|
||||
|
||||
$template = $sitemapConfig['config']['template'] ?: 'Sitemap';
|
||||
$this->view->setTemplate($template);
|
||||
$this->view->assign('items', $items);
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
throw new InvalidConfigurationException('No valid provider set for ' . $sitemap, 1535578522);
|
||||
}
|
||||
|
||||
throw new InvalidConfigurationException('No valid configuration found for sitemap ' . $sitemap, 1535578569);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Fluid\View\StandaloneView
|
||||
*/
|
||||
protected function getStandaloneView(): StandaloneView
|
||||
{
|
||||
$view = GeneralUtility::makeInstance(StandaloneView::class);
|
||||
$view->setTemplateRootPaths($this->configuration['view']['templateRootPaths']);
|
||||
$view->setLayoutRootPaths($this->configuration['view']['layoutRootPaths']);
|
||||
$view->setPartialRootPaths($this->configuration['view']['partialRootPaths']);
|
||||
$view->setFormat('xml');
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the whole typoscript array
|
||||
* @return array
|
||||
*/
|
||||
private function getConfiguration(): array
|
||||
{
|
||||
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(ConfigurationManagerInterface::class);
|
||||
|
||||
return $configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
|
||||
'seo'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user