Merge branch 'master' into develop

This commit is contained in:
Björn Fromme
2019-11-06 11:49:28 +01:00
6 changed files with 341 additions and 290 deletions
+1
View File
@@ -8,6 +8,7 @@
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.2", "php": "^7.2",
"ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-pdo": "*", "ext-pdo": "*",
Generated
+287 -273
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -123,3 +123,4 @@ routeEnhancers:
'/': 0 '/': 0
'/json': 1703 '/json': 1703
'sitemap.xml': 1533906435 'sitemap.xml': 1533906435
'yoast-snippetpreview.json': 1480321830
@@ -3,6 +3,8 @@
defined('TYPO3_MODE') or die(); defined('TYPO3_MODE') or die();
$GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['deprecations']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::NOTICE] = []; $GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['deprecations']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::NOTICE] = [];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['yoast_seo']['allowedDoktypes']['ep_category'] = 101;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['yoast_seo']['allowedDoktypes']['ep_offer'] = 102;
call_user_func(function() { call_user_func(function() {
@@ -33,6 +33,7 @@ use EP\EpProducts\Domain\Repository\RegionRepository;
use EP\EpProducts\Domain\Repository\SnowreportRepository; use EP\EpProducts\Domain\Repository\SnowreportRepository;
use EP\EpProducts\Domain\Repository\WebcamRepository; use EP\EpProducts\Domain\Repository\WebcamRepository;
use EP\EpProducts\Utility\SettingsUtility; use EP\EpProducts\Utility\SettingsUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface; use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
@@ -42,6 +43,16 @@ class SnowreportImportService implements SingletonInterface
const XML_FILE_PATH = 'fileadmin/snowreport/snowreport.xml'; const XML_FILE_PATH = 'fileadmin/snowreport/snowreport.xml';
const XML_FILE_URL = 'http://www.skiresort-service.com/xml-feed/'; const XML_FILE_URL = 'http://www.skiresort-service.com/xml-feed/';
/**
* @var array
*/
protected static $validSnowreportUids = [];
/**
* @var array
*/
protected static $validWebcamUids = [];
/** /**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
*/ */
@@ -170,11 +181,16 @@ class SnowreportImportService implements SingletonInterface
$this->snowreportRepository->update($snowreport); $this->snowreportRepository->update($snowreport);
} }
static::$validSnowreportUids[] = $vendorUid;
$count++; $count++;
} }
$this->persistenceManager->persistAll(); $this->persistenceManager->persistAll();
$this->cleanupData('tx_epproducts_domain_model_webcam', static::$validWebcamUids);
$this->cleanupData('tx_epproducts_domain_model_snowreport', static::$validSnowreportUids);
$GLOBALS['BE_USER']->writelog(4, 0, 0, 0, sprintf('Snowreport XML import successful (%d records).', $count), []); $GLOBALS['BE_USER']->writelog(4, 0, 0, 0, sprintf('Snowreport XML import successful (%d records).', $count), []);
return $count; return $count;
@@ -202,11 +218,43 @@ class SnowreportImportService implements SingletonInterface
$snowreport->addWebcam($webcam); $snowreport->addWebcam($webcam);
} else { } else {
$webcam = $result->getFirst(); $webcam = $result->getFirst();
$webcam->setUrl((string) $item->url);
$webcam->setName((string) $item->dt);
$webcam->setAvailable((string) $item->verf === 'true'); $webcam->setAvailable((string) $item->verf === 'true');
} }
static::$validWebcamUids[] = $vendorUid;
} }
} }
public function cleanupData($table, array $validUids)
{
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$qb = $connectionPool->getQueryBuilderForTable($table);
$result = $qb
->select('vendor_uid')
->from($table)
->execute()
->fetchAll()
;
$currentUids = array_map(function ($row) {
return (int)$row['vendor_uid'];
}, $result);
$obsoleteUids = array_diff($currentUids, $validUids);
if (0 === count($obsoleteUids)) {
return;
}
$qb = $connectionPool->getQueryBuilderForTable($table);
$qb
->delete($table)
->where($qb->expr()->in('vendor_uid', $obsoleteUids))
->execute()
;
}
public function downloadReportsXml() public function downloadReportsXml()
{ {
$path = GeneralUtility::getFileAbsFileName(self::XML_FILE_PATH); $path = GeneralUtility::getFileAbsFileName(self::XML_FILE_PATH);
+2 -17
View File
@@ -36,22 +36,7 @@ if ($hash !== $token) {
die('Access denied'); die('Access denied');
} }
$ch = curl_init(); $imageInfo = getimagesize($url);
curl_setopt($ch, CURLOPT_URL, $url); header('Content-type: '.$imageInfo['mime']);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = curl_exec($ch);
if ($headers === false) {
exit;
}
foreach (explode("\r\n", $headers) as $header) {
header($header);
}
readfile($url); readfile($url);
exit; exit;