Skip to content

Commit

Permalink
[TASK] Backport changes for TYPO3 11
Browse files Browse the repository at this point in the history
  • Loading branch information
astehlik committed Jul 3, 2023
1 parent 095488f commit 8a50e70
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 55 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ jobs:
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_run_tests.sh -s cgl -n -p ${{ env.MAIN_PHP_VERSION }}
bash .Build/bin/t3_run_tests.sh -s cgl -n -p 8.1
"php-unit-tests":
name: "PHP Unit tests"
strategy:
matrix:
php_version: ["8.1", "8.2"]
php_version: ["7.4", "8.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
name: "PHP linting"
strategy:
matrix:
php_version: ["8.1", "8.2"]
php_version: ["7.4", "8.0", "8.1", "8.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -191,4 +191,4 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.MAIN_PHP_VERSION }}"
- run: php .Build/bin/typo3scan scan --target 12 .
- run: php .Build/bin/typo3scan scan --target 11 .
4 changes: 2 additions & 2 deletions Classes/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function renderMediaAction(): ResponseInterface
$contentObject = $this->getCurrentContentObject();

try {
$uid = $contentObject->data['_LOCALIZED_UID'] ?? $contentObject->data['uid'];
$uid = (int)($contentObject->data['_LOCALIZED_UID'] ?? $contentObject->data['uid']);
$media = $this->mediaRepository->findOneByContentElementUid($uid);
} catch (MediaException $mediaException) {
return $this->htmlResponse($this->translate('exception.' . $mediaException->getCode()));
Expand Down Expand Up @@ -85,7 +85,7 @@ public function videoAction(Video $video): ResponseInterface

private function getCurrentContentObject(): ContentObjectRenderer
{
return $this->request->getAttribute('currentContentObject');
return $this->configurationManager->getContentObject();
}

private function renderMedia(Media $media): ResponseInterface
Expand Down
4 changes: 4 additions & 0 deletions Classes/Domain/Model/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public function getParentTable(): string

public function getTracks(): ObjectStorage
{
if (!$this->tracks instanceof ObjectStorage) {
$this->tracks = new ObjectStorage();
}

return $this->tracks;
}

Expand Down
20 changes: 10 additions & 10 deletions Configuration/TCA/Overrides/sys_file_reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
'renderType' => 'selectSingle',
'items' => [
[
'label' => $lllPrefix . 'tx_html5mediakit_track_kind.I.subtitles',
'value' => 'subtitles',
$lllPrefix . 'tx_html5mediakit_track_kind.I.subtitles',
'subtitles',
],
[
'label' => $lllPrefix . 'tx_html5mediakit_track_kind.I.captions',
'value' => 'captions',
$lllPrefix . 'tx_html5mediakit_track_kind.I.captions',
'captions',
],
[
'label' => $lllPrefix . 'tx_html5mediakit_track_kind.I.descriptions',
'value' => 'descriptions',
$lllPrefix . 'tx_html5mediakit_track_kind.I.descriptions',
'descriptions',
],
[
'label' => $lllPrefix . 'tx_html5mediakit_track_kind.I.chapters',
'value' => 'chapters',
$lllPrefix . 'tx_html5mediakit_track_kind.I.chapters',
'chapters',
],
[
'label' => $lllPrefix . 'tx_html5mediakit_track_kind.I.metadata',
'value' => 'metadata',
$lllPrefix . 'tx_html5mediakit_track_kind.I.metadata',
'metadata',
],
],
'default' => 'subtitles',
Expand Down
53 changes: 35 additions & 18 deletions Configuration/TCA/tx_html5mediakit_domain_model_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

use Sto\Html5mediakit\Domain\Model\Enumeration\MediaType;
use TYPO3\CMS\Core\Resource\AbstractFile;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

$languagePrefix = 'LLL:EXT:html5mediakit/Resources/Private/Language/locallang_db.xlf:';
$languagePrefixColumn = $languagePrefix . 'tx_html5mediakit_domain_model_media.';
$languagePrefixCsh = 'LLL:EXT:html5mediakit/Resources/Private/Language/locallang_csh_media.xlf:';
$lllAddImageFileReference = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference';

/** @param array|string $allowedFileTypes */
$buildFileFieldConfig = function (
string|array $allowedFileTypes,
string $fieldName,
$allowedFileTypes,
int $maxitems = 1,
string $showitem = '',
string $createNewRelationLinkTitle = '',
string $createNewRelationLinkTitle = ''
) use (
$languagePrefix
) {
Expand All @@ -26,9 +29,15 @@
$createNewRelationLinkTitle = $languagePrefix . 'choose_file';
}

if (is_array($allowedFileTypes)) {
$allowedFileTypes = implode(',', $allowedFileTypes);
}

if ($allowedFileTypes === 'common-image-types') {
$allowedFileTypes = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
}

$config = [
'type' => 'file',
'allowed' => $allowedFileTypes,
'appearance' => [
'showPossibleLocalizationRecords' => true,
'showAllLocalizationLink' => $allowsMultipleFiles,
Expand Down Expand Up @@ -61,7 +70,11 @@
$config['maxitems'] = $maxitems;
}

return $config;
return ExtensionManagementUtility::getFileFieldTCAConfig(
$fieldName,
$config,
$allowedFileTypes
);
};

return [
Expand All @@ -82,7 +95,6 @@
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'security' => ['ignorePageTypeRestriction' => true],
],
'columns' => [
'type' => [
Expand All @@ -93,12 +105,12 @@
'renderType' => 'selectSingle',
'items' => [
[
'label' => $languagePrefixColumn . 'type.I.video',
'value' => MediaType::VIDEO,
$languagePrefixColumn . 'type.I.video',
MediaType::VIDEO,
],
[
'label' => $languagePrefixColumn . 'type.I.audio',
'value' => MediaType::AUDIO,
$languagePrefixColumn . 'type.I.audio',
MediaType::AUDIO,
],
],
'default' => MediaType::VIDEO,
Expand All @@ -110,6 +122,7 @@
'label' => $languagePrefixColumn . 'tracks',
'description' => $languagePrefixCsh . 'tracks.description',
'config' => $buildFileFieldConfig(
'tracks',
['vtt'],
0,
'tx_html5mediakit_track_kind, tx_html5mediakit_track_label, tx_html5mediakit_track_srclang',
Expand Down Expand Up @@ -141,8 +154,8 @@
'renderType' => 'selectSingle',
'items' => [
[
'label' => '',
'value' => 0,
'',
0,
],
],
'foreign_table' => 'tx_html5mediakit_domain_model_media',
Expand All @@ -154,12 +167,13 @@
'mp3' => [
'label' => $languagePrefixColumn . 'mp3',
'description' => $languagePrefixCsh . 'mp3.description',
'config' => $buildFileFieldConfig(['mp3']),
'config' => $buildFileFieldConfig('mp3', ['mp3']),
],
'ogg' => [
'label' => $languagePrefixColumn . 'ogg',
'description' => $languagePrefixCsh . 'ogg.description',
'config' => $buildFileFieldConfig(
'ogg',
[
'ogg',
'ogx',
Expand All @@ -169,18 +183,21 @@
'h264' => [
'label' => $languagePrefixColumn . 'h264',
'description' => $languagePrefixCsh . 'h264.description',
'config' => $buildFileFieldConfig(['mp4']),
'config' => $buildFileFieldConfig('h264', ['mp4']),
],
'ogv' => [
'label' => $languagePrefixColumn . 'ogv',
'description' => $languagePrefixCsh . 'ogv.description',
'config' => $buildFileFieldConfig(['ogv']),
'config' => $buildFileFieldConfig('ogv', ['ogv']),
],
'poster' => [
'label' => $languagePrefixColumn . 'poster',
'config' => $buildFileFieldConfig(
allowedFileTypes: 'common-image-types',
createNewRelationLinkTitle: $lllAddImageFileReference
'poster',
'common-image-types',
1,
'',
$lllAddImageFileReference
),
],
'sys_language_uid' => [
Expand All @@ -191,7 +208,7 @@
'web_m' => [
'label' => $languagePrefixColumn . 'web_m',
'description' => $languagePrefixCsh . 'web_m.description',
'config' => $buildFileFieldConfig(['webm']),
'config' => $buildFileFieldConfig('web_m', ['webm']),
],
'content_element' => [
'config' => ['type' => 'passthrough'],
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ project = html5mediakit
# ... (recommended) version, displayed next to title (desktop) and in <meta name="book-version"
# .................................................................................

release = 12.0.0
release = 11.1.0

# .................................................................................
# ... (recommended) displayed in footer
Expand Down
8 changes: 3 additions & 5 deletions Tests/Acceptance/Backend/ContentCreationCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ public function html5MediaCanBeCreated(BackendTester $I, PageTree $pageTree, Mod

$I->click('typo3-backend-new-content-element-wizard-button');

$modalDialog->canSeeDialog();
$I->executeJS(
'document.querySelector(\'typo3-backend-new-content-element-wizard\').shadowRoot'
. '.querySelector(\'button[data-identifier="common_html5mediakit_mediarenderer"]\').click()'
);
$I->switchToIFrame();
$I->waitForElement('.t3-new-content-element-wizard-inner');
$I->click('Video / Audio');

$I->switchToContentFrame();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ abstract class AbstractMediaControllerTestCase extends FunctionalTestCase
{
protected const FIXTURES_PATH = 'EXT:html5mediakit/Tests/Functional/Fixtures';

protected array $coreExtensionsToLoad = ['fluid_styled_content'];
protected $coreExtensionsToLoad = ['fluid_styled_content'];

protected array $testExtensionsToLoad = ['typo3conf/ext/html5mediakit'];
protected $testExtensionsToLoad = ['typo3conf/ext/html5mediakit'];

protected array $typoscriptConstantFiles = [
'EXT:fluid_styled_content/Configuration/TypoScript/constants.typoscript',
Expand Down
11 changes: 4 additions & 7 deletions Tests/Functional/Controller/MediaController/RelatedTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

use Sto\Html5mediakit\Domain\Repository\MediaRepository;
use Sto\Html5mediakit\Tests\Unit\Controller\MediaControllerMock;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

class RelatedTableTest extends AbstractMediaControllerTestCase
Expand All @@ -26,13 +24,12 @@ public function testMediaControllerShowsVideo(): void
'parent_record' => 23,
];

$baseRequest = (new ServerRequest())
->withAttribute('extbase', new ExtbaseRequestParameters())
->withAttribute('currentContentObject', $contentObject);
$configurationManagerMock = $this->createMock(ConfigurationManagerInterface::class);
$configurationManagerMock->method('getContentObject')->willReturn($contentObject);

$controller = new MediaControllerMock();
$controller->injectMediaRepository($container->get(MediaRepository::class));
$controller->setRequest(new Request($baseRequest));
$controller->injectConfigurationManager($configurationManagerMock);

$response = $controller->renderMediaForRelatedTableAction();

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
"license": "GPL-3.0-or-later",
"type": "typo3-cms-extension",
"require": {
"php": "^8.1",
"typo3/cms-core": "^12.4",
"php": "^7.4 || ^8.0",
"typo3/cms-core": "^11.5",
"typo3/cms-extbase": "*",
"typo3/cms-frontend": "*"
},
"require-dev": {
"de-swebhosting/php-codestyle": "^5.0",
"de-swebhosting/typo3-extension-buildtools": "dev-TYPO3_12",
"de-swebhosting/typo3-extension-buildtools": "dev-TYPO3_11",
"ergebnis/composer-normalize": "^2.28",
"friendsofphp/php-cs-fixer": "^3.14",
"michielroos/typo3scan": "^1.7",
"squizlabs/php_codesniffer": "^3.7",
"symfony/dom-crawler": "^6.3",
"symfony/dom-crawler": "^5.4",
"typo3/cms-fluid-styled-content": "*"
},
"replace": {
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
'author' => 'Alexander Stehlik',
'author_email' => '[email protected]',
'author_company' => '',
'version' => '12.0.0',
'version' => '11.1.0',
'constraints' => [
'depends' => [
'typo3' => '12.4.0-12.4.99',
'typo3' => '11.5.0-11.5.99',
'extbase' => '',
],
'conflicts' => [],
Expand Down
7 changes: 7 additions & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

/** @noinspection PhpFullyQualifiedNameUsageInspection */

defined('TYPO3') or die();

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_html5mediakit_domain_model_media');

0 comments on commit 8a50e70

Please sign in to comment.