diff --git a/Classes/Backend/LayoutSetup.php b/Classes/Backend/LayoutSetup.php index 4fda3e8..cf76db9 100644 --- a/Classes/Backend/LayoutSetup.php +++ b/Classes/Backend/LayoutSetup.php @@ -112,7 +112,13 @@ public function init($pageId, array $typoScriptSetup = []) protected function loadLayoutSetup($pageId) { // Load page TSconfig. - $pageTSconfig = BackendUtility::getPagesTSconfig($pageId); + + if (TYPO3_MODE === 'FE') { + $pageTSconfig = $GLOBALS['TSFE']->getPagesTSconfig(); + } + if (TYPO3_MODE === 'BE') { + $pageTSconfig = BackendUtility::getPagesTSconfig($pageId); + } $excludeLayoutIds = !empty($pageTSconfig['tx_gridelements.']['excludeLayoutIds']) ? array_flip(GeneralUtility::trimExplode(',', $pageTSconfig['tx_gridelements.']['excludeLayoutIds'])) diff --git a/Classes/ContextMenu/ItemProvider.php b/Classes/ContextMenu/ItemProvider.php index 56779dd..c05c35c 100644 --- a/Classes/ContextMenu/ItemProvider.php +++ b/Classes/ContextMenu/ItemProvider.php @@ -16,7 +16,7 @@ */ use TYPO3\CMS\Backend\ContextMenu\ItemProviders\RecordProvider; -use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Backend\Routing\UriBuilder; class ItemProvider extends RecordProvider { @@ -68,9 +68,11 @@ protected function getAdditionalAttributes(string $itemName): array } $attributes = $this->getPasteAdditionalAttributes('after'); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + $attributes += [ 'data-callback-module' => 'TYPO3/CMS/Gridelements/ClickMenuActions', - 'data-action-url' => htmlspecialchars(BackendUtility::getModuleUrl('tce_db', $urlParameters)), + 'data-action-url' => htmlspecialchars($uriBuilder->buildUriFromRoute('tce_db', $urlParameters)), ]; return $attributes; } diff --git a/Classes/Hooks/DrawItem.php b/Classes/Hooks/DrawItem.php index 23583cf..55cbf0e 100644 --- a/Classes/Hooks/DrawItem.php +++ b/Classes/Hooks/DrawItem.php @@ -23,6 +23,7 @@ use GridElementsTeam\Gridelements\Backend\LayoutSetup; use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Backend\Controller\PageLayoutController; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutViewDrawFooterHookInterface; @@ -460,6 +461,7 @@ protected function renderSingleGridColumn( ) { $specificIds = $this->helper->getSpecificIds($row); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $allowed = base64_encode(json_encode($values['allowed'])); $disallowed = base64_encode(json_encode($values['disallowed'])); $maxItems = (int)$values['maxitems']; @@ -487,7 +489,7 @@ protected function renderSingleGridColumn( 'uid_pid' => $parentObject->id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; - $url = BackendUtility::getModuleUrl('new_content_element', $urlParameters); + $url = $uriBuilder->buildUriFromRoute('new_content_element', $urlParameters); } else { $urlParameters = [ 'edit' => [ @@ -507,7 +509,7 @@ protected function renderSingleGridColumn( ], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; - $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); + $url = $uriBuilder->buildUriFromRoute('record_edit', $urlParameters); } } } @@ -587,7 +589,7 @@ class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $row['sys_languag 'uid_pid' => -$specificIds['uid'], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; - $url = BackendUtility::getModuleUrl('new_content_element', $urlParameters); + $url = $uriBuilder->buildUriFromRoute('new_content_element', $urlParameters); } else { $urlParameters = [ 'edit' => [ @@ -607,7 +609,7 @@ class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $row['sys_languag ], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; - $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); + $url = $uriBuilder->buildUriFromRoute('record_edit', $urlParameters); } $iconsArray = [ 'new' => ' + * All rights reserved + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +use TYPO3\CMS\Backend\View\PageLayoutView; + +/** + * Class/Function which manipulates the rendering of item example content and replaces it with a grid of child elements. + * + * @author Jo Hasenau + * @package TYPO3 + * @subpackage tx_gridelements + */ +class PageLayoutViewHook +{ + public function contentIsUsed(array $params, PageLayoutView $parentObject): bool + { + if ($params['used']) { + return true; + } + $record = $params['record']; + return $record['colPos'] === -1 && !empty($record['tx_gridelements_container']); + } +} diff --git a/Classes/Hooks/PageRenderer.php b/Classes/Hooks/PageRenderer.php index 2c43e40..fb27f6b 100644 --- a/Classes/Hooks/PageRenderer.php +++ b/Classes/Hooks/PageRenderer.php @@ -23,6 +23,7 @@ use GridElementsTeam\Gridelements\Backend\LayoutSetup; use TYPO3\CMS\Backend\Clipboard\Clipboard; use TYPO3\CMS\Backend\Controller\PageLayoutController; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendLayoutView; use TYPO3\CMS\Core\Imaging\Icon; @@ -98,6 +99,8 @@ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $p } } + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + // add Ext.onReady() code from file $pAddExtOnReadyCode .= " top.pageColumnsAllowed = " . json_encode($layout['allowed']) . "; @@ -107,7 +110,7 @@ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $p $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode']) ? 'true' : 'false') . "; top.skipDraggableDetails = " . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . "; top.backPath = '" . $GLOBALS['BACK_PATH'] . "'; - top.browserUrl = '" . BackendUtility::getModuleUrl('wizard_element_browser') . "';"; + top.browserUrl = '" . $uriBuilder->buildUriFromRoute('wizard_element_browser') . "';"; if (!empty($clipBoard) && !empty($clipBoard['el'])) { $clipBoardElement = GeneralUtility::trimExplode('|', key($clipBoard['el'])); diff --git a/Classes/Xclass/DatabaseRecordList.php b/Classes/Xclass/DatabaseRecordList.php index 111b53c..3bdb59d 100644 --- a/Classes/Xclass/DatabaseRecordList.php +++ b/Classes/Xclass/DatabaseRecordList.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendLayoutView; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; @@ -303,7 +304,7 @@ public function getButtons() } // New record on pages that are not locked by editlock if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) { - $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', + $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue($uriBuilder->buildUriFromRoute('db_new', ['id' => $this->id])) . ');'); $buttons['new_record'] = '' @@ -350,7 +351,7 @@ public function getButtons() . $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . ''; // Export if (ExtensionManagementUtility::isLoaded('impexp')) { - $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']); + $url = $uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']); $buttons['export'] = '' @@ -434,6 +435,7 @@ public function getDocHeaderButtons(ModuleTemplate $moduleTemplate) ->setModuleName('xMOD_csh_corebe') ->setFieldName($fieldName); $buttonBar->addButton($cshButton); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); if (isset($this->id)) { // View Exclude doktypes 254,255 Configuration: // mod.web_list.noViewWithDokTypes = 254,255 @@ -449,7 +451,7 @@ public function getDocHeaderButtons(ModuleTemplate $moduleTemplate) } // New record on pages that are not locked by editlock if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) { - $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', + $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($uriBuilder->buildUriFromRoute('db_new', ['id' => $this->id])) . ');'; $newRecordButton = $buttonBar->makeLinkButton() ->setHref('#') @@ -516,7 +518,7 @@ public function getDocHeaderButtons(ModuleTemplate $moduleTemplate) $buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40); // Export if (ExtensionManagementUtility::isLoaded('impexp')) { - $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']); + $url = $uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']); $exportButton = $buttonBar->makeLinkButton() ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id)) ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export')) @@ -1463,6 +1465,8 @@ public function makeControl($table, $row) ]; // If the listed table is 'pages' we have to request the permission settings for each page: $localCalcPerms = 0; + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + if ($table === 'pages') { $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid'])); @@ -1513,7 +1517,7 @@ public function makeControl($table, $row) $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig'); // "Move" wizard link for pages/tt_content elements: if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) { - $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');'; + $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($uriBuilder->buildUriFromRoute('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');'; $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page'))); $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)); @@ -1523,7 +1527,7 @@ public function makeControl($table, $row) // If the table is NOT a read-only table, then show these links: if ($this->isEditable($table)) { // "Revert" link (history/undo) - $moduleUrl = BackendUtility::getModuleUrl('record_history', ['element' => $table . ':' . $row['uid']]); + $moduleUrl = $uriBuilder->buildUriFromRoute('record_history', ['element' => $table . ':' . $row['uid']]); $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');'; $historyAction = '' @@ -1535,7 +1539,7 @@ public function makeControl($table, $row) $this->getBackendUserAuthentication()->workspace, false, $row); // If table can be versionized. if (is_array($vers)) { - $href = BackendUtility::getModuleUrl('web_txversionM1', [ + $href = $uriBuilder->buildUriFromRoute('web_txversionM1', [ 'table' => $table, 'uid' => $row['uid'], ]); @@ -1548,7 +1552,7 @@ public function makeControl($table, $row) // "Edit Perms" link: if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) { - $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&returnId=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit'; + $href = $uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&returnId=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit'; $permsAction = '' . $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . ''; @@ -2378,6 +2382,8 @@ public function renderListHeader($table, $currentIdList) // Init: $theData = []; $icon = ''; + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + // Traverse the fields: foreach ($this->fieldArray as $fCol) { // Calculate users permissions to edit records in the table: @@ -2509,7 +2515,7 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override']) ? $tmpTSc['properties']['newContentElementWizard.']['override'] : 'new_content_element'; - $newContentWizScriptPath = BackendUtility::getModuleUrl($newContentElementWizard, + $newContentWizScriptPath = $uriBuilder->buildUriFromRoute($newContentElementWizard, ['id' => $this->id]); $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');'; @@ -2521,7 +2527,7 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; - $href = BackendUtility::getModuleUrl('db_new', $parameters); + $href = $uriBuilder->buildUriFromRoute('db_new', $parameters); $icon = '' . $spriteIcon->render() . ''; } else { @@ -2760,8 +2766,9 @@ public function outputCSV($prefix) public function pasteUrl($table, $uid, $setRedirect = true, array $update = null) { $formProtection = FormProtectionFactory::get(); - return ($table === '_FILE' ? BackendUtility::getModuleUrl('tce_file', - []) : BackendUtility::getModuleUrl('tce_db', [])) + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + return ($table === '_FILE' ? $uriBuilder->buildUriFromRoute('tce_file', + []) : $uriBuilder->buildUriFromRoute('tce_db', [])) . ($setRedirect ? '&redirect=' . rawurlencode(GeneralUtility::linkThisScript(['CB' => ''])) : '') . '&vC=' . $this->getBackendUserAuthentication()->veriCode() . '&prErr=1&uPT=1' . '&CB[paste]=' . rawurlencode($table . '|' . $uid) . '&CB[pad]=' . $this->clipObj->current diff --git a/ext_tables.php b/ext_tables.php index 975f280..3d99298 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -16,6 +16,7 @@ // Hooks $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][] = \GridElementsTeam\Gridelements\Hooks\DrawItem::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used'] [] = \GridElementsTeam\Gridelements\Hooks\PageLayoutViewHook::class . '->contentIsUsed'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'][] = \GridElementsTeam\Gridelements\Hooks\WizardItems::class;