Commit 54cfbe59 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Frank Nägler
Browse files

[TASK] Code cleanup EXT:backend/Classes/Controller/ContentElement/*.php

- add missing return values
- declare missing class variables
- remove unused variable assingments
- add getter for LanguageService
- add getter for BackendUser

Resolves: #65497
Releases: master
Change-Id: If6303319811e8c5c0979403c4399f8aa19459eb8
Reviewed-on: http://review.typo3.org/37512

Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarFrank Nägler <typo3@naegler.net>
Tested-by: default avatarFrank Nägler <typo3@naegler.net>
parent 70a7ed3a
......@@ -36,11 +36,16 @@ class ElementHistoryController {
*/
public $doc;
/**
* @var array
*/
protected $pageInfo;
/**
* Constructor
*/
public function __construct() {
$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
$this->getLanguageService()->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
$GLOBALS['SOBE'] = $this;
$this->init();
......@@ -57,7 +62,7 @@ class ElementHistoryController {
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/show_rechis.html');
// Start the page header
$this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
$this->content .= $this->doc->header($this->getLanguageService()->getLL('title'));
}
/**
......@@ -75,8 +80,8 @@ class ElementHistoryController {
$markers['CONTENT'] = $this->content;
$markers['CSH'] = $docHeaderButtons['csh'];
// Build the <body> for the module
$this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
$this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
$this->content = $this->doc->startPage($this->getLanguageService()->getLL('title'));
$this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
}
/**
......@@ -110,4 +115,13 @@ class ElementHistoryController {
return $buttons;
}
/**
* Returns LanguageService
*
* @return \TYPO3\CMS\Lang\LanguageService
*/
protected function getLanguageService() {
return $GLOBALS['LANG'];
}
}
......@@ -77,7 +77,7 @@ class ElementInformationController {
*
* @var array
*/
public $pageinfo;
public $pageInfo;
/**
* Database records identified by table/uid
......@@ -123,7 +123,7 @@ class ElementInformationController {
$this->table = GeneralUtility::_GET('table');
$this->uid = GeneralUtility::_GET('uid');
$this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
$this->permsClause = $this->getBackendUser()->getPagePermsClause(1);
$this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
$this->doc->divClass = 'container';
......@@ -142,16 +142,16 @@ class ElementInformationController {
$this->uid = (int)$this->uid;
// Check permissions and uid value:
if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
if ($this->uid && $this->getBackendUser()->check('tables_select', $this->table)) {
if ((string)$this->table == 'pages') {
$this->pageinfo = BackendUtility::readPageAccess($this->uid, $this->perms_clause);
$this->access = is_array($this->pageinfo) ? 1 : 0;
$this->row = $this->pageinfo;
$this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause);
$this->access = is_array($this->pageInfo) ? 1 : 0;
$this->row = $this->pageInfo;
} else {
$this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
if ($this->row) {
$this->pageinfo = BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
$this->access = is_array($this->pageinfo) ? 1 : 0;
$this->pageInfo = BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
$this->access = is_array($this->pageInfo) ? 1 : 0;
}
}
/** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
......@@ -224,14 +224,14 @@ class ElementInformationController {
*/
protected function renderPageTitle() {
if ($this->type === 'folder') {
$table = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder');
$table = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:folder');
$title = $this->doc->getResourceHeader($this->folderObject, array(' ', ''), FALSE);
} elseif ($this->type === 'file') {
$table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
$table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
$title = $this->doc->getResourceHeader($this->fileObject, array(' ', ''), FALSE);
} else {
$table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
$title = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1, array(' ', ''), FALSE);
$table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
$title = $this->doc->getHeader($this->table, $this->row, $this->pageInfo['_thePath'], 1, array(' ', ''), FALSE);
}
// Set HTML title tag
$this->titleTag = $table . ': ' . strip_tags(BackendUtility::getRecordTitle($this->table, $this->row));
......@@ -249,7 +249,7 @@ class ElementInformationController {
protected function renderPreview() {
// Perhaps @todo in future: Also display preview for records - without fileObject
if (!$this->fileObject) {
return;
return '';
}
$previewTag = '';
......@@ -303,7 +303,7 @@ class ElementInformationController {
$downloadLink .= '
<a class="btn btn-primary" href="' . htmlspecialchars($url) . '" target="_blank">
' . IconUtility::getSpriteIcon('actions-edit-download') . '
' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) . '
' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) . '
</a>';
}
}
......@@ -321,17 +321,18 @@ class ElementInformationController {
$tableRows = array();
$extraFields = array();
$lang = $this->getLanguageService();
if (in_array($this->type, array('folder', 'file'), TRUE)) {
if ($this->type === 'file') {
$extraFields['creation_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
$extraFields['modification_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
$extraFields['creation_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
$extraFields['modification_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
}
$extraFields['storage'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
$extraFields['folder'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
$extraFields['storage'] = $lang->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
$extraFields['folder'] = $lang->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
} else {
$extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
$extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
$extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
$extraFields['crdate'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
$extraFields['cruser_id'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
$extraFields['tstamp'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
// check if the special fields are defined in the TCA ctrl section of the table
foreach ($extraFields as $fieldName => $fieldLabel) {
......@@ -359,7 +360,7 @@ class ElementInformationController {
}
// show the backend username who created the issue
if ($name === 'cruser_id' && $rowValue) {
$userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
$userTemp = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
if ($userTemp[0]['username'] !== '') {
$rowValue = $userTemp[0]['username'];
if ($userTemp[0]['realName'] !== '') {
......@@ -389,13 +390,13 @@ class ElementInformationController {
continue;
}
$isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
$isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
if ($isExcluded) {
continue;
}
$itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
$itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
$itemLabel = $lang->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
$tableRows[] = '
<tr>
<th>' . $itemLabel . '</th>
......@@ -423,12 +424,12 @@ class ElementInformationController {
case 'db': {
$references = $this->makeRef($this->table, $this->row['uid']);
if (!empty($references)) {
$content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references);
$content .= $this->doc->section($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references);
}
$referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']);
if (!empty($referencesFrom)) {
$content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
$content .= $this->doc->section($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
}
break;
}
......@@ -438,7 +439,7 @@ class ElementInformationController {
$references = $this->makeRef('_FILE', $this->fileObject);
if (!empty($references)) {
$header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
$header = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
$content .= $this->doc->section($header, $references);
}
}
......@@ -461,7 +462,7 @@ class ElementInformationController {
$backLink .= '
<a class="btn btn-primary" href="' . htmlspecialchars($returnUrl) . '>
' . IconUtility::getSpriteIcon('actions-view-go-back') . '
' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:back', TRUE) . '
' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:back', TRUE) . '
</a>';
}
return $backLink;
......@@ -479,13 +480,13 @@ class ElementInformationController {
if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
continue;
}
$isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
$isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
if ($isExcluded) {
continue;
}
$uid = $this->row['uid'];
$itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
$itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
$itemLabel = $this->getLanguageService()->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
$tableRows[] = '
<tr>
<th>' . $itemLabel . '</th>
......@@ -512,8 +513,8 @@ class ElementInformationController {
*/
public function printContent() {
echo $this->doc->startPage($this->titleTag) .
$this->doc->insertStylesAndJS($this->content) .
$this->doc->endPage();
$this->doc->insertStylesAndJS($this->content) .
$this->doc->endPage();
}
/**
......@@ -525,7 +526,7 @@ class ElementInformationController {
*/
public function getLabelForTableColumn($tableName, $fieldName) {
if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
$field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
$field = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
if (trim($field) === '') {
$field = $fieldName;
}
......@@ -574,14 +575,14 @@ class ElementInformationController {
// Recordlist button
$url = BackendUtility::getModuleUrl('web_list', array('id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
$pageActionIcons .= '
<a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
<a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
' . IconUtility::getSpriteIcon('actions-system-list-open') . '
</a>';
// View page button
$viewOnClick = BackendUtility::viewOnClick($uid, '', BackendUtility::BEgetRootLine($uid));
$pageActionIcons .= '
<a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">
<a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">
' . IconUtility::getSpriteIcon('actions-document-view') . '
</a>';
}
......@@ -600,6 +601,7 @@ class ElementInformationController {
* @return string HTML
*/
protected function makeRef($table, $ref) {
$lang = $this->getLanguageService();
// Files reside in sys_file table
if ($table === '_FILE') {
$selectTable = 'sys_file';
......@@ -608,10 +610,10 @@ class ElementInformationController {
$selectTable = $table;
$selectUid = $ref;
}
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
'*',
'sys_refindex',
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
'ref_table=' . $this->getDatabaseConnection()->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
);
// Compile information for title tag:
......@@ -621,13 +623,13 @@ class ElementInformationController {
$infoDataHeader = '
<tr>
<th class="col-icon"></th>
<th class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
<th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
<th class="col-control"></th>
</tr>';
}
......@@ -659,9 +661,9 @@ class ElementInformationController {
' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '
</a>
</td>
<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
<td>' . $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
<td>
<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
<span title="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
. htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">
' . $record['uid'] . '
</span>
......@@ -676,8 +678,8 @@ class ElementInformationController {
$infoData[] = '
<tr>
<td class="col-icon"></td>
<td class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . $row['recuid'] . ')</td>
<td>' . htmlspecialchars($GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
<td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . $row['recuid'] . ')</td>
<td>' . htmlspecialchars($lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
<td></td>
<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
<td>' . htmlspecialchars($row['flexpointer']) . '</td>
......@@ -708,32 +710,33 @@ class ElementInformationController {
* @return string HTML
*/
protected function makeRefFrom($table, $ref) {
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
$lang = $this->getLanguageService();
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
'*',
'sys_refindex',
'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
);
// Compile information for title tag:
$infoData = array();
$infoDataHeader = '';
if (count($rows)) {
$infoDataHeader = '
<tr>
<th class="col-icon"></th>
<th class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
<th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th>
<th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
<th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th>
<th class="col-control"></th>
</tr>';
}
foreach ($rows as $row) {
$record = BackendUtility::getRecord($row['ref_table'], $row['ref_uid']);
$parentRecord = BackendUtility::getRecord('pages', $record['pid']);
$icon = IconUtility::getSpriteIconForRecord($row['tablename'], $record);
$actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
$editOnClick = BackendUtility::editOnClick('&edit[' . $row['ref_table'] . '][' . $row['ref_uid'] . ']=edit');
......@@ -749,7 +752,7 @@ class ElementInformationController {
' . BackendUtility::getRecordTitle($row['ref_table'], $record, TRUE) . '
</a>
</td>
<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>
<td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>
<td>' . htmlspecialchars($row['ref_uid']) . '</td>
<td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td>
<td>' . htmlspecialchars($row['flexpointer']) . '</td>
......@@ -761,7 +764,7 @@ class ElementInformationController {
}
if (empty($infoData)) {
return;
return '';
}
return '
......@@ -780,7 +783,7 @@ class ElementInformationController {
* @return array
*/
protected function transformFileReferenceToRecordReference(array $referenceRecord) {
$fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
$fileReference = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'*',
'sys_file_reference',
'uid=' . (int)$referenceRecord['recuid']
......@@ -795,4 +798,31 @@ class ElementInformationController {
);
}
/**
* Returns LanguageService
*
* @return \TYPO3\CMS\Lang\LanguageService
*/
protected function getLanguageService() {
return $GLOBALS['LANG'];
}
/**
* Returns the current BE user.
*
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
*/
protected function getBackendUser() {
return $GLOBALS['BE_USER'];
}
/**
* Returns the database connection
*
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected function getDatabaseConnection() {
return $GLOBALS['TYPO3_DB'];
}
}
......@@ -85,7 +85,7 @@ class MoveElementController {
* Constructor
*/
public function __construct() {
$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
$this->getLanguageService()->includeLLFile('EXT:lang/locallang_misc.xlf');
$GLOBALS['SOBE'] = $this;
$this->init();
}
......@@ -105,7 +105,7 @@ class MoveElementController {
$this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
$this->makeCopy = GeneralUtility::_GP('makeCopy');
// Select-pages where clause for read-access:
$this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
// Starting the document template object:
$this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
$this->doc->backPath = $GLOBALS['BACK_PATH'];
......@@ -113,7 +113,7 @@ class MoveElementController {
$this->doc->JScode = '';
// Starting document content (header):
$this->content = '';
$this->content .= $this->doc->header($GLOBALS['LANG']->getLL('movingElement'));
$this->content .= $this->doc->header($this->getLanguageService()->getLL('movingElement'));
}
/**
......@@ -122,43 +122,45 @@ class MoveElementController {
* @return void
*/
public function main() {
$lang = $this->getLanguageService();
if ($this->page_id) {
$backendUser = $this->getBackendUser();
// Get record for element:
$elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid);
// Headerline: Icon, record title:
$hline = IconUtility::getSpriteIconForRecord($this->table, $elRow, array('id' => 'c-recIcon', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($elRow, $this->table))));
$hline .= BackendUtility::getRecordTitle($this->table, $elRow, TRUE);
$headerLine = IconUtility::getSpriteIconForRecord($this->table, $elRow, array('id' => 'c-recIcon', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($elRow, $this->table))));
$headerLine .= BackendUtility::getRecordTitle($this->table, $elRow, TRUE);
// Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
$hline .= $this->doc->spacer(5);
$headerLine .= $this->doc->spacer(5);
$onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript(array('makeCopy' => !$this->makeCopy))) . ';';
$hline .= $this->doc->spacer(5);
$hline .= '<input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $GLOBALS['LANG']->getLL('makeCopy', 1) . '</label>';
$headerLine .= $this->doc->spacer(5);
$headerLine .= '<input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $lang->getLL('makeCopy', 1) . '</label>';
// Add the header-content to the module content:
$this->content .= $this->doc->section('', $hline, FALSE, TRUE);
$this->content .= $this->doc->section('', $headerLine, FALSE, TRUE);
$this->content .= $this->doc->spacer(20);
// Reset variable to pick up the module content in:
$code = '';
// IF the table is "pages":
if ((string)$this->table == 'pages') {
// Get page record (if accessible):
$pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
$pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
// Initialize the position map:
$posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\PageMovingPagePositionMap::class);
$posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
// Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
if ($pageinfo['pid']) {
$pidPageInfo = BackendUtility::readPageAccess($pageinfo['pid'], $this->perms_clause);
if ($pageInfo['pid']) {
$pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause);
if (is_array($pidPageInfo)) {
if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
$code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$pageinfo['pid'], 'moveUid' => $this->moveUid))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
$code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$pageInfo['pid'], 'moveUid' => $this->moveUid))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
} else {
$code .= IconUtility::getSpriteIconForRecord('pages', $pidPageInfo) . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
}
}
}
// Create the position tree:
$code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
$code .= $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI);
}
}
// IF the table is "tt_content":
......@@ -170,18 +172,18 @@ class MoveElementController {
$this->page_id = $tt_content_rec['pid'];
}
// Checking if the parent page is readable:
$pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
$pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
// Initialize the position map:
$posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ContentMovingPagePositionMap::class);
$posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
$posMap->cur_sys_language = $this->sys_language;
// Headerline for the parent page: Icon, record title:
$hline = IconUtility::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($pageinfo, 'pages'))));
$hline .= BackendUtility::getRecordTitle('pages', $pageinfo, TRUE);
$headerLine = IconUtility::getSpriteIconForRecord('pages', $pageInfo, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($pageInfo, 'pages'))));
$headerLine .= BackendUtility::getRecordTitle('pages', $pageInfo, TRUE);
// Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
// SHARED page-TSconfig settings.
$modTSconfig_SHARED = BackendUtility::getModTSconfig($this->page_id, 'mod.SHARED');
// $modTSconfig_SHARED = BackendUtility::getModTSconfig($this->pageId, 'mod.SHARED');
$colPosArray = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $this->page_id, $this);
$colPosIds = array();
foreach ($colPosArray as $colPos) {
......@@ -190,16 +192,16 @@ class MoveElementController {
// Removing duplicates, if any