[BUGFIX] Preview does not include L parameter on localization
authorOliver Hader <oliver@typo3.org>
Thu, 27 Dec 2012 17:12:02 +0000 (18:12 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 4 Jan 2013 08:00:48 +0000 (09:00 +0100)
The workspace module offers a way to preview accordant records
in the frontend. However, the L parameters is missing if dealing
with localized records.

The language needs to be determined from the version record, not
from the live record (which might be a placeholder as well).
Besides that, the L parameter needs to be provided as additional
GET parameter since it cannot be determined anymore later during
processing in t3lib_BEfunc::viewOnClick().

Change-Id: I97083cabce33c7f23a4f20687cfc81865cb8f68c
Fixes: #26612
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/17278
Reviewed-by: Stefan Neufeind
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/workspaces/Classes/Service/GridDataService.php
typo3/sysext/workspaces/Classes/Service/WorkspaceService.php

index a3ad078..e3b379d 100644 (file)
@@ -139,7 +139,7 @@ class GridDataService {
                                                $recordState = $this->workspaceState($versionRecord['t3ver_state']);
                                        }
                                        $isDeletedPage = $table == 'pages' && $recordState == 'deleted';
-                                       $viewUrl = \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $record['t3ver_oid'], $origRecord);
+                                       $viewUrl = \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $record['uid'], $origRecord, $versionRecord);
                                        $versionArray['id'] = $table . ':' . $record['uid'];
                                        $versionArray['uid'] = $record['uid'];
                                        $versionArray['workspace'] = $versionRecord['t3ver_id'];
index 8c7177b..2198893 100644 (file)
@@ -493,26 +493,47 @@ class WorkspaceService implements \TYPO3\CMS\Core\SingletonInterface {
         * Generates a view link for a page.
         *
         * @static
-        * @param string $table
-        * @param integer $uid
-        * @param array $record
+        * @param string $table Table to be used
+        * @param integer $uid Uid of the version(!) record
+        * @param array $liveRecord Optional live record data
+        * @param array $versionRecord Optional version record data
         * @return string
         */
-       static public function viewSingleRecord($table, $uid, $record = NULL) {
+       static public function viewSingleRecord($table, $uid, array $liveRecord = NULL, array $versionRecord = NULL) {
                $viewUrl = '';
+
                if ($table == 'pages') {
                        $viewUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick(\TYPO3\CMS\Backend\Utility\BackendUtility::getLiveVersionIdOfRecord('pages', $uid));
                } elseif ($table === 'pages_language_overlay' || $table === 'tt_content') {
-                       $elementRecord = is_array($record) ? $record : \TYPO3\CMS\Backend\Utility\BackendUtility::getLiveVersionOfRecord($table, $uid);
-                       $viewUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($elementRecord['pid']);
+                       if ($liveRecord === NULL) {
+                               $liveRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getLiveVersionOfRecord($table, $uid);
+                       }
+                       if ($versionRecord === NULL) {
+                               $versionRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $uid);
+                       }
+
+                       $additionalParameters = '';
+                       $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
+                       if ($versionRecord[$languageField] > 0) {
+                               $additionalParameters .= '&L=' . $versionRecord[$languageField];
+                       }
+
+                       $viewUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($liveRecord['pid'], '', '', '', '', $additionalParameters);
                } else {
                        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['viewSingleRecord'])) {
-                               $_params = array('table' => $table, 'uid' => $uid, 'record' => $record);
+                               $_params = array(
+                                       'table' => $table,
+                                       'uid' => $uid,
+                                       'record' => $liveRecord,
+                                       'liveRecord' => $liveRecord,
+                                       'versionRecord' => $versionRecord,
+                               );
                                $_funcRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['viewSingleRecord'];
                                $null = NULL;
                                $viewUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $null);
                        }
                }
+
                return $viewUrl;
        }