Commit cae1b06d authored by Matthias Vogel's avatar Matthias Vogel Committed by Andreas Fernandez
Browse files

[!!!][TASK] Decouple classes extending AbstractRecordList

In order to refactor the page module, list module,
and the file module individually,
the classes should become independent from each other.

Resolves: #82334
Releases: master
Change-Id: I2ca6aad28cbe4a88c03ef71f47fc11eb4b7649f7
Reviewed-on: https://review.typo3.org/53947

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
parent 20de7787
......@@ -32,11 +32,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*
* Base for class listing of database records and files in the
* modules Web>List and File>Filelist
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
abstract class AbstractRecordList
{
/**
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected $id = 0;
......@@ -44,6 +46,7 @@ abstract class AbstractRecordList
* default Max items shown
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $iLimit = 10;
......@@ -51,16 +54,19 @@ abstract class AbstractRecordList
* OBSOLETE - NOT USED ANYMORE. leftMargin
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $leftMargin = 0;
/**
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $showIcon = 1;
/**
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $no_noWrap = 0;
......@@ -68,6 +74,7 @@ abstract class AbstractRecordList
* If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $oddColumnsCssClass = '';
......@@ -75,6 +82,7 @@ abstract class AbstractRecordList
* Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
*
* @var array
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $fieldArray = [];
......@@ -82,6 +90,7 @@ abstract class AbstractRecordList
* Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
*
* @var array
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $addElement_tdParams = [];
......@@ -89,6 +98,7 @@ abstract class AbstractRecordList
* Keys are fieldnames and values are td-css-classes to add in addElement();
*
* @var array
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $addElement_tdCssClass = [];
......@@ -97,6 +107,7 @@ abstract class AbstractRecordList
* Max length of strings
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $fixedL = 30;
......@@ -104,6 +115,7 @@ abstract class AbstractRecordList
* Script URL
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $thisScript = '';
......@@ -111,6 +123,7 @@ abstract class AbstractRecordList
* Set to zero, if you don't want a left-margin with addElement function
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $setLMargin = 1;
......@@ -118,6 +131,7 @@ abstract class AbstractRecordList
* Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $counter = 0;
......@@ -125,6 +139,7 @@ abstract class AbstractRecordList
* This could be set to the total number of items. Used by the fwd_rew_navigation...
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $totalItems = '';
......@@ -132,11 +147,13 @@ abstract class AbstractRecordList
* Internal (used in this class.)
*
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $firstElementNumber = 0;
/**
* @var int
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $eCounter = 0;
......@@ -144,6 +161,7 @@ abstract class AbstractRecordList
* String with accumulated HTML content
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $HTMLcode = '';
......@@ -151,6 +169,7 @@ abstract class AbstractRecordList
* Contains page translation languages
*
* @var array
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $pageOverlays = [];
......@@ -158,24 +177,29 @@ abstract class AbstractRecordList
* Contains sys language icons and titles
*
* @var array
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $languageIconTitles = [];
/**
* @var TranslationConfigurationProvider
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public $translateTools;
/**
* @var IconFactory
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected $iconFactory;
/**
* Constructor
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function __construct()
{
GeneralUtility::logDeprecatedFunction();
if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
$this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
}
......@@ -186,6 +210,7 @@ abstract class AbstractRecordList
/**
* Sets the script url depending on being a module or script request
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected function determineScriptUrl()
{
......@@ -203,6 +228,7 @@ abstract class AbstractRecordList
/**
* @return string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected function getThisScript()
{
......@@ -221,6 +247,7 @@ abstract class AbstractRecordList
* @param string $_2 OBSOLETE - NOT USED ANYMORE. Is the HTML <img>-tag for an alternative 'gfx/ol/line.gif'-icon (used in the top)
* @param string $colType Defines the tag being used for the columns. Default is td.
* @return string HTML content for the table row
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $colType = 'td')
{
......@@ -303,6 +330,7 @@ abstract class AbstractRecordList
/**
* Dummy function, used to write the top of a table listing.
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function writeTop()
{
......@@ -313,6 +341,7 @@ abstract class AbstractRecordList
*
* @param string $table Table name
* @return array array([boolean], [HTML]) where [boolean] is 1 for reverse element, [HTML] is the table-row code for the element
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function fwd_rwd_nav($table = '')
{
......@@ -345,6 +374,7 @@ abstract class AbstractRecordList
* @param string $table Table name
* @return string
* @access private
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function fwd_rwd_HTML($type, $pointer, $table = '')
{
......@@ -370,6 +400,7 @@ abstract class AbstractRecordList
* @param string $table Table name to display. Enter "-1" for the current table.
* @param string $exclList Comma separated list of fields NOT to include ("sortField", "sortRev" or "firstElementNumber")
* @return string URL
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function listURL($altId = '', $table = '-1', $exclList = '')
{
......@@ -380,6 +411,7 @@ abstract class AbstractRecordList
* Returning JavaScript for ClipBoard functionality.
*
* @return string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function CBfunctions()
{
......@@ -417,6 +449,7 @@ abstract class AbstractRecordList
/**
* Initializes page languages and icons
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function initializeLanguages()
{
......@@ -452,6 +485,7 @@ abstract class AbstractRecordList
* @param int $sys_language_uid Sys language uid
* @param bool $addAsAdditionalText If set to true, only the flag is returned
* @return string Language icon
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public function languageFlag($sys_language_uid, $addAsAdditionalText = true)
{
......@@ -472,6 +506,7 @@ abstract class AbstractRecordList
* Gets an instance of TranslationConfigurationProvider
*
* @return TranslationConfigurationProvider
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected function getTranslateTools()
{
......@@ -488,6 +523,7 @@ abstract class AbstractRecordList
* @param int $references number of records from sys_refindex table
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.launchView
* @return string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected function generateReferenceToolTip($references, $launchViewParameter = '')
{
......@@ -508,6 +544,7 @@ abstract class AbstractRecordList
/**
* Returns the language service
* @return LanguageService
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected function getLanguageService()
{
......
.. include:: ../../Includes.txt
=====================================
Breaking: #82334 - AbstractRecordList
=====================================
See :issue:`82334`
Description
===========
The PHP classes :php:`AbstractRecordList` and :php:`AbstractDatabaseRecordList` have been marked as deprecated.
Some classes changed inheritances, which can be breaking for instance in hooks if they type hint or otherwise
check instance types of these classes:
* :php:`PageLayoutView` no longer extends :php:`AbstractDatabaseRecordList`
* :php:`FileList` no longer extends :php:`AbstractRecordList`
* :php:`DatabaseRecordList` no longer extends :php:`AbstractDatabaseRecordList`
Impact
======
Calling the constructor in these classes triggers a deprecation log entry.
Affected Installations
======================
Any TYPO3 installation with an extension accessing or extending the deprecated classes.
Migration
=========
The extension scanner checks if the classes are used.
Any extension authors are encouraged to copy the content of these Classes into there child Classes.
.. index:: Backend, PHP-API, FullyScanned
......@@ -16,9 +16,12 @@ namespace TYPO3\CMS\Filelist;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Backend\RecordList\AbstractRecordList;
use TYPO3\CMS\Backend\Routing\Router;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -39,7 +42,7 @@ use TYPO3\CMS\Filelist\Controller\FileListController;
/**
* Class for rendering of File>Filelist
*/
class FileList extends AbstractRecordList
class FileList
{
/**
* Default Max items shown
......@@ -104,6 +107,8 @@ class FileList extends AbstractRecordList
public $JScode = '';
/**
* String with accumulated HTML content
*
* @var string
*/
public $HTMLcode = '';
......@@ -129,9 +134,67 @@ class FileList extends AbstractRecordList
public $path = '';
/**
* @var Folder
* OBSOLETE - NOT USED ANYMORE. leftMargin
*
* @var int
*/
protected $folderObject;
public $leftMargin = 0;
/**
* This could be set to the total number of items. Used by the fwd_rew_navigation...
*
* @var string
*/
public $totalItems = '';
/**
* Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
*
* @var array
*/
public $fieldArray = [];
/**
* Set to zero, if you don't want a left-margin with addElement function
*
* @var int
*/
public $setLMargin = 1;
/**
* Contains page translation languages
*
* @var array
*/
public $pageOverlays = [];
/**
* Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
*
* @var int
*/
public $counter = 0;
/**
* Contains sys language icons and titles
*
* @var array
*/
public $languageIconTitles = [];
/**
* Script URL
*
* @var string
*/
public $thisScript = '';
/**
* If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
*
* @var string
*/
public $oddColumnsCssClass = '';
/**
* Counting the elements no matter what
......@@ -141,9 +204,38 @@ class FileList extends AbstractRecordList
public $eCounter = 0;
/**
* @var string
* @var TranslationConfigurationProvider
*/
public $totalItems = '';
public $translateTools;
/**
* Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
*
* @var array
*/
public $addElement_tdParams = [];
/**
* @var int
*/
public $no_noWrap = 0;
/**
* @var int
*/
public $showIcon = 1;
/**
* Keys are fieldnames and values are td-css-classes to add in addElement();
*
* @var array
*/
public $addElement_tdCssClass = [];
/**
* @var Folder
*/
protected $folderObject;
/**
* @var array
......@@ -161,17 +253,14 @@ class FileList extends AbstractRecordList
protected $resourceFactory;
/**
* @param ResourceFactory $resourceFactory
* @var IconFactory
*/
public function injectResourceFactory(ResourceFactory $resourceFactory)
{
$this->resourceFactory = $resourceFactory;
}
protected $iconFactory;
/**
* @var IconFactory
* @var int
*/
protected $iconFactory;
protected $id = 0;
/**
* @var FileListController
......@@ -185,7 +274,12 @@ class FileList extends AbstractRecordList
*/
public function __construct(FileListController $fileListController)
{
parent::__construct();
if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
$this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
}
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->getTranslateTools();
$this->determineScriptUrl();
$this->fileListController = $fileListController;
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
......@@ -195,6 +289,14 @@ class FileList extends AbstractRecordList
}
}
/**
* @param ResourceFactory $resourceFactory
*/
public function injectResourceFactory(ResourceFactory $resourceFactory)
{
$this->resourceFactory = $resourceFactory;
}
/**
* Initialization of class
*
......@@ -437,6 +539,265 @@ class FileList extends AbstractRecordList
return $out;
}
/**
* Returns a table-row with the content from the fields in the input data array.
* OBS: $this->fieldArray MUST be set! (represents the list of fields to display)
*
* @param int $h Is an integer >=0 and denotes how tall an element is. Set to '0' makes a halv line, -1 = full line, set to 1 makes a 'join' and above makes 'line'
* @param string $icon Is the <img>+<a> of the record. If not supplied the first 'join'-icon will be a 'line' instead
* @param array $data Is the dataarray, record with the fields. Notice: These fields are (currently) NOT htmlspecialchar'ed before being wrapped in <td>-tags
* @param string $rowParams Is insert in the <tr>-tags. Must carry a ' ' as first character
* @param string $_ OBSOLETE - NOT USED ANYMORE. $lMargin is the leftMargin (int)
* @param string $_2 OBSOLETE - NOT USED ANYMORE. Is the HTML <img>-tag for an alternative 'gfx/ol/line.gif'-icon (used in the top)
* @param string $colType Defines the tag being used for the columns. Default is td.
*
* @return string HTML content for the table row
*/
public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $colType = 'td')
{
$colType = ($colType === 'th') ? 'th' : 'td';
$noWrap = $this->no_noWrap ? '' : ' nowrap';
// Start up:
$l10nParent = isset($data['_l10nparent_']) ? (int)$data['_l10nparent_'] : 0;
$out = '
<!-- Element, begin: -->
<tr ' . $rowParams . ' data-uid="' . (int)$data['uid'] . '" data-l10nparent="' . $l10nParent . '">';
// Show icon and lines
if ($this->showIcon) {
$out .= '
<' . $colType . ' class="col-icon nowrap">';
if (!$h) {
$out .= '&nbsp;';
} else {
for ($a = 0; $a < $h; $a++) {
if (!$a) {
if ($icon) {
$out .= $icon;
}
}
}
}
$out .= '</' . $colType . '>
';
}
// Init rendering.
$colsp = '';
$lastKey = '';
$c = 0;
$ccount = 0;
// __label is used as the label key to circumvent problems with uid used as label (see #67756)
// as it was introduced later on, check if it really exists before using it
$fields = $this->fieldArray;
if ($colType === 'td' && array_key_exists('__label', $data)) {
$fields[0] = '__label';
}
// Traverse field array which contains the data to present:
foreach ($fields as $vKey) {
if (isset($data[$vKey])) {
if ($lastKey) {
$cssClass = $this->addElement_tdCssClass[$lastKey];
if ($this->oddColumnsCssClass && $ccount % 2 == 0) {
$cssClass = implode(' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass]);
}
$out .= '
<' . $colType . ' class="' . $cssClass . $noWrap . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>';
}
$lastKey = $vKey;
$c = 1;
$ccount++;
} else {
if (!$lastKey) {
$lastKey = $vKey;
}
$c++;
}
if ($c > 1) {
$colsp = ' colspan="' . $c . '"';
} else {
$colsp = '';
}
}
if ($lastKey) {
$cssClass = $this->addElement_tdCssClass[$lastKey];
if ($this->oddColumnsCssClass) {
$cssClass = implode(' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass]);
}
$out .= '
<' . $colType . ' class="' . $cssClass . $noWrap . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>';
}
// End row
$out .= '
</tr>';
// Return row.
return $out;
}
/**
* Dummy function, used to write the top of a table listing.
*/
public function writeTop()
{
}
/**
* Creates a forward/reverse button based on the status of ->eCounter, ->firstElementNumber, ->iLimit
*
* @param string $table Table name
* @return array array([boolean], [HTML]) where [boolean] is 1 for reverse element, [HTML] is the table-row code for the element
*/
public function fwd_rwd_nav($table = '')
{
$code = '';
if ($this->eCounter >= $this->firstElementNumber && $this->eCounter < $this->firstElementNumber + $this->iLimit) {
if ($this->firstElementNumber && $this->eCounter == $this->firstElementNumber) {
// Reverse
$theData = [];
$titleCol = $this->fieldArray[0];
$theData[$titleCol] = $this->fwd_rwd_HTML('fwd', $this->eCounter, $table);
$code = $this->addElement(1, '', $theData, 'class="fwd_rwd_nav"');