Fixed bug: #10819 viewOnClick causes error if frontendpreview is disabled
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Service / Befunc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
30 * @package Workspaces
31 * @subpackage Service
32 */
33 class tx_Workspaces_Service_Befunc {
34 /**
35 * Hooks into the t3lib_beFunc::viewOnClick and redirects to the workspace preview
36 * only if we're in a workspace and if the frontend-preview is disabled.
37 *
38 * @param $pageUid
39 * @param $backPath
40 * @param $rootLine
41 * @param $anchorSection
42 * @param $viewScript
43 * @param $additionalGetVars
44 * @param $switchFocus
45 * @return void
46 */
47 public function preProcess($pageUid, $backPath, $rootLine, $anchorSection, &$viewScript, $additionalGetVars, $switchFocus) {
48 if ($GLOBALS['BE_USER']->workspace !== 0 && !$GLOBALS['BE_USER']->user['workspace_preview']) {
49 $ctrl = t3lib_div::makeInstance('Tx_Workspaces_Controller_PreviewController', FALSE);
50 $uriBuilder = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Routing_UriBuilder');
51 /**
52 * @todo BACK_PATH is not available be still needed when used during AJAX request
53 * @todo make sure this would work in local extension installation too
54 */
55 $backPath = isset($GLOBALS['BACK_PATH']) ? $GLOBALS['BACK_PATH'] : '../../../' . TYPO3_mainDir;
56 // @todo why do we need these additional params? the URIBuilder should add the controller, but he doesn't :(
57 $additionalParams = '&tx_workspaces_web_workspacesworkspaces%5Bcontroller%5D=Preview&M=web_WorkspacesWorkspaces&id=';
58
59 $viewScript = '/' . $backPath . $uriBuilder->uriFor('index', array(), $ctrl, 'workspaces', 'web_workspacesworkspaces') . $additionalParams;
60 }
61 }
62
63 }
64
65 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Befunc.php']) {
66 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Befunc.php']);
67 }
68 ?>