Project

General

Profile

Actions

Bug #105015

closed

Locale aware sorting of foreign records with selectMultipleSideBySide in the backend

Added by Rémi Payette 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2024-09-17
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

in typo3 v10 and v13, I use a selectMultipleSideBySide to which I set sortItems in the TCA :

'thecolumn' => [
  'exclude' => 0,
  'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:sources',
  'config' => [
    'type' => 'select',
    'sortItems' => [
      'label' => 'asc',
    ],
    'renderType' => 'selectMultipleSideBySide',

The sort order is managed by the PHP function strcasecmp which only does basic ascii comparision which put accented characters at the end of the list.

This is what I have done locally to fix this ( sorry, not equipped to do a proper pull request )

typo3 10.4.45 /backend/Classes/Form/FormDataProvider/TcaSelectItems.php line 288
typo3 13.2.1 /cms-backend/Classes/Form/Processor/SelectItemProcessor.php line 159

    protected function sortItems(array $items, array $sortOrders): array
    {
        foreach ($sortOrders as $order => $direction) {
            switch ($order) {
                case 'label':
                    $direction = strtolower($direction);
*                   $collator = new \Collator(null);
                    @usort(
                        $items,
*                       function ($item1, $item2) use ($direction, $collator) {
                            if ($direction === 'desc') {
*                               return $collator->compare($item1[0], $item2[0]) <= 0;
                            }
*                           return $collator->compare($item1[0], $item2[0]);
                        }
                    );
                    break;

This is the first half of the function in typo3 v10, same changes to the other case 'value'.
It's almost the same on typo3 v13.


Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #95575: Built-in sortItems by "label" does not respect UTF-8Closed2021-10-12

Actions
Actions

Also available in: Atom PDF