Fixed bug #12415: Respect change #17167: Cache ExtDirect::getAPI calls
[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 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
69 }
70
71 /**
72 * Renders the review module for admins.
73 * The module will show all records of all workspaces.
74 *
75 * @return void
76 */
77 public function fullIndexAction() {
78 if (!$GLOBALS['BE_USER']->isAdmin()) {
79 $this->redirect('index');
80 } else {
81 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
82 $this->view->assign('pageUid', t3lib_div::_GP('id'));
83 $this->view->assign('showGrid', true);
84 $this->view->assign('showLegend', true);
85 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
86 $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
87 $this->view->assign('activeWorkspaceUid', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
88 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
89 // set flag for javascript
90 $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
91 }
92 }
93
94 /**
95 * Renders the review module for a single page. This is used within the
96 * workspace-preview frame.
97 *
98 * @return void
99 */
100 public function singleIndexAction() {
101
102 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
103 $wsList = $wsService->getAvailableWorkspaces();
104 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
105
106 $wsCur = array($activeWorkspace => true);
107 $wsList = array_intersect_key($wsList, $wsCur);
108
109 $this->view->assign('pageUid', t3lib_div::_GP('id'));
110 $this->view->assign('showGrid', true);
111 $this->view->assign('showAllWorkspaceTab', false);
112 $this->view->assign('workspaceList', $wsList);
113 $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
114 }
115
116
117 /**
118 * Initializes the controller before invoking an action method.
119 *
120 * @return void
121 */
122 protected function initializeAction() {
123 parent::initializeAction();
124
125 if (tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
126 $message = t3lib_div::makeInstance(
127 't3lib_FlashMessage',
128 $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
129 '',
130 t3lib_FlashMessage::WARNING
131 );
132
133 t3lib_FlashMessageQueue::addMessage($message);
134 }
135
136 $this->pageRenderer->loadExtJS();
137 $this->pageRenderer->enableExtJSQuickTips();
138 $this->pageRenderer->enableExtJsDebug();
139
140 // Load JavaScript:
141 $this->pageRenderer->addExtDirectCode();
142 $this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Workspaces&' . TYPO3_version, NULL, FALSE);
143
144 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
145 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
146 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
147 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
148
149 $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
150
151 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
152 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
153
154 $jsFiles = array(
155 'gridfilters/menu/RangeMenu.js',
156 'gridfilters/menu/ListMenu.js',
157 'gridfilters/GridFilters.js',
158 'gridfilters/filter/Filter.js',
159 'gridfilters/filter/StringFilter.js',
160 'gridfilters/filter/DateFilter.js',
161 'gridfilters/filter/ListFilter.js',
162 'gridfilters/filter/NumericFilter.js',
163 'gridfilters/filter/BooleanFilter.js',
164 'gridfilters/filter/BooleanFilter.js',
165
166 'configuration.js',
167 'helpers.js',
168 'actions.js',
169 'component.js',
170 'toolbar.js',
171 'grid.js',
172 'workspaces.js',
173 );
174
175 foreach ($jsFiles as $jsFile) {
176 $this->pageRenderer->addJsFile($resourcePath . $jsFile);
177 }
178 }
179 }
180
181
182 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php'])) {
183 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
184 }
185
186 ?>