Skip to content

Commit 5cfc094

Browse files
committed
Merge tag '2.2.1'
Hotfix release 2.2.1 - Translation Update - Reactivate widget types and sorting
2 parents 31ca55f + 734c019 commit 5cfc094

File tree

8 files changed

+156
-24
lines changed

8 files changed

+156
-24
lines changed

.check-author.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ exclude:
77
mapping:
88
"Ingolf Steinhardt <[email protected]>":
99
- "Ingolf Steinhardt <[email protected]>"
10+
- "e-spin <[email protected]>"

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"extra": {
6262
"contao-manager-plugin": "MetaModels\\AttributeTranslatedFileBundle\\ContaoManager\\Plugin",
6363
"branch-alias": {
64-
"dev-feature/2.2.0": "2.2.x-dev"
64+
"dev-hotfix/2.2.1": "2.2.1-dev"
6565
}
6666
},
6767
"config": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
/**
4+
* This file is part of MetaModels/attribute_translatedfile.
5+
*
6+
* (c) 2012-2023 The MetaModels team.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* This project is provided in good faith and hope to be usable by anyone.
12+
*
13+
* @package MetaModels/attribute_translatedfile
14+
* @author Ingolf Steinhardt <[email protected]>
15+
* @copyright 2012-2023 The MetaModels team.
16+
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
17+
* @filesource
18+
*/
19+
20+
declare(strict_types=1);
21+
22+
namespace MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting;
23+
24+
use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator;
25+
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent;
26+
use Doctrine\DBAL\Connection;
27+
use MetaModels\CoreBundle\EventListener\DcGeneral\Table\DcaSetting\AbstractListener;
28+
use MetaModels\IFactory;
29+
30+
/**
31+
* Add the options for the file widget mode.
32+
*/
33+
class FileWidgetModeOptions extends AbstractListener
34+
{
35+
/**
36+
* Invoke the event.
37+
*
38+
* @param GetPropertyOptionsEvent $event The event.
39+
*
40+
* @return void
41+
*/
42+
public function __invoke(GetPropertyOptionsEvent $event): void
43+
{
44+
if (('file_widgetMode' !== $event->getPropertyName())
45+
|| (false === $this->wantToHandle($event))
46+
|| (false === $this->isAttributeTranslatedFile($event))
47+
) {
48+
return;
49+
}
50+
51+
$this->addOptions($event);
52+
}
53+
54+
/**
55+
* Add the options.
56+
*
57+
* @param GetPropertyOptionsEvent $event The event.
58+
*
59+
* @return void
60+
*/
61+
private function addOptions(GetPropertyOptionsEvent $event): void
62+
{
63+
$addOptions = ['downloads', 'gallery'];
64+
65+
$event->setOptions(\array_values(\array_unique(\array_merge($event->getOptions(), $addOptions))));
66+
}
67+
68+
/**
69+
* If used attribute type of file.
70+
*
71+
* @param GetPropertyOptionsEvent $event The event.
72+
*
73+
* @return bool
74+
*/
75+
private function isAttributeTranslatedFile(GetPropertyOptionsEvent $event): bool
76+
{
77+
$builder = $this->connection->createQueryBuilder();
78+
$builder
79+
->select('t.type')
80+
->from('tl_metamodel_attribute', 't')
81+
->where($builder->expr()->eq('t.id', ':id'))
82+
->setParameter('id', $event->getModel()->getProperty('attr_id'));
83+
84+
$statement = $builder->execute();
85+
if (0 === $statement->columnCount()) {
86+
return false;
87+
}
88+
89+
$result = $statement->fetch(\PDO::FETCH_OBJ);
90+
return 'translatedfile' === $result->type;
91+
}
92+
}

src/Resources/config/event_listeners.yml

+10
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ services:
3636
event: dc-general.view.contao2backend.get-property-options
3737
method: removeOption
3838
priority: -1
39+
40+
MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions:
41+
public: false
42+
arguments:
43+
$scopeDeterminator: '@cca.dc-general.scope-matcher'
44+
$factory: '@MetaModels\IFactory'
45+
$connection: '@database_connection'
46+
tags:
47+
- name: kernel.event_listener
48+
event: dc-general.view.contao2backend.get-property-options

src/Resources/contao/languages/de/tl_metamodel_attribute.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* This file is part of MetaModels/attribute_translatedfile.
44
*
5-
* (c) 2012-2020 The MetaModels team.
5+
* (c) 2012-2023 The MetaModels team.
66
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
@@ -12,9 +12,9 @@
1212
* Translations are managed automatically using Transifex. To create a new translation
1313
* or to help to maintain an existing one, please register at transifex.com.
1414
*
15-
* Last-updated: 2020-02-16T16:31:44+01:00
15+
* Last-updated: 2023-02-01T15:59:43+00:00
1616
*
17-
* @copyright 2012-2020 The MetaModels team.
17+
* @copyright 2012-2023 The MetaModels team.
1818
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
1919
* @link https://www.transifex.com/metamodels/public/
2020
* @link https://www.transifex.com/signup/?join_project=metamodels
@@ -23,8 +23,6 @@
2323

2424
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Passen Sie den Dateibaum an.';
2525
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Erlaubt Ihnen, individuelle Optionen für den Dateibaum zu setzen.';
26-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Dateipicker benutzen';
27-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['1'] = 'Falls angewählt wird der Dateipicker anstelle des Dateibaums benutzt.';
2826
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Nur Dateien erlauben';
2927
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['1'] = 'Wählen Sie diese Option, um die Auswahl auf Einzeldateien zu beschränken und die Auswahl kompletter Ordner zu verhindern.';
3028
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Mehrfachauswahl';

src/Resources/contao/languages/fr/tl_metamodel_attribute.php

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
<?php
22
/**
3-
* Translations are managed using Transifex. To create a new translation
4-
* or to help to maintain an existing one, please register at transifex.com.
3+
* This file is part of MetaModels/attribute_translatedfile.
4+
*
5+
* (c) 2012-2023 The MetaModels team.
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
59
*
6-
* @link http://help.transifex.com/intro/translating.html
7-
* @link https://www.transifex.com/projects/p/metamodels/language/fr/
10+
* This project is provided in good faith and hope to be usable by anyone.
811
*
9-
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
12+
* Translations are managed automatically using Transifex. To create a new translation
13+
* or to help to maintain an existing one, please register at transifex.com.
14+
*
15+
* Last-updated: 2023-02-01T15:59:43+00:00
1016
*
11-
* last-updated: 2015-07-11T07:34:25+02:00
17+
* @copyright 2012-2023 The MetaModels team.
18+
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
19+
* @link https://www.transifex.com/metamodels/public/
20+
* @link https://www.transifex.com/signup/?join_project=metamodels
1221
*/
1322

23+
1424
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Personnalier l\'arborescence de fichiers';
1525
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Vous permet de choisir les réglages personnalisés concernant l\'arborescence des fichiers';
16-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Selecteur de fichiers';
1726
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Autoriser seulement les fichiers';
1827
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['1'] = 'Sélectionner cette option pour restreindre l\'explorateur au fichier seulement (répertoires non sélectionnables)';
1928
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Sélection multiple';

src/Resources/contao/languages/ru/tl_metamodel_attribute.php

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
<?php
22
/**
3-
* Translations are managed using Transifex. To create a new translation
4-
* or to help to maintain an existing one, please register at transifex.com.
3+
* This file is part of MetaModels/attribute_translatedfile.
4+
*
5+
* (c) 2012-2023 The MetaModels team.
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
59
*
6-
* @link http://help.transifex.com/intro/translating.html
7-
* @link https://www.transifex.com/projects/p/metamodels/language/ru/
10+
* This project is provided in good faith and hope to be usable by anyone.
11+
*
12+
* Translations are managed automatically using Transifex. To create a new translation
13+
* or to help to maintain an existing one, please register at transifex.com.
814
*
9-
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
15+
* Last-updated: 2023-02-01T15:59:43+00:00
1016
*
11-
* last-updated: 2014-12-14T16:13:25+01:00
17+
* @copyright 2012-2023 The MetaModels team.
18+
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
19+
* @link https://www.transifex.com/metamodels/public/
20+
* @link https://www.transifex.com/signup/?join_project=metamodels
1221
*/
1322

1423

1524
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Настроить дерево файлов';
1625
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Позволяет задать пользовательские параметры для дерева файлов.';
17-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Использовать выбор файлов';
18-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['1'] = 'Если выбрано, использовать выбор файлов вместо дерева файлов.';
1926
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Разрешить только файлы';
2027
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['1'] = 'Выберите опцию для ограничения файлового браузера выбором только файлов (каталоги не выбираются).';
2128
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Множественный выбор';

tests/DependencyInjection/MetaModelsAttributeTranslatedFileExtensionTest.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of MetaModels/attribute_translatedfile.
55
*
6-
* (c) 2012-2021 The MetaModels team.
6+
* (c) 2012-2023 The MetaModels team.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -14,7 +14,8 @@
1414
* @author David Molineus <[email protected]>
1515
* @author Sven Baumann <[email protected]>
1616
* @author Christian Schiffler <[email protected]>
17-
* @copyright 2012-2021 The MetaModels team.
17+
* @author Ingolf Steinhardt <[email protected]>
18+
* @copyright 2012-2023 The MetaModels team.
1819
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
1920
* @filesource
2021
*/
@@ -27,6 +28,7 @@
2728
use MetaModels\AttributeTranslatedFileBundle\EventListener\BuildAttributeListener;
2829
use MetaModels\AttributeTranslatedFileBundle\EventListener\BuildDataDefinitionListener;
2930
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\Attribute\RemoveTypeOptions;
31+
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions;
3032
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\FilterSetting\RemoveAttIdOptions;
3133
use MetaModels\AttributeTranslatedFileBundle\EventListener\Factory\AddAttributeInformation;
3234
use MetaModels\AttributeTranslatedFileBundle\EventListener\ImageSizeOptions;
@@ -65,7 +67,7 @@ public function testFactoryIsRegistered()
6567
$container = $this->getMockBuilder(ContainerBuilder::class)->getMock();
6668

6769
$container
68-
->expects(self::exactly(8))
70+
->expects(self::exactly(9))
6971
->method('setDefinition')
7072
->withConsecutive(
7173
[
@@ -168,6 +170,19 @@ function ($value) {
168170
$this->assertEquals(RemoveAttIdOptions::class, $value->getClass());
169171
$this->assertCount(1, $value->getTag('kernel.event_listener'));
170172

173+
return true;
174+
}
175+
)
176+
],
177+
[
178+
FileWidgetModeOptions::class,
179+
self::callback(
180+
function ($value) {
181+
/** @var Definition $value */
182+
$this->assertInstanceOf(Definition::class, $value);
183+
$this->assertEquals(null, $value->getClass());
184+
$this->assertCount(1, $value->getTag('kernel.event_listener'));
185+
171186
return true;
172187
}
173188
)

0 commit comments

Comments
 (0)