Fixed bug #12855: Generate preview link visible in Live-Workspace and on non-content...
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Controller / ReviewController.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Steffen Ritter (steffen@typo3.org)
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 class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller_AbstractController {
29
30 /**
31 * Renders the review module user dependent with all workspaces.
32 * The module will show all records of one workspace.
33 *
34 * @return void
35 */
36 public function indexAction() {
37 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
38 $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
39 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
40 $this->view->assign('pageUid', t3lib_div::_GP('id'));
41 $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
42
43 $wsList = $wsService->getAvailableWorkspaces();
44 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
45 $performWorkspaceSwitch = FALSE;
46
47 if (!$GLOBALS['BE_USER']->isAdmin()) {
48 $wsCur = array($activeWorkspace => true);
49 $wsList = array_intersect_key($wsList, $wsCur);
50 } else {
51 $wsList = $wsService->getAvailableWorkspaces();
52 if (strlen(t3lib_div::_GP('workspace'))) {
53 $switchWs = (int) t3lib_div::_GP('workspace');
54 if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
55 $activeWorkspace = $switchWs;
56 $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
57 $performWorkspaceSwitch = TRUE;
58 t3lib_BEfunc::setUpdateSignal('updatePageTree');
59 } elseif ($switchWs == tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) {
60 $this->redirect('fullIndex');
61 }
62 }
63 }
64 $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
65 $this->view->assign('workspaceList', $wsList);
66 $this->view->assign('activeWorkspaceUid', $activeWorkspace);
67 $this->view->assign('activeWorkspaceTitle', tx_Workspaces_Service_Workspaces::getWorkspaceTitle($activeWorkspace));
68 $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink( t3lib_div::_GP('id'), $activeWorkspace));
69 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
70 }
71
72 /**
73 * Renders the review module for admins.
74 * The module will show all records of all workspaces.
75 *
76 * @return void
77 */
78 public function fullIndexAction() {
79 if (!$GLOBALS['BE_USER']->isAdmin()) {
80 $this->redirect('index');
81 } else {
82 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
83 $this->view->assign('pageUid', t3lib_div::_GP('id'));
84 $this->view->assign('showGrid', true);
85 $this->view->assign('showLegend', true);
86 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
87 $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
88 $this->view->assign('activeWorkspaceUid', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
89 $this->view->assign('showPreviewLink', FALSE);
90 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
91 // set flag for javascript
92 $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
93 }
94 }
95
96 /**
97 * Renders the review module for a single page. This is used within the
98 * workspace-preview frame.
99 *
100 * @return void
101 */
102 public function singleIndexAction() {
103
104 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
105 $wsList = $wsService->getAvailableWorkspaces();
106 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
107
108 $wsCur = array($activeWorkspace => true);
109 $wsList = array_intersect_key($wsList, $wsCur);
110
111 $this->view->assign('pageUid', t3lib_div::_GP('id'));
112 $this->view->assign('showGrid', true);
113 $this->view->assign('showAllWorkspaceTab', false);
114 $this->view->assign('workspaceList', $wsList);
115 $this->view->assign('backendDomain', t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'));
116 $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
117 }
118
119
120 /**
121 * Initializes the controller before invoking an action method.
122 *
123 * @return void
124 */
125 protected function initializeAction() {
126 parent::initializeAction();
127
128 if (tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
129 $message = t3lib_div::makeInstance(
130 't3lib_FlashMessage',
131 $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
132 '',
133 t3lib_FlashMessage::WARNING
134 );
135
136 t3lib_FlashMessageQueue::addMessage($message);
137 }
138
139 $this->pageRenderer->loadExtJS();
140 $this->pageRenderer->enableExtJSQuickTips();
141 $this->pageRenderer->enableExtJsDebug();
142
143 // Load JavaScript:
144 $this->pageRenderer->addExtDirectCode(array(
145 'TYPO3.Workspaces'
146 ));
147
148 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
149 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
150 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
151 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
152
153 $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
154
155 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
156 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
157
158 $jsFiles = array(
159 'gridfilters/menu/RangeMenu.js',
160 'gridfilters/menu/ListMenu.js',
161 'gridfilters/GridFilters.js',
162 'gridfilters/filter/Filter.js',
163 'gridfilters/filter/StringFilter.js',
164 'gridfilters/filter/DateFilter.js',
165 'gridfilters/filter/ListFilter.js',
166 'gridfilters/filter/NumericFilter.js',
167 'gridfilters/filter/BooleanFilter.js',
168 'gridfilters/filter/BooleanFilter.js',
169
170 'configuration.js',
171 'helpers.js',
172 'actions.js',
173 'component.js',
174 'toolbar.js',
175 'grid.js',
176 'workspaces.js',
177 );
178
179 foreach ($jsFiles as $jsFile) {
180 $this->pageRenderer->addJsFile($resourcePath . $jsFile);
181 }
182 }
183 }
184
185
186 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php'])) {
187 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
188 }
189
190 ?>