[BUGFIX] Make class name consistent
[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 /**
48 * Only admins see multiple tabs, we decided to use it this
49 * way for usability reasons. Regular users might be confused
50 * by switching workspaces with the tabs in a module.
51 */
52 if (!$GLOBALS['BE_USER']->isAdmin()) {
53 $wsCur = array($activeWorkspace => TRUE);
54 $wsList = array_intersect_key($wsList, $wsCur);
55 } else {
56 if (strlen(t3lib_div::_GP('workspace'))) {
57 $switchWs = (int) t3lib_div::_GP('workspace');
58 if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
59 $activeWorkspace = $switchWs;
60 $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
61 $performWorkspaceSwitch = TRUE;
62 t3lib_BEfunc::setUpdateSignal('updatePageTree');
63 } elseif ($switchWs == Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) {
64 $this->redirect('fullIndex');
65 }
66 }
67 }
68 $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', ($GLOBALS['BE_USER']->workspace == 0) ? TRUE : FALSE);
69 $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
70 $this->view->assign('workspaceList', $wsList);
71 $this->view->assign('activeWorkspaceUid', $activeWorkspace);
72 $this->view->assign('activeWorkspaceTitle', Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($activeWorkspace));
73 $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink( t3lib_div::_GP('id'), $activeWorkspace));
74 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
75 }
76
77 /**
78 * Renders the review module for admins.
79 * The module will show all records of all workspaces.
80 *
81 * @return void
82 */
83 public function fullIndexAction() {
84 if (!$GLOBALS['BE_USER']->isAdmin()) {
85 $this->redirect('index');
86 } else {
87 $wsService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
88 $this->view->assign('pageUid', t3lib_div::_GP('id'));
89 $this->view->assign('showGrid', TRUE);
90 $this->view->assign('showLegend', TRUE);
91 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
92 $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
93 $this->view->assign('activeWorkspaceUid', Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
94 $this->view->assign('showPreviewLink', FALSE);
95 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
96 // set flag for javascript
97 $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
98 }
99 }
100
101 /**
102 * Renders the review module for a single page. This is used within the
103 * workspace-preview frame.
104 *
105 * @return void
106 */
107 public function singleIndexAction() {
108
109 $wsService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
110 $wsList = $wsService->getAvailableWorkspaces();
111 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
112
113 $wsCur = array($activeWorkspace => TRUE);
114 $wsList = array_intersect_key($wsList, $wsCur);
115
116 $this->view->assign('pageUid', t3lib_div::_GP('id'));
117 $this->view->assign('showGrid', TRUE);
118 $this->view->assign('showAllWorkspaceTab', FALSE);
119 $this->view->assign('workspaceList', $wsList);
120 $this->view->assign('backendDomain', t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'));
121 $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
122 }
123
124
125 /**
126 * Initializes the controller before invoking an action method.
127 *
128 * @return void
129 */
130 protected function initializeAction() {
131 parent::initializeAction();
132
133 $this->template->setExtDirectStateProvider();
134
135 if (Tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
136 $message = t3lib_div::makeInstance(
137 't3lib_FlashMessage',
138 $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
139 '',
140 t3lib_FlashMessage::WARNING
141 );
142
143 t3lib_FlashMessageQueue::addMessage($message);
144 }
145
146 $this->pageRenderer->loadExtJS();
147 $this->pageRenderer->enableExtJSQuickTips();
148
149 $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
150 $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
151
152
153 // Load JavaScript:
154 $this->pageRenderer->addExtDirectCode(array(
155 'TYPO3.Workspaces'
156 ));
157
158 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
159 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
160 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
161 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
162
163 $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
164
165 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
166 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
167
168 $jsFiles = array(
169 'gridfilters/menu/RangeMenu.js',
170 'gridfilters/menu/ListMenu.js',
171 'gridfilters/GridFilters.js',
172 'gridfilters/filter/Filter.js',
173 'gridfilters/filter/StringFilter.js',
174 'gridfilters/filter/DateFilter.js',
175 'gridfilters/filter/ListFilter.js',
176 'gridfilters/filter/NumericFilter.js',
177 'gridfilters/filter/BooleanFilter.js',
178 'gridfilters/filter/BooleanFilter.js',
179 'Store/mainstore.js',
180
181 'configuration.js',
182 'helpers.js',
183 'actions.js',
184 'component.js',
185 'toolbar.js',
186 'grid.js',
187 'workspaces.js',
188 );
189
190 foreach ($jsFiles as $jsFile) {
191 $this->pageRenderer->addJsFile($resourcePath . $jsFile);
192 }
193 }
194 }
195
196
197 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php'])) {
198 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
199 }
200
201 ?>