diff --git a/Classes/Controller/ParticipantController.php b/Classes/Controller/ParticipantController.php
index 0bfad46..c9eee4b 100644
--- a/Classes/Controller/ParticipantController.php
+++ b/Classes/Controller/ParticipantController.php
@@ -7,6 +7,10 @@
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use Psr\Http\Message\ResponseInterface;
+use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
+use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
/***
*
@@ -24,6 +28,10 @@
*/
class ParticipantController extends ActionController
{
+ protected int $id;
+
+ protected ModuleTemplate $moduleTemplate;
+
/**
* participantRepository
*
@@ -41,13 +49,24 @@ public function injectParticipantRepository(\Fixpunkt\FpMasterquiz\Domain\Reposi
$this->participantRepository = $participantRepository;
}
+ public function __construct(
+ protected readonly ModuleTemplateFactory $moduleTemplateFactory,
+ ) {
+ }
+
+ public function initializeAction()
+ {
+ $this->id = (int)($this->request->getQueryParams()['id'] ?? 0);
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
+ }
+
/**
* action list
*
* @param int $currentPage
- * @return void
+ * @return ResponseInterface
*/
- public function listAction(int $currentPage = 1)
+ public function listAction(int $currentPage = 1): ResponseInterface
{
$pid = (int)GeneralUtility::_GP('id');
$qid = $this->request->hasArgument('quiz') ? intval($this->request->getArgument('quiz')) : 0;
@@ -70,15 +89,17 @@ public function listAction(int $currentPage = 1)
$this->view->assign('paginator', $participantPaginator);
$this->view->assign('pagination', $participantPagination);
$this->view->assign('pages', range(1, $participantPagination->getLastPageNumber()));
+ $this->addDocHeaderDropDown('list');
+ return $this->defaultRendering();
}
/**
* action detail
*
* @param \Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant
- * @return void
+ * @return ResponseInterface
*/
- public function detailAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant)
+ public function detailAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant): ResponseInterface
{
foreach ($participant->getSelections() as $selection) {
if ($selection->getQuestion()->getQmode() == 8) {
@@ -97,20 +118,63 @@ public function detailAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $pa
}
}
$this->view->assign('participant', $participant);
+ $this->addDocHeaderDropDown('list');
+ return $this->defaultRendering();
}
/**
* action delete
*
* @param \Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant
- * @return void
+ * @return ResponseInterface
*/
- public function deleteAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant)
+ public function deleteAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $participant): ResponseInterface
{
if ($participant->getUid() > 0) {
$this->addFlashMessage($participant->getName() . ' deleted.', '', AbstractMessage::WARNING);
$this->participantRepository->remove($participant);
}
- $this->redirect('list');
+ return $this->responseFactory->createResponse(307)
+ ->withHeader('Location', $this->uriBuilder->reset()->uriFor('list'));
+ }
+
+ /*
+ * Fürs Backend-Modul
+ */
+ protected function getLanguageService(): LanguageService
+ {
+ return $GLOBALS['LANG'];
+ }
+
+ protected function defaultRendering(): ResponseInterface
+ {
+ $this->moduleTemplate->setContent($this->view->render());
+ return $this->htmlResponse($this->moduleTemplate->renderContent());
+ }
+
+ protected function addDocHeaderDropDown(string $currentAction): void
+ {
+ $languageService = $this->getLanguageService();
+ $actionMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+ $actionMenu->setIdentifier('masterquizSelector');
+ $actions = ['Quiz,index', 'Participant,list'];
+ foreach ($actions as $controller_action_string) {
+ $controller_action_array = explode(",", $controller_action_string);
+ $actionMenu->addMenuItem(
+ $actionMenu->makeMenuItem()
+ ->setTitle($languageService->sL(
+ 'LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_mod1.xlf:index.' .
+ strtolower($controller_action_array[0])
+ ))
+ ->setHref($this->getModuleUri($controller_action_array[0], $controller_action_array[1]))
+ ->setActive($currentAction === $controller_action_array[1])
+ );
+ }
+ $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($actionMenu);
+ }
+
+ protected function getModuleUri(string $controller = null, string $action = null): string
+ {
+ return $this->uriBuilder->reset()->uriFor($action, null, $controller, 'mod1');
}
}
\ No newline at end of file
diff --git a/Classes/Controller/QuestionController.php b/Classes/Controller/QuestionController.php
index 6545025..c4e2868 100644
--- a/Classes/Controller/QuestionController.php
+++ b/Classes/Controller/QuestionController.php
@@ -4,6 +4,10 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use Psr\Http\Message\ResponseInterface;
+use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
+use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
/***
*
@@ -21,6 +25,10 @@
*/
class QuestionController extends ActionController
{
+ protected int $id;
+
+ protected ModuleTemplate $moduleTemplate;
+
/**
* questionRepository
*
@@ -38,14 +46,25 @@ public function injectQuestionRepository(\Fixpunkt\FpMasterquiz\Domain\Repositor
$this->questionRepository = $questionRepository;
}
+ public function __construct(
+ protected readonly ModuleTemplateFactory $moduleTemplateFactory,
+ ) {
+ }
+
+ public function initializeAction()
+ {
+ $this->id = (int)($this->request->getQueryParams()['id'] ?? 0);
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
+ }
+
/**
* action move
*
* @param \Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz
* @param \Fixpunkt\FpMasterquiz\Domain\Model\Question $question
- * @return void
+ * @return ResponseInterface
*/
- public function moveAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, \Fixpunkt\FpMasterquiz\Domain\Model\Question $question = NULL)
+ public function moveAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, \Fixpunkt\FpMasterquiz\Domain\Model\Question $question = NULL): ResponseInterface
{
$pid = (int)GeneralUtility::_GP('id');
if ($question) {
@@ -55,6 +74,47 @@ public function moveAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, \Fixp
$this->view->assign('question', $question);
$this->view->assign('questions', $questions);
$this->view->assign('quiz', $quiz);
+ $this->addDocHeaderDropDown('index');
+ return $this->defaultRendering();
+ }
+
+ /*
+ * Fürs Backend-Modul
+ */
+ protected function getLanguageService(): LanguageService
+ {
+ return $GLOBALS['LANG'];
}
+ protected function defaultRendering(): ResponseInterface
+ {
+ $this->moduleTemplate->setContent($this->view->render());
+ return $this->htmlResponse($this->moduleTemplate->renderContent());
+ }
+
+ protected function addDocHeaderDropDown(string $currentAction): void
+ {
+ $languageService = $this->getLanguageService();
+ $actionMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+ $actionMenu->setIdentifier('masterquizSelector');
+ $actions = ['Quiz,index', 'Participant,list'];
+ foreach ($actions as $controller_action_string) {
+ $controller_action_array = explode(",", $controller_action_string);
+ $actionMenu->addMenuItem(
+ $actionMenu->makeMenuItem()
+ ->setTitle($languageService->sL(
+ 'LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_mod1.xlf:index.' .
+ strtolower($controller_action_array[0])
+ ))
+ ->setHref($this->getModuleUri($controller_action_array[0], $controller_action_array[1]))
+ ->setActive($currentAction === $controller_action_array[1])
+ );
+ }
+ $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($actionMenu);
+ }
+
+ protected function getModuleUri(string $controller = null, string $action = null): string
+ {
+ return $this->uriBuilder->reset()->uriFor($action, null, $controller, 'mod1');
+ }
}
diff --git a/Classes/Controller/QuizController.php b/Classes/Controller/QuizController.php
index 4371726..82fb1bb 100644
--- a/Classes/Controller/QuizController.php
+++ b/Classes/Controller/QuizController.php
@@ -10,6 +10,9 @@
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use Psr\Http\Message\ResponseInterface;
+use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
+use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
/***
*
@@ -27,6 +30,10 @@
*/
class QuizController extends ActionController
{
+ protected int $id;
+
+ protected ModuleTemplate $moduleTemplate;
+
/**
* quizRepository
*
@@ -72,6 +79,27 @@ class QuizController extends ActionController
*/
protected $persistenceManager;
+ public function __construct(
+ protected readonly ModuleTemplateFactory $moduleTemplateFactory,
+ ) {
+ }
+
+ public function initializeIndexAction()
+ {
+ $this->id = (int)($this->request->getQueryParams()['id'] ?? 0);
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
+ }
+ public function initializeDetailAction()
+ {
+ $this->id = (int)($this->request->getQueryParams()['id'] ?? 0);
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
+ }
+ public function initializeChartsAction()
+ {
+ $this->id = (int)($this->request->getQueryParams()['id'] ?? 0);
+ $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
+ }
+
/**
* Injects the quiz-Repository
*
@@ -816,7 +844,7 @@ public function doAll(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, array $use
(!$categoryUid && ($finalPoints >= $evaluation->getMinimum()) && ($finalPoints <= $evaluation->getMaximum()))) {
// Punkte-Match
if ($evaluation->getPage() > 0) {
- // Weiterleitung zu diese Seite
+ // Weiterleitung zu dieser Seite
$this->redirectToURI(
$this->uriBuilder->reset()
->setTargetPageUid($evaluation->getPage())
@@ -830,7 +858,8 @@ public function doAll(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, array $use
'source' => $evaluation->getCe(),
'dontCheckPid' => 1
];
- $finalContent = $this->objectManager->get('TYPO3\CMS\Frontend\ContentObject\RecordsContentObject')->render($ttContentConfig);
+ // TODO: funktioniert nicht mehr!
+ $finalContent = GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\RecordsContentObject')->render($ttContentConfig);
$finalBodytext = $evaluation->getBodytext();
$finalImageuid = $evaluation->getImage();
} else {
@@ -1248,7 +1277,6 @@ protected function setAllUserAnswersForOneQuestion(\Fixpunkt\FpMasterquiz\Domain
protected function setAllUserAnswers(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz &$c_quiz, int $pid, bool $be)
{
$debug = '';
- // Alternative: $selectedRepository = $this->objectManager->get('Fixpunkt\\FpMasterquiz\\Domain\\Repository\\SelectedRepository');
foreach ($c_quiz->getQuestions() as $oneQuestion) {
$debug .= $this->setAllUserAnswersForOneQuestion($oneQuestion, $pid, $be);
}
@@ -1342,7 +1370,8 @@ public function introAction(): ResponseInterface
'tables' => 'tt_content',
'source' => $this->settings['introContentUid'],
'dontCheckPid' => 1);
- $contentElement = $this->objectManager->get('TYPO3\CMS\Frontend\ContentObject\RecordsContentObject')->render($ttContentConfig);
+ // TODO: funktioniert nicht mehr!
+ $contentElement = GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\RecordsContentObject')->render($ttContentConfig);
} else {
$contentElement = '';
}
@@ -1393,7 +1422,21 @@ public function showAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz = null
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
- $this->redirect('closure', 'Quiz', NULL, ['participant' => $this->participant, 'session' => $this->participant->getSession()], $this->settings['closurePageUid']);
+ $this->redirectToURI(
+ $this->uriBuilder->reset()
+ ->setTargetPageUid($this->settings['closurePageUid'])
+ ->uriFor(
+ 'closure',
+ [
+ 'participant' => $this->participant,
+ 'session' => $this->participant->getSession()
+ ],
+ 'Quiz',
+ null,
+ 'closure'
+ )
+ ->build()
+ );
}
// participant wird zuerst hier definiert ...
$userData = $this->findParticipant($quiz->getUid(), $quiz->getPid());
@@ -1475,7 +1518,21 @@ public function showByTagAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz =
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
- $this->redirect('closure', 'Quiz', NULL, ['participant' => $this->participant, 'session' => $this->participant->getSession()], $this->settings['closurePageUid']);
+ $this->redirectToURI(
+ $this->uriBuilder->reset()
+ ->setTargetPageUid($this->settings['closurePageUid'])
+ ->uriFor(
+ 'closure',
+ [
+ 'participant' => $this->participant,
+ 'session' => $this->participant->getSession()
+ ],
+ 'Quiz',
+ null,
+ 'closure'
+ )
+ ->build()
+ );
}
$userData = $this->findParticipant($quiz->getUid(), $quiz->getPid());
$page = $this->request->hasArgument('currentPage') ? intval($this->request->getArgument('currentPage')) : 1;
@@ -1582,7 +1639,21 @@ public function showAjaxAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz):
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
- $this->redirect('closure', 'Quiz', NULL, ['participant' => $this->participant, 'session' => $this->participant->getSession()], $this->settings['closurePageUid']);
+ $this->redirectToURI(
+ $this->uriBuilder->reset()
+ ->setTargetPageUid($this->settings['closurePageUid'])
+ ->uriFor(
+ 'closure',
+ [
+ 'participant' => $this->participant,
+ 'session' => $this->participant->getSession()
+ ],
+ 'Quiz',
+ null,
+ 'closure'
+ )
+ ->build()
+ );
}
// siehe: https://www.sebkln.de/tutorials/erstellung-einer-typo3-extension-mit-ajax-aufruf/
// $quizUid = $this->request->hasArgument('quiz') ? intval($this->request->getArgument('quiz')) : 0;
@@ -1791,7 +1862,7 @@ public function closureAction(\Fixpunkt\FpMasterquiz\Domain\Model\Participant $p
}
/**
- * Action list for the backend
+ * Action index for the backend
*
* @return ResponseInterface
*/
@@ -1806,7 +1877,8 @@ function indexAction(): ResponseInterface
$this->view->assign('pid', $pid);
$this->view->assign('quizzes', $quizzes);
$this->view->assign('otherQuizzes', $otherLangs);
- return $this->htmlResponse();
+ $this->addDocHeaderDropDown('index');
+ return $this->defaultRendering();
}
/**
@@ -1817,7 +1889,7 @@ function indexAction(): ResponseInterface
*/
public function detailAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz): ResponseInterface
{
- $questionRepository = $this->objectManager->get('Fixpunkt\\FpMasterquiz\\Domain\\Repository\QuestionRepository');
+ $questionRepository = GeneralUtility::makeInstance('Fixpunkt\\FpMasterquiz\\Domain\\Repository\\QuestionRepository');
$pid = (int)GeneralUtility::_GP('id');
$uid = (int)$quiz->getUid();
$updated = false;
@@ -1861,7 +1933,8 @@ public function detailAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz): Re
} else {
$this->view->assign('chart', 0);
}
- return $this->htmlResponse();
+ $this->addDocHeaderDropDown('index');
+ return $this->defaultRendering();
}
/**
@@ -1882,7 +1955,8 @@ public function chartsAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz): Re
$this->view->assign('debug', $debug);
$this->view->assign('pid', $pid);
$this->view->assign('quiz', $quiz);
- return $this->htmlResponse();
+ $this->addDocHeaderDropDown('index');
+ return $this->defaultRendering();
}
/**
@@ -1903,7 +1977,7 @@ protected function sendTemplateEmail(array $recipient, array $sender, $subject,
);
/** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
- $emailViewHtml = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
+ $emailViewHtml = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$emailViewHtml->setTemplateRootPaths($extbaseFrameworkConfiguration['view']['templateRootPaths']);
$emailViewHtml->setLayoutRootPaths($extbaseFrameworkConfiguration['view']['layoutRootPaths']);
$emailViewHtml->setPartialRootPaths($extbaseFrameworkConfiguration['view']['partialRootPaths']);
@@ -1917,7 +1991,7 @@ protected function sendTemplateEmail(array $recipient, array $sender, $subject,
}
/** @var $message \TYPO3\CMS\Core\Mail\MailMessage */
- $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
+ $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
foreach ($recipient as $key => $value) {
$email = $key;
$name = $value;
@@ -1937,4 +2011,45 @@ protected function sendTemplateEmail(array $recipient, array $sender, $subject,
$message->send();
return $message->isSent();
}
-}
+
+
+ /*
+ * Fürs Backend-Modul
+ */
+ protected function getLanguageService(): LanguageService
+ {
+ return $GLOBALS['LANG'];
+ }
+
+ protected function defaultRendering(): ResponseInterface
+ {
+ $this->moduleTemplate->setContent($this->view->render());
+ return $this->htmlResponse($this->moduleTemplate->renderContent());
+ }
+
+ protected function addDocHeaderDropDown(string $currentAction): void
+ {
+ $languageService = $this->getLanguageService();
+ $actionMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+ $actionMenu->setIdentifier('masterquizSelector');
+ $actions = ['Quiz,index', 'Participant,list'];
+ foreach ($actions as $controller_action_string) {
+ $controller_action_array = explode(",", $controller_action_string);
+ $actionMenu->addMenuItem(
+ $actionMenu->makeMenuItem()
+ ->setTitle($languageService->sL(
+ 'LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_mod1.xlf:index.' .
+ strtolower($controller_action_array[0])
+ ))
+ ->setHref($this->getModuleUri($controller_action_array[0], $controller_action_array[1]))
+ ->setActive($currentAction === $controller_action_array[1])
+ );
+ }
+ $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($actionMenu);
+ }
+
+ protected function getModuleUri(string $controller = null, string $action = null): string
+ {
+ return $this->uriBuilder->reset()->uriFor($action, null, $controller, 'mod1');
+ }
+}
\ No newline at end of file
diff --git a/Configuration/Icons.php b/Configuration/Icons.php
new file mode 100644
index 0000000..07aedfc
--- /dev/null
+++ b/Configuration/Icons.php
@@ -0,0 +1,15 @@
+ [
+ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
+ 'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/user_plugin_pi1.gif'
+ ],
+ 'fp_masterquiz-mod1' => [
+ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
+ 'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/user_mod_mod1.gif'
+ ],
+ 'ext-fpmasterquiz-folder-icon' => [
+ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
+ 'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/ext-fpmasterquiz-folder-icon.svg'
+ ]
+];
\ No newline at end of file
diff --git a/Configuration/TypoScript/setup.ts b/Configuration/TypoScript/setup.ts
index 43fbcf3..cd58707 100644
--- a/Configuration/TypoScript/setup.ts
+++ b/Configuration/TypoScript/setup.ts
@@ -112,7 +112,7 @@ plugin.tx_fpmasterquiz {
}
# Module configuration
-module.tx_fpmasterquiz_web_fpmasterquizmod1 {
+module.tx_fpmasterquiz {
persistence {
storagePid = {$module.tx_fpmasterquiz_mod1.persistence.storagePid}
}
diff --git a/Documentation/ChangeLog/Index.rst b/Documentation/ChangeLog/Index.rst
index d1bb747..39efe69 100644
--- a/Documentation/ChangeLog/Index.rst
+++ b/Documentation/ChangeLog/Index.rst
@@ -179,4 +179,8 @@ ChangeLog
3.7.1:
Absolute path to images in emails.
debug-echo removed.
- PHP 8 bugfix.
\ No newline at end of file
+ PHP 8 bugfix.
+
+4.0.0:
+ Breaking: all plugins must be changed via an update-script (in the install-tool)!
+ TypoScript module.tx_fpmasterquiz_web_fpmasterquizmod1 changed to module.tx_fpmasterquiz
\ No newline at end of file
diff --git a/Resources/Private/Backend/Layouts/Default.html b/Resources/Private/Backend/Layouts/Default.html
index ea63db8..9eadf0e 100644
--- a/Resources/Private/Backend/Layouts/Default.html
+++ b/Resources/Private/Backend/Layouts/Default.html
@@ -1,27 +1,10 @@
-
+
-