Skip to content

Commit

Permalink
Merge tag '2.2.1'
Browse files Browse the repository at this point in the history
Hotfix release 2.2.1

- Translation Update
- Reactivate widget types and sorting
  • Loading branch information
stefanheimes committed Jun 18, 2023
2 parents 31ca55f + 734c019 commit 5cfc094
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 24 deletions.
1 change: 1 addition & 0 deletions .check-author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ exclude:
mapping:
"Ingolf Steinhardt <info@e-spin.de>":
- "Ingolf Steinhardt <git@e-spin.de>"
- "e-spin <gitlab@e-spin.de>"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"extra": {
"contao-manager-plugin": "MetaModels\\AttributeTranslatedFileBundle\\ContaoManager\\Plugin",
"branch-alias": {
"dev-feature/2.2.0": "2.2.x-dev"
"dev-hotfix/2.2.1": "2.2.1-dev"
}
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

/**
* This file is part of MetaModels/attribute_translatedfile.
*
* (c) 2012-2023 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package MetaModels/attribute_translatedfile
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2023 The MetaModels team.
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/

declare(strict_types=1);

namespace MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting;

use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent;
use Doctrine\DBAL\Connection;
use MetaModels\CoreBundle\EventListener\DcGeneral\Table\DcaSetting\AbstractListener;
use MetaModels\IFactory;

/**
* Add the options for the file widget mode.
*/
class FileWidgetModeOptions extends AbstractListener
{
/**
* Invoke the event.
*
* @param GetPropertyOptionsEvent $event The event.
*
* @return void
*/
public function __invoke(GetPropertyOptionsEvent $event): void
{
if (('file_widgetMode' !== $event->getPropertyName())
|| (false === $this->wantToHandle($event))
|| (false === $this->isAttributeTranslatedFile($event))
) {
return;
}

$this->addOptions($event);
}

/**
* Add the options.
*
* @param GetPropertyOptionsEvent $event The event.
*
* @return void
*/
private function addOptions(GetPropertyOptionsEvent $event): void
{
$addOptions = ['downloads', 'gallery'];

$event->setOptions(\array_values(\array_unique(\array_merge($event->getOptions(), $addOptions))));
}

/**
* If used attribute type of file.
*
* @param GetPropertyOptionsEvent $event The event.
*
* @return bool
*/
private function isAttributeTranslatedFile(GetPropertyOptionsEvent $event): bool
{
$builder = $this->connection->createQueryBuilder();
$builder
->select('t.type')
->from('tl_metamodel_attribute', 't')
->where($builder->expr()->eq('t.id', ':id'))
->setParameter('id', $event->getModel()->getProperty('attr_id'));

$statement = $builder->execute();
if (0 === $statement->columnCount()) {
return false;
}

$result = $statement->fetch(\PDO::FETCH_OBJ);
return 'translatedfile' === $result->type;
}
}
10 changes: 10 additions & 0 deletions src/Resources/config/event_listeners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ services:
event: dc-general.view.contao2backend.get-property-options
method: removeOption
priority: -1

MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions:
public: false
arguments:
$scopeDeterminator: '@cca.dc-general.scope-matcher'
$factory: '@MetaModels\IFactory'
$connection: '@database_connection'
tags:
- name: kernel.event_listener
event: dc-general.view.contao2backend.get-property-options
8 changes: 3 additions & 5 deletions src/Resources/contao/languages/de/tl_metamodel_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of MetaModels/attribute_translatedfile.
*
* (c) 2012-2020 The MetaModels team.
* (c) 2012-2023 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,9 +12,9 @@
* Translations are managed automatically using Transifex. To create a new translation
* or to help to maintain an existing one, please register at transifex.com.
*
* Last-updated: 2020-02-16T16:31:44+01:00
* Last-updated: 2023-02-01T15:59:43+00:00
*
* @copyright 2012-2020 The MetaModels team.
* @copyright 2012-2023 The MetaModels team.
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
* @link https://www.transifex.com/metamodels/public/
* @link https://www.transifex.com/signup/?join_project=metamodels
Expand All @@ -23,8 +23,6 @@

$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Passen Sie den Dateibaum an.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Erlaubt Ihnen, individuelle Optionen für den Dateibaum zu setzen.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Dateipicker benutzen';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['1'] = 'Falls angewählt wird der Dateipicker anstelle des Dateibaums benutzt.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Nur Dateien erlauben';
$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.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Mehrfachauswahl';
Expand Down
23 changes: 16 additions & 7 deletions src/Resources/contao/languages/fr/tl_metamodel_attribute.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
<?php
/**
* Translations are managed using Transifex. To create a new translation
* or to help to maintain an existing one, please register at transifex.com.
* This file is part of MetaModels/attribute_translatedfile.
*
* (c) 2012-2023 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://help.transifex.com/intro/translating.html
* @link https://www.transifex.com/projects/p/metamodels/language/fr/
* This project is provided in good faith and hope to be usable by anyone.
*
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
* Translations are managed automatically using Transifex. To create a new translation
* or to help to maintain an existing one, please register at transifex.com.
*
* Last-updated: 2023-02-01T15:59:43+00:00
*
* last-updated: 2015-07-11T07:34:25+02:00
* @copyright 2012-2023 The MetaModels team.
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
* @link https://www.transifex.com/metamodels/public/
* @link https://www.transifex.com/signup/?join_project=metamodels
*/


$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Personnalier l\'arborescence de fichiers';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Vous permet de choisir les réglages personnalisés concernant l\'arborescence des fichiers';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Selecteur de fichiers';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Autoriser seulement les fichiers';
$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)';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Sélection multiple';
Expand Down
23 changes: 15 additions & 8 deletions src/Resources/contao/languages/ru/tl_metamodel_attribute.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<?php
/**
* Translations are managed using Transifex. To create a new translation
* or to help to maintain an existing one, please register at transifex.com.
* This file is part of MetaModels/attribute_translatedfile.
*
* (c) 2012-2023 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://help.transifex.com/intro/translating.html
* @link https://www.transifex.com/projects/p/metamodels/language/ru/
* This project is provided in good faith and hope to be usable by anyone.
*
* Translations are managed automatically using Transifex. To create a new translation
* or to help to maintain an existing one, please register at transifex.com.
*
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
* Last-updated: 2023-02-01T15:59:43+00:00
*
* last-updated: 2014-12-14T16:13:25+01:00
* @copyright 2012-2023 The MetaModels team.
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
* @link https://www.transifex.com/metamodels/public/
* @link https://www.transifex.com/signup/?join_project=metamodels
*/


$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['0'] = 'Настроить дерево файлов';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_customFiletree']['1'] = 'Позволяет задать пользовательские параметры для дерева файлов.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['0'] = 'Использовать выбор файлов';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filePicker']['1'] = 'Если выбрано, использовать выбор файлов вместо дерева файлов.';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['0'] = 'Разрешить только файлы';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_filesOnly']['1'] = 'Выберите опцию для ограничения файлового браузера выбором только файлов (каталоги не выбираются).';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['file_multiple']['0'] = 'Множественный выбор';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_translatedfile.
*
* (c) 2012-2021 The MetaModels team.
* (c) 2012-2023 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,8 @@
* @author David Molineus <david.molineus@netzmacht.de>
* @author Sven Baumann <baumann.sv@gmail.com>
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @copyright 2012-2021 The MetaModels team.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2023 The MetaModels team.
* @license https://github.com/MetaModels/attribute_translatedfile/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand All @@ -27,6 +28,7 @@
use MetaModels\AttributeTranslatedFileBundle\EventListener\BuildAttributeListener;
use MetaModels\AttributeTranslatedFileBundle\EventListener\BuildDataDefinitionListener;
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\Attribute\RemoveTypeOptions;
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\DcaSetting\FileWidgetModeOptions;
use MetaModels\AttributeTranslatedFileBundle\EventListener\DcGeneral\Table\FilterSetting\RemoveAttIdOptions;
use MetaModels\AttributeTranslatedFileBundle\EventListener\Factory\AddAttributeInformation;
use MetaModels\AttributeTranslatedFileBundle\EventListener\ImageSizeOptions;
Expand Down Expand Up @@ -65,7 +67,7 @@ public function testFactoryIsRegistered()
$container = $this->getMockBuilder(ContainerBuilder::class)->getMock();

$container
->expects(self::exactly(8))
->expects(self::exactly(9))
->method('setDefinition')
->withConsecutive(
[
Expand Down Expand Up @@ -168,6 +170,19 @@ function ($value) {
$this->assertEquals(RemoveAttIdOptions::class, $value->getClass());
$this->assertCount(1, $value->getTag('kernel.event_listener'));

return true;
}
)
],
[
FileWidgetModeOptions::class,
self::callback(
function ($value) {
/** @var Definition $value */
$this->assertInstanceOf(Definition::class, $value);
$this->assertEquals(null, $value->getClass());
$this->assertCount(1, $value->getTag('kernel.event_listener'));

return true;
}
)
Expand Down

0 comments on commit 5cfc094

Please sign in to comment.