[TASK] Change list view delete icon if record is deleted in WS 36/24736/4
authorSascha Egerer <sascha.egerer@dkd.de>
Mon, 14 Oct 2013 15:13:07 +0000 (17:13 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 9 Jan 2014 13:23:40 +0000 (14:23 +0100)
If a record is deleted in a workspace the delete icon is still
displayed but the function is different. If you click on
the delete icon of a deleted record you will "restore"
the record (remove the deleted flag).
The icon should change if record is marked as deleted.

Resolves: #52554
Releases: 6.2, 6.1, 6.0, 4.5
Change-Id: I9bccc076d06525fad16f9f5ca4b3413e217f32f6
Reviewed-on: https://review.typo3.org/24736
Reviewed-by: Thorsten Kahler
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/lang/locallang_mod_web_list.xlf
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index 2eda536..c54b3d7 100644 (file)
@@ -93,6 +93,9 @@
                        <trans-unit id="delete" xml:space="preserve">
                                <source>Delete record (!)</source>
                        </trans-unit>
+                       <trans-unit id="restore" xml:space="preserve">
+                               <source>Restore record</source>
+                       </trans-unit>
                        <trans-unit id="history" xml:space="preserve">
                                <source>Display change history / Un-do</source>
                        </trans-unit>
                        <trans-unit id="deleteWarning" xml:space="preserve">
                                <source>Are you sure you want to delete this record?</source>
                        </trans-unit>
+                       <trans-unit id="restoreWarning" xml:space="preserve">
+                               <source>Are you sure you want to restore this record by reverting the delete status?</source>
+                       </trans-unit>
                        <trans-unit id="localization" xml:space="preserve">
                                <source>Localization view</source>
                        </trans-unit>
index 3b07517..db668f6 100644 (file)
@@ -1103,11 +1103,40 @@ class DatabaseRecordList extends \TYPO3\CMS\Recordlist\RecordList\AbstractDataba
                                }
                                // "Delete" link:
                                if ($table == 'pages' && $localCalcPerms & 4 || $table != 'pages' && $this->calcPerms & 16) {
+                                       // Check if the record version is in "deleted" state, because that will switch the action to "restore"
+                                       if ($GLOBALS['BE_USER']->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
+                                               $actionName = 'restore';
+                                               $refCountMsg = '';
+                                       } else {
+                                               $actionName = 'delete';
+                                               $refCountMsg = \TYPO3\CMS\Backend\Utility\BackendUtility::referenceCount(
+                                                       $table,
+                                                       $row['uid'],
+                                                       ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'),
+                                                       $this->getReferenceCount($table, $row['uid'])
+                                               )
+                                               . \TYPO3\CMS\Backend\Utility\BackendUtility::translationCount(
+                                                       $table,
+                                                       $row['uid'],
+                                                       ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')
+                                               );
+                                       }
+
                                        $titleOrig = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
                                        $title = \TYPO3\CMS\Core\Utility\GeneralUtility::slashJS(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
+                                       $warningText = $GLOBALS['LANG']->JScharCode(
+                                               $GLOBALS['LANG']->getLL($actionName . 'Warning') . ' "' . $title . '" ' . $refCountMsg
+                                       );
+
                                        $params = '&cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
-                                       $refCountMsg = \TYPO3\CMS\Backend\Utility\BackendUtility::referenceCount($table, $row['uid'], (' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord')), $this->getReferenceCount($table, $row['uid'])) . \TYPO3\CMS\Backend\Utility\BackendUtility::translationCount($table, $row['uid'], (' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')));
-                                       $cells['delete'] = '<a href="#" onclick="' . htmlspecialchars(('if (confirm(' . $GLOBALS['LANG']->JScharCode(($GLOBALS['LANG']->getLL('deleteWarning') . ' "' . $title . '" ' . $refCountMsg)) . ')) {jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');} return false;')) . '" title="' . $GLOBALS['LANG']->getLL('delete', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
+                                       $onClick = htmlspecialchars(
+                                               ('if (confirm(' . $warningText . ')) {jumpToUrl(\''
+                                                       . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');} return false;')
+                                       );
+
+                                       $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-' . $actionName);
+                                       $linkTitle = $GLOBALS['LANG']->getLL($actionName, TRUE);
+                                       $cells['delete'] = '<a href="#" onclick="' . $onClick . '" title="' . $linkTitle . '">' . $icon . '</a>';
                                } elseif (!$this->table) {
                                        $cells['delete'] = $this->spaceIcon;
                                }