Update to TYPO3 8.7 LTS
This commit is contained in:
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,22 +28,39 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ArgumentPrefixViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('pluginName', 'string', 'Plugin name');
|
||||
$this->registerArgument('extensionName', 'string', 'Extension name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pluginName
|
||||
* @param string $extensionName
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($pluginName = null, $extensionName = null)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$request = $this->controllerContext->getRequest();
|
||||
$request = $renderingContext->getControllerContext()->getRequest();
|
||||
$pluginName = $arguments['pluginName'];
|
||||
if ($pluginName === null) {
|
||||
$pluginName = $request->getPluginName();
|
||||
}
|
||||
$extensionName = $arguments['extensionName'];
|
||||
if ($extensionName === null) {
|
||||
$extensionName = $request->getControllerExtensionName();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers\Calendar;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -32,22 +32,54 @@ use CalendR\Period\Day;
|
||||
use CalendR\Period\Month;
|
||||
use EP\EpProducts\Domain\Model\Contingent;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ContingentViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
const LEVEL_GREEN = 1;
|
||||
const LEVEL_YELLOW = 2;
|
||||
const LEVEL_RED = 3;
|
||||
|
||||
public function render(Month $month, Day $day, Basic $events)
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('month', Month::class, 'The month', true);
|
||||
$this->registerArgument('day', Day::class, 'The day', true);
|
||||
$this->registerArgument('events', Basic::class, 'The calendar events', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$month = $arguments['month'];
|
||||
$day = $arguments['day'];
|
||||
$events = $arguments['events'];
|
||||
|
||||
if (!$month->includes($day)) {
|
||||
return '';
|
||||
}
|
||||
$now = new \DateTime('now');
|
||||
if ($now > $day->getBegin()) {
|
||||
$class = [ 'text-muted' ];
|
||||
return $this->getHtml($class, $day->format('d'));
|
||||
return static::getHtml($class, $day->format('d'));
|
||||
}
|
||||
$contingents = $events->find($day);
|
||||
if (count($contingents) === 0) {
|
||||
@@ -57,7 +89,7 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
$contingent = reset($contingents);
|
||||
$percentage = $contingent->getPercentageAvailable();
|
||||
$status = $contingent->getStatus();
|
||||
$level = $this->getOccupancyLevel($percentage, $status);
|
||||
$level = static::getOccupancyLevel($percentage, $status);
|
||||
}
|
||||
$previousDay = $day->getPrevious();
|
||||
$previousContingents = $events->find($previousDay);
|
||||
@@ -67,16 +99,16 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
$previousContingent = reset($previousContingents);
|
||||
$previousPercentage = $previousContingent->getPercentageAvailable();
|
||||
$previousStatus = $previousContingent->getStatus();
|
||||
$previousLevel = $this->getOccupancyLevel($previousPercentage, $previousStatus);
|
||||
$previousLevel = static::getOccupancyLevel($previousPercentage, $previousStatus);
|
||||
}
|
||||
|
||||
if ($previousLevel !== $level) {
|
||||
$class = $this->getTransientLabelClasses($previousLevel, $level);
|
||||
$class = static::getTransientLabelClasses($previousLevel, $level);
|
||||
} else {
|
||||
$class = $this->getLabelClasses($percentage, $level);
|
||||
$class = static::getLabelClasses($percentage, $level);
|
||||
}
|
||||
|
||||
return $this->getHtml($class, $day->format('d'));
|
||||
return static::getHtml($class, $day->format('d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,9 +117,9 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getLabelClasses($percentage, $level)
|
||||
protected static function getLabelClasses($percentage, $level)
|
||||
{
|
||||
$classes = $this->getTransientLabelClasses($level);
|
||||
$classes = static::getTransientLabelClasses($level);
|
||||
$classes[] = 'available-' . $percentage;
|
||||
return $classes;
|
||||
}
|
||||
@@ -98,7 +130,7 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTransientLabelClasses($levelFrom, $levelTo = null)
|
||||
protected static function getTransientLabelClasses($levelFrom, $levelTo = null)
|
||||
{
|
||||
$classes = [ 'label' ];
|
||||
if ($levelFrom === static::LEVEL_RED) {
|
||||
@@ -125,7 +157,7 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getOccupancyLevel($percentage, $status)
|
||||
protected static function getOccupancyLevel($percentage, $status)
|
||||
{
|
||||
if ($percentage <= 20 || $status === Contingent::STATUS_BLOCKED) {
|
||||
return static::LEVEL_RED;
|
||||
@@ -141,7 +173,7 @@ class ContingentViewHelper extends AbstractViewHelper
|
||||
* @param string $label
|
||||
* @return string
|
||||
*/
|
||||
protected function getHtml(array $class, $label)
|
||||
protected static function getHtml(array $class, $label)
|
||||
{
|
||||
$cssClass = ' class="' . implode(' ', $class) . '"';
|
||||
return sprintf('<span%s>%s</span>', $cssClass, $label);
|
||||
|
||||
@@ -34,6 +34,7 @@ class IncludesViewHelper extends AbstractConditionViewHelper
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('range', 'object', 'Range to check against', true);
|
||||
$this->registerArgument('period', 'object', 'Period to check if it is included in range', true);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,17 +29,35 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ComfortCategoryViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('hotel', Hotel::class, 'The hotel');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Hotel $hotel
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render(Hotel $hotel)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
/** @var Hotel $hotel */
|
||||
$hotel = $arguments['hotel'];
|
||||
|
||||
$flag = '<span class="category-flag" data-toggle="tooltip" title="%s">%s</span>';
|
||||
|
||||
switch ($hotel->getCategory())
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,38 +28,63 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ContainerViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $columnsWithoutContainers = [ 0, 1, 3 ];
|
||||
protected static $columnsWithoutContainers = [ 0, 1, 3 ];
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('content', 'string', 'The content');
|
||||
$this->registerArgument('cssClasses', 'string', 'Additional css classes');
|
||||
$this->registerArgument('data', 'Array', 'The data', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string $content
|
||||
* @param string $cssClasses
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render(array $data, $content = null, $cssClasses = null)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$content = $renderChildrenClosure();
|
||||
|
||||
if ($content === null) {
|
||||
$content = $this->renderChildren();
|
||||
$content = $arguments['content'];
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
if (in_array($data['colPos'], $this->columnsWithoutContainers, false)) {
|
||||
if (in_array($arguments['data']['colPos'], static::$columnsWithoutContainers, false)) {
|
||||
$classes[] = 'container';
|
||||
} else {
|
||||
$classes[] = 'in-column';
|
||||
}
|
||||
if ($cssClasses !== null) {
|
||||
$classes[] = $cssClasses;
|
||||
if ($arguments['cssClasses'] !== null) {
|
||||
$classes[] = $arguments['cssClasses'];
|
||||
}
|
||||
if (count($classes) > 0) {
|
||||
return '<div class="' . implode(' ', $classes) . '">' . $content . '</div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,23 +28,38 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ContextClassesViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('context', 'Array', 'The context', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $context
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render(array $context)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$classes = [];
|
||||
if (isset($context['country'])) {
|
||||
$classes[] = mb_strtolower($context['country']['name']);
|
||||
if (isset($arguments['context']['country'])) {
|
||||
$classes[] = mb_strtolower($arguments['context']['country']['name']);
|
||||
}
|
||||
if (isset($context['region'])) {
|
||||
$classes[] = mb_strtolower($context['region']['name']);
|
||||
if (isset($arguments['context']['region'])) {
|
||||
$classes[] = mb_strtolower($arguments['context']['region']['name']);
|
||||
}
|
||||
|
||||
$classesString = implode(' ', $classes);
|
||||
@@ -53,5 +68,4 @@ class ContextClassesViewHelper extends AbstractViewHelper
|
||||
|
||||
return $classesString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,21 +29,40 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Utility\DateUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class DateRangeViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param \DateTime $dateFrom
|
||||
* @param \DateTime $dateTo
|
||||
* @param bool $includeLabel
|
||||
* @param string $format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(\DateTime $dateFrom = null, \DateTime $dateTo = null, $includeLabel = true, $format = 'd.m.Y')
|
||||
public function initializeArguments()
|
||||
{
|
||||
return DateUtility::formatDateRange($dateFrom, $dateTo, $includeLabel, $format);
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('dateFrom', \DateTime::class, 'Date range start');
|
||||
$this->registerArgument('dateTo', \DateTime::class, 'Date range end');
|
||||
$this->registerArgument('includeLabel', 'Bool', 'Whether to include a label', false, true);
|
||||
$this->registerArgument('format', 'String', 'The date format', false, 'd.m.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
return DateUtility::formatDateRange(
|
||||
$arguments['dateFrom'],
|
||||
$arguments['dateTo'],
|
||||
$arguments['includeLabel'],
|
||||
$arguments['format']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -30,24 +30,47 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
use EP\EpProducts\Service\FilterSettingsEncoder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class FilterSettingsEncoderViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param string $argument
|
||||
*
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render($argument = null)
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('argument', 'string', 'The argument string to encode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$argument = $renderChildrenClosure();
|
||||
if ($argument === null) {
|
||||
$argument = $this->renderChildren();
|
||||
$argument = $arguments['argument'];
|
||||
}
|
||||
if ($argument === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/** @var \EP\EpProducts\Service\FilterSettingsEncoder $encoder */
|
||||
$encoder = GeneralUtility::makeInstance(FilterSettingsEncoder::class);
|
||||
return $encoder->encode($argument);
|
||||
return $encoder::encode($argument);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,26 +29,41 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Domain\Model\Country;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class FlagiconSourceViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('countryCode', 'string', 'Country code to return a flag icon source for.');
|
||||
$this->registerArgument('country', 'object', 'Country entity to return a flag icon source for.');
|
||||
$this->registerArgument('country', 'mixed', 'Country entity to return a flag icon source for.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$code = null;
|
||||
|
||||
if (is_object($this->arguments['country']) && $this->arguments['country'] instanceof Country) {
|
||||
if (\is_object($arguments['country']) && $arguments['country'] instanceof Country) {
|
||||
/** @var \EP\EpProducts\Domain\Model\Country $country */
|
||||
$country = $this->arguments['country'];
|
||||
$country = $arguments['country'];
|
||||
$code = strtolower($country->getCode());
|
||||
} elseif (!empty($this->arguments['countryCode'])) {
|
||||
$code = strtolower($this->arguments['countryCode']);
|
||||
} elseif (!empty($arguments['countryCode'])) {
|
||||
$code = strtolower($arguments['countryCode']);
|
||||
}
|
||||
|
||||
if ($code !== null) {
|
||||
@@ -57,5 +72,4 @@ class FlagiconSourceViewHelper extends AbstractViewHelper
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Model\Region;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
class GmapsStaticMapViewHelper extends AbstractViewHelper
|
||||
{
|
||||
const URLBASE = '%s¢er=%s,%s&zoom=%d&size=%dx%d';
|
||||
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $manager
|
||||
* @return void
|
||||
*/
|
||||
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
|
||||
{
|
||||
$this->configurationManager = $manager;
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
$this->settings = $settings['plugin']['tx_eptheme']['settings'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Hotel $hotel
|
||||
* @param Region $region
|
||||
* @param int $zoom
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(Hotel $hotel = null, Region $region = null, $zoom = 10, $width = 0, $height = 0)
|
||||
{
|
||||
if ($hotel !== null && $hotel->getLatitude() && $hotel->getLongitude()) {
|
||||
$source = $hotel;
|
||||
} elseif ($hotel !== null && $hotel->getRegion()->getLatitude() && $hotel->getRegion()->getLongitude()) {
|
||||
$source = $hotel->getRegion();
|
||||
} elseif ($region !== null) {
|
||||
$source = $region;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
$staticMapsBaseUrl = $this->settings['googleStaticMapsBaseUrl'];
|
||||
$url = sprintf(static::URLBASE, $staticMapsBaseUrl, $source->getLatitude(), $source->getLongitude(), $zoom, $width, $height);
|
||||
$tag = sprintf('<img class="scale" src="%s" alt="%s" title="%s"/>', $url, $source->getName(), $source->getName());
|
||||
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -30,21 +30,44 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Model\Region;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class GmapsUrlViewHelper extends AbstractViewHelper
|
||||
{
|
||||
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param Hotel $hotel
|
||||
* @param Region $region
|
||||
* @param string $type
|
||||
* @param int $zoom
|
||||
*
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render(Hotel $hotel = null, Region $region = null, $type = 'p', $zoom = 10)
|
||||
protected $escapeOutput = false;
|
||||
|
||||
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('hotel', Hotel::class, 'The hotel');
|
||||
$this->registerArgument('region', Region::class, 'The region');
|
||||
$this->registerArgument('type', 'string', 'The map type', false, 'p');
|
||||
$this->registerArgument('zoom', 'int', 'The zoom level', false, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$hotel = $arguments['hotel'];
|
||||
$region = $arguments['region'];
|
||||
if ($hotel !== null && $hotel->getLatitude() && $hotel->getLongitude()) {
|
||||
$source = $hotel;
|
||||
} elseif ($hotel !== null && $hotel->getRegion()->getLatitude() && $hotel->getRegion()->getLongitude()) {
|
||||
@@ -54,6 +77,7 @@ class GmapsUrlViewHelper extends AbstractViewHelper
|
||||
} else {
|
||||
return 'http://www.google.de/maps';
|
||||
}
|
||||
return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $type, $zoom);
|
||||
return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $arguments['type'], $arguments['zoom']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -27,19 +27,35 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class HotelCategoriesViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('categories', 'array', 'The categories', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $categories
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($categories)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$categories = $arguments['categories'];
|
||||
|
||||
switch (count($categories)) {
|
||||
case 1:
|
||||
$label = reset($categories);
|
||||
@@ -52,4 +68,5 @@ class HotelCategoriesViewHelper extends AbstractViewHelper
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,9 +29,13 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class HotelCategoryViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -42,13 +46,28 @@ class HotelCategoryViewHelper extends AbstractViewHelper
|
||||
Hotel::CATEGORY_SUPER_DELUXE => 'Super Deluxe',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($category)
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('category', 'int', 'The category id', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$category = $arguments['category'];
|
||||
|
||||
return static::$categoryLabels[$category];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,17 +28,33 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class NightsOptionsViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('options', 'array', 'The options');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render(array $options = null)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$options = $arguments['options'];
|
||||
if ($options === null) {
|
||||
return '';
|
||||
}
|
||||
@@ -54,6 +70,7 @@ class NightsOptionsViewHelper extends AbstractViewHelper
|
||||
$output = $lastOption;
|
||||
}
|
||||
$output .= (int) $lastOption > 1 ? ' Nächte' : ' Nacht';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,17 +29,41 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Domain\Model\Product;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class RatingViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render(Product $product)
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('product', Product::class, 'The product', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$product = $renderChildrenClosure();
|
||||
if ($product === null) {
|
||||
$product = $arguments['product'];
|
||||
}
|
||||
$ratingAverage = $product->getRatingAverage();
|
||||
$ratingVotesCount = $product->getRatingVotesCount();
|
||||
$fullStars = floor($ratingAverage);
|
||||
@@ -55,6 +79,7 @@ class RatingViewHelper extends AbstractViewHelper
|
||||
$content .= '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
|
||||
}
|
||||
$content .= sprintf('%s Sterne (%d)', $ratingAverageLabel, $ratingVotesCount);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,27 +28,48 @@ namespace EP\EpTheme\ViewHelpers;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class TopnavItemViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param string $item
|
||||
*
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render($item = null)
|
||||
{
|
||||
if ($item === null) {
|
||||
$item = $this->renderChildren();
|
||||
}
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('item', 'string', 'The navigation item');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$item = $renderChildrenClosure();
|
||||
if ($item === null) {
|
||||
$item = $arguments['item'];
|
||||
}
|
||||
$parts = explode(' ', $item);
|
||||
if (count($parts) === 1) {
|
||||
return $item;
|
||||
}
|
||||
$hiddenMobileText = array_shift($parts);
|
||||
$linkText = implode(' ', $parts);
|
||||
|
||||
return '<span class="hidden-md">' . $hiddenMobileText . '</span> ' . $linkText;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -27,9 +27,8 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
|
||||
class AjaxViewHelper extends ActionViewHelper
|
||||
{
|
||||
@@ -37,58 +36,40 @@ class AjaxViewHelper extends ActionViewHelper
|
||||
const PAGE_TYPE_JSON = 1701;
|
||||
const PAGE_TYPE_HTML = 1702;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $manager
|
||||
*/
|
||||
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
|
||||
public function initializeArguments()
|
||||
{
|
||||
$configurationManager = $manager;
|
||||
$settings = GeneralUtility::removeDotsFromTS($configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
|
||||
$this->settings = $settings['plugin']['tx_eptheme']['settings'];
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->overrideArgument('extensionName', 'string', 'Target extension name', false, 'epproducts');
|
||||
$this->overrideArgument('pluginName', 'string', 'Target plugin name', false, 'Ajax');
|
||||
$this->overrideArgument('format', 'string', 'The requested format', false, 'json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action Target action
|
||||
* @param array $arguments Arguments
|
||||
* @param string $controller Target controller. If NULL current controllerName is used
|
||||
* @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
|
||||
* @param string $pluginName Target plugin. If empty, the current plugin name is used
|
||||
* @param int $pageUid target page. See TypoLink destination
|
||||
* @param int $pageType type of the target page. See typolink.parameter
|
||||
* @param bool $noCache set this to disable caching for the target page. You should not need this.
|
||||
* @param bool $noCacheHash set this to suppress the cHash query parameter created by TypoLink. You should not need this.
|
||||
* @param string $section the anchor to be added to the URI
|
||||
* @param string $format The requested format, e.g. ".html
|
||||
* @param bool $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
|
||||
* @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
|
||||
* @param bool $absolute If set, an absolute URI is rendered
|
||||
* @param bool $addQueryString If set, the current query parameters will be kept in the URI
|
||||
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
|
||||
* @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
|
||||
*
|
||||
* @return string Rendered link
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public function render($action = null, array $arguments = array(), $controller = null, $extensionName = 'epproducts', $pluginName = 'Ajax', $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = true, $section = '', $format = 'json', $linkAccessRestrictedPages = false, array $additionalParams = array(), $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array(), $addQueryStringMethod = null)
|
||||
public static function renderStatic
|
||||
(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
if (array_key_exists('defaultAjaxUid', $this->settings)) {
|
||||
$pageUid = $this->settings['defaultAjaxUid'];
|
||||
}
|
||||
if (strtolower(trim($format)) === 'json') {
|
||||
$pageType = self::PAGE_TYPE_JSON;
|
||||
if (strtolower(trim($arguments['format'])) === 'json') {
|
||||
$arguments['pageType'] = self::PAGE_TYPE_JSON;
|
||||
} else {
|
||||
$pageType = self::PAGE_TYPE_HTML;
|
||||
$arguments['pageType'] = self::PAGE_TYPE_HTML;
|
||||
}
|
||||
if ($pageUid === null) {
|
||||
if ($arguments['pageUid'] === null) {
|
||||
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($GLOBALS['TSFE']->id);
|
||||
$rootPage = array_pop($rootLine);
|
||||
$pageUid = $rootPage['uid'];
|
||||
$arguments['pageUid'] = $rootPage['uid'];
|
||||
}
|
||||
return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid, $pageType, $noCache, $noCacheHash, $section, '', $linkAccessRestrictedPages, $additionalParams, $absolute, $addQueryString, $argumentsToBeExcludedFromQueryString, $addQueryStringMethod);
|
||||
|
||||
return parent::renderStatic($arguments, $renderChildrenClosure, $renderingContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -31,47 +31,62 @@ use EP\EpProducts\Utility\BookingUrlUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class BookingViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
protected static $settings = [];
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $manager
|
||||
* @return void
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
|
||||
public function __construct(ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $manager;
|
||||
$settings = GeneralUtility::removeDotsFromTS($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
|
||||
$this->settings = $settings['plugin']['tx_theme'];
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
static::$settings = $settings['plugin']['tx_theme'];
|
||||
}
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('bookingId', 'string', 'The booking id', true);
|
||||
$this->registerArgument('hotelId', 'string', 'The hotel id', true);
|
||||
$this->registerArgument('template', 'string', 'The booking template');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $bookingId
|
||||
* @param int $hotelId
|
||||
* @param string $template
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($bookingId, $hotelId, $template = null)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$template = $arguments['template'];
|
||||
|
||||
if ($template === null) {
|
||||
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
||||
$template = static::$settings['bpnBookungUrlTemplateCode'];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'bookingId' => $bookingId,
|
||||
'hotelId' => $hotelId,
|
||||
'bookingId' => $arguments['bookingId'],
|
||||
'hotelId' => $arguments['hotelId'],
|
||||
'template' => $template,
|
||||
];
|
||||
return BookingUrlUtility::generateUrl($options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -28,18 +28,44 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ExternalImageViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render($url)
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('url', 'string', 'The url');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$url = $renderChildrenClosure();
|
||||
if ($url === null) {
|
||||
$url = $arguments['url'];
|
||||
}
|
||||
$encryptionKey = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
|
||||
$token = sha1($url . $encryptionKey);
|
||||
return 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/extimg.php?url=' . urlencode($url) . '&token=' . $token;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -29,71 +29,66 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Model\Product;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class ProductViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $manager
|
||||
* @return void
|
||||
*/
|
||||
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
|
||||
public function initializeArgument()
|
||||
{
|
||||
$this->configurationManager = $manager;
|
||||
$settings = GeneralUtility::removeDotsFromTS($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
|
||||
$this->settings = $settings['plugin']['tx_epproducts'];
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('product', Product::class, 'The product', true);
|
||||
$this->registerArgument('hotel', Hotel::class, 'The hotel');
|
||||
$this->registerArgument('linkHotel', 'bool', 'Whether to link the hotel', false, false);
|
||||
$this->registerArgument('referringPageUid', 'int', 'Uid of the referring page');
|
||||
$this->registerArgument('defaultDetailPageUid', 'int', 'Uid of default page for product details');
|
||||
$this->registerArgument('origin', 'string', 'Origin of the link');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
* @param Hotel|null $hotel
|
||||
* @param bool $linkHotel
|
||||
* @param int $referringPageUid
|
||||
* @param string $origin
|
||||
*
|
||||
* @return string
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public function render(Product $product, Hotel $hotel = null, $linkHotel = false, $referringPageUid = null, $origin = null)
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$product = $arguments['product'];
|
||||
if ($product->getDetailPage()) {
|
||||
return $this
|
||||
->controllerContext
|
||||
return $renderingContext
|
||||
->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setTargetPageUid($product->getDetailPage())
|
||||
->build()
|
||||
;
|
||||
;
|
||||
}
|
||||
$pageUid = $this->settings['defaultDetailPageUid'];
|
||||
$arguments = [ 'product' => $product ];
|
||||
if ((int) $referringPageUid > 0) {
|
||||
$arguments['referringPageUid'] = $referringPageUid;
|
||||
|
||||
$pageUid = $arguments['defaultDetailPageUid'];
|
||||
$uriArguments = [ 'product' => $product ];
|
||||
if ((int) $arguments['referringPageUid'] > 0) {
|
||||
$uriArguments['referringPageUid'] = $arguments['referringPageUid'];
|
||||
}
|
||||
if ($origin !== null) {
|
||||
$arguments['origin'] = $origin;
|
||||
if ($arguments['origin'] !== null) {
|
||||
$uriArguments['origin'] = $arguments['origin'];
|
||||
}
|
||||
if ((bool) $linkHotel && $hotel !== null) {
|
||||
$arguments['hotel'] = $hotel;
|
||||
if ((bool) $arguments['linkHotel'] && $arguments['hotel'] !== null) {
|
||||
$uriArguments['hotel'] = $arguments['hotel'];
|
||||
}
|
||||
return $this
|
||||
->controllerContext
|
||||
return $renderingContext
|
||||
->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setTargetPageUid($pageUid)
|
||||
->uriFor('detail', $arguments, 'Product', 'epproducts', 'product_detail')
|
||||
->uriFor('detail', $uriArguments, 'Product', 'epproducts', 'product_detail')
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,24 +28,48 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
class VideoViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param int $layout
|
||||
* @return string
|
||||
* @var bool
|
||||
*/
|
||||
public function render($value, $layout = 1)
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('value', 'string', 'The video url', true);
|
||||
$this->registerArgument('layout', 'int', 'The layout', false, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
// YouTube
|
||||
if ((int) $layout === 0) {
|
||||
return $value . '?rel=0&controls=0&showinfo=0';
|
||||
if ((int) $arguments['layout'] === 0) {
|
||||
return $arguments['value'] . '?rel=0&controls=0&showinfo=0';
|
||||
}
|
||||
// Vimeo
|
||||
if ((int) $layout === 1) {
|
||||
return sprintf('https://player.vimeo.com/video/%d?html5=1', $value);
|
||||
if ((int) $arguments['layout'] === 1) {
|
||||
return sprintf('https://player.vimeo.com/video/%d?html5=1', $arguments['value']);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user