Commit 873e4305 authored by Benni Mack's avatar Benni Mack Committed by Susanne Moog
Browse files

[TASK] Use BE Routing / PSR-7 instead of BackendUtility::getModuleUrl

The new PSR-7-based solution since TYPO3 v7 should be used everywhere
instead of "BackendUtility::getModuleUrl()". This is possible because
modules can be addressed via the "route" GET parameter instead of the
"M" parameter since a few months.

The patch changes all occurrences within TYPO3 Core to use the new API.

Resolves: #83172
Releases: master
Change-Id: Iec40e8ae00f1d900d7479b84a3a62827ddba653b
Reviewed-on: https://review.typo3.org/54755

Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
parent e32bfd67
......@@ -14,9 +14,9 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -48,13 +48,14 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ClearCacheMenu');
$backendUser = $this->getBackendUser();
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
// Clear all page-related caches
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) {
$this->cacheActions[] = [
'id' => 'pages',
'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:flushPageCachesTitle',
'description' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:flushPageCachesDescription',
'href' => BackendUtility::getModuleUrl('tce_db', ['cacheCmd' => 'pages']),
'href' => (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'pages']),
'iconIdentifier' => 'actions-system-cache-clear-impact-low'
];
$this->optionValues[] = 'pages';
......@@ -68,7 +69,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
'id' => 'all',
'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:flushAllCachesTitle2',
'description' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:flushAllCachesDescription2',
'href' => BackendUtility::getModuleUrl('tce_db', ['cacheCmd' => 'all']),
'href' => (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'all']),
'iconIdentifier' => 'actions-system-cache-clear-impact-high'
];
$this->optionValues[] = 'all';
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
......@@ -317,14 +318,14 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$parsedUrl = parse_url($url);
parse_str($parsedUrl['query'], $parameters);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
// parse the returnUrl and replace the module token of it
if (isset($parameters['returnUrl'])) {
$parsedReturnUrl = parse_url($parameters['returnUrl']);
parse_str($parsedReturnUrl['query'], $returnUrlParameters);
if (strpos($parsedReturnUrl['path'], 'index.php') !== false && !empty($returnUrlParameters['route'])) {
$module = $returnUrlParameters['route'];
$returnUrl = BackendUtility::getModuleUrl($module, $returnUrlParameters);
$parameters['returnUrl'] = $returnUrl;
$parameters['returnUrl'] = (string)$uriBuilder->buildUriFromRoutePath($module, $returnUrlParameters);
$url = $parsedUrl['path'] . '?' . http_build_query($parameters, '', '&', PHP_QUERY_RFC3986);
}
}
......@@ -334,9 +335,6 @@ class ShortcutToolbarItem implements ToolbarItemInterface
}
if (strpos($parsedUrl['path'], 'index.php') !== false && isset($parameters['route'])) {
$module = $parameters['route'];
$url = BackendUtility::getModuleUrl($module, $parameters);
} elseif (strpos($parsedUrl['path'], 'index.php') !== false && isset($parameters['route'])) {
$routePath = $parameters['route'];
/** @var \TYPO3\CMS\Backend\Routing\Router $router */
$router = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\Router::class);
......@@ -344,8 +342,6 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$route = $router->match($routePath);
if ($route) {
$routeIdentifier = $route->getOption('_identifier');
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
unset($parameters['route']);
$url = (string)$uriBuilder->buildUriFromRoute($routeIdentifier, $parameters);
}
......
......@@ -16,9 +16,9 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
......@@ -346,9 +346,10 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
return '';
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$view = $this->getFluidTemplateObject('SystemInformationDropDown.html');
$view->assignMultiple([
'environmentToolUrl' => BackendUtility::getModuleUrl('tools_toolsenvironment'),
'environmentToolUrl' => (string)$uriBuilder->buildUriFromRoute('tools_toolsenvironment'),
'messages' => $this->systemMessages,
'count' => $this->totalCount > $this->maximumCountInBadge ? $this->maximumCountInBadge . '+' : $this->totalCount,
'severityBadgeClass' => $this->severityBadgeClass,
......
......@@ -15,8 +15,8 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
*/
use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -65,6 +65,7 @@ class UserToolbarItem implements ToolbarItemInterface
/** @var BackendModuleRepository $backendModuleRepository */
$backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$mostRecentUsers = [];
if (ExtensionManagementUtility::isLoaded('beuser')
......@@ -85,7 +86,7 @@ class UserToolbarItem implements ToolbarItemInterface
$mostRecentUsers = array_flip($backendUser->uc['recentSwitchedToUsers']);
while ($row = $result->fetch()) {
$row['switchUserLink'] = BackendUtility::getModuleUrl(
$row['switchUserLink'] = (string)$uriBuilder->buildUriFromRoute(
'system_BeuserTxBeuser',
[
'SwitchUser' => $row['uid']
......@@ -110,7 +111,7 @@ class UserToolbarItem implements ToolbarItemInterface
$view = $this->getFluidTemplateObject('UserToolbarItemDropDown.html');
$view->assignMultiple([
'modules' => $backendModuleRepository->findByModuleName('user')->getChildren(),
'logoutUrl' => BackendUtility::getModuleUrl('logout'),
'logoutUrl' => (string)$uriBuilder->buildUriFromRoute('logout'),
'switchUserMode' => $this->getBackendUser()->user['ses_backuserid'],
'recentUsers' => $mostRecentUsers,
]);
......
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Clipboard;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
......@@ -270,10 +271,11 @@ class Clipboard
$optionArray = [];
// Import / Export link:
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = BackendUtility::getModuleUrl('xMOD_tximpexp', $this->exportClipElementParameters());
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = $uriBuilder->buildUriFromRoute('xMOD_tximpexp', $this->exportClipElementParameters());
$optionArray[] = [
'label' => $this->clLabel('export', 'rm'),
'uri' => $url
'uri' => (string)$url
];
}
// Edit:
......@@ -541,19 +543,18 @@ class Clipboard
*/
public function linkItemText($str, $rec, $table = '')
{
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
if (is_array($rec) && $table) {
if ($this->fileMode) {
$str = '<span class="text-muted">' . $str . '</span>';
} else {
$str = '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_list', ['id' => $rec['pid']])) . '">' . $str . '</a>';
$str = '<a href="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute('web_list', ['id' => $rec['pid']])) . '">' . $str . '</a>';
}
} elseif (file_exists($rec)) {
if (!$this->fileMode) {
$str = '<span class="text-muted">' . $str . '</span>';
} else {
if (ExtensionManagementUtility::isLoaded('filelist')) {
$str = '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('file_list', ['id' => dirname($rec)])) . '">' . $str . '</a>';
}
} elseif (ExtensionManagementUtility::isLoaded('filelist')) {
$str = '<a href="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute('file_list', ['id' => dirname($rec)])) . '">' . $str . '</a>';
}
}
return $str;
......@@ -621,7 +622,8 @@ class Clipboard
if (is_array($update)) {
$urlParameters['CB[update]'] = $update;
}
return BackendUtility::getModuleUrl($table === '_FILE' ? 'tce_file' : 'tce_db', $urlParameters);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute($table === '_FILE' ? 'tce_file' : 'tce_db', $urlParameters);
}
/**
......@@ -640,7 +642,8 @@ class Clipboard
if ($setRedirect) {
$urlParameters['redirect'] = GeneralUtility::linkThisScript(['CB' => '']);
}
return BackendUtility::getModuleUrl($file ? 'tce_file' : 'tce_db', $urlParameters);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute($file ? 'tce_file' : 'tce_db', $urlParameters);
}
/**
......@@ -659,7 +662,8 @@ class Clipboard
list($table, $uid) = explode('|', $tP);
$parameters['edit[' . $table . '][' . $uid . ']'] = 'edit';
}
return BackendUtility::getModuleUrl('record_edit', $parameters);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters);
}
/**
......
......@@ -15,8 +15,9 @@ namespace TYPO3\CMS\Backend\ContextMenu\ItemProviders;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Context menu item provider for pages table
......@@ -453,13 +454,15 @@ class PageProvider extends RecordProvider
$attributes += $this->getPasteAdditionalAttributes('after');
}
if ($itemName === 'pagesSort') {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$attributes += [
'data-pages-sort-url' => BackendUtility::getModuleUrl('pages_sort', ['id' => $this->record['uid']]),
'data-pages-sort-url' => (string)$uriBuilder->buildUriFromRoute('pages_sort', ['id' => $this->record['uid']]),
];
}
if ($itemName === 'pagesNewMultiple') {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$attributes += [
'data-pages-new-multiple-url' => BackendUtility::getModuleUrl('pages_new', ['id' => $this->record['uid']]),
'data-pages-new-multiple-url' => (string)$uriBuilder->buildUriFromRoute('pages_new', ['id' => $this->record['uid']]),
];
}
return $attributes;
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\ContextMenu\ItemProviders;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
......@@ -302,7 +303,8 @@ class RecordProvider extends AbstractProvider
'colPos' => $this->record['colPos'],
'uid_pid' => -$this->record['uid']
];
$url = BackendUtility::getModuleUrl($moduleName, $urlParameters);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($moduleName, $urlParameters);
$attributes += [
'data-new-wizard-url' => htmlspecialchars($url)
];
......
......@@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
......@@ -112,7 +113,7 @@ class BackendController
$this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
// Set debug flag for BE development only
$this->debug = (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] === 1;
// Initializes the backend modules structure for use later.
......@@ -131,8 +132,8 @@ class BackendController
];
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LoginRefresh', 'function(LoginRefresh) {
LoginRefresh.setIntervalTime(' . MathUtility::forceIntegerInRange((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'] - 60, 60) . ');
LoginRefresh.setLoginFramesetUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('login_frameset')) . ');
LoginRefresh.setLogoutUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('logout')) . ');
LoginRefresh.setLoginFramesetUrl(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('login_frameset')) . ');
LoginRefresh.setLogoutUrl(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('logout')) . ');
LoginRefresh.initialize();
}');
......@@ -166,12 +167,12 @@ class BackendController
$this->pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf');
$this->pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
$this->pageRenderer->addInlineSetting('ShowItem', 'moduleUrl', BackendUtility::getModuleUrl('show_item'));
$this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history'));
$this->pageRenderer->addInlineSetting('NewRecord', 'moduleUrl', BackendUtility::getModuleUrl('db_new'));
$this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit'));
$this->pageRenderer->addInlineSetting('RecordCommit', 'moduleUrl', BackendUtility::getModuleUrl('tce_db'));
$this->pageRenderer->addInlineSetting('WebLayout', 'moduleUrl', BackendUtility::getModuleUrl('web_layout'));
$this->pageRenderer->addInlineSetting('ShowItem', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('show_item'));
$this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('record_history'));
$this->pageRenderer->addInlineSetting('NewRecord', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('db_new'));
$this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('record_edit'));
$this->pageRenderer->addInlineSetting('RecordCommit', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('tce_db'));
$this->pageRenderer->addInlineSetting('WebLayout', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('web_layout'));
$this->css = '';
......
......@@ -417,7 +417,10 @@ class ElementHistoryController
// Merging overriding values:
$params = array_merge($params, $overrideParameters);
// Make the link:
return BackendUtility::getModuleUrl('record_history', $params);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_history', $params);
}
/**
......
......@@ -497,18 +497,20 @@ class ElementInformationController
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$actions['recordEditUrl'] = BackendUtility::getModuleUrl('record_edit', $urlParameters);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$actions['recordEditUrl'] = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
// History button
$urlParameters = [
'element' => $table . ':' . $uid,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$actions['recordHistoryUrl'] = BackendUtility::getModuleUrl('record_history', $urlParameters);
$actions['recordHistoryUrl'] = (string)$uriBuilder->buildUriFromRoute('record_history', $urlParameters);
if ($table === 'pages') {
// Recordlist button
$actions['webListUrl'] = BackendUtility::getModuleUrl('web_list', ['id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
$actions['webListUrl'] = (string)$uriBuilder->buildUriFromRoute('web_list', ['id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
// View page button
$actions['viewOnClick'] = BackendUtility::viewOnClick($uid, '', BackendUtility::BEgetRootLine($uid));
......@@ -582,7 +584,9 @@ class ElementInformationController
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$line['url'] = $url;
$line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
$line['row'] = $row;
......@@ -646,7 +650,9 @@ class ElementInformationController
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
];
$url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$line['url'] = $url;
$line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
$line['row'] = $row;
......
......@@ -462,8 +462,10 @@ class EditDocumentController
if (!is_array($this->defVals) && is_array($this->overrideVals)) {
$this->defVals = $this->overrideVals;
}
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Setting return URL
$this->retUrl = $this->returnUrl ?: BackendUtility::getModuleUrl('dummy');
$this->retUrl = $this->returnUrl ?: (string)$uriBuilder->buildUriFromRoute('dummy');
// Fix $this->editconf if versioning applies to any of the records
$this->fixWSversioningInEditConf();
// Make R_URL (request url) based on input GETvars:
......@@ -607,10 +609,12 @@ class EditDocumentController
}
$newEditConf[$tableName][$editId] = 'edit';
}
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Traverse all new records and forge the content of ->editconf so we can continue to EDIT
// these records!
if ($tableName === 'pages'
&& $this->retUrl != BackendUtility::getModuleUrl('dummy')
&& $this->retUrl != (string)$uriBuilder->buildUriFromRoute('dummy')
&& $this->returnNewPageId
) {
$this->retUrl .= '&id=' . $tce->substNEWwithIDs[$key];
......@@ -728,6 +732,8 @@ class EditDocumentController
$this->doc = $GLOBALS['TBE_TEMPLATE'];
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// override the default jumpToUrl
$this->moduleTemplate->addJavaScriptCode(
'jumpToUrl',
......@@ -743,7 +749,7 @@ class EditDocumentController
// Info view:
function launchView(table,uid) {
var thePreviewWindow = window.open(
' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
"ShowItem" + Math.random().toString(16).slice(2),
"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0"
);
......@@ -752,7 +758,7 @@ class EditDocumentController
}
}
function deleteRecord(table,id,url) {
window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1&redirect="+escape(url);
window.location.href = ' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1&redirect="+escape(url);
}
' . (isset($_POST['_savedokview']) && $this->popViewId ? $this->generatePreviewCode() : '')
);
......@@ -1154,6 +1160,8 @@ class EditDocumentController
protected function getButtons()
{
$lang = $this->getLanguageService();
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Render SAVE type buttons:
// The action of each button is decided by its name attribute. (See doProcessData())
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
......@@ -1282,7 +1290,7 @@ class EditDocumentController
) {
// TODO: Use the page's pid instead of 0, this requires a clean API to manipulate the page
// tree from the outside to be able to mark the pid as active
$returnUrl = BackendUtility::getModuleUrl($queryParams['route'], ['id' => 0]);
$returnUrl = (string)$uriBuilder->buildUriFromRoute($queryParams['route'], ['id' => 0]);
}
}
$deleteButton = $buttonBar->makeLinkButton()
......@@ -1324,7 +1332,7 @@ class EditDocumentController
if ($undoButtonR !== false) {
$aOnClick = 'window.location.href=' .
GeneralUtility::quoteJSvalue(
BackendUtility::getModuleUrl(
(string)$uriBuilder->buildUriFromRoute(
'record_history',
[
'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
......@@ -1355,7 +1363,7 @@ class EditDocumentController
if ($this->getNewIconMode($this->firstEl['table'], 'showHistory')) {
$aOnClick = 'window.location.href=' .
GeneralUtility::quoteJSvalue(
BackendUtility::getModuleUrl(
(string)$uriBuilder->buildUriFromRoute(
'record_history',
[
'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
......@@ -1505,6 +1513,9 @@ class EditDocumentController
{
$languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
$transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Table editable and activated for languages?
if ($this->getBackendUser()->check('tables_modify', $table)
&& $languageField
......@@ -1593,7 +1604,7 @@ class EditDocumentController
// Create url for creating a localized record
$addOption = true;
if ($newTranslation) {
$redirectUrl = BackendUtility::getModuleUrl('record_edit', [
$redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', [
'justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'],
'returnUrl' => $this->retUrl
]);
......@@ -1607,7 +1618,7 @@ class EditDocumentController
$addOption = false;
}
} else {
$href = BackendUtility::getModuleUrl('record_edit', [
$href = (string)$uriBuilder->buildUriFromRoute('record_edit', [
'edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit',
'returnUrl' => $this->retUrl
]);
......@@ -1636,6 +1647,9 @@ class EditDocumentController
*/
public function localizationRedirect($justLocalized)
{
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
list($table, $origUid, $language) = explode(':', $justLocalized);
if ($GLOBALS['TCA'][$table]
&& $GLOBALS['TCA'][$table]['ctrl']['languageField']
......@@ -1665,7 +1679,7 @@ class EditDocumentController
if (is_array($localizedRecord)) {
// Create parameters and finally run the classic page module for creating a new page translation
$location = BackendUtility::getModuleUrl('record_edit', [
$location = (string)$uriBuilder->buildUriFromRoute('record_edit', [
'edit[' . $table . '][' . $localizedRecord['uid'] . ']' => 'edit',
'returnUrl' => GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))
]);
......@@ -1900,9 +1914,11 @@ class EditDocumentController
BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
}
if ($mode !== self::DOCUMENT_CLOSE_MODE_NO_REDIRECT) {
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by
// other scripts, like wizard_add, to know which records was created or so...)
if ($this->returnEditConf && $this->retUrl != BackendUtility::getModuleUrl('dummy')) {
if ($this->returnEditConf && $this->retUrl != (string)$uriBuilder->buildUriFromRoute('dummy')) {
$this->retUrl .= '&returnEditConf=' . rawurlencode(json_encode($this->editconf));
}
......
......@@ -131,6 +131,9 @@ class CreateFolderController
$pathInfo = [
'combined_identifier' => $this->folderObject->getCombinedIdentifier(),
];
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pathInfo);
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
$this->moduleTemplate->addJavaScriptCode(
......@@ -148,7 +151,7 @@ class CreateFolderController
. ';
function reload(a) {
var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . rawurlencode($this->returnUrl) . '";
var url = \'' . BackendUtility::getModuleUrl('file_newfolder') . '\';
var url = \'' . (string)$uriBuilder->buildUriFromRoute('file_newfolder') . '\';
if (!changed) {
window.location.href = url + params;
} else {
......@@ -178,7 +181,9 @@ class CreateFolderController
$assigns = [];
$assigns['target'] = $this->target;
if ($this->folderObject->checkActionPermission('add')) {
$assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file');
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$assigns['moduleUrlTceFile'] = (string)$uriBuilder->buildUriFromRoute('tce_file');
$assigns['cshFileNewFolder'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfolder');
// Making the selector box for the number of concurrent folder-creations
$this->number = MathUtility::forceIntegerInRange($this->number, 1, 10);
......@@ -200,7 +205,9 @@ class CreateFolderController
}
if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')) {
$assigns['moduleUrlOnlineMedia'] = BackendUtility::getModuleUrl('online_media');
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$assigns['moduleUrlOnlineMedia'] = (string)$uriBuilder->buildUriFromRoute('online_media');
$assigns['cshFileNewMedia'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newMedia');
// Create a list of allowed file extensions with the readable format "youtube, vimeo" etc.
$fileExtList = [];
......@@ -212,7 +219,7 @@ class CreateFolderController
}
$assigns['fileExtList'] = $fileExtList;
$assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file');
$assigns['moduleUrlTceFile'] = (string)$uriBuilder->buildUriFromRoute('tce_file');
$assigns['cshFileNewFile'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_newfile');
// Create a list of allowed file extensions with a text format "*.txt, *.css" etc.
$fileExtList = [];
......
......@@ -21,7 +21,6 @@ use TYPO3\CMS\Backend\Form\NodeFactory;