Skip to content
Snippets Groups Projects
Commit 7e8a4b40 authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Use constants in NewMultiplePagesController

This change uses constants from PageRepository
to define possible doktypes.

In addition, some minor details in the rest
of the code (strict types, variable renaming)
help to understand the code better.

Resolves: #97399
Releases: main
Change-Id: Id275edc131b2406f346418eecc099fd1f0b2ac05
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74328


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenjamin Franzke <bfr@qbus.de>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent b0ea7c5f
Branches
Tags
No related merge requests found
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
......@@ -136,30 +137,30 @@ class NewMultiplePagesController
}
}
$commandArray = [];
$dataMap = [];
$firstRecord = true;
$previousIdentifier = '';
foreach ($newPagesData as $identifier => $data) {
if (!trim($data['title'])) {
continue;
}
$commandArray['pages'][$identifier]['hidden'] = (int)$hidePages;
$commandArray['pages'][$identifier]['nav_hide'] = (int)$hidePagesInMenu;
$commandArray['pages'][$identifier]['title'] = $data['title'];
$commandArray['pages'][$identifier]['doktype'] = $data['doktype'];
$dataMap['pages'][$identifier]['hidden'] = (int)$hidePages;
$dataMap['pages'][$identifier]['nav_hide'] = (int)$hidePagesInMenu;
$dataMap['pages'][$identifier]['title'] = $data['title'];
$dataMap['pages'][$identifier]['doktype'] = $data['doktype'];
if ($firstRecord) {
$firstRecord = false;
$commandArray['pages'][$identifier]['pid'] = $firstPid;
$dataMap['pages'][$identifier]['pid'] = $firstPid;
} else {
$commandArray['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
$dataMap['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
}
$previousIdentifier = $identifier;
}
if (!empty($commandArray)) {
if (!empty($dataMap)) {
$pagesCreated = true;
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start($commandArray, []);
$dataHandler->start($dataMap, []);
$dataHandler->process_datamap();
BackendUtility::setUpdateSignal('updatePageTree');
}
......@@ -169,11 +170,8 @@ class NewMultiplePagesController
/**
* Page selector type data
*
* @param int $pageUid Page Uid
* @return array
*/
protected function getTypeSelectData(int $pageUid)
protected function getTypeSelectData(int $pageUid): array
{
$tsConfig = BackendUtility::getPagesTSconfig($pageUid);
$pagesTsConfig = $tsConfig['TCEFORM.']['pages.'] ?? [];
......@@ -182,11 +180,11 @@ class NewMultiplePagesController
$types = $GLOBALS['PAGES_TYPES'];
unset($types['default']);
$types = array_keys($types);
$types[] = 1; // default
$types[] = 3; // link
$types[] = 4; // shortcut
$types[] = 7; // mount point
$types[] = 199; // spacer
$types[] = PageRepository::DOKTYPE_DEFAULT;
$types[] = PageRepository::DOKTYPE_LINK;
$types[] = PageRepository::DOKTYPE_SHORTCUT;
$types[] = PageRepository::DOKTYPE_MOUNTPOINT;
$types[] = PageRepository::DOKTYPE_SPACER;
if (!$this->getBackendUser()->isAdmin() && isset($this->getBackendUser()->groupData['pagetypes_select'])) {
$types = GeneralUtility::trimExplode(',', $this->getBackendUser()->groupData['pagetypes_select'], true);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment