diff --git a/Classes/Backend/Module/AbstractStandardModule.php b/Classes/Backend/Module/AbstractStandardModule.php index 5ebb912..2de1f03 100644 --- a/Classes/Backend/Module/AbstractStandardModule.php +++ b/Classes/Backend/Module/AbstractStandardModule.php @@ -31,4 +31,21 @@ */ abstract class AbstractStandardModule extends AbstractModule { + /** + * default size for pagination + */ + const METASEO_UI_DEFAULT_PAGING_SIZE = 50; + + /** + * @return int + */ + protected function getUiPagingSize() + { + $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['metaseo']); + if (empty($confArr['pagingSize'])) { + return self::METASEO_UI_DEFAULT_PAGING_SIZE; + } + + return (int)$confArr['pagingSize']; + } } diff --git a/Classes/Controller/Ajax/AbstractPageSeoController.php b/Classes/Controller/Ajax/AbstractPageSeoController.php index d8a1834..3f554d8 100644 --- a/Classes/Controller/Ajax/AbstractPageSeoController.php +++ b/Classes/Controller/Ajax/AbstractPageSeoController.php @@ -387,7 +387,9 @@ protected function getFrontendUtility() */ protected function getPageRepository() { - return $this->objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); + $pageRepository = $this->objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); + $pageRepository->versioningPreview = true; //enable preview mode + return $pageRepository; } /** diff --git a/Classes/Controller/Ajax/PageSeo/UrlController.php b/Classes/Controller/Ajax/PageSeo/UrlController.php index c810855..8edc041 100644 --- a/Classes/Controller/Ajax/PageSeo/UrlController.php +++ b/Classes/Controller/Ajax/PageSeo/UrlController.php @@ -41,14 +41,17 @@ class UrlController extends AbstractPageSeoSimController */ protected function initFieldList() { - $this->fieldList = array( + $fieldList = array( 'title', 'url_scheme', 'alias', - 'tx_realurl_pathsegment', - 'tx_realurl_pathoverride', - 'tx_realurl_exclude', ); + if (ExtensionManagementUtility::isLoaded('realurl')) { + $fieldList[] = 'tx_realurl_pathsegment'; + $fieldList[] = 'tx_realurl_pathoverride'; + $fieldList[] = 'tx_realurl_exclude'; + } + $this->fieldList = $fieldList; } /** diff --git a/Classes/Controller/BackendPageSeoController.php b/Classes/Controller/BackendPageSeoController.php index 16c5332..34cdebe 100644 --- a/Classes/Controller/BackendPageSeoController.php +++ b/Classes/Controller/BackendPageSeoController.php @@ -202,7 +202,7 @@ protected function handleSubAction($listType) 'ajaxController' => $ajaxController, 'pid' => (int)$pageId, 'renderTo' => 'tx-metaseo-sitemap-grid', - 'pagingSize' => 50, + 'pagingSize' => $this->getUiPagingSize(), 'depth' => 2, 'sortField' => 'crdate', 'sortDir' => 'DESC', diff --git a/Classes/Controller/BackendSitemapController.php b/Classes/Controller/BackendSitemapController.php index 7b86e2e..5c810a1 100644 --- a/Classes/Controller/BackendSitemapController.php +++ b/Classes/Controller/BackendSitemapController.php @@ -267,7 +267,7 @@ public function sitemapAction() 'ajaxController' => SitemapController::AJAX_PREFIX, 'pid' => (int)$rootPid, 'renderTo' => 'tx-metaseo-sitemap-grid', - 'pagingSize' => 50, + 'pagingSize' => $this->getUiPagingSize(), 'sortField' => 'crdate', 'sortDir' => 'DESC', 'filterIcon' => IconUtility::getSpriteIcon( diff --git a/Classes/Hook/SitemapIndexHook.php b/Classes/Hook/SitemapIndexHook.php index adcd4b4..bf697b6 100644 --- a/Classes/Hook/SitemapIndexHook.php +++ b/Classes/Hook/SitemapIndexHook.php @@ -31,6 +31,7 @@ use Metaseo\Metaseo\Utility\SitemapUtility; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; /** * Sitemap Indexer @@ -122,9 +123,11 @@ public function __construct() */ protected function initConfiguration() { + $tsfe = self::getTsfe(); + // Get configuration - if (!empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.'])) { - $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']; + if (!empty($tsfe->tmpl->setup['plugin.']['metaseo.'])) { + $this->conf = $tsfe->tmpl->setup['plugin.']['metaseo.']; } // Store blacklist configuration @@ -168,11 +171,13 @@ protected static function processLinkUrl($linkUrl) static $absRefPrefix = null; static $absRefPrefixLength = 0; $ret = $linkUrl; + $tsfe = self::getTsfe(); + // Fetch abs ref prefix if available/set if ($absRefPrefix === null) { - if (!empty($GLOBALS['TSFE']->tmpl->setup['config.']['absRefPrefix'])) { - $absRefPrefix = $GLOBALS['TSFE']->tmpl->setup['config.']['absRefPrefix']; + if (!empty($tsfe->tmpl->setup['config.']['absRefPrefix'])) { + $absRefPrefix = $tsfe->tmpl->setup['config.']['absRefPrefix']; $absRefPrefixLength = strlen($absRefPrefix); } else { $absRefPrefix = false; @@ -252,6 +257,7 @@ protected function checkIfSitemapIndexingIsEnabled($indexingType) * - REQUEST_METHOD (must be GET) * - If there is a feuser session * - Page type blacklisting + * - Exclusion from search engines * - If page is static cacheable * - If no_cache is not set * @@ -283,13 +289,20 @@ protected function checkIfCurrentPageIsIndexable() return false; } + $tsfe = self::getTsfe(); + // Check for type blacklisting (from typoscript PAGE object) - if (in_array($GLOBALS['TSFE']->type, $this->pageTypeBlacklist)) { + if (in_array($tsfe->type, $this->pageTypeBlacklist)) { + return false; + } + + // Check if page is excluded from search engines + if (!empty($tsfe->page['tx_metaseo_is_exclude'])) { return false; } // Check for doktype blacklisting (from current page record) - if (in_array((int)$GLOBALS['TSFE']->page['doktype'], $this->doktypeBlacklist)) { + if (in_array((int)$tsfe->page['doktype'], $this->doktypeBlacklist)) { return false; } @@ -298,4 +311,12 @@ protected function checkIfCurrentPageIsIndexable() return true; } + + /** + * @return TypoScriptFrontendController + */ + protected static function getTsfe() + { + return $GLOBALS['TSFE']; + } } diff --git a/Classes/Hook/SitemapIndexLinkHook.php b/Classes/Hook/SitemapIndexLinkHook.php index 5fae98d..22455f3 100644 --- a/Classes/Hook/SitemapIndexLinkHook.php +++ b/Classes/Hook/SitemapIndexLinkHook.php @@ -28,6 +28,7 @@ use Metaseo\Metaseo\Utility\GeneralUtility; use Metaseo\Metaseo\Utility\SitemapUtility; +use TYPO3\CMS\Backend\Utility\BackendUtility; /** * Sitemap Indexer @@ -128,6 +129,11 @@ public function hook_linkParse(array &$pObj) $pageLanguage = (int)GeneralUtility::getLanguageId(); } + if (!$this->checkIfTranslationExists($linkPageUid, $pageLanguage)) { + //translation does not exist => don't index + return; + } + // Index link $pageData = $this->generateSitemapPageData($linkUrl, $linkPageUid, $rootline, $pageLanguage, $linkType); if (!empty($pageData)) { @@ -135,6 +141,26 @@ public function hook_linkParse(array &$pObj) } } + /** + * Returns True if translation exists for a chosen language (L=) parameter + * Returns False if no translation exists + * + * @return bool + */ + protected function checkIfTranslationExists($linkPageUid, $requestLanguage) + { + if ($requestLanguage === 0) { + //default language always exists + return true; + } + $translated = BackendUtility::getRecordLocalization('pages', $linkPageUid, $requestLanguage); + if ($translated === false || $translated === null) { + //translation does not exist + return false; + } + return true; + } + // ######################################################################## // Methods // ######################################################################## diff --git a/Classes/Hook/SitemapIndexPageHook.php b/Classes/Hook/SitemapIndexPageHook.php index 9119f86..dfab12d 100644 --- a/Classes/Hook/SitemapIndexPageHook.php +++ b/Classes/Hook/SitemapIndexPageHook.php @@ -91,6 +91,11 @@ public function addPageToSitemapIndex() return; } + if (!$this->checkIfNoLanguageFallback()) { + // got content in fallback language => don't index + return; + } + $pageUrl = $this->getPageUrl(); // check blacklisting @@ -105,6 +110,22 @@ public function addPageToSitemapIndex() } } + /** + * Returns True if language chosen by L= parameter matches language of content + * Returns False if content is in fallback language + * + * @return bool + */ + protected function checkIfNoLanguageFallback() + { + $tsfe = self::getTsfe(); + // Check if we have fallen back to a default language + if (GeneralUtility::getLanguageId() !== $tsfe->sys_language_uid) { + return false; //don't index untranslated page + } + return true; + } + /** * Generate sitemap page data * diff --git a/Classes/Page/Part/MetatagPart.php b/Classes/Page/Part/MetatagPart.php index ef26608..ef8c658 100644 --- a/Classes/Page/Part/MetatagPart.php +++ b/Classes/Page/Part/MetatagPart.php @@ -99,6 +99,11 @@ class MetatagPart extends AbstractPart protected function initialize() { $this->cObj = $GLOBALS['TSFE']->cObj; + if (ExtensionManagementUtility::isLoaded('fluidpages')) { + // works around missing language overlay when fluidpages extension is used + $this->cObj->start($GLOBALS['TSFE']->page, 'pages'); + } + $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup; $this->pageRecord = $GLOBALS['TSFE']->page; $this->pageMeta = array(); diff --git a/Documentation/AdministratorManual/Index.rst b/Documentation/AdministratorManual/Index.rst index 26dfc2c..680115f 100644 --- a/Documentation/AdministratorManual/Index.rst +++ b/Documentation/AdministratorManual/Index.rst @@ -250,3 +250,28 @@ If you want to activate a “real” sitemap.xml feature (eg. http://example.com ); + + +Configuration via Extension Manager +----------------------------------- + +In TYPO3's extension manager go to the configuration symbol besides the entry for metaseo: + +.. figure:: ../Images/AdministatorManual/ConfigurationExtensionManager.png + :scale: 80% + :alt: Configuration via Extension Manager + +============================== ========================================================== +Configuration variable Description +============================== ========================================================== +general.pagingSize Pagination: Maximum number of entries displayed per page + in tables of backend sections Sitemap and SEO/Metatags. + Defaults to 50 entries per page. + +general.enableBeta Enable or disable beta features. + +general.enableIntegrationTTNews Enable or disable tt_news integration. + +general.sitemap_ to be documented. +clearCachePossibility +============================== ========================================================== \ No newline at end of file diff --git a/Documentation/ChangeLog/Index.rst b/Documentation/ChangeLog/Index.rst index e7eb6f5..eae2dbf 100644 --- a/Documentation/ChangeLog/Index.rst +++ b/Documentation/ChangeLog/Index.rst @@ -15,6 +15,13 @@ Changelog +-------------+----------------------------------------------------------------------------------------------------+ | Version | Changes | +=============+====================================================================================================+ +| **2.0.3** | **New feature and Bugfix release** | +| | | +| | - Number of entries shown in sitemap now can be changed via extension manager | +| | | +| | `Milestone 2.0.3 `_ | +| | `Changes in 2.0.3 `_ | ++-------------+----------------------------------------------------------------------------------------------------+ | **2.0.2** | **Bugfix release** | | | | | | **Migration to 2.0.2:** | diff --git a/Documentation/Images/AdministatorManual/ConfigurationExtensionManager.png b/Documentation/Images/AdministatorManual/ConfigurationExtensionManager.png new file mode 100644 index 0000000..172f5c9 Binary files /dev/null and b/Documentation/Images/AdministatorManual/ConfigurationExtensionManager.png differ diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 2e0d498..92e37e6 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ - + **MetaSEO version**: 0.0.0 diff --git a/README.md b/README.md index fe93143..a291caa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # MetaSEO - Search Engine Optimization for TYPO3 -![stable v2.0.2](https://img.shields.io/badge/stable-v2.0.3-green.svg?style=flat) -![development v2.0.2](https://img.shields.io/badge/development-v2.0.2-red.svg?style=flat) +![stable v2.0.3](https://img.shields.io/badge/stable-v2.0.3-green.svg?style=flat) +![development v2.0.4](https://img.shields.io/badge/development-v2.0.4-red.svg?style=flat) ![License GPL3](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat) @@ -22,13 +22,13 @@ It's a replacement for the "metatag" extension and the successor of the disconti ## Version status -* Version **2.0.2**: +* Version **2.0.3**: + Branch **master** + TYPO3 Version: 6.2.x - 7.6.x + Composer: dev-master -* Version **2.0.2-dev**: +* Version **2.0.4-dev**: + Branch **develop** + TYPO3 Version: 6.2.x - 7.6.x diff --git a/composer.json b/composer.json index 992b907..f6d7bcf 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ }, "license": ["GPL-3.0+"], "keywords": ["TYPO3 CMS"], - "version": "2.0.2", + "version": "2.0.3", "autoload": { "psr-4": { "Metaseo\\Metaseo\\": "Classes/" diff --git a/ext_conf_template.txt b/ext_conf_template.txt index 98ced38..5a6eae3 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,3 +1,6 @@ +# cat=General; type=int+; label=Pagination: Maximum number of entries displayed in tables of backend sections Sitemap and SEO/Metatags. Defaults to 50 entries. +pagingSize = + # cat=General; type=boolean; label=Beta: Enable beta-features, see manual for details (default is disabled) enableBeta = diff --git a/ext_emconf.php b/ext_emconf.php index 43587a9..c4800eb 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -5,13 +5,13 @@ 'description' => 'Search Engine Optimization (SEO), Indexed Google-Sitemap (TXT- and XML-Sitemap) for all Extensions (pibase, extbase), Metatags, Canonical-URL, Pagetitle manipulations, Crawler verification, Piwik and Google Analytics support and some more... multi-language- and multi-tree-support', 'category' => 'misc', 'shy' => 0, - 'version' => '2.0.2', + 'version' => '2.0.3', 'dependencies' => '', 'conflicts' => '', 'priority' => '', 'loadOrder' => '', 'module' => '', - 'state' => 'beta', + 'state' => 'stable', 'uploadfolder' => 1, 'createDirs' => '', 'modify_tables' => 'pages,pages_language_overlay', @@ -29,10 +29,10 @@ ), 'conflicts' => array(), 'suggests' => array(), - 'autoload' => array( - 'psr-4' => array( - 'Metaseo\\Metaseo\\' => 'Classes', - ), + ), + 'autoload' => array( + 'psr-4' => array( + 'Metaseo\\Metaseo\\' => 'Classes', ), ), '_md5_values_when_last_written' => 'a:31:{s:9:"ChangeLog";s:4:"95d7";s:10:"README.txt";s:4:"878d";s:16:"ext_autoload.php";s:4:"550a";s:21:"ext_conf_template.txt";s:4:"09c3";s:12:"ext_icon.gif";s:4:"6ce1";s:17:"ext_localconf.php";s:4:"4f36";s:14:"ext_tables.php";s:4:"6b22";s:14:"ext_tables.sql";s:4:"31cb";s:16:"locallang_db.xml";s:4:"a7ed";s:17:"locallang_tca.xml";s:4:"6623";s:7:"tca.php";s:4:"95ea";s:14:"doc/manual.pdf";s:4:"6b9f";s:14:"doc/manual.sxw";s:4:"0385";s:40:"hooks/sitemap/class.cache_controller.php";s:4:"b6d4";s:45:"hooks/sitemap/class.cache_controller_hook.php";s:4:"5b2d";s:27:"hooks/sitemap/locallang.xlf";s:4:"0c9f";s:19:"lib/class.cache.php";s:4:"2659";s:18:"lib/class.http.php";s:4:"5366";s:24:"lib/class.linkparser.php";s:4:"a2e1";s:22:"lib/class.metatags.php";s:4:"0067";s:24:"lib/class.pagefooter.php";s:4:"35b6";s:23:"lib/class.pagetitle.php";s:4:"1709";s:24:"lib/class.robots_txt.php";s:4:"e839";s:19:"lib/class.tools.php";s:4:"b67d";s:34:"lib/sitemap/class.sitemap_base.php";s:4:"0e0a";s:37:"lib/sitemap/class.sitemap_indexer.php";s:4:"3162";s:33:"lib/sitemap/class.sitemap_txt.php";s:4:"fcc3";s:33:"lib/sitemap/class.sitemap_xml.php";s:4:"10bc";s:24:"res/ga-track-download.js";s:4:"e80d";s:28:"static/default/constants.txt";s:4:"60b5";s:24:"static/default/setup.txt";s:4:"e6ff";}',