diff --git a/Classes/Controller/RatingController.php b/Classes/Controller/RatingController.php index 0462649..7d539b0 100644 --- a/Classes/Controller/RatingController.php +++ b/Classes/Controller/RatingController.php @@ -2,17 +2,19 @@ namespace TTN\Tea\Controller; -use Psr\Http\Message\ResponseInterface; -use TTN\Tea\Domain\Model\Product\Tea; -use TTN\Tea\Domain\Repository\Product\TeaRepository; -use TYPO3\CMS\Core\Context\Context; -use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; +use TTN\Tea\Domain\Model\Tea; +use TTN\Tea\Domain\Repository\TeaRepository; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -class RatingController extends FrontEndEditorController +class RatingController extends ActionController { + + public function __construct(protected TeaRepository $teaRepository) + { + } + public function ratingAction(Tea $tea, int $stars) { - $this->checkIfUserIsOwner($tea); $tea->setStars($stars); $this->teaRepository->update($tea); diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 7d35150..c4908f9 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -30,10 +30,18 @@ call_user_func( 'EXT:tea/Resources/Public/Icons/Extension.svg' ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + 'Tea', + 'TeaRating', + 'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_rating', + 'EXT:tea/Resources/Public/Icons/Extension.svg' + ); + // This removes the default controls from the plugin. $controlsToRemove = 'recursive,pages'; $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teaindex'] = $controlsToRemove; $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teashow'] = $controlsToRemove; $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teafrontendeditor'] = $controlsToRemove; + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_tearating'] = $controlsToRemove; } ); diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 4de562a..2dc2c2b 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -21,3 +21,27 @@ plugin.tx_tea { singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid} } } + +plugin.tx_tea_tearating { + view { + templateRootPaths { + 0 = EXT:tea/Resources/Private/Plugins/Rating/Templates/ + } + + partialRootPaths { + 0 = EXT:tea/Resources/Private/Plugins/Rating/Partials/ + } + + layoutRootPaths { + 0 = EXT:tea/Resources/Private/Plugins/Rating/Layouts/ + } + } + + persistence { + storagePid = {$plugin.tx_tea.persistence.storagePid} + } + + settings { + singleViewPageUid = {$plugin.tx_tea_tearating.settings.singleViewPageUid} + } +} diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index ec70e63..ec6bbfd 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -11,6 +11,10 @@ Tea single view Tee-Einzelansicht + + Tea Rating view + Tee-Bewertungsansicht + Tea front-end editor Frontend-Editor für Tee diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index a905a48..68cdad4 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -9,6 +9,9 @@ Tea single view + + Tea Rating view + Tea front-end editor @@ -66,6 +69,10 @@ Create new tea + + Filter by rating + + diff --git a/Resources/Private/Plugins/Rating/Templates/Rating/Filter.html b/Resources/Private/Plugins/Rating/Templates/Rating/Filter.html new file mode 100644 index 0000000..751fbda --- /dev/null +++ b/Resources/Private/Plugins/Rating/Templates/Rating/Filter.html @@ -0,0 +1,41 @@ + + + + + +

+ Rating Plugin: +

+ 1 + 2 + 3 + 4 + 5 + + + + + + + + + + + + + + + +
+ + + +
+ {tea.uid} + + + {tea.title} + +
+
+ diff --git a/Resources/Private/Plugins/Rating/Templates/Tea/Index.html b/Resources/Private/Plugins/Rating/Templates/Tea/Index.html new file mode 100644 index 0000000..45eb436 --- /dev/null +++ b/Resources/Private/Plugins/Rating/Templates/Tea/Index.html @@ -0,0 +1,42 @@ + + + + + +

+ +

+ + 1 + 2 + 3 + 4 + 5 + + + + + + + + + + + + + + + +
+ + + +
+ {tea.uid} + + + {tea.title} + +
+
+ diff --git a/Resources/Private/Plugins/Rating/Templates/Tea/Show.html b/Resources/Private/Plugins/Rating/Templates/Tea/Show.html new file mode 100644 index 0000000..2e2ec33 --- /dev/null +++ b/Resources/Private/Plugins/Rating/Templates/Tea/Show.html @@ -0,0 +1,12 @@ + + + + + +

+ Rating Plugin: {tea.title} +

+ + {tea.description -> f:format.html()} +
+ diff --git a/Resources/Private/Templates/Tea/Index.html b/Resources/Private/Templates/Tea/Index.html index 7847c71..d8b6b8b 100644 --- a/Resources/Private/Templates/Tea/Index.html +++ b/Resources/Private/Templates/Tea/Index.html @@ -6,11 +6,6 @@

- 1 - 2 - 3 - 4 - 5 diff --git a/ext_localconf.php b/ext_localconf.php index bf0f0af..778efce 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -18,7 +18,6 @@ ExtensionUtility::configurePlugin( // all actions [ TeaController::class => 'index', - RatingController::class => 'filter' ], // non-cacheable actions [ @@ -45,13 +44,26 @@ ExtensionUtility::configurePlugin( // all actions [ FrontEndEditorController::class => 'index, edit, update, create, new, delete', - RatingController::class => 'filter,rating' ], // non-cacheable actions [ // All actions need to be non-cacheable because they either contain dynamic data, // or because they are specific to the logged-in FE user (while FE content is cached by FE groups). FrontEndEditorController::class => 'index, edit, update, create, new, delete', - RatingController::class => 'rating' ] ); + +// Combine TeaController and RatingController into a new Plugin +ExtensionUtility::configurePlugin( + 'Tea', + 'TeaRating', + [ + TeaController::class => 'index', + RatingController::class => 'filter,rating' + ], + [ + TeaController::class => 'index', + RatingController::class => 'rating,filter' + ] +); +