Skip to content

Commit

Permalink
Merge pull request #1 from contao-estatemanager/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
doishub authored Jun 8, 2020
2 parents 730db16 + d87caec commit 1fb34d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# WIB-Import Extension for Contao EstateManager

The WIB import extension provides a new interface for importing real estate of the "Westdeutsche Immobilienbörse" for the Contao EstateManager.

# License
Copyright (c) 2019 Contao EstateManager

Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
"license":"proprietary",
"authors":[
{
"name":"Oveleon",
"homepage":"https://www.oveleon.de/",
"name":"Daniele Sciannimanica",
"homepage":"https://github.com/doishub",
"role":"Developer"
},
{
"name":"Fabian Ekert",
"homepage":"https://github.com/eki89",
"role":"Developer"
}
],
"require":{
"php":">=7.1",
"contao/core-bundle":"^4.4",
"contao-estatemanager/core": "*"
"contao-estatemanager/core": "^1.0"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/contao/classes/AddonManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace ContaoEstateManager\WibImport;

use Contao\Config;
use Contao\Environment;
use ContaoEstateManager\EstateManager;

class AddonManager
Expand Down Expand Up @@ -101,14 +103,14 @@ public static function getLicenses()

public static function valid()
{
if(strpos(\Environment::get('requestUri'), '/contao/install') !== false)
if(strpos(Environment::get('requestUri'), '/contao/install') !== false)
{
return true;
}

if (static::$initialized === false)
{
static::$valid = EstateManager::checkLicenses(\Config::get(static::$key), static::$licenses, static::$key);
static::$valid = EstateManager::checkLicenses(Config::get(static::$key), static::$licenses, static::$key);
static::$initialized = true;
}

Expand Down
23 changes: 13 additions & 10 deletions src/Resources/contao/classes/WibImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
namespace ContaoEstateManager\WibImport;


use Contao\File;
use Contao\FilesModel;
use Contao\Input;
use ContaoEstateManager\FilesHelper;

/**
Expand All @@ -25,11 +28,11 @@ class WibImport
*
* @param $context
*/
public function manuallyDownloadOpenImmoFile($context)
public function manuallyDownloadOpenImmoFile($context): void
{
if ($context->interface->type === 'wib')
{
if (\Input::get('downloadWibXml'))
if (Input::get('downloadWibXml'))
{
$this->downloadOpenImmoFile($context);
}
Expand All @@ -43,7 +46,7 @@ public function manuallyDownloadOpenImmoFile($context)
*
* @param $context
*/
public function downloadOpenImmoFile($context)
public function downloadOpenImmoFile($context): void
{
$objInterface = $context->interface;

Expand All @@ -55,7 +58,7 @@ public function downloadOpenImmoFile($context)

if (strpos($content, 'uebertragung') !== false)
{
\File::putContent($context->importFolder->path . '/' . $fileName, $content);
File::putContent($context->importFolder->path . '/' . $fileName, $content);

$objInterface->lastSync = $syncTime;
$objInterface->save();
Expand All @@ -77,7 +80,7 @@ public function downloadOpenImmoFile($context)
* @param $skip
* @param $context
*/
public function skipPartnerRecord($realEstate, &$re, &$contactPerson, &$skip, $context)
public function skipPartnerRecord($realEstate, &$re, &$contactPerson, &$skip, $context): void
{
if ($context->interface->type === 'wib')
{
Expand All @@ -101,7 +104,7 @@ public function skipPartnerRecord($realEstate, &$re, &$contactPerson, &$skip, $c
*
* @return string
*/
protected function getWibAuftragsart($realEstate, $context)
protected function getWibAuftragsart($realEstate, $context): string
{
$groups = $realEstate->xpath('verwaltung_objekt');

Expand All @@ -127,7 +130,7 @@ protected function getWibAuftragsart($realEstate, $context)
return '';
}

public function downloadImage($objFilesFolder, &$value, $tmpGroup, &$values, &$skip, $context)
public function downloadImage($objFilesFolder, &$value, $tmpGroup, &$values, &$skip, $context): void
{
if ($context->interface->type === 'wib')
{
Expand All @@ -147,7 +150,7 @@ public function downloadImage($objFilesFolder, &$value, $tmpGroup, &$values, &$s

$completeFileName = $fileName . $extension;

$existingFile = \FilesModel::findByPath($objFilesFolder->path . '/' . $context->uniqueProviderValue . '/' . $context->uniqueValue . '/' . $completeFileName);
$existingFile = FilesModel::findByPath($objFilesFolder->path . '/' . $context->uniqueProviderValue . '/' . $context->uniqueValue . '/' . $completeFileName);

if ($existingFile !== null && $existingFile->hash === $check)
{
Expand Down Expand Up @@ -218,11 +221,11 @@ protected function getExtension($format)
return $extension;
}

protected function downloadFile($path, $targetDirectory, $fileName, $tmpFolder=true)
protected function downloadFile($path, $targetDirectory, $fileName, $tmpFolder=true): void
{
$content = $this->getFileContent($path);

\File::putContent($targetDirectory->path . '/' . ($tmpFolder ? 'tmp/' : '') . $fileName, $content);
File::putContent($targetDirectory->path . '/' . ($tmpFolder ? 'tmp/' : '') . $fileName, $content);
}

protected function getFileContent($path)
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/

// ESTATEMANAGER
$GLOBALS['TL_ESTATEMANAGER_ADDONS'][] = array('ContaoEstateManager\\WibImport', 'AddonManager');
$GLOBALS['TL_ESTATEMANAGER_ADDONS'][] = array('ContaoEstateManager\WibImport', 'AddonManager');

if(ContaoEstateManager\WibImport\AddonManager::valid()) {
// HOOKS
$GLOBALS['TL_HOOKS']['realEstateImportBeforeSync'][] = array('ContaoEstateManager\\WibImport\\WibImport', 'manuallyDownloadOpenImmoFile');
$GLOBALS['TL_HOOKS']['realEstateImportBeforeCronSync'][] = array('ContaoEstateManager\\WibImport\\WibImport', 'downloadOpenImmoFile');
$GLOBALS['TL_HOOKS']['realEstateImportPrePrepareRecord'][] = array('ContaoEstateManager\\WibImport\\WibImport', 'skipPartnerRecord');
$GLOBALS['TL_HOOKS']['realEstateImportSaveImage'][] = array('ContaoEstateManager\\WibImport\\WibImport', 'downloadImage');
$GLOBALS['TL_HOOKS']['realEstateImportBeforeSync'][] = array('ContaoEstateManager\WibImport\WibImport', 'manuallyDownloadOpenImmoFile');
$GLOBALS['TL_HOOKS']['realEstateImportBeforeCronSync'][] = array('ContaoEstateManager\WibImport\WibImport', 'downloadOpenImmoFile');
$GLOBALS['TL_HOOKS']['realEstateImportPrePrepareRecord'][] = array('ContaoEstateManager\WibImport\WibImport', 'skipPartnerRecord');
$GLOBALS['TL_HOOKS']['realEstateImportSaveImage'][] = array('ContaoEstateManager\WibImport\WibImport', 'downloadImage');
}

0 comments on commit 1fb34d5

Please sign in to comment.