Commit 35929000 authored by Dirk Wildt's avatar Dirk Wildt

0.0.8

parent 098a6c70
......@@ -62,7 +62,7 @@ class BookingController extends AbstractFrontendController
* @since 0.0.8
* @internal #t3869
*/
private function _getCaddyPid( )
private function _getCaddyPid()
{
$caddyUid = $this->_getFlexformCaddy();
$ttContent = $this->_getContentCaddy( $caddyUid );
......@@ -170,8 +170,21 @@ class BookingController extends AbstractFrontendController
$sheet = 'area';
$field = 'settings.flexform.pi1.area.uid';
$areaUid = $this->_getFlexformValue( __METHOD__, __LINE__, $xmlFlexform, $sheet, $field );
$area = $this->areaRepository->findByUid( $areaUid );
return $area;
if( !empty( $areaUid ) )
{
$area = $this->areaRepository->findByUid( $areaUid );
return $area;
}
$prompt = ''
. '<h1>'
. 'ERROR: site plan is missing'
. '</h1>'
. 'Current flexform isn\'t linked with an area (site plan).<br />'
. 'Please take care of a proper configuration.<br />'
. '<br />'
. 'Error occurs @ ' . __METHOD__ . ' (#' . __LINE__ . ')'
;
die( $prompt );
}
/**
......@@ -189,12 +202,25 @@ class BookingController extends AbstractFrontendController
{
return $caddyUid;
}
$xmlFlexform = $this->contentObject->data[ 'pi_flexform' ];
$sheet = 'caddy';
$field = 'settings.flexform.pi1.caddy.uid';
$caddyUid = $this->_getFlexformValue( __METHOD__, __LINE__, $xmlFlexform, $sheet, $field );
return $caddyUid;
if( !empty( $caddyUid ) )
{
return $caddyUid;
}
$prompt = ''
. '<h1>'
. 'ERROR: caddy is missing'
. '</h1>'
. 'Current flexform isn\'t linked with a Caddy.<br />'
. 'Please take care of a proper configuration.<br />'
. '<br />'
. 'Error occurs @ ' . __METHOD__ . ' (#' . __LINE__ . ')'
;
die( $prompt );
}
/**
......
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class AbstractBaseViewhelper
*
* @version 0.0.8
* @since 0.0.8
*/
class AbstractColorViewHelper extends AbstractViewHelper
{
/**
* _getFlexformValue():
*
* @param string method
* @param string line
* @param string flexform
* @param string label of the sheet
* @param string label of the field
* @return mixed value from flexform
* @access protected
* @version 0.0.8
* @since 0.0.8
*/
protected function _hex2rgba( $color, $opacity = false )
{
$default = 'rgb(0,0,0)';
//Return default if no color provided
if( empty( $color ) )
{
return $default;
}
//Sanitize $color if "#" is provided
if( $color[ 0 ] == '#' )
{
$color = substr( $color, 1 );
}
//Check if color has 6 or 3 characters and get values
if( strlen( $color ) == 6 )
{
$hex = array( $color[ 0 ] . $color[ 1 ], $color[ 2 ] . $color[ 3 ], $color[ 4 ] . $color[ 5 ] );
}
elseif( strlen( $color ) == 3 )
{
$hex = array( $color[ 0 ] . $color[ 0 ], $color[ 1 ] . $color[ 1 ], $color[ 2 ] . $color[ 2 ] );
}
else
{
return $default;
}
//Convert hexadec to rgb
$rgb = array_map( 'hexdec', $hex );
//Check if opacity is set(rgba or rgb)
if( $opacity )
{
if( abs( $opacity ) > 1 )
{
$opacity = 1.0;
}
$output = 'rgba(' . implode( ",", $rgb ) . ',' . $opacity . ')';
}
else
{
$output = 'rgb(' . implode( ",", $rgb ) . ')';
}
//Return rgb(a) color string
return $output;
}
}
......@@ -11,7 +11,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
* @version 0.0.8
* @since 0.0.8
*/
class AbstractBaseViewHelper extends AbstractViewHelper
class AbstractFlexformViewHelper extends AbstractViewHelper
{
......
......@@ -19,7 +19,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* @since 0.0.8
* @internal #t3816
*/
class CellClassViewHelper extends AbstractBaseViewHelper
class CellClassViewHelper extends AbstractFlexformViewHelper
{
/**
......
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\CategoryRepository;
use Netzmacher\Tile\Domain\Repository\CellRepository;
use Netzmacher\Tile\Domain\Repository\CssRepository;
use Netzmacher\Tile\Domain\Repository\TicketRepository;
use Netzmacher\Tile\Utility\ObjectUtility;
use Netzmacher\Tile\Utility\SessionUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class CellClassViewHelper
*
* @version 0.0.8
* @since 0.0.8
* @internal #t3816
*/
class CellClassViewHelper extends AbstractViewHelper
{
/**
* Current cell
*
* @var \Netzmacher\Tile\Domain\Model\Cell
*/
private $_cell = null;
/**
* Category Repository
*
* @var Netzmacher\Tile\Domain\Repository\CategoryRepository
*/
private $_categoryRepository = null;
/**
* Prompts in context with static varibales. For development only
*
* @var boolean
*/
private $_promptStatic = true;
/**
* Session class
*
* @var Netzmacher\Tile\Utility\SessionUtility
*/
private static $_sessionUtility = null;
/**
* @return mixed
*/
private function _getClassCategory()
{
if( $this->_dontDisplayCategory() )
{
return;
}
$class = $this->_getClassCategoryOfCurrentCell();
return $class;
}
/**
* @return mixed
*/
private function _getClassCategoryOfCurrentCell()
{
$this->_initCategoryRepository();
$uidCategory = $this->_cell->getTxTileCategory();
if( empty( $uidCategory ) )
{
return;
}
$category = $this->_getCategoryByUid( $uidCategory );
if( empty( $category ) )
{
return;
}
$categoryCss = $category->getTxTileCss();
$categoryCssUid = $categoryCss->getUid();
$cssRepository = ObjectUtility::getObjectManager()->get( CssRepository::class );
$css = $cssRepository->findByUid( $categoryCssUid );
var_dump( __METHOD__, __LINE__, $uidCategory );
var_dump( __METHOD__, __LINE__, 'Hier weiterarbeiten' );
die();
// return;
//
return $css->getClass();
}
/**
* @param integer $uid
* @return mixed
*/
private function _getCategoryByUid( $uid )
{
static $categories = null;
if( isset( $categories[ $uid ] ) )
{
return $categories[ $uid ];
}
$categories[ $uid ] = $this->categoryRepository->findByUid( $uid );
$prompt = 'This prompt should display once only for "' . $categories[ $uid ] . '"! Check of static variables:';
$this->_promptStatic( __METHOD__, __LINE__, $prompt );
return $categories[ $uid ];
}
/**
* @return mixed
*/
private function _getGroupCss()
{
static $display = null;
if( $display === false )
{
return;
}
$display = $this->_sessionUtility->getSessionElement( 'formCellWiGroups', false );
if( empty( $display ) )
{
$display = false;
}
var_dump( __METHOD__, __LINE__, $display );
return;
$default = $this->arguments[ 'default' ];
$class = $this->arguments[ 'class' ];
$uidCell = $this->arguments[ 'uidCell' ];
switch( true )
{
case( empty( $uidCell ) ):
case( empty( $class ) ):
return $default;
default :
// follow the workflow
break;
}
$cssCell = ObjectUtility::getObjectManager()->get( CellRepository::class );
$cell = $cssCell->findByUid( $uidCell );
if( empty( $cell ) )
{
return '';
}
return $cell->getGroupcss();
}
/**
* @param string $status: caddy | default | selled
* @return mixed
*/
private function _getProductCss( $status = 'default' )
{
$default = $this->arguments[ 'default' ];
$class = $this->arguments[ 'class' ];
$uid = $this->arguments[ 'uidTicket' ];
switch( true )
{
case( empty( $uid ) ):
case( empty( $class ) ):
return $default;
default :
// follow the workflow
break;
}
$ticketRepository = ObjectUtility::getObjectManager()->get( TicketRepository::class );
$ticket = $ticketRepository->findByUid( $uid );
if( empty( $ticket ) )
{
return null;
}
switch( $status )
{
case('caddy'):
$ticketCss = $ticket->getTxTileCsscaddy();
break;
case('default'):
$ticketCss = $ticket->getTxTileCssdefault();
break;
case('selled'):
$ticketCss = $ticket->getTxTileCssselled();
break;
default:
$prompt = 'Undefined value in switch @ ' . __METHOD__ . ' (#' . __LINE__ . ')';
die( $prompt );
}
if( empty( $ticketCss ) )
{
$this->_getProductCssPromptDie( __METHOD__, __LINE__, $ticket );
}
$ticketCssUid = $ticketCss->getUid();
$cssRepository = ObjectUtility::getObjectManager()->get( CssRepository::class );
$css = $cssRepository->findByUid( $ticketCssUid );
return $css->getClass();
}
/**
* @param string $method
* @param string $line
* @param string $ticket
* @return void
*/
private function _getProductCssPromptDie( $method, $line, $ticket )
{
$prompt = 'ERROR @ ' . $method . ' (#' . $line . ')<br />'
. '<br />'
. 'It seems, that a CSS class of the ticket with the uid #' . $ticket->getUid() . ' is empty.<br />'
. 'Please check the ticket!'
;
die( $prompt );
}
/**
* Init the Category Repository once
*
* @return void
*/
private function _initCategoryRepository()
{
static $categoryRepository = null;
if( $categoryRepository !== null )
{
$this->_categoryRepository = $categoryRepository;
return;
}
$categoryRepository = ObjectUtility::getObjectManager()->get( CategoryRepository::class );
$this->_categoryRepository = $categoryRepository;
$this->_promptStatic( __METHOD__, __LINE__ );
}
/**
* Init the session class once
*
* @param array $cData content data of current object
*
* @return void
*/
private function _initSessionObject( $cData )
{
static $sessionUtility = null;
if( $sessionUtility !== null )
{
$this->_sessionUtility = $sessionUtility;
$this->_sessionUtility->setCData( $cData );
return;
}
$sessionUtility = GeneralUtility::makeInstance( SessionUtility::class );
$this->_sessionUtility = $sessionUtility;
$this->_sessionUtility->setCData( $cData );
$this->_promptStatic( __METHOD__, __LINE__ );
}
/**
* @return mixed
*/
private function _dontDisplayCategory()
{
static $display = null;
if( $display === false )
{
return false;
}
$display = $this->_sessionUtility->getSessionElement( 'formCellWiCategories', false );
if( empty( $display ) )
{
$this->_promptStatic( __METHOD__, __LINE__ );
return false;
}
$this->_promptStatic( __METHOD__, __LINE__ );
return true;
}
/**
* Prompt in context with static variables
*
* @param string $method
* @param string $line
* @param string $prompt
*
* @return void
*/
private function _promptStatic( $method, $line, $prompt = 'This prompt should display once only! Check of static variables:' )
{
if( !$this->_promptStatic )
{
return;
}
echo '[#' . $line . '] ' . $prompt . ' @ ' . $method . ' (#' . $line . ')<br />' . PHP_EOL;
}
/**
* @param int $uid
* @return mixed
*/
private function _getProductCssSelled()
{
$default = $this->arguments[ 'default' ];
$class = $this->arguments[ 'class' ];
$uid = $this->arguments[ 'uidTicket' ];
switch( true )
{
case( empty( $uid ) ):
case( empty( $class ) ):
return $default;
default :
// follow the workflow
break;
}
$ticketRepository = ObjectUtility::getObjectManager()->get( TicketRepository::class );
$ticket = $ticketRepository->findByUid( $uid );
if( empty( $ticket ) )
{
return null;
}
$ticketCss = $ticket->getTxTileCss();
$ticketCssUid = $ticketCss->getUid();
$cssRepository = ObjectUtility::getObjectManager()->get( CssRepository::class );
$css = $cssRepository->findByUid( $ticketCssUid );
return $css->getClass();
}
/**
* @return void
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument( 'cell', 'Netzmacher\Tile\Domain\Model\Cell', 'cell', false, null );
$this->registerArgument( 'cData', 'array', 'cData', false, null );
}
/**
* @return mixed
*/
public function render()
{
$class = null;
$cell = $this->arguments[ 'cell' ];
$cData = $this->arguments[ 'cData' ];
if( empty( $cell ) )
{
return $class;
}
$this->_cell = $cell;
$this->_initSessionObject( $cData );
$class = $class . $this->_getClassCategory();
$class = $class . $this->_getGroupCss();
$class = $class . $this->_getProductCss();
//$class = $class . $this->_getUndefinedTileCss();
return $class;
var_dump( __METHOD__, __LINE__, serialize( $this->arguments[ 'cell' ] ) );
die();
// switch( $this->arguments[ 'class' ] )
// {
// case('cssClassForCategory'):
// return $this->_getClassCategory();
// case('cssClassForGroup'):
// return $this->_getGroupCss();
// case('cssClassForTicketCaddy'):
// return $this->_getProductCss( 'caddy' );
// case('cssClassForTicket'):
// case('cssClassForTicketDefault'):
// return $this->_getProductCss();
// case('cssClassForTicketSelled'):
// return $this->_getProductCss( 'selled' );
// case(''):
// return $this->arguments[ 'default' ];
// default:
// var_dump( __METHOD__, __LINE__, 'Error in switch! Unexpected value.' );
// die();
// }
}
}
......@@ -6,7 +6,6 @@ namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\CssRepository;
use Netzmacher\Tile\Utility\ObjectUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class GetCellCategoryCssViewHelper
......@@ -15,7 +14,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
* @since 0.0.3
* @internal #t3731
*/
class CssClassesViewHelper extends AbstractViewHelper
class CssClassesViewHelper extends AbstractColorViewHelper
{
/**
......@@ -49,8 +48,7 @@ class CssClassesViewHelper extends AbstractViewHelper
{
$arrReturn[] = '' .
$prefix . '.' . $css->getClass() . ' {
background-color: ' . $css->getColor() . ';
opacity: ' . $css->getOpacity() . ';
background-color: ' . $this->_hex2rgba( $css->getColor(), $css->getOpacity() ) . ';
}
';
}
......
......@@ -2,7 +2,7 @@
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
namespace Netzmacher\Tile\ViewHelpers\Get\Modul;
use Netzmacher\Tile\Domain\Repository\CategoryRepository;
use Netzmacher\Tile\Domain\Repository\CellRepository;
......
......@@ -6,7 +6,7 @@
<f:if condition="{formCellWiBgimageChecked}==1">
<style>
.grid-container {
.grid-container-{area.uid} {
background-image: url("/{area.image.originalResource.publicUrl}");
background-position: center;
background-repeat: no-repeat;
......
......@@ -65,9 +65,9 @@
<h2>Objekt zuweisen: {categoryTitle}, Modus: {currentModeLabel}</h2>
<div class="grid-container">
<f:for each="{cells}" as="cell">
<div class="{vh:Get.CssClass(uidGroup: cell.txTileTicket, uidCell: cell.uid, class: '{cssForGroup}', default: '')}">
<div class="{vh:Get.CssClass(uidTicket: cell.txTileTicket, uidCell: cell.uid, class: '{cssForTicket}', default: '')}">
<div class="{vh:Get.CssClass(uidCategory: cell.txTileCategory, uidCell: cell.uid, class: '{cssForCategory}', default: '{cssClassUndefinedCell}')}">
<div class="{vh:Get.Modul.CssClass(uidGroup: cell.txTileTicket, uidCell: cell.uid, class: '{cssForGroup}', default: '')}">
<div class="{vh:Get.Modul.CssClass(uidTicket: cell.txTileTicket, uidCell: cell.uid, class: '{cssForTicket}', default: '')}">
<div class="{vh:Get.Modul.CssClass(uidCategory: cell.txTileCategory, uidCell: cell.uid, class: '{cssForCategory}', default: '{cssClassUndefinedCell}')}">
<f:if condition="{area.type}=1">
<f:then>
<a href="#" title="[Ein Live-Objekt kann nicht verändert werden!] {vh:Get.GroupField(uid: cell.txTileGroup.uid, field: 'title', default: '', prefix: '')}{vh:Get.TicketField(uid: cell.txTileTicket, field: 'title', default: '', prefix: ', ')}{vh:Get.TicketField(uid: cell.txTileTicket, field: 'price', currency: 'EUR', default: '', locale: 'de_DE', prefix: '')}">&nbsp;</a>
......
{namespace vh=Netzmacher\Tile\ViewHelpers}
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="content">
<f:flashMessages />
<f:variable name="cssForCategory"></f:variable>
<f:if condition="{formCellWiCategoriesChecked}">
<f:variable name="cssForCategory">cssClassForCategory</f:variable>
</f:if>
<f:variable name="cssForGroup"></f:variable>
<f:if condition="{formCellWiGroupsChecked}">
<f:variable name="cssForGroup">cssClassForGroup</f:variable>
</f:if>
<f:variable name="cssForTicket"></f:variable>
<f:if condition="{formCellWiTicketsChecked}">
<f:variable name="cssForTicket">cssClassForTicket</f:variable>
</f:if>
<f:variable name="cssClassUndefinedCell"></f:variable>
<f:if condition="{formCellWiUndefinedCellsChecked}">
<f:variable name="cssClassUndefinedCell">undefined</f:variable>
</f:if>
<f:if condition="{formCellWiBgimageChecked}==1">
<style>
.grid-container {
background-image: url("/{area.image.originalResource.publicUrl}");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
</f:if>
<style>
.grid-container {
position: relative;
display: inline-grid;
grid-template-columns: {grid-template-columns};
grid-gap: 2px;
background-color: #FF5E00;
background-color: #FDFDFD;
padding: 0.4rem;
}
.grid-container > div {
/*background-color: rgba(255, 255, 255, 1);*/
text-align: center;
font-size: {size}px;
width: {size}px;
height: {size}px;
overflow: hidden;
}
.grid-container div.undefined {
background-color: rgba(0, 0, 0, 0.1);
}
.grid-container div.disabled {
background-color: rgba(255, 255, 255, 0.2);
}
<f:format.raw><vh:Get.CssClasses prefix=".grid-container div" /></f:format.raw>
.grid-container div a {
display: block;
}
</style>
<h1><f:translate key="tx_tile_domain_model_area.title" />: {area.title} ({area.lenx}x{area.leny})</h1>
<h2>Objekt zuweisen: {categoryTitle}, Modus: {currentModeLabel}</h2>
<div class="grid-container">
<f:for each="{cells}" as="cell">
<div class="{vh:Get.CssClass(uidGroup: cell.txTileTicket, uidCell: cell.uid, class: '{cssForGroup}', default: '')}">
<div class="{vh:Get.CssClass(uidTicket: cell.txTileTicket, uidCell: cell.uid, class: '{cssForTicket}', default: '')}">
<div class="{vh:Get.CssClass(uidCategory: cell.txTileCategory, uidCell: cell.uid, class: '{cssForCategory}', default: '{cssClassUndefinedCell}')}">
<f:if condition="{area.type}=1">
<f:then>
<a href="#" title="[Ein Live-Objekt kann nicht verändert werden!] {vh:Get.GroupField(uid: cell.txTileGroup.uid, field: 'title', default: '', prefix: '')}{vh:Get.TicketField(uid: cell.txTileTicket, field: 'title', default: '', prefix: ', ')}{vh:Get.TicketField(uid: cell.txTileTicket, field: 'price', currency: 'EUR', default: '', locale: 'de_DE', prefix: '')}">&nbsp;</a>
</f:then>
<f:else>
<f:link.action action="updatecell" controller="Category" arguments="{cell : cell, area : area}" title="{cell.title}{vh:Get.CategoryField(uid: cell.txTileCategory, field: 'title', default: '', prefix: ', ')}">&nbsp;</f:link.action>
</f:else>
</f:if>
</div>
</div>
</div>
</f:for>
</div>
<div style="clear:both;"></div>