Commit 7d994b0a authored by Dirk Wildt's avatar Dirk Wildt

0.0.6

parent 8ddc4c93
......@@ -8,6 +8,7 @@ use \Netzmacher\Tile\Domain\Repository\CategoryRepository;
use \Netzmacher\Tile\Domain\Repository\CellRepository;
use \Netzmacher\Tile\Domain\Repository\CssRepository;
use \Netzmacher\Tile\Domain\Repository\GroupRepository;
use \Netzmacher\Tile\Domain\Repository\PageRepository;
use \Netzmacher\Tile\Domain\Repository\TicketRepository;
/* * *
......@@ -67,6 +68,14 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $groupRepository = null;
/**
* pageRepository
*
* @var \Netzmacher\Tile\Domain\Repository\pageRepository
* @inject
*/
protected $pageRepository = null;
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
* @inject
......@@ -133,6 +142,15 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
$this->groupRepository = $groupRepository;
}
/**
* @param PageRepository $pageRepository
* @return void
*/
public function injectPageRepository( PageRepository $pageRepository )
{
$this->pageRepository = $pageRepository;
}
/**
* @param ProductRepository $productRepository
* @return void
......
......@@ -135,6 +135,7 @@ class AreaController extends AbstractController
return ( int ) count( $this->_getCells( $area ) );
}
/**
* action create
*
......
......@@ -2,8 +2,6 @@
namespace Netzmacher\Tile\Controller;
use Netzmacher\Tile\Utility\Module\AreaModuleUtility;
use Netzmacher\Tile\Utility\Module\CellModuleUtility;
use Netzmacher\Tile\Utility\Module\SessionModuleUtility;
/* * *
......@@ -36,7 +34,7 @@ class ShopController extends AbstractController
{
switch( true )
{
case(!$this->_checkGroup($area) ):
case(!$this->_checkGroup( $area ) ):
return false;
default:
return true;
......@@ -56,7 +54,8 @@ class ShopController extends AbstractController
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
foreach( $cells as $cell )
{
if($cell->getTxTileGroup()){
if( $cell->getTxTileGroup() )
{
return true;
}
}
......@@ -68,20 +67,176 @@ class ShopController extends AbstractController
return false;
}
/**
* _checkPid
*
* @param int $pid
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3843
*/
public function _checkPid( $pid )
{
$checkPid = true;
switch( true )
{
case($pid < 1):
$checkPid = false;
break;
case(!$this->pageRepository->findByUid( $pid )):
$checkPid = false;
break;
}
if( $checkPid )
{
return true;
}
$header = '';
$prompt = 'Die Page ID "' . $pid . '" für den Ziel-Ordner ist nicht in Ordnung.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
return false;
}
/**
* action createAction
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @param int $pid
* @return int
* @version 0.0.6
* @since 0.0.6
* @internal #t3843
*/
public function _cloneArea( \Netzmacher\Tile\Domain\Model\Area $area, $pid ): int
{
$clone = new \Netzmacher\Tile\Domain\Model\Area;
$properties = $area->_getProperties();
unset( $properties[ 'uid' ] );
$properties[ 'pid' ] = $pid;
foreach( $properties as $key => $value )
{
$clone->_setProperty( $key, $value );
}
$clone->setTitle( $clone->getTitle() . ' – cloned at ' . strftime( '%c', time() ) );
$this->areaRepository->add( $clone );
$this->persistenceManager->persistAll();
$uid = $clone->getUid();
$page = $this->pageRepository->findByUid( $pid );
$prompt = $clone->getTitle() . ' (#' . $uid . ') was cloned at page ' . $page->getTitle() . ' (#' . $clone->getPid() . ')';
$this->addFlashMessage( $prompt, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK );
return $uid;
}
/**
* _getCells
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3812
*/
private function _getCells( \Netzmacher\Tile\Domain\Model\Area $area )
{
static $rows = null;
if( is_array( $rows ) )
{
//$this->addFlashMessage( __METHOD__ . ' (#' . __LINE__ . ')', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return $rows;
}
//$this->addFlashMessage( __METHOD__ . ' (#' . __LINE__ . ')', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
$rows = $this->cellRepository->getCellsByArea( $area );
return $rows;
}
/**
* _sumGroup
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @param string $relation
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _sumGroup( \Netzmacher\Tile\Domain\Model\Area $area )
{
$groups = [];
$sum = 0;
$rows = $this->_getCells( $area );
foreach( $rows as $row )
{
if( !$row[ 'tx_tile_group' ] )
{
continue;
}
$group = $row[ 'tx_tile_group' ];
if( in_array( $row[ 'tx_tile_group' ], $groups ) )
{
continue;
}
$groups[] = $group;
$sum++;
}
return $sum;
}
/**
* _sumRelation
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @param string $relation
* @return void
* @version 0.0.6
* @since 0.0.6
*/
private function _sumRelation( \Netzmacher\Tile\Domain\Model\Area $area, $relation )
{
$sum = 0;
$rows = $this->_getCells( $area );
foreach( $rows as $row )
{
if( $row[ $relation ] )
{
$sum++;
}
}
return $sum;
}
/**
* action createAction
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3812, #t3843
*/
public function createAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$header = ':TODO: Developer';
$prompt = 'Plan kopieren, Quick Shop Products generieren.';
$this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::NOTICE );
$pid = ( int ) SessionModuleUtility::getFormShopDestpid();
if( !$this->_checkPid( $pid ) )
{
$this->redirect( 'createconfirm', 'Shop', null, array( 'area' => $area ) );
// $this->redirect( 'list', 'Module' );
}
$cloneAreaUid = $this->_cloneArea( $area, $pid );
// // Check Destination Pid: Must exist
// $header = ':TODO: Developer';
// $prompt = 'Plan kopieren, Quick Shop Products generieren.';
// $this->addFlashMessage( $prompt, $header, \TYPO3\CMS\Core\Messaging\AbstractMessage::NOTICE );
$this->redirect( 'list', 'Module' );
}
......@@ -96,9 +251,15 @@ class ShopController extends AbstractController
*/
public function createconfirmAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
if(!$this->_check( $area )){
if( !$this->_check( $area ) )
{
return;
}
$formShopDestpid = SessionModuleUtility::getFormShopDestpid();
$this->view->assign( 'formShopDestpid', $formShopDestpid );
$this->view->assign( 'sumCategory', $this->_sumRelation( $area, 'tx_tile_category' ) );
$this->view->assign( 'sumGroup', $this->_sumGroup( $area ) );
$this->view->assign( 'sumTicket', $this->_sumRelation( $area, 'tx_tile_ticket' ) );
$this->view->assign( 'area', $area );
}
......
......@@ -45,6 +45,13 @@ class Area extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $leny = '';
/**
* pid
*
* @var int
*/
protected $pid = null;
/**
* title
*
......@@ -56,7 +63,7 @@ class Area extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* type
*
* @var int
* @var mixed
*/
protected $type = '';
......@@ -134,6 +141,16 @@ class Area extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->leny = $leny;
}
/**
* Returns the pid
*
* @return string $pid
*/
public function getPid()
{
return $this->pid;
}
/**
* Returns the title
*
......
<?php
namespace Netzmacher\Tile\Domain\Model;
/* * *
*
* 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
*
* * */
/**
* Page
*/
class Page extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* doktype
*
* @var integer
*/
protected $doktype = '';
/**
* image
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @internal http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html
*/
protected $image = 0;
/**
* title
*
* @var string
* @validate NotEmpty
*/
protected $title = '';
/**
* Returns the doktype
*
* @return string $doktype
*/
public function getDoktype()
{
return $this->doktype;
}
/**
* Sets the doktype
*
* @param string $doktype
* @return void
*/
public function setDoktype( $doktype )
{
$this->doktype = $doktype;
}
/**
* Returns the image
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
* @internal http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html
*/
public function getImage()
{
return $this->image;
}
/**
* Sets the image
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
* @return void
* @internal http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html
*/
public function setImage( $image )
{
$this->image = $image;
}
/**
* Returns the title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Sets the title
*
* @param string $title
* @return void
*/
public function setTitle( $title )
{
$this->title = $title;
}
}
<?php
namespace Netzmacher\Tile\Domain\Repository;
//use TYPO3\CMS\Core\Utility\GeneralUtility;
/* * *
*
* 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
*
* * */
/**
* The repository for Areas
*/
class PageRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
// public function findPages()
// {
// $query = $this->createQuery();
// $query->getQuerySettings()->setRespectStoragePage(TRUE);
//
// $result = $query->execute();
// //echo (serialize($result)) . PHP_EOL;
// return $result;
// }
//
// public function findCurrentPage()
// {
// $pageId = GeneralUtility::_GP('id');
//
// $result = $this->findByUid($pageId);
// echo (serialize($result)) . PHP_EOL;
// return $result;
// }
}
......@@ -202,6 +202,20 @@ class SessionModuleUtility
return $value;
}
/**
* getFormShopDestpid:
*
* @return string
* @version 0.0.6
* @since 0.0.6
* @internal t3841
*/
static public function getFormShopDestpid()
{
$value = self::_getSessionElement( 'formShopDestpid' );
return $value;
}
/**
* getValue()
*
......
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\CategoryRepository;
use Netzmacher\Tile\Domain\Repository\CssRepository;
use Netzmacher\Tile\Utility\ObjectUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class CssCategoryViewHelper
*
* @version 0.0.6
* @since 0.0.3
* @internal #t3731
*/
class CssCategoryViewHelper extends AbstractViewHelper
{
/**
* @param int $uid
* @return mixed
*/
private function _getCss( $uid )
{
if( empty( $uid ) )
{
return null;
}
$categoryRepository = ObjectUtility::getObjectManager()->get( CategoryRepository::class );
$category = $categoryRepository->findByUid( $uid );
if( empty( $category ) )
{
return null;
}
$categoryCss = $category->getTxTileCss();
$categoryCssUid = $categoryCss->getUid();
$cssRepository = ObjectUtility::getObjectManager()->get( CssRepository::class );
$css = $cssRepository->findByUid( $categoryCssUid );
return $css;
}
/**
* @return void
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument( 'default', 'string', 'default', false, 'undefined' );
$this->registerArgument( 'field', 'string', 'field', false, 0 );
$this->registerArgument( 'uidCategory', 'int', 'uidCategory', false, 0 );
$this->registerArgument( 'uidCell', 'int', 'uidCell', false, 0 );
}
/**
* @return string
*/
public function render(): string
{
$css = $this->_getCss( $this->arguments[ 'uidCategory' ] );
if( empty( $css ) )
{
return $this->arguments[ 'default' ];
}
$field = $this->arguments[ 'field' ];
switch( $field )
{
case('class'):
return $css->getClass();
case('color'):
return $css->getColor();
case('opacity'):
return $css->getOpacity();
case('title'):
return $css->getTitle();
default:
var_dump( __METHOD__, __LINE__, 'Error in switch! Undefined field "' . $field . '"' );
die();
}
}
}
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\CellRepository;
use Netzmacher\Tile\Domain\Repository\CssRepository;
use Netzmacher\Tile\Domain\Repository\TicketRepository;
use Netzmacher\Tile\Utility\ObjectUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class CssTicketViewHelper
*
* @version 0.0.6
* @since 0.0.6
* @internal #t3816
*/
class CssTicketViewHelper extends AbstractViewHelper
{
/**
* @return mixed
*/
private function _getCellCss()
{
$default = $this->arguments[ 'default' ];
$field = $this->arguments[ 'field' ];
$uid = $this->arguments[ 'uidCell' ];
switch( true )
{
case( empty( $uid ) ):
case( empty( $field ) ):
return $default;
default :
// follow the workflow
break;
}
$cssCell = ObjectUtility::getObjectManager()->get( CellRepository::class );
$cell = $cssCell->findByUid( $uid );
if( empty( $cell ) )
{
return '';
}
switch( $field )
{
case('classAndGroupcss'):
case('groupcss'):
return $cell->getGroupcss();
case('class'):
case('color'):
case('opacity'):
case('title'):
return '';
default:
var_dump( __METHOD__, __LINE__, 'Error in switch! Undefined field "' . $field . '"' );
die();
}
}
/**
* @param int $uid
* @return mixed
*/
private function _getTicketCss( $uid )
{
$default = $this->arguments[ 'default' ];
$field = $this->arguments[ 'field' ];
switch( true )
{
case( empty( $uid ) ):
case( empty( $field ) ):
return $default;
default :
// follow the workflow
break;
}
if( empty( $uid ) )
{
return null;
}
$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 );
switch( $field )
{
case('class'):
case('classAndGroupcss'):
return $css->getClass();
case('color'):
return $css->getColor();
case('groupcss'):
return;
case('opacity'):
return $css->getOpacity();
case('title'):
return $css->getTitle();
default:
var_dump( __METHOD__, __LINE__, 'Error in switch! Undefined field "' . $field . '"' );
die();
}
}
/**
* @return void
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument( 'default', 'string', 'default', false, 'undefined' );
$this->registerArgument( 'field', 'string', 'field', false, 0 );
$this->registerArgument( 'uidCell', 'int', 'uidCell', false, 0 );
$this->registerArgument( 'uidTicket', 'int', 'uidTicket', false, 0 );
}
/**
* @return mixed
*/
public function render()
{
$ticketCss = $this->_getTicketCss( $this->arguments[ 'uidTicket' ] );
$cellCss = $this->_getCellCss( $this->arguments[ 'uidCell' ] );
switch(true){
case(empty($cellCss)):
case(empty($ticketCss)):
$css = $ticketCss . $cellCss;
break;
case($cellCss == $ticketCss):
$css = $cellCss;
break;
default:
$css = $ticketCss . ' ' . $cellCss;
break;
}
return $css;
}