mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-21 14:16:13 +01:00
Merge e5e997cfde
into 0a01e3f20c
This commit is contained in:
commit
38432a58b0
19 changed files with 307 additions and 5 deletions
|
@ -19,7 +19,7 @@ class FrontEndEditorController extends ActionController
|
|||
{
|
||||
private Context $context;
|
||||
|
||||
private TeaRepository $teaRepository;
|
||||
protected TeaRepository $teaRepository;
|
||||
|
||||
public function __construct(Context $context, TeaRepository $teaRepository)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ class FrontEndEditorController extends ActionController
|
|||
/**
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function checkIfUserIsOwner(Tea $tea): void
|
||||
protected function checkIfUserIsOwner(Tea $tea): void
|
||||
{
|
||||
if ($tea->getOwnerUid() !== $this->getUidOfLoggedInUser()) {
|
||||
throw new \RuntimeException('You do not have the permissions to edit this tea.', 1687363749);
|
||||
|
|
30
Classes/Controller/RatingController.php
Normal file
30
Classes/Controller/RatingController.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace TTN\Tea\Controller;
|
||||
|
||||
use TTN\Tea\Domain\Model\Tea;
|
||||
use TTN\Tea\Domain\Repository\TeaRepository;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
|
||||
class RatingController extends ActionController
|
||||
{
|
||||
|
||||
public function __construct(protected TeaRepository $teaRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function ratingAction(Tea $tea, int $stars)
|
||||
{
|
||||
$tea->setStars($stars);
|
||||
$this->teaRepository->update($tea);
|
||||
|
||||
return $this->redirect('index','FrontEndEditor');
|
||||
}
|
||||
|
||||
public function filterAction(int $stars)
|
||||
{
|
||||
$this->view->assign('teas', $this->teaRepository->findByStars($stars));
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,11 @@ class Tea extends AbstractEntity
|
|||
*/
|
||||
protected $image;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $stars = null;
|
||||
|
||||
// Note: We cannot use `@var` for the more specific type annotation here as this confuses the Extbase type mapper.
|
||||
|
||||
/**
|
||||
|
@ -90,4 +95,23 @@ class Tea extends AbstractEntity
|
|||
{
|
||||
$this->ownerUid = $ownerUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStars(): ?int
|
||||
{
|
||||
return $this->stars;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $stars
|
||||
* @return void
|
||||
*/
|
||||
public function setStars(?int $stars): void
|
||||
{
|
||||
$this->stars = $stars;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,10 +32,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;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -29,8 +29,8 @@ $tca = [
|
|||
'1' => [
|
||||
'showitem' =>
|
||||
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
|
||||
title, description, image, owner,
|
||||
--div--;LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_tea.tabs.access,
|
||||
title, description, image, stars, owner,
|
||||
--div--;LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.tabs.access,
|
||||
--palette--;;hidden,
|
||||
--palette--;;access,',
|
||||
],
|
||||
|
@ -206,6 +206,16 @@ $tca = [
|
|||
'hideSuggest' => true,
|
||||
],
|
||||
],
|
||||
'stars' => [
|
||||
'exclude' => true,
|
||||
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.stars',
|
||||
'config' => [
|
||||
'type' => 'input',
|
||||
'size' => 8,
|
||||
'eval' => 'trim',
|
||||
'max' => 255,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
<source>Tea single view</source>
|
||||
<target>Tee-Einzelansicht</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea_rating" resname="plugin.tea_rating">
|
||||
<source>Tea Rating view</source>
|
||||
<target>Tee-Bewertungsansicht</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor" approved="yes">
|
||||
<source>Tea front-end editor</source>
|
||||
<target>Frontend-Editor für Tee</target>
|
||||
|
@ -27,6 +31,10 @@
|
|||
<source>Title</source>
|
||||
<target>Titel</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea.property.stars">
|
||||
<source>Stars</source>
|
||||
<target>Sterne</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.index.heading" resname="plugin.frontEndEditor.index.heading" approved="yes">
|
||||
<source>My teas</source>
|
||||
<target>Meine Tees</target>
|
||||
|
@ -55,6 +63,10 @@
|
|||
<source>Actions</source>
|
||||
<target>Aktionen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.action.rating">
|
||||
<source>Rating</source>
|
||||
<target>Bewertung</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.action.edit" resname="plugin.frontEndEditor.action.edit" approved="yes">
|
||||
<source>Edit</source>
|
||||
<target>Bearbeiten</target>
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
<source>Visible</source>
|
||||
<target>Sichtbar</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_product_tea.stars">
|
||||
<source>Stars</source>
|
||||
<target>Sterne</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<trans-unit id="plugin.tea_show" resname="plugin.tea_show">
|
||||
<source>Tea single view</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea_rating" resname="plugin.tea_rating">
|
||||
<source>Tea Rating view</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor">
|
||||
<source>Tea front-end editor</source>
|
||||
</trans-unit>
|
||||
|
@ -36,12 +39,18 @@
|
|||
<trans-unit id="plugin.frontEndEditor.property.title" resname="plugin.frontEndEditor.property.title">
|
||||
<source>Title</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.property.stars">
|
||||
<source>Stars</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.edit.heading" resname="plugin.frontEndEditor.edit.heading">
|
||||
<source>Edit tea</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.action.actions" resname="plugin.frontEndEditor.action.actions">
|
||||
<source>Actions</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.action.rating">
|
||||
<source>Rating</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.frontEndEditor.action.edit" resname="plugin.frontEndEditor.action.edit">
|
||||
<source>Edit</source>
|
||||
</trans-unit>
|
||||
|
@ -60,6 +69,10 @@
|
|||
<trans-unit id="plugin.frontEndEditor.new.heading" resname="plugin.frontEndEditor.new.heading">
|
||||
<source>Create new tea</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="plugin.tea.filter.rating" resname="plugin.tea.filter.rating">
|
||||
<source>Filter by rating</source>
|
||||
</trans-unit>
|
||||
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<trans-unit id="tx_tea_domain_model_tea.hidden" resname="tx_tea_domain_model_tea.hidden">
|
||||
<source>Visible</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_product_tea.stars">
|
||||
<source>Stars</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -25,6 +25,17 @@
|
|||
<f:render partial="FrontEndEditor/ValidationResult" arguments="{property: 'description'}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="{idPrefix}-stars" class="col-sm-2 col-form-label">
|
||||
<f:translate key="{propertyLabelPrefix}.stars"/>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<f:form.textfield property="stars" id="{idPrefix}-stars" maxlength="5"
|
||||
class="form-control" errorClass="is-invalid" required="required"/>
|
||||
<f:render partial="FrontEndEditor/ValidationResult" arguments="{property: 'stars'}"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="d-flex justify-content-end mt-3 mb-3">
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="main">
|
||||
<h2>
|
||||
Rating Plugin: <f:translate key="plugin.tea.heading"/>
|
||||
</h2>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.uid"/>
|
||||
</th>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.title"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<f:for each="{teas}" as="tea">
|
||||
<tr>
|
||||
<td>
|
||||
{tea.uid}
|
||||
</td>
|
||||
<td>
|
||||
<f:link.action action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
|
||||
{tea.title}
|
||||
</f:link.action>
|
||||
</td>
|
||||
</tr>
|
||||
</f:for>
|
||||
</tbody>
|
||||
</table>
|
||||
</f:section>
|
||||
</html>
|
42
Resources/Private/Plugins/Rating/Templates/Tea/Index.html
Normal file
42
Resources/Private/Plugins/Rating/Templates/Tea/Index.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="main">
|
||||
<h2>
|
||||
<f:translate key="plugin.tea.heading"/>
|
||||
</h2>
|
||||
<f:translate key="plugin.tea.filter.rating"/>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.uid"/>
|
||||
</th>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.title"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<f:for each="{teas}" as="tea">
|
||||
<tr>
|
||||
<td>
|
||||
{tea.uid}
|
||||
</td>
|
||||
<td>
|
||||
<f:link.action pluginName="tearaing" action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
|
||||
{tea.title}
|
||||
</f:link.action>
|
||||
</td>
|
||||
</tr>
|
||||
</f:for>
|
||||
</tbody>
|
||||
</table>
|
||||
</f:section>
|
||||
</html>
|
12
Resources/Private/Plugins/Rating/Templates/Tea/Show.html
Normal file
12
Resources/Private/Plugins/Rating/Templates/Tea/Show.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="main">
|
||||
<h2>
|
||||
Rating Plugin: {tea.title}
|
||||
</h2>
|
||||
|
||||
{tea.description -> f:format.html()}
|
||||
</f:section>
|
||||
</html>
|
|
@ -26,6 +26,9 @@
|
|||
<th scope="col" colspan="2">
|
||||
<f:translate key="plugin.frontEndEditor.action.actions"/>
|
||||
</th>
|
||||
<th scope="col" colspan="2">
|
||||
<f:translate key="plugin.frontEndEditor.action.rating"/>
|
||||
</th>
|
||||
</tr>
|
||||
<f:for each="{teas}" as="tea">
|
||||
<tr>
|
||||
|
@ -46,6 +49,14 @@
|
|||
class="btn btn-danger"/>
|
||||
</f:form>
|
||||
</td>
|
||||
<td>
|
||||
<f:link.action action="rating" controller="Rating" arguments="{tea:tea,stars:1}">1</f:link.action>
|
||||
<f:link.action action="rating" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||
<f:link.action action="rating" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||
<f:link.action action="rating" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||
<f:link.action action="rating" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||
({tea.stars})
|
||||
</td>
|
||||
</tr>
|
||||
</f:for>
|
||||
</table>
|
||||
|
|
41
Resources/Private/Templates/Rating/Filter.html
Normal file
41
Resources/Private/Templates/Rating/Filter.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="main">
|
||||
<h2>
|
||||
<f:translate key="plugin.tea.heading"/>
|
||||
</h2>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.uid"/>
|
||||
</th>
|
||||
<th>
|
||||
<f:translate key="plugin.tea.property.title"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<f:for each="{teas}" as="tea">
|
||||
<tr>
|
||||
<td>
|
||||
{tea.uid}
|
||||
</td>
|
||||
<td>
|
||||
<f:link.action action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
|
||||
{tea.title}
|
||||
</f:link.action>
|
||||
</td>
|
||||
</tr>
|
||||
</f:for>
|
||||
</tbody>
|
||||
</table>
|
||||
</f:section>
|
||||
</html>
|
|
@ -6,7 +6,6 @@
|
|||
<h2>
|
||||
<f:translate key="plugin.tea.heading"/>
|
||||
</h2>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use TTN\Tea\Controller\FrontEndEditorController;
|
||||
use TTN\Tea\Controller\RatingController;
|
||||
use TTN\Tea\Controller\TeaController;
|
||||
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
|
||||
|
||||
|
@ -51,3 +52,18 @@ ExtensionUtility::configurePlugin(
|
|||
FrontEndEditorController::class => 'index, edit, update, create, new, delete',
|
||||
]
|
||||
);
|
||||
|
||||
// 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'
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ CREATE TABLE tx_tea_domain_model_tea (
|
|||
description varchar(2000) DEFAULT '' NOT NULL,
|
||||
image int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
owner int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
stars int(11) unsigned DEFAULT NULL,
|
||||
|
||||
KEY owner (owner)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue