Commit 5bbc0761 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[TASK] Remove unused functionality of PageLayoutView class

A lot of code within PageLayoutView is not properly applicable
anymore.

The next step in this area is to:
- Extract Logic for PageInformationController into a separate class
- Extract Helper logic for custom content element previews into a separate class

Resolves: #90272
Releases: master
Change-Id: Ied94677c3a957eb81d18f281afab658c55214b48
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63097

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 9a912800
......@@ -56,13 +56,6 @@ class PageLayoutController
*/
public $id;
/**
* Pointer - for browsing list of records.
*
* @var int
*/
protected $pointer;
/**
* Thumbnails or not
*
......@@ -127,20 +120,6 @@ class PageLayoutController
*/
protected $colPosList;
/**
* Flag: If content can be edited or not.
*
* @var bool
*/
protected $EDIT_CONTENT;
/**
* Users permissions integer for this page.
*
* @var int
*/
protected $CALC_PERMS;
/**
* Currently selected language for editing content elements
*
......@@ -263,7 +242,6 @@ class PageLayoutController
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$this->id = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
$this->pointer = $parsedBody['pointer'] ?? $queryParams['pointer'] ?? null;
$this->imagemode = $parsedBody['imagemode'] ?? $queryParams['imagemode'] ?? null;
$this->popView = $parsedBody['popView'] ?? $queryParams['popView'] ?? null;
$returnUrl = $parsedBody['returnUrl'] ?? $queryParams['returnUrl'] ?? null;
......@@ -626,10 +604,6 @@ class PageLayoutController
// Content
$content = '';
if ($this->id && $access) {
// Initialize permission settings:
$this->CALC_PERMS = $this->getBackendUser()->calcPerms($this->pageinfo);
$this->EDIT_CONTENT = $this->isContentEditable($this->current_sys_language);
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
......@@ -674,13 +648,11 @@ class PageLayoutController
$content .= $this->getHeaderFlashMessagesForCurrentPid();
// Render the primary module content:
if ($this->MOD_SETTINGS['function'] == 1 || $this->MOD_SETTINGS['function'] == 2) {
$content .= '<form action="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->id, 'imagemode' => $this->imagemode])) . '" id="PageLayoutController" method="post">';
// Page title
$content .= '<h1 class="' . ($this->isPageEditable($this->current_sys_language) ? 't3js-title-inlineedit' : '') . '">' . htmlspecialchars($this->getLocalizedPageTitle()) . '</h1>';
// All other listings
$content .= $this->renderContent();
}
$content .= '<form action="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->id, 'imagemode' => $this->imagemode])) . '" id="PageLayoutController" method="post">';
// Page title
$content .= '<h1 class="' . ($this->isPageEditable($this->current_sys_language) ? 't3js-title-inlineedit' : '') . '">' . htmlspecialchars($this->getLocalizedPageTitle()) . '</h1>';
// All other listings
$content .= $this->renderContent();
$content .= '</form>';
$content .= $this->searchContent;
// Setting up the buttons for the docheader
......@@ -716,92 +688,60 @@ class PageLayoutController
{
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
$dbList = GeneralUtility::makeInstance(PageLayoutView::class);
$dbList->thumbs = $this->imagemode;
$dbList->no_noWrap = 1;
$this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
$dbList->doEdit = $this->EDIT_CONTENT;
$dbList->ext_CALC_PERMS = $this->CALC_PERMS;
$dbList->doEdit = $this->isContentEditable($this->current_sys_language);
$dbList->id = $this->id;
$dbList->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
$dbList->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 1, 10);
$dbList->option_newWizard = empty($this->modTSconfig['properties']['disableNewContentElementWizard']);
$dbList->defLangBinding = !empty($this->modTSconfig['properties']['defLangBinding']);
if (!$dbList->nextThree) {
$dbList->nextThree = 1;
}
// Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
// also fills $dbList->activeTables
$dbList->getTableMenu($this->id);
// Initialize other variables:
$tableOutput = [];
$CMcounter = 0;
$tableOutput = '';
$backendLayoutContainer = GeneralUtility::makeInstance(BackendLayoutView::class);
$tcaItems = $backendLayoutContainer->getColPosListItemsParsed($this->id);
// Traverse the list of table names which has records on this page (that array is populated
// by the $dblist object during the function getTableMenu()):
foreach ($dbList->activeTables as $table => $value) {
$h_func = '';
$pageRenderer = $this->getPageRenderer();
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/Paste');
if ($this->getBackendUser()->check('tables_select', 'tt_content')) {
$h_func_b = '';
if (!isset($dbList->externalTables[$table])) {
// Boolean: Display up/down arrows and edit icons for tt_content records
$dbList->tt_contentConfig['showCommands'] = 1;
// Boolean: Display info-marks or not
$dbList->tt_contentConfig['showInfo'] = 1;
// Setting up the tt_content columns to show:
if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
$colList = [];
foreach ($tcaItems as $temp) {
$colList[] = $temp[1];
}
} else {
// ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
$colList = ['1', '0', '2', '3'];
}
if ($this->colPosList !== '') {
$colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
}
// The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
$dbList->tt_contentConfig['cols'] = implode(',', $colList);
$dbList->tt_contentConfig['activeCols'] = $this->activeColPosList;
$dbList->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
$dbList->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
// If the function menu is set to "Language":
if ($this->MOD_SETTINGS['function'] == 2) {
$dbList->tt_contentConfig['languageMode'] = 1;
$dbList->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
$dbList->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
}
// Toggle hidden ContentElements
$numberOfHiddenElements = $this->getNumberOfHiddenElements($dbList->tt_contentConfig);
if ($numberOfHiddenElements > 0) {
$h_func_b = '
<div class="checkbox">
<label for="checkTt_content_showHidden">
<input type="checkbox" id="checkTt_content_showHidden" class="checkbox" name="SET[tt_content_showHidden]" value="1" ' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? 'checked="checked"' : '') . ' />
' . htmlspecialchars($this->getLanguageService()->getLL('hiddenCE')) . ' (<span class="t3js-hidden-counter">' . $numberOfHiddenElements . '</span>)
</label>
</div>';
// Setting up the tt_content columns to show:
if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
$colList = [];
foreach ($tcaItems as $temp) {
$colList[] = $temp[1];
}
} else {
if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
$h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], '', '');
}
// ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
$colList = ['1', '0', '2', '3'];
}
if ($this->colPosList !== '') {
$colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
}
// The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
$dbList->tt_contentConfig['cols'] = implode(',', $colList);
$dbList->tt_contentConfig['activeCols'] = $this->activeColPosList;
$dbList->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
$dbList->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
// If the function menu is set to "Language":
if ($this->MOD_SETTINGS['function'] == 2) {
$dbList->tt_contentConfig['languageMode'] = 1;
$dbList->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
$dbList->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
}
// Toggle hidden ContentElements
$numberOfHiddenElements = $this->getNumberOfHiddenElements($dbList->tt_contentConfig);
if ($numberOfHiddenElements > 0) {
$h_func_b = '
<div class="checkbox">
<label for="checkTt_content_showHidden">
<input type="checkbox" id="checkTt_content_showHidden" class="checkbox" name="SET[tt_content_showHidden]" value="1" ' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? 'checked="checked"' : '') . ' />
' . htmlspecialchars($this->getLanguageService()->getLL('hiddenCE')) . ' (<span class="t3js-hidden-counter">' . $numberOfHiddenElements . '</span>)
</label>
</div>';
}
// Start the dblist object:
$dbList->itemsLimitSingleTable = 1000;
$dbList->start($this->id, $table, $this->pointer);
$dbList->counter = $CMcounter;
$dbList->ext_function = $this->MOD_SETTINGS['function'];
$dbList->start($this->id);
// Generate the list of elements here:
$dbList->generateList();
// Adding the list content to the tableOutput variable:
$tableOutput[$table] = $h_func . $dbList->HTMLcode . $h_func_b;
// Increase global counter:
$CMcounter += $dbList->counter;
// Reset variables after operation:
$dbList->HTMLcode = '';
$tableOutput = $dbList->getTable_tt_content($this->id) . $h_func_b;
}
// END: traverse tables
// For Context Sensitive Menus:
// Init the content
$content = '';
// Additional header content
......@@ -809,10 +749,7 @@ class PageLayoutController
$params = [];
$content .= GeneralUtility::callUserFunction($hook, $params, $this);
}
// Add the content for each table we have rendered (traversing $tableOutput variable)
foreach ($tableOutput as $table => $output) {
$content .= $output;
}
$content .= $tableOutput;
// Making search form:
if (!$this->modTSconfig['properties']['disableSearchBox']) {
$this->searchContent = $this->getSearchBox();
......
......@@ -65,19 +65,14 @@ class PageInformationController
$languageService = $this->getLanguageService();
$theOutput = '<h1>' . htmlspecialchars($languageService->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>';
$dblist = GeneralUtility::makeInstance(PageLayoutView::class);
$dblist->thumbs = 0;
if (isset($this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']])) {
$dblist->fieldArray = $this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']]['fields'];
}
// PAGES:
$this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
// ONLY for the sake of dblist module which uses this value.
$h_func = BackendUtility::getDropdownMenu($this->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
$h_func .= BackendUtility::getDropdownMenu($this->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
$dblist->start($this->id, 'pages', 0);
$dblist->generateList();
$dblist->start($this->id);
$theOutput .= '<div class="form-inline form-inline-spaced">'
. $h_func
......@@ -85,7 +80,7 @@ class PageInformationController
. BackendUtility::cshItem('_MOD_web_info', 'func_' . $this->pObj->MOD_SETTINGS['pages'], null, '<span class="btn btn-default btn-sm">|</span>')
. '</div>'
. '</div>'
. $dblist->HTMLcode;
. $dblist->getTable_pages($this->id, (int)$this->pObj->MOD_SETTINGS['depth']);
// Additional footer content
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'] ?? [] as $hook) {
......
Supports Markdown
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