Initial commit

This commit is contained in:
Björn Fromme
2018-04-18 17:24:00 +02:00
commit da4db35be3
875 changed files with 80368 additions and 0 deletions
@@ -0,0 +1,53 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ArgumentPrefixViewHelper extends AbstractViewHelper
{
/**
* @param string $pluginName
* @param string $extensionName
*
* @return string
*/
public function render($pluginName = null, $extensionName = null)
{
$request = $this->controllerContext->getRequest();
if ($pluginName === null) {
$pluginName = $request->getPluginName();
}
if ($extensionName === null) {
$extensionName = $request->getControllerExtensionName();
}
return strtolower(implode('_', ['tx', $extensionName, $pluginName]));
}
}
@@ -0,0 +1,149 @@
<?php
namespace EP\EpTheme\ViewHelpers\Calendar;
/***************************************************************
*
* 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 CalendR\Event\Collection\Basic;
use CalendR\Period\Day;
use CalendR\Period\Month;
use EP\EpProducts\Domain\Model\Contingent;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContingentViewHelper extends AbstractViewHelper
{
const LEVEL_GREEN = 1;
const LEVEL_YELLOW = 2;
const LEVEL_RED = 3;
public function render(Month $month, Day $day, Basic $events)
{
if (!$month->includes($day)) {
return '';
}
$now = new \DateTime('now');
if ($now > $day->getBegin()) {
$class = [ 'text-muted' ];
return $this->getHtml($class, $day->format('d'));
}
$contingents = $events->find($day);
if (count($contingents) === 0) {
$percentage = 100;
$level = static::LEVEL_GREEN;
} else {
$contingent = reset($contingents);
$percentage = $contingent->getPercentageAvailable();
$status = $contingent->getStatus();
$level = $this->getOccupancyLevel($percentage, $status);
}
$previousDay = $day->getPrevious();
$previousContingents = $events->find($previousDay);
if (count($previousContingents) === 0) {
$previousLevel = static::LEVEL_GREEN;
} else {
$previousContingent = reset($previousContingents);
$previousPercentage = $previousContingent->getPercentageAvailable();
$previousStatus = $previousContingent->getStatus();
$previousLevel = $this->getOccupancyLevel($previousPercentage, $previousStatus);
}
if ($previousLevel !== $level) {
$class = $this->getTransientLabelClasses($previousLevel, $level);
} else {
$class = $this->getLabelClasses($percentage, $level);
}
return $this->getHtml($class, $day->format('d'));
}
/**
* @param int $percentage
* @param int $level
*
* @return array
*/
protected function getLabelClasses($percentage, $level)
{
$classes = $this->getTransientLabelClasses($level);
$classes[] = 'available-' . $percentage;
return $classes;
}
/**
* @param int $levelFrom
* @param int|null $levelTo
*
* @return array
*/
protected function getTransientLabelClasses($levelFrom, $levelTo = null)
{
$classes = [ 'label' ];
if ($levelFrom === static::LEVEL_RED) {
$class = 'label-danger';
} elseif ($levelFrom === static::LEVEL_YELLOW) {
$class = 'label-warning';
} else {
$class = 'label-success';
}
if ($levelTo === static::LEVEL_RED) {
$class .= '-danger';
} elseif ($levelTo === static::LEVEL_YELLOW) {
$class .= '-warning';
} elseif ($levelTo !== null) {
$class .= '-success';
}
$classes[] = $class;
return $classes;
}
/**
* @param int $percentage
* @param int $status
*
* @return int
*/
protected function getOccupancyLevel($percentage, $status)
{
if ($percentage <= 20 || $status === Contingent::STATUS_BLOCKED) {
return static::LEVEL_RED;
}
if (($percentage > 20 && $percentage <= 80) || $status === Contingent::STATUS_ONREQUEST) {
return static::LEVEL_YELLOW;
}
return static::LEVEL_GREEN;
}
/**
* @param array $class
* @param string $label
* @return string
*/
protected function getHtml(array $class, $label)
{
$cssClass = ' class="' . implode(' ', $class) . '"';
return sprintf('<span%s>%s</span>', $cssClass, $label);
}
}
@@ -0,0 +1,53 @@
<?php
namespace EP\EpTheme\ViewHelpers\Calendar;
/***************************************************************
*
* 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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
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);
}
/**
* @param array $arguments
* @return bool
*/
protected static function evaluateCondition($arguments = null)
{
/** @var \CalendR\Period\Range $range */
$range = $arguments['range'];
/** @var \CalendR\Period\PeriodInterface $period */
$period = $arguments['period'];
return $range->includes($period);
}
}
@@ -0,0 +1,70 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ComfortCategoryViewHelper extends AbstractViewHelper
{
/**
* @param Hotel $hotel
*
* @return string
*/
public function render(Hotel $hotel)
{
$flag = '<span class="category-flag" data-toggle="tooltip" title="%s">%s</span>';
switch ($hotel->getCategory())
{
case Hotel::CATEGORY_STANDARD:
$icon = 'S';
$tooltip = 'Kategorie: Standard';
break;
case Hotel::CATEGORY_COMFORT:
$icon = 'C';
$tooltip = 'Kategorie: Komfort';
break;
case Hotel::CATEGORY_DELUXE:
$icon = 'D';
$tooltip = 'Kategorie: Deluxe';
break;
case Hotel::CATEGORY_SUPER_DELUXE:
$icon = 'SD';
$tooltip = 'Kategorie: Superdeluxe';
break;
default:
return '';
}
return sprintf($flag, $tooltip, $icon);
}
}
@@ -0,0 +1,65 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContainerViewHelper extends AbstractViewHelper
{
/**
* @var array
*/
protected $columnsWithoutContainers = [ 0, 1, 3 ];
/**
* @param array $data
* @param string $content
* @param string $cssClasses
*
* @return string
*/
public function render(array $data, $content = null, $cssClasses = null)
{
if ($content === null) {
$content = $this->renderChildren();
}
$classes = [];
if (in_array($data['colPos'], $this->columnsWithoutContainers, false)) {
$classes[] = 'container';
} else {
$classes[] = 'in-column';
}
if ($cssClasses !== null) {
$classes[] = $cssClasses;
}
if (count($classes) > 0) {
return '<div class="' . implode(' ', $classes) . '">' . $content . '</div>';
}
return $content;
}
}
@@ -0,0 +1,57 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContextClassesViewHelper extends AbstractViewHelper
{
/**
* @param array $context
*
* @return string
*/
public function render(array $context)
{
$classes = [];
if (isset($context['country'])) {
$classes[] = mb_strtolower($context['country']['name']);
}
if (isset($context['region'])) {
$classes[] = mb_strtolower($context['region']['name']);
}
$classesString = implode(' ', $classes);
$classesString = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $classesString);
return $classesString;
}
}
@@ -0,0 +1,49 @@
<?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\Utility\DateUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class DateRangeViewHelper extends AbstractViewHelper
{
/**
* @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')
{
return DateUtility::formatDateRange($dateFrom, $dateTo, $includeLabel, $format);
}
}
@@ -0,0 +1,53 @@
<?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\Service\FilterSettingsEncoder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class FilterSettingsEncoderViewHelper extends AbstractViewHelper
{
/**
* @param string $argument
*
* @return string
*/
public function render($argument = null)
{
if ($argument === null) {
$argument = $this->renderChildren();
}
if ($argument === null) {
return '';
}
/** @var \EP\EpProducts\Service\FilterSettingsEncoder $encoder */
$encoder = GeneralUtility::makeInstance(FilterSettingsEncoder::class);
return $encoder->encode($argument);
}
}
@@ -0,0 +1,61 @@
<?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\Country;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class FlagiconSourceViewHelper extends AbstractViewHelper
{
public function 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.');
}
public function render()
{
$code = null;
if (is_object($this->arguments['country']) && $this->arguments['country'] instanceof Country) {
/** @var \EP\EpProducts\Domain\Model\Country $country */
$country = $this->arguments['country'];
$code = strtolower($country->getCode());
} elseif (!empty($this->arguments['countryCode'])) {
$code = strtolower($this->arguments['countryCode']);
}
if ($code !== null) {
return 'EXT:ep_theme/Resources/Public/images/' . $code . '.png';
}
return '';
}
}
@@ -0,0 +1,89 @@
<?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&center=%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;
}
}
@@ -0,0 +1,59 @@
<?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\Fluid\Core\ViewHelper\AbstractViewHelper;
class GmapsUrlViewHelper extends AbstractViewHelper
{
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
/**
* @param Hotel $hotel
* @param Region $region
* @param string $type
* @param int $zoom
*
* @return string
*/
public function render(Hotel $hotel = null, Region $region = null, $type = 'p', $zoom = 10)
{
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 'http://www.google.de/maps';
}
return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $type, $zoom);
}
}
@@ -0,0 +1,54 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class HotelCategoryViewHelper extends AbstractViewHelper
{
/**
* @var array
*/
static protected $categoryLabels = [
Hotel::CATEGORY_STANDARD => 'Standard',
Hotel::CATEGORY_COMFORT => 'Comfort',
Hotel::CATEGORY_DELUXE => 'Deluxe',
Hotel::CATEGORY_SUPER_DELUXE => 'Super Deluxe',
];
/**
* @param int $category
*
* @return string
*/
public function render($category)
{
return static::$categoryLabels[$category];
}
}
@@ -0,0 +1,60 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class NightsOptionsViewHelper extends AbstractViewHelper
{
/**
* @param array $options
*
* @return string
*/
public function render(array $options = null)
{
if ($options === null) {
return '';
}
sort($options);
$optionsCount = count($options);
$lastOption = array_pop($options);
$output = '';
if ($optionsCount > 2) {
$output .= implode(', ' , $options) . ' oder ' . $lastOption;
} elseif ($optionsCount === 2) {
$output .= reset($options) . ' oder ' . $lastOption;
} else {
$output = $lastOption;
}
$output .= (int) $lastOption > 1 ? ' Nächte' : ' Nacht';
return $output;
}
}
@@ -0,0 +1,61 @@
<?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\Product;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class RatingViewHelper extends AbstractViewHelper
{
/**
* @param Product $product
*
* @return string
*/
public function render(Product $product)
{
$ratingAverage = $product->getRatingAverage();
$ratingVotesCount = $product->getRatingVotesCount();
$fullStars = floor($ratingAverage);
$halfStar = ($ratingAverage - $fullStars) > 0;
$ratingAverageLabel = number_format($ratingAverage, 1, ',', '.');
$content = '';
for ($i = 1; $i <= $fullStars; $i++)
{
$content .= '<i class="fa fa-star" aria-hidden="true"></i>';
}
if ($halfStar) {
$content .= '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
}
$content .= sprintf('%s Sterne (%d)', $ratingAverageLabel, $ratingVotesCount);
return $content;
}
}
@@ -0,0 +1,55 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class TopnavItemViewHelper extends AbstractViewHelper
{
/**
* @param string $item
*
* @return string
*/
public function render($item = null)
{
if ($item === null) {
$item = $this->renderChildren();
}
$parts = explode(' ', $item);
if (count($parts) === 1) {
return $item;
}
$hiddenMobileText = array_shift($parts);
$linkText = implode(' ', $parts);
return '<span class="hidden-md">' . $hiddenMobileText . '</span> ' . $linkText;
}
}
@@ -0,0 +1,94 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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 TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper;
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)
{
$configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS($configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
$this->settings = $settings['plugin']['tx_eptheme']['settings'];
}
/**
* @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
*/
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)
{
if (array_key_exists('defaultAjaxUid', $this->settings)) {
$pageUid = $this->settings['defaultAjaxUid'];
}
if (strtolower(trim($format)) === 'json') {
$pageType = self::PAGE_TYPE_JSON;
} else {
$pageType = self::PAGE_TYPE_HTML;
}
if ($pageUid === null) {
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($GLOBALS['TSFE']->id);
$rootPage = array_pop($rootLine);
$pageUid = $rootPage['uid'];
}
return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid, $pageType, $noCache, $noCacheHash, $section, '', $linkAccessRestrictedPages, $additionalParams, $absolute, $addQueryString, $argumentsToBeExcludedFromQueryString, $addQueryStringMethod);
}
}
@@ -0,0 +1,72 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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\Utility\BookingUrlUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class BookingViewHelper extends AbstractViewHelper
{
/**
* @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_theme'];
}
/**
* @param int $bookingId
* @param int $hotelId
* @param string $template
*
* @return string
*/
public function render($bookingId, $hotelId, $template = null)
{
if ($template === null) {
$template = $this->settings['bpnBookingUrlTemplateCode'];
}
return BookingUrlUtility::generateUrl($bookingId, $hotelId, $template);
}
}
@@ -0,0 +1,45 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ExternalImageViewHelper extends AbstractViewHelper
{
/**
* @param string $url
*
* @return string
*/
public function render($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;
}
}
@@ -0,0 +1,100 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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\Product;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ProductViewHelper extends AbstractViewHelper
{
/**
* @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_epproducts'];
}
/**
* @param Product $product
* @param Hotel|null $hotel
* @param bool $linkHotel
* @param int $referringPageUid
* @param string $origin
*
* @return string
*/
public function render(Product $product, Hotel $hotel = null, $linkHotel = false, $referringPageUid = null, $origin = null)
{
if ($product->getDetailPage()) {
return $this
->controllerContext
->getUriBuilder()
->reset()
->setTargetPageUid($product->getDetailPage())
->build()
;
}
$pageUid = $this->settings['defaultDetailPageUid'];
$arguments = [ 'product' => $product ];
if ((int) $referringPageUid > 0) {
$arguments['referringPageUid'] = $referringPageUid;
}
if ($origin !== null) {
$arguments['origin'] = $origin;
}
if ((bool) $linkHotel && $hotel !== null) {
$arguments['hotel'] = $hotel;
}
return $this
->controllerContext
->getUriBuilder()
->reset()
->setTargetPageUid($pageUid)
->uriFor('detail', $arguments, 'Product', 'epproducts', 'product_detail')
;
}
}
@@ -0,0 +1,51 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class VideoViewHelper extends AbstractViewHelper
{
/**
* @param string $value
* @param int $layout
* @return string
*/
public function render($value, $layout = 1)
{
// YouTube
if ((int) $layout === 0) {
return $value . '?rel=0&amp;controls=0&amp;showinfo=0';
}
// Vimeo
if ((int) $layout === 1) {
return sprintf('https://player.vimeo.com/video/%d?html5=1', $value);
}
return '';
}
}