Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature deaktivate page rootline #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Classes/Middleware/RedirectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
*/
$cookieName = 'site-language-preference';

// stop if somewhere in our rootline tx_sitelanguageredirection_stop has been set
$pageArguments = $request->getAttribute('routing');
$rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageArguments->getPageId());
/** @var RootlineUtility $rootlineUtility */
$pageRootline = $rootlineUtility->get();
foreach ($pageRootline as $pageItem) {
if (isset($pageItem['tx_sitelanguageredirection_stop']) && $pageItem['tx_sitelanguageredirection_stop'] === 1) {
return $handler->handle($request);
}
}

/**
* Do not redirect search engine bots.
*/
Expand Down
53 changes: 53 additions & 0 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'pages',
[
'tx_sitelanguageredirection_stop' => [
'exclude' => 1,
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:site_language_redirection/Resources/Private/Language/locallang_db.xlf:pages.tx_sitelanguageredirection_stop.label',
'config' => [
'type' => 'check',
'renderType' => 'checkboxToggle',
'items' => [
[
0 => '',
1 => '',
]
],
]
],
]
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'tx_sitelanguageredirection_stop',
1,
'after:php_tree_stop'
);
18 changes: 18 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2019-08-09T08:33:58Z">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'site-language-redirection'</description>
<generator>LFEditor</generator>
<authorName>Matthia Adrowski</authorName>
<authorEmail>[email protected]</authorEmail>
</header>
<body>
<trans-unit id="pages.tx_sitelanguageredirection_stop.label" xml:space="preserve">
<source>Stop Site Language Redirects</source>
<target>Stop Site Language Redirects</target>
</trans-unit>
</body>
</file>
</xliff>
17 changes: 17 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2019-08-09T08:33:58Z">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'site-language-redirection'</description>
<generator>LFEditor</generator>
<authorName>Matthia Adrowski</authorName>
<authorEmail>[email protected]</authorEmail>
</header>
<body>
<trans-unit id="pages.tx_sitelanguageredirection_stop.label" xml:space="preserve">
<source>Stop Site Language Redirects</source>
</trans-unit>
</body>
</file>
</xliff>
7 changes: 7 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

call_user_func(
static function () {
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ', tx_sitelanguageredirection_stop';
}
);
3 changes: 3 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE pages (
tx_sitelanguageredirection_stop tinyint(4) unsigned DEFAULT 0 NOT NULL,
);