TYPO3 API  SVNRelease
ReviewController.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2010-2011 Steffen Ritter (steffen@typo3.org)
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 
00028 class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller_AbstractController {
00029 
00030     /**
00031      * Renders the review module user dependent with all workspaces.
00032      * The module will show all records of one workspace.
00033      *
00034      * @return void
00035      */
00036     public function indexAction() {
00037         $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
00038         $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
00039         $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
00040         $this->view->assign('pageUid', t3lib_div::_GP('id'));
00041         $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
00042 
00043         $wsList = $wsService->getAvailableWorkspaces();
00044         $activeWorkspace = $GLOBALS['BE_USER']->workspace;
00045         $performWorkspaceSwitch = FALSE;
00046 
00047         if (!$GLOBALS['BE_USER']->isAdmin()) {
00048             $wsCur = array($activeWorkspace => true);
00049             $wsList = array_intersect_key($wsList, $wsCur);
00050         } else {
00051             $wsList = $wsService->getAvailableWorkspaces();
00052             if (strlen(t3lib_div::_GP('workspace'))) {
00053                 $switchWs = (int) t3lib_div::_GP('workspace');
00054                 if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
00055                     $activeWorkspace = $switchWs;
00056                     $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
00057                     $performWorkspaceSwitch = TRUE;
00058                     t3lib_BEfunc::setUpdateSignal('updatePageTree');
00059                 } elseif ($switchWs == tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) {
00060                     $this->redirect('fullIndex');
00061                 }
00062             }
00063         }
00064         $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
00065         $this->view->assign('workspaceList', $wsList);
00066         $this->view->assign('activeWorkspaceUid', $activeWorkspace);
00067         $this->view->assign('activeWorkspaceTitle', tx_Workspaces_Service_Workspaces::getWorkspaceTitle($activeWorkspace));
00068         $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
00069     }
00070 
00071     /**
00072      * Renders the review module for admins.
00073      * The module will show all records of all workspaces.
00074      *
00075      * @return void
00076      */
00077     public function fullIndexAction() {
00078         if (!$GLOBALS['BE_USER']->isAdmin()) {
00079             $this->redirect('index');
00080         } else {
00081             $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
00082             $this->view->assign('pageUid', t3lib_div::_GP('id'));
00083             $this->view->assign('showGrid', true);
00084             $this->view->assign('showLegend', true);
00085             $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
00086             $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
00087             $this->view->assign('activeWorkspaceUid', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
00088             $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
00089                 // set flag for javascript
00090             $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
00091         }
00092     }
00093 
00094     /**
00095      * Renders the review module for a single page. This is used within the
00096      * workspace-preview frame.
00097      *
00098      * @return void
00099      */
00100     public function singleIndexAction() {
00101 
00102         $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
00103         $wsList = $wsService->getAvailableWorkspaces();
00104         $activeWorkspace = $GLOBALS['BE_USER']->workspace;
00105 
00106         $wsCur = array($activeWorkspace => true);
00107         $wsList = array_intersect_key($wsList, $wsCur);
00108 
00109         $this->view->assign('pageUid', t3lib_div::_GP('id'));
00110         $this->view->assign('showGrid', true);
00111         $this->view->assign('showAllWorkspaceTab', false);
00112         $this->view->assign('workspaceList', $wsList);
00113         $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
00114     }
00115 
00116 
00117     /**
00118      * Initializes the controller before invoking an action method.
00119      *
00120      * @return void
00121      */
00122     protected function initializeAction() {
00123         parent::initializeAction();
00124 
00125         if (tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
00126             $message = t3lib_div::makeInstance(
00127                 't3lib_FlashMessage',
00128                 $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
00129                 '',
00130                 t3lib_FlashMessage::WARNING
00131             );
00132 
00133             t3lib_FlashMessageQueue::addMessage($message);
00134         }
00135 
00136         $this->pageRenderer->loadExtJS();
00137         $this->pageRenderer->enableExtJSQuickTips();
00138         $this->pageRenderer->enableExtJsDebug();
00139 
00140             // Load  JavaScript:
00141         $this->pageRenderer->addExtDirectCode();
00142         $this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Workspaces&' . TYPO3_version, NULL, FALSE);
00143 
00144         $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
00145         $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
00146         $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
00147         $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
00148 
00149         $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
00150 
00151         $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
00152         $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
00153 
00154         $jsFiles = array(
00155             'gridfilters/menu/RangeMenu.js',
00156             'gridfilters/menu/ListMenu.js',
00157             'gridfilters/GridFilters.js',
00158             'gridfilters/filter/Filter.js',
00159             'gridfilters/filter/StringFilter.js',
00160             'gridfilters/filter/DateFilter.js',
00161             'gridfilters/filter/ListFilter.js',
00162             'gridfilters/filter/NumericFilter.js',
00163             'gridfilters/filter/BooleanFilter.js',
00164             'gridfilters/filter/BooleanFilter.js',
00165 
00166             'configuration.js',
00167             'helpers.js',
00168             'actions.js',
00169             'component.js',
00170             'toolbar.js',
00171             'grid.js',
00172             'workspaces.js',
00173         );
00174 
00175         foreach ($jsFiles as $jsFile) {
00176             $this->pageRenderer->addJsFile($resourcePath . $jsFile);
00177         }
00178     }
00179 }
00180 
00181 
00182 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php'])) {
00183     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
00184 }
00185 
00186 ?>