17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
47 public function dispatch(ServerRequestInterface $request): ResponseInterface
49 $parsedBody = $request->getParsedBody();
50 $queryParams = $request->getQueryParams();
52 $this->conf[
'action'] = $parsedBody[
'action'] ?? $queryParams[
'action'] ??
null;
53 $this->conf[
'table'] = $parsedBody[
'table'] ?? $queryParams[
'table'] ??
'';
55 (
int)($this->
getBackendUser()->getTSConfig()[
'mod.'][
'recycler.'][
'recordsPageLimit'] ?? 25),
58 $this->conf[
'start'] = (int)($parsedBody[
'start'] ?? $queryParams[
'start'] ?? 0);
59 $this->conf[
'filterTxt'] = $parsedBody[
'filterTxt'] ?? $queryParams[
'filterTxt'] ??
'';
60 $this->conf[
'startUid'] = (int)($parsedBody[
'startUid'] ?? $queryParams[
'startUid'] ?? 0);
61 $this->conf[
'depth'] = (int)($parsedBody[
'depth'] ?? $queryParams[
'depth'] ?? 0);
62 $this->conf[
'records'] = $parsedBody[
'records'] ?? $queryParams[
'records'] ??
null;
63 $this->conf[
'recursive'] = (bool)($parsedBody[
'recursive'] ?? $queryParams[
'recursive'] ??
false);
67 $view = GeneralUtility::makeInstance(StandaloneView::class);
68 $view->setPartialRootPaths([
'default' => $extPath .
'Resources/Private/Partials']);
72 switch ($this->conf[
'action']) {
77 $model = GeneralUtility::makeInstance(Tables::class);
78 $content = $model->getTables($this->conf[
'startUid'], $this->conf[
'depth']);
80 case 'getDeletedRecords':
82 'tableSelection' => $this->conf[
'table'],
83 'depthSelection' => $this->conf[
'depth'],
84 'resultLimit' => $this->conf[
'limit'],
88 $model = GeneralUtility::makeInstance(DeletedRecords::class);
89 $model->loadData($this->conf[
'startUid'], $this->conf[
'table'], $this->conf[
'depth'], $this->conf[
'start'] .
',' . $this->conf[
'limit'], $this->conf[
'filterTxt']);
90 $deletedRowsArray = $model->getDeletedRows();
92 $model = GeneralUtility::makeInstance(DeletedRecords::class);
93 $totalDeleted = $model->getTotalCount($this->conf[
'startUid'], $this->conf[
'table'], $this->conf[
'depth'], $this->conf[
'filterTxt']);
96 $controller = GeneralUtility::makeInstance(DeletedRecordsController::class);
97 $recordsArray = $controller->transform($deletedRowsArray);
102 $view->setTemplatePathAndFilename($extPath .
'Resources/Private/Templates/Ajax/RecordsTable.html');
103 $view->assign(
'records', $recordsArray[
'rows']);
104 $view->assign(
'allowDelete', $allowDelete);
106 'rows' => $view->render(),
107 'totalItems' => $totalDeleted
111 if (empty($this->conf[
'records']) || !is_array($this->conf[
'records'])) {
120 $model = GeneralUtility::makeInstance(DeletedRecords::class);
121 $affectedRecords = $model->undeleteData($this->conf[
'records'], $this->conf[
'recursive']);
122 $messageKey =
'flashmessage.undo.' . ($affectedRecords !==
false ?
'success' :
'failure') .
'.' . ((
int)$affectedRecords === 1 ?
'singular' :
'plural');
128 case 'deleteRecords':
129 if (empty($this->conf[
'records']) || !is_array($this->conf[
'records'])) {
138 $model = GeneralUtility::makeInstance(DeletedRecords::class);
139 $success = $model->deleteData($this->conf[
'records']);
140 $affectedRecords = count($this->conf[
'records']);
141 $messageKey =
'flashmessage.delete.' . ($success ?
'success' :
'failure') .
'.' . ($affectedRecords === 1 ?
'singular' :
'plural');
159 $recyclerUC = $beUser->uc[
'tx_recycler'] ?? [];
160 if (!empty(array_diff_assoc($data, $recyclerUC))) {
161 $beUser->uc[
'tx_recycler'] = array_merge($recyclerUC, $data);