Commit 68e64735 authored by Dirk Wildt's avatar Dirk Wildt

0.0.7

parent 28e8af5d
0.0.7
19-07-03
Feature
* #t3865: Frontend plugin. Here: Flexform
New files:
* Classes/Flexform/ItemsprocFlexform.php
* Configuration
* Flexform/Booking/*
* TypoScript/page/includeCSS/tileModule.ts
* Resources/Private/Language/Flexform/*
Affected file:
* /opt/typo3/extensions/tile/Classes/Controller/AbstractController.php
* #t3864: Frontend plugin. Here: Booking Controller
New files:
* Classes/Controller/BookController.php
* Configuration/TCA/Overrides/tt_content.php
Affected files:
* ext_localconf.php
0.0.6
19-06-29
19-07-02
Feature
* #t3857: Relation cell <> product
* #t3854: Type clone
......
......@@ -10,6 +10,8 @@ use \Netzmacher\Tile\Domain\Repository\GroupRepository;
use \Netzmacher\Tile\Domain\Repository\PageRepository;
use \Netzmacher\Tile\Domain\Repository\ProductRepository;
use \Netzmacher\Tile\Domain\Repository\TicketRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/* * *
*
......@@ -24,6 +26,10 @@ use \Netzmacher\Tile\Domain\Repository\TicketRepository;
/**
* Class AbstractController
*
* @version 0.0.6
* @since 0.0.1
*/
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
......@@ -52,6 +58,11 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $cellRepository = null;
/**
* @var ContentObjectRenderer
*/
protected $contentObject;
/**
* cssRepository
*
......@@ -89,6 +100,7 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
* @inject
*/
protected $productRepository = null;
/**
* ticketRepository
*
......@@ -97,6 +109,71 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $ticketRepository = null;
/**
* _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.5.2
* @since 0.5.2
*/
protected function _getFlexformValue( $method, $line, $xmlFlexform, $sheet, $field )
{
$NSprefix = '';
$reportDocTag = false;
$arrFlexform = GeneralUtility::xml2array( $xmlFlexform, $NSprefix, $reportDocTag );
if( !isset( $arrFlexform[ 'data' ][ $sheet ][ 'lDEF' ][ $field ][ 'vDEF' ] ) )
{
$this->_getFlexformValueDiePrompt( $method, $line, $sheet, $field );
}
return $arrFlexform[ 'data' ][ $sheet ][ 'lDEF' ][ $field ][ 'vDEF' ];
}
/**
* _getFlexformValueDiePrompt():
*
* @param string method
* @param string line
* @param string label of the sheet
* @param string label of the field
* @return mixed value from flexform
* @access protected
* @version 0.5.2
* @since 0.5.2
*/
private function _getFlexformValueDiePrompt( $method, $line, $sheet, $field )
{
$prompt = ''
. 'ERROR<br />'
. 'Current Flexform does\'t contain a sheet ' . $sheet . ' with field ' . $field . '<br />'
. '@ ' . $method . ' (#' . $line . ')'
;
die( $prompt );
}
/**
* Initializes this object
*
* @return void
* @codeCoverageIgnore
* @throws InvalidSlotException
* @throws InvalidSlotReturnException
*/
protected function _initObjectContent()
{
// @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
$this->contentObject = $this->configurationManager->getContentObject();
//var_dump(__METHOD__, __LINE__, $this->contentObject->data);
}
/**
* @param AreaRepository $areaRepository
* @return void
......
<?php
namespace Netzmacher\Tile\Controller;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/* * *************************************************************
* 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!
* ************************************************************* */
/**
* AbstractObjectController 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
*/
class AbstractObjectController extends AbstractController
{
/**
* @var TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
private $_oCObj;
/**
* @var TYPO3\CMS\Extbase\Object\ObjectManager
*/
private $_oObjectManager;
/**
* @var \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
*/
protected $_oPlugin;
/**
* @var TYPO3\CMS\Extbase\Service\TypoScriptService
*/
protected $_oTypoScriptService;
/**
* @var ContentObjectRenderer
*/
protected $contentObject;
/**
* TypoScript configuration
*
* @var array
*/
protected $conf;
/**
* @var string Extension key
*/
public $extKey = 'tile';
/**
* Initializes this object
*
* @return void
* @codeCoverageIgnore
* @throws InvalidSlotException
* @throws InvalidSlotReturnException
*/
private function _initObjectContent()
{
// @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
$this->contentObject = $this->configurationManager->getContentObject();
//var_dump(__METHOD__, __LINE__, $this->contentObject->data);
}
/**
* _initObjectCObj( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectCObj()
{
$this->_oCObj = $this->_oObjectManager->get( 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer' );
$this->_initObjectCObjData();
}
/**
* _initObjectCObjData( ) : Is needed, if in TypoScript is used: data = flexform : pi_flexform:...
* If it isn't set, data will be empty, and data[pi_flexform] too of course.
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectCObjData()
{
$this->_oCObj->data = $this->contentObject->data;
}
/**
* _initObjectObjectManager( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectObjectManager()
{
$this->_oObjectManager = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' );
}
/**
* _initObjectPlugin( ) : Init localisation
*
* @return void
* @access private
* @version 0.8.4
* @since 0.0.1
* @internal #i0062
*/
private function _initObjectPlugin()
{
$this->_oPlugin = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Frontend\\Plugin\\AbstractPlugin' );
}
/**
* _initObjectTypoScriptService( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectTypoScriptService()
{
$this->_oTypoScriptService = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Service\\TypoScriptService' );
}
/**
* _cObjGetSingle( ) :
*
* @param array $record
* @return string $value
* @access protected
* @version 0.0.1
* @since 0.0.1
*/
protected function cObjGetSingle( $record )
{
if( empty( $record ) )
{
return;
}
$name = $record[ '_typoScriptNodeValue' ];
$conf = $this->_oTypoScriptService->convertPlainArrayToTypoScriptArray( $record );
$value = $this->_oCObj->cObjGetSingle( $name, $conf );
return $value;
}
/**
* initObjects( ) :
*
* @return void
* @access private
* @version 0.3.0
* @since 0.0.1
*/
protected function initObjects()
{
$this->_initObjectObjectManager();
$this->_initObjectContent();
$this->_initObjectCObj();
$this->_initObjectPlugin();
$this->_initObjectTypoScriptService();
}
}
......@@ -14,7 +14,10 @@ namespace Netzmacher\Tile\Controller;
* * */
/**
* AreaController
* AreaController: backend module
*
* @version 0.0.6
* @since 0.0.1
*/
class AreaController extends AbstractController
{
......@@ -167,7 +170,6 @@ class AreaController extends AbstractController
return ( int ) count( $this->_getCells( $area ) );
}
/**
* action create
*
......
<?php
namespace Netzmacher\Tile\Controller;
use Netzmacher\Tile\Utility\Module\AreaModuleUtility;
use Netzmacher\Tile\Utility\Module\CellModuleUtility;
use Netzmacher\Tile\Utility\Module\SessionModuleUtility;
/* * *
*
* 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
*
* * */
/**
* BookingController: frontend plugin for booking tiles
*
* @version 0.0.7
* @since 0.0.7
*/
class BookingController extends AbstractController
{
/**
* _cellIsEmpty
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _cellIsEmpty( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
switch( true )
{
case($cell->getTxTileGroup());
case($cell->getTxTileTicket());
return false;
default:
return true;
}
}
/**
* _cellModeIsGroup()
*
* @return boolean
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _cellModeIsGroup()
{
$mode = SessionModuleUtility::getFormCellMode();
switch( $mode )
{
case('cell'):
return false;
case('group'):
return true;
default:
$prompt = 'Warning @ ' . __METHOD__ . ' (#' . __LINE__ . ')! Undefined value in switch: "' . $mode . '"';
$this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return false;
}
}
/**
* _cellRangeIsEditable
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _cellRangeIsEditable( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
switch( true )
{
case($this->_ticketIsNull()):
return true;
case($this->_cellRangeIsEmpty( $cell )):
return true;
default:
return false;
}
}
/**
* _cellRangeIsEmpty
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _cellRangeIsEmpty( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
// Mode: single cell
if( !$this->_cellModeIsGroup() )
{
if( $this->_cellIsEmpty( $cell ) )
{
return true;
}
return false;
}
// Mode: cell group
$formerCellUid = SessionModuleUtility::getValue( 'formerCellUid' );
// return, there is no former cell
if( empty( $formerCellUid ) )
{
return true;
}
$formerCell = $this->cellRepository->findByUid( $formerCellUid );
$xyRange = CellModuleUtility::getXsYsOrdered( $formerCell, $cell );
$cellUids = $this->cellRepository->getCellsByXyRange( $cell, $xyRange );
foreach( $cellUids as $cellUid )
{
$cell = $this->cellRepository->findByUid( $cellUid );
if( !$this->_cellIsEmpty( $cell ) )
{
return false;
}
}
return true;
}
/**
* _getAreaCells
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.3
* @since 0.0.3
*/
private function _getAreaCells( \Netzmacher\Tile\Domain\Model\Area $area )
{
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
return $cells;
}
/**
* _getTicketTitle()
*
* @param integer $uid
*
* @return \Netzmacher\Tile\Domain\Model\Ticket
* @version 0.0.6
* @since 0.0.6
* @internal #t3812
*/
private function _getTicketTitle( $uid )
{
$ticket = $this->ticketRepository->findByUid( $uid );
if( !is_object( $ticket ) )
{
return;
}
return $ticket->getTitle();
}
/**
* _getTickets()
*
* @return \Netzmacher\Tile\Domain\Model\Category
* @version 0.0.6
* @since 0.0.6
* @internal #t3812
*/
private function _getTickets()
{
$returnArray = [];
$defaultOrderings = [
'title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
];
$this->ticketRepository->setDefaultOrderings( $defaultOrderings );
$tickets = $this->ticketRepository->findAll();
foreach( $tickets as $ticket )
{
$returnArray[ $ticket->getUid() ] = $ticket->getTitle();
}
return $returnArray;
}
/**
* _promptCellRangeIsNotEmpty
*
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _promptCellRangeIsNotEmpty()
{
$header = '';
$prompt = 'Tickets können nicht überschrieben werden.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
$header = '';
$prompt = 'Bitte leere den Bereich, bevor Du diesem ein neues Ticket zuweist.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
}
/**
* _resetCellsByDeprecatedGroups()
*
* @param array $groups
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _resetCellsByDeprecatedGroups( array $groups )
{
switch( true )
{
case(empty( $groups ) ):
$prompt = 'Warning @ ' . __METHOD__ . ' (#' . __LINE__ . ')! Groups are empty.';
$this->addFlashMessage( $prompt, 'ERROR', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
return;
case(!$this->_ticketIsNull() ):
// Do nothing
return;
case( $this->_ticketIsNull() ):
$groups = array_unique( $groups );
foreach( $groups as $group )
{
if( empty( $group ) )
{
continue;
}
$cellUids = $this->cellRepository->getCellsByGroup( $group );
foreach( $cellUids as $cellUid )
{
$cell = $this->cellRepository->findByUid( $cellUid );
$this->_setTicketForCell( $cell );
$this->_setGroupForCell( $cell, $group );
$this->cellRepository->update( $cell );
}
}
return;
}
}
/**
* _removeDeprecatedGroups()
*
* @param array $groups
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _removeDeprecatedGroups( array $groups )
{
switch( true )
{
case(empty( $groups ) ):
$prompt = 'Warning @ ' . __METHOD__ . ' (#' . __LINE__ . ')! Groups are empty.';
$this->addFlashMessage( $prompt, 'ERROR', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
return;
case(!$this->_ticketIsNull() ):
// Do nothing
return;
case( $this->_ticketIsNull() ):
$this->groupRepository->removeGroups( $groups );
return;
}
}
/**
* _setGroupForCell()
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @param \Netzmacher\Tile\Domain\Model\Group $group
* @return mixed
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _setGroupForCell( \Netzmacher\Tile\Domain\Model\Cell $cell, \Netzmacher\Tile\Domain\Model\Group $group = null )
{
switch( true )
{
case(!$this->_ticketIsNull() ):
if( empty( $group ) )
{
// Create a new group and set it
$group = new \Netzmacher\Tile\Domain\Model\Group();
$title = $cell->getTitle();
$group->setTitle( $title );
}
$group->setTxTileCell( ( int ) $group->getTxTileCell() + 1 );
$cell->setTxTileGroup( $group );
break;
case( $this->_ticketIsNull() ):
// Remove the group of the current cell from the current cell
$group = $cell->getTxTileGroup();
$cell->removeTxTileGroup( $group );
break;
}
return $group;
}
/**
* _setGroupTitle()
*
* @param \Netzmacher\Tile\Domain\Model\Group $group
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @param array $xyRange
* @return mixed
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _setGroupTitle( $cell, $xyRange, $group = null )
{
if( empty( $group ) )
{
return;
}
$range = 'x' . $xyRange[ 'minX' ] . 'y' . $xyRange[ 'minY' ] . '-x' . $xyRange[ 'maxX' ] . 'y' . $xyRange[ 'maxY' ];
$title = $cell->getTxTileArea()->getTitle() . ' ' . $range;
$group->setTitle( $title );
}
/**
* _setTicketForCell()
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
*
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _setTicketForCell( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
$cell->setTxTileTicket( SessionModuleUtility::getFormCellTicket() );
$cell->setGroupcss( SessionModuleUtility::getFormCellMode() );
$this->cellRepository->update( $cell );
return;
}
/**
* _setTicketForCells()
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
*
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
private function _setTicketForCells( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
$group = $this->_setGroupForCell( $cell );
$groups[] = $group;
if( !$this->_cellModeIsGroup() )
{
$this->_setTicketForCell( $cell );
$this->_resetCellsByDeprecatedGroups( $groups );
$this->_removeDeprecatedGroups( $groups );