[FEATURE] Make sys_language records sortable. 10/49610/5
authorGeorg Ringer <georg.ringer@gmail.com>
Mon, 29 Aug 2016 07:00:02 +0000 (09:00 +0200)
committerAndreas Wolf <andreas.wolf@typo3.org>
Thu, 1 Sep 2016 11:19:30 +0000 (13:19 +0200)
To improve the usability, the sys_language records are now sortable.

Resolves: #77652
Releases: master
Change-Id: I4225da82a172175b36a04772d9eacf0a8fc863f4
Reviewed-on: https://review.typo3.org/49610
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
13 files changed:
typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Domain/Repository/Localization/LocalizationRepository.php
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseSystemLanguageRows.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php
typo3/sysext/beuser/Classes/ViewHelpers/Display/SysLanguageViewHelper.php
typo3/sysext/core/Configuration/TCA/sys_language.php
typo3/sysext/core/Documentation/Changelog/master/Feature-77652-MakeSys_languageRecordsSortable.rst [new file with mode: 0644]
typo3/sysext/core/ext_tables.sql
typo3/sysext/frontend/Classes/Controller/TranslationStatusController.php
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php

index 0dbdd20..08ba769 100644 (file)
@@ -69,6 +69,7 @@ class TranslationConfigurationProvider
         $languageRecords = $queryBuilder
             ->select('*')
             ->from('sys_language')
+            ->orderBy('sorting')
             ->execute()
             ->fetchAll();
         foreach ($languageRecords as $languageRecord) {
index 123951a..2659cb2 100644 (file)
@@ -1707,7 +1707,7 @@ class EditDocumentController extends AbstractModule
         $queryBuilder->select('s.uid', 's.pid', 's.hidden', 's.title', 's.flag')
             ->from('sys_language', 's')
             ->groupBy('s.uid', 's.pid', 's.hidden', 's.title', 's.flag')
-            ->orderBy('s.title');
+            ->orderBy('s.sorting');
 
         if ($id) {
             $queryBuilder->getRestrictions()
index 5ab9f07..ebd6a03 100644 (file)
@@ -417,7 +417,7 @@ class PageLayoutController
                 ->groupBy('pages_language_overlay.sys_language_uid', 'sys_language.uid', 'sys_language.pid',
                     'sys_language.tstamp', 'sys_language.hidden', 'sys_language.title',
                     'sys_language.language_isocode', 'sys_language.static_lang_isocode', 'sys_language.flag')
-                ->orderBy('sys_language.title');
+                ->orderBy('sys_language.sorting');
             if (!$this->getBackendUser()->isAdmin()) {
                 $queryBuilder->andWhere($queryBuilder->expr()->eq('sys_language.hidden', 0));
             }
@@ -426,7 +426,7 @@ class PageLayoutController
             $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(HiddenRestriction::class));
             $statement = $queryBuilder->select('uid', 'title')
                 ->from('sys_language')
-                ->orderBy('title')
+                ->orderBy('sorting')
                 ->execute();
         }
         while ($lRow = $statement->fetch()) {
@@ -469,6 +469,7 @@ class PageLayoutController
         $count = $queryBuilder
             ->count('uid')
             ->from('sys_language')
+            ->orderBy('sorting')
             ->execute()
             ->fetchColumn(0);
 
index 0ba787f..63ba611 100644 (file)
@@ -123,7 +123,7 @@ class LocalizationRepository
             ->from('sys_language')
             ->where(...$constraints)
             ->groupBy('sys_language.uid')
-            ->orderBy('sys_language.title');
+            ->orderBy('sys_language.sorting');
 
         $result = $queryBuilder->execute()->fetchAll();
 
index 29ba560..34941d6 100644 (file)
@@ -77,6 +77,7 @@ class DatabaseSystemLanguageRows implements FormDataProviderInterface
             ->select('uid', 'title', 'language_isocode', 'flag')
             ->from('sys_language')
             ->where($queryBuilder->expr()->eq('pid', 0))
+            ->orderBy('sorting')
             ->execute();
 
         while ($row = $queryResult->fetch()) {
index a6cc34c..ddfcf3d 100644 (file)
@@ -2038,7 +2038,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
             $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(HiddenRestriction::class));
             $statement = $queryBuilder->select('uid', 'title')
                 ->from('sys_language')
-                ->orderBy('title')
+                ->orderBy('sorting')
                 ->execute();
             $langSelItems = [];
             $langSelItems[0] = '
@@ -2071,7 +2071,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                 ->groupBy('pages_language_overlay.sys_language_uid', 'sys_language.uid', 'sys_language.pid',
                     'sys_language.tstamp', 'sys_language.hidden', 'sys_language.title',
                     'sys_language.language_isocode', 'sys_language.static_lang_isocode', 'sys_language.flag')
-                ->orderBy('sys_language.title');
+                ->orderBy('sys_language.sorting');
             if (!$this->getBackendUser()->isAdmin()) {
                 $queryBuilder->andWhere($queryBuilder->expr()->eq('sys_language.hidden', 0));
             }
index b8e34cc..8718970 100644 (file)
@@ -100,6 +100,7 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
         $queryBuilderProphecy->getRestrictions()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
         $queryBuilderProphecy->select('uid', 'title', 'language_isocode', 'flag')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->from('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
+        $queryBuilderProphecy->orderBy('sorting')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->expr()->shouldBeCalled()->willReturn($expressionBuilderProphecy->reveal());
         $expressionBuilderProphecy->eq('pid', 0)->shouldBeCalled()->willReturn('pid = 0');
         $queryBuilderProphecy->where('pid = 0')->shouldBeCalled()->willReturn($queryBuilderRevelation);
@@ -142,6 +143,7 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
         $queryBuilderProphecy->getRestrictions()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
         $queryBuilderProphecy->select('uid', 'title', 'language_isocode', 'flag')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->from('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
+        $queryBuilderProphecy->orderBy('sorting')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->expr()->shouldBeCalled()->willReturn($expressionBuilderProphecy->reveal());
         $expressionBuilderProphecy->eq('pid', 0)->shouldBeCalled()->willReturn('pid = 0');
         $queryBuilderProphecy->where('pid = 0')->shouldBeCalled()->willReturn($queryBuilderRevelation);
@@ -199,6 +201,7 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
         $queryBuilderProphecy->getRestrictions()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
         $queryBuilderProphecy->select('uid', 'title', 'language_isocode', 'flag')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->from('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
+        $queryBuilderProphecy->orderBy('sorting')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->expr()->shouldBeCalled()->willReturn($expressionBuilderProphecy->reveal());
         $expressionBuilderProphecy->eq('pid', 0)->shouldBeCalled()->willReturn('pid = 0');
         $queryBuilderProphecy->where('pid = 0')->shouldBeCalled()->willReturn($queryBuilderRevelation);
@@ -251,6 +254,7 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
         // Simulate method call flow on database objects and verify correct query is built
         $connectionPoolProphecy->getQueryBuilderForTable('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryRestrictionContainerProphecy->removeAll()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
+        $queryBuilderProphecy->orderBy('sorting')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->getRestrictions()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
         $queryBuilderProphecy->select('uid', 'title', 'language_isocode', 'flag')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->from('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
@@ -317,6 +321,7 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
         $queryBuilderProphecy->getRestrictions()->shouldBeCalled()->willReturn($queryRestrictionContainerRevelation);
         $queryBuilderProphecy->select('uid', 'title', 'language_isocode', 'flag')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->from('sys_language')->shouldBeCalled()->willReturn($queryBuilderRevelation);
+        $queryBuilderProphecy->orderBy('sorting')->shouldBeCalled()->willReturn($queryBuilderRevelation);
         $queryBuilderProphecy->expr()->shouldBeCalled()->willReturn($expressionBuilderProphecy->reveal());
         $expressionBuilderProphecy->eq('pid', 0)->shouldBeCalled()->willReturn('pid = 0');
         $queryBuilderProphecy->where('pid = 0')->shouldBeCalled()->willReturn($queryBuilderRevelation);
index 26b4a58..3f81431 100644 (file)
@@ -79,7 +79,7 @@ class SysLanguageViewHelper extends AbstractViewHelper
                     GeneralUtility::intExplode(',', $uids)
                 )
             )
-            ->orderBy('title', 'ASC')
+            ->orderBy('sorting')
             ->execute();
 
         while ($row = $res->fetch()) {
index 41e4dd1..ffdbd95 100644 (file)
@@ -3,7 +3,8 @@ return [
     'ctrl' => [
         'label' => 'title',
         'tstamp' => 'tstamp',
-        'default_sortby' => 'ORDER BY title',
+        'default_sortby' => 'ORDER BY sorting',
+        'sortby' => 'sorting',
         'title' => 'LLL:EXT:lang/locallang_tca.xlf:sys_language',
         'adminOnly' => true,
         'rootLevel' => 1,
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-77652-MakeSys_languageRecordsSortable.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-77652-MakeSys_languageRecordsSortable.rst
new file mode 100644 (file)
index 0000000..d2e69ef
--- /dev/null
@@ -0,0 +1,14 @@
+====================================================
+Feature: #77652 - Make sys_language records sortable
+====================================================
+
+Description
+===========
+
+To improve the usability, the sys_language records are now sortable.
+
+
+Impact
+======
+
+The languages can now be manually sorted instead of an ordering by its name.
\ No newline at end of file
index 2741276..aeebeda 100644 (file)
@@ -636,6 +636,7 @@ CREATE TABLE sys_language (
        flag varchar(20) DEFAULT '' NOT NULL,
        language_isocode varchar(2) DEFAULT '' NOT NULL,
        static_lang_isocode int(11) unsigned DEFAULT '0' NOT NULL,
+       sorting int(11) unsigned DEFAULT '0' NOT NULL,
        PRIMARY KEY (uid),
        KEY parent (pid)
 );
index f4faaa8..2729f60 100644 (file)
@@ -347,7 +347,8 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
             ->removeAll();
         $queryBuilder
             ->select('*')
-            ->from('sys_language');
+            ->from('sys_language')
+            ->orderBy('sorting');
         $res = $queryBuilder->execute();
         $outputArray = [];
         if (is_array($allowed_languages) && !empty($allowed_languages)) {
index 02d0535..8e681dd 100644 (file)
@@ -287,7 +287,7 @@ class ViewModuleController extends ActionController
             )
             ->where($queryBuilder->expr()->eq('o.pid', (int)$pageIdToShow))
             ->groupBy('sys_language.uid', 'sys_language.title')
-            ->orderBy('sys_language.title')
+            ->orderBy('sys_language.sorting')
             ->execute();
 
         while ($row = $result->fetch()) {