initial commit

This commit is contained in:
origin
2023-12-04 16:40:27 +01:00
commit 813b2d3da4
133 changed files with 50635 additions and 0 deletions

View File

@ -0,0 +1,472 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Controller;
use \A2G\A2gMaps\Domain\Traits\InjectMarkerRepositoryTrait;
use A2G\A2gTravelBlog\Domain\Traits\{
InjectMapEntryRepositoryTrait,
InjectTravelAuthorRepositoryTrait,
InjectImageServiceTrait,
InjectTravelPostRepositoryTrait,
InjectTravelCategoryRepositoryTrait,
};
use A2G\A2gMaps\Utility\MapConfigUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\CMS\Fluid\View\StandaloneView;
use T3G\AgencyPack\Blog\Constants;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* MapController
*/
class MapController extends ActionController {
use InjectMarkerRepositoryTrait;
use InjectMapEntryRepositoryTrait;
use InjectTravelAuthorRepositoryTrait;
use InjectTravelPostRepositoryTrait;
use InjectTravelCategoryRepositoryTrait;
use InjectImageServiceTrait;
private static $mapIcons = null;
/**
*
* @param UriBuilder $uriBuilder
* @param TemplateView $sourceView
* @param type $arguments
* @param type $actionName
* @param type $controllerName
* @return string
*/
static private function generateContent(UriBuilder $uriBuilder, TemplateView &$sourceView, $arguments = [], $actionName = 'popup', $controllerName = 'Map'): StandaloneView {
$templatePath = $controllerName . '/' . ucfirst($actionName);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$templateRootPaths = $sourceView->getTemplateRootPaths();
$context = $objectManager->get(ControllerContext::class);
$request = $objectManager->get(Request::class);
$context->setRequest($request);
$context->setUriBuilder($uriBuilder);
/**
* @var StandaloneView $view
*/
$view = $objectManager->get(StandaloneView::class);
$view->setControllerContext($context);
$view->setLayoutRootPaths($sourceView->getLayoutRootPaths());
$view->setTemplateRootPaths($templateRootPaths);
$view->setPartialRootPaths($sourceView->getPartialRootPaths());
$view->setTemplate($templatePath);
$arguments['today'] = (new \DateTime())->format('d.m.Y');
$view->assignMultiple($arguments);
return $view;
}
private function setMapMarkerIcons() {
if (self::$mapIcons === null) {
self::$mapIcons = [];
$markers = $this->markerRepository->findAll();
foreach ($markers as $marker) {
if ($marker->getMapIcon() !== null) {
self::$mapIcons[] = [
'uid' => 'i-' . $marker->getUid(),
'icon' => $this->imageService->getImageUri($this->imageService->applyProcessingInstructions($this->imageService->getImage('', $marker->getMapIcon(), false), []), true)
];
}
}
}
}
/**
* action map
*
* @return string|object|null|void
*/
public function mapAction() {
$layerIds = explode(',', $this->settings['layers']);
$layerConfigs = MapConfigUtility::getMapLayerConfig($layerIds);
if ($this->settings['useLayerSwitcher'] === '1') {
for ($i = 0; $i < count($layerConfigs); $i++) {
$layerConfigs[$i]['active'] = true;
}
}
$this->uriBuilder->setTargetPageType(1652369512);
$centerLat = 0.0;
$centerLon = 0.0;
switch ((int) $this->settings['mapType']) {
case 0:
$markers = $this->mapEntryRepository->findAll();
$markerUri = $this->uriBuilder->uriFor('allMapMarkers', null, null, null, 'MapConfig');
$zoom = 1;
break;
case 1:
$travelPost = $this->travelPostRepository->findByUid((int) $this->configurationManager->getContentObject()->data['pid']);
if ($travelPost !== null && $travelPost->getDoktype() === Constants::DOKTYPE_BLOG_POST) {
$markers = $travelPost->getRelMapEntries();
foreach ($markers as $marker) {
$centerLat = $centerLat + $marker->getLatitude();
$centerLon = $centerLon + $marker->getLongitude();
}
$centerLat = $centerLat / count($markers);
$centerLon = $centerLon / count($markers);
$markerUri = $this->uriBuilder->uriFor('postMapMarkers', null, null, null, 'MapConfig');
$zoom = 6;
}
break;
case 2:
$cats = explode(',', $this->settings['showCategories']);
$args = ['tx_a2gtravelblog_mapconfig' => ['categories' => $cats]];
$travelPosts = $this->travelPostRepository->getFromCategoryUids($cats);
$this->uriBuilder->setArguments($args);
$markerUri = $this->uriBuilder->uriFor('mapMarkersFromCategories', null, null, null, 'MapConfig');
$markers = [];
foreach ($travelPosts as $travelPost) {
$markers[$travelPost->getUid()] = $travelPost->getRelMapEntries()->current();
$centerLat = $centerLat + $markers[$travelPost->getUid()]->getLatitude();
$centerLon = $centerLon + $markers[$travelPost->getUid()]->getLongitude();
}
$centerLat = $centerLat / count($markers);
$centerLon = $centerLon / count($markers);
$zoom = 3;
break;
case 3:
$authorUids = explode(',', $this->settings['showAuthors']);
$args = ['tx_a2gtravelblog_mapconfig' => ['authors' => $authorUids]];
$travelPosts = $this->travelPostRepository->getFromAuthorUids($authorUids);
$this->uriBuilder->setArguments($args);
$markerUri = $this->uriBuilder->uriFor('mapMarkersFromAuthor', null, null, null, 'MapConfig');
$markers = [];
foreach ($travelPosts as $travelPost) {
$markers[$travelPost->getUid()] = $travelPost->getRelMapEntries()->current();
$centerLat = $centerLat + $markers[$travelPost->getUid()]->getLatitude();
$centerLon = $centerLon + $markers[$travelPost->getUid()]->getLongitude();
}
$centerLat = $centerLat / count($markers);
$centerLon = $centerLon / count($markers);
$zoom = 2;
break;
default:
$markers = [];
$zoom = 1;
break;
}
if ((int) $this->settings['zoom'] > 0) {
$zoom = (int) $this->settings['zoom'];
}
if (count($markers) > 0) {
$showMarkers = true;
} else {
$showMarkers = false;
}
$this->view->assignMultiple([
'mapId' => 'a2g-map-' . uniqid(),
'countMapLayers' => count($layerIds),
'mapConfig' => \GuzzleHttp\json_encode(MapConfigUtility::getMapConfig(
$layerIds,
null,
$showMarkers === true ? $markerUri : null,
null,
$zoom,
18, $centerLon, $centerLat,
true, true, true))
]);
}
private function getMarkersFromCategories(array $uids) {
}
private function getMarkers(int $uid = 0) {
$travelPost = $this->travelPostRepository->findByUid($uid);
if ($travelPost !== null && $travelPost->getDoktype() === Constants::DOKTYPE_BLOG_POST) {
$markers = [];
foreach ($travelPost->getRelMapEntries() as $post) {
$markers[] = $post;
}
} else {
$markers = [];
$posts = $this->travelPostRepository->findAll();
foreach ($posts as $post) {
if (count($post->getRelMapEntries()) > 0) {
$markers[] = $post->getRelMapEntries()->current();
}
}
}
return $markers;
}
/**
* action mapMarkersFromTag
*
* @return string|object|null|void
*/
public function mapMarkersFromTagAction() {
$travelPosts = $this->travelPostRepository->getFromTagUids([(int)$_GET['tx_a2gtravelblog_mapconfig']['tag']]);
$markers = [];
foreach ($travelPosts as $post) {
if (count($post->getRelMapEntries()) > 0) {
$markers[] = $post->getRelMapEntries()->current();
}
}
$out = [
"type" => "FeatureCollection",
"totalFeatures" => count($markers),
"csr" => MapConfigUtility::getMarkerCsr(),
"features" => []
];
foreach ($markers as $marker) {
if ($marker->getRelMarker() !== null) {
$tmpIcon = "i-" . $marker->getRelMarker()->getUid();
} else if ($marker->getRelTravelPost()->getAuthors()->count() > 0) {
$author = $this->travelAuthorRepository->findByUid($marker->getRelTravelPost()->getAuthors()->current()->getUid());
$tmpIcon = $author === null || $author->getRelMapMarker() === null ? null : "i-" . $author->getRelMapMarker()->getUid();
} else {
$tmpIcon = null;
}
$out["features"][] = MapConfigUtility::getMarker($marker, $tmpIcon, self::generateContent($this->uriBuilder, $this->view, ['settings' => $this->settings, 'mapEntry' => $marker], 'popup')->render());
}
return \GuzzleHttp\json_encode($out);
}
/**
* action mapMarkers
*
* @return string|object|null|void
*/
public function mapMarkersFromAuthorAction() {
$travelPosts = $this->travelPostRepository->getFromAuthorUids($_GET['tx_a2gtravelblog_mapconfig']['authors']);
$markers = [];
foreach ($travelPosts as $post) {
if (count($post->getRelMapEntries()) > 0) {
$markers[] = $post->getRelMapEntries()->current();
}
}
$out = [
"type" => "FeatureCollection",
"totalFeatures" => count($markers),
"csr" => MapConfigUtility::getMarkerCsr(),
"features" => []
];
foreach ($markers as $marker) {
if ($marker->getRelMarker() !== null) {
$tmpIcon = "i-" . $marker->getRelMarker()->getUid();
} else if ($marker->getRelTravelPost()->getAuthors()->count() > 0) {
$author = $this->travelAuthorRepository->findByUid($marker->getRelTravelPost()->getAuthors()->current()->getUid());
$tmpIcon = $author === null || $author->getRelMapMarker() === null ? null : "i-" . $author->getRelMapMarker()->getUid();
} else {
$tmpIcon = null;
}
$out["features"][] = MapConfigUtility::getMarker($marker, $tmpIcon, self::generateContent($this->uriBuilder, $this->view, ['settings' => $this->settings, 'mapEntry' => $marker], 'popup')->render());
}
return \GuzzleHttp\json_encode($out);
}
/**
* action mapMarkers
*
* @return string|object|null|void
*/
public function mapMarkersFromCategoriesAction() {
$travelPosts = $this->travelPostRepository->getFromCategoryUids($_GET['tx_a2gtravelblog_mapconfig']['categories']);
$markers = [];
foreach ($travelPosts as $post) {
if (count($post->getRelMapEntries()) > 0) {
$markers[] = $post->getRelMapEntries()->current();
}
}
$out = [
"type" => "FeatureCollection",
"totalFeatures" => count($markers),
"csr" => MapConfigUtility::getMarkerCsr(),
"features" => []
];
foreach ($markers as $marker) {
if ($marker->getRelMarker() !== null) {
$tmpIcon = "i-" . $marker->getRelMarker()->getUid();
} else if ($marker->getRelTravelPost()->getAuthors()->count() > 0) {
$author = $this->travelAuthorRepository->findByUid($marker->getRelTravelPost()->getAuthors()->current()->getUid());
$tmpIcon = $author === null || $author->getRelMapMarker() === null ? null : "i-" . $author->getRelMapMarker()->getUid();
} else {
$tmpIcon = null;
}
$out["features"][] = MapConfigUtility::getMarker($marker, $tmpIcon, self::generateContent($this->uriBuilder, $this->view, ['settings' => $this->settings, 'mapEntry' => $marker], 'popup')->render());
}
return \GuzzleHttp\json_encode($out);
}
/**
* action mapMarkers
*
* @return string|object|null|void
*/
public function postMapMarkersAction() {
$markers = $this->getMarkers((int) $this->configurationManager->getContentObject()->data['uid']);
$out = [
"type" => "FeatureCollection",
"totalFeatures" => count($markers),
"csr" => MapConfigUtility::getMarkerCsr(),
"features" => []
];
foreach ($markers as $marker) {
if ($marker->getRelMarker() !== null) {
$tmpIcon = "i-" . $marker->getRelMarker()->getUid();
} else if ($marker->getRelTravelPost()->getAuthors()->count() > 0) {
$author = $this->travelAuthorRepository->findByUid($marker->getRelTravelPost()->getAuthors()->current()->getUid());
$tmpIcon = $author === null || $author->getRelMapMarker() === null ? null : "i-" . $author->getRelMapMarker()->getUid();
} else {
$tmpIcon = null;
}
$out["features"][] = MapConfigUtility::getMarker($marker, $tmpIcon, self::generateContent($this->uriBuilder, $this->view, ['mapEntry' => $marker], 'popupPost')->render());
}
return \GuzzleHttp\json_encode($out);
}
/**
* action mapMarkers
*
* @return string|object|null|void
*/
public function allMapMarkersAction() {
$markers = $this->getMarkers();
$out = [
"type" => "FeatureCollection",
"totalFeatures" => count($markers),
"csr" => MapConfigUtility::getMarkerCsr(),
"features" => []
];
foreach ($markers as $marker) {
if ($marker->getRelMarker() !== null) {
$tmpIcon = "i-" . $marker->getRelMarker()->getUid();
} else if ($marker->getRelTravelPost()->getAuthors()->count() > 0) {
$author = $this->travelAuthorRepository->findByUid($marker->getRelTravelPost()->getAuthors()->current()->getUid());
$tmpIcon = $author === null || $author->getRelMapMarker() === null ? null : "i-" . $author->getRelMapMarker()->getUid();
} else {
$tmpIcon = null;
}
$out["features"][] = MapConfigUtility::getMarker($marker, $tmpIcon, self::generateContent($this->uriBuilder, $this->view, ['settings' => $this->settings, 'mapEntry' => $marker])->render());
}
return \GuzzleHttp\json_encode($out);
}
public function activeCountryGeojsonAction(){
$travelCats=[];
foreach($_GET['tx_a2gtravelblog_mapconfig']['categories'] as $uid){
$travelCats[] = $this->travelCategoryRepository->findByUid((int)$uid);
}
$isoCodes = [];
foreach($travelCats as $travelCat){
$isoCodes[$travelCat->getIsoA2CountryCode()] = null;
}
return \GuzzleHttp\json_encode(MapConfigUtility::getCountryFeatureCollectionsFromIsoCodeList($isoCodes));
}
public function activeCountriesGeojsonAction(){
$travelCats = $this->travelCategoryRepository->findAll();
$isoCodes = [];
foreach($travelCats as $travelCat){
$isoCodes[$travelCat->getIsoA2CountryCode()] = self::generateContent($this->uriBuilder, $this->view, ['settings' => $this->settings, 'category' => $travelCat], 'popupCategory')->render();
}
return \GuzzleHttp\json_encode(MapConfigUtility::getCountryFeatureCollectionsFromIsoCodeList($isoCodes));
}
/**
* action mapConfig
*
* @return string|object|null|void
*/
public function mapConfigAction() {
$this->setMapMarkerIcons();
$this->view->assignMultiple([
'mapIcons' => \GuzzleHttp\json_encode(self::$mapIcons)
]);
}
/**
* action ajaxListAction
*
* @return string|object|null|void
*/
public function ajaxListAction() {
}
// /**
// * action show
// *
// * @param Ingredients $ingredient
// * @return string|object|null|void
// */
// public function showAction(Ingredients $ingredient) {
// $titleProvider = GeneralUtility::makeInstance(A2gPageTitleProvider::class);
//
// if($this->settings['pageTitleSuffix'] !== null && $this->settings['pageTitleSuffix'] !== '' && (strlen($ingredient->getTitle()) + strlen($this->settings['pageTitleSuffix'])) < 66 ){
// $pageTitle = $ingredient->getTitle(). ' ' . $this->settings['pageTitleSuffix'];
// } else {
// $pageTitle = $ingredient->getTitle();
// }
// $titleProvider->setTitle($pageTitle);
// $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
// $description = $contentObject->crop($ingredient->getDescription(), 125 . '|...|' . true);
//
// $uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->setTargetPageUid(
// $GLOBALS['TSFE']->id)->uriFor('show', ['ingredient' => $ingredient], 'Ingredients', 'a2gProducts', 'ingredientsdetail');
//
// $metaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
//
// $metaTagManager->getManagerForProperty('robots')->addProperty('robots', 'index, folow');
// $metaTagManager->getManagerForProperty('og:type')->addProperty('og:type', 'website');
// $metaTagManager->getManagerForProperty('twitter:card')->addProperty('twitter:card', 'summary_large_image');
//
// if ($ingredient->getTitle() !== '') {
// $metaTagManager->getManagerForProperty('title')->addProperty('title', $pageTitle);
// $metaTagManager->getManagerForProperty('og:title')->addProperty('og:title', $pageTitle);
// $metaTagManager->getManagerForProperty('twitter:title')->addProperty('twitter:title', $pageTitle);
// }
// if ($ingredient->getDescription() !== '') {
// $metaTagManager->getManagerForProperty('description')->addProperty('description', $description);
// $metaTagManager->getManagerForProperty('og:description')->addProperty('og:description', $description);
// $metaTagManager->getManagerForProperty('twitter:description')->addProperty('twitter:description', $description);
// }
// $metaTagManager->getManagerForProperty('og:url')->addProperty('og:url', $uri);
// $metaTagManager->getManagerForProperty('twitter:url')->addProperty('twitter:url', $uri);
//
// if ($ingredient->getImage() !== null) {
// $processedImage = $this->imageService->applyProcessingInstructions(
// $this->imageService->getImage('', $ingredient->getImage(), false),
// ['width' => '
// 1200', 'height' => '630c']
// );
// $metaTagManager->getManagerForProperty('twitter:image')->addProperty('twitter:image', $this->imageService->getImageUri($processedImage, true));
// $metaTagManager->getManagerForProperty('og:image')->addProperty('og:image', $this->imageService->getImageUri($processedImage, true));
// }
// $this->view->assign('ingredient', $ingredient);
// }
}

View File

@ -0,0 +1,123 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Controller;
use \A2G\A2gMaps\Domain\Traits\InjectMarkerRepositoryTrait;
use A2G\A2gTravelBlog\Domain\Traits\{
InjectMapEntryRepositoryTrait,
InjectTravelAuthorRepositoryTrait,
InjectImageServiceTrait,
InjectTravelPostRepositoryTrait,
InjectTravelCategoryRepositoryTrait,
};
use A2G\A2gMaps\Utility\MapConfigUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\CMS\Fluid\View\StandaloneView;
use T3G\AgencyPack\Blog\Constants;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* MapController
*/
class TravelPostController extends ActionController {
use InjectMarkerRepositoryTrait;
use InjectMapEntryRepositoryTrait;
use InjectTravelAuthorRepositoryTrait;
use InjectTravelPostRepositoryTrait;
use InjectTravelCategoryRepositoryTrait;
use InjectImageServiceTrait;
private static $mapIcons = null;
/**
*
* @param UriBuilder $uriBuilder
* @param TemplateView $sourceView
* @param type $arguments
* @param type $actionName
* @param type $controllerName
* @return string
*/
static private function generateContent(UriBuilder $uriBuilder, TemplateView &$sourceView, $arguments = [], $actionName = 'popup', $controllerName = 'Map'): StandaloneView {
$templatePath = $controllerName . '/' . ucfirst($actionName);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$templateRootPaths = $sourceView->getTemplateRootPaths();
$context = $objectManager->get(ControllerContext::class);
$request = $objectManager->get(Request::class);
$context->setRequest($request);
$context->setUriBuilder($uriBuilder);
/**
* @var StandaloneView $view
*/
$view = $objectManager->get(StandaloneView::class);
$view->setControllerContext($context);
$view->setLayoutRootPaths($sourceView->getLayoutRootPaths());
$view->setTemplateRootPaths($templateRootPaths);
$view->setPartialRootPaths($sourceView->getPartialRootPaths());
$view->setTemplate($templatePath);
$arguments['today'] = (new \DateTime())->format('d.m.Y');
$view->assignMultiple($arguments);
return $view;
}
private function setMapMarkerIcons() {
if (self::$mapIcons === null) {
self::$mapIcons = [];
$markers = $this->markerRepository->findAll();
foreach ($markers as $marker) {
if ($marker->getMapIcon() !== null) {
self::$mapIcons[] = [
'uid' => 'i-' . $marker->getUid(),
'icon' => $this->imageService->getImageUri($this->imageService->applyProcessingInstructions($this->imageService->getImage('', $marker->getMapIcon(), false), []), true)
];
}
}
}
}
/**
* action timeline
*
* @return string|object|null|void
*/
public function timelineAction() {
$args=[];
switch ((int) $this->settings['timelineType']) {
case 2:
$cats = explode(',', $this->settings['showCategories']);
$travelPosts = $this->travelPostRepository->getFromCategoryUids($cats);
break;
case 3:
$authorUids = explode(',', $this->settings['showAuthors']);
$travelPosts = $this->travelPostRepository->getFromAuthorUids($authorUids);
$args['authors'] = $this->travelAuthorRepository->getFromUids($authorUids);
break;
default:
$travelPosts = $this->travelPostRepository->findAll();
break;
}
$args['posts'] = $travelPosts;
$this->view->assignMultiple($args);
}
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Model;
use A2G\A2gMaps\Domain\Model\MapEntry as BaseMapEntry;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Annotation\ORM\{
Cascade,
Lazy
};
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
/**
* This file is part of the "altogether Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* MapEntry
*/
class MapEntry extends BaseMapEntry {
/**
* relTravelPost
*
* @Cascade("remove")
* @Lazy
* @var TravelPost
*/
protected $relTravelPost = null;
/**
*
* @return TravelPost
*/
public function getRelTravelPost(): TravelPost {
if ($this->relTravelPost instanceof LazyLoadingProxy) {
$this->relTravelPost = $this->relTravelPost->_loadRealInstance();
}
return $this->relTravelPost;
}
/**
*
* @param TravelPost $relTravelPost
* @return void
*/
public function setRelTravelPost(TravelPost $relTravelPost): void {
$this->relTravelPost = $relTravelPost;
}
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Model;
use T3G\AgencyPack\Blog\Domain\Model\Author;
use A2G\A2gTravelBlog\Domain\Model\TravelMarker;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* TravelAuthor
*/
class TravelAuthor extends Author {
/**
* relMapMarker
*
* @var TravelMarker
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
*/
protected $relMapMarker = null;
/**
* Returns the relMapMarker
*
* @return TravelMarker $relMapMarker
*/
public function getRelMapMarker() {
if ($this->relMapMarker instanceof LazyLoadingProxy) {
$this->relMapMarker = $this->relMapMarker->_loadRealInstance();
}
return $this->relMapMarker;
}
/**
* Sets the relMapMarker
*
* @param TravelMarker $relMapMarker
* @return void
*/
public function setRelMapMarker(TravelMarker $relMapMarker) {
$this->relMapMarker = $relMapMarker;
}
}

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Model;
use T3G\AgencyPack\Blog\Domain\Model\Category;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* TravelCategory
*/
class TravelCategory extends Category {
/**
* isoA2CountryCode
*
* @var string
*/
protected $isoA2CountryCode = '';
public function getIsoA2CountryCode(): string {
return $this->isoA2CountryCode;
}
public function setIsoA2CountryCode(string $isoA2CountryCode): void {
$this->isoA2CountryCode = $isoA2CountryCode;
}
}

View File

@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Model;
use A2G\A2gMaps\Domain\Model\Marker;
use A2G\A2gTravelBlog\Domain\Model\TravelAuthor;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* TravelMarker
*/
class TravelMarker extends Marker {
/**
* relTravelAuthor
*
* @var TravelAuthor
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
*/
protected $relTravelAuthor = null;
/**
* Returns the relTravelAuthor
*
* @return TravelAuthor $relTravelAuthor
*/
public function getRelTravelAuthor() {
if ($this->relTravelAuthor instanceof LazyLoadingProxy) {
$this->relTravelAuthor = $this->relTravelAuthor->_loadRealInstance();
}
return $this->relTravelAuthor;
}
/**
* Sets the relTravelAuthor
*
* @param TravelAuthor $relTravelAuthor
* @return void
*/
public function setRelTravelAuthor(TravelAuthor $relTravelAuthor) {
$this->relTravelAuthor = $relTravelAuthor;
}
}

View File

@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Model;
use \T3G\AgencyPack\Blog\Domain\Model\Post;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* TravelPost
*/
class TravelPost extends Post {
/**
* relMapEntries
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\A2G\A2gTravelBlog\Domain\Model\MapEntry>
*/
protected $relMapEntries = null;
/**
* Post constructor.
*/
public function __construct()
{
parent::__construct();
$this->initializeObject();
}
/**
* initializeObject
*/
public function initializeObject(): void
{
$this->relMapEntries = new ObjectStorage();
}
/**
* @return ObjectStorage
*/
public function getRelMapEntries(): ObjectStorage
{
return $this->relMapEntries;
}
/**
* @param ObjectStorage $relMapEntries
* @return TravelPost
*/
public function setRelMapEntries($relMapEntries): self
{
$this->relMapEntries = $relMapEntries;
return $this;
}
/**
* @param MapEntry $relMapEntry
* @return TravelPost
*/
public function addRelMapEntry(MapEntry $relMapEntry): self
{
$this->relMapEntries->attach($relMapEntry);
return $this;
}
/**
* @param MapEntry $relMapEntry
*
* @return TravelPost
*/
public function removeRelMapEntry(MapEntry $relMapEntry): self
{
$this->relMapEntries->detach($relMapEntry);
return $this;
}
}

View File

@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Repository;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* The repository for MapEntry
*/
class MapEntryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* @var array
*/
// protected $defaultOrderings = [
// 'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
// ];
static protected function mapInt($value){
if(MathUtility::canBeInterpretedAsInteger($value)){
return (int)$value;
}
return null;
}
public function getFromCategoryUids(array $uids){
$uidsFiltered = array_filter(array_map('self::mapInt', $uids));
$query = $this->createQuery();
$query->matching(
$query->logicalOr($query->in('relTravelPost.categories.uid', $uidsFiltered)));
return $query->execute();
}
public function initializeObject() {
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}

View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Repository;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* This file is part of the "Travel Blog" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* The repository for TravelAuthor
*/
class TravelAuthorRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* @var array
*/
// protected $defaultOrderings = [
// 'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
// ];
static protected function mapInt($value){
if(MathUtility::canBeInterpretedAsInteger($value)){
return (int)$value;
}
return null;
}
public function getFromUids(array $uids){
$uidsFiltered = array_filter(array_map('self::mapInt', $uids));
$query = $this->createQuery();
$query->matching(
$query->logicalOr($query->in('uid', $uidsFiltered)));
return $query->execute();
}
public function initializeObject() {
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Repository;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* The repository for TravelPost
*/
class TravelCategoryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* @var array
*/
// protected $defaultOrderings = [
// 'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
// ];
//
static protected function mapInt($value){
if(MathUtility::canBeInterpretedAsInteger($value)){
return (int)$value;
}
return null;
}
public function initializeObject() {
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}

View File

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Repository;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* This file is part of the "Products" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Raphael Martin <raphy.martin@gmail.com>, none
*/
/**
* The repository for TravelPost
*/
class TravelPostRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* @var array
*/
protected $defaultOrderings = [
'crdate' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
];
static protected function mapInt($value){
if(MathUtility::canBeInterpretedAsInteger($value)){
return (int)$value;
}
return null;
}
public function getFromCategoryUids(array $uids){
$uidsFiltered = array_filter(array_map('self::mapInt', $uids));
$query = $this->createQuery();
$query->matching($query->in('categories.uid', $uidsFiltered));
return $query->execute();
}
public function getFromAuthorUids(array $uids){
$uidsFiltered = array_filter(array_map('self::mapInt', $uids));
$query = $this->createQuery();
$query->matching($query->in('authors.uid', $uidsFiltered));
return $query->execute();
}
public function getFromTagUids(array $uids){
$uidsFiltered = array_filter(array_map('self::mapInt', $uids));
$query = $this->createQuery();
$query->matching($query->in('tags.uid', $uidsFiltered));
return $query->execute();
}
public function initializeObject() {
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}

View File

@ -0,0 +1,35 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Domain\Traits;
use TYPO3\CMS\Extbase\Service\ImageService;
/**
* Description of InjectImageServiceTrait
*
* @author Raphael Martin
*/
trait InjectImageServiceTrait {
/**
* imageService
*
* @var ImageService
*/
protected $imageService = null;
/**
* @param ImageService $imageService
*/
public function injectImageService(ImageService $imageService) {
$this->imageService = $imageService;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace A2G\A2gTravelBlog\Domain\Traits;
use A2G\A2gTravelBlog\Domain\Repository\MapEntryRepository;
/**y
* Description of InjectMapEntryRepositoryTrait
*
* @author Raphael Martin
*/
trait InjectMapEntryRepositoryTrait {
/**
*
* @var MapEntryRepository
*/
protected $mapEntryRepository = null;
/**
* @param MapEntryRepository $mapEntryRepository
*/
public function injectMapEntryRepository(MapEntryRepository $mapEntryRepository) {
$this->mapEntryRepository = $mapEntryRepository;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace A2G\A2gTravelBlog\Domain\Traits;
use A2G\A2gTravelBlog\Domain\Repository\TravelAuthorRepository;
/**y
* Description of InjectTravelAuthorRepositoryTrait
*
* @author Raphael Martin
*/
trait InjectTravelAuthorRepositoryTrait {
/**
*
* @var TravelAuthorRepository
*/
protected $travelAuthorRepository = null;
/**
* @param TravelAuthorRepository $travelAuthorRepository
*/
public function injectTravelAuthorRepository(TravelAuthorRepository $travelAuthorRepository) {
$this->travelAuthorRepository = $travelAuthorRepository;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace A2G\A2gTravelBlog\Domain\Traits;
use A2G\A2gTravelBlog\Domain\Repository\TravelCategoryRepository;
/**
* Description of InjectIngredientsRepositoryTrait
*
* @author Raphael Martin
*/
trait InjectTravelCategoryRepositoryTrait {
/**
*
* @var TravelCategoryRepository
*/
protected $travelCategoryRepository = null;
/**
* @param TravelCategoryRepository $travelCategoryRepository
*/
public function injectTravelCategoryRepository(TravelCategoryRepository $travelCategoryRepository) {
$this->travelCategoryRepository = $travelCategoryRepository;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace A2G\A2gTravelBlog\Domain\Traits;
use A2G\A2gTravelBlog\Domain\Repository\TravelPostRepository;
/**
* Description of InjectIngredientsRepositoryTrait
*
* @author Raphael Martin
*/
trait InjectTravelPostRepositoryTrait {
/**
*
* @var TravelPostRepository
*/
protected $travelPostRepository = null;
/**
* @param TravelPostRepository $travelPostRepository
*/
public function injectTravelPostRepository(TravelPostRepository $travelPostRepository) {
$this->travelPostRepository = $travelPostRepository;
}
}

View File

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Evaluation;
/**
* This file is part of the "tt_address" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
use A2G\A2gTravelBlog\Utility\EvalcoordinatesUtility;
/**
* Class for validation/evaluation of longitude to be used in 'eval' of TCA
* removes everything except numbers and digit-sign (dot). Fills coordinates up with zeros if too short
*/
class LatitudeEvaluation
{
/**
* JavaScript code for client side validation/evaluation
*
* @return string JavaScript code for client side validation/evaluation
*/
public function returnFieldJS()
{
// Nice to have: add javascript-code for evalution on blur
return '
return value;
';
}
/**
* Server-side validation/evaluation on saving the record
* Tests if latutide is between -90 and +90, fills up with zeros to mach decimal (14,12) in database
*
* @param string $value The field value to be evaluated
* @return string Evaluated field value
*/
public function evaluateFieldValue($value)
{
// test if we have any latitude
if ($value && $value !== '') {
return EvalcoordinatesUtility::formatLatitude($value);
}
return null;
}
/**
* Server-side validation/evaluation on opening the record
*
* @param array $parameters Array with key 'value' containing the field value from the database
* @return string Evaluated field value
*/
public function deevaluateFieldValue(array $parameters)
{
// test if we have any latitude
if ($parameters['value'] && $parameters['value'] !== '') {
$parameters['value'] = EvalcoordinatesUtility::formatLatitude($parameters['value']);
}
return $parameters['value'];
}
}

View File

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Evaluation;
/**
* This file is part of the "tt_address" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
use A2G\A2gTravelBlog\Utility\EvalcoordinatesUtility;
/**
* Class for validation/evaluation of Longitude to be used in 'eval' of TCA
* removes everything except numbers and digit-sign (dot). Fills coordinates up with zeros if too short
*/
class LongitudeEvaluation
{
/**
* JavaScript code for client side validation/evaluation
*
* @return string JavaScript code for client side validation/evaluation
*/
public function returnFieldJS()
{
// Nice to have: add javascript-code for evaluation on blur
return '
return value;
';
}
/**
* Server-side validation/evaluation on saving the record
* Tests if latitude is between -90 and +90, fills up with zeros to mach decimal (14,12) in database
*
* @param string $value The field value to be evaluated
* @return string Evaluated field value
*/
public function evaluateFieldValue($value)
{
// test if we have any longitude
if ($value && $value !== '') {
return EvalcoordinatesUtility::formatLongitude($value);
}
return null;
}
/**
* Server-side validation/evaluation on opening the record
*
* @param array $parameters Array with key 'value' containing the field value from the database
* @return string Evaluated field value
*/
public function deevaluateFieldValue(array $parameters)
{
// test if we have any longitude
if ($parameters['value'] && $parameters['value'] != '') {
$parameters['value'] = EvalcoordinatesUtility::formatLongitude($parameters['value']);
}
return $parameters['value'];
}
}

View File

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\PageTitle;
use TYPO3\CMS\Core\PageTitle\AbstractPageTitleProvider;
/**
* Description of A2gPageTitleProvider
*
* @author Raphael Martin
*/
class A2gPageTitleProvider extends AbstractPageTitleProvider
{
/**
* @param string $title
*/
public function setTitle(string $title)
{
$this->title = $title;
}
}

View File

@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace A2G\A2gProducts\Utility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
* Description of Canonical
*
* @author Raphael Martin raphael@web-crossing.com
*/
class CanonicalUtility {
/**
* objectManager
*
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
* @Extbase\Inject
*/
protected $objectManager = null;
/**
* plugin
*
* @var string
*/
static private $plugin = 'tx_a2gproducts_a2gproductsdetail';
/**
* uidParamName
*
* @var string
*/
static private $uidParamName = 'resource';
/**
* setCanonical
*
* @param type $href
*/
public function setCanonical(&$href) {
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$main = GeneralUtility::_GET(self::$plugin);
if ($main[self::$uidParamName]) {
$uriBuilder = $this->objectManager->get(UriBuilder::class);
$uriBuilder->setCreateAbsoluteUri(true);
$uriBuilder->setArguments([self::$plugin => [self::$uidParamName => $main[self::$uidParamName]]]);
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
if (isset($settings['plugin.'][self::$plugin.'.']['settings.']['canonical']) && $settings['plugin.'][self::$plugin.'.']['settings.']['canonical'] !== 0) {
$uriBuilder->setTargetPageUid($settings['plugin.'][self::$plugin.'.']['settings.']['canonical']);
$href = $uriBuilder->build();
}
}
}
}

View File

@ -0,0 +1,95 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Utility;
/**
* This file is part of the "tt_address" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
/**
* Class EvalcoordinatesUtility
*/
class EvalcoordinatesUtility
{
const LATITUDE_UPPER = '90.00000000';
const LONGITUDE_UPPER = '180.00000000';
/**
* @param float $coordinate
* @return float evaluated and well-formed coordinate
*/
public static function formatLongitude(float $coordinate)
{
return self::validate((string)$coordinate, self::LONGITUDE_UPPER);
}
/**
* @param float $coordinate
* @return float evaluated and well-formed coordinate
*/
public static function formatLatitude(float $coordinate)
{
return self::validate((string)$coordinate, self::LATITUDE_UPPER);
}
/**
* @param string $coordinate
* @param string $upperRange
* @return string
*/
protected static function validate($coordinate, string $upperRange): string
{
if ($coordinate === '') {
return '.00000000';
}
// test if value is negative
$negative = '';
if ($coordinate[0] === '-') {
$negative = '-';
}
// remove all chars not being digits and point
// therefore we will get a number
$coordinate = preg_replace("/[^\d\.]/", '', $coordinate);
// split up string at first occurrence decimal point without losing data
$integerPart = strstr($coordinate, '.', true);
$decimalPart = strstr($coordinate, '.');
// if coordinate is given as integer (no decimal point)
if ($integerPart === false) {
$integerPart = $coordinate;
}
if ($decimalPart === false) {
$decimalPart = '00';
}
// remove all points from decimal-part
$decimalPart = preg_replace("/[^\d]/", '', $decimalPart);
// fill up with zeros or shorten to match our goal of decimal(latitude: 10,8 and longitude: 11,8) in DB
if (\strlen($decimalPart) >= 8) {
$decimalPart = substr($decimalPart, 0, 8);
} else {
$decimalPart = str_pad($decimalPart, 8, '0', STR_PAD_RIGHT);
}
// concatenate the whole string to a well-formed longitude and return
$coordinate = $integerPart . '.' . $decimalPart;
// test if value is in the possible range. longitude can be -180 to +180.
// latitude can be -90 to +90
// At this point, our minus, if there, is stored to 'negative'
// therefore we just test if integerpart is bigger than 90
if ($coordinate > $upperRange) {
$coordinate = $upperRange;
}
// reapply signed/unsigned and return
return $negative . $coordinate;
}
}

View File

@ -0,0 +1,237 @@
<?php
declare(strict_types=1);
namespace A2G\A2gTravelBlog\Utility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
* Description of Canonical
*
* @author Raphael Martin raphael@web-crossing.com
*/
class MapConfigUtility {
/**
* uidParamName
*
* @var string
*/
static private $mapLayerConfigs = [
1 => [
"layer" => "osm",
"config" => [
],
"label"=>"osm_map_layer"
],
10 => [
"layer" => "stamen",
"config" => [
"layer" => "terrain"
],
"label" => "stamen_map_terrain"
],
11 => [
"layer" => "stamen",
"config" => [
"layer" => "watercolor"
],
"label" => "stamen_map_watercolor"
],
12 => [
"layer" => "stamen",
"config" => [
"layer" => "toner"
],
"label" => "stamen_map_toner"
],
100 => [
"layer" => "thunderforest",
"config" => [
"layer" => "cycle"
],
"label" => "thunderforest_map_cycle"
],
101 => [
"layer" => "thunderforest",
"config" => [
"layer" => "transport"
],
"label" => "thunderforest_map_transport"
],
102 => [
"layer" => "thunderforest",
"config" => [
"layer" => "landscape"
],
"label" => "thunderforest_map_landscape"
],
103 => [
"layer" => "thunderforest",
"config" => [
"layer" => "outdoors"
],
"label" => "thunderforest_map_outdoors"
],
104 => [
"layer" => "thunderforest",
"config" => [
"layer" => "atlas"
],
"label" => "thunderforest_map_atlas"
],
105 => [
"layer" => "thunderforest",
"config" => [
"layer" => "transport-dark"
],
"label" => "thunderforest_map_transport-dark"
],
106 => [
"layer" => "thunderforest",
"config" => [
"layer" => "spinal-map"
],
"label" => "thunderforest_map_spinal"
],
107 => [
"layer" => "thunderforest",
"config" => [
"layer" => "pioneer"
],
"label" => "thunderforest_map_pioneer"
],
108 => [
"layer" => "thunderforest",
"config" => [
"layer" => "neighbourhood"
],
"label" => "thunderforest_map_neighbourhood"
],
109 => [
"layer" => "thunderforest",
"config" => [
"layer" => "mobile-atlas"
],
"label" => "thunderforest_map_mobile-atlas"
],
200 => [
"layer" => "maptiler",
"config" => [
"layer" => "basic"
],
"label" => "maptiler_map_basic"
],
201 => [
"layer" => "maptiler",
"config" => [
"layer" => "basic-4326"
],
"label" => "maptiler_map_basic-4326"
],
202 => [
"layer" => "maptiler",
"config" => [
"layer" => "bright"
],
"label" => "maptiler_map_bright"
],
203 => [
"layer" => "maptiler",
"config" => [
"layer" => "openstreetmap"
],
"label" => "maptiler_map_openstreetmap"
],
204 => [
"layer" => "maptiler",
"config" => [
"layer" => "outdoor"
],
"label" => "maptiler_map_outdoor"
],
205 => [
"layer" => "maptiler",
"config" => [
"layer" => "pastel"
],
"label" => "maptiler_map_pastel"
],
206 => [
"layer" => "maptiler",
"config" => [
"layer" => "hybrid"
],
"label" => "maptiler_map_hybrid"
],
207 => [
"layer" => "maptiler",
"config" => [
"layer" => "streets"
],
"label" => "maptiler_map_streets"
],
208 => [
"layer" => "maptiler",
"config" => [
"layer" => "toner"
],
"label" => "maptiler_map_toner"
],
209 => [
"layer" => "maptiler",
"config" => [
"layer" => "topo"
],
"label" => "maptiler_map_topo"
],
210 => [
"layer" => "maptiler",
"config" => [
"layer" => "topographique"
],
"label" => "maptiler_map_topographique"
],
211 => [
"layer" => "maptiler",
"config" => [
"layer" => "voyager"
],
"label" => "maptiler_map_voyager"
],
212 => [
"layer" => "maptiler",
"config" => [
"layer" => "winter"
],
"label" => "maptiler_map_winter"
],
];
/**
* setCanonical
*
* @param type $href
*/
public static function getMapLayerConfig(array $mapLayerConfigIds) {
$out = [];
foreach($mapLayerConfigIds as $id){
$out[]=self::$mapLayerConfigs[$id];
}
return $out;
}
}

View File

@ -0,0 +1,73 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package t3g/blog.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace A2G\A2gTravelBlog\ViewHelpers;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use A2G\A2gMaps\Utility\MapConfigUtility;
class MapViewHelper extends AbstractTagBasedViewHelper
{
public function __construct()
{
$this->tagName = 'div';
parent::__construct();
}
/**
* Arguments Initialization.
*
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerArgument('category', 'int', 'categoryUid', true);
}
/**
* @return string the HTML <img>-Tag of the gravatar
*/
public function render(): string
{
// <div class="a2g-map"
// data-map-config='{"zoom":2,"maxZoom":18,
// "centerLon":0,"centerLat":0,
// "style": {
// "featureOverlay":{
// "stroke":{
// "color": "rgba(240,145,48,0.7)",
// "width": 4
// }
// }
// },
// "mapLayers":[{
// "layer": "country",
// "config": {
// "layer": "country",
// "countryGeoSource": "<f:uri.action action="activeCountriesGeojson" pluginName="MapConfig" controller="Map" extensionName="A2gTravelBlog" pageType="1652369512"></f:uri.action>"
// },
// "label": "country (free)",
// "active": true
// },{"layer":"osm","config":[],"label":"osm_map_layer","active":true}],
// "zoomSlider":true,
// "fullScreen":true}'></div>
//
/** @var GravatarProvider $gravatarProvider */
// $gravatarProvider = GeneralUtility::makeInstance(GravatarProvider::class);
// $src = $gravatarProvider->getAvatarUrl((new Author())->setEmail($this->arguments['email']));
$this->tag->addAttribute('data-map-config', '{}');
return $this->tag->render();
}
}