Skip to content

Commit

Permalink
[FEATURE] Upgrade to TYPO3 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Oct 25, 2024
1 parent 3866a92 commit 9f2f539
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ assignees: ''

## Prerequisites

* [ ] Can you reproduce the problem on TYPO3 v10.4 LTS
* [ ] Can you reproduce the problem on TYPO3 v11.5 LTS
* [ ] Can you reproduce the problem on TYPO3 v12.0
* [ ] Can you reproduce the problem on TYPO3 v12.4 LTS
* [ ] Can you reproduce the problem on TYPO3 v13.x
* [ ] Can you reproduce the problem on TYPO3 dev-main
* [ ] Did you [perform a search](https://github.com/simonschaufi/gkh_rss_import/issues)
to see if your bug or enhancement is already reported?
Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Prerequisites

* [ ] Changes have been tested on TYPO3 v12.4 LTS
* [ ] Changes have been tested on TYPO3 v13.x
* [ ] Changes have been tested on TYPO3 dev-main
* [ ] Changes have been tested on PHP 8.1.x
* [ ] Changes have been tested on PHP 8.2.x
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]
php: [8.2, 8.3]

name: "PHP linter - ${{ matrix.php }}"

Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
#- "php:sniff"
- "yaml:lint"
- "xliff:lint"
php: [8.1]
php: [8.2]

name: "Code quality checks"

Expand Down Expand Up @@ -98,8 +98,8 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]
typo3: ["^12.4"]
php: [8.2, 8.3]
typo3: ["^13.0"]
stability: [prefer-lowest, prefer-stable]
# include:
# - typo3: "^13.0"
Expand Down Expand Up @@ -150,8 +150,8 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]
typo3: ["^12.4"]
php: [8.2, 8.3]
typo3: ["^13.0"]
stability: [prefer-lowest, prefer-stable]
# include:
# - typo3: "^13.0"
Expand Down
10 changes: 5 additions & 5 deletions Build/rector/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
__DIR__ . '/../../ext_emconf.php',
__DIR__ . '/../../ext_localconf.php',
]);
$rectorConfig->phpVersion(PhpVersion::PHP_81);
$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->sets([
// Rector sets
LevelSetList::UP_TO_PHP_81,
LevelSetList::UP_TO_PHP_82,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
//SetList::STRICT_BOOLEANS,
Expand All @@ -41,16 +41,16 @@
// TYPO3 Sets
Typo3SetList::CODE_QUALITY,
Typo3SetList::GENERAL,
Typo3LevelSetList::UP_TO_TYPO3_12,
Typo3LevelSetList::UP_TO_TYPO3_13,
]);
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
$rectorConfig->rules([
AddVoidReturnTypeWhereNoReturnRector::class,
ConvertImplicitVariablesToExplicitGlobalsRector::class,
]);
$rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.1.0-8.3.99',
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '12.0.0-12.4.99',
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.2.0-8.4.99',
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.0.0-13.4.99',
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => []
]);
$rectorConfig->importNames();
Expand Down
40 changes: 23 additions & 17 deletions Classes/Controller/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace GertKaaeHansen\GkhRssImport\Controller;

use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Localization\Locales;
use TYPO3\CMS\Core\Localization\LocalizationFactory;
use TYPO3\CMS\Core\Page\DefaultJavaScriptAssetTrait;
Expand Down Expand Up @@ -109,14 +110,14 @@ class AbstractPlugin
/**
* Initializes $this->piVars if $this->prefixId is set to any value
* Will also set $this->LLkey based on the config.language setting.
*
* @param null $_ unused,
*/
public function __construct($_ = null, TypoScriptFrontendController $frontendController = null)
public function __construct(TypoScriptFrontendController $frontendController = null)
{
$this->frontendController = $frontendController instanceof TypoScriptFrontendController ? $frontendController : $GLOBALS['TSFE'];
$this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
$this->LLkey = $this->frontendController->getLanguage()->getTypo3Language();

$language = $this->getRequest()->getAttribute('language') ?? $this->getRequest()->getAttribute('site')->getDefaultLanguage();
$this->LLkey = $language->getTypo3Language();

$locales = GeneralUtility::makeInstance(Locales::class);
if ($locales->isValidLanguageKey($this->LLkey)) {
Expand Down Expand Up @@ -147,25 +148,25 @@ public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
* @param string $class The class name (or the END of it since it will be prefixed by $this->prefixId.'-')
* @return string The combined class name (with the correct prefix)
*/
public function pi_getClassName(string $class): string
public function getClassName(string $class): string
{
return str_replace('_', '-', $this->prefixId) . ($this->prefixId ? '-' : '') . $class;
return str_replace('_', '-', $this->prefixId) . ($this->prefixId !== '' ? '-' : '') . $class;
}

/**
* Returns the class-attribute with the correctly prefixed classname
* Using pi_getClassName()
* Using getClassName()
*
* @param string $class The class name(s) (suffix) - separate multiple classes with commas
* @param string $addClasses Additional class names which should not be prefixed - separate multiple classes with commas
* @return string A "class" attribute with value and a single space char before it.
*/
public function pi_classParam(string $class, string $addClasses = ''): string
public function classParam(string $class, string $addClasses = ''): string
{
$output = '';
$classNames = GeneralUtility::trimExplode(',', $class);
foreach ($classNames as $className) {
$output .= ' ' . $this->pi_getClassName($className);
$output .= ' ' . $this->getClassName($className);
}
$additionalClassNames = GeneralUtility::trimExplode(',', $addClasses);
foreach ($additionalClassNames as $additionalClassName) {
Expand All @@ -181,7 +182,7 @@ public function pi_classParam(string $class, string $addClasses = ''): string
* @param string $str HTML content to wrap in the div-tags with the "main class" of the plugin
* @return string HTML content wrapped, ready to return to the parent object.
*/
public function pi_wrapInBaseClass(string $str): string
public function wrapInBaseClass(string $str): string
{
$content = '<div class="' . str_replace('_', '-', $this->prefixId) . '">
' . $str . '
Expand Down Expand Up @@ -213,7 +214,7 @@ public function pi_wrapInBaseClass(string $str): string
* @param string $alternativeLabel Alternative string to return IF no value is found set for the key, neither for the local language nor the default.
* @return string|null The value from LOCAL_LANG.
*/
public function pi_getLL(string $key, string $alternativeLabel = ''): ?string
public function getLL(string $key, string $alternativeLabel = ''): ?string
{
$word = null;
if (
Expand Down Expand Up @@ -259,7 +260,7 @@ public function pi_getLL(string $key, string $alternativeLabel = ''): ?string
*
* @param string $languageFilePath path to the plugin language file in format EXT:....
*/
public function pi_loadLL(string $languageFilePath = ''): void
public function loadLL(string $languageFilePath = ''): void
{
if ($this->LOCAL_LANG_loaded) {
return;
Expand Down Expand Up @@ -321,7 +322,7 @@ public function pi_loadLL(string $languageFilePath = ''): void
*
* @param string $field Field name to convert
*/
public function pi_initPIflexForm(string $field = 'pi_flexform'): void
public function initPIflexForm(string $field = 'pi_flexform'): void
{
// Converting flexform data into array
$fieldData = $this->cObj->data[$field] ?? null;
Expand All @@ -343,7 +344,7 @@ public function pi_initPIflexForm(string $field = 'pi_flexform'): void
* @param string $value Value pointer, eg. "vDEF
* @return string|null The content.
*/
public function pi_getFFvalue(
public function getFFvalue(
?array $T3FlexForm_array,
string $fieldName,
string $sheet = 'sDEF',
Expand All @@ -356,7 +357,7 @@ public function pi_getFFvalue(

$sheetArray = $T3FlexForm_array['data'][$sheet][$lang] ?? null;
if (is_array($sheetArray)) {
return $this->pi_getFFvalueFromSheetArray($sheetArray, explode('/', $fieldName), $value);
return $this->getFFvalueFromSheetArray($sheetArray, explode('/', $fieldName), $value);
}
return null;
}
Expand All @@ -368,9 +369,9 @@ public function pi_getFFvalue(
* @param array $fieldNameArr Array where each value points to a key in the FlexForms content - the input array will have the value returned pointed to by these keys. All integer keys will not take their integer counterparts, but rather traverse the current position in the array and return element number X (whether this is right behavior is not settled yet...)
* @param string $value Value for outermost key, typ. "vDEF" depending on language.
* @return mixed The value, typ. string.
* @see pi_getFFvalue()
* @see getFFvalue()
*/
public function pi_getFFvalueFromSheetArray(array $sheetArray, array $fieldNameArr, string $value)
public function getFFvalueFromSheetArray(array $sheetArray, array $fieldNameArr, string $value)
{
$tempArr = $sheetArray;
foreach ($fieldNameArr as $v) {
Expand All @@ -391,4 +392,9 @@ public function pi_getFFvalueFromSheetArray(array $sheetArray, array $fieldNameA
}
return $tempArr[$value] ?? '';
}

private function getRequest(): ServerRequest
{
return $GLOBALS['TYPO3_REQUEST'];
}
}
38 changes: 19 additions & 19 deletions Classes/Controller/RssImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class RssImportController extends AbstractPlugin

protected DateFormatter $dateFormatter;

public function __construct($_ = null, TypoScriptFrontendController $frontendController = null)
public function __construct(TypoScriptFrontendController $frontendController = null)
{
parent::__construct($_, $frontendController);
parent::__construct($frontendController);

$this->cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$this->rssService = GeneralUtility::makeInstance(LastRssService::class);
Expand All @@ -78,8 +78,8 @@ public function __construct($_ = null, TypoScriptFrontendController $frontendCon
public function main(string $content, array $conf): string
{
$this->conf = $conf;
$this->pi_loadLL('EXT:gkh_rss_import/Resources/Private/Language/locallang.xlf');
$this->pi_initPIflexForm();
$this->loadLL('EXT:gkh_rss_import/Resources/Private/Language/locallang.xlf');
$this->initPIflexForm();
$this->mergeFlexFormValuesIntoConf();

if (empty($this->conf['rssFeed'])) {
Expand All @@ -102,7 +102,7 @@ public function main(string $content, array $conf): string

$this->template = $this->getTemplate();

return $this->pi_wrapInBaseClass($this->render());
return $this->wrapInBaseClass($this->render());
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ protected function getTemplate(): string
*/
protected function render(): string
{
$markerArray['###BOX###'] = $this->pi_classParam('rss_box');
$markerArray['###BOX###'] = $this->classParam('rss_box');

// Try to load and parse RSS file
$rss = $this->rssService->getFeed();
Expand All @@ -170,13 +170,13 @@ protected function render(): string
$markerArray['###IMAGE###'] = $this->getImage($rss, $target);

// title
$markerArray['###CLASS_RSS_TITLE###'] = $this->pi_classParam('rss_title');
$markerArray['###CLASS_RSS_TITLE###'] = $this->classParam('rss_title');
$markerArray['###URL###'] = $this->removeDoubleHTTP($rss['link']);
$markerArray['###TARGET###'] = $target;
// TODO: htmlspecialchars?
$markerArray['###RSS_TITLE###'] = $rss['title'];
// description
$markerArray['###CLASS_DESCRIPTION###'] = $this->pi_classParam('description');
$markerArray['###CLASS_DESCRIPTION###'] = $this->classParam('description');
// TODO: htmlspecialchars?
$markerArray['###DESCRIPTION###'] = smart_trim($rss['description'], (int)$this->conf['headerLength']);

Expand Down Expand Up @@ -223,7 +223,7 @@ protected function getImage(array $rss, string $target): string
$location = $this->getCachedImageLocation($rss['image_url']);

if (!file_exists($location)) {
throw new \RuntimeException(sprintf('File %s could not be found!', $location));
throw new \RuntimeException(sprintf('File %s could not be found!', $location), 9859542783);
}

// Pass the combination of TS-defined values and php processing through the IMAGE cObject function
Expand All @@ -237,7 +237,7 @@ protected function getImage(array $rss, string $target): string
]);
return sprintf(
'<div%s><a href="%s" target="%s">%s</a></div><br />',
$this->pi_classParam('RSS_h_image'),
$this->classParam('RSS_h_image'),
$this->removeDoubleHTTP($rss['image_link']),
$target,
$imgOutput
Expand Down Expand Up @@ -282,16 +282,16 @@ protected function renderItem(array $item, string $itemSubpart, string $target,
$this->getTypoScriptFrontendController()->register['RSS_IMPORT_ITEM_LINK'] = $item['link'];

// Get item header
$markerArray['###CLASS_HEADER###'] = $this->pi_classParam('header');
$markerArray['###CLASS_HEADER###'] = $this->classParam('header');
$markerArray['###HEADER_URL###'] = $this->removeDoubleHTTP($item['link']);
$markerArray['###HEADER_TARGET###'] = $target;
// TODO: htmlspecialchars?
$markerArray['###HEADER###'] = smart_trim($item['title'], (int)$this->conf['headerLength']);

// Get published date, author and category
$markerArray['###CLASS_PUBBOX###'] = $this->pi_classParam('pubbox');
$markerArray['###CLASS_PUBBOX###'] = $this->classParam('pubbox');
if ($item['pubDate'] !== '01/01/1970') {
$markerArray['###CLASS_RSS_DATE###'] = $this->pi_classParam('date');
$markerArray['###CLASS_RSS_DATE###'] = $this->classParam('date');

$pubDate = strtotime((string)$item['pubDate']);
if ($pubDate !== false) {
Expand All @@ -305,15 +305,15 @@ protected function renderItem(array $item, string $itemSubpart, string $target,
$markerArray['###RSS_DATE###'] = '';
}
}
$markerArray['###CLASS_AUTHOR###'] = $this->pi_classParam('author');
$markerArray['###CLASS_AUTHOR###'] = $this->classParam('author');
// TODO: htmlspecialchars?
$markerArray['###AUTHOR###'] = $item['author'] ?? '';
$markerArray['###CLASS_CATEGORY###'] = $this->pi_classParam('category');
$markerArray['###CLASS_CATEGORY###'] = $this->classParam('category');
// TODO: htmlspecialchars?
$markerArray['###CATEGORY###'] = htmlentities($item['category'] ?? '');

// Get item content
$markerArray['###CLASS_SUMMARY###'] = $this->pi_classParam('content');
$markerArray['###CLASS_SUMMARY###'] = $this->classParam('content');
$itemSummary = $item['description'];

// for UserFunction smart_trim
Expand All @@ -325,9 +325,9 @@ protected function renderItem(array $item, string $itemSubpart, string $target,
// no htmlspecialchars as this might contain html which should be rendered
$markerArray['###SUMMARY###'] = $itemSummary;

$markerArray['###CLASS_DOWNLOAD###'] = $this->pi_classParam('download');
$markerArray['###CLASS_DOWNLOAD###'] = $this->classParam('download');
if (isset($item['enclosure']['prop']['url']) && $item['enclosure']['prop']['url'] !== '') {
$download = $this->pi_getLL('Download');
$download = $this->getLL('Download');
if (isset($item['enclosure']['prop']['length'])) {
$download .= ' (' . round((float)$item['enclosure']['prop']['length'] / (1024 * 1024), 1) . ' MB)';
}
Expand Down Expand Up @@ -429,7 +429,7 @@ protected function mergeFlexFormValuesIntoConf(): void
*/
protected function flexFormValue(string $variable, string $sheet): ?string
{
return $this->pi_getFFvalue($this->cObj->data['pi_flexform'] ?? null, $variable, $sheet);
return $this->getFFvalue($this->cObj->data['pi_flexform'] ?? null, $variable, $sheet);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Classes/Service/LastRssService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ public function __construct()
$this->rss->cache_dir = $path;
}

/**
* @return array|bool|mixed
*/
public function getFeed(): mixed
public function getFeed(): bool|array
{
if ($this->url === null || $this->url === '') {
throw new \RuntimeException('Feed URL is not set.', 1526816720);
Expand Down
1 change: 1 addition & 0 deletions Configuration/page.tsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:gkh_rss_import/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.typoscript">
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Latest Stable Version](https://poser.pugx.org/gkh/gkh-rss-import/v/stable)](https://packagist.org/packages/gkh/gkh-rss-import)
[![Total Downloads](https://poser.pugx.org/gkh/gkh-rss-import/downloads)](https://packagist.org/packages/gkh/gkh-rss-import)
[![License](https://poser.pugx.org/gkh/gkh-rss-import/license)](https://packagist.org/packages/gkh/gkh-rss-import)
[![TYPO3](https://img.shields.io/badge/TYPO3-12-orange.svg)](https://get.typo3.org/version/12)
[![TYPO3](https://img.shields.io/badge/TYPO3-13-orange.svg)](https://get.typo3.org/version/13)

Fetch an RSS / Atom Feed and display its content on the Frontend.

Expand Down Expand Up @@ -46,7 +46,7 @@ Download and install the [extension][3] with the extension manager module in the

| Branch | TYPO3 | PHP | Support / Development |
|----------|-------------|-----------|-----------------------------|
| dev-main | 12.0 - 12.0 | 8.1 - 8.3 | unstable development branch |
| dev-main | 13.0 - 13.0 | 8.2 - 8.3 | unstable development branch |
| 9.x | 11.5 - 11.5 | 7.4 - 8.1 | bugfixes, security updates |
| 8.x | 9.5 - 11.5 | 7.2 - 7.4 | no more support |
| 6.x | 8.7 - 8.7 | 7.0 - 7.4 | no more support |
Expand Down
Loading

0 comments on commit 9f2f539

Please sign in to comment.