From a01a7462ee189ca1114280cb4b29db9b4bd2c600 Mon Sep 17 00:00:00 2001
From: Wolfgang Klinger <wolfgang@wazum.com>
Date: Wed, 9 Aug 2017 17:22:09 +0200
Subject: [PATCH] [FEATURE] Add file links sorting by date and sorting
 direction
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Adds ‘Sort by creation date’ and ‘Sort by modification date’ options
and a new option to set a sorting direction in the file links
content element.
Corrects the sorting option labels in English.

Resolves: #65403
Resolves: #63509
Releases: master
Change-Id: I0e0b474ee49e2be5e4111b6841a36f27d35f3b71
Reviewed-on: https://review.typo3.org/53667
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Tested-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
---
 ...eLinksSortingByDateAndSortingDirection.rst | 24 +++++++++++++++++
 .../TypoScript/ContentElement/Uploads.txt     |  1 +
 .../frontend/Configuration/TCA/tt_content.php | 17 +++++++++++-
 .../Private/Language/locallang_ttc.xlf        | 27 ++++++++++++++-----
 typo3/sysext/frontend/ext_tables.sql          |  3 ++-
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Feature-63509-FileLinksSortingByDateAndSortingDirection.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-63509-FileLinksSortingByDateAndSortingDirection.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-63509-FileLinksSortingByDateAndSortingDirection.rst
new file mode 100644
index 000000000000..c4e82e71dad4
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-63509-FileLinksSortingByDateAndSortingDirection.rst
@@ -0,0 +1,24 @@
+.. include:: ../../Includes.txt
+
+======================================================================
+Feature: #65403 - Add file links sorting by date and sorting direction
+======================================================================
+
+See :issue:`63509`
+See :issue:`65403`
+
+Description
+===========
+
+Adds "Sort by creation date" and "Sort by modification date" options
+and a new option to set a sorting direction in the file links
+content element.
+
+
+Impact
+======
+
+New options in the "Sort by" dropdown and a new dropdown
+to set a sorting direction.
+
+.. index:: Backend
diff --git a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/Uploads.txt b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/Uploads.txt
index 78d84e8fef2d..262a1752d8c8 100644
--- a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/Uploads.txt
+++ b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/Uploads.txt
@@ -12,6 +12,7 @@ tt_content.uploads {
             references.fieldName = media
             collections.field = file_collections
             sorting.field = filelink_sorting
+            sorting.direction.field = filelink_sorting_direction
         }
     }
     stdWrap {
diff --git a/typo3/sysext/frontend/Configuration/TCA/tt_content.php b/typo3/sysext/frontend/Configuration/TCA/tt_content.php
index 369642f437ff..b9763e81be01 100644
--- a/typo3/sysext/frontend/Configuration/TCA/tt_content.php
+++ b/typo3/sysext/frontend/Configuration/TCA/tt_content.php
@@ -996,7 +996,21 @@ return [
                     ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.extension', 'extension'],
                     ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.name', 'name'],
                     ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.type', 'type'],
-                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.size', 'size']
+                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.size', 'size'],
+                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.creation_date', 'creation_date'],
+                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting.modification_date', 'modification_date']
+                ]
+            ]
+        ],
+        'filelink_sorting_direction' => [
+            'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting_direction',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    ['', ''],
+                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting_direction.ascending', 'asc'],
+                    ['LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:filelink_sorting_direction.descending', 'desc'],
                 ]
             ]
         ],
@@ -1903,6 +1917,7 @@ return [
                 file_collections;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:file_collections.ALT.uploads_formlabel,
                 --linebreak--,
                 filelink_sorting,
+                filelink_sorting_direction,
                 target
             ',
         ],
diff --git a/typo3/sysext/frontend/Resources/Private/Language/locallang_ttc.xlf b/typo3/sysext/frontend/Resources/Private/Language/locallang_ttc.xlf
index 74567d93fe53..77691243b576 100644
--- a/typo3/sysext/frontend/Resources/Private/Language/locallang_ttc.xlf
+++ b/typo3/sysext/frontend/Resources/Private/Language/locallang_ttc.xlf
@@ -451,22 +451,37 @@
 				<source>Show File Size:</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting">
-				<source>Sort Filelist:</source>
+				<source>Sort file list:</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting.none">
-					<source>none</source>
+					<source>no sorting</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting.extension">
-					<source>by Fileextension</source>
+					<source>by file extension</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting.name">
-					<source>by Filename</source>
+					<source>by filename</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting.type">
-					<source>by Filetype</source>
+					<source>by file type</source>
 			</trans-unit>
 			<trans-unit id="filelink_sorting.size">
-					<source>by Filesize</source>
+					<source>by file size</source>
+			</trans-unit>
+			<trans-unit id="filelink_sorting.creation_date">
+					<source>by file creation date</source>
+			</trans-unit>
+			<trans-unit id="filelink_sorting.modification_date">
+					<source>by file modification date</source>
+			</trans-unit>
+			<trans-unit id="filelink_sorting_direction">
+				<source>Sorting direction:</source>
+			</trans-unit>
+			<trans-unit id="filelink_sorting_direction.ascending">
+					<source>Ascending (default)</source>
+			</trans-unit>
+			<trans-unit id="filelink_sorting_direction.descending">
+					<source>Descending</source>
 			</trans-unit>
 			<trans-unit id="filelink_size_formlabel">
 				<source>Display File Size Information</source>
diff --git a/typo3/sysext/frontend/ext_tables.sql b/typo3/sysext/frontend/ext_tables.sql
index 36cfa88ee7c4..1178baeb7236 100644
--- a/typo3/sysext/frontend/ext_tables.sql
+++ b/typo3/sysext/frontend/ext_tables.sql
@@ -276,7 +276,8 @@ CREATE TABLE tt_content (
 	linkToTop tinyint(3) unsigned DEFAULT '0' NOT NULL,
 	file_collections text,
 	filelink_size tinyint(3) unsigned DEFAULT '0' NOT NULL,
-	filelink_sorting varchar(10) DEFAULT '' NOT NULL,
+	filelink_sorting varchar(17) DEFAULT '' NOT NULL,
+	filelink_sorting_direction varchar(4) DEFAULT '' NOT NULL,
 	target varchar(30) DEFAULT '' NOT NULL,
 	date int(10) unsigned DEFAULT '0' NOT NULL,
 	recursive tinyint(3) unsigned DEFAULT '0' NOT NULL,
-- 
GitLab