Skip to content

Commit

Permalink
Merge pull request #124 from contao-estatemanager/develop
Browse files Browse the repository at this point in the history
Field filesPerSync added in tl_interface for type openimmo
  • Loading branch information
eki89 authored Jul 24, 2020
2 parents 28a94e4 + ebebbc8 commit 793177c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/Resources/contao/classes/RealEstateCronImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ public function run()

if ($minDiff - intval($objInterface->autoSync) >= 0)
{
$this->sync();
$this->sync($objInterface->current());
}
}
}
}

/**
* Synchronize an interface
*
* @param InterfaceModel $objInterface
*/
protected function sync()
protected function sync($objInterface)
{
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['realEstateImportBeforeCronSync']) && \is_array($GLOBALS['TL_HOOKS']['realEstateImportBeforeCronSync']))
Expand All @@ -93,7 +95,7 @@ protected function sync()

// ToDo: Use array_filter to remove duplicate files (may its possible if file is not completely transferred)

$files = array_slice(array_reverse($files), 0, 10);
$files = array_slice(array_reverse($files), 0, $objInterface->filesPerSync);

foreach ($files as $file)
{
Expand Down
10 changes: 9 additions & 1 deletion src/Resources/contao/dca/tl_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
(
'__selector__' => array('type', 'importThirdPartyRecords'),
'default' => '{title_legend},title,type',
'openimmo' => '{title_legend},title,type;{oi_field_legend},provider,anbieternr,uniqueProviderField,uniqueField,importPath,filesPath,filesPathContactPerson;{related_records_legend},contactPersonActions,contactPersonUniqueField,importThirdPartyRecords;{expert_legend},skipRecords,dontPublishRecords;{sync_legend},autoSync,deleteFilesOlderThen',
'openimmo' => '{title_legend},title,type;{oi_field_legend},provider,anbieternr,uniqueProviderField,uniqueField,importPath,filesPath,filesPathContactPerson;{related_records_legend},contactPersonActions,contactPersonUniqueField,importThirdPartyRecords;{expert_legend},skipRecords,dontPublishRecords;{sync_legend},autoSync,deleteFilesOlderThen,filesPerSync',
),

// Subpalettes
Expand Down Expand Up @@ -352,6 +352,14 @@
'options_callback' => array('tl_interface', 'getDeleteFilesOlderThenOptions'),
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'filesPerSync' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_interface']['filesPerSync'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('maxlength'=>2, 'rgxp'=>'natural', 'tl_class'=>'w50'),
'sql' => "smallint(2) unsigned NOT NULL default '10'"
),
)
);

Expand Down
6 changes: 6 additions & 0 deletions src/Resources/contao/languages/en/tl_interface.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
<trans-unit id="tl_interface.syncRealEstates.1">
<source>Here you can synchronize real estate</source>
</trans-unit>
<trans-unit id="tl_interface.filesPerSync.0">
<source>Max. files per sync</source>
</trans-unit>
<trans-unit id="tl_interface.filesPerSync.1">
<source>Here you can specify the maximum number of files to be synchronized during an automatic import.</source>
</trans-unit>

<trans-unit id="tl_interface.openimmo.0">
<source>OpenImmo</source>
Expand Down

0 comments on commit 793177c

Please sign in to comment.