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