[BUGFIX] Force icon overlay for deleted records
authorFrancois Suter <francois@typo3.org>
Tue, 19 Apr 2011 11:51:27 +0000 (13:51 +0200)
committerOliver Hader <oliver@typo3.org>
Fri, 6 May 2011 16:27:19 +0000 (18:27 +0200)
t3lib_iconWorks::mapRecordOverlayToSpriteIconName() defines the
overlays to display for any given record icon, but it not workspace-
aware. However a pending request adds a hook to override the
icon overlays. This enables the "version" extension to hook into
the process and force the overlays to "deleted" when the current
record's t3ver_state = 2 (i.e. it is deleted in a workspace).

Test in conjunction with https://review.typo3.org/#change,1459

Change-Id: I63793da2450dbf5113218441713a5edb79e6f21d
Resolves: #24641
Releases: 4.6, 4.5

typo3/sysext/version/class.tx_version_iconworks.php [new file with mode: 0644]
typo3/sysext/version/ext_localconf.php

diff --git a/typo3/sysext/version/class.tx_version_iconworks.php b/typo3/sysext/version/class.tx_version_iconworks.php
new file mode 100644 (file)
index 0000000..46ced3e
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2011 Francois Suter (francois.suter@typo3.org)
+*
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Implements a hook for t3lib_iconworks
+ */
+class tx_version_iconworks {
+       /**
+        * Visualizes the deleted status for a versionized record.
+        *
+        * @param string $table Name of the table
+        * @param array $row Record row containing the field values
+        * @param array $status Status to be used for rendering the icon
+        * @return void
+        */
+       public function overrideIconOverlay($table, array $row, array &$status) {
+               if (isset($row['t3ver_state']) && $row['t3ver_state'] == 2) {
+                       $status['deleted'] = TRUE;
+               }
+       }
+}
+
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_iconworks.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_iconworks.php']);
+}
+?>
\ No newline at end of file
index 107bf08..df6c04d 100644 (file)
@@ -8,6 +8,8 @@ if (!defined ('TYPO3_MODE')) {
        // register the hook to actually do the work within TCEmain
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['version'] = t3lib_extMgm::extPath('version', 'class.tx_version_tcemain.php:&tx_version_tcemain');
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass']['version'] = t3lib_extMgm::extPath('version', 'class.tx_version_tcemain.php:&tx_version_tcemain');
+       // Register hook for overriding the icon status overlay
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_iconworks.php']['overrideIconOverlay']['version'] = t3lib_extMgm::extPath('version', 'class.tx_version_iconworks.php:&tx_version_iconworks');
 
 if (TYPO3_MODE == 'BE') {