Commit 978e3065 authored by Dirk Wildt's avatar Dirk Wildt

0.0.7

parent 68e64735
<?php
namespace Netzmacher\Tile\Controller;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/* * *************************************************************
* Copyright notice
*
* (c) 2019 - Dirk Wildt <http://wildt.at.die-netzmacher.de>
* 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 2 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!
* ************************************************************* */
/**
* AbstractFrontendController for the tile extension
*
* @package TYPO3
* @subpackage tile
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @version 0.0.7
* @since 0.0.7
* @internal #t3866
*/
class AbstractFrontendController extends AbstractController
{
/**
* @var Netzmacher\Tile\Utility\SessionUtility
*/
protected $_oSessionUtility;
/**
* _initObjectSession( ) :
*
* @return void
* @access private
* @version 0.0.7
* @since 0.0.7
*/
private function _initObjectSession()
{
$this->_oSessionUtility = GeneralUtility::makeInstance( 'Netzmacher\\Tile\\Utility\\SessionUtility' );
}
/**
* _getSessionSpace( ): Get the name of the session data space.
* The name is user, if a frontend user is logged in.
* The name is ses, if any frontend user isn't logged in.
*
* @return string user || ses
* @version 0.0.7
* @since 0.0.7
*/
protected function _getSessionSpace()
{
switch( $GLOBALS[ 'TSFE' ]->loginUser )
{
case( true ):
return 'user';
default:
return 'ses';
}
}
/**
* initObjects( ) :
*
* @return void
* @access private
* @version 0.0.7
* @since 0.0.7
*/
protected function _initObjects()
{
$this->_initObjectContent();
$this->_initObjectSession();
}
}
This diff is collapsed.
......@@ -37,11 +37,25 @@ class Ticket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
protected $title = '';
/**
* txTileCss
* txTileCsscaddy
*
* @var \Netzmacher\Tile\Domain\Model\Css
*/
protected $txTileCss = null;
protected $txTileCsscaddy = null;
/**
* txTileCssdefault
*
* @var \Netzmacher\Tile\Domain\Model\Css
*/
protected $txTileCssdefault = null;
/**
* txTileCssselled
*
* @var \Netzmacher\Tile\Domain\Model\Css
*/
protected $txTileCssselled = null;
/**
* Returns the price
......@@ -86,24 +100,66 @@ class Ticket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
/**
* Returns the txTileCss
* Returns the txTileCsscaddy
*
* @return \Netzmacher\Tile\Domain\Model\Css $txTileCsscaddy
*/
public function getTxTileCsscaddy()
{
return $this->txTileCsscaddy;
}
/**
* Sets the txTileCsscaddy
*
* @param \Netzmacher\Tile\Domain\Model\Css $txTileCsscaddy
* @return void
*/
public function setTxTileCsscaddy( \Netzmacher\Tile\Domain\Model\Css $txTileCsscaddy )
{
$this->txTileCsscaddy = $txTileCsscaddy;
}
/**
* Returns the txTileCssdefault
*
* @return \Netzmacher\Tile\Domain\Model\Css $txTileCssdefault
*/
public function getTxTileCssdefault()
{
return $this->txTileCssdefault;
}
/**
* Sets the txTileCssdefault
*
* @param \Netzmacher\Tile\Domain\Model\Css $txTileCssdefault
* @return void
*/
public function setTxTileCssdefault( \Netzmacher\Tile\Domain\Model\Css $txTileCssdefault )
{
$this->txTileCssdefault = $txTileCssdefault;
}
/**
* Returns the txTileCssselled
*
* @return \Netzmacher\Tile\Domain\Model\Css $txTileCss
* @return \Netzmacher\Tile\Domain\Model\Css $txTileCssselled
*/
public function getTxTileCss()
public function getTxTileCssselled()
{
return $this->txTileCss;
return $this->txTileCssselled;
}
/**
* Sets the txTileCss
* Sets the txTileCssselled
*
* @param \Netzmacher\Tile\Domain\Model\Css $txTileCss
* @param \Netzmacher\Tile\Domain\Model\Css $txTileCssselled
* @return void
*/
public function setTxTileCss( \Netzmacher\Tile\Domain\Model\Css $txTileCss )
public function setTxTileCssselled( \Netzmacher\Tile\Domain\Model\Css $txTileCssselled )
{
$this->txTileCss = $txTileCss;
$this->txTileCssselled = $txTileCssselled;
}
}
<?php
namespace Netzmacher\Tile\Utility;
/* * *
*
* This file is part of the "Book a tile!" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019 Dirk Wildt (Die Netzmacher) <http://wildt@die-netzmacher.de>, Die Netzmacher
*
* * */
/**
* SessionUtility
*
* @version 0.0.7
* @since 0.0.7
* @internal #t3866
*/
class SessionUtility
{
/**
* Data of the current object / plugin (tt_content)
*
* @var array
*/
private $_cData = [];
/**
* _getSessionData
*
* @return array
* @version 0.0.7
* @since 0.0.7
*/
private function _getSessionData()
{
$plugin = 'tx_' . $this->_cData[ 'list_type' ];
$space = $this->_getSessionSpace();
$sessionData = $GLOBALS[ 'TSFE' ]->fe_user->getKey( $space, $plugin );
return $sessionData;
}
/**
* _getSessionSpace( ): Get the name of the session data space.
* The name is user, if a frontend user is logged in.
* The name is ses, if any frontend user isn't logged in.
*
* @return string user || ses
* @version 0.5.2
* @since 0.5.2
*/
private function _getSessionSpace()
{
switch( $GLOBALS[ 'TSFE' ]->loginUser )
{
case( true ):
return 'user';
default:
return 'ses';
}
}
/**
* setSessionContinue
*
* @param array $arrSessionData
* @param string $key
* @param string $value
* @return boolean
* @version 0.0.7
* @since 0.0.7
*/
private function _setSessionContinue( &$arrSessionData, $key, $value ): bool
{
$uid = $this->_cData[ 'uid' ];
$pos = strpos( $key, '__' );
switch( true )
{
case($pos === ( int ) 0):
return true;
case($value === NULL):
unset( $arrSessionData[ $uid ][ $key ] );
return true;
default:
return false;
}
}
/**
* _setSessionData
*
* @param array $pluginData: data of the current form
* @param string $plugin: f.e. tx_tile_pi1
* @param int $uid: uid of the current plugin
* @param array $sessionData: current session data
* @return array
* @version 0.0.7
* @since 0.0.7
*/
private function _setSessionData( $pluginData, $sessionData )
{
$uid = $this->_cData[ 'uid' ];
$plugin = 'tx_' . $this->_cData[ 'list_type' ];
foreach( $pluginData as $key => $value )
{
if( $this->_setSessionContinue( $sessionData, $key, $value ) )
{
continue;
}
$sessionData[ $uid ][ $key ] = $value;
}
$space = $this->_getSessionSpace();
$GLOBALS[ 'TSFE' ]->fe_user->setKey( $space, $plugin, $sessionData );
$GLOBALS[ "TSFE" ]->storeSessionData();
return $sessionData;
}
// /**
// * getFormShopTitle:
// *
// * @return string
// * @version 0.0.7
// * @since 0.0.7
// * @internal #t3863
// */
// public function getFormShopTitle()
// {
// $value = $this->_getSessionElement( 'formShopTitle' );
// return $value;
// }
//
/**
* getSessionElement: get an element from the session data
*
* @param string $element
* @param string $default: default value
* @return mixed
* @version 0.0.7
* @since 0.0.7
*/
public function getSessionElement( $element, $default = null )
{
$uid = $this->_cData[ 'uid' ];
$sessionData = $this->_getSessionData();
if( isset( $sessionData[ $uid ][ $element ] ) )
{
$value = $sessionData[ $uid ][ $element ];
return $value;
}
$value = $sessionData[ $uid ][ $element ];
return $default;
}
/**
* setCData()
*
* @param string key
* @param string value
*
* @return string
* @version 0.0.7
* @since 0.0.7
*/
public function setCData( $cData )
{
$this->_cData = $cData;
}
//
// /**
// * setValue()
// *
// * @param string key
// * @param string value
// *
// * @return string
// * @version 0.0.7
// * @since 0.0.7
// */
// public function setValue( $key, $value )
// {
// $this->_setSessionElement( $key, $value );
// }
/**
* setSession: set session data
*
* @return void
* @version 0.0.7
* @since 0.0.7
*/
public function setSession()
{
$plugin = 'tx_' . $this->_cData[ 'list_type' ];
$pluginData = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP( $plugin );
//var_dump( __METHOD__, __LINE__, $plugin, $pluginData );
// Do not remove session data
if( empty( $pluginData ) )
{
return;
}
$sessionData = $this->_getSessionData();
$sessionData = $this->_setSessionData( $pluginData, $sessionData );
//var_dump( __METHOD__, __LINE__, $sessionData );
return;
}
}
......@@ -80,11 +80,63 @@ class CssClassViewHelper extends AbstractViewHelper
return $cell->getGroupcss();
}
/**
* @param string $status: caddy | default | selled
* @return mixed
*/
private function _getTicketCss( $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 );
}
// var_dump( __METHOD__, __LINE__, serialize( $ticketCss ) );
// die();
$ticketCssUid = $ticketCss->getUid();
$cssRepository = ObjectUtility::getObjectManager()->get( CssRepository::class );
$css = $cssRepository->findByUid( $ticketCssUid );
return $css->getClass();
}
/**
* @param int $uid
* @return mixed
*/
private function _getTicketCss()
private function _getTicketCssSelled()
{
$default = $this->arguments[ 'default' ];
$class = $this->arguments[ 'class' ];
......@@ -141,8 +193,13 @@ class CssClassViewHelper extends AbstractViewHelper
return $this->_getCategoryCss();
case('cssClassForGroup'):
return $this->_getGroupCss();
case('cssClassForTicketCaddy'):
return $this->_getTicketCss( 'caddy' );
case('cssClassForTicket'):
case('cssClassForTicketDefault'):
return $this->_getTicketCss();
case('cssClassForTicketSelled'):
return $this->_getTicketCss( 'selled' );
case(''):
return $this->arguments[ 'default' ];
default:
......
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\ProductRepository;
use Netzmacher\Tile\Utility\ObjectUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class ProductFieldViewHelper
*
* @version 0.0.7
* @since 0.0.7
* @internal #t3867
*/
class ProductFieldViewHelper extends AbstractViewHelper
{
/**
* @return void
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument( 'currency', 'string', 'currency', false, 'EUR' );
$this->registerArgument( 'default', 'string', 'default', false, '' );
$this->registerArgument( 'field', 'string', 'field', false, 0 );
$this->registerArgument( 'locale', 'string', 'locale', false, 'de_DE' );
$this->registerArgument( 'prefix', 'string', 'prefix', false, '' );
$this->registerArgument( 'uid', 'int', 'uid', false, 0 );
$this->registerArgument( 'product', 'Netzmacher\Tile\Domain\Model\Product', 'product', false, null );
}
/**
* @return string
*/
public function render(): string
{
$default = $this->arguments[ 'default' ];
$field = $this->arguments[ 'field' ];
$prefix = $this->arguments[ 'prefix' ];
$uid = $this->arguments[ 'uid' ];
$locale = $this->arguments[ 'locale' ];
$currency = $this->arguments[ 'currency' ];
$product = $this->arguments[ 'product' ];
// var_dump(__METHOD__, __LINE__, serialize($product));
// die();
// if( empty( $uid ) )
// {
// return $default;
// }
//
// $productRepository = ObjectUtility::getObjectManager()->get( ProductRepository::class );
// $product = $productRepository->findByUid( $uid );
if( empty( $product ) )
{
return $default;
}
// var_dump(__METHOD__, __LINE__, serialize($product));
// die();
switch( $field )
{
case('title'):
return $prefix . $product->getTitle();
case('price'):
setlocale( LC_MONETARY, $locale );
$price = ' (' . money_format( '%.2n', $product->getPrice() ) . ' ' . $currency . ')';
return $prefix . $price;
default:
var_dump( __METHOD__, __LINE__, 'Error in switch!Undefined field "' . $field . '"' );
die();
}
}
}
......@@ -5,9 +5,6 @@ defined( 'TYPO3_MODE' ) || die();
/**
* Include Plugins
*/
//\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'powermail', 'Pi1', 'Powermail' );
//\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'powermail', 'Pi2', 'Powermail_Frontend' );
//\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'tile', 'Pi1', 'Book a Tile!' );
TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'tile'
......
......@@ -34,7 +34,9 @@ return [
// . 'hidden,'
. 'title,'
. 'price, '
. 'tx_tile_css,'
. 'tx_tile_cssdefault,'
. 'tx_tile_csscaddy,'
. 'tx_tile_cssselled,'
],
'types' => [
'1' => [
......@@ -43,7 +45,9 @@ return [
// . ' hidden, '
. ' title,'
. ' price, '
. ' tx_tile_css, '
. 'tx_tile_cssdefault,'
. 'tx_tile_csscaddy,'
. 'tx_tile_cssselled,'
// . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,'
// . ' starttime, endtime'
],
......@@ -168,9 +172,39 @@ return [
'eval' => 'trim,required'
],
],
'tx_tile_css' => [
'tx_tile_csscaddy' => [
'exclude' => true,
'label' => 'LLL:EXT:tile/Resources/Private/Language/locallang_db.xlf:tx_tile_domain_model_category.tx_tile_css',
'label' => 'LLL:EXT:tile/Resources/Private/Language/locallang_db.xlf:tx_tile_domain_model_ticket.tx_tile_csscaddy',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_tile_domain_model_css',
'minitems' => 1,
'maxitems' => 1,
'items' => [
[ '', '' ],
],
'eval' => 'required',
],
],
'tx_tile_cssdefault' => [
'exclude' => true,
'label' => 'LLL:EXT:tile/Resources/Private/Language/locallang_db.xlf:tx_tile_domain_model_ticket.tx_tile_cssdefault',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_tile_domain_model_css',
'minitems' => 1,
'maxitems' => 1,
'items' => [
[ '', '' ],
],
'eval' => 'required',
],
],
'tx_tile_cssselled' => [
'exclude' => true,
'label' => 'LLL:EXT:tile/Resources/Private/Language/locallang_db.xlf:tx_tile_domain_model_ticket.tx_tile_cssselled',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
......
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:tile/Configuration/TypoScript/page/includeCSS/tileModule.ts">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:tile/Configuration/TypoScript/page/includeCSS/tileBootstrapAlert.ts">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:tile/Configuration/TypoScript/page/includeCSS/tileModule.ts">
\ No newline at end of file
page {
// empty statement for proper comments only
includeCSS {
}
// tileBootstrapAlert
includeCSS =
includeCSS {
tileBootstrapAlert = EXT:tile/Resources/Public/Css/Bootstrap/alert.css
}
}
......@@ -147,9 +147,17 @@
<source>Title</source>
<target>Name</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_css">
<source>CSS class</source>
<target>CSS-Klasse</target>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_csscaddy">
<source>Color for a ticket in the caddy</source>
<target>Farbe für ein Ticket im Warenkorb</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_cssdefault">
<source>Color for a ticket</source>
<target>Farbe für ein Ticket</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_cssselled">
<source>Color for a selled ticket</source>
<target>Farbe für verkauftes Ticket</target>
</trans-unit>
<trans-unit id="tx_tile_pi1.name">
<source>Pi1</source>
......
......@@ -147,9 +147,17 @@
<source>Title</source>
<target>Name</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_css">
<source>CSS class</source>
<target>CSS-Klasse</target>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_csscaddy">
<source>Color for a ticket in the caddy</source>
<target>Farbe für ein Ticket im Warenkorb</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_cssdefault">
<source>Color for a ticket</source>
<target>Farbe für ein Ticket</target>
</trans-unit>
<trans-unit id="tx_tile_domain_model_ticket.tx_tile_cssselled">
<source>Color for a selled ticket</source>
<target>Farbe für verkauftes Ticket</target>
</trans-unit>
<trans-unit id="tx_tile_pi1.name">
<source>Pi1</source>
......
......@@ -13,8 +13,10 @@
<f:variable name="cssForGroup">cssClassForGroup</f:variable>
</f:if>
<f:variable name="cssForTicket"></f:variable>
<f:variable name="cssForTicketSelled"></f:variable>
<f:if condition="{formCellWiTicketsChecked}">
<f:variable name="cssForTicket">cssClassForTicket</f:variable>
<f:variable name="cssForTicketSelled">cssClassForTicketSelled</f:variable>
</f:if>
<f:variable name="cssClassUndefinedCell"></f:variable>