';
+ $html[] = '
';
}
$result['html'] = implode(LF, $html);
diff --git a/Classes/Controller/ManagementController.php b/Classes/Controller/ManagementController.php
index 4835105..7efd57e 100644
--- a/Classes/Controller/ManagementController.php
+++ b/Classes/Controller/ManagementController.php
@@ -12,6 +12,7 @@
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3Fluid\Fluid\View\ViewInterface;
@@ -38,10 +39,10 @@ class ManagementController
/** @var LogRepository */
protected $logRepository;
- public function __construct()
+ public function __construct(private PageRenderer $pageRenderer)
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
- $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
+ $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$this->getLanguageService()->includeLLFile('EXT:riddle/Resources/Private/Language/locallang.xlf');
$this->logRepository = GeneralUtility::makeInstance(LogRepository::class);
}
@@ -85,7 +86,6 @@ protected function exportLogs(LogDemand $demand)
->setPage(1);
$riddles = $this->logRepository->findByDemandForExport($demand);
-
$fp = fopen('php://output', 'wb');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="export.csv"');
@@ -94,7 +94,7 @@ protected function exportLogs(LogDemand $demand)
fputcsv($fp, array_keys($riddles[0]));
foreach ($riddles as $row) {
fputcsv($fp, array_values($row));
- };
+ }
fclose($fp);
die;
}
@@ -113,7 +113,7 @@ protected function preparePagination(LogDemand $demand, int $count): array
'hasLessPages' => $demand->getPage() > 1,
'hasMorePages' => $demand->getPage() < $numberOfPages,
'startRecord' => $demand->getOffset() + 1,
- 'endRecord' => $endRecord
+ 'endRecord' => $endRecord,
];
if ($pagination['current'] < $pagination['numberOfPages']) {
$pagination['nextPage'] = $pagination['current'] + 1;
diff --git a/Classes/Controller/PluginController.php b/Classes/Controller/PluginController.php
index c58f275..aa7d1e3 100644
--- a/Classes/Controller/PluginController.php
+++ b/Classes/Controller/PluginController.php
@@ -14,14 +14,16 @@
use StudioMitte\Riddle\Api\RiddleApi;
use StudioMitte\Riddle\Utility\RiddleUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class PluginController extends ContentObjectRenderer
{
+ protected ContentObjectRenderer $cObj;
- /** @var ContentObjectRenderer */
- protected $cObj;
+ public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
+ {
+ $this->cObj = $cObj;
+ }
public function run(): string
{
@@ -34,20 +36,11 @@ public function run(): string
return '';
}
- if (MathUtility::canBeInterpretedAsInteger($riddleId)) {
- return $this->getRiddleHtml((int)$riddleId);
- }
- return $this->getRiddleHtmlV2($riddleId);
- }
-
- protected function getRiddleHtml(int $id): string
- {
- $response = GeneralUtility::makeInstance(RiddleApi::class)->getEmbedCode($id);
- return (string)($response['response'] ?? '');
+ return $this->getRiddleHtml($riddleId);
}
- protected function getRiddleHtmlV2(string $id): string
+ protected function getRiddleHtml(string $id): string
{
- return GeneralUtility::makeInstance(RiddleApi::class)->getEmbedCodeV2($id);
+ return GeneralUtility::makeInstance(RiddleApi::class)->getEmbedCode($id);
}
}
diff --git a/Classes/Domain/Dto/LogDemand.php b/Classes/Domain/Dto/LogDemand.php
index ccb5644..6413031 100644
--- a/Classes/Domain/Dto/LogDemand.php
+++ b/Classes/Domain/Dto/LogDemand.php
@@ -8,7 +8,6 @@
class LogDemand
{
-
/** @var string */
protected $type = '';
@@ -51,7 +50,6 @@ public function getId(): int
return $this->id;
}
-
/**
* The current Page of the paginated redirects
*
@@ -107,8 +105,4 @@ public function setPage(int $page): LogDemand
$this->page = $page;
return $this;
}
-
-
-
-
}
diff --git a/Classes/Domain/LogItem.php b/Classes/Domain/LogItem.php
index 3c3ebde..ba49775 100644
--- a/Classes/Domain/LogItem.php
+++ b/Classes/Domain/LogItem.php
@@ -6,7 +6,6 @@
class LogItem
{
-
public static function convert(array $raw): array
{
$raw = $raw['data'];
@@ -25,7 +24,7 @@ public static function convert(array $raw): array
'result_id' => $raw['resultData']['resultId'] ?? '',
'lead_name' => $raw['lead2']['Name']['value'] ?? '',
'lead_email' => $raw['lead2']['Email']['value'] ?? '',
- 'full_json' => json_encode($raw, JSON_THROW_ON_ERROR)
+ 'full_json' => json_encode($raw, JSON_THROW_ON_ERROR),
];
return $data;
diff --git a/Classes/Domain/Repository/LogRepository.php b/Classes/Domain/Repository/LogRepository.php
index 84c2911..233329b 100644
--- a/Classes/Domain/Repository/LogRepository.php
+++ b/Classes/Domain/Repository/LogRepository.php
@@ -12,7 +12,6 @@
class LogRepository
{
-
private const TABLE = 'tx_riddle_log';
public function add(array $item): void
@@ -98,9 +97,7 @@ public function getGroupingInformation(): array
$rows = $queryBuilder
->select($field)
- ->from(self::TABLE)
- ->groupBy($field)
- ->execute()
+ ->from(self::TABLE)->groupBy($field)->executeQuery()
->fetchAll();
foreach ($rows as $row) {
@@ -115,5 +112,4 @@ protected function getConnection(): Connection
{
return GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(self::TABLE);
}
-
}
diff --git a/Classes/ExtensionConfiguration.php b/Classes/ExtensionConfiguration.php
index 7287e8e..f351b6f 100644
--- a/Classes/ExtensionConfiguration.php
+++ b/Classes/ExtensionConfiguration.php
@@ -16,10 +16,7 @@
class ExtensionConfiguration implements SingletonInterface
{
-
protected string $apiKey = '';
- protected string $apiToken = '';
- protected string $apiTokenV2 = '';
public function __construct()
{
@@ -28,8 +25,6 @@ public function __construct()
if (is_array($configuration)) {
$this->apiKey = (string)($configuration['apiKey'] ?? '');
- $this->apiToken = (string)($configuration['apiToken'] ?? '');
- $this->apiTokenV2 = (string)($configuration['apiTokenV2'] ?? '');
}
} catch (\Exception $e) {
}
@@ -39,25 +34,4 @@ public function getApiKey(): string
{
return $this->apiKey;
}
-
- public function getApiToken(): string
- {
- return $this->apiToken;
- }
-
- public function getApiTokenV2(): string
- {
- return $this->apiTokenV2;
- }
-
- public function isV1Enabled(): bool
- {
- return $this->apiKey && $this->apiToken;
- }
-
- public function isV2Enabled(): bool
- {
- return (bool)$this->apiTokenV2;
- }
-
}
diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php
index 3690fa7..74a1fea 100644
--- a/Classes/Hooks/ItemsProcFunc.php
+++ b/Classes/Hooks/ItemsProcFunc.php
@@ -10,10 +10,10 @@
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
-
use StudioMitte\Riddle\Api\RiddleApi;
use StudioMitte\Riddle\Utility\RiddleUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -26,18 +26,7 @@ class ItemsProcFunc
public function riddleList(array &$config): void
{
try {
- $riddles2 = $this->getAllRiddlesV2();
- if ($riddles2) {
- $config['items'][] = ['V2', '--div--'];
- }
- foreach ($riddles2 as $item) {
- $config['items'][] = $this->getSelectItem($item);
- }
-
$riddles = $this->getAllRiddles();
- if ($riddles) {
- $config['items'][] = ['V1', '--div--'];
- }
foreach ($riddles as $item) {
$config['items'][] = $this->getSelectItem($item, false);
}
@@ -47,7 +36,7 @@ public function riddleList(array &$config): void
FlashMessage::class,
$e->getMessage(),
'',
- FlashMessage::ERROR
+ AbstractMessage::ERROR
);
GeneralUtility::makeInstance(FlashMessageService::class)
->getMessageQueueByIdentifier()
@@ -58,39 +47,18 @@ public function riddleList(array &$config): void
protected function getSelectItem(array $item, bool $isV2 = true): array
{
- if ($isV2) {
- $item = RiddleUtility::enrichRiddleData($item);
- $date = $item['_enriched']['datepublished'] ? BackendUtility::date($item['_enriched']['datepublished']) : $item['created']['at'] ?? '';
- return [
- sprintf('%s [%s] - %s', $item['title'], $item['type'] ?? '-', $date),
- $item['UUID'],
- $item['image'] ?? '',
- ];
- }
-
$item = RiddleUtility::enrichRiddleData($item);
-
- $date = $item['_enriched']['datepublished'] ? BackendUtility::date($item['_enriched']['datepublished']) : $item['datepublished'];
+ $date = $item['_enriched']['datepublished'] ? BackendUtility::date($item['_enriched']['datepublished']) : $item['created']['at'] ?? '';
return [
sprintf('%s [%s] - %s', $item['title'], $item['type'] ?? '-', $date),
- $item['id'],
- $item['thumb'] ?? '',
+ $item['UUID'],
+ $item['image'] ?? '',
];
}
protected function getAllRiddles(): array
{
$api = GeneralUtility::makeInstance(RiddleApi::class);
- $response = $api->getRiddleList();
-
- return $response['response']['items'] ?? [];
- }
-
- protected function getAllRiddlesV2(): array
- {
- $api = GeneralUtility::makeInstance(RiddleApi::class);
- $response = $api->getRiddleListV2();
-
- return $response['data'] ?? [];
+ return $api->getRiddleList();
}
}
diff --git a/Classes/Hooks/PageLayoutView.php b/Classes/Hooks/PageLayoutView.php
deleted file mode 100644
index 4b7afa0..0000000
--- a/Classes/Hooks/PageLayoutView.php
+++ /dev/null
@@ -1,74 +0,0 @@
-getView();
- try {
- $standaloneView->assignMultiple([
- 'riddleId' => $riddleId,
- 'riddle' => $this->getRiddleData($riddleId),
- 'riddleV2' => !MathUtility::canBeInterpretedAsInteger($riddleId)
- ]);
- } catch (ApiConfigurationMissingException $exception) {
- $standaloneView->assign('apiNotConfigured', true);
- }
- return $standaloneView->render();
- }
-
- protected function getView(): StandaloneView
- {
- $standaloneView = GeneralUtility::makeInstance(StandaloneView::class);
- $standaloneView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->template));
- $standaloneView->assignMultiple([
- 'dateTime' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],
- 'lll' => 'LLL:EXT:riddle/Resources/Private/Language/locallang.xlf:',
- ]);
- return $standaloneView;
- }
-
- /**
- * @param string|int $id
- * @return array
- */
- protected function getRiddleData($id): array
- {
- $api = GeneralUtility::makeInstance(RiddleApi::class);
- if (MathUtility::canBeInterpretedAsInteger($id)) {
- $item = $api->getRiddleItem((int)$id);
- } else {
- $item = $api->getRiddleItemV2($id);
- }
- return RiddleUtility::enrichRiddleData($item);
- }
-}
diff --git a/Classes/Middleware/WebhookEndpoint.php b/Classes/Middleware/WebhookEndpoint.php
index 2de6220..3ff9bc6 100644
--- a/Classes/Middleware/WebhookEndpoint.php
+++ b/Classes/Middleware/WebhookEndpoint.php
@@ -1,4 +1,5 @@
getUri()->getPath(), self::ENDPOINT)) {
+ ): ResponseInterface {
+ if (!\str_starts_with($request->getUri()->getPath(), self::ENDPOINT)) {
return $handler->handle($request);
}
$json = $request->getParsedBody()['data'] ?? '';
@@ -44,5 +42,4 @@ public function process(
}
return new JsonResponse(['status' => 'ok']);
}
-
}
diff --git a/Classes/Utility/RiddleUtility.php b/Classes/Utility/RiddleUtility.php
index de63c0a..e55bd14 100644
--- a/Classes/Utility/RiddleUtility.php
+++ b/Classes/Utility/RiddleUtility.php
@@ -16,7 +16,6 @@
class RiddleUtility
{
-
/**
* Enrich the API riddle response
*
@@ -61,6 +60,6 @@ public static function getRiddleId(string $flexforms)
return '';
}
$data = GeneralUtility::makeInstance(FlexFormService::class)->convertFlexFormContentToArray($flexforms);
- return ($data['riddle'] ?? '');
+ return $data['riddle'] ?? '';
}
}
diff --git a/Configuration/FlexForms/flexform_riddle.xml b/Configuration/FlexForms/flexform_riddle.xml
index 629a61b..ec829f5 100644
--- a/Configuration/FlexForms/flexform_riddle.xml
+++ b/Configuration/FlexForms/flexform_riddle.xml
@@ -22,10 +22,10 @@
-
+
ExternalIcons
0
-
+
diff --git a/Configuration/RequestMiddlewares.php b/Configuration/RequestMiddlewares.php
index 032497e..a658e40 100644
--- a/Configuration/RequestMiddlewares.php
+++ b/Configuration/RequestMiddlewares.php
@@ -5,11 +5,11 @@
'studiomitte/riddle/router' => [
'target' => \StudioMitte\Riddle\Middleware\WebhookEndpoint::class,
'after' => [
- 'typo3/cms-frontend/site'
+ 'typo3/cms-frontend/site',
],
'before' => [
- 'typo3/cms-frontend/static-route-resolver'
- ]
+ 'typo3/cms-frontend/static-route-resolver',
+ ],
],
],
];
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
new file mode 100644
index 0000000..532edd0
--- /dev/null
+++ b/Configuration/Services.yaml
@@ -0,0 +1,12 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ StudioMitte\Riddle\:
+ resource: '../Classes/*'
+
+ StudioMitte\Riddle\Backend\EventListener\BackendPreviewEventListener:
+ tags:
+ - name: event.listener
+ identifier: 'riddle/riddle'
\ No newline at end of file
diff --git a/Configuration/TCA/tx_riddle_log.php b/Configuration/TCA/tx_riddle_log.php
index e5dbbf6..b8a044e 100644
--- a/Configuration/TCA/tx_riddle_log.php
+++ b/Configuration/TCA/tx_riddle_log.php
@@ -5,17 +5,16 @@
'title' => 'LLL:EXT:plain_faq/Resources/Private/Language/locallang_db.xlf:tx_plainfaq_domain_model_faq',
'label' => 'uid',
'crdate' => 'crdate',
- 'cruser_id' => 'cruser_id',
'sortby' => 'sorting',
'searchFields' => 'question,answer,keywords,images,files',
'typeicon_classes' => [
- 'default' => 'ext-plainfaq-faq'
+ 'default' => 'ext-plainfaq-faq',
],
- 'readOnly' => true
+ 'readOnly' => true,
],
'types' => [
'1' => ['showitem' => '
- question, slug, answer, keywords,'
+ question, slug, answer, keywords,',
],
],
'palettes' => [
@@ -23,6 +22,5 @@
],
'columns' => [
-
],
];
diff --git a/Resources/Private/Templates/BackendPreview.html b/Resources/Private/Templates/BackendPreview.html
index 4e62484..26a92cf 100644
--- a/Resources/Private/Templates/BackendPreview.html
+++ b/Resources/Private/Templates/BackendPreview.html
@@ -8,7 +8,7 @@
{riddle.title}
-
+
@@ -18,7 +18,7 @@ {riddle.title}
| {f:translate(key:'{lll}riddle.id')} |
- {f:if(condition: riddleV2, then:riddle.UUID, else: riddle.id)} |
+ {riddle.UUID} |
| {f:translate(key:'{lll}riddle.type')} |
@@ -28,13 +28,13 @@ {riddle.title}
{f:translate(key:'{lll}riddle.created')} |
{riddle._enriched.dateCreated -> f:format.date(format:dateTime)}
-
+ {riddle.created.by}
|
| {f:translate(key:'{lll}riddle.published')} |
{riddle._enriched.datepublished -> f:format.date(format:dateTime)}
-
+ {riddle.published.by}
|
@@ -53,29 +53,14 @@ {riddle.title}
@@ -96,12 +81,4 @@ {riddle.title}
-
-
-
- {user.name} ({user.email})
- {by}
-
-
-