From b192ee142774cb74df08f998fcff0d46099b21b8 Mon Sep 17 00:00:00 2001 From: Krystian Szymukowicz Date: Sun, 7 Jan 2018 20:24:29 +0100 Subject: [PATCH 1/2] Fixes #512 --- Classes/Hook/SitemapIndexHook.php | 22 +++++++++++++++++++--- Classes/Utility/SitemapUtility.php | 19 ++++++++++++++++++- Configuration/TypoScript/setup.txt | 3 +++ Documentation/DeveloperManual/Index.rst | 3 +++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Classes/Hook/SitemapIndexHook.php b/Classes/Hook/SitemapIndexHook.php index 0d621c1..dc354bf 100644 --- a/Classes/Hook/SitemapIndexHook.php +++ b/Classes/Hook/SitemapIndexHook.php @@ -57,6 +57,13 @@ abstract class SitemapIndexHook implements SingletonInterface */ protected $pageTypeBlacklist = array(); + /** + * List of whitelisted page types (Setup PAGE object typeNum) + * + * @var array + */ + protected $pageTypeWhitelist = array(); + /** * Page index status * @@ -157,6 +164,9 @@ protected function initConfiguration() // Init blacklist for PAGE typenum $this->pageTypeBlacklist = SitemapUtility::getPageTypeBlacklist(); + + // Init whitelist for PAGE typenum + $this->pageTypeWhitelist = SitemapUtility::getPageTypeWhitelist(); } /** @@ -293,9 +303,15 @@ protected function checkIfCurrentPageIsIndexable() $tsfe = self::getTsfe(); - // Check for type blacklisting (from typoscript PAGE object) - if (in_array($tsfe->type, $this->pageTypeBlacklist)) { - return false; + if (!empty($this->pageTypeWhitelist)) { + if (!in_array($tsfe->type, $this->pageTypeWhitelist)) { + return false; + } + } else { + // Check for type blacklisting (from typoscript PAGE object) + if (in_array($tsfe->type, $this->pageTypeBlacklist)) { + return false; + } } // Check if page is excluded from search engines diff --git a/Classes/Utility/SitemapUtility.php b/Classes/Utility/SitemapUtility.php index c30dc8d..c13d688 100644 --- a/Classes/Utility/SitemapUtility.php +++ b/Classes/Utility/SitemapUtility.php @@ -221,7 +221,7 @@ public static function getPageTypeBlacklist() ) >= 1 ) { $pageTypeBlacklist = $GLOBALS['TSFE']->tmpl - ->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeBlacklist']; + ->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeBlacklist']; $pageTypeBlacklist = Typo3GeneralUtility::trimExplode(',', $pageTypeBlacklist); $ret = array_merge($ret, $pageTypeBlacklist); @@ -230,6 +230,23 @@ public static function getPageTypeBlacklist() return $ret; } + /** + * Get list of whitelisted PAGE typenum (typoscript object) + * + * @return array + */ + public static function getPageTypeWhitelist() + { + $pageTypeWhitelist = []; + if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist']) + && strlen($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist']) + >= 1) { + $pageTypeWhitelist = Typo3GeneralUtility::trimExplode(',', + $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist']); + } + return $pageTypeWhitelist; + } + /** * Return list of sitemap pages * diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.txt index eda0341..6d06378 100644 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.txt @@ -482,6 +482,9 @@ plugin.metaseo { # Blacklist for SetupTS PAGE object typeNums pageTypeBlacklist = + # Whitelist for SetupTS PAGE object typeNums (when set then pageTypeBlacklist is ignored) + pageTypeWhitelist = + allowNoStaticCachable = {$plugin.metaseo.sitemap.index.allowNoStaticCachable} allowNoCache = {$plugin.metaseo.sitemap.index.allowNoCache} diff --git a/Documentation/DeveloperManual/Index.rst b/Documentation/DeveloperManual/Index.rst index 5c36513..6a8b440 100644 --- a/Documentation/DeveloperManual/Index.rst +++ b/Documentation/DeveloperManual/Index.rst @@ -166,6 +166,9 @@ plugin.metaseo.sitemap.index.blacklist List of Regular Exp plugin.metaseo.sitemap.index.pageTypeBlacklist List of blacklisted page typeNums (SetupTS PAGE objects) String, comma separated +plugin.metaseo.sitemap.index.pageTypeWhitelist List of whitelisted page typeNums (SetupTS PAGE objects) String, comma separated + If set then "pageTypeBlacklist" is ignored. + plugin.metaseo.sitemap.index.fileExtension List of allowed file extensions for indexing List Default: From 02e491a1b220d7f176926fdb895bf338cfd645b0 Mon Sep 17 00:00:00 2001 From: Krystian Szymukowicz Date: Sun, 7 Jan 2018 20:29:19 +0100 Subject: [PATCH 2/2] Fixes #512 --- Classes/Utility/SitemapUtility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Utility/SitemapUtility.php b/Classes/Utility/SitemapUtility.php index c13d688..60c2266 100644 --- a/Classes/Utility/SitemapUtility.php +++ b/Classes/Utility/SitemapUtility.php @@ -221,7 +221,7 @@ public static function getPageTypeBlacklist() ) >= 1 ) { $pageTypeBlacklist = $GLOBALS['TSFE']->tmpl - ->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeBlacklist']; + ->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeBlacklist']; $pageTypeBlacklist = Typo3GeneralUtility::trimExplode(',', $pageTypeBlacklist); $ret = array_merge($ret, $pageTypeBlacklist);