-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix release 2.2.1 - Translation Update - Reactivate widget types and sorting
- Loading branch information
Showing
8 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/EventListener/DcGeneral/Table/DcaSetting/FileWidgetModeOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 16 additions & 7 deletions
23
src/Resources/contao/languages/fr/tl_metamodel_attribute.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 15 additions & 8 deletions
23
src/Resources/contao/languages/ru/tl_metamodel_attribute.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters