Skip to content

Commit

Permalink
[TASK] TYPO3 v12 compatibility
Browse files Browse the repository at this point in the history
ref #21
  • Loading branch information
cdaecke committed Sep 20, 2023
1 parent a54bc55 commit 178cf2d
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 200 deletions.
14 changes: 10 additions & 4 deletions Classes/Controller/NewsAuthorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use GeorgRinger\NumberedPagination\NumberedPagination;
use Mediadreams\MdNewsAuthor\Domain\Repository\NewsAuthorRepository;
use Mediadreams\MdNewsAuthor\Domain\Repository\NewsRepository;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;

Expand Down Expand Up @@ -73,9 +74,10 @@ public function __construct(
*
* @param string $selectedLetter
* @param int $currentPage
* @return void
* @return ResponseInterface
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function listAction($selectedLetter = "", int $currentPage = 1)
public function listAction($selectedLetter = "", int $currentPage = 1): ResponseInterface
{
// get all authors
// we need all authors all the time because the alphabetical filter needs them as well
Expand Down Expand Up @@ -109,16 +111,18 @@ public function listAction($selectedLetter = "", int $currentPage = 1)
$this->settings['authorList']['paginate']['itemsPerPage'],
$this->settings['authorList']['paginate']['maximumNumberOfLinks']
);

return $this->htmlResponse();
}

/**
* action show
*
* @param \Mediadreams\MdNewsAuthor\Domain\Model\NewsAuthor|null $newsAuthor
* @return ResponseInterface
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function showAction(\Mediadreams\MdNewsAuthor\Domain\Model\NewsAuthor $newsAuthor = null)
public function showAction(\Mediadreams\MdNewsAuthor\Domain\Model\NewsAuthor $newsAuthor = null): ResponseInterface
{
if ($newsAuthor != null) {
// write page title
Expand All @@ -143,6 +147,8 @@ public function showAction(\Mediadreams\MdNewsAuthor\Domain\Model\NewsAuthor $ne
$this->redirectToUri($uri, 0, 308);
}
}

return $this->htmlResponse();
}

/**
Expand Down
11 changes: 6 additions & 5 deletions Classes/Domain/Repository/NewsAuthorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,22 @@ public function getAuthorsByCategories($categories = '', $initial = '')
$categories = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $categories, true);
}

$categoryConstraints = [];
foreach ($categories as $category) {
$categoryConstraints[] = $query->contains('categories', $category);
}

$constraint[] = $query->logicalOr($categoryConstraints);
if (count($categoryConstraints) > 0) {
$constraint[] = $query->logicalOr(...$categoryConstraints);
}

if (!empty($initial)) {
$constraint[] = $query->logicalAnd(
$query->like('lastname', $initial . '%')
);
$constraint[] = $query->logicalAnd($query->like('lastname', $initial . '%'));
}

if (!empty($constraint)) {
$query->matching(
$query->logicalAnd($constraint)
$query->logicalAnd(...$constraint)
);
}

Expand Down
9 changes: 6 additions & 3 deletions Classes/Domain/Repository/NewsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ public function getNewsByAuthor(int $authorUid)
{
$query = $this->createQuery();
$query->matching(
$query->logicalAnd([
$query->equals('newsAuthor.uid', (int)$authorUid),
])
$query->logicalAnd(
...
[
$query->equals('newsAuthor.uid', (int)$authorUid),
]
)
);

return $query->execute();
Expand Down
19 changes: 0 additions & 19 deletions Configuration/TCA/Overrides/sys_category.php

This file was deleted.

2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3_MODE') or die();
defined('TYPO3') or die();

/**
* Add static template
Expand Down
4 changes: 2 additions & 2 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3_MODE') or die();
defined('TYPO3') or die();

/**
* Add new select group for list_type
Expand All @@ -25,7 +25,7 @@
*/
foreach ($plugins as $plugin) {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Mediadreams.md_news_author',
'md_news_author',
ucfirst($plugin),
'LLL:EXT:md_news_author/Resources/Private/Language/locallang.xlf:plugin.' . $plugin . '.title',
'EXT:md_news_author/Resources/Public/Icons/tx_mdnewsauthor_domain_model_newsauthor.svg',
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/tx_news_domain_model_news.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3_MODE') or die();
defined('TYPO3') or die();


$tmp_news_author_columns = [
Expand Down
48 changes: 29 additions & 19 deletions Configuration/TCA/tx_mdnewsauthor_domain_model_newsauthor.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
defined('TYPO3_MODE') or die();
defined('TYPO3') or die();

$versionInformation = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Information\Typo3Version::class);

return [
'ctrl' => [
Expand All @@ -10,7 +12,7 @@
'default_sortby' => 'lastname',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'cruser_id' => 'cruser_id', // TODO: Remove as soon as TYPO3 v11 is not supported anymore
'dividers2tabs' => TRUE,
'versioningWS' => TRUE,
'languageField' => 'sys_language_uid',
Expand All @@ -22,6 +24,9 @@
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'security' => [
'ignorePageTypeRestriction' => true,
],
'searchFields' => 'title,firstname,lastname,bio,image,',
'iconfile' => 'EXT:md_news_author/Resources/Public/Icons/tx_mdnewsauthor_domain_model_newsauthor.svg'
],
Expand Down Expand Up @@ -83,17 +88,7 @@
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
],
],
'default' => 0,
'type' => 'language'
],
],
'l10n_parent' => [
Expand Down Expand Up @@ -127,6 +122,16 @@
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'config' => [
'type' => 'check',
'renderType' => 'checkboxToggle',
'default' => 0,
'items' => $versionInformation->getMajorVersion() < 12 ? [
[
0 => '',
1 => '',
],
] : [
['label' => '', 'value' => ''],
],
],
],
'starttime' => [
Expand All @@ -136,7 +141,7 @@
'type' => 'input',
'renderType' => 'inputDateTime',
'size' => 13,
'eval' => 'datetime',
'eval' => 'datetime,int',
'default' => 0,
'behaviour' => [
'allowLanguageSynchronization' => true
Expand All @@ -150,7 +155,7 @@
'type' => 'input',
'renderType' => 'inputDateTime',
'size' => 13,
'eval' => 'datetime',
'eval' => 'datetime,int',
'default' => 0,
'range' => [
'upper' => mktime(0, 0, 0, 1, 1, 2038)
Expand All @@ -169,7 +174,7 @@
'renderType' => 'selectSingle',
'size' => 1,
'items' => [
['-', ''],
['label' => '-', 'value' => ''],
['LLL:EXT:md_news_author/Resources/Private/Language/locallang_db.xlf:tx_mdnewsauthor_domain_model_newsauthor.gender.female', 'f'],
['LLL:EXT:md_news_author/Resources/Private/Language/locallang_db.xlf:tx_mdnewsauthor_domain_model_newsauthor.gender.male', 'm'],
]
Expand Down Expand Up @@ -251,9 +256,9 @@
'exclude' => true,
'label' => 'LLL:EXT:md_news_author/Resources/Private/Language/locallang_db.xlf:tx_mdnewsauthor_domain_model_newsauthor.email',
'config' => [
'type' => 'input',
'type' => 'input', // TODO: change to `email` as soon, as TYPO3 v11 is not supported anymore
'size' => 30,
'eval' => 'trim,email'
'eval' => 'trim,email' // TODO: remove `email` as soon, as TYPO3 v11 is not supported anymore
],
],
'www' => [
Expand Down Expand Up @@ -383,6 +388,11 @@
],
],
],

'categories' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category',
'config' => [
'type' => 'category'
]
]
],
];
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ author which also shows the news records of the selected author.

## Requirements

- TYPO3 >= 10.4
- ext:news >= 7.0
- ext:numbered_pagination >= 1.0
- TYPO3 >= 11.5
- ext:news >= 9.0
- ext:numbered_pagination >= 1.0.1

### Installation

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 178cf2d

Please sign in to comment.