[TASK] Change list view delete icon if record is deleted in WS 46/24746/5
authorSascha Egerer <sascha.egerer@dkd.de>
Tue, 15 Oct 2013 08:57:36 +0000 (10:57 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 9 Jan 2014 13:42:23 +0000 (14:42 +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/24746
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/class.db_list_extra.inc
typo3/sysext/lang/locallang_mod_web_list.xml

index 7fe66c3..bfe258f 100644 (file)
@@ -1290,22 +1290,36 @@ class localRecordList extends recordList {
 
                                        // "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 = t3lib_BEfunc::referenceCount(
+                                                       $table,
+                                                       $row['uid'],
+                                                       ' ' . $GLOBALS['LANG']->sL(
+                                                               'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
+                                                       ),
+                                                       $this->getReferenceCount($table, $row['uid'])
+                                               ) .
+                                               t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
+                                       }
+
                                        $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
                                        $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
-                                       $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
+                                       $warningText = $LANG->JScharCode(
+                                               $LANG->getLL($actionName . 'Warning') . ' "' . $title . '" ' . $refCountMsg
+                                       );
 
-                                       $refCountMsg = t3lib_BEfunc::referenceCount(
-                                               $table,
-                                               $row['uid'],
-                                               ' ' . $GLOBALS['LANG']->sL(
-                                                       'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
-                                               ),
-                                               $this->getReferenceCount($table, $row['uid'])
-                                       ) .
-                                               t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
-                                       $cells['delete']='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').' "'. $title.'" '.$refCountMsg).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'" title="' . $LANG->getLL('delete', TRUE) . '">' .
-                                                       t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
-                                                       '</a>';
+                                       $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
+                                       $onClick = htmlspecialchars(
+                                               'if (confirm(' . $warningText . ')) {jumpToUrl(\'' . $SOBE->doc->issueCommand($params, -1) . '\');} return false;'
+                                       );
+                                       $icon = t3lib_iconWorks::getSpriteIcon('actions-edit-' . $actionName);
+                                       $linkTitle = $LANG->getLL($actionName, TRUE);
+                                       $cells['delete']='<a href="#" onclick="' . $onClick . '" title="' . $linkTitle . '">' . $icon . '</a>';
                                } elseif(!$this->table) {
                                        $cells['delete'] = $this->spaceIcon;
                                }
index c23689d..ba3de6d 100755 (executable)
@@ -36,6 +36,7 @@
                        <label index="prevLevel">Move this page to the position after the current parent page (Inwards)</label>
                        <label index="nextLevel">Move this page to be a subpage of the page above (Outwards)</label>
                        <label index="delete">Delete record (!)</label>
+                       <label index="restore">Restore record (!)</label>
                        <label index="history">Display change history / Un-do</label>
                        <label index="displayVersions">Display versions</label>
                        <label index="permissions">Set permissions for page</label>
@@ -46,6 +47,7 @@
                        <label index="editShownColumns">Edit all shown fields of the listed records</label>
                        <label index="editThisColumn">Edit the '%s' field of the listed records</label>
                        <label index="deleteWarning">Are you sure you want to delete this record?</label>
+                       <label index="restoreWarning">Are you sure you want to restore this record by reverting the delete status?</label>
                        <label index="localization">Localization view</label>
                        <label index="defaultLanguage">Default</label>
                        <label index="multipleLanguages">All languages</label>