Skip to content

Commit

Permalink
Merge pull request #21 from ayacoo/3.0
Browse files Browse the repository at this point in the history
[TASK] v12 Support
  • Loading branch information
ayacoo authored Dec 19, 2022
2 parents ee081dc + 19256a0 commit a674476
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 60 deletions.
27 changes: 11 additions & 16 deletions Classes/Form/Element/RedirectElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,30 @@

class RedirectElement extends AbstractFormElement
{
/**
* @var object|\Psr\Log\LoggerAwareInterface|\TYPO3\CMS\Core\SingletonInterface
*/
private $view;
private StandaloneView $view;

/**
* @var object|\Psr\Log\LoggerAwareInterface|\TYPO3\CMS\Core\SingletonInterface
*/
private $redirectRepository;
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private RedirectRepository $redirectRepository;

public function render(): array
{
$this->redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class);
$this->eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class);
$eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class);

$this->prepareView();
list($demand, $redirects) = $this->getRedirects();

$event = $this->eventDispatcher->dispatch(new ModifyRedirectsEvent($redirects));
$event = $eventDispatcher->dispatch(new ModifyRedirectsEvent($redirects));
$redirects = $event->getRedirects();

$backendUriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$uriParameters = ['edit' => ['pages' => [$this->data['effectivePid'] => 'edit']]];
$returnUrl = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);

$this->view->assignMultiple([
'redirects' => $redirects,
'demand' => $demand,
'pagination' => $this->preparePagination($demand)
'pagination' => $this->preparePagination($demand),
'returnUrl' => $returnUrl
]);

$result = $this->initializeResultArray();
Expand Down Expand Up @@ -97,7 +92,7 @@ protected function getRedirects(): array
$redirectsWithSlugAsIdentifier ?? []
);
}
return array($demand, $redirects);
return [$demand, $redirects];
}

/**
Expand Down
15 changes: 7 additions & 8 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

defined('TYPO3_MODE') || die();
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') || die();

(static function ($extKey, $table): void {

/**
* Extend TCA.
*/
$temporaryColumns = [
'redirects' => [
'exclude' => true,
'label' => '',
'label' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang.xlf:redirect_list',
'config' => [
'type' => 'user',
'renderType' => 'listRedirects',
Expand All @@ -19,16 +18,16 @@
];

// Add to TCA pages
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
ExtensionManagementUtility::addTCAcolumns(
$table,
$temporaryColumns
);


// Add additional tab for page properties
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
ExtensionManagementUtility::addToAllTCAtypes(
$table,
'--div--;LLL:EXT:redirect_tab/Resources/Private/Language/locallang.xlf:tab,' . implode(',', array_keys($temporaryColumns)),
'--div--;LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang.xlf:tab,' . implode(',', array_keys($temporaryColumns)),
'',
''
);
Expand Down
51 changes: 32 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

* Show redirects of the respective page in a tab in the page properties

**Hint**:

This extension is new and should first be tested in a dev environment. Feedback is welcome.

## 2 Usage

### 2.1 Installation
Expand All @@ -26,26 +22,31 @@ composer require ayacoo/redirect-tab

### 3.1 Versions and support

| News | TYPO3 | PHP | Support / Development |
| ----------- | ---------- | ----------|---------------------------------------- |
| dev-main | 11.x - 12.x| 7.4 - 8.0 | unstable development branch |
| 2.x | 11.x | 7.4 - 8.0 | features, bugfixes, security updates |
| 1.x | 10.x | 7.2 - 7.4 | features, bugfixes, security updates |

| redirect_tab | TYPO3 | PHP | Support / Development |
|------|---------|-----------|-----------------------------|
| 3.x | 12.x | 8.1 | features, bugfixes, security updates |
| 2.x | 11.x | 7.4 - 8.0 | bugfixes, security updates |
| 1.x | 10.x | 7.2 - 7.4 | no support any more |

### 3.2 Release Management

reidrect_tab uses [**semantic versioning**][2], which means, that
* **bugfix updates** (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or security relevant stuff without breaking changes,
* **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes,
* and **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes which can be refactorings, features or bugfixes.
redirect_tab uses [**semantic versioning**][2], which means, that

* **bugfix updates** (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or
security relevant stuff without breaking changes,
* **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller
tasks without breaking changes,
* and **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes which can be
refactorings, features or bugfixes.

### 3.3 Contribution

**Pull Requests** are gladly welcome! Nevertheless please don't forget to add an issue and connect it to your pull requests. This
**Pull Requests** are gladly welcome! Nevertheless please don't forget to add an
issue and connect it to your pull requests. This
is very helpful to understand what kind of issue the **PR** is going to solve.

**Bugfixes**: Please describe what kind of bug your fix solve and give us feedback how to reproduce the issue. We're going
**Bugfixes**: Please describe what kind of bug your fix solve and give us
feedback how to reproduce the issue. We're going
to accept only bugfixes if we can reproduce the issue.

## 4 Developer corner
Expand All @@ -54,7 +55,10 @@ to accept only bugfixes if we can reproduce the issue.

**ModifyRedirectsEvent**

The ModifyRedirectsEvent offers the possibility to influence the resultset of the redirects. For example, the LIKE %Value% search from the core sometimes displays incorrect hits for the respective page. These can be filtered out with the event.
The ModifyRedirectsEvent offers the possibility to influence the resultset of
the redirects. For example, the LIKE %Value% search from the core sometimes
displays incorrect hits for the respective page. These can be filtered out with
the event.

Example for registration:

Expand All @@ -71,10 +75,19 @@ services:

## 5 Thanks / Notices

Special thanks to Georg Ringer and his [news][3] extension. A good template to build a TYPO3 extension. Here, for example, the structure of README.md is used.
Special thanks to Georg Ringer and his [news][3] extension. A good template to
build a TYPO3 extension. Here, for example, the structure of README.md is used.

This extension is a result of a core proof of concept and uses many parts of the TYPO3 core, especially parts of the redirect extension.
This extension is a result of a core proof of concept and uses many parts of the
TYPO3 core, especially parts of the redirect extension.

[1]: https://getcomposer.org/

[2]: https://semver.org/

[3]: https://github.com/georgringer/news

## 6 Support

If you are happy with the extension and would like to support it in any way, I
would appreciate the support of social institutions.
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<trans-unit id="tab" xml:space="preserve">
<source>Redirects</source>
</trans-unit>
<trans-unit id="redirect_list" xml:space="preserve">
<source>List of linked redirects for this page</source>
</trans-unit>
</body>
</file>
</xliff>
18 changes: 9 additions & 9 deletions Resources/Private/Templates/Backend/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<table class="table table-striped table-hover">
<thead>
<tr>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:source_host"/></th>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:source_path"/></th>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:destination"/></th>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_db.xlf:sys_redirect.source_host"/></th>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_db.xlf:sys_redirect.source_path"/></th>
<th><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_db.xlf:sys_redirect.destination"/></th>
<th></th>
</tr>
</thead>
Expand All @@ -37,7 +37,7 @@
</f:if>
<core:iconForRecord table="sys_redirect" row="{redirect}" /></span>
</f:alias>
<be:link.editRecord table="sys_redirect" uid="{redirect.uid}" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')}: {redirect.source_path}">
<be:link.editRecord returnUrl="{returnUrl}" table="sys_redirect" uid="{redirect.uid}" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')}: {redirect.source_path}">
{redirect.source_path -> f:format.crop(maxCharacters:100)}
</be:link.editRecord>
</td>
Expand All @@ -62,17 +62,17 @@
</f:if>
<f:if condition="{redirect.disabled} == 1">
<f:then>
<a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[sys_redirect][{redirect.uid}][disabled]=0', currentUrlParameterName:'redirect')}" title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:unHide')}"><core:icon identifier="actions-edit-unhide" /></a>
<a class="btn btn-default" href="{be:moduleLink(route:'tce_db', arguments:'{redirect: returnUrl}', query:'data[sys_redirect][{redirect.uid}][disabled]=0', currentUrlParameterName:'redirect')}" title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:unHide')}"><core:icon identifier="actions-edit-unhide" /></a>
</f:then>
<f:else>
<a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[sys_redirect][{redirect.uid}][disabled]=1', currentUrlParameterName:'redirect')}" title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:hide')}"><core:icon identifier="actions-edit-hide" /></a>
<a class="btn btn-default" href="{be:moduleLink(route:'tce_db', arguments:'{redirect: returnUrl}', query:'data[sys_redirect][{redirect.uid}][disabled]=1', currentUrlParameterName:'redirect')}" title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:hide')}"><core:icon identifier="actions-edit-hide" /></a>
</f:else>
</f:if>
<be:link.editRecord class="btn btn-default" table="sys_redirect" uid="{redirect.uid}" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')}">
<be:link.editRecord returnUrl="{returnUrl}" class="btn btn-default" table="sys_redirect" uid="{redirect.uid}" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')}">
<core:icon identifier="actions-open" />
</be:link.editRecord>
<a class="btn btn-default t3js-modal-trigger"
href="{be:moduleLink(route:'tce_db', query:'cmd[sys_redirect][{redirect.uid}][delete]=1', currentUrlParameterName:'redirect')}"
href="{be:moduleLink(route:'tce_db', arguments:'{redirect: returnUrl}', query:'cmd[sys_redirect][{redirect.uid}][delete]=1', currentUrlParameterName:'redirect')}"
title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:delete')}"
data-severity="warning"
data-title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf:label.confirm.delete_record.title')}"
Expand All @@ -91,7 +91,7 @@
<f:else>
<f:be.infobox state="-1" title="{f:translate(key: 'LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:redirect_not_found.title')}">
<p><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:redirect_not_found.message"/></p>
<be:link.newRecord class="btn btn-primary" table="sys_redirect">
<be:link.newRecord returnUrl="{returnUrl}" class="btn btn-primary" table="sys_redirect">
<f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_module_redirect.xlf:redirect_create"/>
</be:link.newRecord>
</f:be.infobox>
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ayacoo/redirect-tab",
"type": "typo3-cms-extension",
"version": "2.1.0",
"version": "3.0.0",
"description": "Show TYPO3 redirects in the page properties",
"authors": [
{
Expand All @@ -12,9 +12,8 @@
"homepage": "https://www.ayacoo.de/",
"license": "GPL-2.0-or-later",
"require": {
"php": "^7.4 || ^8.0",
"typo3/cms-core": "^11.5",
"typo3/cms-redirects": "^11.5"
"php": ">=8.1",
"typo3/cms-core": "^12.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
'author_email' => '[email protected]',
'state' => 'beta',
'clearCacheOnLoad' => 0,
'version' => '2.1.0',
'version' => '3.0.0',
'constraints' => [
'depends' => [
'typo3' => '11.0.0-11.99.99',
'typo3' => '12.0.0-12.99.99',
],
'conflicts' => [
],
Expand Down
7 changes: 5 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php
defined('TYPO3_MODE') || die();

use Ayacoo\RedirectTab\Form\Element\RedirectElement;

defined('TYPO3') || die();

(function () {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry']['1610832584'] = [
'nodeName' => 'listRedirects',
'priority' => 40,
'class' => \Ayacoo\RedirectTab\Form\Element\RedirectElement::class,
'class' => RedirectElement::class,
];
})();

0 comments on commit a674476

Please sign in to comment.