124 lines
4.4 KiB
PHP
124 lines
4.4 KiB
PHP
|
<?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);
|
||
|
}
|
||
|
}
|