diff --git a/typo3/db_new.php b/typo3/db_new.php index 8fabbe1515e454e2637c36a7bf820ca4250338fe..fd28c707219b01d27110963b8adb3f5357d1757b 100644 --- a/typo3/db_new.php +++ b/typo3/db_new.php @@ -22,6 +22,10 @@ */ require __DIR__ . '/init.php'; +\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog( + 'The entry point to create a new database entry was moved to an own module. Please use BackendUtility::getModuleUrl(\'db_new\') to link to db_new.php. This script will be removed in TYPO3 CMS 8.' +); + $newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class); $newRecordController->main(); $newRecordController->printContent(); diff --git a/typo3/js/extjs/components/pagetree/javascript/actions.js b/typo3/js/extjs/components/pagetree/javascript/actions.js index 877dcbdd0078f175270e5c2afe5d6d3288ef3bab..3e49a9f18eeaeafd13f645b1f5e144b88914163b 100644 --- a/typo3/js/extjs/components/pagetree/javascript/actions.js +++ b/typo3/js/extjs/components/pagetree/javascript/actions.js @@ -336,7 +336,7 @@ TYPO3.Components.PageTree.Actions = { newPageWizard: function(node) { node.select(); TYPO3.Backend.ContentContainer.setUrl( - 'db_new.php?id=' + node.attributes.nodeData.id + '&pagesOnly=1' + TYPO3.settings.NewRecord.moduleUrl + '&id=' + node.attributes.nodeData.id + '&pagesOnly=1' ); }, diff --git a/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php b/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php index d1f6e046190e4c069b050bb949abf88a3e9a2cd5..12006daf4f0f8ee8eebbf0e6e670586c44203e21 100644 --- a/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php +++ b/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php @@ -623,7 +623,7 @@ class ClickMenu { } /** - * Adding CM element for Create new wizard (either db_new.php or BackendUtility::getModuleUrl('new_content_element') or custom wizard) + * Adding CM element for Create new wizard (either BackendUtility::getModuleUrl('db_new') or BackendUtility::getModuleUrl('new_content_element') or custom wizard) * * @param string $table Table name * @param int $uid UID for the current record. @@ -637,7 +637,7 @@ class ClickMenu { $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension']; $newContentWizScriptPath = ExtensionManagementUtility::isLoaded($tmpTSc) ? ExtensionManagementUtility::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php?' : BackendUtility::getModuleUrl('new_content_element') . '&'; - $url = $table === 'pages' ? 'db_new.php?id=' . $uid . '&pagesOnly=1' : $newContentWizScriptPath . 'id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid']; + $url = $table === 'pages' ? BackendUtility::getModuleUrl('db_new', ['id' => $uid, 'pagesOnly' => 1]) : $newContentWizScriptPath . 'id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid']; return $this->linkItem($this->languageService->makeEntities($this->languageService->getLL('CM_newWizard')), IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new'), $this->urlRefForCM($url, 'returnUrl'), 0); } @@ -706,9 +706,14 @@ class ClickMenu { * @internal */ public function DB_new($table, $uid) { - $loc = 'top.content.list_frame'; - $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . ($this->listFrame ? 'alt_doc.php?returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'&edit[' . $table . '][-' . $uid . ']=new\'' : 'db_new.php?id=' . (int)$uid . '\'') . ';}'; - return $this->linkItem($this->label('new'), IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new'), $editOnClick . ';'); + $frame = 'top.content.list_frame'; + $location = $this->frameLocation($frame . '.document'); + $module = $this->listFrame + ? GeneralUtility::quoteJSvalue('alt_doc.php?edit[' . $table . '][-' . $uid . ']=new&returnUrl=') . '+top.rawurlencode(' . $location . '.pathname+' . $location . '.search)' + : GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => (int)$uid])); + $editOnClick = 'if(' . $frame . '){' . $frame . '.location.href=top.TS.PATH_typo3+' . $module . ';}'; + $icon = IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new'); + return $this->linkItem($this->label('new'), $icon, $editOnClick); } /** diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php index a397ff6e86cde9c96a1652c3a45b100c270748ec..38675e14ff3e61020bc0f797dcd322b8fa615c77 100644 --- a/typo3/sysext/backend/Classes/Controller/BackendController.php +++ b/typo3/sysext/backend/Classes/Controller/BackendController.php @@ -305,6 +305,7 @@ class BackendController { $this->pageRenderer->addJsFile($relativeComponentPath . 'javascript/' . $jsFile); } $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history')); + $this->pageRenderer->addInlineSetting('NewRecord', 'moduleUrl', BackendUtility::getModuleUrl('db_new')); } } diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php index 9c1198c6f77419e1a06d8f2aa6075c44ce75c19b..662af3a899d3dba9892ff4f00d16180a9820ed5e 100644 --- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php +++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php @@ -323,7 +323,7 @@ class NewRecordController { $this->code .= $positionMap->positionTree($this->id, $this->pageinfo, $this->perms_clause, $this->R_URI); } else { // No pages yet, no need to prompt for position, redirect to page creation. - $javascript = BackendUtility::editOnClick('returnUrl=%2Ftypo3%2Fdb_new.php%3Fid%3D0%26pagesOnly%3D1&edit[pages][0]=new&returnNewPageId=1'); + $javascript = BackendUtility::editOnClick('&edit[pages][0]=new&returnNewPageId=1', '', BackendUtility::getModuleUrl('db_new', array('id' => $this->id, 'pagesOnly' => '1'))); $startPos = strpos($javascript, 'href=\'') + 6; $endPos = strpos($javascript, '\';'); $url = substr($javascript, $startPos, $endPos - $startPos); diff --git a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php index 210254b84c434366fd4b46965fb3848ab44529b8..41e5bca4af0e87e9e57ebe548c4667bf51cc6ee0 100644 --- a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php +++ b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php @@ -227,7 +227,7 @@ class PageTreeNavigationController { 'refresh' => '' ); // New Page - $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&id=\'+Tree.pageID;'; + $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['pagesOnly' => 1, 'id' => ''])) . '+Tree.pageID;'; $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:newPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-page-new') . '</a>'; // Refresh $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>'; diff --git a/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php b/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php index adb0ccf70783a322e5374db7f93d34be417e7725..d1a8e7a7701f89e77d2319afff3eb95b03f0a488 100644 --- a/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Tree\View; /** * Extension for the tree class that generates the tree of pages in the page-wizard mode - * see typo3/db_new.php + * see typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php */ class NewRecordPageTreeView extends PageTreeView { diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index 2ca8da7afe647c5d41a7333c74786ff6c4c1b8b9..8fbc43a95f14627de55140d5d4472beb57e7c42b 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -873,9 +873,13 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe ); } if ($this->ext_CALC_PERMS & 8) { + $parameters = [ + 'id' => $id, + 'pagesOnly' => 1, + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') + ]; $bArray[2] = $this->getPageLayoutController()->doc->t3Button( - 'window.location.href=\'' . $this->backPath . 'db_new.php?id=' . $id - . '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';', + 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', $parameters, $this->backPath)) . ';', $this->getLanguageService()->getLL('newPage2') ); } diff --git a/typo3/sysext/backend/Modules/NewRecord/conf.php b/typo3/sysext/backend/Modules/NewRecord/conf.php new file mode 100644 index 0000000000000000000000000000000000000000..17b22fd506ed593defc00bd1c3d4fee99e96bfe8 --- /dev/null +++ b/typo3/sysext/backend/Modules/NewRecord/conf.php @@ -0,0 +1,3 @@ +<?php +$MCONF['script'] = '_DISPATCH'; +$MCONF['name'] = 'db_new'; \ No newline at end of file diff --git a/typo3/sysext/backend/Modules/NewRecord/index.php b/typo3/sysext/backend/Modules/NewRecord/index.php new file mode 100644 index 0000000000000000000000000000000000000000..da71f00f7dcde63b922c6c48897b81c8a812f032 --- /dev/null +++ b/typo3/sysext/backend/Modules/NewRecord/index.php @@ -0,0 +1,26 @@ +<?php +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +/** + * New database item menu + * + * This script lets users choose a new database element to create. + * Includes a wizard mode for visually pointing out the position of new pages + * + * @author Kasper Skårhøj <kasperYYYY@typo3.com> + */ + +$newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class); +$newRecordController->main(); +$newRecordController->printContent(); \ No newline at end of file diff --git a/typo3/sysext/backend/ext_tables.php b/typo3/sysext/backend/ext_tables.php index cb5cf2a9fd489a9317d5cf7104b06cd8d3571441..679aed8220b5426c2ac8f4e98de3e8deff4eb04f 100644 --- a/typo3/sysext/backend/ext_tables.php +++ b/typo3/sysext/backend/ext_tables.php @@ -116,6 +116,12 @@ if (TYPO3_MODE === 'BE') { ) ); + // Register new record + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath( + 'db_new', + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/NewRecord/' + ); + // Register new content element module \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath( 'new_content_element', diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst new file mode 100644 index 0000000000000000000000000000000000000000..01e804eb7147d13282162439e0e40853b294c101 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst @@ -0,0 +1,25 @@ +======================================================== +Deprecation: #65288 - Deprecate "new record" entry point +======================================================== + +Description +=========== + +The following entry point has been marked as deprecated: + +* typo3/db_new.php + + +Impact +====== + +Using this entry points in a backend module will throw a deprecation message. + + +Migration +========= + +Use ``\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()`` instead with the according module name. + +typo3/db_new.php +``\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('db_new')`` diff --git a/typo3/sysext/feedit/Classes/FrontendEditPanel.php b/typo3/sysext/feedit/Classes/FrontendEditPanel.php index 40cf7dfd91d782223f9bbef3364b6a73043183e8..0930e54838ac35bc0a985587c873f51586cc30d7 100644 --- a/typo3/sysext/feedit/Classes/FrontendEditPanel.php +++ b/typo3/sysext/feedit/Classes/FrontendEditPanel.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Feedit; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\IconUtility; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Core\Database\DatabaseConnection; @@ -243,7 +244,7 @@ class FrontendEditPanel { } elseif ($cmd == 'new') { $rParts = explode(':', $currentRecord); if ($rParts[0] == 'pages') { - $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'db_new.php?id=' . $rParts[1] . '&pagesOnly=1', $currentRecord); + $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . BackendUtility::getModuleUrl('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord); } else { if (!(int)$nPid) { $nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id; @@ -264,7 +265,7 @@ class FrontendEditPanel { } /** - * Creates a link to a script (eg. typo3/alt_doc.php or typo3/db_new.php) which either opens in the current frame OR in a pop-up window. + * Creates a link to a script (eg. typo3/alt_doc.php or NewRecordController) which either opens in the current frame OR in a pop-up window. * * @param string $string The string to wrap in a link, typ. and image used as button in the edit panel. * @param string $url The URL of the link. Should be absolute if supposed to work with <base> path set. diff --git a/typo3/sysext/frontend/Classes/View/AdminPanelView.php b/typo3/sysext/frontend/Classes/View/AdminPanelView.php index 652f9be454c37541903f589c39a8944c21b2442e..3230d77f3ec8c5e0eff45a0f085bed99c684473a 100644 --- a/typo3/sysext/frontend/Classes/View/AdminPanelView.php +++ b/typo3/sysext/frontend/Classes/View/AdminPanelView.php @@ -600,30 +600,30 @@ class AdminPanelView { $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page); $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid); $id = $GLOBALS['TSFE']->id; - $returnUrl = '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')); + $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI'); $icon = IconUtility::getSpriteIcon('actions-document-history-open', array('title' => $this->extGetLL('edit_recordHistory', FALSE))); - $toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id)) . $returnUrl) . '#latest">' . $icon . '</a>'; + $toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id, 'returnUrl' => $returnUrl))) . '#latest">' . $icon . '</a>'; if ($perms & 16 && $langAllowed) { $params = ''; if ($GLOBALS['TSFE']->sys_language_uid) { $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid; } $icon = IconUtility::getSpriteIcon('actions-document-new', array('title' => $this->extGetLL('edit_newContentElement', FALSE))); - $toolBar .= '<a href="' . htmlspecialchars(($newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>'; + $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>'; } if ($perms & 2) { $icon = IconUtility::getSpriteIcon('actions-document-move', array('title' => $this->extGetLL('edit_move_page', FALSE))); - $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . BackendUtility::getModuleUrl('move_element') . '&table=pages&uid=' . $id . '&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>'; + $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>'; } if ($perms & 8) { $icon = IconUtility::getSpriteIcon('actions-page-new', array('title' => $this->extGetLL('edit_newPage', FALSE))); - $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>'; + $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('db_new', ['id' => $id, 'pagesOnly' => 1, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>'; } if ($perms & 2) { $params = '&edit[pages][' . $id . ']=edit'; $icon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $this->extGetLL('edit_editPageProperties', FALSE))); - $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>'; + $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>'; if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) { $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow( 'uid,pid,t3ver_state', @@ -636,7 +636,7 @@ class AdminPanelView { if (is_array($row)) { $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit'; $icon = IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay', array('title' => $this->extGetLL('edit_editPageOverlay', FALSE))); - $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>'; + $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>'; } } } diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php index 05967b16dbdd0fbfbd3bbdb37becc1f747283580..2a7c48596061b8cfa9104df1bf18bdea8e6c3c6d 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php @@ -241,7 +241,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList { } // New record if (!$module->modTSconfig['properties']['noCreateRecordsLink']) { - $onClick = htmlspecialchars(('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');')); + $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id], $this->backPath)) . ');'); $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="' . $lang->getLL('newRecordGeneral', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-new') . '</a>'; @@ -954,8 +954,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList { $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>'; } elseif ($table == 'pages' && $this->newWizards) { - $href = $this->backPath . 'db_new.php?id=' . $this->id - . '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')); + $parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; + $href = BackendUtility::getModuleUrl('db_new', $parameters, $this->backPath); $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>'; } else {