Commit 093f6183 authored by Thomas Hohn's avatar Thomas Hohn Committed by Susanne Moog
Browse files

[!!!][TASK] Remove deprecated output-related code from EXT:backend

Removes and adapts some classes, methods and properties
which were marked as deprecated.

Resolves: #80705
Releases: master
Change-Id: I6f594956a4a9fcaf99345e8edc07bb31e76564ae
Reviewed-on: https://review.typo3.org/52511

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarHenrik Elsner <helsner@dfau.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
parent bb9cc741
......@@ -666,27 +666,6 @@ class Clipboard
return GeneralUtility::linkThisScript(['CB' => ['remove' => $table . '|' . $uid]]);
}
/**
* Returns confirm JavaScript message
*
* @param string $table Table name
* @param mixed $rec For records its an array, for files its a string (path)
* @param string $type Type-code
* @param array $clElements Array of selected elements
* @param string $columnLabel Name of the content column
* @return string JavaScript "confirm" message
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function confirmMsg($table, $rec, $type, $clElements, $columnLabel = '')
{
GeneralUtility::logDeprecatedFunction();
$message = $this->confirmMsgText($table, $rec, $type, $clElements, $columnLabel);
if (!empty($message)) {
$message = 'confirm(' . GeneralUtility::quoteJSvalue($message) . ');';
}
return $message;
}
/**
* Returns confirm JavaScript message
*
......
......@@ -173,45 +173,6 @@ class BackendController
$this->initializeToolbarItems();
$this->executeHook('constructPostProcess');
$this->includeLegacyBackendItems();
}
/**
* Add hooks from the additional backend items to load certain things for the main backend.
* This was previously called from the global scope from backend.php.
*
* Please note that this method will be removed in TYPO3 v9. it does not throw a deprecation warning as it is protected and still called on every main backend request.
*/
protected function includeLegacyBackendItems()
{
$TYPO3backend = $this;
// Include extensions which may add css, javascript or toolbar items
if (is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
GeneralUtility::deprecationLog('The hook $TYPO3_CONF_VARS["typo3/backend.php"]["additionalBackendItems"] is deprecated in TYPO3 v8, and will be removed in TYPO3 v9. Use the "constructPostProcess" hook within BackendController instead.');
foreach ($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
include_once $additionalBackendItem;
}
}
// Process ExtJS module js and css
if (is_array($GLOBALS['TBE_MODULES']['_configuration'])) {
foreach ($GLOBALS['TBE_MODULES']['_configuration'] as $moduleName => $moduleConfig) {
if (is_array($moduleConfig['cssFiles'])) {
foreach ($moduleConfig['cssFiles'] as $cssFileName => $cssFile) {
$cssFile = GeneralUtility::getFileAbsFileName($cssFile);
$cssFile = PathUtility::getAbsoluteWebPath($cssFile);
$TYPO3backend->addCssFile($cssFileName, $cssFile);
}
}
if (is_array($moduleConfig['jsFiles'])) {
foreach ($moduleConfig['jsFiles'] as $jsFile) {
$jsFile = GeneralUtility::getFileAbsFileName($jsFile);
$jsFile = PathUtility::getAbsoluteWebPath($jsFile);
$TYPO3backend->addJavascriptFile($jsFile);
}
}
}
}
}
/**
......@@ -824,42 +785,6 @@ class BackendController
}
}
/**
* Adds a javascript snippet to the backend
*
* @param string $javascript Javascript snippet
* @throws \InvalidArgumentException
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9. Use the "constructPostProcess" hook within BackendController instead.
*/
public function addJavascript($javascript)
{
GeneralUtility::logDeprecatedFunction();
// @todo do we need more checks?
if (!is_string($javascript)) {
throw new \InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
}
$this->js .= $javascript;
}
/**
* Adds a javscript file to the backend after it has been checked that it exists
*
* @param string $javascriptFile Javascript file reference
* @return bool TRUE if the javascript file was successfully added, FALSE otherwise
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9. Use the "constructPostProcess" hook within BackendController instead.
*/
public function addJavascriptFile($javascriptFile)
{
GeneralUtility::logDeprecatedFunction();
$jsFileAdded = false;
// @todo add more checks if necessary
if (file_exists(GeneralUtility::resolveBackPath(PATH_typo3 . $javascriptFile))) {
$this->jsFiles[] = $javascriptFile;
$jsFileAdded = true;
}
return $jsFileAdded;
}
/**
* Adds a css snippet to the backend
*
......@@ -874,25 +799,6 @@ class BackendController
$this->css .= $css;
}
/**
* Adds a css file to the backend after it has been checked that it exists
*
* @param string $cssFileName The css file's name with out the .css ending
* @param string $cssFile Css file reference
* @return bool TRUE if the css file was added, FALSE otherwise
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9, use the according PageRenderer methods directly
*/
public function addCssFile($cssFileName, $cssFile)
{
GeneralUtility::logDeprecatedFunction();
$cssFileAdded = false;
if (empty($this->cssFiles[$cssFileName])) {
$this->cssFiles[$cssFileName] = $cssFile;
$cssFileAdded = true;
}
return $cssFileAdded;
}
/**
* Executes defined hooks functions for the given identifier.
*
......
......@@ -207,12 +207,6 @@ class EditDocumentController extends AbstractModule
*/
public $returnEditConf;
/**
* @var string
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public $localizationMode;
/**
* Workspace used for the editing action.
*
......
......@@ -148,35 +148,6 @@ class LocalizationController
return $response;
}
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function getRecordUidsToCopy(ServerRequestInterface $request, ResponseInterface $response)
{
GeneralUtility::logDeprecatedFunction();
$params = $request->getQueryParams();
if (!isset($params['pageId'], $params['colPos'], $params['languageId'])) {
$response = $response->withStatus(500);
return $response;
}
$pageId = (int)$params['pageId'];
$colPos = (int)$params['colPos'];
$languageId = (int)$params['languageId'];
$result = $this->localizationRepository->getRecordsToCopyDatabaseResult($pageId, $colPos, $languageId, 'uid');
$uids = [];
while ($row = $result->fetch()) {
$uids[] = (int)$row['uid'];
}
$response->getBody()->write(json_encode($uids));
return $response;
}
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
......
......@@ -108,24 +108,6 @@ class PageLayoutController
*/
public $popView;
/**
* QuickEdit: Variable, that tells quick edit what to show/edit etc.
* Format is [tablename]:[uid] with some exceptional values for both parameters (with special meanings).
*
* @var string
* @deprecated since TYPO3 CMS 8, will be removed in TYPO3 CMS 9.
*/
public $edit_record;
/**
* QuickEdit: If set, this variable tells quick edit that the last edited record had
* this value as UID and we should look up the new, real uid value in sys_log.
*
* @var string
* @deprecated since TYPO3 CMS 8, will be removed in TYPO3 CMS 9.
*/
public $new_unique_uid;
/**
* Page select perms clause
*
......@@ -211,14 +193,6 @@ class PageLayoutController
*/
public $MOD_SETTINGS = [];
/**
* Array of tables to be listed by the Web > Page module in addition to the default tables
*
* @var array
* @deprecated since TYPO3 CMS 8, will be removed in TYPO3 CMS 9.
*/
public $externalTables = [];
/**
* Module output accumulation
*
......@@ -294,13 +268,10 @@ class PageLayoutController
$this->imagemode = GeneralUtility::_GP('imagemode');
$this->clear_cache = GeneralUtility::_GP('clear_cache');
$this->popView = GeneralUtility::_GP('popView');
$this->edit_record = GeneralUtility::_GP('edit_record');
$this->new_unique_uid = GeneralUtility::_GP('new_unique_uid');
$this->search_field = GeneralUtility::_GP('search_field');
$this->search_levels = GeneralUtility::_GP('search_levels');
$this->showLimit = GeneralUtility::_GP('showLimit');
$this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
$this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
$sessionData['search_field'] = $this->search_field;
// Store session data
$this->getBackendUser()->setAndSaveSessionData(RecordList::class, $sessionData);
......@@ -334,31 +305,7 @@ class PageLayoutController
// initialize page/be_user TSconfig settings
$this->modSharedTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.SHARED');
$this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->moduleName);
// example settings:
// $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
// array ('default' => array(
// 'MENU' => 'LLL:EXT:tx_myext/locallang_db.xlf:menuDefault',
// 'fList' => 'title,description,image',
// 'icon' => TRUE));
if (is_array($this->externalTables)) {
if (!empty($this->externalTables)) {
GeneralUtility::deprecationLog('The rendering of records in the page module by using '
. '$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'cms\'][\'db_layout\'][\'addTables\']'
. ' has been deprecated since TYPO3 CMS 8 and will be removed in TYPO3 CMS 9.'
);
}
foreach ($this->externalTables as $table => $tableSettings) {
// delete the default settings from above
if (is_array($this->MOD_MENU[$table])) {
unset($this->MOD_MENU[$table]);
}
if (is_array($tableSettings) && count($tableSettings) > 1) {
foreach ($tableSettings as $key => $settings) {
$this->MOD_MENU[$table][$key] = $lang->sL($settings['MENU']);
}
}
}
}
// First, select all pages_language_overlay records on the current page. Each represents a possibility for a language on the page. Add these to language selector.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');
$queryBuilder->getRestrictions()->removeAll();
......@@ -464,16 +411,6 @@ class PageLayoutController
if (!$count) {
unset($actions['2']);
}
// @internal: This is an internal hook for compatibility7 only, this hook will be removed without further notice
$initActionHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::class]['initActionHook'];
if (is_array($initActionHook)) {
foreach ($initActionHook as $hook) {
$params = [
'actions' => &$actions
];
GeneralUtility::callUserFunction($hook, $params, $this);
}
}
// page/be_user TSconfig blinding of menu-items
$actions = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $actions, 'menu.function');
......@@ -875,7 +812,6 @@ class PageLayoutController
if (!$dbList->nextThree) {
$dbList->nextThree = 1;
}
$dbList->externalTables = $this->externalTables;
// 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);
......@@ -1000,17 +936,6 @@ class PageLayoutController
return $this->moduleTemplate;
}
/**
* Print accumulated content of module
*
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function printContent()
{
GeneralUtility::logDeprecatedFunction();
echo $this->moduleTemplate->renderContent();
}
/***************************
*
* Sub-content functions, rendering specific parts of the module content.
......
......@@ -14,11 +14,9 @@ namespace TYPO3\CMS\Backend\Domain\Repository\Localization;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -165,43 +163,6 @@ class LocalizationRepository
return $result;
}
/**
* Builds an additional where clause to exclude deleted records and setting the versioning placeholders
*
* @return string
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function getExcludeQueryPart()
{
GeneralUtility::logDeprecatedFunction();
return BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content');
}
/**
* Builds an additional where clause to exclude hidden languages and limit a backend user to its allowed languages,
* if the user is not an admin.
*
* @return string
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function getAllowedLanguagesForBackendUser()
{
GeneralUtility::logDeprecatedFunction();
$backendUser = $this->getBackendUser();
$additionalWhere = '';
if (!$backendUser->isAdmin()) {
$additionalWhere .= ' AND sys_language.hidden=0';
if (!empty($backendUser->user['allowed_languages'])) {
$additionalWhere .= ' AND sys_language.uid IN(' . implode(',', GeneralUtility::intExplode(',', $backendUser->user['allowed_languages'])) . ')';
}
}
return $additionalWhere;
}
/**
* Builds additional query constraints to exclude hidden languages and
* limit a backend user to its allowed languages (unless the user is an admin)
......@@ -307,140 +268,6 @@ class LocalizationRepository
return $queryBuilder->execute();
}
/**
* Fetches the localization for a given record.
*
* @FIXME: This method is a clone of BackendUtility::getRecordLocalization, using origUid instead of transOrigPointerField
*
* @param string $table Table name present in $GLOBALS['TCA']
* @param int $uid The uid of the record
* @param int $language The uid of the language record in sys_language
* @param string $andWhereClause Optional additional WHERE clause (default: '')
* @return mixed Multidimensional array with selected records; if none exist, FALSE is returned
*
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function getRecordLocalization($table, $uid, $language, $andWhereClause = '')
{
GeneralUtility::logDeprecatedFunction();
$recordLocalization = false;
// Pages still stores translations in the pages_language_overlay table, all other tables store in themself
if ($table === 'pages') {
$table = 'pages_language_overlay';
}
if (BackendUtility::isTableLocalizable($table)) {
$tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
if (isset($tcaCtrl['origUid'])) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
$queryBuilder->select('*')
->from($table)
->where(
$queryBuilder->expr()->eq(
$tcaCtrl['origUid'],
$queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
$tcaCtrl['languageField'],
$queryBuilder->createNamedParameter((int)$language, \PDO::PARAM_INT)
)
)
->setMaxResults(1);
if ($andWhereClause) {
$queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($andWhereClause));
}
$recordLocalization = $queryBuilder->execute()->fetchAll();
}
}
return $recordLocalization;
}
/**
* Returning uid of previous localized record, if any, for tables with a "sortby" column
* Used when new localized records are created so that localized records are sorted in the same order as the default language records
*
* @FIXME: This method is a clone of DataHandler::getPreviousLocalizedRecordUid which is protected there and uses
* BackendUtility::getRecordLocalization which we also needed to clone in this class. Also, this method takes two
* language arguments.
*
* @param string $table Table name
* @param int $uid Uid of default language record
* @param int $pid Pid of default language record
* @param int $sourceLanguage Language of origin
* @param int $destinationLanguage Language of localization
* @return int uid of record after which the localized record should be inserted
*
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function getPreviousLocalizedRecordUid($table, $uid, $pid, $sourceLanguage, $destinationLanguage)
{
GeneralUtility::logDeprecatedFunction();
$previousLocalizedRecordUid = $uid;
if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
$sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
$select = [$sortRow, 'pid', 'uid'];
// For content elements, we also need the colPos
if ($table === 'tt_content') {
$select[] = 'colPos';
}
// Get the sort value of the default language record
$row = BackendUtility::getRecord($table, $uid, implode(',', $select));
if (is_array($row)) {
$queryBuilder = $this->getQueryBuilderWithWorkspaceRestriction('tt_content');
$queryBuilder->select(...$select)
->from($table)
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter($sourceLanguage, \PDO::PARAM_INT)
),
$queryBuilder->expr()->lt(
$sortRow,
$queryBuilder->createNamedParameter($row[$sortRow], \PDO::PARAM_INT)
)
);
// Respect the colPos for content elements
if ($table === 'tt_content') {
$queryBuilder->andWhere(
$queryBuilder->expr()->eq(
'colPos',
$queryBuilder->createNamedParameter($row['colPos'], \PDO::PARAM_INT)
)
);
}
$previousRow = $queryBuilder->orderBy($sortRow, 'DESC')->execute()->fetch();
// If there is an element, find its localized record in specified localization language
if ($previousRow !== false) {
$previousLocalizedRecord = $this->getRecordLocalization(
$table,
$previousRow['uid'],
$destinationLanguage
);
if (is_array($previousLocalizedRecord[0])) {
$previousLocalizedRecordUid = $previousLocalizedRecord[0]['uid'];
}
}
}
}
return $previousLocalizedRecordUid;
}
/**
* Returns the current BE user.
*
......
......@@ -17,9 +17,7 @@ namespace TYPO3\CMS\Backend\Module;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;
......@@ -121,15 +119,6 @@ abstract class AbstractFunctionModule
*/
public $extObj = null;
/**
* Set to the directory name of this class file.
*
* @see init()
* @var string
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public $thisPath = '';
/**
* Can be hardcoded to the name of a locallang.xlf file (from the same directory as the class file) to use/load
* and is included / added to $GLOBALS['LOCAL_LANG']
......@@ -173,12 +162,6 @@ abstract class AbstractFunctionModule
public function init(&$pObj, $conf)
{
$this->pObj = $pObj;
// Path of this script:
$reflector = new \ReflectionObject($this);
$this->thisPath = dirname($reflector->getFileName());
if (!@is_dir($this->thisPath)) {
throw new \RuntimeException('TYPO3 Fatal Error: Could not find path for class ' . get_class($this), 1381164687);
}
// Local lang:
if (!empty($this->localLangFile)) {
$this->getLanguageService()->includeLLFile($this->localLangFile);
......@@ -202,29 +185,6 @@ abstract class AbstractFunctionModule
}
}
/**
* Including any locallang file configured and merging its content over
* the current global LOCAL_LANG array (which is EXPECTED to exist!!!)
* @deprecated since TYPO3 v8, will be removed in TYPO3 v9
*/
public function incLocalLang()
{
GeneralUtility::logDeprecatedFunction();
if (
$this->localLangFile
&& (
@is_file(($this->thisPath . '/' . $this->localLangFile))
|| @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xml'))
)
) {
$LOCAL_LANG = $this->getLanguageService()->includeLLFile($this->thisPath . '/' . $this->localLangFile, false);
if (is_array($LOCAL_LANG)) {
$GLOBALS['LOCAL_LANG'] = (array)$GLOBALS['LOCAL_LANG'];
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
}
}
}