Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5919755

Browse files
author
Sebastian Zoglowek
committed
[Addition] Enable overriding the maximum image filesize when importing
1 parent 501c76b commit 5919755

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

src/Resources/contao/classes/RealEstateImporter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
use Contao\BackendTemplate;
15+
use Contao\Config;
1516
use Contao\CoreBundle\Monolog\ContaoContext;
1617
use Contao\Database;
1718
use Contao\Dbafs;
@@ -1355,9 +1356,10 @@ protected function saveImage($interfaceMapping, $tmpGroup, &$value, &$values)
13551356
return false;
13561357
}
13571358

1358-
// ToDo: Add import limit from estatemanager settings
1359-
$fileSize = FilesHelper::fileSize($this->objImportFolder->path . '/tmp/' . $value);
1360-
if ($fileSize > 3000000 || $fileSize === 0)
1359+
$fileSize = FilesHelper::fileSize($this->objImportFolder->path . '/tmp/' . $value);
1360+
$maxUpload = Config::get('estateManagerMaxFileSize') ?? 3000000;
1361+
1362+
if ($fileSize > $maxUpload || $fileSize === 0)
13611363
{
13621364
return false;
13631365
}

src/Resources/contao/config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,4 @@
193193
$GLOBALS['TL_CONFIG']['numberFormatDecimals'] = ',';
194194
$GLOBALS['TL_CONFIG']['numberFormatThousands'] = '.';
195195
$GLOBALS['TL_CONFIG']['roomOptions'] = '1,2,3,4,5,6,7,8';
196+
$GLOBALS['TL_CONFIG']['estateManagerMaxFileSize'] = 3000000;

src/Resources/contao/dca/tl_real_estate_config.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Palettes
2525
'palettes' => array
2626
(
27-
'default' => '{global_legend},estateManagerAdminEmail;{real_estate_list_legend},defaultSorting,statusTokenNewDisplayDuration,defaultNumberOfMainDetails,defaultNumberOfMainAttr,defaultImage;{provider_contact_legend},defaultContactPersonImage,defaultContactPersonFemaleImage,defaultContactPersonMaleImage;{number_legend:hide},numberFormatDecimals,numberFormatThousands;{filter_config_legend:hide},roomOptions'
27+
'default' => '{global_legend},estateManagerAdminEmail;{real_estate_list_legend},defaultSorting,statusTokenNewDisplayDuration,defaultNumberOfMainDetails,defaultNumberOfMainAttr,defaultImage;{provider_contact_legend},defaultContactPersonImage,defaultContactPersonFemaleImage,defaultContactPersonMaleImage;{number_legend:hide},numberFormatDecimals,numberFormatThousands;{filter_config_legend:hide},roomOptions;{import_legend:hide},estateManagerMaxFileSize'
2828
),
2929

3030
// Fields
@@ -125,5 +125,12 @@
125125
'inputType' => 'text',
126126
'eval' => array('mandatory'=>true, 'rgxp'=>'natural', 'tl_class'=>'w50')
127127
),
128+
'estateManagerMaxFileSize' => array
129+
(
130+
'label' => &$GLOBALS['TL_LANG']['tl_real_estate_config']['maxFileSize'],
131+
'default' => '3000000',
132+
'inputType' => 'text',
133+
'eval' => array('mandatory'=>true, 'rgxp'=>'natural', 'nospace'=>true, 'tl_class'=>'w50')
134+
),
128135
)
129136
);

src/Resources/contao/languages/de/tl_real_estate_config.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<source>Provider / Contact Persons</source>
2222
<target>Anbieter / Kontaktpersonen</target>
2323
</trans-unit>
24+
<trans-unit id="tl_real_estate_config.import_legend">
25+
<source>Import</source>
26+
<target>Import</target>
27+
</trans-unit>
2428

2529
<trans-unit id="tl_real_estate_config.estateManagerAdminEmail.0">
2630
<source>E-mail address of the technical administrator</source>
@@ -110,6 +114,14 @@
110114
<source>Here you can enter a comma separated list of options which should be available for the number of rooms.</source>
111115
<target>Hier können Sie die eine kommagetrente Liste von Optionen eingeben, die für die Zimmeranzahl zur Verfügung stehen soll.</target>
112116
</trans-unit>
117+
<trans-unit id="tl_real_estate_config.estateManagerMaxFileSize.0">
118+
<source>Maximum image upload file size</source>
119+
<target>Maximale Bild-Upload-Dateigröße</target>
120+
</trans-unit>
121+
<trans-unit id="tl_real_estate_config.estateManagerMaxFileSize.1">
122+
<source>Here you can enter the maximum upload file size in bytes (1 MB = 1000 kB = 1000000 byte).</source>
123+
<target>Hier können Sie die maximale Upload-Dateigröße in Bytes eingeben (1 MB = 1000 kB = 1000000 Byte).</target>
124+
</trans-unit>
113125

114126
<trans-unit id="tl_real_estate_config.dateAdded">
115127
<source>Date added</source>

src/Resources/contao/languages/en/tl_real_estate_config.xlf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<trans-unit id="tl_real_estate_config.provider_contact_legend">
1818
<source>Provider / Contact Persons</source>
1919
</trans-unit>
20-
20+
<trans-unit id="tl_real_estate_config.import_legend">
21+
<source>Import</source>
22+
</trans-unit>
2123
<trans-unit id="tl_real_estate_config.estateManagerAdminEmail.0">
2224
<source>E-mail address of the technical administrator</source>
2325
</trans-unit>
@@ -84,6 +86,12 @@
8486
<trans-unit id="tl_real_estate_config.roomOptions.1">
8587
<source>Here you can enter a comma separated list of options which should be available for the number of rooms.</source>
8688
</trans-unit>
89+
<trans-unit id="tl_real_estate_config.estateManagerMaxFileSize.0">
90+
<source>Maximum image upload file size</source>
91+
</trans-unit>
92+
<trans-unit id="tl_real_estate_config.estateManagerMaxFileSize.1">
93+
<source>Here you can enter the maximum upload file size in bytes (1 MB = 1000 kB = 1000000 byte).</source>
94+
</trans-unit>
8795

8896
<trans-unit id="tl_real_estate_config.dateAdded">
8997
<source>Date added</source>

0 commit comments

Comments
 (0)