[TASK][WIP] Move non class code back to source files
authorThomas Maroschik <tmaroschik@dfau.de>
Wed, 17 Oct 2012 19:51:19 +0000 (21:51 +0200)
committerThomas Maroschik <tmaroschik@dfau.de>
Wed, 17 Oct 2012 19:51:19 +0000 (21:51 +0200)
Change-Id: I037a6322ad55b34545df429659d77041e1f58278

40 files changed:
typo3/sysext/workspaces/Classes/Controller/AbstractController.php
typo3/sysext/workspaces/Classes/Controller/PreviewController.php
typo3/sysext/workspaces/Classes/Controller/ReviewController.php
typo3/sysext/workspaces/Classes/Domain/Model/CombinedRecord.php
typo3/sysext/workspaces/Classes/Domain/Model/DatabaseRecord.php
typo3/sysext/workspaces/Classes/ExtDirect/AbstractHandler.php
typo3/sysext/workspaces/Classes/ExtDirect/ActionHandler.php
typo3/sysext/workspaces/Classes/ExtDirect/ExtDirectServer.php
typo3/sysext/workspaces/Classes/ExtDirect/MassActionHandler.php
typo3/sysext/workspaces/Classes/ExtDirect/PagetreeCollectionsProcessor.php
typo3/sysext/workspaces/Classes/ExtDirect/Server.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/ExtDirect/ToolbarMenu.php
typo3/sysext/workspaces/Classes/ExtDirect/WorkspaceSelectorToolbarItem.php
typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
typo3/sysext/workspaces/Classes/Hook/TypoScriptFrontendControllerHook.php
typo3/sysext/workspaces/Classes/Service/AutoPublish.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/AutoPublishService.php
typo3/sysext/workspaces/Classes/Service/AutoPublishTask.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/Befunc.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/Fehooks.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/GridData.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/GridDataService.php
typo3/sysext/workspaces/Classes/Service/History.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/HistoryService.php
typo3/sysext/workspaces/Classes/Service/Integrity.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/IntegrityService.php
typo3/sysext/workspaces/Classes/Service/Stages.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/StagesService.php
typo3/sysext/workspaces/Classes/Service/Tcemain.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Service/WorkspaceService.php
typo3/sysext/workspaces/Classes/Service/Workspaces.php [new file with mode: 0644]
typo3/sysext/workspaces/Classes/Task/AutoPublishTask.php
typo3/sysext/workspaces/Classes/Task/CleanupPreviewLinkTask.php
typo3/sysext/workspaces/ext_autoload.php
typo3/sysext/workspaces/ext_emconf.php
typo3/sysext/workspaces/ext_localconf.php
typo3/sysext/workspaces/ext_tables.php
typo3/sysext/workspaces/tca.php

index 659b6db..a0fce64 100644 (file)
@@ -24,9 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
-require_once(PATH_site . TYPO3_mainDir . 'template.php');
-
+require_once (PATH_site . TYPO3_mainDir) . 'template.php';
 /**
  * Abstract action controller.
  *
@@ -35,6 +33,7 @@ require_once(PATH_site . TYPO3_mainDir . 'template.php');
  * @subpackage Controller
  */
 class Tx_Workspaces_Controller_AbstractController extends Tx_Extbase_MVC_Controller_ActionController {
+
        /**
         * @var string Key of the extension this controller belongs to
         */
@@ -58,36 +57,31 @@ class Tx_Workspaces_Controller_AbstractController extends Tx_Extbase_MVC_Control
        protected function initializeAction() {
                // @todo Evaluate how the intval() call can be used with Extbase validators/filters
                $this->pageId = intval(t3lib_div::_GP('id'));
-
                $icons = array(
                        'language' => t3lib_iconWorks::getSpriteIconClasses('flags-multiple'),
                        'integrity' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-information'),
                        'success' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-ok'),
                        'info' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-information'),
                        'warning' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-warning'),
-                       'error' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-error'),
+                       'error' => t3lib_iconWorks::getSpriteIconClasses('status-dialog-error')
                );
-
                $this->pageRenderer->addInlineSetting('Workspaces', 'icons', $icons);
                $this->pageRenderer->addInlineSetting('Workspaces', 'id', $this->pageId);
-               $this->pageRenderer->addInlineSetting('Workspaces', 'depth', ($this->pageId === 0 ? 999 : 1));
+               $this->pageRenderer->addInlineSetting('Workspaces', 'depth', $this->pageId === 0 ? 999 : 1);
                $this->pageRenderer->addInlineSetting('Workspaces', 'language', $this->getLanguageSelection());
-
                $this->pageRenderer->addCssFile(t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/StyleSheet/module.css');
-
                $this->pageRenderer->addInlineLanguageLabelArray(array(
-                       'title'                 => $GLOBALS['LANG']->getLL('title'),
-                       'path'                  => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path'),
-                       'table'                 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table'),
-                       'depth'                 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'),
-                       'depth_0'               => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'),
-                       'depth_1'               => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'),
-                       'depth_2'               => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'),
-                       'depth_3'               => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'),
-                       'depth_4'               => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'),
-                       'depth_infi'    => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'),
+                       'title' => $GLOBALS['LANG']->getLL('title'),
+                       'path' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path'),
+                       'table' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table'),
+                       'depth' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'),
+                       'depth_0' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'),
+                       'depth_1' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'),
+                       'depth_2' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'),
+                       'depth_3' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'),
+                       'depth_4' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'),
+                       'depth_infi' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi')
                ));
-
                $this->pageRenderer->addInlineLanguageLabelFile('EXT:workspaces/Resources/Private/Language/locallang.xml');
        }
 
@@ -102,18 +96,12 @@ class Tx_Workspaces_Controller_AbstractController extends Tx_Extbase_MVC_Control
        public function processRequest(Tx_Extbase_MVC_RequestInterface $request, Tx_Extbase_MVC_ResponseInterface $response) {
                $this->template = t3lib_div::makeInstance('template');
                $this->pageRenderer = $this->template->getPageRenderer();
-
                $GLOBALS['SOBE'] = new stdClass();
                $GLOBALS['SOBE']->doc = $this->template;
-
                parent::processRequest($request, $response);
-
-               $pageHeader = $this->template->startpage(
-                       $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:module.title')
-               );
+               $pageHeader = $this->template->startpage($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:module.title'));
                $pageEnd = $this->template->endPage();
-
-               $response->setContent($pageHeader . $response->getContent() . $pageEnd);
+               $response->setContent(($pageHeader . $response->getContent()) . $pageEnd);
        }
 
        /**
@@ -123,12 +111,12 @@ class Tx_Workspaces_Controller_AbstractController extends Tx_Extbase_MVC_Control
         */
        protected function getLanguageSelection() {
                $language = 'all';
-
                if (isset($GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['language'])) {
                        $language = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['language'];
                }
-
                return $language;
        }
+
 }
+
 ?>
\ No newline at end of file
index b646acc..55251ba 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Implements the preview controller of the workspace module.
  *
@@ -54,43 +53,32 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                $this->stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
                $this->workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
                $this->template->setExtDirectStateProvider();
-
                $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/StyleSheet/preview.css';
                $GLOBALS['TBE_STYLES']['extJS']['theme'] = $resourcePath;
-
                $this->pageRenderer->loadExtJS();
                $this->pageRenderer->enableExtJSQuickTips();
-
-                       // Load  JavaScript:
+               // Load  JavaScript:
                $this->pageRenderer->addExtDirectCode(array(
                        'TYPO3.Workspaces',
                        'TYPO3.ExtDirectStateProvider'
                ));
-
                $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
                $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
-
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/notifications.js');
-
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
                $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/iframepanel.js');
-
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/notifications.js');
-
                $resourcePathJavaScript = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
-
                $jsFiles = array(
                        'Ext.ux.plugins.TabStripContainer.js',
                        'Store/mainstore.js',
                        'helpers.js',
-                       'actions.js',
+                       'actions.js'
                );
-
                foreach ($jsFiles as $jsFile) {
                        $this->pageRenderer->addJsFile($resourcePathJavaScript . $jsFile);
                }
-
-                       // todo this part should be done with inlineLocallanglabels
+               // todo this part should be done with inlineLocallanglabels
                $this->pageRenderer->addJsInlineCode('workspace-inline-code', $this->generateJavascript());
        }
 
@@ -100,24 +88,20 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
         * only the frames-urls we've to generate here
         *
         * @param integer $previewWS
-        *
         * @return void
         */
        public function indexAction($previewWS = NULL) {
                // @todo language doesn't always come throught the L parameter
                // @todo Evaluate how the intval() call can be used with Extbase validators/filters
                $language = intval(t3lib_div::_GP('L'));
-
-                       // fetch the next and previous stage
-               $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $this->pageId, $recursionLevel = 0, $selectionType = 'tables_modify');
+               // fetch the next and previous stage
+               $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $this->pageId, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
                list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray);
                list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray);
-
                /** @var $wsService Tx_Workspaces_Service_Workspaces */
                $wsService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
                $wsList = $wsService->getAvailableWorkspaces();
                $activeWorkspace = $GLOBALS['BE_USER']->workspace;
-
                if (!is_null($previewWS)) {
                        if (in_array($previewWS, array_keys($wsList)) && $activeWorkspace != $previewWS) {
                                $activeWorkspace = $previewWS;
@@ -125,31 +109,26 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                                t3lib_BEfunc::setUpdateSignal('updatePageTree');
                        }
                }
-
                /** @var $uriBuilder Tx_Extbase_MVC_Web_Routing_UriBuilder */
                $uriBuilder = $this->objectManager->create('Tx_Extbase_MVC_Web_Routing_UriBuilder');
-
                $wsSettingsPath = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
                $wsSettingsUri = $uriBuilder->uriFor('singleIndex', array(), 'Tx_Workspaces_Controller_ReviewController', 'workspaces', 'web_workspacesworkspaces');
                $wsSettingsParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Review';
-               $wsSettingsUrl = $wsSettingsPath . $wsSettingsUri . $wsSettingsParams;
-
+               $wsSettingsUrl = ($wsSettingsPath . $wsSettingsUri) . $wsSettingsParams;
                $viewDomain = t3lib_BEfunc::getViewDomain($this->pageId);
-               $wsBaseUrl =  $viewDomain . '/index.php?id=' . $this->pageId . '&L=' . $language;
-
+               $wsBaseUrl = ((($viewDomain . '/index.php?id=') . $this->pageId) . '&L=') . $language;
                // @todo - handle new pages here
                // branchpoints are not handled anymore because this feature is not supposed anymore
                if (Tx_Workspaces_Service_Workspaces::isNewPage($this->pageId)) {
                        $wsNewPageUri = $uriBuilder->uriFor('newPage', array(), 'Tx_Workspaces_Controller_PreviewController', 'workspaces', 'web_workspacesworkspaces');
                        $wsNewPageParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Preview';
-                       $this->view->assign('liveUrl', $wsSettingsPath . $wsNewPageUri . $wsNewPageParams);
+                       $this->view->assign('liveUrl', ($wsSettingsPath . $wsNewPageUri) . $wsNewPageParams);
                } else {
                        $this->view->assign('liveUrl', $wsBaseUrl . '&ADMCMD_noBeUser=1');
                }
-               $this->view->assign('wsUrl', $wsBaseUrl . '&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=' . $GLOBALS['BE_USER']->workspace);
+               $this->view->assign('wsUrl', ($wsBaseUrl . '&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=') . $GLOBALS['BE_USER']->workspace);
                $this->view->assign('wsSettingsUrl', $wsSettingsUrl);
                $this->view->assign('backendDomain', t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'));
-
                $splitPreviewTsConfig = t3lib_BEfunc::getModTSconfig($this->pageId, 'workspaces.splitPreviewModes');
                $splitPreviewModes = t3lib_div::trimExplode(',', $splitPreviewTsConfig['value']);
                $allPreviewModes = array('slider', 'vbox', 'hbox');
@@ -157,30 +136,28 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                        $splitPreviewModes = $allPreviewModes;
                }
                $this->pageRenderer->addInlineSetting('Workspaces', 'SplitPreviewModes', $splitPreviewModes);
-
                $GLOBALS['BE_USER']->setAndSaveSessionData('workspaces.backend_domain', t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'));
-
                $this->pageRenderer->addInlineSetting('Workspaces', 'disableNextStageButton', $this->isInvalidStage($nextStage));
                $this->pageRenderer->addInlineSetting('Workspaces', 'disablePreviousStageButton', $this->isInvalidStage($previousStage));
                $this->pageRenderer->addInlineSetting('Workspaces', 'disableDiscardStageButton', $this->isInvalidStage($nextStage) && $this->isInvalidStage($previousStage));
                $resourcePath = t3lib_extMgm::extRelPath('lang') . 'res/js/be/';
                $this->pageRenderer->addJsFile($resourcePath . 'typo3lang.js');
-               $this->pageRenderer->addJsInlineCode('workspaces.preview.lll', "
+               $this->pageRenderer->addJsInlineCode('workspaces.preview.lll', ((((((((((((((((((((((('
                TYPO3.lang = {
-                       visualPreview: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.visualPreview', TRUE) . "',
-                       listView: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.listView', TRUE) . "',
-                       livePreview: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.livePreview', TRUE) . "',
-                       livePreviewDetail: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.livePreviewDetail', TRUE) . "',
-                       workspacePreview: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.workspacePreview', TRUE) . "',
-                       workspacePreviewDetail: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.workspacePreviewDetail', TRUE) . "',
-                       modeSlider: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeSlider', TRUE) . "',
-                       modeVbox: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeVbox', TRUE) . "',
-                       modeHbox: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeHbox', TRUE) . "',
-                       discard: '" . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:label_doaction_discard', TRUE) . "',
-                       nextStage: '" . $nextStage['title'] . "',
-                       previousStage: '" . $previousStage['title'] . "'
-               };TYPO3.l10n.initialize();\n");
-
+                       visualPreview: \'' . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.visualPreview', TRUE)) . '\',
+                       listView: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.listView', TRUE)) . '\',
+                       livePreview: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.livePreview', TRUE)) . '\',
+                       livePreviewDetail: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.livePreviewDetail', TRUE)) . '\',
+                       workspacePreview: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.workspacePreview', TRUE)) . '\',
+                       workspacePreviewDetail: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.workspacePreviewDetail', TRUE)) . '\',
+                       modeSlider: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeSlider', TRUE)) . '\',
+                       modeVbox: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeVbox', TRUE)) . '\',
+                       modeHbox: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:preview.modeHbox', TRUE)) . '\',
+                       discard: \'') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:label_doaction_discard', TRUE)) . '\',
+                       nextStage: \'') . $nextStage['title']) . '\',
+                       previousStage: \'') . $previousStage['title']) . '\'
+               };TYPO3.l10n.initialize();
+');
                $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/';
                $this->pageRenderer->addJsFile($resourcePath . 'JavaScript/preview.js');
        }
@@ -190,7 +167,6 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
         *
         * @param array $stageArray
         * @return boolean
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        protected function isInvalidStage($stageArray) {
@@ -201,12 +177,7 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
         * @return void
         */
        public function newPageAction() {
-               $message = t3lib_div::makeInstance(
-                       't3lib_FlashMessage',
-                       $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage.detail'),
-                       $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage'),
-                       t3lib_FlashMessage::INFO
-               );
+               $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage.detail'), $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage'), t3lib_FlashMessage::INFO);
                t3lib_FlashMessageQueue::addMessage($message);
        }
 
@@ -215,30 +186,26 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
         * and since we're loading a backend module outside of the actual backend
         * this copies parts of the backend.php
         *
-        * @return      string
+        * @return      string
         */
        protected function generateJavascript() {
                $pathTYPO3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/';
-
-                       // If another page module was specified, replace the default Page module with the new one
+               // If another page module was specified, replace the default Page module with the new one
                $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
                $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
                if (!$GLOBALS['BE_USER']->check('modules', $pageModule)) {
                        $pageModule = '';
                }
-
                $menuFrameName = 'menu';
                if ($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
                        $menuFrameName = 'topmenuFrame';
                }
-
-                       // determine security level from conf vars and default to super challenged
+               // determine security level from conf vars and default to super challenged
                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
                        $loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
                } else {
                        $loginSecurityLevel = 'superchallenged';
                }
-
                $t3Configuration = array(
                        'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
                        'PATH_typo3' => $pathTYPO3,
@@ -248,24 +215,23 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                        'securityLevel' => $this->loginSecurityLevel,
                        'TYPO3_mainDir' => TYPO3_mainDir,
                        'pageModule' => $pageModule,
-                       'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
+                       'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0,
                        'inWorkspace' => $GLOBALS['BE_USER']->workspace !== 0 ? 1 : 0,
                        'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->user['workspace_preview'] ? 1 : 0,
                        'veriCode' => $GLOBALS['BE_USER']->veriCode(),
                        'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
                        'moduleMenuWidth' => $this->menuWidth - 1,
-                       'topBarHeight' => (isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ? intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30),
+                       'topBarHeight' => isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ? intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30,
                        'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
                        'listModulePath' => t3lib_extMgm::isLoaded('recordlist') ? t3lib_extMgm::extRelPath('recordlist') . 'mod1/' : '',
                        'debugInWindow' => $GLOBALS['BE_USER']->uc['debugInWindow'] ? 1 : 0,
                        'ContextHelpWindows' => array(
                                'width' => 600,
                                'height' => 400
-                       ),
+                       )
                );
-
                $t3LLLcore = array(
-                       'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
+                       'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in'),
                        'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
                        'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
                        'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user['username'])),
@@ -292,13 +258,12 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                        'donateWindow_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.message'),
                        'donateWindow_button_donate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_donate'),
                        'donateWindow_button_disable' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_disable'),
-                       'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone'),
+                       'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone')
                );
-
-               $js = '
-               TYPO3.configuration = ' . json_encode($t3Configuration) . ';
+               $js = ((('
+               TYPO3.configuration = ' . json_encode($t3Configuration)) . ';
                TYPO3.LLL = {
-                       core : ' . json_encode($t3LLLcore) . '
+                       core : ') . json_encode($t3LLLcore)) . '
                };
 
                /**
@@ -319,5 +284,7 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
                ';
                return $js;
        }
+
 }
+
 ?>
\ No newline at end of file
index e190117..5adcd7a 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Review controller.
  *
@@ -46,16 +45,12 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
                $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
                $this->view->assign('pageUid', t3lib_div::_GP('id'));
                $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
-
                $wsList = $wsService->getAvailableWorkspaces();
                $activeWorkspace = $GLOBALS['BE_USER']->workspace;
                $performWorkspaceSwitch = FALSE;
-
-                       /**
-                        * Only admins see multiple tabs, we decided to use it this
-                        * way for usability reasons. Regular users might be confused
-                        * by switching workspaces with the tabs in a module.
-                        */
+               /** Only admins see multiple tabs, we decided to use it this
+               way for usability reasons. Regular users might be confused
+               by switching workspaces with the tabs in a module. */
                if (!$GLOBALS['BE_USER']->isAdmin()) {
                        $wsCur = array($activeWorkspace => TRUE);
                        $wsList = array_intersect_key($wsList, $wsCur);
@@ -72,12 +67,12 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
                                }
                        }
                }
-               $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', ($GLOBALS['BE_USER']->workspace == 0) ? TRUE : FALSE);
+               $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', $GLOBALS['BE_USER']->workspace == 0 ? TRUE : FALSE);
                $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
                $this->view->assign('workspaceList', $wsList);
                $this->view->assign('activeWorkspaceUid', $activeWorkspace);
                $this->view->assign('activeWorkspaceTitle', Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($activeWorkspace));
-               $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink( t3lib_div::_GP('id'), $activeWorkspace));
+               $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink(t3lib_div::_GP('id'), $activeWorkspace));
                $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
        }
 
@@ -100,7 +95,7 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
                        $this->view->assign('activeWorkspaceUid', Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
                        $this->view->assign('showPreviewLink', FALSE);
                        $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
-                               // set flag for javascript
+                       // set flag for javascript
                        $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
                }
        }
@@ -112,14 +107,11 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
         * @return void
         */
        public function singleIndexAction() {
-
                $wsService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
                $wsList = $wsService->getAvailableWorkspaces();
                $activeWorkspace = $GLOBALS['BE_USER']->workspace;
-
                $wsCur = array($activeWorkspace => TRUE);
                $wsList = array_intersect_key($wsList, $wsCur);
-
                $this->view->assign('pageUid', t3lib_div::_GP('id'));
                $this->view->assign('showGrid', TRUE);
                $this->view->assign('showAllWorkspaceTab', FALSE);
@@ -128,7 +120,6 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
                $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
        }
 
-
        /**
         * Initializes the controller before invoking an action method.
         *
@@ -136,41 +127,26 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
         */
        protected function initializeAction() {
                parent::initializeAction();
-
                $this->template->setExtDirectStateProvider();
-
                if (Tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
-                       $message = t3lib_div::makeInstance(
-                               't3lib_FlashMessage',
-                               $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
-                               '',
-                               t3lib_FlashMessage::WARNING
-                       );
-
+                       $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'), '', t3lib_FlashMessage::WARNING);
                        t3lib_FlashMessageQueue::addMessage($message);
                }
-
                $this->pageRenderer->loadExtJS();
                $this->pageRenderer->enableExtJSQuickTips();
-
                $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
                $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
-
-                       // Load  JavaScript:
+               // Load  JavaScript:
                $this->pageRenderer->addExtDirectCode(array(
                        'TYPO3.Workspaces'
                ));
-
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
                $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
-
                $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
-
                $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
                $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
-
                $jsFiles = array(
                        'gridfilters/menu/RangeMenu.js',
                        'gridfilters/menu/ListMenu.js',
@@ -183,19 +159,19 @@ class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller
                        'gridfilters/filter/BooleanFilter.js',
                        'gridfilters/filter/BooleanFilter.js',
                        'Store/mainstore.js',
-
                        'configuration.js',
                        'helpers.js',
                        'actions.js',
                        'component.js',
                        'toolbar.js',
                        'grid.js',
-                       'workspaces.js',
+                       'workspaces.js'
                );
-
                foreach ($jsFiles as $jsFile) {
                        $this->pageRenderer->addJsFile($resourcePath . $jsFile);
                }
        }
+
 }
+
 ?>
\ No newline at end of file
index 33b70b5..de0f272 100644 (file)
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * @author Oliver Hader <oliver.hader@typo3.org>
  * @package Workspaces
  * @subpackage Domain
  */
 class Tx_Workspaces_Domain_Model_CombinedRecord {
+
        /**
         * @var string
         */
@@ -54,14 +54,10 @@ class Tx_Workspaces_Domain_Model_CombinedRecord {
         * @param integer $versionId Id of the datbase version-record row
         * @return Tx_Workspaces_Domain_Model_CombinedRecord
         */
-       public static function create($table, $liveId, $versionId) {
+       static public function create($table, $liveId, $versionId) {
                $liveRecord = Tx_Workspaces_Domain_Model_DatabaseRecord::create($table, $liveId);
                $versionRecord = Tx_Workspaces_Domain_Model_DatabaseRecord::create($table, $versionId);
-
-               return t3lib_div::makeInstance(
-                       'Tx_Workspaces_Domain_Model_CombinedRecord',
-                       $table, $liveRecord, $versionRecord
-               );
+               return t3lib_div::makeInstance('Tx_Workspaces_Domain_Model_CombinedRecord', $table, $liveRecord, $versionRecord);
        }
 
        /**
@@ -72,14 +68,10 @@ class Tx_Workspaces_Domain_Model_CombinedRecord {
         * @param array $versionRow The relevant database version-record row
         * @return Tx_Workspaces_Domain_Model_CombinedRecord
         */
-       public static function createFromArrays($table, array $liveRow, array $versionRow) {
+       static public function createFromArrays($table, array $liveRow, array $versionRow) {
                $liveRecord = Tx_Workspaces_Domain_Model_DatabaseRecord::createFromArray($table, $liveRow);
                $versionRecord = Tx_Workspaces_Domain_Model_DatabaseRecord::createFromArray($table, $versionRow);
-
-               return t3lib_div::makeInstance(
-                       'Tx_Workspaces_Domain_Model_CombinedRecord',
-                       $table, $liveRecord, $versionRecord
-               );
+               return t3lib_div::makeInstance('Tx_Workspaces_Domain_Model_CombinedRecord', $table, $liveRecord, $versionRecord);
        }
 
        /**
@@ -169,5 +161,7 @@ class Tx_Workspaces_Domain_Model_CombinedRecord {
        public function getVersiondId() {
                return $this->getVersionRecord()->getUid();
        }
+
 }
+
 ?>
\ No newline at end of file
index d627695..38a33d1 100644 (file)
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * @author Oliver Hader <oliver.hader@typo3.org>
  * @package Workspaces
  * @subpackage Domain
  */
 class Tx_Workspaces_Domain_Model_DatabaseRecord {
+
        /**
         * @var string
         */
@@ -53,11 +53,8 @@ class Tx_Workspaces_Domain_Model_DatabaseRecord {
         * @param integer $uid Id of the datbase record row
         * @return Tx_Workspaces_Domain_Model_DatabaseRecord
         */
-       public static function create($table, $uid) {
-               return t3lib_div::makeInstance(
-                       'Tx_Workspaces_Domain_Model_DatabaseRecord',
-                       $table, $uid
-               );
+       static public function create($table, $uid) {
+               return t3lib_div::makeInstance('Tx_Workspaces_Domain_Model_DatabaseRecord', $table, $uid);
        }
 
        /**
@@ -67,11 +64,8 @@ class Tx_Workspaces_Domain_Model_DatabaseRecord {
         * @param array $row The relevant database record row
         * @return Tx_Workspaces_Domain_Model_DatabaseRecord
         */
-       public static function createFromArray($table, array $row) {
-               return t3lib_div::makeInstance(
-                       'Tx_Workspaces_Domain_Model_DatabaseRecord',
-                       $table, $row['uid'], $row
-               );
+       static public function createFromArray($table, array $row) {
+               return t3lib_div::makeInstance('Tx_Workspaces_Domain_Model_DatabaseRecord', $table, $row['uid'], $row);
        }
 
        /**
@@ -82,7 +76,6 @@ class Tx_Workspaces_Domain_Model_DatabaseRecord {
        public function __construct($table, $uid, array $row = NULL) {
                $this->setTable($table);
                $this->setUid($uid);
-
                if ($row !== NULL) {
                        $this->setRow($row);
                }
@@ -152,10 +145,7 @@ class Tx_Workspaces_Domain_Model_DatabaseRecord {
         * @return string
         */
        public function getIdentifier() {
-               return implode(
-                       ':',
-                       array($this->getTable(), $this->getUid())
-               );
+               return implode(':', array($this->getTable(), $this->getUid()));
        }
 
        /**
@@ -165,11 +155,10 @@ class Tx_Workspaces_Domain_Model_DatabaseRecord {
         */
        protected function loadRow() {
                if ($this->row === NULL) {
-                       $this->row = t3lib_BEfunc::getRecord(
-                               $this->getTable(),
-                               $this->getUid()
-                       );
+                       $this->row = t3lib_BEfunc::getRecord($this->getTable(), $this->getUid());
                }
        }
+
 }
+
 ?>
\ No newline at end of file
index ed65647..c9642a9 100644 (file)
@@ -1,30 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * Abstract ExtDirect handler
  *
@@ -33,6 +32,7 @@
  * @subpackage ExtDirect
  */
 abstract class Tx_Workspaces_ExtDirect_AbstractHandler {
+
        /**
         * Gets the current workspace ID.
         *
@@ -52,15 +52,13 @@ abstract class Tx_Workspaces_ExtDirect_AbstractHandler {
         */
        protected function getErrorResponse($errorLabel, $errorCode = 0, $successFlagValue = FALSE) {
                $localLangFile = 'LLL:EXT:workspaces/Resources/Private/Language/locallang.xml';
-
                $response = array(
                        'error' => array(
                                'code' => $errorCode,
-                               'message' => $GLOBALS['LANG']->sL($localLangFile . ':' . $errorLabel),
+                               'message' => $GLOBALS['LANG']->sL(($localLangFile . ':') . $errorLabel)
                        ),
-                       'success' => $successFlagValue,
+                       'success' => $successFlagValue
                );
-
                return $response;
        }
 
@@ -82,11 +80,9 @@ abstract class Tx_Workspaces_ExtDirect_AbstractHandler {
         */
        protected function validateLanguageParameter(stdClass $parameters) {
                $language = NULL;
-
                if (isset($parameters->language) && t3lib_utility_Math::canBeInterpretedAsInteger($parameters->language)) {
                        $language = $parameters->language;
                }
-
                return $language;
        }
 
@@ -101,36 +97,20 @@ abstract class Tx_Workspaces_ExtDirect_AbstractHandler {
         */
        protected function getAffectedElements(stdClass $parameters) {
                $affectedElements = array();
-
                if ($parameters->type === 'selection') {
                        foreach ((array) $parameters->selection as $element) {
-                               $affectedElements[] = Tx_Workspaces_Domain_Model_CombinedRecord::create(
-                                       $element->table,
-                                       $element->liveId,
-                                       $element->versionId
-                               );
+                               $affectedElements[] = Tx_Workspaces_Domain_Model_CombinedRecord::create($element->table, $element->liveId, $element->versionId);
                        }
                } elseif ($parameters->type === 'all') {
-                       $versions = $this->getWorkspaceService()->selectVersionsInWorkspace(
-                               $this->getCurrentWorkspace(),
-                               0, -99, -1, 0, 'tables_select',
-                               $this->validateLanguageParameter($parameters)
-                       );
-
+                       $versions = $this->getWorkspaceService()->selectVersionsInWorkspace($this->getCurrentWorkspace(), 0, -99, -1, 0, 'tables_select', $this->validateLanguageParameter($parameters));
                        foreach ($versions as $table => $tableElements) {
                                foreach ($tableElements as $element) {
-                                       $affectedElement = Tx_Workspaces_Domain_Model_CombinedRecord::create(
-                                               $table,
-                                               $element['t3ver_oid'],
-                                               $element['uid']
-                                       );
-
+                                       $affectedElement = Tx_Workspaces_Domain_Model_CombinedRecord::create($table, $element['t3ver_oid'], $element['uid']);
                                        $affectedElement->getVersionRecord()->setRow($element);
                                        $affectedElements[] = $affectedElement;
                                }
                        }
                }
-
                return $affectedElements;
        }
 
@@ -148,5 +128,7 @@ abstract class Tx_Workspaces_ExtDirect_AbstractHandler {
                $integrityService->setAffectedElements($affectedElements);
                return $integrityService;
        }
+
 }
+
 ?>
\ No newline at end of file
index c81c39c..0e259f4 100644 (file)
@@ -1,30 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * ExtDirect action handler
  *
@@ -63,7 +62,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         * @param integer $t3ver_oid
         * @param integer $orig_uid
         * @return void
-        *
         * @todo What about reporting errors back to the ExtJS interface? /olly/
         */
        public function swapSingleRecord($table, $t3ver_oid, $orig_uid) {
@@ -72,7 +70,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                        'swapWith' => $orig_uid,
                        'swapIntoWS' => 1
                );
-
                $this->processTcaCmd($cmd);
        }
 
@@ -82,14 +79,12 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         * @param string $table
         * @param integer $uid
         * @return void
-        *
         * @todo What about reporting errors back to the ExtJS interface? /olly/
         */
        public function deleteSingleRecord($table, $uid) {
                $cmd[$table][$uid]['version'] = array(
                        'action' => 'clearWSID'
                );
-
                $this->processTcaCmd($cmd);
        }
 
@@ -114,8 +109,8 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                $data = array();
                foreach ($model as $column) {
                        $data[$column->column] = array(
-                               'position'  => $column->position,
-                               'hidden'   => $column->hidden
+                               'position' => $column->position,
+                               'hidden' => $column->hidden
                        );
                }
                $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'] = $data;
@@ -140,7 +135,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                if (t3lib_utility_Math::canBeInterpretedAsInteger($language) === FALSE && $language !== 'all') {
                        $language = 'all';
                }
-
                $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['language'] = $language;
                $GLOBALS['BE_USER']->writeUC();
        }
@@ -155,10 +149,8 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         */
        public function sendToNextStageWindow($uid, $table, $t3ver_oid) {
                $elementRecord = t3lib_BEfunc::getRecord($table, $uid);
-
                if (is_array($elementRecord)) {
                        $stageId = $elementRecord['t3ver_stage'];
-
                        if ($this->getStageService()->isValid($stageId)) {
                                $nextStage = $this->getStageService()->getNextStage($stageId);
                                $result = $this->getSentToStageWindow($nextStage['uid']);
@@ -166,7 +158,7 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                        'table' => $table,
                                        'nextStage' => $nextStage['uid'],
                                        't3ver_oid' => $t3ver_oid,
-                                       'uid' => $uid,
+                                       'uid' => $uid
                                );
                        } else {
                                $result = $this->getErrorResponse('error.stageId.invalid', 1291111644);
@@ -174,7 +166,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                } else {
                        $result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264776);
                }
-
                return $result;
        }
 
@@ -187,22 +178,19 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         */
        public function sendToPrevStageWindow($uid, $table) {
                $elementRecord = t3lib_BEfunc::getRecord($table, $uid);
-
                if (is_array($elementRecord)) {
                        $stageId = $elementRecord['t3ver_stage'];
-
                        if ($this->getStageService()->isValid($stageId)) {
                                if ($stageId !== Tx_Workspaces_Service_Stages::STAGE_EDIT_ID) {
                                        $prevStage = $this->getStageService()->getPrevStage($stageId);
-
                                        $result = $this->getSentToStageWindow($prevStage['uid']);
                                        $result['affects'] = array(
                                                'table' => $table,
                                                'uid' => $uid,
-                                               'nextStage' => $prevStage['uid'],
+                                               'nextStage' => $prevStage['uid']
                                        );
                                } else {
-                                               // element is already in edit stage, there is no prev stage - return an error message
+                                       // element is already in edit stage, there is no prev stage - return an error message
                                        $result = $this->getErrorResponse('error.sendToPrevStage.noPreviousStage', 1287264746);
                                }
                        } else {
@@ -211,7 +199,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                } else {
                        $result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264765);
                }
-
                return $result;
        }
 
@@ -224,9 +211,8 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
        public function sendToSpecificStageWindow($nextStageId) {
                $result = $this->getSentToStageWindow($nextStageId);
                $result['affects'] = array(
-                       'nextStage' => $nextStageId,
+                       'nextStage' => $nextStageId
                );
-
                return $result;
        }
 
@@ -243,7 +229,7 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                if (!$this->getStageService()->isValid($stageId)) {
                        throw new InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'));
                } else {
-                       $stageId = (int)$stageId;
+                       $stageId = (int) $stageId;
                }
                $recipients = array();
                foreach ($uidOfRecipients as $userUid) {
@@ -252,79 +238,70 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                $uc = $beUserRecord['uc'] ? unserialize($beUserRecord['uc']) : array();
                                $recipients[$beUserRecord['email']] = array(
                                        'email' => $beUserRecord['email'],
-                                       'lang'  => (isset($uc['lang']) ? $uc['lang'] : $beUserRecord['lang']),
+                                       'lang' => isset($uc['lang']) ? $uc['lang'] : $beUserRecord['lang']
                                );
                        }
                }
-
-                       // the notification mode can be configured in the workspace stage record
+               // the notification mode can be configured in the workspace stage record
                $notification_mode = $this->getStageService()->getNotificationMode($stageId);
                if (intval($notification_mode) === Tx_Workspaces_Service_Stages::MODE_NOTIFY_ALL || intval($notification_mode) === Tx_Workspaces_Service_Stages::MODE_NOTIFY_ALL_STRICT) {
-                               // get the default recipients from the stage configuration
-                               // the default recipients needs to be added in some cases of the notification_mode
+                       // get the default recipients from the stage configuration
+                       // the default recipients needs to be added in some cases of the notification_mode
                        $default_recipients = $this->getStageService()->getResponsibleBeUser($stageId, TRUE);
                        foreach ($default_recipients as $default_recipient_uid => $default_recipient_record) {
                                if (!isset($recipients[$default_recipient_record['email']])) {
                                        $uc = $default_recipient_record['uc'] ? unserialize($default_recipient_record['uc']) : array();
                                        $recipients[$default_recipient_record['email']] = array(
                                                'email' => $default_recipient_record['email'],
-                                               'lang'  => (isset($uc['lang']) ? $uc['lang'] : $default_recipient_record['lang']),
+                                               'lang' => isset($uc['lang']) ? $uc['lang'] : $default_recipient_record['lang']
                                        );
                                }
                        }
                }
-
                if ($additionalRecipients !== '') {
                        $emails = t3lib_div::trimExplode(LF, $additionalRecipients, TRUE);
                        $additionalRecipients = array();
                        foreach ($emails as $email) {
                                $additionalRecipients[$email] = array('email' => $email);
-                       };
+                       }
                } else {
                        $additionalRecipients = array();
                }
-
-                       // We merge $recipients on top of $additionalRecipients because $recipients
-                       // possibly is more complete with a user language. Furthermore, the list of
-                       // recipients is automatically unique since we indexed $additionalRecipients
-                       // and $recipients with the email address
+               // We merge $recipients on top of $additionalRecipients because $recipients
+               // possibly is more complete with a user language. Furthermore, the list of
+               // recipients is automatically unique since we indexed $additionalRecipients
+               // and $recipients with the email address
                $allRecipients = array_merge($additionalRecipients, $recipients);
-
                foreach ($allRecipients as $email => $recipientInformation) {
                        if (t3lib_div::validEmail($email)) {
                                $finalRecipients[] = $recipientInformation;
                        }
                }
-
                return $finalRecipients;
        }
 
        /**
         * Discard all items from given page id.
         *
-        * @param  integer $pageId
+        * @param integer $pageId
         * @return array
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function discardStagesFromPage($pageId) {
-               $cmdMapArray      = array();
-                       /** @var $workspaceService Tx_Workspaces_Service_Workspaces */
+               $cmdMapArray = array();
+               /** @var $workspaceService Tx_Workspaces_Service_Workspaces */
                $workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
-                       /** @var $stageService Tx_Workspaces_Service_Stages */
-               $stageService     = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
-               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), $filter = 1, $stage = -99, $pageId, $recursionLevel = 0, $selectionType = 'tables_modify');
-
+               /** @var $stageService Tx_Workspaces_Service_Stages */
+               $stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $pageId, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
                foreach ($workspaceItemsArray as $tableName => $items) {
                        foreach ($items as $item) {
                                $cmdMapArray[$tableName][$item['uid']]['version']['action'] = 'clearWSID';
                        }
                }
-
                $this->processTcaCmd($cmdMapArray);
-
-               return array (
-                       'success' => TRUE,
+               return array(
+                       'success' => TRUE
                );
        }
 
@@ -341,23 +318,19 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         *
         * @param stdClass $parameters
         * @return array
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function sentCollectionToStage(stdClass $parameters) {
                $cmdMapArray = array();
-               $comment     = $parameters->comments;
-               $stageId     = $parameters->stageId;
-
+               $comment = $parameters->comments;
+               $stageId = $parameters->stageId;
                if (t3lib_utility_Math::canBeInterpretedAsInteger($stageId) === FALSE) {
                        throw new InvalidArgumentException('Missing "stageId" in $parameters array.', 1319488194);
                }
                if (!is_object($parameters->affects) || count($parameters->affects) == 0) {
                        throw new InvalidArgumentException('Missing "affected items" in $parameters array.', 1319488195);
                }
-
-               $recipients  = $this->getRecipientList($parameters->receipients, $parameters->additional, $stageId);
-
+               $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $stageId);
                foreach ($parameters->affects as $tableName => $items) {
                        foreach ($items as $item) {
                                if ($stageId == Tx_Workspaces_Service_Stages::STAGE_PUBLISH_EXECUTE_ID) {
@@ -373,22 +346,19 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                }
                        }
                }
-
                $this->processTcaCmd($cmdMapArray);
-
-               return array (
+               return array(
                        'success' => TRUE,
-                               // force refresh after publishing changes
-                       'refreshLivePanel' => ($parameters->stageId == -20) ? TRUE : FALSE
+                       // force refresh after publishing changes
+                       'refreshLivePanel' => $parameters->stageId == -20 ? TRUE : FALSE
                );
        }
 
        /**
         * Process TCA command map array.
         *
-        * @param  array $cmdMapArray
+        * @param array $cmdMapArray
         * @return void
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        protected function processTcaCmd(array $cmdMapArray) {
@@ -400,28 +370,26 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
        /**
         * Gets an object with this structure:
         *
-        *      affects: object
-        *              table
-        *              t3ver_oid
-        *              nextStage
-        *              uid
-        *      receipients: array with uids
-        *      additional: string
-        *      comments: string
+        * affects: object
+        * table
+        * t3ver_oid
+        * nextStage
+        * uid
+        * receipients: array with uids
+        * additional: string
+        * comments: string
         *
         * @param stdClass $parameters
         * @return array
         */
        public function sendToNextStageExecute(stdClass $parameters) {
                $cmdArray = array();
-
                $setStageId = $parameters->affects->nextStage;
                $comments = $parameters->comments;
                $table = $parameters->affects->table;
                $uid = $parameters->affects->uid;
                $t3ver_oid = $parameters->affects->t3ver_oid;
                $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
-
                if ($setStageId == Tx_Workspaces_Service_Stages::STAGE_PUBLISH_EXECUTE_ID) {
                        $cmdArray[$table][$t3ver_oid]['version']['action'] = 'swap';
                        $cmdArray[$table][$t3ver_oid]['version']['swapWith'] = $uid;
@@ -433,26 +401,23 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                        $cmdArray[$table][$uid]['version']['comment'] = $comments;
                        $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
                }
-
                $this->processTcaCmd($cmdArray);
-
                $result = array(
-                       'success' => TRUE,
+                       'success' => TRUE
                );
-
                return $result;
        }
 
        /**
         * Gets an object with this structure:
         *
-        *      affects: object
-        *              table
-        *              t3ver_oid
-        *              nextStage
-        *      receipients: array with uids
-        *      additional: string
-        *      comments: string
+        * affects: object
+        * table
+        * t3ver_oid
+        * nextStage
+        * receipients: array with uids
+        * additional: string
+        * comments: string
         *
         * @param stdClass $parameters
         * @return array
@@ -460,57 +425,50 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
        public function sendToPrevStageExecute(stdClass $parameters) {
                $cmdArray = array();
                $recipients = array();
-
                $setStageId = $parameters->affects->nextStage;
                $comments = $parameters->comments;
                $table = $parameters->affects->table;
                $uid = $parameters->affects->uid;
                $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
-
                $cmdArray[$table][$uid]['version']['action'] = 'setStage';
                $cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
                $cmdArray[$table][$uid]['version']['comment'] = $comments;
                $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
-
                $this->processTcaCmd($cmdArray);
-
                $result = array(
-                       'success' => TRUE,
+                       'success' => TRUE
                );
-
                return $result;
        }
 
        /**
         * Gets an object with this structure:
         *
-        *      affects: object
-        *              elements: array
-        *                      0: object
-        *                              table
-        *                              t3ver_oid
-        *                              uid
-        *                      1: object
-        *                              table
-        *                              t3ver_oid
-        *                              uid
-        *              nextStage
-        *      receipients: array with uids
-        *      additional: string
-        *      comments: string
+        * affects: object
+        * elements: array
+        * 0: object
+        * table
+        * t3ver_oid
+        * uid
+        * 1: object
+        * table
+        * t3ver_oid
+        * uid
+        * nextStage
+        * receipients: array with uids
+        * additional: string
+        * comments: string
         *
         * @param stdClass $parameters
         * @return array
         */
        public function sendToSpecificStageExecute(stdClass $parameters) {
                $cmdArray = array();
-
                $setStageId = $parameters->affects->nextStage;
                $comments = $parameters->comments;
                $elements = $parameters->affects->elements;
                $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
-
-               foreach ($elements as $key=>$element) {
+               foreach ($elements as $key => $element) {
                        if ($setStageId == Tx_Workspaces_Service_Stages::STAGE_PUBLISH_EXECUTE_ID) {
                                $cmdArray[$element->table][$element->t3ver_oid]['version']['action'] = 'swap';
                                $cmdArray[$element->table][$element->t3ver_oid]['version']['swapWith'] = $element->uid;
@@ -523,20 +481,17 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                $cmdArray[$element->table][$element->uid]['version']['notificationAlternativeRecipients'] = $recipients;
                        }
                }
-
                $this->processTcaCmd($cmdArray);
-
                $result = array(
-                       'success' => TRUE,
+                       'success' => TRUE
                );
-
                return $result;
        }
 
        /**
         * Gets the dialog window to be displayed before a record can be sent to a stage.
         *
-        * @param  $nextStageId
+        * @param $nextStageId
         * @return array
         */
        protected function getSentToStageWindow($nextStageId) {
@@ -549,60 +504,56 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                array(
                                        'xtype' => 'panel',
                                        'bodyStyle' => 'margin-bottom: 7px; border: none;',
-                                       'html' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.itemsWillBeSentTo') . ' ' . $stageTitle,
+                                       'html' => ($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.itemsWillBeSentTo') . ' ') . $stageTitle
                                )
                        )
                );
-
                switch ($nextStageId) {
-                       case Tx_Workspaces_Service_Stages::STAGE_PUBLISH_EXECUTE_ID:
-                       case Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID:
-                               if (!empty($workspaceRec['publish_allow_notificaton_settings'])) {
-                                       $showNotificationFields = TRUE;
-                               }
-                               break;
-                       case Tx_Workspaces_Service_Stages::STAGE_EDIT_ID:
-                               if (!empty($workspaceRec['edit_allow_notificaton_settings'])) {
-                                       $showNotificationFields = TRUE;
-                               }
-                               break;
-                       default:
-                               $allow_notificaton_settings = $this->getStageService()->getPropertyOfCurrentWorkspaceStage($nextStageId, 'allow_notificaton_settings');
-                               if (!empty($allow_notificaton_settings)) {
-                                       $showNotificationFields = TRUE;
-                               }
-                               break;
-               }
+               case Tx_Workspaces_Service_Stages::STAGE_PUBLISH_EXECUTE_ID:
 
+               case Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID:
+                       if (!empty($workspaceRec['publish_allow_notificaton_settings'])) {
+                               $showNotificationFields = TRUE;
+                       }
+                       break;
+               case Tx_Workspaces_Service_Stages::STAGE_EDIT_ID:
+                       if (!empty($workspaceRec['edit_allow_notificaton_settings'])) {
+                               $showNotificationFields = TRUE;
+                       }
+                       break;
+               default:
+                       $allow_notificaton_settings = $this->getStageService()->getPropertyOfCurrentWorkspaceStage($nextStageId, 'allow_notificaton_settings');
+                       if (!empty($allow_notificaton_settings)) {
+                               $showNotificationFields = TRUE;
+                       }
+                       break;
+               }
                if ($showNotificationFields == TRUE) {
                        $result['items'][] = array(
-                                               'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.sendMailTo'),
-                                               'xtype' => 'checkboxgroup',
-                                               'itemCls' => 'x-check-group-alt',
-                                               'columns' => 1,
-                                               'style' => 'max-height: 200px',
-                                               'autoScroll' => TRUE,
-                                               'items' => array(
-                                                       $this->getReceipientsOfStage($nextStageId)
-                                               )
-                                       );
-
+                               'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.sendMailTo'),
+                               'xtype' => 'checkboxgroup',
+                               'itemCls' => 'x-check-group-alt',
+                               'columns' => 1,
+                               'style' => 'max-height: 200px',
+                               'autoScroll' => TRUE,
+                               'items' => array(
+                                       $this->getReceipientsOfStage($nextStageId)
+                               )
+                       );
                        $result['items'][] = array(
-                                               'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.additionalRecipients'),
-                                               'name' => 'additional',
-                                               'xtype' => 'textarea',
-                                               'width' => 250,
-                                       );
+                               'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.additionalRecipients'),
+                               'name' => 'additional',
+                               'xtype' => 'textarea',
+                               'width' => 250
+                       );
                }
-
                $result['items'][] = array(
-                                       'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.comments'),
-                                       'name' => 'comments',
-                                       'xtype' => 'textarea',
-                                       'width' => 250,
-                                       'value' => $this->getDefaultCommentOfStage($nextStageId),
-                               );
-
+                       'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.comments'),
+                       'name' => 'comments',
+                       'xtype' => 'textarea',
+                       'width' => 250,
+                       'value' => $this->getDefaultCommentOfStage($nextStageId)
+               );
                return $result;
        }
 
@@ -614,23 +565,20 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         */
        protected function getReceipientsOfStage($stage) {
                $result = array();
-
                $recipients = $this->getStageService()->getResponsibleBeUser($stage);
                $default_recipients = $this->getStageService()->getResponsibleBeUser($stage, TRUE);
-
                foreach ($recipients as $id => $user) {
                        if (t3lib_div::validEmail($user['email'])) {
                                $checked = FALSE;
                                $disabled = FALSE;
                                $name = $user['realName'] ? $user['realName'] : $user['username'];
-
-                                       // the notification mode can be configured in the workspace stage record
+                               // the notification mode can be configured in the workspace stage record
                                $notification_mode = $this->getStageService()->getNotificationMode($stage);
                                if (intval($notification_mode) === Tx_Workspaces_Service_Stages::MODE_NOTIFY_SOMEONE) {
-                                               // all responsible users are checked per default, as in versions before
+                                       // all responsible users are checked per default, as in versions before
                                        $checked = TRUE;
                                } elseif (intval($notification_mode) === Tx_Workspaces_Service_Stages::MODE_NOTIFY_ALL) {
-                                               // the default users are checked only
+                                       // the default users are checked only
                                        if (!empty($default_recipients[$id])) {
                                                $checked = TRUE;
                                                $disabled = TRUE;
@@ -638,20 +586,18 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
                                                $checked = FALSE;
                                        }
                                } elseif (intval($notification_mode) === Tx_Workspaces_Service_Stages::MODE_NOTIFY_ALL_STRICT) {
-                                               // all responsible users are checked
+                                       // all responsible users are checked
                                        $checked = TRUE;
                                        $disabled = TRUE;
                                }
-
                                $result[] = array(
                                        'boxLabel' => sprintf('%s (%s)', $name, $user['email']),
                                        'name' => 'receipients-' . $id,
                                        'checked' => $checked,
-                                       'disabled' => $disabled,
+                                       'disabled' => $disabled
                                );
                        }
                }
-
                return $result;
        }
 
@@ -663,7 +609,6 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         */
        protected function getDefaultCommentOfStage($stage) {
                $result = $this->getStageService()->getPropertyOfCurrentWorkspaceStage($stage, 'default_mailcomment');
-
                return $result;
        }
 
@@ -682,47 +627,40 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
        /**
         * Send all available workspace records to the previous stage.
         *
-        * @param  integer $id Current page id to process items to previous stage.
+        * @param integer $id Current page id to process items to previous stage.
         * @return array
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function sendPageToPreviousStage($id) {
                $workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
-               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $id, $recursionLevel = 0, $selectionType = 'tables_modify');
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
                list($currentStage, $previousStage) = $this->getStageService()->getPreviousStageForElementCollection($workspaceItemsArray);
-
-                       // get only the relevant items for processing
-               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $currentStage['uid'], $id, $recursionLevel = 0, $selectionType = 'tables_modify');
-
-               return array (
-                       'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $previousStage['title'],
+               // get only the relevant items for processing
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), $currentStage['uid'], $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
+               return array(
+                       'title' => (('Status message: Page send to next stage - ID: ' . $id) . ' - Next stage title: ') . $previousStage['title'],
                        'items' => $this->getSentToStageWindow($previousStage['uid']),
                        'affects' => $workspaceItemsArray,
-                       'stageId' => $previousStage['uid'],
+                       'stageId' => $previousStage['uid']
                );
        }
 
        /**
-        *
         * @param integer $id Current Page id to select Workspace items from.
-        *
         * @return array
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function sendPageToNextStage($id) {
                $workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
-               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $id, $recursionLevel = 0, $selectionType = 'tables_modify');
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
                list($currentStage, $nextStage) = $this->getStageService()->getNextStageForElementCollection($workspaceItemsArray);
-                       // get only the relevant items for processing
-               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $currentStage['uid'], $id, $recursionLevel = 0, $selectionType = 'tables_modify');
-
-               return array (
-                       'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $nextStage['title'],
+               // get only the relevant items for processing
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), $currentStage['uid'], $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
+               return array(
+                       'title' => (('Status message: Page send to next stage - ID: ' . $id) . ' - Next stage title: ') . $nextStage['title'],
                        'items' => $this->getSentToStageWindow($nextStage['uid']),
                        'affects' => $workspaceItemsArray,
-                       'stageId' => $nextStage['uid'],
+                       'stageId' => $nextStage['uid']
                );
        }
 
@@ -731,35 +669,32 @@ class Tx_Workspaces_ExtDirect_ActionHandler extends Tx_Workspaces_ExtDirect_Abst
         *
         * @param integer $id
         * @return array Contains the visibility state and label of the stage change buttons.
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function updateStageChangeButtons($id) {
-
                $stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
                $workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
-
-                       // fetch the next and previous stage
-               $workspaceItemsArray   = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), $filter = 1, $stage = -99, $id, $recursionLevel = 0, $selectionType = 'tables_modify');
-               list(, $nextStage)     = $stageService->getNextStageForElementCollection($workspaceItemsArray);
+               // fetch the next and previous stage
+               $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
+               list(, $nextStage) = $stageService->getNextStageForElementCollection($workspaceItemsArray);
                list(, $previousStage) = $stageService->getPreviousStageForElementCollection($workspaceItemsArray);
-
                $toolbarButtons = array(
                        'feToolbarButtonNextStage' => array(
                                'visible' => is_array($nextStage) && count($nextStage) > 0,
-                               'text' => $nextStage['title'],
+                               'text' => $nextStage['title']
                        ),
                        'feToolbarButtonPreviousStage' => array(
                                'visible' => is_array($previousStage) && count($previousStage),
-                               'text' => $previousStage['title'],
+                               'text' => $previousStage['title']
                        ),
                        'feToolbarButtonDiscardStage' => array(
-                               'visible' => (is_array($nextStage) && count($nextStage) > 0) || (is_array($previousStage) && count($previousStage) > 0),
-                               'text' =>  $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:label_doaction_discard', TRUE),
-                       ),
+                               'visible' => is_array($nextStage) && count($nextStage) > 0 || is_array($previousStage) && count($previousStage) > 0,
+                               'text' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:label_doaction_discard', TRUE)
+                       )
                );
-
                return $toolbarButtons;
        }
+
 }
+
 ?>
\ No newline at end of file
index 3a47205..f9ed172 100644 (file)
@@ -1,30 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * ExtDirect server
  *
@@ -33,6 +32,7 @@
  * @subpackage ExtDirect
  */
 class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHandler {
+
        /**
         * @var Tx_Workspaces_Service_GridData
         */
@@ -50,16 +50,11 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
         * @return array
         */
        public function checkIntegrity(stdClass $parameters) {
-               $integrity = $this->createIntegrityService(
-                       $this->getAffectedElements($parameters)
-               );
-
+               $integrity = $this->createIntegrityService($this->getAffectedElements($parameters));
                $integrity->check();
-
                $response = array(
-                       'result' => $integrity->getStatusRepresentation(),
+                       'result' => $integrity->getStatusRepresentation()
                );
-
                return $response;
        }
 
@@ -70,23 +65,12 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
         * @return array $data
         */
        public function getWorkspaceInfos($parameter) {
-                       // To avoid too much work we use -1 to indicate that every page is relevant
+               // To avoid too much work we use -1 to indicate that every page is relevant
                $pageId = $parameter->id > 0 ? $parameter->id : -1;
-
                if (!isset($parameter->language) || !t3lib_utility_Math::canBeInterpretedAsInteger($parameter->language)) {
                        $parameter->language = NULL;
                }
-
-               $versions = $this->getWorkspaceService()->selectVersionsInWorkspace(
-                       $this->getCurrentWorkspace(),
-                       0,
-                       -99,
-                       $pageId,
-                       $parameter->depth,
-                       'tables_select',
-                       $parameter->language
-               );
-
+               $versions = $this->getWorkspaceService()->selectVersionsInWorkspace($this->getCurrentWorkspace(), 0, -99, $pageId, $parameter->depth, 'tables_select', $parameter->language);
                $data = $this->getGridDataService()->generateGridListFromVersions($versions, $parameter, $this->getCurrentWorkspace());
                return $data;
        }
@@ -101,10 +85,9 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                /** @var $historyService Tx_Workspaces_Service_History */
                $historyService = t3lib_div::makeInstance('Tx_Workspaces_Service_History');
                $history = $historyService->getHistory($parameters->table, $parameters->versionId);
-
                return array(
                        'data' => $history,
-                       'total' => count($history),
+                       'total' => count($history)
                );
        }
 
@@ -120,7 +103,6 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                if ($currentWorkspace != Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) {
                        $stages = $this->getStagesService()->getStagesForWSUser();
                }
-
                $data = array(
                        'total' => count($stages),
                        'data' => $stages
@@ -137,21 +119,16 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
        public function getRowDetails($parameter) {
                $diffReturnArray = array();
                $liveReturnArray = array();
-
                /** @var $t3lib_diff t3lib_diff */
                $t3lib_diff = t3lib_div::makeInstance('t3lib_diff');
-
                /** @var $parseObj t3lib_parsehtml_proc */
                $parseObj = t3lib_div::makeInstance('t3lib_parsehtml_proc');
-
                $liveRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->t3ver_oid);
                $versionRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->uid);
                $icon_Live = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord);
                $icon_Workspace = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord);
                $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage);
-
                $fieldsOfRecords = array_keys($liveRecord);
-
                // get field list from TCA configuration, if available
                t3lib_div::loadTCA($parameter->table);
                if ($GLOBALS['TCA'][$parameter->table]) {
@@ -160,26 +137,22 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                                $fieldsOfRecords = t3lib_div::trimExplode(',', $fieldsOfRecords, 1);
                        }
                }
-
                foreach ($fieldsOfRecords as $fieldName) {
-                               // check for exclude fields
-                       if ($GLOBALS['BE_USER']->isAdmin() || ($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0) || t3lib_div::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) {
-                                       // call diff class only if there is a difference
+                       // check for exclude fields
+                       if (($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0) || t3lib_div::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], ($parameter->table . ':') . $fieldName)) {
+                               // call diff class only if there is a difference
                                if (strcmp($liveRecord[$fieldName], $versionRecord[$fieldName]) !== 0) {
-                                               // Select the human readable values before diff
+                                       // Select the human readable values before diff
                                        $liveRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1);
                                        $versionRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1);
-
-                                               // Get the field's label. If not available, use the field name
+                                       // Get the field's label. If not available, use the field name
                                        $fieldTitle = $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($parameter->table, $fieldName));
                                        if (empty($fieldTitle)) {
                                                $fieldTitle = $fieldName;
                                        }
-
                                        if ($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') {
                                                $versionThumb = t3lib_BEfunc::thumbCode($versionRecord, $parameter->table, $fieldName, '');
                                                $liveThumb = t3lib_BEfunc::thumbCode($liveRecord, $parameter->table, $fieldName, '');
-
                                                $diffReturnArray[] = array(
                                                        'field' => $fieldName,
                                                        'label' => $fieldTitle,
@@ -194,7 +167,7 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                                                $diffReturnArray[] = array(
                                                        'field' => $fieldName,
                                                        'label' => $fieldTitle,
-                                                       'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName]) // call diff class to get diff
+                                                       'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName])
                                                );
                                                $liveReturnArray[] = array(
                                                        'field' => $fieldName,
@@ -205,17 +178,15 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                                }
                        }
                }
-                       // Hook for modifying the difference and live arrays
-                       // (this may be used by custom or dynamically-defined fields)
+               // Hook for modifying the difference and live arrays
+               // (this may be used by custom or dynamically-defined fields)
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) {
-                               $hookObject = &t3lib_div::getUserObj($className);
+                               $hookObject =t3lib_div::getUserObj($className);
                                $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $t3lib_diff);
                        }
                }
-
                $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table);
-
                return array(
                        'total' => 1,
                        'data' => array(
@@ -243,31 +214,20 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
         */
        public function getCommentsForRecord($uid, $table) {
                $sysLogReturnArray = array();
-
-               $sysLogRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'log_data,tstamp,userid',
-                               'sys_log',
-                               'action=6 and details_nr=30
-                               AND tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_log') . '
-                               AND recuid=' . intval($uid),
-                               '',
-                               'tstamp DESC'
-               );
-
+               $sysLogRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('log_data,tstamp,userid', 'sys_log', (('action=6 and details_nr=30
+                               AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_log')) . '
+                               AND recuid=') . intval($uid), '', 'tstamp DESC');
                foreach ($sysLogRows as $sysLogRow) {
                        $sysLogEntry = array();
                        $data = unserialize($sysLogRow['log_data']);
                        $beUserRecord = t3lib_BEfunc::getRecord('be_users', $sysLogRow['userid']);
-
                        $sysLogEntry['stage_title'] = $this->getStagesService()->getStageTitle($data['stage']);
                        $sysLogEntry['user_uid'] = $sysLogRow['userid'];
                        $sysLogEntry['user_username'] = is_array($beUserRecord) ? $beUserRecord['username'] : '';
                        $sysLogEntry['tstamp'] = t3lib_BEfunc::datetime($sysLogRow['tstamp']);
                        $sysLogEntry['user_comment'] = $data['comment'];
-
                        $sysLogReturnArray[] = $sysLogEntry;
                }
-
                return $sysLogReturnArray;
        }
 
@@ -281,27 +241,23 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                        array(
                                'uid' => 'all',
                                'title' => Tx_Extbase_Utility_Localization::translate('language.allLanguages', 'workspaces'),
-                               'cls' => t3lib_iconWorks::getSpriteIconClasses('empty-empty'),
+                               'cls' => t3lib_iconWorks::getSpriteIconClasses('empty-empty')
                        )
                );
-
                foreach ($this->getGridDataService()->getSystemLanguages() as $id => $systemLanguage) {
                        if ($id < 0) {
                                continue;
                        }
-
                        $systemLanguages[] = array(
                                'uid' => $id,
                                'title' => htmlspecialchars($systemLanguage['title']),
-                               'cls' => t3lib_iconWorks::getSpriteIconClasses($systemLanguage['flagIcon']),
+                               'cls' => t3lib_iconWorks::getSpriteIconClasses($systemLanguage['flagIcon'])
                        );
                }
-
                $result = array(
                        'total' => count($systemLanguages),
-                       'data' => $systemLanguages,
+                       'data' => $systemLanguages
                );
-
                return $result;
        }
 
@@ -328,5 +284,7 @@ class Tx_Workspaces_ExtDirect_Server extends Tx_Workspaces_ExtDirect_AbstractHan
                }
                return $this->stagesService;
        }
+
 }
+
 ?>
\ No newline at end of file
index 274d9f3..582feaf 100644 (file)
@@ -25,7 +25,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Class encapsulates all actions which are triggered for all elements within the current workspace.
  *
  * @subpackage ExtDirect
  */
 class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_AbstractHandler {
-       const MAX_RECORDS_TO_PROCESS = 30;
 
+       const MAX_RECORDS_TO_PROCESS = 30;
        /**
         * Path to the locallang file
+        *
         * @var string
         */
        private $pathToLocallang = 'LLL:EXT:workspaces/Resources/Private/Language/locallang.xml';
@@ -53,24 +53,19 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                $actions = array();
                $currentWorkspace = $this->getCurrentWorkspace();
                $massActionsEnabled = $GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.enableMassActions') !== '0';
-                       // in case we're working within "All Workspaces" we can't provide Mass Actions
-               if (($currentWorkspace != Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) && $massActionsEnabled) {
+               // in case we're working within "All Workspaces" we can't provide Mass Actions
+               if ($currentWorkspace != Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES && $massActionsEnabled) {
                        $publishAccess = $GLOBALS['BE_USER']->workspacePublishAccess($currentWorkspace);
                        if ($publishAccess && !($GLOBALS['BE_USER']->workspaceRec['publish_access'] & 1)) {
-                               $actions[] = array('action' => 'publish', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_publish')
-                               );
+                               $actions[] = array('action' => 'publish', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_publish'));
                                if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
-                                       $actions[] = array('action' => 'swap', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_swap')
-                                       );
+                                       $actions[] = array('action' => 'swap', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_swap'));
                                }
                        }
-
                        if ($currentWorkspace !== Tx_Workspaces_Service_Workspaces::LIVE_WORKSPACE_ID) {
-                               $actions[] = array('action' => 'discard', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_discard')
-                               );
+                               $actions[] = array('action' => 'discard', 'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':label_doaction_discard'));
                        }
                }
-
                $result = array(
                        'total' => count($actions),
                        'data' => $actions
@@ -91,7 +86,6 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                        'processed' => 0,
                        'error' => FALSE
                );
-
                try {
                        if ($parameters->init) {
                                $language = $this->validateLanguageParameter($parameters);
@@ -120,7 +114,6 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                        'processed' => 0,
                        'error' => FALSE
                );
-
                try {
                        if ($parameters->init) {
                                $language = $this->validateLanguageParameter($parameters);
@@ -145,7 +138,7 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
         * @return integer
         */
        protected function initPublishData($workspace, $swap, $language = NULL) {
-                       // workspace might be -98 a.k.a "All Workspaces but that's save here
+               // workspace might be -98 a.k.a "All Workspaces but that's save here
                $publishData = $this->getWorkspaceService()->getCmdArrayForPublishWS($workspace, $swap, 0, $language);
                $recordCount = 0;
                foreach ($publishData as $table => $recs) {
@@ -167,7 +160,7 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
         * @return integer
         */
        protected function initFlushData($workspace, $language = NULL) {
-                       // workspace might be -98 a.k.a "All Workspaces but that's save here
+               // workspace might be -98 a.k.a "All Workspaces but that's save here
                $flushData = $this->getWorkspaceService()->getCmdArrayForFlushWS($workspace, TRUE, 0, $language);
                $recordCount = 0;
                foreach ($flushData as $table => $recs) {
@@ -192,7 +185,6 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                $recordsProcessed = $GLOBALS['BE_USER']->getSessionData('workspaceMassAction_processed');
                $limitedCmd = array();
                $numRecs = 0;
-
                foreach ($processData as $table => $recs) {
                        foreach ($recs as $key => $value) {
                                $numRecs++;
@@ -205,24 +197,22 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                                break;
                        }
                }
-
                if ($numRecs == 0) {
-                               // All done
+                       // All done
                        $GLOBALS['BE_USER']->setAndSaveSessionData('workspaceMassAction', NULL);
                        $GLOBALS['BE_USER']->setAndSaveSessionData('workspaceMassAction_total', 0);
                } else {
                        /** @var $tce t3lib_TCEmain */
                        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                        $tce->stripslashes_values = 0;
-                               // Execute the commands:
+                       // Execute the commands:
                        $tce->start(array(), $limitedCmd);
                        $tce->process_cmdmap();
-
                        $errors = $tce->errorLog;
                        if (count($errors) > 0) {
                                throw new Exception(implode(', ', $errors));
                        } else {
-                                       // Unset processed records
+                               // Unset processed records
                                foreach ($limitedCmd as $table => $recs) {
                                        foreach ($recs as $key => $value) {
                                                $recordsProcessed++;
@@ -233,8 +223,9 @@ class Tx_Workspaces_ExtDirect_MassActionHandler extends Tx_Workspaces_ExtDirect_
                                $GLOBALS['BE_USER']->setAndSaveSessionData('workspaceMassAction_processed', $recordsProcessed);
                        }
                }
-
                return $recordsProcessed;
        }
+
 }
+
 ?>
\ No newline at end of file
index 9d9499b..4b69ce5 100644 (file)
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Interface for classes which perform pre or post processing
  *
  * @author Tolleiv Nietsch <typo3@tolleiv.de>
- * @package    TYPO3
+ * @package    TYPO3
  * @subpackage t3lib
  */
 class Tx_Workspaces_ExtDirect_PagetreeCollectionsProcessor implements t3lib_tree_pagetree_interfaces_CollectionProcessor {
 
        /**
         * @abstract
-        * @param  t3lib_tree_pagetree_Node $node
-        * @param  int $mountPoint
-        * @param  int $level
-        * @param  t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @param t3lib_tree_pagetree_Node $node
+        * @param int $mountPoint
+        * @param int $level
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
         * @return void
         */
        public function postProcessGetNodes($node, $mountPoint, $level, $nodeCollection) {
@@ -51,10 +50,10 @@ class Tx_Workspaces_ExtDirect_PagetreeCollectionsProcessor implements t3lib_tree
 
        /**
         * @abstract
-        * @param  t3lib_tree_pagetree_Node $node
-        * @param  string $searchFilter
-        * @param  int $mountPoint
-        * @param  t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @param t3lib_tree_pagetree_Node $node
+        * @param string $searchFilter
+        * @param int $mountPoint
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
         * @return void
         */
        public function postProcessFilteredNodes($node, $searchFilter, $mountPoint, $nodeCollection) {
@@ -66,8 +65,8 @@ class Tx_Workspaces_ExtDirect_PagetreeCollectionsProcessor implements t3lib_tree
 
        /**
         * @abstract
-        * @param  string $searchFilter
-        * @param  t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @param string $searchFilter
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
         * @return void
         */
        public function postProcessGetTreeMounts($searchFilter, $nodeCollection) {
@@ -85,10 +84,11 @@ class Tx_Workspaces_ExtDirect_PagetreeCollectionsProcessor implements t3lib_tree
         * @return void
         */
        protected function highlightVersionizedElements(t3lib_tree_Node $node) {
-               if (!$node->getCls() && count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $node->getId(), TRUE)))        {
+               if (!$node->getCls() && count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $node->getId(), TRUE))) {
                        $node->setCls('ver-versions');
                }
        }
+
 }
 
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/ExtDirect/Server.php b/typo3/sysext/workspaces/Classes/ExtDirect/Server.php
new file mode 100644 (file)
index 0000000..a16b39f
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_ExtDirect_Server and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/ExtDirect/ExtDirectServer.php
+ */
+?>
\ No newline at end of file
index b77251b..5c2885e 100644 (file)
@@ -1,30 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * ExtDirect toolbar menu
  *
@@ -41,7 +40,6 @@ class Tx_Workspaces_ExtDirect_ToolbarMenu {
        public function toggleWorkspacePreviewMode($parameter) {
                $newState = $GLOBALS['BE_USER']->user['workspace_preview'] ? '0' : '1';
                $GLOBALS['BE_USER']->setWorkspacePreview($newState);
-
                return array('newWorkspacePreviewState' => $newState);
        }
 
@@ -51,12 +49,13 @@ class Tx_Workspaces_ExtDirect_ToolbarMenu {
         */
        public function setWorkspace($parameter) {
                $workspaceId = intval($parameter->workSpaceId);
-
                $GLOBALS['BE_USER']->setWorkspace($workspaceId);
                return array(
                        'title' => Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($workspaceId),
                        'id' => $workspaceId
                );
        }
+
 }
+
 ?>
\ No newline at end of file
index 01d37e5..8590d42 100644 (file)
@@ -1,51 +1,50 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2007-2011 Ingo Renner <ingo@typo3.org>
-*  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
+ *  Copyright notice
+ *
+ *  (c) 2007-2011 Ingo Renner <ingo@typo3.org>
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
-       require_once(PATH_typo3 . 'interfaces/interface.backend_toolbaritem.php');
+       require_once PATH_typo3 . 'interfaces/interface.backend_toolbaritem.php';
 }
-
 /**
  * class to render the workspace selector
  *
- * @author     Ingo Renner <ingo@typo3.org>
+ * @author     Ingo Renner <ingo@typo3.org>
  * @package Workspaces
  * @subpackage ExtDirect
  */
 class Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem implements backend_toolbarItem {
 
        protected $changeWorkspace;
+
        protected $changeWorkspacePreview;
 
        /**
         * reference back to the backend object
         *
-        * @var TYPO3backend
+        * @var         TYPO3backend
         */
        protected $backendReference;
 
@@ -54,32 +53,32 @@ class Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem implements backend_to
        /**
         * constructor
         *
-        * @param       TYPO3backend    TYPO3 backend object reference
+        * @param       TYPO3backend    TYPO3 backend object reference
         */
        public function __construct(TYPO3backend &$backendReference = NULL) {
-               $this->backendReference       = $backendReference;
-               $this->changeWorkspace        = t3lib_div::_GP('changeWorkspace');
+               $this->backendReference = $backendReference;
+               $this->changeWorkspace = t3lib_div::_GP('changeWorkspace');
                $this->changeWorkspacePreview = t3lib_div::_GP('changeWorkspacePreview');
-
                $pageRenderer = t3lib_div::makeInstance('t3lib_pageRenderer');
-               $this->backendReference->addJavaScript("TYPO3.Workspaces = { workspaceTitle : '" . addslashes(Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($GLOBALS['BE_USER']->workspace)) . "'};\n");
+               $this->backendReference->addJavaScript(('TYPO3.Workspaces = { workspaceTitle : \'' . addslashes(Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($GLOBALS['BE_USER']->workspace))) . '\'};
+');
        }
 
        /**
         * checks whether the user has access to this toolbar item
         *
-        * @see         typo3/alt_shortcut.php
-        * @return  boolean  TRUE if user has access, FALSE if not
+        * @see                 typo3/alt_shortcut.php
+        * @return boolean  TRUE if user has access, FALSE if not
         */
        public function checkAccess() {
                if (t3lib_extMgm::isLoaded('workspaces')) {
                        if ($this->checkAccess == NULL) {
-                                       $availableWorkspaces = Tx_Workspaces_Service_Workspaces::getAvailableWorkspaces();
-                                       if (count($availableWorkspaces) > 0) {
-                                               $this->checkAccess = TRUE;
-                                       } else {
-                                               $this->checkAccess = FALSE;
-                                       }
+                               $availableWorkspaces = Tx_Workspaces_Service_Workspaces::getAvailableWorkspaces();
+                               if (count($availableWorkspaces) > 0) {
+                                       $this->checkAccess = TRUE;
+                               } else {
+                                       $this->checkAccess = FALSE;
+                               }
                        }
                        return $this->checkAccess;
                }
@@ -89,25 +88,19 @@ class Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem implements backend_to
        /**
         * Creates the selector for workspaces
         *
-        * @return      string          workspace selector as HTML select
+        * @return      string          workspace selector as HTML select
         */
        public function render() {
                $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.workspace', TRUE);
                $this->addJavascriptToBackend();
                $availableWorkspaces = Tx_Workspaces_Service_Workspaces::getAvailableWorkspaces();
-               $workspaceMenu       = array();
-
+               $workspaceMenu = array();
                $stateCheckedIcon = t3lib_iconWorks::getSpriteIcon('status-status-checked');
-
                $stateUncheckedIcon = t3lib_iconWorks::getSpriteIcon('empty-empty', array(
                        'title' => $GLOBALS['LANG']->getLL('bookmark_inactive')
                ));
-
-               $workspaceMenu[] = '<a href="#" class="toolbar-item">' .
-                       t3lib_iconWorks::getSpriteIcon('apps-toolbar-menu-workspace', array('title' => $title)) .
-                               '</a>';
+               $workspaceMenu[] = ('<a href="#" class="toolbar-item">' . t3lib_iconWorks::getSpriteIcon('apps-toolbar-menu-workspace', array('title' => $title))) . '</a>';
                $workspaceMenu[] = '<ul class="toolbar-item-menu" style="display: none;">';
-
                if (count($availableWorkspaces)) {
                        foreach ($availableWorkspaces as $workspaceId => $label) {
                                $selected = '';
@@ -116,34 +109,23 @@ class Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem implements backend_to
                                        $selected = ' class="selected"';
                                        $icon = $stateCheckedIcon;
                                }
-
-                               $workspaceMenu[] = '<li' . $selected . '>' .
-                                       '<a href="backend.php?changeWorkspace=' .
-                                       intval($workspaceId) . '" id="ws-' . intval($workspaceId) .
-                                       '" class="ws">' . $icon . ' ' . htmlspecialchars($label) . '</a></li>';
+                               $workspaceMenu[] = (((((((((('<li' . $selected) . '>') . '<a href="backend.php?changeWorkspace=') . intval($workspaceId)) . '" id="ws-') . intval($workspaceId)) . '" class="ws">') . $icon) . ' ') . htmlspecialchars($label)) . '</a></li>';
                        }
                } else {
-                       $workspaceMenu[] = '<li>' . $stateUncheckedIcon . ' ' .
-                               $GLOBALS['LANG']->getLL('bookmark_noWSfound', TRUE) .
-                               '</li>';
+                       $workspaceMenu[] = ((('<li>' . $stateUncheckedIcon) . ' ') . $GLOBALS['LANG']->getLL('bookmark_noWSfound', TRUE)) . '</li>';
                }
-
                if ($GLOBALS['BE_USER']->check('modules', 'web_WorkspacesWorkspaces')) {
-                               // go to workspace module link
-                       $workspaceMenu[] = '<li class="divider">' . $stateUncheckedIcon . ' ' .
-                               '<a href="javascript:top.goToModule(\'web_WorkspacesWorkspaces\');" target="content" id="goToWsModule">' .
-                               ' '. $GLOBALS['LANG']->getLL('bookmark_workspace', TRUE) . '</a></li>';
+                       // go to workspace module link
+                       $workspaceMenu[] = ((((('<li class="divider">' . $stateUncheckedIcon) . ' ') . '<a href="javascript:top.goToModule(\'web_WorkspacesWorkspaces\');" target="content" id="goToWsModule">') . ' ') . $GLOBALS['LANG']->getLL('bookmark_workspace', TRUE)) . '</a></li>';
                }
-
                $workspaceMenu[] = '</ul>';
-
                return implode(LF, $workspaceMenu);
        }
 
        /**
         * adds the necessary JavaScript to the backend
         *
-        * @return      void
+        * @return      void
         */
        protected function addJavascriptToBackend() {
                $this->backendReference->addJavascriptFile(t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/workspacemenu.js');
@@ -152,13 +134,13 @@ class Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem implements backend_to
        /**
         * returns additional attributes for the list item in the toolbar
         *
-        * @return      string          list item HTML attibutes
+        * @return      string          list item HTML attibutes
         */
        public function getAdditionalAttributes() {
                return ' id="workspace-selector-menu"';
        }
-}
 
+}
 
 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
        $GLOBALS['TYPO3backend']->addToolbarItem('workSpaceSelector', 'Tx_Workspaces_ExtDirect_WorkspaceSelectorToolbarItem');
index 40769fd..25036e8 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Befunc service
  *
  * @subpackage Service
  */
 class Tx_Workspaces_Service_Befunc implements t3lib_Singleton {
+
        /**
         * Gets a singleton instance of this object.
         *
         * @return Tx_Workspaces_Service_Befunc
         */
-       public static function getInstance() {
+       static public function getInstance() {
                return t3lib_div::makeInstance('Tx_Workspaces_Service_Befunc');
        }
 
@@ -46,13 +46,13 @@ class Tx_Workspaces_Service_Befunc implements t3lib_Singleton {
         * Hooks into the t3lib_beFunc::viewOnClick and redirects to the workspace preview
         * only if we're in a workspace and if the frontend-preview is disabled.
         *
-        * @param  $pageUid
-        * @param  $backPath
-        * @param  $rootLine
-        * @param  $anchorSection
-        * @param  $viewScript
-        * @param  $additionalGetVars
-        * @param  $switchFocus
+        * @param $pageUid
+        * @param $backPath
+        * @param $rootLine
+        * @param $anchorSection
+        * @param $viewScript
+        * @param $additionalGetVars
+        * @param $switchFocus
         * @return void
         */
        public function preProcess(&$pageUid, $backPath, $rootLine, $anchorSection, &$viewScript, $additionalGetVars, $switchFocus) {
@@ -88,8 +88,8 @@ class Tx_Workspaces_Service_Befunc implements t3lib_Singleton {
         * Use that hook to show a info message in case someone starts editing
         * a staged element
         *
-        * @param  $params
-        * @param  $form
+        * @param $params
+        * @param $form
         * @return boolean
         */
        public function makeEditForm_accessCheck($params, &$form) {
@@ -100,17 +100,13 @@ class Tx_Workspaces_Service_Befunc implements t3lib_Singleton {
                                $stageName = $stages->getStageTitle($record['t3ver_stage']);
                                $editingName = $stages->getStageTitle(Tx_Workspaces_Service_Stages::STAGE_EDIT_ID);
                                $message = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
-                               $flashMessage = t3lib_div::makeInstance(
-                                       't3lib_FlashMessage',
-                                       sprintf($message, $stageName, $editingName),
-                                       '',
-                                       t3lib_FlashMessage::INFO,
-                                       TRUE
-                               );
+                               $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($message, $stageName, $editingName), '', t3lib_FlashMessage::INFO, TRUE);
                                t3lib_FlashMessageQueue::addMessage($flashMessage);
                        }
                }
                return $params['hasAccess'];
        }
+
 }
+
 ?>
\ No newline at end of file
index c2afd00..e3bd06d 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /***************************************************************
  *  Copyright notice
  *
@@ -25,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Tcemain service
  *
@@ -62,7 +60,7 @@ class Tx_Workspaces_Service_Tcemain {
         * executed
         *
         * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
-        * @return      void
+        * @return      void
         */
        public function processCmdmap_afterFinish(t3lib_TCEmain $tcemainObj) {
                $this->flushWorkspaceCacheEntriesByWorkspaceId($tcemainObj->BE_USER->workspace);
@@ -78,14 +76,11 @@ class Tx_Workspaces_Service_Tcemain {
         */
        protected function resetStageOfElements($stageId) {
                $fields = array('t3ver_stage' => Tx_Workspaces_Service_Stages::STAGE_EDIT_ID);
-
                foreach ($this->getTcaTables() as $tcaTable) {
                        if (t3lib_BEfunc::isTableWorkspaceEnabled($tcaTable)) {
-
                                $where = 't3ver_stage = ' . intval($stageId);
                                $where .= ' AND t3ver_wsid > 0 AND pid=-1';
                                $where .= t3lib_BEfunc::deleteClause($tcaTable);
-
                                $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tcaTable, $where, $fields);
                        }
                }
@@ -99,13 +94,11 @@ class Tx_Workspaces_Service_Tcemain {
         */
        protected function flushWorkspaceElements($workspaceId) {
                $command = array();
-
                foreach ($this->getTcaTables() as $tcaTable) {
                        if (t3lib_BEfunc::isTableWorkspaceEnabled($tcaTable)) {
                                $where = '1=1';
                                $where .= t3lib_BEfunc::getWorkspaceWhereClause($tcaTable, $workspaceId);
                                $where .= t3lib_BEfunc::deleteClause($tcaTable);
-
                                $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $tcaTable, $where, '', '', '', 'uid');
                                if (is_array($records)) {
                                        foreach (array_keys($records) as $recordId) {
@@ -114,7 +107,6 @@ class Tx_Workspaces_Service_Tcemain {
                                }
                        }
                }
-
                if (count($command)) {
                        $tceMain = $this->getTceMain();
                        $tceMain->start(array(), $command);
@@ -153,5 +145,7 @@ class Tx_Workspaces_Service_Tcemain {
                $workspacesCache->flushByTag($workspaceId);
                $workspacesCache->flushByTag(Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
        }
+
 }
+
 ?>
\ No newline at end of file
index 0e15617..36c8ccc 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Frontend hooks
  *
@@ -43,19 +42,16 @@ class Tx_Workspaces_Service_Fehooks {
                if ($pObj->fePreview != 2) {
                        return;
                }
-
-               $previewParts = $GLOBALS['TSFE']->cObj->cObjGetSingle(
-                       'FLUIDTEMPLATE',
-                       array(
-                               'file' => 'EXT:workspaces/Resources/Private/Templates/Preview/Preview.html',
-                               'variables.' => array(
-                                       'backendDomain' => 'TEXT',
-                                       'backendDomain.' => array('value' => $GLOBALS['BE_USER']->getSessionData('workspaces.backend_domain'))
-                               )
+               $previewParts = $GLOBALS['TSFE']->cObj->cObjGetSingle('FLUIDTEMPLATE', array(
+                       'file' => 'EXT:workspaces/Resources/Private/Templates/Preview/Preview.html',
+                       'variables.' => array(
+                               'backendDomain' => 'TEXT',
+                               'backendDomain.' => array('value' => $GLOBALS['BE_USER']->getSessionData('workspaces.backend_domain'))
                        )
-               );
+               ));
                $GLOBALS['TSFE']->content = str_ireplace('</body>', $previewParts . '</body>', $GLOBALS['TSFE']->content);
-
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/AutoPublish.php b/typo3/sysext/workspaces/Classes/Service/AutoPublish.php
new file mode 100644 (file)
index 0000000..f68b441
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_AutoPublish and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/AutoPublishService.php
+ */
+?>
\ No newline at end of file
index edd5119..335978f 100644 (file)
@@ -21,7 +21,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Automatic publishing of workspaces.
  *
  * @subpackage Service
  */
 class Tx_Workspaces_Service_AutoPublish {
+
        /**
         * This method is called by the Scheduler task that triggers
         * the autopublication process
         * It searches for workspaces whose publication date is in the past
         * and publishes them
         *
-        * @return      void
+        * @return      void
         */
        public function autoPublishWorkspaces() {
                global $TYPO3_CONF_VARS;
-
-                       // Temporarily set admin rights
-                       // FIXME: once workspaces are cleaned up a better solution should be implemented
+               // Temporarily set admin rights
+               // FIXME: once workspaces are cleaned up a better solution should be implemented
                $currentAdminStatus = $GLOBALS['BE_USER']->user['admin'];
                $GLOBALS['BE_USER']->user['admin'] = 1;
-
-                       // Select all workspaces that needs to be published / unpublished:
-               $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       'uid,swap_modes,publish_time,unpublish_time',
-                       'sys_workspace',
-                       'pid=0
+               // Select all workspaces that needs to be published / unpublished:
+               $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,swap_modes,publish_time,unpublish_time', 'sys_workspace', (((('pid=0
                                AND
-                               ((publish_time!=0 AND publish_time<=' . intval($GLOBALS['EXEC_TIME']) . ')
-                               OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<=' . intval($GLOBALS['EXEC_TIME']) . '))'.
-                               t3lib_BEfunc::deleteClause('sys_workspace')
-                       );
-
+                               ((publish_time!=0 AND publish_time<=' . intval($GLOBALS['EXEC_TIME'])) . ')
+                               OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<=') . intval($GLOBALS['EXEC_TIME'])) . '))') . t3lib_BEfunc::deleteClause('sys_workspace'));
                $workspaceService = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
-
                foreach ($workspaces as $rec) {
-
-                               // First, clear start/end time so it doesn't get select once again:
+                       // First, clear start/end time so it doesn't get select once again:
                        $fieldArray = $rec['publish_time'] != 0 ? array('publish_time' => 0) : array('unpublish_time' => 0);
                        $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_workspace', 'uid=' . intval($rec['uid']), $fieldArray);
-
-                               // Get CMD array:
-                       $cmd = $workspaceService->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes'] == 1); // $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace.
-
-                               // Execute CMD array:
+                       // Get CMD array:
+                       $cmd = $workspaceService->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes'] == 1);
+                       // $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace.
+                       // Execute CMD array:
                        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                        $tce->stripslashes_values = 0;
                        $tce->start(array(), $cmd);
                        $tce->process_cmdmap();
                }
-
-                       // Restore admin status
+               // Restore admin status
                $GLOBALS['BE_USER']->user['admin'] = $currentAdminStatus;
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/AutoPublishTask.php b/typo3/sysext/workspaces/Classes/Service/AutoPublishTask.php
new file mode 100644 (file)
index 0000000..a8f301a
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_AutoPublishTask and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Task/AutoPublishTask.php
+ */
+?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Befunc.php b/typo3/sysext/workspaces/Classes/Service/Befunc.php
new file mode 100644 (file)
index 0000000..befad37
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Befunc and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
+ */
+?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php b/typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php
new file mode 100644 (file)
index 0000000..c4adf15
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_CleanupPreviewLinkTask and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Task/CleanupPreviewLinkTask.php
+ */
+?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Fehooks.php b/typo3/sysext/workspaces/Classes/Service/Fehooks.php
new file mode 100644 (file)
index 0000000..270b7d4
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Fehooks and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Hook/TypoScriptFrontendControllerHook.php
+ */
+?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/GridData.php b/typo3/sysext/workspaces/Classes/Service/GridData.php
new file mode 100644 (file)
index 0000000..3d6fd7c
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_GridData and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/GridDataService.php
+ */
+?>
\ No newline at end of file
index e88b8eb..598b7a3 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Grid data service
  *
  * @subpackage Service
  */
 class Tx_Workspaces_Service_GridData {
+
        const SIGNAL_GenerateDataArray_BeforeCaching = 'generateDataArray.beforeCaching';
        const SIGNAL_GenerateDataArray_PostProcesss = 'generateDataArray.postProcess';
        const SIGNAL_GetDataArray_PostProcesss = 'getDataArray.postProcess';
        const SIGNAL_SortDataArray_PostProcesss = 'sortDataArray.postProcess';
-
        /**
         * Id of the current active workspace.
         *
@@ -84,34 +83,29 @@ class Tx_Workspaces_Service_GridData {
        /**
         * Generates grid list array from given versions.
         *
-        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
+        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
         * @param object $parameter Parameters as submitted by JavaScript component
         * @param integer $currentWorkspace The current workspace
         * @return array Version record information (filtered, sorted and limited)
         * @throws InvalidArgumentException
         */
        public function generateGridListFromVersions($versions, $parameter, $currentWorkspace) {
-                       // Read the given parameters from grid. If the parameter is not set use default values.
+               // Read the given parameters from grid. If the parameter is not set use default values.
                $filterTxt = isset($parameter->filterTxt) ? $parameter->filterTxt : '';
                $start = isset($parameter->start) ? intval($parameter->start) : 0;
                $limit = isset($parameter->limit) ? intval($parameter->limit) : 30;
                $this->sort = isset($parameter->sort) ? $parameter->sort : 't3ver_oid';
                $this->sortDir = isset($parameter->dir) ? $parameter->dir : 'ASC';
-
                if (is_int($currentWorkspace)) {
                        $this->currentWorkspace = $currentWorkspace;
                } else {
                        throw new InvalidArgumentException('No such workspace defined');
                }
-
                $data = array();
                $data['data'] = array();
-
                $this->generateDataArray($versions, $filterTxt);
-
                $data['total'] = count($this->dataArray);
                $data['data'] = $this->getDataArray($start, $limit);
-
                return $data;
        }
 
@@ -124,41 +118,29 @@ class Tx_Workspaces_Service_GridData {
         */
        protected function generateDataArray(array $versions, $filterTxt) {
                $workspaceAccess = $GLOBALS['BE_USER']->checkWorkspace($GLOBALS['BE_USER']->workspace);
-               $swapStage = ($workspaceAccess['publish_access'] & 1) ? Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID : 0;
-               $swapAccess = ($GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace)
-                       && $GLOBALS['BE_USER']->workspaceSwapAccess());
-
+               $swapStage = $workspaceAccess['publish_access'] & 1 ? Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID : 0;
+               $swapAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace) && $GLOBALS['BE_USER']->workspaceSwapAccess();
                $this->initializeWorkspacesCachingFramework();
-
                // check for dataArray in cache
                if ($this->getDataArrayFromCache($versions, $filterTxt) === FALSE) {
                        /** @var $stagesObj Tx_Workspaces_Service_Stages */
                        $stagesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
-
                        foreach ($versions as $table => $records) {
                                $versionArray = array('table' => $table);
                                $isRecordTypeAllowedToModify = $GLOBALS['BE_USER']->check('tables_modify', $table);
-
                                foreach ($records as $record) {
                                        $origRecord = t3lib_BEFunc::getRecord($table, $record['t3ver_oid']);
                                        $versionRecord = t3lib_BEFunc::getRecord($table, $record['uid']);
-
-                                       $combinedRecord = Tx_Workspaces_Domain_Model_CombinedRecord::createFromArrays(
-                                               $table, $origRecord, $versionRecord
-                                       );
-
+                                       $combinedRecord = Tx_Workspaces_Domain_Model_CombinedRecord::createFromArrays($table, $origRecord, $versionRecord);
                                        $this->getIntegrityService()->checkElement($combinedRecord);
-
                                        if (isset($GLOBALS['TCA'][$table]['columns']['hidden'])) {
                                                $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord['hidden'], $versionRecord['hidden']);
                                        } else {
                                                $recordState = $this->workspaceState($versionRecord['t3ver_state']);
                                        }
-
-                                       $isDeletedPage = ($table == 'pages' && $recordState == 'deleted');
-                                       $viewUrl =  Tx_Workspaces_Service_Workspaces::viewSingleRecord($table, $record['t3ver_oid'], $origRecord);
-
-                                       $versionArray['id'] = $table . ':' . $record['uid'];
+                                       $isDeletedPage = $table == 'pages' && $recordState == 'deleted';
+                                       $viewUrl = Tx_Workspaces_Service_Workspaces::viewSingleRecord($table, $record['t3ver_oid'], $origRecord);
+                                       $versionArray['id'] = ($table . ':') . $record['uid'];
                                        $versionArray['uid'] = $record['uid'];
                                        $versionArray['workspace'] = $versionRecord['t3ver_id'];
                                        $versionArray['label_Workspace'] = htmlspecialchars(t3lib_befunc::getRecordTitle($table, $versionRecord));
@@ -171,7 +153,6 @@ class Tx_Workspaces_Service_GridData {
                                        $versionArray['path_Live'] = htmlspecialchars(t3lib_BEfunc::getRecordPath($record['livepid'], '', 999));
                                        $versionArray['path_Workspace'] = htmlspecialchars(t3lib_BEfunc::getRecordPath($record['wspid'], '', 999));
                                        $versionArray['workspace_Title'] = htmlspecialchars(Tx_Workspaces_Service_Workspaces::getWorkspaceTitle($versionRecord['t3ver_wsid']));
-
                                        $versionArray['workspace_Tstamp'] = $versionRecord['tstamp'];
                                        $versionArray['workspace_Formated_Tstamp'] = t3lib_BEfunc::datetime($versionRecord['tstamp']);
                                        $versionArray['t3ver_oid'] = $record['t3ver_oid'];
@@ -179,66 +160,48 @@ class Tx_Workspaces_Service_GridData {
                                        $versionArray['stage'] = $versionRecord['t3ver_stage'];
                                        $versionArray['icon_Live'] = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($table, $origRecord);
                                        $versionArray['icon_Workspace'] = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($table, $versionRecord);
-
                                        $languageValue = $this->getLanguageValue($table, $versionRecord);
                                        $versionArray['languageValue'] = $languageValue;
                                        $versionArray['language'] = array(
                                                'cls' => t3lib_iconWorks::getSpriteIconClasses($this->getSystemLanguageValue($languageValue, 'flagIcon')),
-                                               'title' => htmlspecialchars($this->getSystemLanguageValue($languageValue, 'title')),
+                                               'title' => htmlspecialchars($this->getSystemLanguageValue($languageValue, 'title'))
                                        );
-
                                        $versionArray['allowedAction_nextStage'] = $isRecordTypeAllowedToModify && $stagesObj->isNextStageAllowedForUser($versionRecord['t3ver_stage']);
                                        $versionArray['allowedAction_prevStage'] = $isRecordTypeAllowedToModify && $stagesObj->isPrevStageAllowedForUser($versionRecord['t3ver_stage']);
-
-                                       if ($swapAccess && $swapStage != 0 && $versionRecord['t3ver_stage'] == $swapStage) {
+                                       if (($swapAccess && $swapStage != 0) && $versionRecord['t3ver_stage'] == $swapStage) {
                                                $versionArray['allowedAction_swap'] = $isRecordTypeAllowedToModify && $stagesObj->isNextStageAllowedForUser($swapStage);
                                        } elseif ($swapAccess && $swapStage == 0) {
                                                $versionArray['allowedAction_swap'] = $isRecordTypeAllowedToModify;
                                        } else {
                                                $versionArray['allowedAction_swap'] = FALSE;
                                        }
-
                                        $versionArray['allowedAction_delete'] = $isRecordTypeAllowedToModify;
-                                               // preview and editing of a deleted page won't work ;)
+                                       // preview and editing of a deleted page won't work ;)
                                        $versionArray['allowedAction_view'] = !$isDeletedPage && $viewUrl;
                                        $versionArray['allowedAction_edit'] = $isRecordTypeAllowedToModify && !$isDeletedPage;
                                        $versionArray['allowedAction_editVersionedPage'] = $isRecordTypeAllowedToModify && !$isDeletedPage;
-
                                        $versionArray['state_Workspace'] = $recordState;
-
                                        if ($filterTxt == '' || $this->isFilterTextInVisibleColumns($filterTxt, $versionArray)) {
                                                $this->dataArray[] = $versionArray;
                                        }
                                }
                        }
-
-                               // Suggested slot method:
-                               // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, array $versions)
-                       $this->emitSignal(
-                               self::SIGNAL_GenerateDataArray_BeforeCaching,
-                               $this->dataArray, $versions
-                       );
-
-                               // Enrich elements after everything has been processed:
+                       // Suggested slot method:
+                       // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, array $versions)
+                       $this->emitSignal(self::SIGNAL_GenerateDataArray_BeforeCaching, $this->dataArray, $versions);
+                       // Enrich elements after everything has been processed:
                        foreach ($this->dataArray as &$element) {
-                               $identifier = $element['table'] . ':' . $element['t3ver_oid'];
-
+                               $identifier = ($element['table'] . ':') . $element['t3ver_oid'];
                                $element['integrity'] = array(
                                        'status' => $this->getIntegrityService()->getStatusRepresentation($identifier),
-                                       'messages' => htmlspecialchars($this->getIntegrityService()->getIssueMessages($identifier, TRUE)),
+                                       'messages' => htmlspecialchars($this->getIntegrityService()->getIssueMessages($identifier, TRUE))
                                );
                        }
-
                        $this->setDataArrayIntoCache($versions, $filterTxt);
                }
-
-                       // Suggested slot method:
-                       // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, array $versions)
-               $this->emitSignal(
-                       self::SIGNAL_GenerateDataArray_PostProcesss,
-                       $this->dataArray, $versions
-               );
-
+               // Suggested slot method:
+               // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, array $versions)
+               $this->emitSignal(self::SIGNAL_GenerateDataArray_PostProcesss, $this->dataArray, $versions);
                $this->sortDataArray();
        }
 
@@ -252,18 +215,12 @@ class Tx_Workspaces_Service_GridData {
        protected function getDataArray($start, $limit) {
                $dataArrayPart = array();
                $end = $start + $limit < count($this->dataArray) ? $start + $limit : count($this->dataArray);
-
                for ($i = $start; $i < $end; $i++) {
                        $dataArrayPart[] = $this->dataArray[$i];
                }
-
-                       // Suggested slot method:
-                       // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, $start, $limit)
-               $this->emitSignal(
-                       self::SIGNAL_GetDataArray_PostProcesss,
-                       $this->dataArray, $start, $limit
-               );
-
+               // Suggested slot method:
+               // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, $start, $limit)
+               $this->emitSignal(self::SIGNAL_GetDataArray_PostProcesss, $this->dataArray, $start, $limit);
                return $dataArrayPart;
        }
 
@@ -279,44 +236,36 @@ class Tx_Workspaces_Service_GridData {
        /**
         * Puts the generated dataArray into the workspace cache.
         *
-        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
+        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
         * @param string $filterTxt The given filter text from the grid.
         */
        protected function setDataArrayIntoCache(array $versions, $filterTxt) {
                $hash = $this->calculateHash($versions, $filterTxt);
-               $this->workspacesCache->set(
-                       $hash,
-                       $this->dataArray,
-                       array($this->currentWorkspace, 'user_' . $GLOBALS['BE_USER']->user['uid'])
-               );
+               $this->workspacesCache->set($hash, $this->dataArray, array($this->currentWorkspace, 'user_' . $GLOBALS['BE_USER']->user['uid']));
        }
 
        /**
         * Checks if a cache entry is given for given versions and filter text and tries to load the data array from cache.
         *
-        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
+        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
         * @param string $filterTxt The given filter text from the grid.
         * @return boolean TRUE if cache entry was successfully fetched from cache and content put to $this->dataArray
         */
        protected function getDataArrayFromCache(array $versions, $filterTxt) {
                $cacheEntry = FALSE;
-
                $hash = $this->calculateHash($versions, $filterTxt);
-
                $content = $this->workspacesCache->get($hash);
-
                if ($content !== FALSE) {
                        $this->dataArray = $content;
                        $cacheEntry = TRUE;
                }
-
                return $cacheEntry;
        }
 
        /**
         * Calculates the hash value of the used workspace, the user id, the versions array, the filter text, the sorting attribute, the workspace selected in grid and the sorting direction.
         *
-        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
+        * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
         * @param string $filterTxt The given filter text from the grid.
         * @return string
         */
@@ -328,9 +277,9 @@ class Tx_Workspaces_Service_GridData {
                        $filterTxt,
                        $this->sort,
                        $this->sortDir,
-                       $this->currentWorkspace);
+                       $this->currentWorkspace
+               );
                $hash = md5(serialize($hashArray));
-
                return $hash;
        }
 
@@ -343,34 +292,40 @@ class Tx_Workspaces_Service_GridData {
        protected function sortDataArray() {
                if (is_array($this->dataArray)) {
                        switch ($this->sort) {
-                               case 'uid';
-                               case 'change';
-                               case 'workspace_Tstamp';
-                               case 't3ver_oid';
-                               case 'liveid';
-                               case 'livepid':
-                               case 'languageValue';
-                                       usort($this->dataArray, array($this, 'intSort'));
-                                       break;
-                               case 'label_Workspace';
-                               case 'label_Live';
-                               case 'label_Stage';
-                               case 'workspace_Title';
-                               case 'path_Live':
-                                               // case 'path_Workspace': This is the first sorting attribute
-                                       usort($this->dataArray, array($this, 'stringSort'));
-                                       break;
+                       case 'uid':
+
+                       case 'change':
+
+                       case 'workspace_Tstamp':
+
+                       case 't3ver_oid':
+
+                       case 'liveid':
+
+                       case 'livepid':
+
+                       case 'languageValue':
+                               usort($this->dataArray, array($this, 'intSort'));
+                               break;
+                       case 'label_Workspace':
+
+                       case 'label_Live':
+
+                       case 'label_Stage':
+
+                       case 'workspace_Title':
+
+                       case 'path_Live':
+                               // case 'path_Workspace': This is the first sorting attribute
+                               usort($this->dataArray, array($this, 'stringSort'));
+                               break;
                        }
                } else {
-                       t3lib_div::sysLog('Try to sort "' . $this->sort . '" in "Tx_Workspaces_Service_GridData::sortDataArray" but $this->dataArray is empty! This might be the Bug #26422 which could not reproduced yet.', 3);
+                       t3lib_div::sysLog(('Try to sort "' . $this->sort) . '" in "Tx_Workspaces_Service_GridData::sortDataArray" but $this->dataArray is empty! This might be the Bug #26422 which could not reproduced yet.', 3);
                }
-
-                       // Suggested slot method:
-                       // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, $sortColumn, $sortDirection)
-               $this->emitSignal(
-                       self::SIGNAL_SortDataArray_PostProcesss,
-                       $this->dataArray, $this->sort, $this->sortDir
-               );
+               // Suggested slot method:
+               // methodName(Tx_Workspaces_Service_GridData $gridData, array &$dataArray, $sortColumn, $sortDirection)
+               $this->emitSignal(self::SIGNAL_SortDataArray_PostProcesss, $this->dataArray, $this->sort, $this->sortDir);
        }
 
        /**
@@ -381,9 +336,8 @@ class Tx_Workspaces_Service_GridData {
         * @return integer
         */
        protected function intSort(array $a, array $b) {
-                       // First sort by using the page-path in current workspace
+               // First sort by using the page-path in current workspace
                $path_cmp = strcasecmp($a['path_Workspace'], $b['path_Workspace']);
-
                if ($path_cmp < 0) {
                        return $path_cmp;
                } elseif ($path_cmp == 0) {
@@ -391,14 +345,14 @@ class Tx_Workspaces_Service_GridData {
                                return 0;
                        }
                        if ($this->sortDir == 'ASC') {
-                               return ($a[$this->sort] < $b[$this->sort]) ? -1 : 1;
+                               return $a[$this->sort] < $b[$this->sort] ? -1 : 1;
                        } elseif ($this->sortDir == 'DESC') {
-                               return ($a[$this->sort] > $b[$this->sort]) ? -1 : 1;
+                               return $a[$this->sort] > $b[$this->sort] ? -1 : 1;
                        }
                } elseif ($path_cmp > 0) {
                        return $path_cmp;
                }
-               return 0; //ToDo: Throw Exception
+               return 0;
        }
 
        /**
@@ -410,7 +364,6 @@ class Tx_Workspaces_Service_GridData {
         */
        protected function stringSort($a, $b) {
                $path_cmp = strcasecmp($a['path_Workspace'], $b['path_Workspace']);
-
                if ($path_cmp < 0) {
                        return $path_cmp;
                } elseif ($path_cmp == 0) {
@@ -418,14 +371,14 @@ class Tx_Workspaces_Service_GridData {
                                return 0;
                        }
                        if ($this->sortDir == 'ASC') {
-                               return (strcasecmp($a[$this->sort], $b[$this->sort]));
+                               return strcasecmp($a[$this->sort], $b[$this->sort]);
                        } elseif ($this->sortDir == 'DESC') {
-                               return (strcasecmp($a[$this->sort], $b[$this->sort]) * (-1));
+                               return strcasecmp($a[$this->sort], $b[$this->sort]) * -1;
                        }
                } elseif ($path_cmp > 0) {
                        return $path_cmp;
                }
-               return 0; //ToDo: Throw Exception
+               return 0;
        }
 
        /**
@@ -439,23 +392,23 @@ class Tx_Workspaces_Service_GridData {
        protected function isFilterTextInVisibleColumns($filterText, array $versionArray) {
                if (is_array($GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'])) {
                        foreach ($GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'] as $column => $value) {
-                               if (isset($value['hidden']) && isset($column) && isset($versionArray[$column])) {
+                               if ((isset($value['hidden']) && isset($column)) && isset($versionArray[$column])) {
                                        if ($value['hidden'] == 0) {
                                                switch ($column) {
-                                                       case 'workspace_Tstamp':
-                                                               if (stripos($versionArray['workspace_Formated_Tstamp'], $filterText) !== FALSE) {
-                                                                       return TRUE;
-                                                               }
-                                                               break;
-                                                       case 'change':
-                                                               if (stripos(strval($versionArray[$column]), str_replace('%', '', $filterText)) !== FALSE) {
-                                                                       return TRUE;
-                                                               }
-                                                               break;
-                                                       default:
-                                                               if (stripos(strval($versionArray[$column]), $filterText) !== FALSE) {
-                                                                       return TRUE;
-                                                               }
+                                               case 'workspace_Tstamp':
+                                                       if (stripos($versionArray['workspace_Formated_Tstamp'], $filterText) !== FALSE) {
+                                                               return TRUE;
+                                                       }
+                                                       break;
+                                               case 'change':
+                                                       if (stripos(strval($versionArray[$column]), str_replace('%', '', $filterText)) !== FALSE) {
+                                                               return TRUE;
+                                                       }
+                                                       break;
+                                               default:
+                                                       if (stripos(strval($versionArray[$column]), $filterText) !== FALSE) {
+                                                               return TRUE;
+                                                       }
                                                }
                                        }
                                }
@@ -474,26 +427,25 @@ class Tx_Workspaces_Service_GridData {
         */
        protected function workspaceState($stateId, $hiddenOnline = FALSE, $hiddenOffline = FALSE) {
                switch ($stateId) {
-                       case -1:
-                               $state = 'new';
-                               break;
-                       case 1:
-                       case 2:
-                               $state = 'deleted';
-                               break;
-                       case 4:
-                               $state = 'moved';
-                               break;
-                       default:
-                               $state = 'modified';
+               case -1:
+                       $state = 'new';
+                       break;
+               case 1:
+
+               case 2:
+                       $state = 'deleted';
+                       break;
+               case 4:
+                       $state = 'moved';
+                       break;
+               default:
+                       $state = 'modified';
                }
-
                if ($hiddenOnline == 0 && $hiddenOffline == 1) {
                        $state = 'hidden';
                } elseif ($hiddenOnline == 1 && $hiddenOffline == 0) {
                        $state = 'unhidden';
                }
-
                return $state;
        }
 
@@ -507,15 +459,12 @@ class Tx_Workspaces_Service_GridData {
         */
        protected function getLanguageValue($table, array $record) {
                $languageValue = 0;
-
                if (t3lib_BEfunc::isTableLocalizable($table)) {
                        $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
-
                        if (!empty($record[$languageField])) {
                                $languageValue = $record[$languageField];
                        }
                }
-
                return $languageValue;
        }
 
@@ -529,12 +478,10 @@ class Tx_Workspaces_Service_GridData {
         */
        protected function getSystemLanguageValue($id, $key) {
                $value = NULL;
-
                $systemLanguages = $this->getSystemLanguages();
                if (!empty($systemLanguages[$id][$key])) {
                        $value = $systemLanguages[$id][$key];
                }
-
                return $value;
        }
 
@@ -550,7 +497,6 @@ class Tx_Workspaces_Service_GridData {
                        $translateTools = t3lib_div::makeInstance('t3lib_transl8tools');
                        $this->systemLanguages = $translateTools->getSystemLanguages();
                }
-
                return $this->systemLanguages;
        }
 
@@ -563,7 +509,6 @@ class Tx_Workspaces_Service_GridData {
                if (!isset($this->integrityService)) {
                        $this->integrityService = t3lib_div::makeInstance('Tx_Workspaces_Service_Integrity');
                }
-
                return $this->integrityService;
        }
 
@@ -574,17 +519,9 @@ class Tx_Workspaces_Service_GridData {
         * @return void
         */
        protected function emitSignal($signalName) {
-                       // Arguments are always ($this, [method argument], [method argument], ...)
-               $signalArguments = array_merge(
-                       array($this),
-                       array_slice(func_get_args(), 1)
-               );
-
-               $this->getSignalSlotDispatcher()->dispatch(
-                       'Tx_Workspaces_Service_GridData',
-                       $signalName,
-                       $signalArguments
-               );
+               // Arguments are always ($this, [method argument], [method argument], ...)
+               $signalArguments = array_merge(array($this), array_slice(func_get_args(), 1));
+               $this->getSignalSlotDispatcher()->dispatch('Tx_Workspaces_Service_GridData', $signalName, $signalArguments);
        }
 
        /**
@@ -600,5 +537,7 @@ class Tx_Workspaces_Service_GridData {
        protected function getObjectManager() {
                return t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
        }
+
 }
-?>
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/History.php b/typo3/sysext/workspaces/Classes/Service/History.php
new file mode 100644 (file)
index 0000000..e819e57
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_History and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/HistoryService.php
+ */
+?>
\ No newline at end of file
index 85323ab..970322a 100644 (file)
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * @author Oliver Hader <oliver.hader@typo3.org>
  * @package Workspaces
  * @subpackage Service
  */
 class Tx_Workspaces_Service_History implements t3lib_Singleton {
+
        /**
         * @var array
         */
@@ -64,15 +64,12 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
        public function getHistory($table, $id) {
                $history = array();
                $i = 0;
-
                foreach ($this->getHistoryObject($table, $id)->changeLog as $entry) {
                        if ($i++ > 20) {
                                break;
                        }
-
                        $history[] = $this->getHistoryEntry($entry);
                }
-
                return $history;
        }
 
@@ -88,16 +85,12 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
                if (!empty($entry['action'])) {
                        $differences = $entry['action'];
                } else {
-                       $differences = implode(
-                               '<br/>',
-                               $this->getDifferences($entry)
-                       );
+                       $differences = implode('<br/>', $this->getDifferences($entry));
                }
-
                return array(
                        'datetime' => htmlspecialchars(t3lib_BEfunc::datetime($entry['tstamp'])),
                        'user' => htmlspecialchars($this->getUserName($entry['user'])),
-                       'differences' => $differences,
+                       'differences' => $differences
                );
        }
 
@@ -111,26 +104,17 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
        protected function getDifferences(array $entry) {
                $differences = array();
                $tableName = $entry['tablename'];
-
                if (is_array($entry['newRecord'])) {
                        $fields = array_keys($entry['newRecord']);
-
                        foreach ($fields as $field) {
                                t3lib_div::loadTCA($tableName);
-
                                if (!empty($GLOBALS['TCA'][$tableName]['columns'][$field]['config']['type']) && $GLOBALS['TCA'][$tableName]['columns'][$field]['config']['type'] !== 'passthrough') {
-
-                                               // Create diff-result:
-                                       $fieldDifferences = $this->getDifferencesObject()->makeDiffDisplay(
-                                               t3lib_BEfunc::getProcessedValue($tableName, $field, $entry['oldRecord'][$field], 0, TRUE),
-                                               t3lib_BEfunc::getProcessedValue($tableName ,$field, $entry['newRecord'][$field], 0, TRUE)
-                                       );
-
+                                       // Create diff-result:
+                                       $fieldDifferences = $this->getDifferencesObject()->makeDiffDisplay(t3lib_BEfunc::getProcessedValue($tableName, $field, $entry['oldRecord'][$field], 0, TRUE), t3lib_BEfunc::getProcessedValue($tableName, $field, $entry['newRecord'][$field], 0, TRUE));
                                        $differences[] = nl2br($fieldDifferences);
                                }
                        }
                }
-
                return $differences;
        }
 
@@ -142,11 +126,9 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
         */
        protected function getUserName($user) {
                $userName = 'unknown';
-
                if (!empty($this->backendUserNames[$user]['username'])) {
                        $userName = $this->backendUserNames[$user]['username'];
                }
-
                return $userName;
        }
 
@@ -161,12 +143,10 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
                if (!isset($this->historyObjects[$table][$id])) {
                        /** @var $historyObject recordHistory */
                        $historyObject = t3lib_div::makeInstance('recordHistory');
-                       $historyObject->element = $table . ':' . $id;
+                       $historyObject->element = ($table . ':') . $id;
                        $historyObject->createChangeLog();
-
                        $this->historyObjects[$table][$id] = $historyObject;
                }
-
                return $this->historyObjects[$table][$id];
        }
 
@@ -179,8 +159,9 @@ class Tx_Workspaces_Service_History implements t3lib_Singleton {
                if (!isset($this->differencesObject)) {
                        $this->differencesObject = t3lib_div::makeInstance('t3lib_diff');
                }
-
                return $this->differencesObject;
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Integrity.php b/typo3/sysext/workspaces/Classes/Service/Integrity.php
new file mode 100644 (file)
index 0000000..5c70dc0
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Integrity and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/IntegrityService.php
+ */
+?>
\ No newline at end of file
index 9256858..ce0b2e8 100644 (file)
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * @author Oliver Hader <oliver.hader@typo3.org>
  * @package Workspaces
  * @subpackage Service
  */
 class Tx_Workspaces_Service_Integrity {
+
        /**
         * Succes status - everything is fine
         *
         * @var integer
         */
        const STATUS_Succes = 100;
-
        /**
         * Info status - nothing is wrong, but a notice is shown
         *
         * @var integer
         */
        const STATUS_Info = 101;
-
        /**
         * Warning status - user interaction might be required
         *
         * @var integer
         */
        const STATUS_Warning = 102;
-
        /**
         * Error status - user interaction is required
         *
         * @var integer
         */
        const STATUS_Error = 103;
-
        /**
         * @var array
         */
@@ -66,7 +62,7 @@ class Tx_Workspaces_Service_Integrity {
                self::STATUS_Succes => 'success',
                self::STATUS_Info => 'info',
                self::STATUS_Warning => 'warning',
-               self::STATUS_Error => 'error',
+               self::STATUS_Error => 'error'
        );
 
        /**
@@ -80,10 +76,10 @@ class Tx_Workspaces_Service_Integrity {
         * are identifiers of table and the version-id.
         *
         * 'tx_table:123' => array(
-        *     array(
-        *         'status' => 'warning',
-        *         'message' => 'Element cannot be...',
-        *     )
+        * array(
+        * 'status' => 'warning',
+        * 'message' => 'Element cannot be...',
+        * )
         * )
         *
         * @var array
@@ -132,43 +128,21 @@ class Tx_Workspaces_Service_Integrity {
         */
        protected function checkLocalization(Tx_Workspaces_Domain_Model_CombinedRecord $element) {
                $table = $element->getTable();
-
                if (t3lib_BEfunc::isTableLocalizable($table)) {
                        $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
                        $languageParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
-
                        $versionRow = $element->getVersionRecord()->getRow();
-
                        // If element is a localization:
                        if ($versionRow[$languageField] > 0) {
                                // Get localization parent from live workspace:
-                               $languageParentRecord = t3lib_BEfunc::getRecord(
-                                       $table, $versionRow[$languageParentField], 'uid,t3ver_state'
-                               );
-
+                               $languageParentRecord = t3lib_BEfunc::getRecord($table, $versionRow[$languageParentField], 'uid,t3ver_state');
                                // If localization parent is a "new placeholder" record:
                                if ($languageParentRecord['t3ver_state'] == 1) {
                                        $title = t3lib_BEfunc::getRecordTitle($table, $versionRow);
-
                                        // Add warning for current versionized record:
-                                       $this->addIssue(
-                                               $element->getLiveRecord()->getIdentifier(),
-                                               self::STATUS_Warning,
-                                               sprintf(
-                                                       Tx_Extbase_Utility_Localization::translate('integrity.dependsOnDefaultLanguageRecord', 'workspaces'),
-                                                       $title
-                                               )
-                                       );
-
+                                       $this->addIssue($element->getLiveRecord()->getIdentifier(), self::STATUS_Warning, sprintf(Tx_Extbase_Utility_Localization::translate('integrity.dependsOnDefaultLanguageRecord', 'workspaces'), $title));
                                        // Add info for related localization parent record:
-                                       $this->addIssue(
-                                               $table . ':' . $languageParentRecord['uid'],
-                                               self::STATUS_Info,
-                                               sprintf(
-                                                       Tx_Extbase_Utility_Localization::translate('integrity.isDefaultLanguageRecord', 'workspaces'),
-                                                       $title
-                                               )
-                                       );
+                                       $this->addIssue(($table . ':') . $languageParentRecord['uid'], self::STATUS_Info, sprintf(Tx_Extbase_Utility_Localization::translate('integrity.isDefaultLanguageRecord', 'workspaces'), $title));
                                }
                        }
                }
@@ -183,7 +157,6 @@ class Tx_Workspaces_Service_Integrity {
         */
        public function getStatus($identifier = NULL) {
                $status = self::STATUS_Succes;
-
                if ($identifier === NULL) {
                        foreach ($this->issues as $idenfieriferIssues) {
                                foreach ($idenfieriferIssues as $issue) {
@@ -199,7 +172,6 @@ class Tx_Workspaces_Service_Integrity {
                                }
                        }
                }
-
                return $status;
        }
 
@@ -226,7 +198,6 @@ class Tx_Workspaces_Service_Integrity {
                } elseif (isset($this->issues[$identifier])) {
                        return $this->issues[$identifier];
                }
-
                return array();
        }
 
@@ -239,7 +210,6 @@ class Tx_Workspaces_Service_Integrity {
         */
        public function getIssueMessages($identifier = NULL, $asString = FALSE) {
                $messages = array();
-
                if ($identifier === NULL) {
                        foreach ($this->issues as $idenfieriferIssues) {
                                foreach ($idenfieriferIssues as $issue) {
@@ -251,11 +221,9 @@ class Tx_Workspaces_Service_Integrity {
                                $messages[] = $issue['message'];
                        }
                }
-
                if ($asString) {
-                       $messages = implode('<br/>' , $messages);
+                       $messages = implode('<br/>', $messages);
                }
-
                return $messages;
        }
 
@@ -271,11 +239,12 @@ class Tx_Workspaces_Service_Integrity {
                if (!isset($this->issues[$identifier])) {
                        $this->issues[$identifier] = array();
                }
-
                $this->issues[$identifier][] = array(
                        'status' => $status,
-                       'message' => $message,
+                       'message' => $message
                );
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Stages.php b/typo3/sysext/workspaces/Classes/Service/Stages.php
new file mode 100644 (file)
index 0000000..d81d379
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Stages and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/StagesService.php
+ */
+?>
\ No newline at end of file
index 9bd2ab4..88814a5 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Stages service
  *
  * @subpackage Service
  */
 class Tx_Workspaces_Service_Stages {
+
        const TABLE_STAGE = 'sys_workspace_stage';
-               // if a record is in the "ready to publish" stage STAGE_PUBLISH_ID the nextStage is STAGE_PUBLISH_EXECUTE_ID, this id wont be saved at any time in db
+       // if a record is in the "ready to publish" stage STAGE_PUBLISH_ID the nextStage is STAGE_PUBLISH_EXECUTE_ID, this id wont be saved at any time in db
        const STAGE_PUBLISH_EXECUTE_ID = -20;
-               // ready to publish stage
+       // ready to publish stage
        const STAGE_PUBLISH_ID = -10;
        const STAGE_EDIT_ID = 0;
        const MODE_NOTIFY_SOMEONE = 0;
        const MODE_NOTIFY_ALL = 1;
        const MODE_NOTIFY_ALL_STRICT = 2;
-
        /**
         * Current workspace ID
+        *
         * @var integer
         */
        private $workspaceId = NULL;
 
        /**
         * Path to the locallang file
+        *
         * @var string
         */
        private $pathToLocallang = 'LLL:EXT:workspaces/Resources/Private/Language/locallang.xml';
 
        /**
         * Local cache to reduce number of database queries for stages, groups, etc.
+        *
         * @var array
         */
        protected $workspaceStageCache = array();
@@ -112,7 +114,6 @@ class Tx_Workspaces_Service_Stages {
         * @param array $workspaceItems
         * @param array $byTableName
         * @return array Current and next highest possible stage
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function getPreviousStageForElementCollection($workspaceItems, array $byTableName = array('tt_content', 'pages', 'pages_language_overlay')) {
@@ -123,7 +124,6 @@ class Tx_Workspaces_Service_Stages {
                $availableStagesForWS = array_reverse($this->getStagesForWS());
                $availableStagesForWSUser = $this->getStagesForWSUser();
                $byTableName = array_flip($byTableName);
-
                foreach ($workspaceItems as $tableName => $items) {
                        if (!array_key_exists($tableName, $byTableName)) {
                                continue;
@@ -132,7 +132,6 @@ class Tx_Workspaces_Service_Stages {
                                $usedStages[$item['t3ver_stage']] = TRUE;
                        }
                }
-
                foreach ($availableStagesForWS as $stage) {
                        if (isset($usedStages[$stage['uid']])) {
                                $currentStage = $stage;
@@ -140,19 +139,16 @@ class Tx_Workspaces_Service_Stages {
                                break;
                        }
                }
-
                foreach ($availableStagesForWSUser as $userWS) {
                        if ($previousStage['uid'] == $userWS['uid']) {
                                $found = TRUE;
                                break;
                        }
                }
-
                if ($found === FALSE) {
                        $previousStage = array();
                }
-
-               return array (
+               return array(
                        $currentStage,
                        $previousStage
                );
@@ -164,7 +160,6 @@ class Tx_Workspaces_Service_Stages {
         * @param array $workspaceItems
         * @param array $byTableName
         * @return array Current and next possible stage.
-        *
         * @author Michael Klapper <development@morphodo.com>
         */
        public function getNextStageForElementCollection($workspaceItems, array $byTableName = array('tt_content', 'pages', 'pages_language_overlay')) {
@@ -175,16 +170,14 @@ class Tx_Workspaces_Service_Stages {
                $availableStagesForWSUser = $this->getStagesForWSUser();
                $byTableName = array_flip($byTableName);
                $found = FALSE;
-
                foreach ($workspaceItems as $tableName => $items) {
-                       if (! array_key_exists($tableName, $byTableName)) {
+                       if (!array_key_exists($tableName, $byTableName)) {
                                continue;
                        }
                        foreach ($items as $item) {
                                $usedStages[$item['t3ver_stage']] = TRUE;
                        }
                }
-
                foreach ($availableStagesForWS as $stage) {
                        if (isset($usedStages[$stage['uid']])) {
                                $currentStage = $stage;
@@ -192,19 +185,16 @@ class Tx_Workspaces_Service_Stages {
                                break;
                        }
                }
-
                foreach ($availableStagesForWSUser as $userWS) {
                        if ($nextStage['uid'] == $userWS['uid']) {
                                $found = TRUE;
                                break;
                        }
                }
-
                if ($found === FALSE) {
                        $nextStage = array();
                }
-
-               return array (
+               return array(
                        $currentStage,
                        $nextStage
                );
@@ -217,58 +207,44 @@ class Tx_Workspaces_Service_Stages {
         */
        public function getStagesForWS() {
                $stages = array();
-
                if (isset($this->workspaceStageCache[$this->getWorkspaceId()])) {
                        $stages = $this->workspaceStageCache[$this->getWorkspaceId()];
                } else {
                        $stages[] = array(
                                'uid' => self::STAGE_EDIT_ID,
-                               'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing') . '"'
+                               'title' => (($GLOBALS['LANG']->sL(($this->pathToLocallang . ':actionSendToStage')) . ' "') . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing')) . '"'
                        );
-
                        $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
                        if ($workspaceRec['custom_stages'] > 0) {
-                                       // Get all stage records for this workspace
-                               $workspaceStageRecs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                       '*',
-                                       self::TABLE_STAGE,
-                                       'parentid=' . $this->getWorkspaceId() . ' AND parenttable=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('sys_workspace', self::TABLE_STAGE) . ' AND deleted=0',
-                                       '',
-                                       'sorting',
-                                       '',
-                                       'uid'
-                               );
+                               // Get all stage records for this workspace
+                               $workspaceStageRecs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', self::TABLE_STAGE, ((('parentid=' . $this->getWorkspaceId()) . ' AND parenttable=') . $GLOBALS['TYPO3_DB']->fullQuoteStr('sys_workspace', self::TABLE_STAGE)) . ' AND deleted=0', '', 'sorting', '', 'uid');
                                foreach ($workspaceStageRecs as $stage) {
-                                       $stage['title'] =  $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $stage['title'] . '"';
+                                       $stage['title'] = (($GLOBALS['LANG']->sL(($this->pathToLocallang . ':actionSendToStage')) . ' "') . $stage['title']) . '"';
                                        $stages[] = $stage;
                                }
                        }
-
                        $stages[] = array(
                                'uid' => self::STAGE_PUBLISH_ID,
-                               'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xml:stage_ready_to_publish') . '"'
+                               'title' => (($GLOBALS['LANG']->sL(($this->pathToLocallang . ':actionSendToStage')) . ' "') . $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xml:stage_ready_to_publish')) . '"'
                        );
-
                        $stages[] = array(
                                'uid' => self::STAGE_PUBLISH_EXECUTE_ID,
                                'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':publish_execute_action_option')
                        );
                        $this->workspaceStageCache[$this->getWorkspaceId()] = $stages;
                }
-
                return $stages;
        }
 
        /**
         * Returns an array of stages, the user is allowed to send to
+        *
         * @return array id and title of stages
         */
        public function getStagesForWSUser() {
-
                $stagesForWSUserData = array();
                $allowedStages = array();
                $orderedAllowedStages = array();
-
                $workspaceStageRecs = $this->getStagesForWS();
                if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) {
                        if ($GLOBALS['BE_USER']->isAdmin()) {
@@ -282,7 +258,6 @@ class Tx_Workspaces_Service_Stages {
                                                $stagesForWSUserData[$workspaceStageRec['uid']] = $workspaceStageRec;
                                        }
                                }
-
                                foreach ($stagesForWSUserData as $allowedStage) {
                                        $nextStage = $this->getNextStage($allowedStage['uid']);
                                        $prevStage = $this->getPrevStage($allowedStage['uid']);
@@ -293,7 +268,6 @@ class Tx_Workspaces_Service_Stages {
                                                $allowedStages[$prevStage['uid']] = $prevStage;
                                        }
                                }
-
                                $orderedAllowedStages = array_values($allowedStages);
                        }
                }
@@ -319,26 +293,23 @@ class Tx_Workspaces_Service_Stages {
        public function getStageTitle($ver_stage) {
                global $LANG;
                $stageTitle = '';
-
                switch ($ver_stage) {
-                       case self::STAGE_PUBLISH_EXECUTE_ID:
-                               $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_publish');
-                               break;
-                       case self::STAGE_PUBLISH_ID:
-                               $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xml:stage_ready_to_publish');
-                               break;
-                       case self::STAGE_EDIT_ID:
-                               $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing');
-                               break;
-                       default:
-                               $stageTitle = $this->getPropertyOfCurrentWorkspaceStage($ver_stage, 'title');
-
-                               if ($stageTitle == NULL) {
-                                       $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.getStageTitle.stageNotFound');
-                               }
-                               break;
+               case self::STAGE_PUBLISH_EXECUTE_ID:
+                       $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_publish');
+                       break;
+               case self::STAGE_PUBLISH_ID:
+                       $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xml:stage_ready_to_publish');
+                       break;
+               case self::STAGE_EDIT_ID:
+                       $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing');
+                       break;
+               default:
+                       $stageTitle = $this->getPropertyOfCurrentWorkspaceStage($ver_stage, 'title');
+                       if ($stageTitle == NULL) {
+                               $stageTitle = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.getStageTitle.stageNotFound');
+                       }
+                       break;
                }
-
                return $stageTitle;
        }
 
@@ -360,18 +331,13 @@ class Tx_Workspaces_Service_Stages {
         */
        public function getNextStage($stageId) {
                if (!t3lib_utility_Math::canBeInterpretedAsInteger($stageId)) {
-                       throw new InvalidArgumentException(
-                               $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'),
-                               1291109987
-                       );
+                       throw new InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'), 1291109987);
                }
-
                $nextStage = FALSE;
                $workspaceStageRecs = $this->getStagesForWS();
-
                if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) {
                        reset($workspaceStageRecs);
-                       while (!is_null($workspaceStageRecKey = key($workspaceStageRecs))) {
+                       while (!is_null(($workspaceStageRecKey = key($workspaceStageRecs)))) {
                                $workspaceStageRec = current($workspaceStageRecs);
                                if ($workspaceStageRec['uid'] == $stageId) {
                                        $nextStage = next($workspaceStageRecs);
@@ -380,45 +346,43 @@ class Tx_Workspaces_Service_Stages {
                                next($workspaceStageRecs);
                        }
                } else {
-                       // @todo consider to throw an exception here
-               }
 
+               }
                if ($nextStage === FALSE) {
                        $nextStage[] = array(
                                'uid' => self::STAGE_EDIT_ID,
-                               'title' => $GLOBALS['LANG']->sL($this->pathToLocallang . ':actionSendToStage') . ' "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing') . '"'
+                               'title' => (($GLOBALS['LANG']->sL(($this->pathToLocallang . ':actionSendToStage')) . ' "') . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:stage_editing')) . '"'
                        );
                }
-
                return $nextStage;
        }
 
        /**
         * Recursive function to get all next stages for a record depending on user permissions
         *
-        * @param       array   next stages
-        * @param       int             stage id
-        * @param       int             current stage id of the record
-        * @return      array   next stages
+        * @param       array   next stages
+        * @param       int             stage id
+        * @param       int             current stage id of the record
+        * @return      array   next stages
         */
        public function getNextStages(array &$nextStageArray, $stageId) {
-                       // Current stage is "Ready to publish" - there is no next stage
+               // Current stage is "Ready to publish" - there is no next stage
                if ($stageId == self::STAGE_PUBLISH_ID) {
                        return $nextStageArray;
                } else {
                        $nextStageRecord = $this->getNextStage($stageId);
                        if (empty($nextStageRecord) || !is_array($nextStageRecord)) {
-                                       // There is no next stage
+                               // There is no next stage
                                return $nextStageArray;
                        } else {
-                                       // Check if the user has the permission to for the current stage
-                                       // If this next stage record is the first next stage after the current the user
-                                       // has always the needed permission
+                               // Check if the user has the permission to for the current stage
+                               // If this next stage record is the first next stage after the current the user
+                               // has always the needed permission
                                if ($this->isStageAllowedForUser($stageId)) {
                                        $nextStageArray[] = $nextStageRecord;
                                        return $this->getNextStages($nextStageArray, $nextStageRecord['uid']);
                                } else {
-                                               // He hasn't - return given next stage array
+                                       // He hasn't - return given next stage array
                                        return $nextStageArray;
                                }
                        }
@@ -433,16 +397,14 @@ class Tx_Workspaces_Service_Stages {
         * @return int                  id
         */
        public function getPrevStage($stageid) {
-
                if (!t3lib_utility_Math::canBeInterpretedAsInteger($stageid)) {
                        throw new InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'));
                }
-
                $prevStage = FALSE;
                $workspaceStageRecs = $this->getStagesForWS();
                if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) {
                        end($workspaceStageRecs);
-                       while (!is_null($workspaceStageRecKey = key($workspaceStageRecs))) {
+                       while (!is_null(($workspaceStageRecKey = key($workspaceStageRecs)))) {
                                $workspaceStageRec = current($workspaceStageRecs);
                                if ($workspaceStageRec['uid'] == $stageid) {
                                        $prevStage = prev($workspaceStageRecs);
@@ -451,7 +413,7 @@ class Tx_Workspaces_Service_Stages {
                                prev($workspaceStageRecs);
                        }
                } else {
-                       // @todo consider to throw an exception here
+
                }
                return $prevStage;
        }
@@ -459,25 +421,23 @@ class Tx_Workspaces_Service_Stages {
        /**
         * Recursive function to get all prev stages for a record depending on user permissions
         *
-        * @param       array   prev stages
-        * @param       int             workspace id
-        * @param       int             stage id
-        * @param       int             current stage id of the record
-        * @return      array   prev stages
+        * @param       array   prev stages
+        * @param       int             workspace id
+        * @param       int             stage id
+        * @param       int             current stage id of the record
+        * @return      array   prev stages
         */
        public function getPrevStages(array &$prevStageArray, $stageId) {
-                       // Current stage is "Editing" - there is no prev stage
+               // Current stage is "Editing" - there is no prev stage
                if ($stageId != self::STAGE_EDIT_ID) {
                        $prevStageRecord = $this->getPrevStage($stageId);
-
                        if (!empty($prevStageRecord) && is_array($prevStageRecord)) {
-                                       // Check if the user has the permission to switch to that stage
-                                       // If this prev stage record is the first previous stage before the current
-                                       // the user has always the needed permission
+                               // Check if the user has the permission to switch to that stage
+                               // If this prev stage record is the first previous stage before the current
+                               // the user has always the needed permission
                                if ($this->isStageAllowedForUser($stageId)) {
                                        $prevStageArray[] = $prevStageRecord;
                                        $prevStageArray = $this->getPrevStages($prevStageArray, $prevStageRecord['uid']);
-
                                }
                        }
                }
@@ -487,48 +447,45 @@ class Tx_Workspaces_Service_Stages {
        /**
         * Get array of all responsilbe be_users for a stage
         *
-        * @param       int     stage id
-        * @param       boolean if field notification_defaults should be selected instead of responsible users
-        * @return      array be_users with e-mail and name
+        * @param       int     stage id
+        * @param       boolean if field notification_defaults should be selected instead of responsible users
+        * @return      array be_users with e-mail and name
         */
        public function getResponsibleBeUser($stageId, $selectDefaultUserField = FALSE) {
                $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
                $recipientArray = array();
-
                switch ($stageId) {
-                       case self::STAGE_PUBLISH_EXECUTE_ID:
-                       case self::STAGE_PUBLISH_ID:
-                               if ($selectDefaultUserField == FALSE) {
-                                       $userList = $this->getResponsibleUser($workspaceRec['adminusers']);
-                               } else {
-                                       $notification_default_user = $workspaceRec['publish_notification_defaults'];
-                                       $userList = $this->getResponsibleUser($notification_default_user);
-                               }
-                               break;
-                       case self::STAGE_EDIT_ID:
-                               if ($selectDefaultUserField == FALSE) {
-                                       $userList = $this->getResponsibleUser($workspaceRec['members']);
-                               } else {
-                                       $notification_default_user = $workspaceRec['edit_notification_defaults'];
-                                       $userList = $this->getResponsibleUser($notification_default_user);
-                               }
-                               break;
-                       default:
-                               if ($selectDefaultUserField == FALSE) {
-                                       $responsible_persons = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'responsible_persons');
-                                       $userList = $this->getResponsibleUser($responsible_persons);
-                               } else {
-                                       $notification_default_user = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'notification_defaults');
-                                       $userList = $this->getResponsibleUser($notification_default_user);
-                               }
-                               break;
-               }
+               case self::STAGE_PUBLISH_EXECUTE_ID:
 
+               case self::STAGE_PUBLISH_ID:
+                       if ($selectDefaultUserField == FALSE) {
+                               $userList = $this->getResponsibleUser($workspaceRec['adminusers']);
+                       } else {
+                               $notification_default_user = $workspaceRec['publish_notification_defaults'];
+                               $userList = $this->getResponsibleUser($notification_default_user);
+                       }
+                       break;
+               case self::STAGE_EDIT_ID:
+                       if ($selectDefaultUserField == FALSE) {
+                               $userList = $this->getResponsibleUser($workspaceRec['members']);
+                       } else {
+                               $notification_default_user = $workspaceRec['edit_notification_defaults'];
+                               $userList = $this->getResponsibleUser($notification_default_user);
+                       }
+                       break;
+               default:
+                       if ($selectDefaultUserField == FALSE) {
+                               $responsible_persons = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'responsible_persons');
+                               $userList = $this->getResponsibleUser($responsible_persons);
+                       } else {
+                               $notification_default_user = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'notification_defaults');
+                               $userList = $this->getResponsibleUser($notification_default_user);
+                       }
+                       break;
+               }
                if (!empty($userList)) {
-                       $userRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName',
-                                       'AND uid IN (' . $userList . ')');
+                       $userRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName', ('AND uid IN (' . $userList) . ')');
                }
-
                if (!empty($userRecords) && is_array($userRecords)) {
                        foreach ($userRecords as $userUid => $userRecord) {
                                $recipientArray[$userUid] = $userRecord;
@@ -540,20 +497,19 @@ class Tx_Workspaces_Service_Stages {
        /**
         * Get uids of all responsilbe persons for a stage
         *
-        * @param       string  responsible_persion value from stage record
-        * @return      string  uid list of responsible be_users
+        * @param       string  responsible_persion value from stage record
+        * @return      string  uid list of responsible be_users
         */
        public function getResponsibleUser($stageRespValue) {
                $stageValuesArray = array();
                $stageValuesArray = t3lib_div::trimExplode(',', $stageRespValue);
-
                $beuserUidArray = array();
                $begroupUidArray = array();
                $allBeUserArray = array();
                $begroupUidList = array();
-
                foreach ($stageValuesArray as $key => $uidvalue) {
-                       if (strstr($uidvalue, 'be_users') !== FALSE) { // Current value is a uid of a be_user record
+                       if (strstr($uidvalue, 'be_users') !== FALSE) {
+                               // Current value is a uid of a be_user record
                                $beuserUidArray[] = str_replace('be_users_', '', $uidvalue);
                        } elseif (strstr($uidvalue, 'be_groups') !== FALSE) {
                                $begroupUidArray[] = str_replace('be_groups_', '', $uidvalue);
@@ -563,12 +519,9 @@ class Tx_Workspaces_Service_Stages {
                }
                if (!empty($begroupUidArray)) {
                        $allBeUserArray = t3lib_befunc::getUserNames();
-
                        $begroupUidList = implode(',', $begroupUidArray);
-
                        $this->userGroups = array();
                        $begroupUidArray = $this->fetchGroups($begroupUidList);
-
                        foreach ($begroupUidArray as $groupkey => $groupData) {
                                foreach ($allBeUserArray as $useruid => $userdata) {
                                        if (t3lib_div::inList($userdata['usergroup_cached_list'], $groupData['uid'])) {
@@ -577,26 +530,23 @@ class Tx_Workspaces_Service_Stages {
                                }
                        }
                }
-
                array_unique($beuserUidArray);
                return implode(',', $beuserUidArray);
        }
 
-
        /**
-        * @param  $grList
+        * @param $grList
         * @param string $idList
         * @return array
         */
        private function fetchGroups($grList, $idList = '') {
-
                $cacheKey = md5($grList . $idList);
                $groupList = array();
                if (isset($this->fetchGroupsCache[$cacheKey])) {
                        $groupList = $this->fetchGroupsCache[$cacheKey];
                } else {
                        if ($idList === '') {
-                                       // we're at the beginning of the recursion and therefore we need to reset the userGroups member
+                               // we're at the beginning of the recursion and therefore we need to reset the userGroups member
                                $this->userGroups = array();
                        }
                        $groupList = $this->fetchGroupsRecursive($grList);
@@ -606,14 +556,13 @@ class Tx_Workspaces_Service_Stages {
        }
 
        /**
-        * @param  array        $groups
+        * @param array         $groups
         * @return void
         */
        private function fetchGroupsFromDB(array $groups) {
-               $whereSQL = 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . implode(',', $groups) . ') ';
+               $whereSQL = ('deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . implode(',', $groups)) . ') ';
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'be_groups', $whereSQL);
-
-                       // The userGroups array is filled
+               // The userGroups array is filled
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                        $this->userGroups[$row['uid']] = $row;
                }
@@ -622,7 +571,7 @@ class Tx_Workspaces_Service_Stages {
        /**
         * Fetches particular groups recursively.
         *
-        * @param  $grList
+        * @param $grList
         * @param string $idList
         * @return array
         */
@@ -630,32 +579,31 @@ class Tx_Workspaces_Service_Stages {
                $requiredGroups = t3lib_div::intExplode(',', $grList, TRUE);
                $existingGroups = array_keys($this->userGroups);
                $missingGroups = array_diff($requiredGroups, $existingGroups);
-
                if (count($missingGroups) > 0) {
                        $this->fetchGroupsFromDB($missingGroups);
                }
-
-                       // Traversing records in the correct order
-               foreach ($requiredGroups as $uid) { // traversing list
-                               // Get row:
+               // Traversing records in the correct order
+               foreach ($requiredGroups as $uid) {
+                       // traversing list
+                       // Get row:
                        $row = $this->userGroups[$uid];
-                       if (is_array($row) && !t3lib_div::inList($idList, $uid)) { // Must be an array and $uid should not be in the idList, because then it is somewhere previously in the grouplist
-                                       // If the localconf.php option isset the user of the sub- sub- groups will also be used
+                       if (is_array($row) && !t3lib_div::inList($idList, $uid)) {
+                               // Must be an array and $uid should not be in the idList, because then it is somewhere previously in the grouplist
+                               // If the localconf.php option isset the user of the sub- sub- groups will also be used
                                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['customStageShowRecipientRecursive'] == 1) {
-                                               // Include sub groups
+                                       // Include sub groups
                                        if (trim($row['subgroup'])) {
-                                                       // Make integer list
+                                               // Make integer list
                                                $theList = implode(',', t3lib_div::intExplode(',', $row['subgroup']));
-                                                       // Get the subarray
-                                               $subbarray = $this->fetchGroups($theList, $idList . ',' . $uid);
+                                               // Get the subarray
+                                               $subbarray = $this->fetchGroups($theList, ($idList . ',') . $uid);
                                                list($subUid, $subArray) = each($subbarray);
-                                                       // Merge the subarray to the already existing userGroups array
+                                               // Merge the subarray to the already existing userGroups array
                                                $this->userGroups[$subUid] = $subArray;
                                        }
                                }
                        }
                }
-
                return $this->userGroups;
        }
 
@@ -668,17 +616,13 @@ class Tx_Workspaces_Service_Stages {
         */
        public function getPropertyOfCurrentWorkspaceStage($stageId, $property) {
                $result = NULL;
-
                if (!t3lib_utility_Math::canBeInterpretedAsInteger($stageId)) {
                        throw new InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'));
                }
-
                $workspaceStage = t3lib_BEfunc::getRecord(self::TABLE_STAGE, $stageId);
-
                if (is_array($workspaceStage) && isset($workspaceStage[$property])) {
                        $result = $workspaceStage[$property];
                }
-
                return $result;
        }
 
@@ -691,23 +635,22 @@ class Tx_Workspaces_Service_Stages {
        public function getPositionOfCurrentStage($stageId) {
                $stagesOfWS = $this->getStagesForWS();
                $countOfStages = count($stagesOfWS);
-
                switch ($stageId) {
-                       case self::STAGE_PUBLISH_ID:
-                                       $position = $countOfStages;
-                               break;
-                       case self::STAGE_EDIT_ID:
-                                       $position = 1;
-                               break;
-                       default:
-                               $position = 1;
-                               foreach ($stagesOfWS as $key => $stageInfoArray) {
-                                       $position++;
-                                       if ($stageId == $stageInfoArray['uid']) {
-                                               break;
-                                       }
+               case self::STAGE_PUBLISH_ID:
+                       $position = $countOfStages;
+                       break;
+               case self::STAGE_EDIT_ID:
+                       $position = 1;
+                       break;
+               default:
+                       $position = 1;
+                       foreach ($stagesOfWS as $key => $stageInfoArray) {
+                               $position++;
+                               if ($stageId == $stageInfoArray['uid']) {
+                                       break;
                                }
-                               break;
+                       }
+                       break;
                }
                return array('position' => $position, 'count' => $countOfStages);
        }
@@ -715,55 +658,53 @@ class Tx_Workspaces_Service_Stages {
        /**
         * Check if the user has access to the previous stage, relative to the given stage
         *
-        * @param  integer $stageId
+        * @param integer $stageId
         * @return bool
         */
        public function isPrevStageAllowedForUser($stageId) {
                $isAllowed = FALSE;
                try {
                        $prevStage = $this->getPrevStage($stageId);
-                               // if there's no prev-stage the stageIds match,
-                               // otherwise we've to check if the user is permitted to use the stage
+                       // if there's no prev-stage the stageIds match,
+                       // otherwise we've to check if the user is permitted to use the stage
                        if (!empty($prevStage) && $prevStage['uid'] != $stageId) {
-                                       // if the current stage is allowed for the user, the user is also allowed to send to prev
+                               // if the current stage is allowed for the user, the user is also allowed to send to prev
                                $isAllowed = $this->isStageAllowedForUser($stageId);
                        }
                } catch (Exception $e) {
-                       // Exception raised - we're not allowed to go this way
-               }
 
+               }
                return $isAllowed;
        }
 
        /**
         * Check if the user has access to the next stage, relative to the given stage
         *
-        * @param  integer $stageId
+        * @param integer $stageId
         * @return bool
         */
        public function isNextStageAllowedForUser($stageId) {
                $isAllowed = FALSE;
                try {
                        $nextStage = $this->getNextStage($stageId);
-                               // if there's no next-stage the stageIds match,
-                               // otherwise we've to check if the user is permitted to use the stage
+                       // if there's no next-stage the stageIds match,
+                       // otherwise we've to check if the user is permitted to use the stage
                        if (!empty($nextStage) && $nextStage['uid'] != $stageId) {
-                                       // if the current stage is allowed for the user, the user is also allowed to send to next
+                               // if the current stage is allowed for the user, the user is also allowed to send to next
                                $isAllowed = $this->isStageAllowedForUser($stageId);
                        }
                } catch (Exception $e) {
-                       // Exception raised - we're not allowed to go this way
-               }
 
+               }
                return $isAllowed;
        }
 
        /**
-        * @param  $stageId
+        * @param $stageId
         * @return bool
         */
        protected function isStageAllowedForUser($stageId) {
-               $cacheKey = $this->getWorkspaceId() . '_' . $stageId;
+               $cacheKey = ($this->getWorkspaceId() . '_') . $stageId;
                $isAllowed = FALSE;
                if (isset($this->workspaceStageAllowedCache[$cacheKey])) {
                        $isAllowed = $this->workspaceStageAllowedCache[$cacheKey];
@@ -783,14 +724,12 @@ class Tx_Workspaces_Service_Stages {
        public function isValid($stageId) {
                $isValid = FALSE;
                $stages = $this->getStagesForWS();
-
                foreach ($stages as $stage) {
                        if ($stage['uid'] == $stageId) {
                                $isValid = TRUE;
                                break;
                        }
                }
-
                return $isValid;
        }
 
@@ -809,25 +748,26 @@ class Tx_Workspaces_Service_Stages {
                if (!t3lib_utility_Math::canBeInterpretedAsInteger($stageId)) {
                        throw new InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:error.stageId.integer'));
                }
-
                switch ($stageId) {
-                       case self::STAGE_PUBLISH_EXECUTE_ID:
-                       case self::STAGE_PUBLISH_ID:
-                                       $workspaceRecord = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
-                                       return $workspaceRecord['publish_notification_mode'];
-                               break;
-                       case self::STAGE_EDIT_ID:
-                                       $workspaceRecord = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
-                                       return $workspaceRecord['edit_notification_mode'];
-                               break;
-                       default:
-                               $workspaceStage = t3lib_BEfunc::getRecord(self::TABLE_STAGE, $stageId);
-
-                               if (is_array($workspaceStage) && isset($workspaceStage['notification_mode'])) {
-                                       return $workspaceStage['notification_mode'];
-                               }
-                               break;
+               case self::STAGE_PUBLISH_EXECUTE_ID:
+
+               case self::STAGE_PUBLISH_ID:
+                       $workspaceRecord = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
+                       return $workspaceRecord['publish_notification_mode'];
+                       break;
+               case self::STAGE_EDIT_ID:
+                       $workspaceRecord = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
+                       return $workspaceRecord['edit_notification_mode'];
+                       break;
+               default:
+                       $workspaceStage = t3lib_BEfunc::getRecord(self::TABLE_STAGE, $stageId);
+                       if (is_array($workspaceStage) && isset($workspaceStage['notification_mode'])) {
+                               return $workspaceStage['notification_mode'];
+                       }
+                       break;
                }
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Tcemain.php b/typo3/sysext/workspaces/Classes/Service/Tcemain.php
new file mode 100644 (file)
index 0000000..03c6498
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Tcemain and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
+ */
+?>
\ No newline at end of file
index 5faaf28..c6e2414 100644 (file)
@@ -24,7 +24,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * Workspace service
  *
@@ -33,6 +32,7 @@
  * @subpackage Service
  */
 class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
+
        /**
         * @var array
         */
@@ -41,22 +41,19 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
        const TABLE_WORKSPACE = 'sys_workspace';
        const SELECT_ALL_WORKSPACES = -98;
        const LIVE_WORKSPACE_ID = 0;
-
        /**
         * retrieves the available workspaces from the database and checks whether
         * they're available to the current BE user
         *
-        * @return      array   array of worspaces available to the current user
+        * @return      array   array of worspaces available to the current user
         */
        public function getAvailableWorkspaces() {
                $availableWorkspaces = array();
-
-                       // add default workspaces
+               // add default workspaces
                if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => (string) self::LIVE_WORKSPACE_ID))) {
                        $availableWorkspaces[self::LIVE_WORKSPACE_ID] = self::getWorkspaceTitle(self::LIVE_WORKSPACE_ID);
                }
-
-                       // add custom workspaces (selecting all, filtering by BE_USER check):
+               // add custom workspaces (selecting all, filtering by BE_USER check):
                $customWorkspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid, title, adminusers, members', 'sys_workspace', 'pid = 0' . t3lib_BEfunc::deleteClause('sys_workspace'), '', 'title');
                if (count($customWorkspaces)) {
                        foreach ($customWorkspaces as $workspace) {
@@ -65,7 +62,6 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                                }
                        }
                }
-
                return $availableWorkspaces;
        }
 
@@ -89,45 +85,39 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * @param integer $wsId
         * @return string
         */
-       public static function getWorkspaceTitle($wsId) {
+       static public function getWorkspaceTitle($wsId) {
                $title = FALSE;
                switch ($wsId) {
-                       case self::LIVE_WORKSPACE_ID:
-                               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS');
-                               break;
-                       default:
-                               $labelField = $GLOBALS['TCA']['sys_workspace']['ctrl']['label'];
-                               $wsRecord = t3lib_beFunc::getRecord('sys_workspace', $wsId, 'uid,' . $labelField);
-                               if (is_array($wsRecord)) {
-                                       $title = $wsRecord[$labelField];
-                               }
+               case self::LIVE_WORKSPACE_ID:
+                       $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS');
+                       break;
+               default:
+                       $labelField = $GLOBALS['TCA']['sys_workspace']['ctrl']['label'];
+                       $wsRecord = t3lib_beFunc::getRecord('sys_workspace', $wsId, 'uid,' . $labelField);
+                       if (is_array($wsRecord)) {
+                               $title = $wsRecord[$labelField];
+                       }
                }
-
                if ($title === FALSE) {
                        throw new InvalidArgumentException('No such workspace defined');
                }
-
                return $title;
        }
 
-
        /**
         * Building tcemain CMD-array for swapping all versions in a workspace.
         *
-        * @param       integer         Real workspace ID, cannot be ONLINE (zero).
-        * @param       boolean         If set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied.
-        * @param       integer         $pageId: ...
-        * @param       integer         $language Select specific language only
-        * @return      array           Command array for tcemain
+        * @param       integer         Real workspace ID, cannot be ONLINE (zero).
+        * @param       boolean         If set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied.
+        * @param       integer         $pageId: ...
+        * @param       integer         $language Select specific language only
+        * @return      array           Command array for tcemain
         */
        public function getCmdArrayForPublishWS($wsid, $doSwap, $pageId = 0, $language = NULL) {
-
                $wsid = intval($wsid);
                $cmd = array();
-
-               if ($wsid >= -1 && $wsid!==0) {
-
-                               // Define stage to select:
+               if ($wsid >= -1 && $wsid !== 0) {
+                       // Define stage to select:
                        $stage = -99;
                        if ($wsid > 0) {
                                $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $wsid);
@@ -135,14 +125,12 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                                        $stage = Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID;
                                }
                        }
-
-                               // Select all versions to swap:
-                       $versions = $this->selectVersionsInWorkspace($wsid, 0, $stage, ($pageId ? $pageId : -1), 0, 'tables_modify', $language);
-
-                               // Traverse the selection to build CMD array:
+                       // Select all versions to swap:
+                       $versions = $this->selectVersionsInWorkspace($wsid, 0, $stage, $pageId ? $pageId : -1, 0, 'tables_modify', $language);
+                       // Traverse the selection to build CMD array:
                        foreach ($versions as $table => $records) {
                                foreach ($records as $rec) {
-                                               // Build the cmd Array:
+                                       // Build the cmd Array:
                                        $cmd[$table][$rec['t3ver_oid']]['version'] = array('action' => 'swap', 'swapWith' => $rec['uid'], 'swapIntoWS' => $doSwap ? 1 : 0);
                                }
                        }
@@ -150,69 +138,60 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                return $cmd;
        }
 
-
        /**
         * Building tcemain CMD-array for releasing all versions in a workspace.
         *
-        * @param       integer         Real workspace ID, cannot be ONLINE (zero).
-        * @param       boolean         Run Flush (TRUE) or ClearWSID (FALSE) command
-        * @param       integer         $pageId: ...
-        * @param       integer         $language Select specific language only
-        * @return      array           Command array for tcemain
+        * @param       integer         Real workspace ID, cannot be ONLINE (zero).
+        * @param       boolean         Run Flush (TRUE) or ClearWSID (FALSE) command
+        * @param       integer         $pageId: ...
+        * @param       integer         $language Select specific language only
+        * @return      array           Command array for tcemain
         */
        public function getCmdArrayForFlushWS($wsid, $flush = TRUE, $pageId = 0, $language = NULL) {
-
                $wsid = intval($wsid);
                $cmd = array();
-
-               if ($wsid >= -1 && $wsid!==0) {
-                               // Define stage to select:
+               if ($wsid >= -1 && $wsid !== 0) {
+                       // Define stage to select:
                        $stage = -99;
-
-                               // Select all versions to swap:
-                       $versions = $this->selectVersionsInWorkspace($wsid, 0, $stage, ($pageId ? $pageId : -1), 0, 'tables_modify', $language);
-
-                               // Traverse the selection to build CMD array:
+                       // Select all versions to swap:
+                       $versions = $this->selectVersionsInWorkspace($wsid, 0, $stage, $pageId ? $pageId : -1, 0, 'tables_modify', $language);
+                       // Traverse the selection to build CMD array:
                        foreach ($versions as $table => $records) {
                                foreach ($records as $rec) {
                                        // Build the cmd Array:
-                                       $cmd[$table][$rec['uid']]['version'] = array('action' => ($flush ? 'flush' : 'clearWSID'));
+                                       $cmd[$table][$rec['uid']]['version'] = array('action' => $flush ? 'flush' : 'clearWSID');
                                }
                        }
                }
                return $cmd;
        }
 
-
        /**
         * Select all records from workspace pending for publishing
         * Used from backend to display workspace overview
         * User for auto-publishing for selecting versions for publication
         *
-        * @param       integer         Workspace ID. If -99, will select ALL versions from ANY workspace. If -98 will select all but ONLINE. >=-1 will select from the actual workspace
-        * @param       integer         Lifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple), anything else selects all.
-        * @param       integer         Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10"
-        * @param       integer         Page id: Live page for which to find versions in workspace!
-        * @param       integer         Recursion Level - select versions recursive - parameter is only relevant if $pageId != -1
-        * @param       string          How to collect records for "listing" or "modify" these tables. Support the permissions of each type of record (@see t3lib_userAuthGroup::check).
-        * @parem       integer         $language Select specific language only
-        * @return      array           Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oidfields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
+        * @param       integer         Workspace ID. If -99, will select ALL versions from ANY workspace. If -98 will select all but ONLINE. >=-1 will select from the actual workspace
+        * @param       integer         Lifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple), anything else selects all.
+        * @param       integer         Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10
+        * @param       integer         Page id: Live page for which to find versions in workspace!
+        * @param       integer         Recursion Level - select versions recursive - parameter is only relevant if $pageId != -1
+        * @param       string          How to collect records for "listing" or "modify" these tables. Support the permissions of each type of record (@see t3lib_userAuthGroup::check).
+        * @parem       integer         $language Select specific language only
+        * @return      array           Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oidfields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
         */
        public function selectVersionsInWorkspace($wsid, $filter = 0, $stage = -99, $pageId = -1, $recursionLevel = 0, $selectionType = 'tables_select', $language = NULL) {
-
                $wsid = intval($wsid);
                $filter = intval($filter);
                $output = array();
-
-                       // Contains either nothing or a list with live-uids
+               // Contains either nothing or a list with live-uids
                if ($pageId != -1 && $recursionLevel > 0) {
                        $pageList = $this->getTreeUids($pageId, $wsid, $recursionLevel);
                } elseif ($pageId != -1) {
                        $pageList = $pageId;
                } else {
                        $pageList = '';
-
-                               // check if person may only see a "virtual" page-root
+                       // check if person may only see a "virtual" page-root
                        $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
                        $mountPoints = array_unique($mountPoints);
                        if (!in_array(0, $mountPoints)) {
@@ -223,17 +202,13 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                                $pageList = implode(',', $tempPageIds);
                        }
                }
-
-                       // Traversing all tables supporting versioning:
+               // Traversing all tables supporting versioning:
                foreach ($GLOBALS['TCA'] as $table => $cfg) {
-
-                               // we do not collect records from tables without permissions on them.
-                       if (! $GLOBALS['BE_USER']->check($selectionType, $table)) {
+                       // we do not collect records from tables without permissions on them.
+                       if (!$GLOBALS['BE_USER']->check($selectionType, $table)) {
                                continue;
                        }
-
                        if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-
                                $recs = $this->selectAllVersionsFromPages($table, $pageList, $wsid, $filter, $stage, $language);
                                if (intval($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) === 2) {
                                        $moveRecs = $this->getMoveToPlaceHolderFromPages($table, $pageList, $wsid, $filter, $stage);
@@ -262,78 +237,60 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
        protected function selectAllVersionsFromPages($table, $pageList, $wsid, $filter, $stage, $language = NULL) {
                $isTableLocalizable = t3lib_BEfunc::isTableLocalizable($table);
                $languageParentField = '';
-
-                       // If table is not localizable, but localized reocrds shall
-                       // be collected, an empty result array needs to be returned:
+               // If table is not localizable, but localized reocrds shall
+               // be collected, an empty result array needs to be returned:
                if ($isTableLocalizable === FALSE && $language > 0) {
                        return array();
                } elseif ($isTableLocalizable) {
-                       $languageParentField = 'A.' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ', ';
+                       $languageParentField = ('A.' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) . ', ';
                }
-
-               $fields = 'A.uid, A.t3ver_oid, A.t3ver_stage, ' . $languageParentField . 'B.pid AS wspid, B.pid AS livepid';
-
+               $fields = ('A.uid, A.t3ver_oid, A.t3ver_stage, ' . $languageParentField) . 'B.pid AS wspid, B.pid AS livepid';
                if ($isTableLocalizable) {
                        $fields .= ', A.' . $GLOBALS['TCA'][$table]['ctrl']['languageField'];
                }
-
-               $from = $table . ' A,' . $table . ' B';
-
-                       // Table A is the offline version and pid=-1 defines offline
+               $from = (($table . ' A,') . $table) . ' B';
+               // Table A is the offline version and pid=-1 defines offline
                $where = 'A.pid=-1 AND A.t3ver_state!=4';
-
                if ($pageList) {
-                       $pidField = ($table==='pages' ? 'uid' : 'pid');
-                       $pidConstraint = strstr($pageList, ',') ? ' IN (' . $pageList . ')' : '=' . $pageList;
-                       $where .= ' AND B.' . $pidField . $pidConstraint;
+                       $pidField = $table === 'pages' ? 'uid' : 'pid';
+                       $pidConstraint = strstr($pageList, ',') ? (' IN (' . $pageList) . ')' : '=' . $pageList;
+                       $where .= (' AND B.' . $pidField) . $pidConstraint;
                }
-
                if ($isTableLocalizable && t3lib_utility_Math::canBeInterpretedAsInteger($language)) {
-                       $where .= ' AND A.' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . $language;
+                       $where .= ((' AND A.' . $GLOBALS['TCA'][$table]['ctrl']['languageField']) . '=') . $language;
                }
-
-               /**
-                * For "real" workspace numbers, select by that.
-                * If = -98, select all that are NOT online (zero).
-                * Anything else below -1 will not select on the wsid and therefore select all!
-                */
+               /** For "real" workspace numbers, select by that.
+               If = -98, select all that are NOT online (zero).
+               Anything else below -1 will not select on the wsid and therefore select all! */
                if ($wsid > self::SELECT_ALL_WORKSPACES) {
                        $where .= ' AND A.t3ver_wsid=' . $wsid;
                } elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
                        $where .= ' AND A.t3ver_wsid!=0';
                }
-
-               /**
-                * lifecycle filter:
-                * 1 = select all drafts (never-published),
-                * 2 = select all published one or more times (archive/multiple)
-                */
-               if ($filter===1 || $filter===2) {
+               /** lifecycle filter:
+               1 = select all drafts (never-published),
+               2 = select all published one or more times (archive/multiple) */
+               if ($filter === 1 || $filter === 2) {
                        $where .= ' AND A.t3ver_count ' . ($filter === 1 ? '= 0' : '> 0');
                }
-
                if ($stage != -99) {
                        $where .= ' AND A.t3ver_stage=' . intval($stage);
                }
-
-                       // Table B (online) must have PID >= 0 to signify being online.
+               // Table B (online) must have PID >= 0 to signify being online.
                $where .= ' AND B.pid>=0';
-                       // ... and finally the join between the two tables.
+               // ... and finally the join between the two tables.
                $where .= ' AND A.t3ver_oid=B.uid';
                $where .= t3lib_BEfunc::deleteClause($table, 'A');
                $where .= t3lib_BEfunc::deleteClause($table, 'B');
-
-               /**
-                * Select all records from this table in the database from the workspace
-                * This joins the online version with the offline version as tables A and B
-                * Order by UID, mostly to have a sorting in the backend overview module which doesn't "jump around" when swapping.
-                */
+               /** Select all records from this table in the database from the workspace
+               This joins the online version with the offline version as tables A and B
+               Order by UID, mostly to have a sorting in the backend overview module which doesn't "jump around" when swapping. */
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $from, $where, '', 'B.uid');
                return is_array($res) ? $res : array();
        }
 
        /**
-        *      Find all moved records at their new position.
+        * Find all moved records at their new position.
         *
         * @param string $table
         * @param string $pageList
@@ -343,70 +300,54 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * @return array
         */
        protected function getMoveToPlaceHolderFromPages($table, $pageList, $wsid, $filter, $stage) {
-
-               /**
-                * Aliases:
-                * A - moveTo placeholder
-                * B - online record
-                * C - moveFrom placeholder
-                */
+               /** Aliases:
+               A - moveTo placeholder
+               B - online record
+               C - moveFrom placeholder */
                $fields = 'A.pid AS wspid, B.uid AS t3ver_oid, C.uid AS uid, B.pid AS livepid';
-               $from = $table . ' A, ' . $table . ' B,' . $table . ' C';
+               $from = (((($table . ' A, ') . $table) . ' B,') . $table) . ' C';
                $where = 'A.t3ver_state=3 AND B.pid>0 AND B.t3ver_state=0 AND B.t3ver_wsid=0 AND C.pid=-1 AND C.t3ver_state=4';
-
                if ($wsid > self::SELECT_ALL_WORKSPACES) {
-                       $where .= ' AND A.t3ver_wsid=' . $wsid . ' AND C.t3ver_wsid=' . $wsid;
+                       $where .= ((' AND A.t3ver_wsid=' . $wsid) . ' AND C.t3ver_wsid=') . $wsid;
                } elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
                        $where .= ' AND A.t3ver_wsid!=0 AND C.t3ver_wsid!=0 ';
                }
-
-               /**
-                * lifecycle filter:
-                * 1 = select all drafts (never-published),
-                * 2 = select all published one or more times (archive/multiple)
-                */
-               if ($filter===1 || $filter===2) {
+               /** lifecycle filter:
+               1 = select all drafts (never-published),
+               2 = select all published one or more times (archive/multiple) */
+               if ($filter === 1 || $filter === 2) {
                        $where .= ' AND C.t3ver_count ' . ($filter === 1 ? '= 0' : '> 0');
                }
-
                if ($stage != -99) {
                        $where .= ' AND C.t3ver_stage=' . intval($stage);
                }
-
                if ($pageList) {
-                       $pidField = ($table==='pages' ? 'B.uid' : 'A.pid');
-                       $pidConstraint = strstr($pageList, ',') ? ' IN (' . $pageList . ')' : '=' . $pageList;
-                       $where .= ' AND ' . $pidField . $pidConstraint;
+                       $pidField = $table === 'pages' ? 'B.uid' : 'A.pid';
+                       $pidConstraint = strstr($pageList, ',') ? (' IN (' . $pageList) . ')' : '=' . $pageList;
+                       $where .= (' AND ' . $pidField) . $pidConstraint;
                }
-
                $where .= ' AND A.t3ver_move_id = B.uid AND B.uid = C.t3ver_oid';
                $where .= t3lib_BEfunc::deleteClause($table, 'A');
                $where .= t3lib_BEfunc::deleteClause($table, 'B');
                $where .= t3lib_BEfunc::deleteClause($table, 'C');
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $from, $where, '', 'A.uid');
-
                return is_array($res) ? $res : array();
        }
 
-
        /**
         * Find all page uids recursive starting from a specific page
         *
-        * @param        integer        $pageId
-        * @param        integer        $wsid
-        * @param        integer        $recursionLevel
-        * @return      string  Comma sep. uid list
+        * @param        integer        $pageId
+        * @param        integer        $wsid
+        * @param        integer        $recursionLevel
+        * @return      string  Comma sep. uid list
         */
        protected function getTreeUids($pageId, $wsid, $recursionLevel) {
-               /**
-                * Reusing existing functionality with the drawback that
-                * mount points are not covered yet
-                **/
+               /** Reusing existing functionality with the drawback that
+               mount points are not covered yet */
                $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
-
                /** @var $searchObj t3lib_fullsearch */
                $searchObj = t3lib_div::makeInstance('t3lib_fullsearch');
-
                if ($pageId > 0) {
                        $pageList = $searchObj->getTreeList($pageId, $recursionLevel, 0, $perms_clause);
                } else {
@@ -421,27 +362,16 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                        }
                        $pageList = implode(',', $newList);
                }
-
                unset($searchObj);
                if (intval($GLOBALS['TCA']['pages']['ctrl']['versioningWS']) === 2 && $pageList) {
-                               // Remove the "subbranch" if a page was moved away
-                       $movedAwayPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'uid, pid, t3ver_move_id',
-                               'pages',
-                               't3ver_move_id IN (' . $pageList . ') AND t3ver_wsid=' . intval($wsid) . t3lib_BEfunc::deleteClause('pages'),
-                               '',
-                               'uid',
-                               '',
-                               't3ver_move_id'
-                       );
+                       // Remove the "subbranch" if a page was moved away
+                       $movedAwayPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid, pid, t3ver_move_id', 'pages', ((('t3ver_move_id IN (' . $pageList) . ') AND t3ver_wsid=') . intval($wsid)) . t3lib_BEfunc::deleteClause('pages'), '', 'uid', '', 't3ver_move_id');
                        $pageIds = t3lib_div::intExplode(',', $pageList, TRUE);
-
-                               // move all pages away
+                       // move all pages away
                        $newList = array_diff($pageIds, array_keys($movedAwayPages));
-
-                               // keep current page in the list
+                       // keep current page in the list
                        $newList[] = $pageId;
-                               // move back in if still connected to the "remaining" pages
+                       // move back in if still connected to the "remaining" pages
                        do {
                                $changed = FALSE;
                                foreach ($movedAwayPages as $uid => $rec) {
@@ -452,18 +382,8 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                                }
                        } while ($changed);
                        $pageList = implode(',', $newList);
-
-                               // In case moving pages is enabled we need to replace all move-to pointer with their origin
-                       $pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               'uid, t3ver_move_id',
-                               'pages',
-                               'uid IN (' . $pageList . ')' . t3lib_BEfunc::deleteClause('pages'),
-                               '',
-                               'uid',
-                               '',
-                               'uid'
-                       );
-
+                       // In case moving pages is enabled we need to replace all move-to pointer with their origin
+                       $pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid, t3ver_move_id', 'pages', (('uid IN (' . $pageList) . ')') . t3lib_BEfunc::deleteClause('pages'), '', 'uid', '', 'uid');
                        $newList = array();
                        $pageIds = t3lib_div::intExplode(',', $pageList, TRUE);
                        if (!in_array($pageId, $pageIds)) {
@@ -489,7 +409,7 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * @return array
         */
        protected function filterPermittedElements($recs, $table) {
-               $checkField = ($table == 'pages') ? 'uid' : 'wspid';
+               $checkField = $table == 'pages' ? 'uid' : 'wspid';
                $permittedElements = array();
                if (is_array($recs)) {
                        foreach ($recs as $rec) {
@@ -503,21 +423,19 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
        }
 
        /**
-       * Check current be users language access on given record.
-       *
-       * @param string $table Name of the table
-       * @param array $record Record row to be checked
-       * @return boolean
-       */
+        * Check current be users language access on given record.
+        *
+        * @param string $table Name of the table
+        * @param array $record Record row to be checked
+        * @return boolean
+        */
        protected function isLanguageAccessibleForCurrentUser($table, array $record) {
                $languageUid = 0;
-
                if (t3lib_BEfunc::isTableLocalizable($table)) {
                        $languageUid = $record[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
                } else {
                        return TRUE;
                }
-
                return $GLOBALS['BE_USER']->checkLanguageAccess($languageUid);
        }
 
@@ -527,7 +445,7 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         *
         * @return bool
         */
-       public static function isOldStyleWorkspaceUsed() {
+       static public function isOldStyleWorkspaceUsed() {
                $oldStyleWorkspaceIsUsed = FALSE;
                $cacheKey = 'workspace-oldstyleworkspace-notused';
                $cacheResult = $GLOBALS['BE_USER']->getSessionData($cacheKey);
@@ -550,20 +468,18 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * @param $language Language for which to check the page
         * @return bool
         */
-       public static function isNewPage($id, $language = 0) {
+       static public function isNewPage($id, $language = 0) {
                $isNewPage = FALSE;
-                       // If the language is not default, check state of overlay
+               // If the language is not default, check state of overlay
                if ($language > 0) {
                        $whereClause = 'pid = ' . $id;
-                       $whereClause .= ' AND ' .$GLOBALS['TCA']['pages_language_overlay']['ctrl']['languageField'] . ' = ' . $language;
+                       $whereClause .= ((' AND ' . $GLOBALS['TCA']['pages_language_overlay']['ctrl']['languageField']) . ' = ') . $language;
                        $whereClause .= ' AND t3ver_wsid = ' . $GLOBALS['BE_USER']->workspace;
                        $whereClause .= t3lib_BEfunc::deleteClause('pages_language_overlay');
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('t3ver_state', 'pages_language_overlay', $whereClause);
-                       if (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
+                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                $isNewPage = (int) $row['t3ver_state'] === 1;
                        }
-
-                       // Otherwise check state of page itself
                } else {
                        $rec = t3lib_BEfunc::getRecord('pages', $id, 't3ver_state');
                        if (is_array($rec)) {
@@ -577,12 +493,12 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * Generates a view link for a page.
         *
         * @static
-        * @param  $table
-        * @param  $uid
-        * @param  $record
+        * @param $table
+        * @param $uid
+        * @param $record
         * @return string
         */
-       public static function viewSingleRecord($table, $uid, $record=NULL) {
+       static public function viewSingleRecord($table, $uid, $record = NULL) {
                $viewUrl = '';
                if ($table == 'pages') {
                        $viewUrl = t3lib_BEfunc::viewOnClick(t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $uid));
@@ -603,8 +519,8 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
        /**
         * Determine whether this page for the current
         *
-        * @param  $pageUid
-        * @param  $workspaceUid
+        * @param $pageUid
+        * @param $workspaceUid
         * @return boolean
         */
        public function canCreatePreviewLink($pageUid, $workspaceUid) {
@@ -630,13 +546,12 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
        public function generateWorkspacePreviewLink($uid) {
                $previewObject = t3lib_div::makeInstance('Tx_Version_Preview');
                $timeToLiveHours = $previewObject->getPreviewLinkLifetime();
-               $previewKeyword = $previewObject->compilePreviewKeyword('', $GLOBALS['BE_USER']->user['uid'], ($timeToLiveHours*3600), $this->getCurrentWorkspace());
-
+               $previewKeyword = $previewObject->compilePreviewKeyword('', $GLOBALS['BE_USER']->user['uid'], $timeToLiveHours * 3600, $this->getCurrentWorkspace());
                $linkParams = array(
                        'ADMCMD_prev' => $previewKeyword,
                        'id' => $uid
                );
-               return t3lib_BEfunc::getViewDomain($uid) . '/index.php?' . t3lib_div::implodeArrayForUrl('', $linkParams);
+               return (t3lib_BEfunc::getViewDomain($uid) . '/index.php?') . t3lib_div::implodeArrayForUrl('', $linkParams);
        }
 
        /**
@@ -647,29 +562,24 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
         * @return string the preview link without the trailing '/'
         */
        public function generateWorkspaceSplittedPreviewLink($uid, $addDomain = FALSE) {
-                       // In case a $pageUid is submitted we need to make sure it points to a live-page
-               if ($uid >  0) {
+               // In case a $pageUid is submitted we need to make sure it points to a live-page
+               if ($uid > 0) {
                        $uid = $this->getLivePageUid($uid);
                }
-
                $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
                /** @var $uriBuilder Tx_Extbase_MVC_Web_Routing_UriBuilder */
                $uriBuilder = $objectManager->create('Tx_Extbase_MVC_Web_Routing_UriBuilder');
-               /**
-                *  This seems to be very harsh to set this directly to "/typo3 but the viewOnClick also
-                *  has /index.php as fixed value here and dealing with the backPath is very error-prone
-                *
-                *  @todo make sure this would work in local extension installation too
-                */
+               /** This seems to be very harsh to set this directly to "/typo3 but the viewOnClick also
+               has /index.php as fixed value here and dealing with the backPath is very error-prone
+
+               @todo make sure this would work in local extension installation too */
                $backPath = '/' . TYPO3_mainDir;
                $redirect = $backPath . 'index.php?redirect_url=';
-                       // @todo why do we need these additional params? the URIBuilder should add the controller, but he doesn't :(
+               // @todo why do we need these additional params? the URIBuilder should add the controller, but he doesn't :(
                $additionalParams = '&tx_workspaces_web_workspacesworkspaces%5Bcontroller%5D=Preview&M=web_WorkspacesWorkspaces&id=';
-               $viewScript = $backPath . $uriBuilder->setArguments(array('tx_workspaces_web_workspacesworkspaces' => array('previewWS' => $GLOBALS['BE_USER']->workspace)))
-                                                                                               ->uriFor('index', array(), 'Tx_Workspaces_Controller_PreviewController', 'workspaces', 'web_workspacesworkspaces') . $additionalParams;
-
+               $viewScript = ($backPath . $uriBuilder->setArguments(array('tx_workspaces_web_workspacesworkspaces' => array('previewWS' => $GLOBALS['BE_USER']->workspace)))->uriFor('index', array(), 'Tx_Workspaces_Controller_PreviewController', 'workspaces', 'web_workspacesworkspaces')) . $additionalParams;
                if ($addDomain === TRUE) {
-                       return t3lib_BEfunc::getViewDomain($uid) . $redirect . urlencode($viewScript) . $uid;
+                       return ((t3lib_BEfunc::getViewDomain($uid) . $redirect) . urlencode($viewScript)) . $uid;
                } else {
                        return $viewScript;
                }
@@ -687,13 +597,14 @@ class Tx_Workspaces_Service_Workspaces implements t3lib_Singleton {
                if (!isset($this->pageCache[$uid])) {
                        $pageRecord = t3lib_beFunc::getRecord('pages', $uid);
                        if (is_array($pageRecord)) {
-                               $this->pageCache[$uid] = ($pageRecord['t3ver_oid'] ? $pageRecord['t3ver_oid'] : $uid);
+                               $this->pageCache[$uid] = $pageRecord['t3ver_oid'] ? $pageRecord['t3ver_oid'] : $uid;
                        } else {
                                throw new InvalidArgumentException('uid is supposed to point to an existing page - given value was:' . $uid, 1290628113);
                        }
                }
-
                return $this->pageCache[$uid];
        }
+
 }
+
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Classes/Service/Workspaces.php b/typo3/sysext/workspaces/Classes/Service/Workspaces.php
new file mode 100644 (file)
index 0000000..2397dbc
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * @deprecated since 6.0, the classname Tx_Workspaces_Service_Workspaces and this file is obsolete
+ * and will be removed by 7.0. The class was renamed and is now located at:
+ * typo3/sysext/workspaces/Classes/Service/WorkspaceService.php
+ */
+?>
\ No newline at end of file
index 9175c17..89cd89b 100644 (file)
@@ -21,7 +21,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * This class provides a wrapper around the autopublication
  * mechanism of workspaces, as a Scheduler task
@@ -37,16 +36,18 @@ class Tx_Workspaces_Service_AutoPublishTask extends tx_scheduler_Task {
         * Call on the workspace logic to publish workspaces whose publication date
         * is in the past
         *
-        * @return      boolean
+        * @return      boolean
         */
        public function execute() {
                $autopubObj = t3lib_div::makeInstance('Tx_Workspaces_Service_AutoPublish');
-                       // Publish the workspaces that need to be
+               // Publish the workspaces that need to be
                $autopubObj->autoPublishWorkspaces();
-                       // There's no feedback from the publishing process,
-                       // so there can't be any failure.
-                       // TODO: This could certainly be improved.
+               // There's no feedback from the publishing process,
+               // so there can't be any failure.
+               // TODO: This could certainly be improved.
                return TRUE;
        }
+
 }
+
 ?>
\ No newline at end of file
index b6f3053..bd3e500 100644 (file)
@@ -21,7 +21,6 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-
 /**
  * This class provides a task to cleanup ol preview links.
  *
@@ -35,17 +34,13 @@ class Tx_Workspaces_Service_CleanupPreviewLinkTask extends tx_scheduler_Task {
    &nb