Skip to content

Commit

Permalink
[BUGFIX] Make RecordBrowser highlight selected record again
Browse files Browse the repository at this point in the history
When using the element browser wizard with a configured record link
handler, the record browser now highlights the currently linked
record again.

Resolves: #82739
Releases: master, 8.7
Change-Id: Iba47f18bf150bb4646729c6a5ecdae46b7d56754
Reviewed-on: https://review.typo3.org/54370
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
  • Loading branch information
sjbrca authored and neufeind committed Mar 15, 2018
1 parent 6369928 commit 9ccc719
Showing 1 changed file with 36 additions and 1 deletion.
Expand Up @@ -33,6 +33,8 @@
use TYPO3\CMS\Core\Database\ReferenceIndex;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Messaging\FlashMessage;
Expand Down Expand Up @@ -585,10 +587,17 @@ class DatabaseRecordList

/**
* Override/add urlparameters in listUrl() method
* @var string[]
* @var mixed[]
*/
protected $overrideUrlParameters = [];

/**
* Current link: array with table names and uid
*
* @var array
*/
protected $currentLink = [];

/**
* Only used to render translated records, used in list module to show page translations
*
Expand Down Expand Up @@ -1376,6 +1385,14 @@ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent
'title' => 'id=' . $row['uid'],
];

// Add active class to record of current link
if (
isset($this->currentLink['tableNames'])
&& (int)$this->currentLink['uid'] === (int)$row['uid']
&& GeneralUtility::inList($this->currentLink['tableNames'], $table)
) {
$tagAttributes['class'][] = 'active';
}
// Add special classes for first and last row
if ($cc == 1 && $indent == 0) {
$tagAttributes['class'][] = 'firstcol';
Expand Down Expand Up @@ -2885,6 +2902,20 @@ public function start($id, $table, $pointer, $search = '', $levels = 0, $showLim
);
}

// If there is a current link to a record, set the current link uid and get the table name from the link handler configuration
$currentLinkValue = isset($this->overrideUrlParameters['P']['currentValue']) ? trim($this->overrideUrlParameters['P']['currentValue']) : '';
if ($currentLinkValue) {
$linkService = GeneralUtility::makeInstance(LinkService::class);
try {
$currentLinkParts = $linkService->resolve($currentLinkValue);
if ($currentLinkParts['type'] === 'record' && isset($currentLinkParts['identifier'])) {
$this->currentLink['tableNames'] = $this->tableList;
$this->currentLink['uid'] = (int)$currentLinkParts['uid'];
}
} catch (UnknownLinkHandlerException $e) {
}
}

// $table might be NULL at this point in the code. As the expressionBuilder
// is used to limit returned records based on the page permissions and the
// uid field of the pages it can hardcoded to work on the pages table.
Expand Down Expand Up @@ -3837,6 +3868,10 @@ public function localizationRedirect($justLocalized)
*/
public function setOverrideUrlParameters(array $urlParameters)
{
$currentUrlParameter = GeneralUtility::_GP('curUrl');
if (isset($currentUrlParameter['url'])) {
$urlParameters['P']['currentValue'] = $currentUrlParameter['url'];
}
$this->overrideUrlParameters = $urlParameters;
}

Expand Down

0 comments on commit 9ccc719

Please sign in to comment.