Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Hides 'Unused elements detected' Message in Backend Page Module #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Classes/Backend/LayoutSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']))
Expand Down
6 changes: 4 additions & 2 deletions Classes/ContextMenu/ItemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions Classes/Hooks/DrawItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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' => [
Expand All @@ -507,7 +509,7 @@ protected function renderSingleGridColumn(
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
$url = $uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
}
}
Expand Down Expand Up @@ -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' => [
Expand All @@ -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' => '<a
Expand Down
42 changes: 42 additions & 0 deletions Classes/Hooks/PageLayoutViewHook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace GridElementsTeam\Gridelements\Hooks;

/***************************************************************
* Copyright notice
* (c) 2013 Jo Hasenau <[email protected]>
* 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 <[email protected]>
* @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']);
}
}
5 changes: 4 additions & 1 deletion Classes/Hooks/PageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']) . ";
Expand All @@ -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']));
Expand Down
31 changes: 19 additions & 12 deletions Classes/Xclass/DatabaseRecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'] = '<a href="#" onclick="' . $onClick . '" title="'
. htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
Expand Down Expand Up @@ -350,7 +351,7 @@ public function getButtons()
. $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . '</a>';
// 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'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
. rawurlencode($this->table . ':' . $this->id)) . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
Expand Down Expand Up @@ -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
Expand All @@ -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('#')
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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']));
Expand Down Expand Up @@ -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));
Expand All @@ -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 = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
Expand All @@ -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'],
]);
Expand All @@ -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 = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
. $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) . ');';
Expand All @@ -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 = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
. $spriteIcon->render() . '</a>';
} else {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down