Commit c813be6f authored by Dirk Wildt's avatar Dirk Wildt

0.0.6

parent 4cd6e8e9
......@@ -2,6 +2,7 @@
namespace Netzmacher\Tile\Controller;
use \Netzmacher\QuickShop\Domain\Repository\ProductRepository;
use \Netzmacher\Tile\Domain\Repository\AreaRepository;
use \Netzmacher\Tile\Domain\Repository\CategoryRepository;
use \Netzmacher\Tile\Domain\Repository\CellRepository;
......@@ -72,6 +73,13 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $persistenceManager;
/**
* ticketRepository
*
* @var \Netzmacher\QuickShop\Domain\Repository\ProductRepository
* @inject
*/
protected $productRepository = null;
/**
* ticketRepository
*
......@@ -125,6 +133,15 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
$this->groupRepository = $groupRepository;
}
/**
* @param ProductRepository $productRepository
* @return void
*/
public function injectProductRepository( ProductRepository $productRepository )
{
$this->productRepository = $productRepository;
}
/**
* @param TicketRepository $ticketRepository
* @return void
......
<?php
namespace Netzmacher\Tile\Controller;
/* * *
*
* 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
*
* * */
/**
* AreaController
*/
class AreaController extends AbstractController
{
/**
* _addCells
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.1
* @since 0.0.1
*/
private function _addCells( \Netzmacher\Tile\Domain\Model\Area $newArea )
{
for( $y = 1; $y <= $newArea->getLeny(); $y++ )
{
for( $x = 1; $x <= $newArea->getLenx(); $x++ )
{
$newCell = new \Netzmacher\Tile\Domain\Model\Cell();
$cellTitle = $newArea->getTitle() . ' x' . $x . 'y' . $y;
$newCell->setTitle( $cellTitle );
$newCell->setX( $x );
$newCell->setY( $y );
$newArea->addTxTileCell( $newCell );
}
}
$newArea->addTxTileCell( $newCell );
return $newArea;
}
/**
* action create
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.2
* @since 0.0.1
*/
public function createAction( \Netzmacher\Tile\Domain\Model\Area $newArea )
{
$newArea = $this->_addCells( $newArea );
$this->areaRepository->add( $newArea );
// $this->addFlashMessage( 'The object was created. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
$this->redirect( 'list', 'Module' );
}
/**
* action createconfirm
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.3
* @since 0.0.3
*/
public function createconfirmAction( \Netzmacher\Tile\Domain\Model\Area $newArea )
{
// $area = [
// 'title' => $newArea->getTitle()
// , 'lenx' => $newArea->getLenx()
// , 'leny' => $newArea->getLeny()
// ];
$this->view->assign( 'newArea', $newArea );
}
/**
* action delete
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.2
* @since 0.0.1
*/
public function deleteAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$groups = [];
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
foreach( $cells as $cell )
{
$groups[] = $cell->getTxTileGroup();
$area->removeTxTileCell( $cell );
$this->cellRepository->remove( $cell );
}
$this->areaRepository->remove( $area );
$this->groupRepository->removeGroups( $groups );
$this->redirect( 'list', 'Module' );
}
/**
* action deleteconfirm
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.3
* @since 0.0.3
*/
public function deleteconfirmAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$this->view->assign( 'area', $area );
}
/**
* action edit
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @ignorevalidation $area
* @return void
* @version 0.0.1
* @since 0.0.1
*/
public function editAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$this->view->assign( 'area', $area );
}
/**
* action new
*
* @return void
* @version 0.0.1
* @since 0.0.1
*/
public function newAction()
{
}
/**
* action show
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.1
* @since 0.0.1
*/
public function showAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$this->view->assign( 'area', $area );
}
/**
* action update
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.1
* @since 0.0.1
*/
public function updateAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$this->addFlashMessage( 'The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
$this->areaRepository->update( $area );
$this->redirect( 'list', 'Module' );
}
}
<?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
*
* * */
/**
* CategoryController
*/
class CategoryController extends AbstractController
{
/**
* _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;
}
/**
* _getCategories()
*
* @return \Netzmacher\Tile\Domain\Model\Category
* @version 0.0.3
* @since 0.0.3
* @internal #t3729
*/
private function _getCategories()
{
$returnArray = [];
$defaultOrderings = [
'title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
];
$this->categoryRepository->setDefaultOrderings( $defaultOrderings );
$categories = $this->categoryRepository->findAll();
foreach( $categories as $category )
{
$returnArray[ $category->getUid() ] = $category->getTitle();
}
return $returnArray;
}
/**
* _getCategoryTitle()
*
* @param integer $uid
*
* @return \Netzmacher\Tile\Domain\Model\Category
* @version 0.0.5
* @since 0.0.5
* @internal #t3749
*/
private function _getCategoryTitle( $uid )
{
$category = $this->categoryRepository->findByUid( $uid );
if( !is_object( $category ) )
{
return;
}
return $category->getTitle();
}
/**
* _setCategoryForCellRange()
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
*
* @return void
* @version 0.0.6
* @since 0.0.5
* @internal #t3749
*/
private function _setCategoryForCellRange( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
if( !$this->_setCategoryForCellRangeRequirements() )
{
return;
}
$formerCellUid = SessionModuleUtility::getValue( 'formerCellUid' );
// return, there is no former cell
if( empty( $formerCellUid ) )
{
// $prompt = 'No former cell @ ' . __METHOD__ . ' (#' . __LINE__ . ')';
// $this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
SessionModuleUtility::setValue( 'formerCellUid', $cell->getUid() );
return;
}
$formerCell = $this->cellRepository->findByUid( $formerCellUid );
SessionModuleUtility::removeValue( 'formerCellUid' );
$xyRange = CellModuleUtility::getXsYsOrdered( $formerCell, $cell );
$cellUids = $this->cellRepository->getCellsByXyRange( $cell, $xyRange );
foreach( $cellUids as $cellUid )
{
$cell = $this->cellRepository->findByUid( $cellUid );
$cell->setTxTileCategory( SessionModuleUtility::getFormCellCategory() );
$this->cellRepository->update( $cell );
}
return;
// $prompt = 'x from ' . $xyRange[ 'minX' ] . ' to ' . $xyRange[ 'maxX' ] . ', y from ' . $xyRange[ 'minY' ] . ' to ' . $xyRange[ 'maxY' ];
// $this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
// $prompt = 'former cell: ' . $formerCell->getUid() . ', x: ' . $formerCell->getX() . ', y: ' . $formerCell->getY() . ' @ ' . __METHOD__ . ' (#' . __LINE__ . ')';
// $this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
// $prompt = 'cell: ' . $cell->getUid() . ', x: ' . $cell->getX() . ', y: ' . $cell->getY() . ' @ ' . __METHOD__ . ' (#' . __LINE__ . ')';
// $this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
}
/**
* _setCategoryForCellRangeRequirements()
*
* @return boolean
* @version 0.0.6
* @since 0.0.5
* @internal #t3749
*/
private function _setCategoryForCellRangeRequirements()
{
$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;
}
}
/**
* action enableAction
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.5
* @since 0.0.5
* @internal #i0001
*/
public function enableAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$categoryTitle = $this->_getCategoryTitle( SessionModuleUtility::getFormCellCategory() );
if( empty( $categoryTitle ) )
{
$categoryTitle = 'Zurücksetzen';
}
$formCellCategoryOptions = [ 0 => 'Zurücksetzen' ] + ( array ) $this->_getCategories();
$formCellCategorySelected = SessionModuleUtility::getFormCellCategory();
$formCellModeSelected = SessionModuleUtility::getFormCellMode();
if( empty( $formCellModeSelected ) )
{
$formCellModeSelected = 'cell';
}
$formCellModeOptions = [
'cell' => 'Kachel',
'group' => 'Gruppe'
];
$currentModeLabel = $formCellModeOptions[ SessionModuleUtility::getFormCellMode() ];
if( empty( $currentModeLabel ) )
{
$currentModeLabel = 'Kachel';
}
$formCellWiBgimageChecked = SessionModuleUtility::getFormCellWiBgimage( true );
$formCellWiCategoriesChecked = SessionModuleUtility::getFormCellWiCategories( true );
$formCellWiGroupsChecked = SessionModuleUtility::getFormCellWiGroups( true );
$formCellWiTicketsChecked = SessionModuleUtility::getFormCellWiTickets( true );
$formCellWiUndefinedCellsChecked = SessionModuleUtility::getFormCellWiUndefinedCells( true );
$this->view->assign( 'area', $area );
$this->view->assign( 'categoryTitle', $categoryTitle );
$this->view->assign( 'cells', $this->_getAreaCells( $area ) );
$this->view->assign( 'currentModeLabel', $currentModeLabel );
$this->view->assign( 'formCellCategoryOptions', $formCellCategoryOptions );
$this->view->assign( 'formCellCategorySelected', $formCellCategorySelected );
$this->view->assign( 'formCellModeOptions', $formCellModeOptions );
$this->view->assign( 'formCellModeSelected', $formCellModeSelected );
$this->view->assign( 'formCellWiBgimageChecked', $formCellWiBgimageChecked );
$this->view->assign( 'formCellWiCategoriesChecked', $formCellWiCategoriesChecked );
$this->view->assign( 'formCellWiGroupsChecked', $formCellWiGroupsChecked );
$this->view->assign( 'formCellWiTicketsChecked', $formCellWiTicketsChecked );
$this->view->assign( 'formCellWiUndefinedCellsChecked', $formCellWiUndefinedCellsChecked );
$this->view->assign( 'grid-template-columns', AreaModuleUtility::getAutoElementsForGridCSS( $area ) );
$this->view->assign( 'size', '15' );
}
/**
* initializeAction: is executed before any Action in the Controller.
*
* @return void
* @version 0.0.3
* @since 0.0.3
* @internal #t3728
*/
public function initializeAction()
{
SessionModuleUtility::setSession();
}
/**
* action updatecell
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @return void
* @version 0.0.6
* @since 0.0.1
*/
public function updatecellAction( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
//$this->addFlashMessage( 'The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
$this->_setCategoryForCellRange( $cell );
$cell->setTxTileCategory( SessionModuleUtility::getFormCellCategory() );
$this->cellRepository->update( $cell );
$area = $this->request->getArgument( 'area' );
$arguments = [
'area' => $area
];
$this->redirect( 'enable', NULL, NULL, $arguments );
}
}
This diff is collapsed.
......@@ -16,199 +16,134 @@ namespace Netzmacher\Tile\Controller;
/**
* ModuleController
*
* @version 0.0.3
* @version 0.0.6
* @since 0.0.1
*/
class ModuleController extends AbstractController
{
/**
* _addCells
* _checkCss
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.1
* @since 0.0.1
* @return boolean
* @version 0.0.6
* @since 0.0.6
* @internal #3824
*/
private function _addCells( \Netzmacher\Tile\Domain\Model\Area $newArea )
private function _check()
{
for( $y = 1; $y <= $newArea->getLeny(); $y++ )
switch( true )
{
for( $x = 1; $x <= $newArea->getLenx(); $x++ )
{
$newCell = new \Netzmacher\Tile\Domain\Model\Cell();
$cellTitle = $newArea->getTitle() . ' x' . $x . 'y' . $y;
$newCell->setTitle( $cellTitle );
$newCell->setX( $x );
$newCell->setY( $y );
$newArea->addTxTileCell( $newCell );
}
case(!$this->_checkCss() ):
return false;
case(!$this->_checkCategory() ):
return false;
case(!$this->_checkTicket() ):
return false;
default:
return true;
}
$newArea->addTxTileCell( $newCell );
return $newArea;
}
/**
* _gridTemplateColumns
* _checkCategory
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.2
* @since 0.0.2
* @return boolean
* @version 0.0.6
* @since 0.0.6
* @internal #3824
*/
private function _gridTemplateColumns( \Netzmacher\Tile\Domain\Model\Area $area )
private function _checkCategory()
{
$arrAuto = null;
for( $x = 1; $x <= $area->getLenx(); $x++ )
$category = $this->categoryRepository->findAll();
if( !empty( $category ) )
{
$arrAuto[] = 'auto';
return true;
}
$strAuto = implode( ' ', ( array ) $arrAuto );
return $strAuto;
$header = 'Objekt-Datensatz fehlt';
$prompt = 'Um einen Plan zu erstellen, benötigst Du mindestens ein Objekt. '
. 'Füge dieses bitte mit dem Modul "Web > Liste" hinzu.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return false;
}
/**
* _tiles
* _checkCss
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.2
* @since 0.0.2
* @return boolean
* @version 0.0.6
* @since 0.0.6
* @internal #3824
*/
private function _tiles( \Netzmacher\Tile\Domain\Model\Area $area )
private function _checkCss()
{
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
foreach( $cells as $cell )
$css = $this->cssRepository->findAll();
if( !empty( $css ) )
{
$alert = $cell->getTitle();
$arrTiles[] = '<div class="undefined"><a href="#" onClick="alert(\'' . $alert . '\')" title = "' . $alert . '">&nbsp;</a></div> ';
return true;
}
$strTiles = implode( PHP_EOL, ( array ) $arrTiles );
return $strTiles;
}
/**
* action copy
*
* @return void
* @version 0.0.2
* @since 0.0.2
*/
public function copyAction()
{
$this->addFlashMessage( 'Die Aktion [Kopieren] ist nicht implementiert. ', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
$this->redirect( 'list' );
$header = 'CSS-Datensatz fehlt';
$prompt = 'Um einen Plan zu erstellen, benötigst Du mindestens einen CSS-Datensatz. '
. 'Füge diesen bitte mit dem Modul "Web > Liste" hinzu.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return false;
}
/**
* action create
* _checkTicket
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.2
* @since 0.0.1
* @return boolean
* @version 0.0.6
* @since 0.0.6
* @internal #3824
*/
public function createAction( \Netzmacher\Tile\Domain\Model\Area $newArea )
private function _checkTicket()
{
$newArea = $this->_addCells( $newArea );
$this->areaRepository->add( $newArea );
$this->addFlashMessage( 'The object was created. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
$this->redirect( 'list' );
}
// /**
// * action createconfirm
// *
// * @param object $newArea
// * @return void
// * @version 0.0.3
// * @since 0.0.3
// */
// public function createconfirmAction( $newArea )
// {
// $this->view->assign( 'newArea', $newArea );
// }
$ticket = $this->ticketRepository->findAll();
if( !empty( $ticket ) )
{
return true;
}
/**
* action createconfirm
*
* @param \Netzmacher\Tile\Domain\Model\Area $newArea
* @return void
* @version 0.0.3
* @since 0.0.3
*/
public function createconfirmAction( \Netzmacher\Tile\Domain\Model\Area $newArea )
{
// $area = [
// 'title' => $newArea->getTitle()
// , 'lenx' => $newArea->getLenx()
// , 'leny' => $newArea->getLeny()
// ];
$this->view->assign( 'newArea', $newArea );
$header = 'Ticket-Datensatz fehlt';
$prompt = 'Um einen Plan zu erstellen, benötigst Du mindestens ein Ticket. '
. 'Füge diesen bitte mit dem Modul "Web > Liste" hinzu.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return false;
}
/**
* action delete
* _gridTemplateColumns
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.2
* @since 0.0.1
* @since 0.0.2
*/
public function deleteAction( \Netzmacher\Tile\Domain\Model\Area $area )
private function _gridTemplateColumns( \Netzmacher\Tile\Domain\Model\Area $area )
{
$groups = [];
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
foreach( $cells as $cell )
$arrAuto = null;
for( $x = 1; $x <= $area->getLenx(); $x++ )
{
$groups[] = $cell->getTxTileGroup();
$area->removeTxTileCell( $cell );
$this->cellRepository->remove( $cell );
$arrAuto[] = 'auto';
}
$this->areaRepository->remove( $area );
$this->groupRepository->removeGroups( $groups );
$this->redirect( 'list' );
}
/**
* action deleteconfirm
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.3
* @since 0.0.3
*/
public function deleteconfirmAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$this->view->assign( 'area', $area );
}