Skip to content

Commit

Permalink
see cl 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Patzer committed Sep 12, 2019
1 parent 77f5d25 commit b3944dd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.5.0] - 2019-09-12

#### Added
- random placeholder mode for image config element type

## [1.4.0] - 2019-08-29

#### Fixed
Expand Down
2 changes: 2 additions & 0 deletions src/Backend/ListConfigElement.php
Expand Up @@ -25,10 +25,12 @@ class ListConfigElement extends Backend
const PLACEHOLDER_IMAGE_MODE_NONE = 'none';
const PLACEHOLDER_IMAGE_MODE_GENDERED = 'gendered';
const PLACEHOLDER_IMAGE_MODE_SIMPLE = 'simple';
const PLACEHOLDER_IMAGE_MODE_RANDOM = 'random';

const PLACEHOLDER_IMAGE_MODES = [
self::PLACEHOLDER_IMAGE_MODE_GENDERED,
self::PLACEHOLDER_IMAGE_MODE_SIMPLE,
self::PLACEHOLDER_IMAGE_MODE_RANDOM,
];

public function checkPermission()
Expand Down
7 changes: 7 additions & 0 deletions src/ConfigElementType/ImageConfigElementType.php
Expand Up @@ -57,6 +57,13 @@ public function addToItemData(ItemInterface $item, ListConfigElementModel $listC
$image = $listConfigElement->placeholderImage;

break;

case ListConfigElement::PLACEHOLDER_IMAGE_MODE_RANDOM:
$images = StringUtil::deserialize($listConfigElement->placeholderImages, true);

if (null !== ($randomKey = array_rand($images))) {
$image = $images[$randomKey];
}
}
} else {
return;
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/contao/dca/tl_list_config_element.php
Expand Up @@ -77,6 +77,7 @@
'subpalettes' => [
'placeholderImageMode_' . \HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_SIMPLE => 'placeholderImage',
'placeholderImageMode_' . \HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_GENDERED => 'genderField,placeholderImage,placeholderImageFemale',
'placeholderImageMode_' . \HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_RANDOM => 'placeholderImages',
],
'fields' => [
'id' => [
Expand Down Expand Up @@ -180,5 +181,12 @@
'eval' => ['includeBlankOption' => true, 'mandatory' => true, 'chosen' => true, 'tl_class' => 'w50 autoheight'],
'sql' => "varchar(64) NOT NULL default ''",
],
'placeholderImages' => [
'label' => &$GLOBALS['TL_LANG']['tl_list_config_element']['placeholderImages'],
'exclude' => true,
'inputType' => 'fileTree',
'eval' => ['tl_class' => 'w50 autoheight', 'fieldType' => 'checkbox', 'filesOnly' => true, 'extensions' => Config::get('validImageTypes'), 'mandatory' => true, 'multiple' => true],
'sql' => "blob NULL",
],
],
];
3 changes: 3 additions & 0 deletions src/Resources/contao/languages/de/tl_list_config_element.php
Expand Up @@ -26,6 +26,8 @@
$lang['placeholderImageFemale'][1] = 'Wählen Sie hier ein Platzhalterbild für weibliche Instanzen aus.';
$lang['genderField'][0] = 'Geschlecht-Feld';
$lang['genderField'][1] = 'Wählen Sie hier das Feld aus, das das Geschlecht der Instanz enthält.';
$lang['placeholderImages'][0] = 'Platzhalterbilder';
$lang['placeholderImages'][1] = 'Wählen Sie hier Platzhalterbilder aus.';

/**
* Legends
Expand All @@ -41,6 +43,7 @@
\HeimrichHannot\ListBundle\ConfigElementType\ImageConfigElementType::TYPE => 'Bild',
\HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_SIMPLE => 'einfach',
\HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_GENDERED => 'geschlechtsspezifisch',
\HeimrichHannot\ListBundle\Backend\ListConfigElement::PLACEHOLDER_IMAGE_MODE_RANDOM => 'zufällig',
];

/**
Expand Down

0 comments on commit b3944dd

Please sign in to comment.