[TASK] Use external Core Projects workspaces and version as Git submodules
authorOliver Hader <oliver@typo3.org>
Mon, 9 May 2011 12:06:39 +0000 (14:06 +0200)
committerOliver Hader <oliver@typo3.org>
Mon, 9 May 2011 12:09:43 +0000 (14:09 +0200)
Part 1/2

Change-Id: Id743a7f72e1d11ed5631d75d6fb95d89b9decd17
Resolves: #26581
Reviewed-on: http://review.typo3.org/1961
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
121 files changed:
typo3/sysext/version/ChangeLog [deleted file]
typo3/sysext/version/Resources/Private/Language/locallang_emails.xml [deleted file]
typo3/sysext/version/class.tx_version_cm1.php [deleted file]
typo3/sysext/version/class.tx_version_gui.php [deleted file]
typo3/sysext/version/class.tx_version_tcemain.php [deleted file]
typo3/sysext/version/class.tx_version_tcemain_commandmap.php [deleted file]
typo3/sysext/version/cli/conf.php [deleted file]
typo3/sysext/version/cm1/clear.gif [deleted file]
typo3/sysext/version/cm1/cm_icon.gif [deleted file]
typo3/sysext/version/cm1/conf.php [deleted file]
typo3/sysext/version/cm1/index.php [deleted file]
typo3/sysext/version/ext_autoload.php [deleted file]
typo3/sysext/version/ext_conf_template.txt [deleted file]
typo3/sysext/version/ext_emconf.php [deleted file]
typo3/sysext/version/ext_icon.gif [deleted file]
typo3/sysext/version/ext_localconf.php [deleted file]
typo3/sysext/version/ext_tables.php [deleted file]
typo3/sysext/version/last_synched_target [deleted file]
typo3/sysext/version/locallang.xml [deleted file]
typo3/sysext/version/tasks/class.tx_version_tasks_autopublish.php [deleted file]
typo3/sysext/version/tca.php [deleted file]
typo3/sysext/version/ws/.htaccess [deleted file]
typo3/sysext/version/ws/class.wslib.php [deleted file]
typo3/sysext/version/ws/class.wslib_gui.php [deleted file]
typo3/sysext/version/ws/clear.gif [deleted file]
typo3/sysext/version/ws/cli/conf.php [deleted file]
typo3/sysext/version/ws/conf.php [deleted file]
typo3/sysext/version/ws/index.php [deleted file]
typo3/sysext/version/ws/progress.gif [deleted file]
typo3/sysext/version/ws/publish.php [deleted file]
typo3/sysext/version/ws/sys_workspace.gif [deleted file]
typo3/sysext/version/ws/sys_workspace.png [deleted file]
typo3/sysext/version/ws/workspaceforms.php [deleted file]
typo3/sysext/version/ws/wsol_preview.php [deleted file]
typo3/sysext/workspaces/ChangeLog [deleted file]
typo3/sysext/workspaces/Classes/BackendUserInterface/WorkspaceSelectorToolbarItem.php [deleted file]
typo3/sysext/workspaces/Classes/Controller/AbstractController.php [deleted file]
typo3/sysext/workspaces/Classes/Controller/PreviewController.php [deleted file]
typo3/sysext/workspaces/Classes/Controller/ReviewController.php [deleted file]
typo3/sysext/workspaces/Classes/ExtDirect/AbstractHandler.php [deleted file]
typo3/sysext/workspaces/Classes/ExtDirect/ActionHandler.php [deleted file]
typo3/sysext/workspaces/Classes/ExtDirect/MassActionHandler.php [deleted file]
typo3/sysext/workspaces/Classes/ExtDirect/Server.php [deleted file]
typo3/sysext/workspaces/Classes/ExtDirect/ToolbarMenu.php [deleted file]
typo3/sysext/workspaces/Classes/Reports/StatusProvider.php [deleted file]
typo3/sysext/workspaces/Classes/Service/AutoPublish.php [deleted file]
typo3/sysext/workspaces/Classes/Service/AutoPublishTask.php [deleted file]
typo3/sysext/workspaces/Classes/Service/Befunc.php [deleted file]
typo3/sysext/workspaces/Classes/Service/Fehooks.php [deleted file]
typo3/sysext/workspaces/Classes/Service/GridData.php [deleted file]
typo3/sysext/workspaces/Classes/Service/Stages.php [deleted file]
typo3/sysext/workspaces/Classes/Service/Tcemain.php [deleted file]
typo3/sysext/workspaces/Classes/Service/Workspaces.php [deleted file]
typo3/sysext/workspaces/Resources/Private/Language/locallang.xml [deleted file]
typo3/sysext/workspaces/Resources/Private/Language/locallang_csh_sysws_stage.xml [deleted file]
typo3/sysext/workspaces/Resources/Private/Language/locallang_db.xml [deleted file]
typo3/sysext/workspaces/Resources/Private/Language/locallang_mod.xml [deleted file]
typo3/sysext/workspaces/Resources/Private/Layouts/module.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Layouts/nodoc.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Layouts/popup.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Partials/legend.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Partials/navigation.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Help.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Index.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Preview/NewPage.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Preview.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Review/FullIndex.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Review/Index.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Review/SingleIndex.html [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/bg.gif [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/generate-ws-preview-link.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/moduleicon.gif [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/slider-bg.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/slider-thumb.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/typo3-logo.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/version-workspace-sendtonextstage.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/version-workspace-sendtoprevstage.png [deleted file]
typo3/sysext/workspaces/Resources/Public/Images/workspaces-comments-arrow.gif [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/Ext.ux.plugins.TabStripContainer.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/actions.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/component.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/configuration.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/grid.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/GridFilters.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/css/GridFilters.css [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/css/RangeMenu.css [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/BooleanFilter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/DateFilter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/Filter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/ListFilter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/NumericFilter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/filter/StringFilter.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/equals.png [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/find.png [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/greater_than.png [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/less_than.png [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/sort_filtered_asc.gif [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/images/sort_filtered_desc.gif [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/menu/ListMenu.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/gridfilters/menu/RangeMenu.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/helpers.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/preview.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/toolbar.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/workspacegrid.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/workspacemenu.js [deleted file]
typo3/sysext/workspaces/Resources/Public/JavaScript/workspaces.js [deleted file]
typo3/sysext/workspaces/Resources/Public/StyleSheet/module.css [deleted file]
typo3/sysext/workspaces/Resources/Public/StyleSheet/preview.css [deleted file]
typo3/sysext/workspaces/Tests/Service/WorkspaceTest.php [deleted file]
typo3/sysext/workspaces/Tests/Service/fixtures/dbDefaultPages.xml [deleted file]
typo3/sysext/workspaces/Tests/Service/fixtures/dbDefaultWorkspaces.xml [deleted file]
typo3/sysext/workspaces/Tests/Service/fixtures/dbMovedContent.xml [deleted file]
typo3/sysext/workspaces/doc/manual.sxw [deleted file]
typo3/sysext/workspaces/ext_autoload.php [deleted file]
typo3/sysext/workspaces/ext_emconf.php [deleted file]
typo3/sysext/workspaces/ext_icon.gif [deleted file]
typo3/sysext/workspaces/ext_localconf.php [deleted file]
typo3/sysext/workspaces/ext_tables.php [deleted file]
typo3/sysext/workspaces/ext_tables.sql [deleted file]
typo3/sysext/workspaces/last_synched_target [deleted file]
typo3/sysext/workspaces/tca.php [deleted file]

diff --git a/typo3/sysext/version/ChangeLog b/typo3/sysext/version/ChangeLog
deleted file mode 100644 (file)
index d31f9e6..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-2011-02-22  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Raised version to 4.5.1
-
-2011-02-20  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Fixed bug #13096: class tx_version_tcemain_CommandMap contains calls to protected methods from tx_version_tcemain (Thanks to Andreas Kiessling)
-       * Fixed bug #13094: Cannot push IRRE records to next stage (Thanks to Andreas Kiessling)
-       * Fixed bug #13097: tx_version_tcemain->processCmdmap - &$commandIsProcessed is not set to TRUE (Thanks to Andreas Kiessling)
-
-2011-02-17  Oliver Hader  <oliver.hader@typo3.org>
-
-       * Fixed bug #12615: Dependencies in sysext 'version' and 'workspaces'
-
-2011-01-26  Tolleiv Nietsch <typo3@tolleiv.de>
-
-       * Reapplied #17284: Formprotection persistToken method is called too often, causing unnecessary DB-load - included in 4.5.0 (Thanks to Helmut Hummel / Ernesto Baschny)
-       * Raised version to 4.5.0
-
-2011-01-25  Tolleiv Nietsch <typo3@tolleiv.de>
-
-       * Raised version to 4.5.0rc2
-
-2011-01-24  Susanne Moog <typo3@susanne-moog.de>
-
-       * Fixed bug #12505: Fatal Error: Call to undefined method t3lib_TCEmain::rawCopyPageContent()
-
-2011-01-21  Tolleiv Nietsch <typo3@tolleiv.de>
-
-       * Raised version to 4.5.0rc1
-
-2011-01-20  Tolleiv Nietsch <typo3@tolleiv.de>
-
-       * Fixed bug #12386: "Publish only content in publish stage" doesn't work anymore
-
-2011-01-20  Susanne Moog <typo3@susanne-moog.de>
-
-       * Fixed bug #12397: CSRF protection for clickmenu and old workspace module (Thanks to Helmut Hummel)
-
-2011-01-12  Oliver Hader  <oliver.hader@typo3.org>
-
-       * Follow-up to bug #11832: Label of the anchor is empty
-       * Raised version to 4.5.0beta4
-
-2011-01-09  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Fixed bug #11832: Versioning - t3lib_extMgm::createListViewLink() function no longer available (Thanks to Mark Johnston)
-       * Fixed bug #16786: Generating preview link not working since Update to 4.4.5
-
-2011-01-06  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Fixed bug #11926: Language file Resources/Private/Language/emails.xml can not be translated (Thanks to Christopher).
-
-2011-01-01  Oliver Hader  <oliver.hader@typo3.org>
-
-       * Fixed bug #11833: Sorting order of IRRE records is wrong after publishing
-
-2010-12-28  Oliver Hader  <oliver.hader@typo3.org>
-
-       * Cleanup: Fixed PHPdoc comments, type hints and XCLASS blocks
-       * Cleanup: Renamed command map class file to start with proper extension prefix
-
-2010-12-22  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Fixed bug:#11606 Remove "Send to review / pub" from contextmenu
-
-2010-12-21  Sonja Scholz  <ss@cabag.ch>
-
-       * Fixed bug #11633: Versioning module should not be available when workspaces is loaded
-
-2010-12-05  Steffen Gebert  <steffen@steffen-gebert.de>
-
-       * Fixed bug #11290: PHP notices from XCLASS inclusions
-
-2010-12-01  Oliver Hader  <oliver@typo3.org>
-
-       * Cleanup: Fixed ext_emconf.php
-       * Raised version to 4.5.0beta2a
-
-2010-12-01  Tolleiv Nietsch  <typo3@tolleiv.de>
-
-       * Fixed bug: #11209: BACK_PATH is not handled right in class.tx_version_gui.php
-
-2010-12-01  Oliver Hader  <oliver@typo3.org>
-
-       * Cleanup: Fixed ext_emconf.php
-       * Raised version to 4.5.0beta2
-
-2010-11-28  Sonja Scholz  <ss@cabag.ch>
-
-       * Fixed bug #5923: Notify per email if groups are selected instead of single users
diff --git a/typo3/sysext/version/Resources/Private/Language/locallang_emails.xml b/typo3/sysext/version/Resources/Private/Language/locallang_emails.xml
deleted file mode 100644 (file)
index f4f49ee..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<T3locallang>
-       <meta type="array">
-               <description>Module labels</description>
-               <type>module</type>
-       </meta>
-       <data type="array">
-               <languageKey index="default" type="array">
-                       <label index="subject">TYPO3 Workspace Note: Stage Change for ###ELEMENT_NAME###</label>
-                       <label index="message">At the TYPO3 site "###SITE_NAME###" (###SITE_URL###)
-in workspace "###WORKSPACE_TITLE###" (###WORKSPACE_UID###)
-the stage has changed for the element(s) "###RECORD_TITLE###" (###ELEMENT_NAME###) at location "###RECORD_PATH###" in the page tree:
-
-=> ###NEXT_STAGE###
-
-User Comment:
-"###COMMENT###"
-
-State was changed by ###USER_FULLNAME### (username: ###USER_USERNAME###)</label>
-               </languageKey>
-       </data>
-</T3locallang>
diff --git a/typo3/sysext/version/class.tx_version_cm1.php b/typo3/sysext/version/class.tx_version_cm1.php
deleted file mode 100755 (executable)
index 881b570..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2004-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  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.
-*
-*  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!
-***************************************************************/
-/**
- * Addition of the versioning item to the clickmenu
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *   54: class tx_version_cm1
- *   65:     function main(&$backRef,$menuItems,$table,$uid)
- *  111:     function includeLL()
- *
- * TOTAL FUNCTIONS: 2
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
-
-
-
-
-
-/**
- * "Versioning" item added to click menu of elements.
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage core
- */
-class tx_version_cm1 {
-
-       /**
-        * Main function, adding the item to input menuItems array
-        *
-        * @param       object          References to parent clickmenu objects.
-        * @param       array           Array of existing menu items accumulated. New element added to this.
-        * @param       string          Table name of the element
-        * @param       integer         Record UID of the element
-        * @return      array           Modified menuItems array
-        */
-       function main(&$backRef,$menuItems,$table,$uid) {
-               global $BE_USER,$TCA,$LANG;
-
-               $localItems = Array();
-               if (!$backRef->cmLevel && $uid>0 && $BE_USER->check('modules','web_txversionM1'))       {
-
-                               // Returns directly, because the clicked item was not from the pages table
-                       if (in_array('versioning', $backRef->disabledItems) || !$TCA[$table] || !$TCA[$table]['ctrl']['versioningWS']) {
-                               return $menuItems;
-                       }
-
-                               // Adds the regular item
-                       $LL = $this->includeLL();
-
-                               // "Versioning" element added:
-                       $url = t3lib_extMgm::extRelPath('version').'cm1/index.php?table='.rawurlencode($table).'&uid='.$uid;
-                       $localItems[] = $backRef->linkItem(
-                               $GLOBALS['LANG']->getLLL('title',$LL),
-                               $backRef->excludeIcon('<img src="'.$backRef->backPath.t3lib_extMgm::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
-                               $backRef->urlRefForCM($url),
-                               1
-                       );
-
-                               // "Send to review" element added:
-                       /*
-                       $url = t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table=='pages'?$uid:$backRef->rec['pid']).'&table='.rawurlencode($table).'&uid='.$uid.'&sendToReview=1';
-                       $localItems[] = $backRef->linkItem(
-                               $GLOBALS['LANG']->getLLL('title_review',$LL),
-                               $backRef->excludeIcon('<img src="'.$backRef->backPath.t3lib_extMgm::extRelPath('version').'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'),
-                               $backRef->urlRefForCM($url),
-                               1
-                       );
-                       */
-
-                               // Find position of "delete" element:
-                       $c=0;
-                       foreach ($menuItems as $k => $value) {
-                               $c++;
-                               if (!strcmp($k,'delete'))       break;
-                       }
-                               // .. subtract two (delete item + divider line)
-                       $c-=2;
-                               // ... and insert the items just before the delete element.
-                       array_splice(
-                               $menuItems,
-                               $c,
-                               0,
-                               $localItems
-                       );
-               }
-               return $menuItems;
-       }
-
-       /**
-        * Includes the [extDir]/locallang.php and returns the $LOCAL_LANG array found in that file.
-        *
-        * @return      array           Local lang array
-        */
-       function includeLL()    {
-               global $LANG;
-
-               return $LANG->includeLLFile('EXT:version/locallang.xml',FALSE);
-       }
-}
-
-
-
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_cm1.php'])) {
-       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_cm1.php']);
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/class.tx_version_gui.php b/typo3/sysext/version/class.tx_version_gui.php
deleted file mode 100644 (file)
index c59737f..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  (c) 2010-2011 Benjamin Mack (benni@typo3.org)
-*
-*  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!
-***************************************************************/
-/**
- *
- * Contains some parts for staging, versioning and workspaces
- * to interact with the TYPO3 Core Engine
- *
- */
-class tx_version_gui {
-
-       /**
-        * Creates the version selector for the page id inputted.
-        * Moved out of the core file typo3/template.php
-        *
-        * @param       integer         Page id to create selector for.
-        * @param       boolean         If set, there will be no button for swapping page.
-        * @return      void
-        */
-       public function getVersionSelector($id, $noAction = FALSE) {
-               if ($id <= 0) {
-                       return;
-               }
-               if ($GLOBALS['BE_USER']->workspace == 0) {
-
-                               // Get Current page record:
-                       $curPage = t3lib_BEfunc::getRecord('pages', $id);
-                               // If the selected page is not online, find the right ID
-                       $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
-                               // Select all versions of online version:
-                       $versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id');
-
-                               // If more than one was found...:
-                       if (count($versions) > 1) {
-                               $selectorLabel = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.label', TRUE) . '</strong>';
-
-                                       // Create selector box entries:
-                               $opt = array();
-                               foreach ($versions as $vRow) {
-                                       if ($vRow['uid'] == $onlineId) {
-                                                       // Live version
-                                               $label = '[' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.live', TRUE) . ']';
-                                       } else {
-                                               $label = $vRow['t3ver_label'] . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionId', TRUE) . ' ' . $vRow['t3ver_id'] .
-                                                       ($vRow['t3ver_wsid'] != 0 ? ' ' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspaceId', TRUE) . ' ' . $vRow['t3ver_wsid'] : '') . ')';
-                                       }
-
-                                       $opt[] = '<option value="' . htmlspecialchars(t3lib_div::linkThisScript(array('id' => $vRow['uid']))) . '"' .
-                                               ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' .
-                                               htmlspecialchars($label) . '</option>';
-                               }
-
-                                       // Add management link:
-                               $management = '<input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.mgm', TRUE) . '" onclick="window.location.href=\'' .
-                                               htmlspecialchars($GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('version') . 'cm1/index.php?table=pages&uid=' . $onlineId) . '\';" />';
-                                       // Create onchange handler:
-                               $onChange = "window.location.href=this.options[this.selectedIndex].value;";
-
-                                       // Controls:
-                               if ($id == $onlineId) {
-                                       $controls .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif','width="5" height="9"') .
-                                               ' class="absmiddle" alt="" /> <strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online', TRUE) .
-                                               '</strong>';
-                               } elseif (!$noAction) {
-                                       $controls .= '<a href="' . $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id .
-                                               '&cmd[pages][' . $onlineId . '][version][action]=swap', t3lib_div::linkThisScript(array('id' => $onlineId))) .
-                                               '" class="nobr">' . t3lib_iconWorks::getSpriteIcon('actions-version-swap-version', array(
-                                                       'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swapPage', TRUE),
-                                                       'style' => 'margin-left:5px;vertical-align:bottom;'
-                                               )) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap', TRUE) . '</strong></a>';
-                               }
-
-                                       // Write out HTML code:
-                               return '
-                                       <!--
-                                               Version selector:
-                                       -->
-                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                               <tr>
-                                                       <td>' . $selectorLabel . '</td>
-                                                       <td>
-                                                               <select onchange="' . htmlspecialchars($onChange) . '">
-                                                                       ' . implode('', $opt) . '
-                                                               </select></td>
-                                                       <td>' . $controls . '</td>
-                                                       <td>' . $management . '</td>
-                                               </tr>
-                                       </table>
-                               ';
-                       }
-               } elseif ($GLOBALS['BE_USER']->workspace !== 0) {
-
-                               // Write out HTML code:
-                       switch ($GLOBALS['BE_USER']->workspace) {
-                               case 0:
-                                       $wsTitle = $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:live', TRUE);
-                               break;
-                               case -1:
-                                       $wsTitle = $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:draft', TRUE);
-                               break;
-                               default:
-                                       $wsTitle = $GLOBALS['BE_USER']->workspaceRec['title'];
-                               break;
-                       }
-
-                       if (t3lib_BEfunc::isPidInVersionizedBranch($id) == 'branchpoint') {
-                               return '
-
-                                       <!--
-                                               Version selector:
-                                       -->
-                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                               <tr>
-                                                       <td>' . $selectorLabel . '</td>
-                                                       <td>Workspace: "' . htmlspecialchars($wsTitle) . '"</td>
-                                                       <td><em>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.inBranch', TRUE) . '</em></td>
-                                               </tr>
-                                       </table>
-                               ';
-                       } else {
-
-                                       // Get Current page record:
-                               $curPage = t3lib_BEfunc::getRecord('pages', $id);
-                                       // If the selected page is not online, find the right ID
-                               $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
-                                       // The version of page:
-                               $verPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, 'pages', $onlineId);
-
-                               if (!$verPage) {
-
-                                       if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId))) {
-                                               if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0)) {
-
-                                                       $onClick = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=new&cmd[pages][' . $onlineId . '][version][treeLevels]=0',
-                                                               t3lib_div::linkThisScript(array(
-                                                                       'id' => $onlineId
-                                                               )));
-                                                       $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
-                                                               // Write out HTML code:
-                                                       return '
-
-                                                               <!--
-                                                                       No version yet, create one?
-                                                               -->
-                                                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                                                       <tr>
-                                                                               <td>' . $selectorLabel . '</td>
-                                                                               <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
-                                                                               <td>
-                                                                                       <input type="button" value="New version of page" name="_" onclick="' . htmlspecialchars($onClick) . '" /></td>
-                                                                       </tr>
-                                                               </table>
-                                                       ';
-                                               }
-                                       } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['elementVersioningOnly'] == FALSE && $GLOBALS['TYPO3_CONF_VARS']['BE']['newPagesVersioningType'] == 0) {
-                                                       // only add this info if old/deprecated newPagesVersioning is allowed
-                                               return '
-
-                                                       <!--
-                                                               Version selector:
-                                                       -->
-                                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                                               <tr>
-                                                                       <td>' . $selectorLabel . '</td>
-                                                                       <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
-                                                                       <td><em>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.versionsFound', TRUE) . '</em></td>
-                                                               </tr>
-                                                       </table>
-                                               ';
-                                       }
-                               } elseif ($verPage['t3ver_swapmode']==0) {
-                                       $onClick = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=swap&cmd[pages][' .
-                                               $onlineId . '][version][swapWith]=' . $verPage['uid'],
-                                               t3lib_div::linkThisScript(array(
-                                                       'id' => $onlineId
-                                               )));
-                                       $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
-
-                                               // Write out HTML code:
-                                       return '
-
-                                               <!--
-                                                       Version selector:
-                                               -->
-                                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                                       <tr>
-                                                               <td>' . $selectorLabel . '</td>
-                                                               <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
-                                                               <td>
-                                                                       <input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.publish', TRUE) .
-                                                                               '" onclick="' . htmlspecialchars($onClick) . '" /></td>
-                                                       </tr>
-                                               </table>
-                                       ';
-                               }
-                       }
-               }
-       }
-
-}
-
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_gui.php'])) {
-       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_gui.php']);
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/class.tx_version_tcemain.php b/typo3/sysext/version/class.tx_version_tcemain.php
deleted file mode 100644 (file)
index 4c58ffb..0000000
+++ /dev/null
@@ -1,1423 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  (c) 2010-2011 Benjamin Mack (benni@typo3.org)
-*
-*  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!
-***************************************************************/
-/**
- *
- * Contains some parts for staging, versioning and workspaces
- * to interact with the TYPO3 Core Engine
- *
- */
-class tx_version_tcemain {
-
-       /**
-        * For accumulating information about workspace stages raised
-        * on elements so a single mail is sent as notification.
-        * previously called "accumulateForNotifEmail" in tcemain
-        *
-        * @var array
-        */
-       protected $notificationEmailInfo = array();
-
-       /**
-        * General comment, eg. for staging in workspaces
-        *
-        * @var string
-        */
-       protected $generalComment = '';
-
-       /**
-        * Contains remapped IDs.
-        *
-        * @var array
-        */
-       protected $remappedIds = array();
-
-       /****************************
-        *****  Cmdmap  Hooks  ******
-        ****************************/
-
-       /**
-        * hook that is called before any cmd of the commandmap is executed
-        *
-        * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
-        * @return void
-        */
-       public function processCmdmap_beforeStart(t3lib_TCEmain $tcemainObj) {
-                       // Reset notification array
-               $this->notificationEmailInfo = array();
-                       // Resolve dependencies of version/workspaces actions:
-               $tcemainObj->cmdmap = $this->getCommandMap($tcemainObj, $tcemainObj->cmdmap)->process()->get();
-       }
-
-
-       /**
-        * hook that is called when no prepared command was found
-        *
-        * @param string $command the command to be executed
-        * @param string $table the table of the record
-        * @param integer $id the ID of the record
-        * @param mixed $value the value containing the data
-        * @param boolean $commandIsProcessed can be set so that other hooks or
-        *                              TCEmain knows that the default cmd doesn't have to be called
-        * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
-        * @return      void
-        */
-       public function processCmdmap($command, $table, $id, $value, &$commandIsProcessed, t3lib_TCEmain $tcemainObj) {
-
-                       // custom command "version"
-               if ($command == 'version') {
-                       $commandIsProcessed = TRUE;
-                       $action = (string) $value['action'];
-                       switch ($action) {
-
-                               case 'new':
-                                               // check if page / branch versioning is needed,
-                                               // or if "element" version can be used
-                                       $versionizeTree = -1;
-                                       if (isset($value['treeLevels'])) {
-                                               $versionizeTree = t3lib_div::intInRange($value['treeLevels'], -1, 100);
-                                       }
-                                       if ($table == 'pages' && $versionizeTree >= 0) {
-                                               $this->versionizePages($id, $value['label'], $versionizeTree, $tcemainObj);
-                                       } else {
-                                               $tcemainObj->versionizeRecord($table, $id, $value['label']);
-                                       }
-                               break;
-
-                               case 'swap':
-                                       $this->version_swap($table, $id, $value['swapWith'], $value['swapIntoWS'], $tcemainObj);
-                               break;
-
-                               case 'clearWSID':
-                                       $this->version_clearWSID($table, $id, FALSE, $tcemainObj);
-                               break;
-
-                               case 'flush':
-                                       $this->version_clearWSID($table, $id, TRUE, $tcemainObj);
-                               break;
-
-                               case 'setStage':
-                                       $elementIds = t3lib_div::trimExplode(',', $id, TRUE);
-                                       foreach ($elementIds as $elementId) {
-                                               $this->version_setStage($table, $elementId, $value['stageId'],
-                                                       (isset($value['comment']) && $value['comment'] ? $value['comment'] : $this->generalComment),
-                                                       TRUE,
-                                                       $tcemainObj,
-                                                       $value['notificationAlternativeRecipients']
-                                               );
-                                       }
-                               break;
-                       }
-               }
-       }
-
-       /**
-        * hook that is called AFTER all commands of the commandmap was
-        * executed
-        *
-        * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
-        * @return      void
-        */
-       public function processCmdmap_afterFinish(t3lib_TCEmain $tcemainObj) {
-                       // Empty accumulation array:
-               foreach ($this->notificationEmailInfo as $notifItem) {
-                       $this->notifyStageChange($notifItem['shared'][0], $notifItem['shared'][1], implode(', ', $notifItem['elements']), 0, $notifItem['shared'][2], $tcemainObj, $notifItem['alternativeRecipients']);
-               }
-
-                       // Reset notification array
-               $this->notificationEmailInfo = array();
-                       // Reset remapped IDs
-               $this->remappedIds = array();
-       }
-
-
-       /**
-        * hook that is called AFTER all commands of the commandmap was
-        * executed
-        *
-        * @param string $table the table of the record
-        * @param integer $id the ID of the record
-        * @param array $record The accordant database record
-        * @param boolean $recordWasDeleted can be set so that other hooks or
-        *                              TCEmain knows that the default delete action doesn't have to be called
-        * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
-        * @return      void
-        */
-       public function processCmdmap_deleteAction($table, $id, array $record, &$recordWasDeleted, t3lib_TCEmain $tcemainObj) {
-                       // only process the hook if it wasn't processed
-                       // by someone else before
-               if (!$recordWasDeleted) {
-                       $recordWasDeleted = TRUE;
-                       $id = $record['uid'];
-
-                               // For Live version, try if there is a workspace version because if so, rather "delete" that instead
-                               // Look, if record is an offline version, then delete directly:
-                       if ($record['pid'] != -1) {
-                               if ($wsVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord($tcemainObj->BE_USER->workspace, $table, $id)) {
-                                       $record = $wsVersion;
-                                       $id = $record['uid'];
-                               }
-                       }
-
-                                       // Look, if record is an offline version, then delete directly:
-                       if ($record['pid'] == -1) {
-                               if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                                               // In Live workspace, delete any. In other workspaces there must be match.
-                                       if ($tcemainObj->BE_USER->workspace == 0 || (int) $record['t3ver_wsid'] == $tcemainObj->BE_USER->workspace) {
-                                               $liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state');
-
-                                                       // Delete those in WS 0 + if their live records state was not "Placeholder".
-                                               if ($record['t3ver_wsid']==0 || (int) $liveRec['t3ver_state'] <= 0) {
-                                                       $tcemainObj->deleteEl($table, $id);
-                                               } else {
-                                                               // If live record was placeholder (new/deleted), rather clear
-                                                               // it from workspace (because it clears both version and placeholder).
-                                                       $this->version_clearWSID($table, $id, FALSE, $tcemainObj);
-                                               }
-                                       } else $tcemainObj->newlog('Tried to delete record from another workspace',1);
-                               } else $tcemainObj->newlog('Versioning not enabled for record with PID = -1!',2);
-                       } elseif ($res = $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($record['pid'], $table)) {
-                                       // Look, if record is "online" or in a versionized branch, then delete directly.
-                               if ($res>0) {
-                                       $tcemainObj->deleteEl($table, $id);
-                               } else {
-                                       $tcemainObj->newlog('Stage of root point did not allow for deletion',1);
-                               }
-                       } elseif ((int)$record['t3ver_state']===3) {
-                                       // Placeholders for moving operations are deletable directly.
-
-                                       // Get record which its a placeholder for and reset the t3ver_state of that:
-                               if ($wsRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($record['t3ver_wsid'], $table, $record['t3ver_move_id'], 'uid')) {
-                                               // Clear the state flag of the workspace version of the record
-                                               // Setting placeholder state value for version (so it can know it is currently a new version...)
-                                       $updateFields = array(
-                                               't3ver_state' => 0
-                                       );
-                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($wsRec['uid']), $updateFields);
-                               }
-                               $tcemainObj->deleteEl($table, $id);
-                       } else {
-                               // Otherwise, try to delete by versioning:
-                               $tcemainObj->versionizeRecord($table, $id, 'DELETED!', TRUE);
-                               $tcemainObj->deleteL10nOverlayRecords($table, $id);
-                       }
-               }
-       }
-
-
-       /**
-        * hook for t3lib_TCEmain::moveRecord that cares about moving records that
-        * are *not* in the live workspace
-        *
-        * @param string $table the table of the record
-        * @param integer $id the ID of the record
-        * @param integer $destPid Position to move to: $destPid: >=0 then it points to
-        *                              a page-id on which to insert the record (as the first element).
-        *                              <0 then it points to a uid from its own table after which to insert it
-        * @param array $propArr Record properties, like header and pid (includes workspace overlay)
-        * @param array $moveRec Record properties, like header and pid (without workspace overlay)
-        * @param integer $resolvedPid The final page ID of the record
-        *                              (workspaces and negative values are resolved)
-        * @param boolean $recordWasMoved can be set so that other hooks or
-        *                              TCEmain knows that the default move action doesn't have to be called
-        * @param       $table  the table
-        */
-       public function moveRecord($table, $uid, $destPid, array $propArr, array $moveRec, $resolvedPid, &$recordWasMoved, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-                       // Only do something in Draft workspace
-               if ($tcemainObj->BE_USER->workspace !== 0) {
-                       $recordWasMoved = TRUE;
-
-                               // Get workspace version of the source record, if any:
-                       $WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($tcemainObj->BE_USER->workspace, $table, $uid, 'uid,t3ver_oid');
-
-                               // If no version exists and versioningWS is in version 2, a new placeholder is made automatically:
-                       if (!$WSversion['uid'] && (int)$TCA[$table]['ctrl']['versioningWS']>=2 && (int)$moveRec['t3ver_state']!=3)      {
-                               $tcemainObj->versionizeRecord($table, $uid, 'Placeholder version for moving record');
-                               $WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($tcemainObj->BE_USER->workspace, $table, $uid, 'uid,t3ver_oid'); // Will not create new versions in live workspace though...
-                       }
-
-                               // Check workspace permissions:
-                       $workspaceAccessBlocked = array();
-                               // Element was in "New/Deleted/Moved" so it can be moved...
-                       $recIsNewVersion = (int)$moveRec['t3ver_state']>0;
-
-                       $destRes = $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($resolvedPid, $table);
-                       $canMoveRecord = $recIsNewVersion || (int)$TCA[$table]['ctrl']['versioningWS'] >= 2;
-
-                               // Workspace source check:
-                       if (!$recIsNewVersion) {
-                               $errorCode = $tcemainObj->BE_USER->workspaceCannotEditRecord($table, $WSversion['uid'] ? $WSversion['uid'] : $uid);
-                               if ($errorCode) {
-                                       $workspaceAccessBlocked['src1'] = 'Record could not be edited in workspace: ' . $errorCode . ' ';
-                               } elseif (!$canMoveRecord && $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($moveRec['pid'], $table) <= 0) {
-                                       $workspaceAccessBlocked['src2'] = 'Could not remove record from table "' . $table . '" from its page "'.$moveRec['pid'].'" ';
-                               }
-                       }
-
-                               // Workspace destination check:
-
-                               // All records can be inserted if $destRes is greater than zero.
-                               // Only new versions can be inserted if $destRes is false.
-                               // NO RECORDS can be inserted if $destRes is negative which indicates a stage
-                               //  not allowed for use. If "versioningWS" is version 2, moving can take place of versions.
-                       if (!($destRes > 0 || ($canMoveRecord && !$destRes))) {
-                               $workspaceAccessBlocked['dest1'] = 'Could not insert record from table "' . $table . '" in destination PID "' . $resolvedPid . '" ';
-                       } elseif ($destRes == 1 && $WSversion['uid']) {
-                               $workspaceAccessBlocked['dest2'] = 'Could not insert other versions in destination PID ';
-                       }
-
-                       if (!count($workspaceAccessBlocked)) {
-                                       // If the move operation is done on a versioned record, which is
-                                       // NOT new/deleted placeholder and versioningWS is in version 2, then...
-                               if ($WSversion['uid'] && !$recIsNewVersion && (int)$TCA[$table]['ctrl']['versioningWS'] >= 2) {
-                                       $this->moveRecord_wsPlaceholders($table, $uid, $destPid, $WSversion['uid'], $tcemainObj);
-                               } else {
-                                       // moving not needed, just behave like in live workspace
-                                       $recordWasMoved = FALSE;
-                               }
-                       } else {
-                               $tcemainObj->newlog("Move attempt failed due to workspace restrictions: " . implode(' // ', $workspaceAccessBlocked), 1);
-                       }
-               }
-       }
-
-
-
-       /****************************
-        *****  Notifications  ******
-        ****************************/
-
-       /**
-        * Send an email notification to users in workspace
-        *
-        * @param array $stat Workspace access array (from t3lib_userauthgroup::checkWorkspace())
-        * @param integer $stageId New Stage number: 0 = editing, 1= just ready for review, 10 = ready for publication, -1 = rejected!
-        * @param string $table Table name of element (or list of element names if $id is zero)
-        * @param integer $id Record uid of element (if zero, then $table is used as reference to element(s) alone)
-        * @param string $comment User comment sent along with action
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @param string $notificationAlternativeRecipients Comma separated list of recipients to notificate instead of be_users selected by sys_workspace, list is generated by workspace extension module
-        * @return void
-        */
-       protected function notifyStageChange(array $stat, $stageId, $table, $id, $comment, t3lib_TCEmain $tcemainObj, $notificationAlternativeRecipients = FALSE) {
-               $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $stat['uid']);
-                       // So, if $id is not set, then $table is taken to be the complete element name!
-               $elementName = $id ? $table . ':' . $id : $table;
-
-               if (is_array($workspaceRec)) {
-
-                                // Get the new stage title from workspaces library, if workspaces extension is installed
-                       if (t3lib_extMgm::isLoaded('workspaces')) {
-                               $stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
-                               $newStage = $stageService->getStageTitle((int)$stageId);
-                       } else {
-                                       // TODO: CONSTANTS SHOULD BE USED - tx_service_workspace_workspaces
-                                       // TODO: use localized labels
-                                       // Compile label:
-                               switch ((int)$stageId) {
-                                       case 1:
-                                               $newStage = 'Ready for review';
-                                       break;
-                                       case 10:
-                                               $newStage = 'Ready for publishing';
-                                       break;
-                                       case -1:
-                                               $newStage = 'Element was rejected!';
-                                       break;
-                                       case 0:
-                                               $newStage = 'Rejected element was noticed and edited';
-                                       break;
-                                       default:
-                                               $newStage = 'Unknown state change!?';
-                                       break;
-                               }
-                       }
-
-                       if ($notificationAlternativeRecipients == false) {
-                                       // Compile list of recipients:
-                               $emails = array();
-                               switch((int)$stat['stagechg_notification'])     {
-                                       case 1:
-                                               switch((int)$stageId)   {
-                                                       case 1:
-                                                               $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
-                                                       break;
-                                                       case 10:
-                                                               $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
-                                                       break;
-                                                       case -1:
-#                                                              $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
-#                                                              $emails = array_merge($emails,$this->getEmailsForStageChangeNotification($workspaceRec['members']));
-
-                                                                       // List of elements to reject:
-                                                               $allElements = explode(',', $elementName);
-                                                                       // Traverse them, and find the history of each
-                                                               foreach ($allElements as $elRef) {
-                                                                       list($eTable, $eUid) = explode(':', $elRef);
-
-                                                                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                                                                       'log_data,tstamp,userid',
-                                                                                       'sys_log',
-                                                                                       'action=6 and details_nr=30
-                                                                                       AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($eTable, 'sys_log') . '
-                                                                                       AND recuid=' . intval($eUid),
-                                                                                       '',
-                                                                                       'uid DESC'
-                                                                       );
-                                                                               // Find all implicated since the last stage-raise from editing to review:
-                                                                       foreach ($rows as $dat) {
-                                                                               $data = unserialize($dat['log_data']);
-
-                                                                               $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($dat['userid'], TRUE));
-
-                                                                               if ($data['stage'] == 1) {
-                                                                                       break;
-                                                                               }
-                                                                       }
-                                                               }
-                                                       break;
-
-                                                       case 0:
-                                                               $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']);
-                                                       break;
-
-                                                       default:
-                                                               $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
-                                                       break;
-                                               }
-                                       break;
-                                       case 10:
-                                               $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
-                                               $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']));
-                                               $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['members']));
-                                       break;
-                               }
-                       } else {
-                               $emails = array();
-                               foreach ($notificationAlternativeRecipients as $emailAddress) {
-                                       $emails[] = array('email' => $emailAddress);
-                               }
-                       }
-
-                               // prepare and then send the emails
-                       if (count($emails)) {
-
-                                       // Path to record is found:
-                               list($elementTable, $elementUid) = explode(':', $elementName);
-                               $elementUid = intval($elementUid);
-                               $elementRecord = t3lib_BEfunc::getRecord($elementTable, $elementUid);
-                               $recordTitle = t3lib_BEfunc::getRecordTitle($elementTable, $elementRecord);
-
-                               if ($elementTable == 'pages') {
-                                       $pageUid = $elementUid;
-                               } else {
-                                       t3lib_BEfunc::fixVersioningPid($elementTable, $elementRecord);
-                                       $pageUid = $elementUid = $elementRecord['pid'];
-                               }
-
-                                       // fetch the TSconfig settings for the email
-
-                                       // old way, options are TCEMAIN.notificationEmail_body/subject
-                               $TCEmainTSConfig = $tcemainObj->getTCEMAIN_TSconfig($pageUid);
-
-                                       // these options are deprecated since TYPO3 4.5, but are still
-                                       // used in order to provide backwards compatibility
-                               $emailMessage = trim($TCEmainTSConfig['notificationEmail_body']);
-                               $emailSubject = trim($TCEmainTSConfig['notificationEmail_subject']);
-
-                                       // new way, options are
-                                       // pageTSconfig: tx_version.workspaces.stageNotificationEmail.subject
-                                       // userTSconfig: page.tx_version.workspaces.stageNotificationEmail.subject
-                               $pageTsConfig = t3lib_BEfunc::getPagesTSconfig($pageUid);
-                               $emailConfig = $pageTsConfig['tx_version.']['workspaces.']['stageNotificationEmail.'];
-
-                               $markers = array(
-                                       '###RECORD_TITLE###' => $recordTitle,
-                                       '###RECORD_PATH###' => t3lib_BEfunc::getRecordPath($elementUid, '', 20),
-                                       '###SITE_NAME###' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
-                                       '###SITE_URL###' => t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir,
-                                       '###WORKSPACE_TITLE###' => $workspaceRec['title'],
-                                       '###WORKSPACE_UID###' => $workspaceRec['uid'],
-                                       '###ELEMENT_NAME###' => $elementName,
-                                       '###NEXT_STAGE###' => $newStage,
-                                       '###COMMENT###' => $comment,
-                                       '###USER_REALNAME###' => $tcemainObj->BE_USER->user['realName'],
-                                       '###USER_USERNAME###' => $tcemainObj->BE_USER->user['username']
-                               );
-
-
-                                       // sending the emails the old way with sprintf(),
-                                       // because it was set explicitly in TSconfig
-                               if ($emailMessage && $emailSubject) {
-                                       t3lib_div::deprecationLog('This TYPO3 installation uses Workspaces staging notification by setting the TSconfig options "TCEMAIN.notificationEmail_subject" / "TCEMAIN.notificationEmail_body". Please use the more flexible marker-based options tx_version.workspaces.stageNotificationEmail.message / tx_version.workspaces.stageNotificationEmail.subject');
-
-                                       $emailSubject = sprintf($emailSubject, $elementName);
-                                       $emailMessage = sprintf($emailMessage,
-                                               $markers['###SITE_NAME###'],
-                                               $markers['###SITE_URL###'],
-                                               $markers['###WORKSPACE_TITLE###'],
-                                               $markers['###WORKSPACE_UID###'],
-                                               $markers['###ELEMENT_NAME###'],
-                                               $markers['###NEXT_STAGE###'],
-                                               $markers['###COMMENT###'],
-                                               $markers['###USER_REALNAME###'],
-                                               $markers['###USER_USERNAME###'],
-                                               $markers['###RECORD_PATH###'],
-                                               $markers['###RECORD_TITLE###']
-                                       );
-
-                                               // filter out double email addresses
-                                       $emailRecipients = array();
-                                       foreach ($emails as $recip) {
-                                               $emailRecipients[$recip['email']] = $recip['email'];
-                                       }
-                                       $emailRecipients = implode(',', $emailRecipients);
-
-                                               // Send one email to everybody
-                                       t3lib_div::plainMailEncoded(
-                                               $emailRecipients,
-                                               $emailSubject,
-                                               $emailMessage
-                                       );
-                               } else {
-                                               // send an email to each individual user, to ensure the
-                                               // multilanguage version of the email
-
-                                       $emailHeaders = $emailConfig['additionalHeaders'];
-                                       $emailRecipients = array();
-
-                                               // an array of language objects that are needed
-                                               // for emails with different languages
-                                       $languageObjects = array(
-                                               $GLOBALS['LANG']->lang => $GLOBALS['LANG']
-                                       );
-
-                                               // loop through each recipient and send the email
-                                       foreach ($emails as $recipientData) {
-                                                       // don't send an email twice
-                                               if (isset($emailRecipients[$recipientData['email']])) {
-                                                       continue;
-                                               }
-                                               $emailSubject = $emailConfig['subject'];
-                                               $emailMessage = $emailConfig['message'];
-                                               $emailRecipients[$recipientData['email']] = $recipientData['email'];
-
-                                                       // check if the email needs to be localized
-                                                       // in the users' language
-                                               if (t3lib_div::isFirstPartOfStr($emailSubject, 'LLL:') || t3lib_div::isFirstPartOfStr($emailMessage, 'LLL:')) {
-                                                       $recipientLanguage = ($recipientData['lang'] ? $recipientData['lang'] : 'default');
-                                                       if (!isset($languageObjects[$recipientLanguage])) {
-                                                                       // a LANG object in this language hasn't been
-                                                                       // instantiated yet, so this is done here
-                                                               /** @var $languageObject language */
-                                                               $languageObject = t3lib_div::makeInstance('language');
-                                                               $languageObject->init($recipientLanguage);
-                                                               $languageObjects[$recipientLanguage] = $languageObject;
-                                                       } else {
-                                                               $languageObject = $languageObjects[$recipientLanguage];
-                                                       }
-
-                                                       if (t3lib_div::isFirstPartOfStr($emailSubject, 'LLL:')) {
-                                                               $emailSubject = $languageObject->sL($emailSubject);
-                                                       }
-
-                                                       if (t3lib_div::isFirstPartOfStr($emailMessage, 'LLL:')) {
-                                                               $emailMessage = $languageObject->sL($emailMessage);
-                                                       }
-                                               }
-
-                                               $emailSubject = t3lib_parseHtml::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
-                                               $emailMessage = t3lib_parseHtml::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
-                                                       // Send an email to the recipient
-                                               t3lib_div::plainMailEncoded(
-                                                       $recipientData['email'],
-                                                       $emailSubject,
-                                                       $emailMessage,
-                                                       $emailHeaders
-                                               );
-                                       }
-                                       $emailRecipients = implode(',', $emailRecipients);
-                               }
-                               $tcemainObj->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id);
-                       }
-               }
-       }
-
-       /**
-        * Return be_users that should be notified on stage change from input list.
-        * previously called notifyStageChange_getEmails() in tcemain
-        *
-        * @param       string          $listOfUsers List of backend users, on the form "be_users_10,be_users_2" or "10,2" in case noTablePrefix is set.
-        * @param       boolean         $noTablePrefix If set, the input list are integers and not strings.
-        * @return      array           Array of emails
-        */
-       protected function getEmailsForStageChangeNotification($listOfUsers, $noTablePrefix = FALSE) {
-               $users = t3lib_div::trimExplode(',', $listOfUsers, 1);
-               $emails = array();
-               foreach ($users as $userIdent) {
-                       if ($noTablePrefix) {
-                               $id = intval($userIdent);
-                       } else {
-                               list($table, $id) = t3lib_div::revExplode('_', $userIdent, 2);
-                       }
-                       if ($table === 'be_users' || $noTablePrefix) {
-                               if ($userRecord = t3lib_BEfunc::getRecord('be_users', $id, 'uid,email,lang,realName')) {
-                                       if (strlen(trim($userRecord['email']))) {
-                                               $emails[$id] = $userRecord;
-                                       }
-                               }
-                       }
-               }
-               return $emails;
-       }
-
-
-       /****************************
-        *****  Stage Changes  ******
-        ****************************/
-
-       /**
-        * Setting stage of record
-        *
-        * @param string $table Table name
-        * @param integer $integer Record UID
-        * @param integer $stageId Stage ID to set
-        * @param string $comment Comment that goes into log
-        * @param boolean $notificationEmailInfo Accumulate state changes in memory for compiled notification email?
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @param string $notificationAlternativeRecipients comma separated list of recipients to notificate instead of normal be_users
-        * @return void
-        */
-       protected function version_setStage($table, $id, $stageId, $comment = '', $notificationEmailInfo = FALSE, t3lib_TCEmain $tcemainObj, $notificationAlternativeRecipients = FALSE) {
-               if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
-                       $tcemainObj->newlog('Attempt to set stage for record failed: ' . $errorCode, 1);
-               } elseif ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
-                       $record = t3lib_BEfunc::getRecord($table, $id);
-                       $stat = $tcemainObj->BE_USER->checkWorkspace($record['t3ver_wsid']);
-                               // check if the usere is allowed to the current stage, so it's also allowed to send to next stage
-                       if ($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($record['t3ver_stage'])) {
-
-                                       // Set stage of record:
-                               $updateData = array(
-                                       't3ver_stage' => $stageId
-                               );
-                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $updateData);
-                               $tcemainObj->newlog2('Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', $table, $id);
-
-                                       // TEMPORARY, except 6-30 as action/detail number which is observed elsewhere!
-                               $tcemainObj->log($table, $id, 6, 0, 0, 'Stage raised...', 30, array('comment' => $comment, 'stage' => $stageId));
-
-                               if ((int)$stat['stagechg_notification'] > 0) {
-                                       if ($notificationEmailInfo) {
-                                               $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['shared'] = array($stat, $stageId, $comment);
-                                               $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['elements'][] = $table . ':' . $id;
-                                               $this->notificationEmailInfo[$stat['uid'] . ':' . $stageId . ':' . $comment]['alternativeRecipients'] = $notificationAlternativeRecipients;
-                                       } else {
-                                               $this->notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients);
-                                       }
-                               }
-                       } else $tcemainObj->newlog('The member user tried to set a stage value "' . $stageId . '" that was not allowed', 1);
-               } else $tcemainObj->newlog('Attempt to set stage for record failed because you do not have edit access', 1);
-       }
-
-
-
-       /*****************************
-        *****  CMD versioning  ******
-        *****************************/
-
-       /**
-        * Creates a new version of a page including content and possible subpages.
-        *
-        * @param integer $uid Page uid to create new version of.
-        * @param string $label Version label
-        * @param integer $versionizeTree Indicating "treeLevel" - "page" (0) or "branch" (>=1) ["element" type must call versionizeRecord() directly]
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return void
-        * @see copyPages()
-        */
-       protected function versionizePages($uid, $label, $versionizeTree, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-               $uid = intval($uid);
-                       // returns the branch
-               $brExist = $tcemainObj->doesBranchExist('', $uid, $tcemainObj->pMap['show'], 1);
-
-                       // Checks if we had permissions
-               if ($brExist != -1) {
-
-                               // Make list of tables that should come along with a new version of the page:
-                       $verTablesArray = array();
-                       $allTables = array_keys($TCA);
-                       foreach ($allTables as $tableName) {
-                               if ($tableName != 'pages' && ($versionizeTree > 0 || $TCA[$tableName]['ctrl']['versioning_followPages'])) {
-                                       $verTablesArray[] = $tableName;
-                               }
-                       }
-
-                               // Remove the possible inline child tables from the tables to be versioniozed automatically:
-                       $verTablesArray = array_diff($verTablesArray, $this->getPossibleInlineChildTablesOfParentTable('pages'));
-
-                               // Begin to copy pages if we're allowed to:
-                       if ($tcemainObj->BE_USER->workspaceVersioningTypeAccess($versionizeTree)) {
-
-                                       // Versionize this page:
-                               $theNewRootID = $tcemainObj->versionizeRecord('pages', $uid, $label, FALSE, $versionizeTree);
-                               if ($theNewRootID) {
-                                       $this->rawCopyPageContent($uid, $theNewRootID, $verTablesArray, $tcemainObj);
-
-                                               // If we're going to copy recursively...:
-                                       if ($versionizeTree > 0) {
-
-                                                       // Get ALL subpages to copy (read permissions respected - they should NOT be...):
-                                               $CPtable = $tcemainObj->int_pageTreeInfo(array(), $uid, intval($versionizeTree), $theNewRootID);
-
-                                                       // Now copying the subpages
-                                               foreach ($CPtable as $thePageUid => $thePagePid)        {
-                                                       $newPid = $tcemainObj->copyMappingArray['pages'][$thePagePid];
-                                                       if (isset($newPid)) {
-                                                               $theNewRootID = $tcemainObj->copyRecord_raw('pages', $thePageUid, $newPid);
-                                                               $this->rawCopyPageContent($thePageUid, $theNewRootID, $verTablesArray, $tcemainObj);
-                                                       } else {
-                                                               $tcemainObj->newlog('Something went wrong during copying branch (for versioning)', 1);
-                                                               break;
-                                                       }
-                                               }
-                                       }       // else the page was not copied. Too bad...
-                               } else $tcemainObj->newlog('The root version could not be created!',1);
-                       } else $tcemainObj->newlog('Versioning type "'.$versionizeTree.'" was not allowed in workspace',1);
-               } else $tcemainObj->newlog('Could not read all subpages to versionize.',1);
-       }
-
-
-       /**
-        * Swapping versions of a record
-        * Version from archive (future/past, called "swap version") will get the uid of the "t3ver_oid", the official element with uid = "t3ver_oid" will get the new versions old uid. PIDs are swapped also
-        *
-        * @param string $table Table name
-        * @param integer $id UID of the online record to swap
-        * @param integer $swapWith UID of the archived version to swap with!
-        * @param boolean $swapIntoWS If set, swaps online into workspace instead of publishing out of workspace.
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return void
-        */
-       protected function version_swap($table, $id, $swapWith, $swapIntoWS=0, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-                       // First, check if we may actually edit the online record
-               if ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
-
-                               // Select the two versions:
-                       $curVersion = t3lib_BEfunc::getRecord($table, $id, '*');
-                       $swapVersion = t3lib_BEfunc::getRecord($table, $swapWith, '*');
-                       $movePlh = array();
-                       $movePlhID = 0;
-
-                       if (is_array($curVersion) && is_array($swapVersion)) {
-                               if ($tcemainObj->BE_USER->workspacePublishAccess($swapVersion['t3ver_wsid'])) {
-                                       $wsAccess = $tcemainObj->BE_USER->checkWorkspace($swapVersion['t3ver_wsid']);
-                                       if ($swapVersion['t3ver_wsid'] <= 0 || !($wsAccess['publish_access'] & 1) || (int)$swapVersion['t3ver_stage'] === -10) {
-                                               if ($tcemainObj->doesRecordExist($table,$swapWith,'show') && $tcemainObj->checkRecordUpdateAccess($table,$swapWith)) {
-                                                       if (!$swapIntoWS || $tcemainObj->BE_USER->workspaceSwapAccess()) {
-
-                                                                       // Check if the swapWith record really IS a version of the original!
-                                                               if ((int)$swapVersion['pid'] == -1 && (int)$curVersion['pid'] >= 0 && !strcmp($swapVersion['t3ver_oid'], $id)) {
-
-                                                                               // Lock file name:
-                                                                       $lockFileName = PATH_site.'typo3temp/swap_locking/' . $table . ':' . $id . '.ser';
-
-                                                                       if (!@is_file($lockFileName))   {
-
-                                                                                       // Write lock-file:
-                                                                               t3lib_div::writeFileToTypo3tempDir($lockFileName, serialize(array(
-                                                                                       'tstamp' => $GLOBALS['EXEC_TIME'],
-                                                                                       'user'   => $tcemainObj->BE_USER->user['username'],
-                                                                                       'curVersion'  => $curVersion,
-                                                                                       'swapVersion' => $swapVersion
-                                                                               )));
-
-                                                                                       // Find fields to keep
-                                                                               $keepFields = $tcemainObj->getUniqueFields($table);
-                                                                               if ($TCA[$table]['ctrl']['sortby']) {
-                                                                                       $keepFields[] = $TCA[$table]['ctrl']['sortby'];
-                                                                               }
-                                                                                       // l10n-fields must be kept otherwise the localization
-                                                                                       // will be lost during the publishing
-                                                                               if (!isset($TCA[$table]['ctrl']['transOrigPointerTable']) && $TCA[$table]['ctrl']['transOrigPointerField']) {
-                                                                                       $keepFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
-                                                                               }
-
-                                                                                       // Swap "keepfields"
-                                                                               foreach ($keepFields as $fN) {
-                                                                                       $tmp = $swapVersion[$fN];
-                                                                                       $swapVersion[$fN] = $curVersion[$fN];
-                                                                                       $curVersion[$fN] = $tmp;
-                                                                               }
-
-                                                                                       // Preserve states:
-                                                                               $t3ver_state = array();
-                                                                               $t3ver_state['swapVersion'] = $swapVersion['t3ver_state'];
-                                                                               $t3ver_state['curVersion'] = $curVersion['t3ver_state'];
-
-                                                                                       // Modify offline version to become online:
-                                                                               $tmp_wsid = $swapVersion['t3ver_wsid'];
-                                                                                       // Set pid for ONLINE
-                                                                               $swapVersion['pid'] = intval($curVersion['pid']);
-                                                                                       // We clear this because t3ver_oid only make sense for offline versions
-                                                                                       // and we want to prevent unintentional misuse of this
-                                                                                       // value for online records.
-                                                                               $swapVersion['t3ver_oid'] = 0;
-                                                                                       // In case of swapping and the offline record has a state
-                                                                                       // (like 2 or 4 for deleting or move-pointer) we set the
-                                                                                       // current workspace ID so the record is not deselected
-                                                                                       // in the interface by t3lib_BEfunc::versioningPlaceholderClause()
-                                                                               $swapVersion['t3ver_wsid'] = 0;
-                                                                               if ($swapIntoWS) {
-                                                                                       if ($t3ver_state['swapVersion'] > 0) {
-                                                                                               $swapVersion['t3ver_wsid'] = $tcemainObj->BE_USER->workspace;
-                                                                                       } else {
-                                                                                               $swapVersion['t3ver_wsid'] = intval($curVersion['t3ver_wsid']);
-                                                                                       }
-                                                                               }
-                                                                               $swapVersion['t3ver_tstamp'] = $GLOBALS['EXEC_TIME'];
-                                                                               $swapVersion['t3ver_stage'] = 0;
-                                                                               if (!$swapIntoWS) {
-                                                                                       $swapVersion['t3ver_state'] = 0;
-                                                                               }
-
-                                                                                       // Moving element.
-                                                                               if ((int)$TCA[$table]['ctrl']['versioningWS']>=2)       {               //  && $t3ver_state['swapVersion']==4   // Maybe we don't need this?
-                                                                                       if ($plhRec = t3lib_BEfunc::getMovePlaceholder($table, $id, 't3ver_state,pid,uid' . ($TCA[$table]['ctrl']['sortby'] ? ',' . $TCA[$table]['ctrl']['sortby'] : ''))) {
-                                                                                               $movePlhID = $plhRec['uid'];
-                                                                                               $movePlh['pid'] = $swapVersion['pid'];
-                                                                                               $swapVersion['pid'] = intval($plhRec['pid']);
-
-                                                                                               $curVersion['t3ver_state'] = intval($swapVersion['t3ver_state']);
-                                                                                               $swapVersion['t3ver_state'] = 0;
-
-                                                                                               if ($TCA[$table]['ctrl']['sortby']) {
-                                                                                                               // sortby is a "keepFields" which is why this will work...
-                                                                                                       $movePlh[$TCA[$table]['ctrl']['sortby']] = $swapVersion[$TCA[$table]['ctrl']['sortby']];
-                                                                                                       $swapVersion[$TCA[$table]['ctrl']['sortby']] = $plhRec[$TCA[$table]['ctrl']['sortby']];
-                                                                                               }
-                                                                                       }
-                                                                               }
-
-                                                                                       // Take care of relations in each field (e.g. IRRE):
-                                                                               if (is_array($GLOBALS['TCA'][$table]['columns'])) {
-                                                                                       foreach ($GLOBALS['TCA'][$table]['columns'] as $field => $fieldConf) {
-                                                                                               $this->version_swap_procBasedOnFieldType(
-                                                                                                       $table, $field, $fieldConf['config'], $curVersion, $swapVersion, $tcemainObj
-                                                                                               );
-                                                                                       }
-                                                                               }
-                                                                               unset($swapVersion['uid']);
-
-                                                                                       // Modify online version to become offline:
-                                                                               unset($curVersion['uid']);
-                                                                                       // Set pid for OFFLINE
-                                                                               $curVersion['pid'] = -1;
-                                                                               $curVersion['t3ver_oid'] = intval($id);
-                                                                               $curVersion['t3ver_wsid'] = ($swapIntoWS ? intval($tmp_wsid) : 0);
-                                                                               $curVersion['t3ver_tstamp'] = $GLOBALS['EXEC_TIME'];
-                                                                               $curVersion['t3ver_count'] = $curVersion['t3ver_count']+1;      // Increment lifecycle counter
-                                                                               $curVersion['t3ver_stage'] = 0;
-                                                                               if (!$swapIntoWS) {
-                                                                                       $curVersion['t3ver_state'] = 0;
-                                                                               }
-
-                                                                                       // Keeping the swapmode state
-                                                                               if ($table === 'pages') {
-                                                                                       $curVersion['t3ver_swapmode'] = $swapVersion['t3ver_swapmode'];
-                                                                               }
-
-                                                                                       // Registering and swapping MM relations in current and swap records:
-                                                                               $tcemainObj->version_remapMMForVersionSwap($table, $id, $swapWith);
-
-                                                                                       // Generating proper history data to prepare logging
-                                                                               $tcemainObj->compareFieldArrayWithCurrentAndUnset($table, $id, $swapVersion);
-                                                                               $tcemainObj->compareFieldArrayWithCurrentAndUnset($table, $swapWith, $curVersion);
-
-                                                                                       // Execute swapping:
-                                                                               $sqlErrors = array();
-                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $swapVersion);
-                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                               } else {
-                                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($swapWith), $curVersion);
-                                                                                       if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                               $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                       } else {
-                                                                                               unlink($lockFileName);
-                                                                                       }
-                                                                               }
-
-                                                                               if (!count($sqlErrors)) {
-                                                                                               // Register swapped ids for later remapping:
-                                                                                       $this->remappedIds[$table][$id] =$swapWith;
-                                                                                       $this->remappedIds[$table][$swapWith] = $id;
-
-                                                                                               // If a moving operation took place...:
-                                                                                       if ($movePlhID) {
-                                                                                                       // Remove, if normal publishing:
-                                                                                               if (!$swapIntoWS) {
-                                                                                                               // For delete + completely delete!
-                                                                                                       $tcemainObj->deleteEl($table, $movePlhID, TRUE, TRUE);
-                                                                                               } else {
-                                                                                                       // Otherwise update the movePlaceholder:
-                                                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($movePlhID), $movePlh);
-                                                                                                       $tcemainObj->addRemapStackRefIndex($table, $movePlhID);
-                                                                                               }
-                                                                                       }
-
-                                                                                               // Checking for delete:
-                                                                                               // Delete only if new/deleted placeholders are there.
-                                                                                       if (!$swapIntoWS && ((int)$t3ver_state['swapVersion'] === 1 || (int)$t3ver_state['swapVersion'] === 2)) {
-                                                                                                       // Force delete
-                                                                                               $tcemainObj->deleteEl($table, $id, TRUE);
-                                                                                       }
-
-                                                                                       $tcemainObj->newlog2(($swapIntoWS ? 'Swapping' : 'Publishing') . ' successful for table "' . $table . '" uid ' . $id . '=>' . $swapWith, $table, $id, $swapVersion['pid']);
-
-                                                                                               // Update reference index of the live record:
-                                                                                       $tcemainObj->addRemapStackRefIndex($table, $id);
-
-                                                                                               // Set log entry for live record:
-                                                                                       $propArr = $tcemainObj->getRecordPropertiesFromRow($table, $swapVersion);
-                                                                                       if ($propArr['_ORIG_pid'] == -1) {
-                                                                                               $label = $GLOBALS['LANG']->sL ('LLL:EXT:lang/locallang_tcemain.xml:version_swap.offline_record_updated');
-                                                                                       } else {
-                                                                                               $label = $GLOBALS['LANG']->sL ('LLL:EXT:lang/locallang_tcemain.xml:version_swap.online_record_updated');
-                                                                                       }
-                                                                                       $theLogId = $tcemainObj->log($table, $id, 2, $propArr['pid'], 0, $label , 10, array($propArr['header'], $table . ':' . $id), $propArr['event_pid']);
-                                                                                       $tcemainObj->setHistory($table, $id, $theLogId);
-
-                                                                                               // Update reference index of the offline record:
-                                                                                       $tcemainObj->addRemapStackRefIndex($table, $swapWith);
-                                                                                               // Set log entry for offline record:
-                                                                                       $propArr = $tcemainObj->getRecordPropertiesFromRow($table, $curVersion);
-                                                                                       if ($propArr['_ORIG_pid'] == -1) {
-                                                                                               $label = $GLOBALS['LANG']->sL ('LLL:EXT:lang/locallang_tcemain.xml:version_swap.offline_record_updated');
-                                                                                       } else {
-                                                                                               $label = $GLOBALS['LANG']->sL ('LLL:EXT:lang/locallang_tcemain.xml:version_swap.online_record_updated');
-                                                                                       }
-                                                                                       $theLogId = $tcemainObj->log($table, $swapWith, 2, $propArr['pid'], 0, $label, 10, array($propArr['header'], $table . ':' . $swapWith), $propArr['event_pid']);
-                                                                                       $tcemainObj->setHistory($table, $swapWith, $theLogId);
-
-                                                                                               // SWAPPING pids for subrecords:
-                                                                                       if ($table=='pages' && $swapVersion['t3ver_swapmode'] >= 0) {
-
-                                                                                                       // Collect table names that should be copied along with the tables:
-                                                                                               foreach ($TCA as $tN => $tCfg)  {
-                                                                                                               // For "Branch" publishing swap ALL,
-                                                                                                               // otherwise for "page" publishing, swap only "versioning_followPages" tables
-                                                                                                       if ($swapVersion['t3ver_swapmode'] > 0 || $TCA[$tN]['ctrl']['versioning_followPages']) {
-                                                                                                               $temporaryPid = -($id+1000000);
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($id), array('pid' => $temporaryPid));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($swapWith), array('pid' => $id));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($temporaryPid), array('pid' => $swapWith));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               if (count($sqlErrors)) {
-                                                                                                                       $tcemainObj->newlog('During Swapping: SQL errors happened: ' . implode('; ', $sqlErrors), 2);
-                                                                                                               }
-                                                                                                       }
-                                                                                               }
-                                                                                       }
-                                                                                               // Clear cache:
-                                                                                       $tcemainObj->clear_cache($table, $id);
-
-                                                                                               // Checking for "new-placeholder" and if found, delete it (BUT FIRST after swapping!):
-                                                                                       if (!$swapIntoWS && $t3ver_state['curVersion']>0) {
-                                                                                                       // For delete + completely delete!
-                                                                                               $tcemainObj->deleteEl($table, $swapWith, TRUE, TRUE);
-                                                                                       }
-                                                                               } else $tcemainObj->newlog('During Swapping: SQL errors happened: ' . implode('; ', $sqlErrors), 2);
-                                                                       } else $tcemainObj->newlog('A swapping lock file was present. Either another swap process is already running or a previous swap process failed. Ask your administrator to handle the situation.', 2);
-                                                               } else $tcemainObj->newlog('In swap version, either pid was not -1 or the t3ver_oid didn\'t match the id of the online version as it must!', 2);
-                                                       } else $tcemainObj->newlog('Workspace #' . $swapVersion['t3ver_wsid'] . ' does not support swapping.', 1);
-                                               } else $tcemainObj->newlog('You cannot publish a record you do not have edit and show permissions for', 1);
-                                       } else $tcemainObj->newlog('Records in workspace #' . $swapVersion['t3ver_wsid'] . ' can only be published when in "Publish" stage.', 1);
-                               } else $tcemainObj->newlog('User could not publish records from workspace #' . $swapVersion['t3ver_wsid'], 1);
-                       } else $tcemainObj->newlog('Error: Either online or swap version could not be selected!', 2);
-               } else $tcemainObj->newlog('Error: You cannot swap versions for a record you do not have access to edit!', 1);
-       }
-
-
-       /**
-        * Update relations on version/workspace swapping.
-        *
-        * @param string $table: Record Table
-        * @param string $field: Record field
-        * @param array $conf: TCA configuration of current field
-        * @param array $curVersion: Reference to the current (original) record
-        * @param array $swapVersion: Reference to the record (workspace/versionized) to publish in or swap with
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return  void
-        */
-       protected function version_swap_procBasedOnFieldType($table, $field, array $conf, array &$curVersion, array &$swapVersion, t3lib_TCEmain $tcemainObj) {
-               $inlineType = $tcemainObj->getInlineFieldType($conf);
-
-                       // Process pointer fields on normalized database:
-               if ($inlineType == 'field') {
-                       // Read relations that point to the current record (e.g. live record):
-                       /** @var $dbAnalysisCur t3lib_loadDBGroup */
-                       $dbAnalysisCur = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                       $dbAnalysisCur->setUpdateReferenceIndex(FALSE);
-                       $dbAnalysisCur->start('', $conf['foreign_table'], '', $curVersion['uid'], $table, $conf);
-                       // Read relations that point to the record to be swapped with e.g. draft record):
-                       /** @var $dbAnalysisSwap t3lib_loadDBGroup */
-                       $dbAnalysisSwap = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                       $dbAnalysisSwap->setUpdateReferenceIndex(FALSE);
-                       $dbAnalysisSwap->start('', $conf['foreign_table'], '', $swapVersion['uid'], $table, $conf);
-                               // Update relations for both (workspace/versioning) sites:
-
-                       if (count($dbAnalysisCur->itemArray)) {
-                               $dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
-                               $tcemainObj->addRemapAction(
-                                       $table, $curVersion['uid'],
-                                       array($this, 'writeRemappedForeignField'),
-                                       array($dbAnalysisCur, $conf, $swapVersion['uid'])
-                               );
-                       }
-
-                       if (count($dbAnalysisSwap->itemArray)) {
-                               $dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
-                               $tcemainObj->addRemapAction(
-                                       $table, $curVersion['uid'],
-                                       array($this, 'writeRemappedForeignField'),
-                                       array($dbAnalysisSwap, $conf, $curVersion['uid'])
-                               );
-                       }
-
-                       $items = array_merge($dbAnalysisCur->itemArray, $dbAnalysisSwap->itemArray);
-                       foreach ($items as $item) {
-                               $tcemainObj->addRemapStackRefIndex($item['table'], $item['id']);
-                       }
-
-                       // Swap field values (CSV):
-                       // BUT: These values will be swapped back in the next steps, when the *CHILD RECORD ITSELF* is swapped!
-               } elseif ($inlineType == 'list') {
-                       $tempValue = $curVersion[$field];
-                       $curVersion[$field] = $swapVersion[$field];
-                       $swapVersion[$field] = $tempValue;
-               }
-       }
-
-       /**
-        * Writes remapped foreign field (IRRE).
-        *
-        * @param t3lib_loadDBGroup $dbAnalysis Instance that holds the sorting order of child records
-        * @param array $configuration The TCA field configuration
-        * @param integer $parentId The uid of the parent record
-        * @return void
-        */
-       public function writeRemappedForeignField(t3lib_loadDBGroup $dbAnalysis, array $configuration, $parentId) {
-               foreach ($dbAnalysis->itemArray as &$item) {
-                       if (isset($this->remappedIds[$item['table']][$item['id']])) {
-                               $item['id'] = $this->remappedIds[$item['table']][$item['id']];
-                       }
-               }
-
-               $dbAnalysis->writeForeignField($configuration, $parentId);
-       }
-
-
-
-       /**
-        * Release version from this workspace (and into "Live" workspace but as an offline version).
-        *
-        * @param string $table Table name
-        * @param integer $id Record UID
-        * @param boolean $flush If set, will completely delete element
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return      void
-        */
-       protected function version_clearWSID($table, $id, $flush = FALSE, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-               if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
-                       $tcemainObj->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1);
-               } elseif ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
-                       if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state')) {
-                                       // Clear workspace ID:
-                               $updateData = array(
-                                       't3ver_wsid' => 0
-                               );
-                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $updateData);
-
-                                       // Clear workspace ID for live version AND DELETE IT as well because it is a new record!
-                               if ((int) $liveRec['t3ver_state'] == 1 || (int) $liveRec['t3ver_state'] == 2) {
-                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid=' . intval($liveRec['uid']), $updateData);
-                                               // THIS assumes that the record was placeholder ONLY for ONE record (namely $id)
-                                       $tcemainObj->deleteEl($table, $liveRec['uid'], TRUE);
-                               }
-
-                                       // If "deleted" flag is set for the version that got released
-                                       // it doesn't make sense to keep that "placeholder" anymore and we delete it completly.
-                               $wsRec = t3lib_BEfunc::getRecord($table, $id);
-                               if ($flush || ((int) $wsRec['t3ver_state'] == 1 || (int) $wsRec['t3ver_state'] == 2)) {
-                                       $tcemainObj->deleteEl($table, $id, TRUE, TRUE);
-                               }
-
-                                       // Remove the move-placeholder if found for live record.
-                               if ((int)$TCA[$table]['ctrl']['versioningWS'] >= 2) {
-                                       if ($plhRec = t3lib_BEfunc::getMovePlaceholder($table, $liveRec['uid'], 'uid')) {
-                                               $tcemainObj->deleteEl($table, $plhRec['uid'], TRUE, TRUE);
-                                       }
-                               }
-                       }
-               } else $tcemainObj->newlog('Attempt to reset workspace for record failed because you do not have edit access',1);
-       }
-
-
-       /*******************************
-        *****  helper functions  ******
-        *******************************/
-
-
-       /**
-        * Copies all records from tables in $copyTablesArray from page with $old_pid to page with $new_pid
-        * Uses raw-copy for the operation (meant for versioning!)
-        *
-        * @param integer $oldPageId Current page id.
-        * @param integer $newPageId New page id
-        * @param array $copyTablesArray Array of tables from which to copy
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return void
-        * @see versionizePages()
-        */
-       protected function rawCopyPageContent($oldPageId, $newPageId, array $copyTablesArray, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-               if ($newPageId) {
-                       foreach ($copyTablesArray as $table) {
-                                               // all records under the page is copied.
-                               if ($table && is_array($TCA[$table]) && $table != 'pages') {
-                                       $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                               'uid',
-                                               $table,
-                                               'pid=' . intval($oldPageId) . $tcemainObj->deleteClause($table)
-                                       );
-                                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
-                                                       // Check, if this record has already been copied by a parent record as relation:
-                                               if (!$tcemainObj->copyMappingArray[$table][$row['uid']]) {
-                                                               // Copying each of the underlying records (method RAW)
-                                                       $tcemainObj->copyRecord_raw($table, $row['uid'], $newPageId);
-                                               }
-                                       }
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($mres);
-                               }
-                       }
-               }
-       }
-
-
-       /**
-        * Finds all elements for swapping versions in workspace
-        *
-        * @param  string $table Table name of the original element to swap
-        * @param integer $id UID of the original element to swap (online)
-        * @param integer $offlineId As above but offline
-        * @return array Element data. Key is table name, values are array with first element as online UID, second - offline UID
-        */
-       public function findPageElementsForVersionSwap($table, $id, $offlineId) {
-               global  $TCA;
-
-               $rec = t3lib_BEfunc::getRecord($table, $offlineId, 't3ver_wsid');
-               $workspaceId = $rec['t3ver_wsid'];
-
-               $elementData = array();
-               if ($workspaceId != 0) {
-                       // Get page UID for LIVE and workspace
-                       if ($table != 'pages') {
-                               $rec = t3lib_BEfunc::getRecord($table, $id, 'pid');
-                               $pageId = $rec['pid'];
-                               $rec = t3lib_BEfunc::getRecord('pages', $pageId);
-                               t3lib_BEfunc::workspaceOL('pages', $rec, $workspaceId);
-                               $offlinePageId = $rec['_ORIG_uid'];
-                       } else {
-                               $pageId = $id;
-                               $offlinePageId = $offlineId;
-                       }
-
-                       // Traversing all tables supporting versioning:
-                       foreach ($TCA as $table => $cfg) {
-                               if ($TCA[$table]['ctrl']['versioningWS'] && $table != 'pages') {
-                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('A.uid AS offlineUid, B.uid AS uid',
-                                                       $table . ' A,' . $table . ' B',
-                                                       'A.pid=-1 AND B.pid=' . $pageId . ' AND A.t3ver_wsid=' . $workspaceId .
-                                                       ' AND B.uid=A.t3ver_oid' .
-                                                       t3lib_BEfunc::deleteClause($table, 'A') . t3lib_BEfunc::deleteClause($table, 'B'));
-                                       while (FALSE != ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res))) {
-                                               $elementData[$table][] = array($row[1], $row[0]);
-                                       }
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-                               }
-                       }
-                       if ($offlinePageId && $offlinePageId != $pageId) {
-                               $elementData['pages'][] = array($pageId, $offlinePageId);
-                       }
-               }
-               return $elementData;
-       }
-
-       /**
-        * Searches for all elements from all tables on the given pages in the same workspace.
-        *
-        * @param array $pageIdList List of PIDs to search
-        * @param integer $workspaceId Workspace ID
-        * @param array $elementList List of found elements. Key is table name, value is array of element UIDs
-        * @return void
-        */
-       public function findPageElementsForVersionStageChange(array $pageIdList, $workspaceId, array &$elementList) {
-               global $TCA;
-
-               if ($workspaceId != 0) {
-                               // Traversing all tables supporting versioning:
-                       foreach ($TCA as $table => $cfg)        {
-                               if ($TCA[$table]['ctrl']['versioningWS'] && $table != 'pages')  {
-                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT A.uid',
-                                               $table . ' A,' . $table . ' B',
-                                               'A.pid=-1' .            // Offline version
-                                               ' AND A.t3ver_wsid=' . $workspaceId .
-                                               ' AND B.pid IN (' . implode(',', $pageIdList) . ') AND A.t3ver_oid=B.uid' .
-                                               t3lib_BEfunc::deleteClause($table,'A').
-                                               t3lib_BEfunc::deleteClause($table,'B')
-                                       );
-                                       while (FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res))) {
-                                               $elementList[$table][] = $row[0];
-                                       }
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-                                       if (is_array($elementList[$table])) {
-                                               // Yes, it is possible to get non-unique array even with DISTINCT above!
-                                               // It happens because several UIDs are passed in the array already.
-                                               $elementList[$table] = array_unique($elementList[$table]);
-                                       }
-                               }
-                       }
-               }
-       }
-
-
-       /**
-        * Finds page UIDs for the element from table <code>$table</code> with UIDs from <code>$idList</code>
-        *
-        * @param string $table Table to search
-        * @param array $idList List of records' UIDs
-        * @param integer $workspaceId Workspace ID. We need this parameter because user can be in LIVE but he still can publisg DRAFT from ws module!
-        * @param array $pageIdList List of found page UIDs
-        * @param array $elementList List of found element UIDs. Key is table name, value is list of UIDs
-        * @return void
-        */
-       public function findPageIdsForVersionStateChange($table, array $idList, $workspaceId, array &$pageIdList, array &$elementList) {
-               if ($workspaceId != 0) {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT B.pid',
-                               $table . ' A,' . $table . ' B',
-                               'A.pid=-1' .            // Offline version
-                               ' AND A.t3ver_wsid=' . $workspaceId .
-                               ' AND A.uid IN (' . implode(',', $idList) . ') AND A.t3ver_oid=B.uid' .
-                               t3lib_BEfunc::deleteClause($table,'A').
-                               t3lib_BEfunc::deleteClause($table,'B')
-                       );
-                       while (FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res))) {
-                               $pageIdList[] = $row[0];
-                                       // Find ws version
-                                       // Note: cannot use t3lib_BEfunc::getRecordWSOL()
-                                       // here because it does not accept workspace id!
-                               $rec = t3lib_BEfunc::getRecord('pages', $row[0]);
-                               t3lib_BEfunc::workspaceOL('pages', $rec, $workspaceId);
-                               if ($rec['_ORIG_uid']) {
-                                       $elementList['pages'][$row[0]] = $rec['_ORIG_uid'];
-                               }
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-                               // The line below is necessary even with DISTINCT
-                               // because several elements can be passed by caller
-                       $pageIdList = array_unique($pageIdList);
-               }
-       }
-
-
-       /**
-        * Finds real page IDs for state change.
-        *
-        * @param       array   $idList List of page UIDs, possibly versioned
-        * @return      void
-        */
-       public function findRealPageIds(array &$idList) {
-               foreach ($idList as $key => $id) {
-                       $rec = t3lib_BEfunc::getRecord('pages', $id, 't3ver_oid');
-                       if ($rec['t3ver_oid'] > 0) {
-                               $idList[$key] = $rec['t3ver_oid'];
-                       }
-               }
-       }
-
-
-       /**
-        * Creates a move placeholder for workspaces.
-        * USE ONLY INTERNALLY
-        * Moving placeholder: Can be done because the system sees it as a placeholder for NEW elements like t3ver_state=1
-        * Moving original: Will either create the placeholder if it doesn't exist or move existing placeholder in workspace.
-        *
-        * @param string $table Table name to move
-        * @param integer $uid Record uid to move (online record)
-        * @param integer $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @param integer $wsUid UID of offline version of online record
-        * @param t3lib_TCEmain $tcemainObj TCEmain object
-        * @return void
-        * @see moveRecord()
-        */
-       protected function moveRecord_wsPlaceholders($table, $uid, $destPid, $wsUid, t3lib_TCEmain $tcemainObj) {
-               global $TCA;
-
-               if ($plh = t3lib_BEfunc::getMovePlaceholder($table, $uid, 'uid')) {
-                               // If already a placeholder exists, move it:
-                       $tcemainObj->moveRecord_raw($table, $plh['uid'], $destPid);
-               } else {
-                               // First, we create a placeholder record in the Live workspace that
-                               // represents the position to where the record is eventually moved to.
-                       $newVersion_placeholderFieldArray = array();
-                       if ($TCA[$table]['ctrl']['crdate']) {
-                               $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
-                       }
-                       if ($TCA[$table]['ctrl']['cruser_id']) {
-                               $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']] = $tcemainObj->userid;
-                       }
-                       if ($TCA[$table]['ctrl']['tstamp']) {
-                               $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
-                       }
-
-                       if ($table == 'pages') {
-                                       // Copy page access settings from original page to placeholder
-                               $perms_clause = $tcemainObj->BE_USER->getPagePermsClause(1);
-                               $access = t3lib_BEfunc::readPageAccess($uid, $perms_clause);
-
-                               $newVersion_placeholderFieldArray['perms_userid']    = $access['perms_userid'];
-                               $newVersion_placeholderFieldArray['perms_groupid']   = $access['perms_groupid'];
-                               $newVersion_placeholderFieldArray['perms_user']      = $access['perms_user'];
-                               $newVersion_placeholderFieldArray['perms_group']     = $access['perms_group'];
-                               $newVersion_placeholderFieldArray['perms_everybody'] = $access['perms_everybody'];
-                       }
-
-                       $newVersion_placeholderFieldArray['t3ver_label'] = 'MOVE-TO PLACEHOLDER for #' . $uid;
-                       $newVersion_placeholderFieldArray['t3ver_move_id'] = $uid;
-                               // Setting placeholder state value for temporary record
-                       $newVersion_placeholderFieldArray['t3ver_state'] = 3;
-
-                               // Setting workspace - only so display of place holders can filter out those from other workspaces.
-                       $newVersion_placeholderFieldArray['t3ver_wsid'] = $tcemainObj->BE_USER->workspace;
-                       $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[MOVE-TO PLACEHOLDER for #' . $uid . ', WS#' . $tcemainObj->BE_USER->workspace . ']';
-
-                               // moving localized records requires to keep localization-settings for the placeholder too
-                       if (array_key_exists('languageField', $GLOBALS['TCA'][$table]['ctrl']) && array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl'])) {
-                               $l10nParentRec = t3lib_BEfunc::getRecord($table, $uid);
-                               $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
-                               $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
-                               unset($l10nParentRec);
-                       }
-
-                               // Initially, create at root level.
-                       $newVersion_placeholderFieldArray['pid'] = 0;
-                       $id = 'NEW_MOVE_PLH';
-                               // Saving placeholder as 'original'
-                       $tcemainObj->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE);
-
-                               // Move the new placeholder from temporary root-level to location:
-                       $tcemainObj->moveRecord_raw($table, $tcemainObj->substNEWwithIDs[$id], $destPid);
-
-                               // Move the workspace-version of the original to be the version of the move-to-placeholder:
-                               // Setting placeholder state value for version (so it can know it is currently a new version...)
-                       $updateFields = array(
-                               't3ver_state' => 4
-                       );
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($wsUid), $updateFields);
-               }
-
-                       // Check for the localizations of that element and move them as well
-               $tcemainObj->moveL10nOverlayRecords($table, $uid, $destPid);
-       }
-
-       /**
-        * Gets all possible child tables that are used on each parent table as field.
-        *
-        * @param string $parentTable Name of the parent table
-        * @param array $possibleInlineChildren Collected possible inline children
-        *                              (will be filled automatically during recursive calls)
-        * @return array
-        */
-       protected function getPossibleInlineChildTablesOfParentTable($parentTable, array $possibleInlineChildren = array()) {
-               t3lib_div::loadTCA($parentTable);
-
-               foreach ($GLOBALS['TCA'][$parentTable]['columns'] as $parentField => $parentFieldDefinition) {
-                       if (isset($parentFieldDefinition['config']['type'])) {
-                               $parentFieldConfiguration = $parentFieldDefinition['config'];
-                               if ($parentFieldConfiguration['type'] == 'inline' && isset($parentFieldConfiguration['foreign_table'])) {
-                                       if (!in_array($parentFieldConfiguration['foreign_table'], $possibleInlineChildren)) {
-                                               $possibleInlineChildren = $this->getPossibleInlineChildTablesOfParentTable(
-                                                       $parentFieldConfiguration['foreign_table'],
-                                                       array_merge($possibleInlineChildren, $parentFieldConfiguration['foreign_table'])
-                                               );
-                                       }
-                               }
-                       }
-               }
-
-               return $possibleInlineChildren;
-       }
-
-       /**
-        * Gets an instance of the command map helper.
-        *
-        * @param t3lib_TCEmain $tceMain TCEmain object
-        * @param array $commandMap The command map as submitted to t3lib_TCEmain
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function getCommandMap(t3lib_TCEmain $tceMain, array $commandMap) {
-               return t3lib_div::makeInstance('tx_version_tcemain_CommandMap', $this, $tceMain, $commandMap);
-       }
-}
-
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain.php'])) {
-       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain.php']);
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/class.tx_version_tcemain_commandmap.php b/typo3/sysext/version/class.tx_version_tcemain_commandmap.php
deleted file mode 100644 (file)
index 80250ce..0000000
+++ /dev/null
@@ -1,782 +0,0 @@
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2010-2011 Oliver Hader <oliver@typo3.org>
- * 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!
- ***************************************************************/
-
-/**
- * Handles the t3lib_TCEmain command map and is only used in combination with t3lib_TCEmain.
- */
-class tx_version_tcemain_CommandMap {
-       const SCOPE_WorkspacesSwap = 'SCOPE_WorkspacesSwap';
-       const SCOPE_WorkspacesSetStage = 'SCOPE_WorkspacesSetStage';
-
-       const KEY_ScopeErrorMessage = 'KEY_ScopeErrorMessage';
-       const KEY_ScopeErrorCode = 'KEY_ScopeErrorCode';
-       const KEY_GetElementPropertiesCallback = 'KEY_GetElementPropertiesCallback';
-       const KEY_GetCommonPropertiesCallback = 'KEY_GetCommonPropertiesCallback';
-       const KEY_ElementConstructCallback = 'KEY_EventConstructCallback';
-       const KEY_ElementCreateChildReferenceCallback = 'KEY_ElementCreateChildReferenceCallback';
-       const KEY_ElementCreateParentReferenceCallback = 'KEY_ElementCreateParentReferenceCallback';
-       const KEY_PurgeWithErrorMessageGetIdCallback = 'KEY_PurgeWithErrorMessageGetIdCallback';
-       const KEY_UpdateGetIdCallback = 'KEY_UpdateGetIdCallback';
-       const KEY_TransformDependentElementsToUseLiveId = 'KEY_TransformDependentElementsToUseLiveId';
-
-       /**
-        * @var tx_version_tcemain
-        */
-       protected $parent;
-
-       /**
-        * @var t3lib_TCEmain
-        */
-       protected $tceMain;
-
-       /**
-        * @var array
-        */
-       protected $commandMap = array();
-
-       /**
-        * @var string
-        */
-       protected $workspacesSwapMode;
-
-       /**
-        * @var string
-        */
-       protected $workspacesChangeStageMode;
-
-       /**
-        * @var boolean
-        */
-       protected $workspacesConsiderReferences;
-
-       /**
-        * @var array
-        */
-       protected $scopes;
-
-       /**
-        * Creates this object.
-        *
-        * @param t3lib_TCEmain $parent
-        * @param array $commandMap
-        */
-       public function __construct(tx_version_tcemain $parent, t3lib_TCEmain $tceMain, array $commandMap) {
-               $this->setParent($parent);
-               $this->setTceMain($tceMain);
-               $this->set($commandMap);
-
-               $this->setWorkspacesSwapMode($this->getTceMain()->BE_USER->getTSConfigVal('options.workspaces.swapMode'));
-               $this->setWorkspacesChangeStageMode($this->getTceMain()->BE_USER->getTSConfigVal('options.workspaces.changeStageMode'));
-               $this->setWorkspacesConsiderReferences($this->getTceMain()->BE_USER->getTSConfigVal('options.workspaces.considerReferences'));
-
-               $this->constructScopes();
-       }
-
-       /**
-        * Gets the command map.
-        *
-        * @return array
-        */
-       public function get() {
-               return $this->commandMap;
-       }
-
-       /**
-        * Sets the command map.
-        *
-        * @param array $commandMap
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function set(array $commandMap) {
-               $this->commandMap = $commandMap;
-               return $this;
-       }
-
-       /**
-        * Gets the parent object.
-        *
-        * @return tx_version_tcemain
-        */
-       public function getParent() {
-               return $this->parent;
-       }
-
-       /**
-        * Sets the parent object.
-        *
-        * @param tx_version_tcemain $parent
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function setParent(tx_version_tcemain $parent) {
-               $this->parent = $parent;
-               return $this;
-       }
-
-       /**
-        * Gets the parent object.
-        *
-        * @return t3lib_TCEmain
-        */
-       public function getTceMain() {
-               return $this->tceMain;
-       }
-
-       /**
-        * Sets the parent object.
-        *
-        * @param t3lib_TCEmain $parent
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function setTceMain(t3lib_TCEmain $tceMain) {
-               $this->tceMain = $tceMain;
-               return $this;
-       }
-
-       /**
-        * Sets the workspaces swap mode
-        * (see options.workspaces.swapMode).
-        *
-        * @param string $workspacesSwapMode
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function setWorkspacesSwapMode($workspacesSwapMode) {
-               $this->workspacesSwapMode = (string)$workspacesSwapMode;
-               return $this;
-       }
-
-       /**
-        * Sets the workspaces change stage mode
-        * see options.workspaces.changeStageMode)
-        *
-        * @param string $workspacesChangeStageMode
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function setWorkspacesChangeStageMode($workspacesChangeStageMode) {
-               $this->workspacesChangeStageMode = (string)$workspacesChangeStageMode;
-               return $this;
-       }
-
-       /**
-        * Sets the workspace behaviour to automatically consider references
-        * (see options.workspaces.considerReferences)
-        *
-        * @param boolean $workspacesConsiderReferences
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function setWorkspacesConsiderReferences($workspacesConsiderReferences) {
-               $this->workspacesConsiderReferences = (bool)$workspacesConsiderReferences;
-               return $this;
-       }
-
-       /**
-        * Processes the command map.
-        *
-        * @return tx_version_tcemain_CommandMap
-        */
-       public function process() {
-               $this->resolveWorkspacesSwapDependencies();
-               $this->resolveWorkspacesSetStageDependencies();
-               return $this;
-       }
-
-       /**
-        * Resolves workspaces related dependencies for swapping/publishing of the command map.
-        * Workspaces records that have children or (relative) parents which are versionized
-        * but not published with this request, are removed from the command map. Otherwise
-        * this would produce hanging record sets and lost references.
-        *
-        * @return void
-        */
-       protected function resolveWorkspacesSwapDependencies() {
-               $scope = self::SCOPE_WorkspacesSwap;
-               $dependency = $this->getDependencyUtility($scope);
-
-               foreach ($this->commandMap as $table => $liveIdCollection) {
-                       foreach ($liveIdCollection as $liveId => $commandCollection) {
-                               foreach ($commandCollection as $command => $properties) {
-                                       if ($command === 'version' && isset($properties['action']) && $properties['action'] === 'swap') {
-                                               if (isset($properties['swapWith']) && t3lib_div::testInt($properties['swapWith'])) {
-                                                       $this->addWorkspacesSwapElements($dependency, $table, $liveId, $properties);
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               $this->applyWorkspacesDependencies($dependency, $scope);
-       }
-
-       /**
-        * Adds workspaces elements for swapping/publishing and takes care of the swapMode.
-        *
-        * @param t3lib_utility_Dependency $dependency
-        * @param string $table
-        * @param iteger $liveId
-        * @param array $properties
-        * @return void
-        */
-       protected function addWorkspacesSwapElements(t3lib_utility_Dependency $dependency, $table, $liveId, array $properties) {
-               $elementList = array();
-
-               // Fetch accordant elements if the swapMode is 'any' or 'pages':
-               if ($this->workspacesSwapMode === 'any' || $this->workspacesSwapMode === 'pages' && $table === 'pages') {
-                       $elementList = $this->getParent()->findPageElementsForVersionSwap($table, $liveId, $properties['swapWith']);
-               }
-
-               foreach ($elementList as $elementTable => $elementIdArray) {
-                       foreach ($elementIdArray as $elementIds) {
-                               $dependency->addElement(
-                                       $elementTable, $elementIds[1],
-                                       array('liveId' => $elementIds[0], 'properties' => array_merge($properties, array('swapWith' => $elementIds[1])))
-                               );
-                       }
-               }
-
-               if (count($elementList) === 0) {
-                       $dependency->addElement(
-                               $table, $properties['swapWith'], array('liveId' => $liveId, 'properties' => $properties)
-                       );
-               }
-       }
-
-       /**
-        * Resolves workspaces related dependencies for staging of the command map.
-        * Workspaces records that have children or (relative) parents which are versionized
-        * but not staged with this request, are removed from the command map.
-        *
-        * @return void
-        */
-       protected function resolveWorkspacesSetStageDependencies() {
-               $scope = self::SCOPE_WorkspacesSetStage;
-               $dependency = $this->getDependencyUtility($scope);
-
-               foreach ($this->commandMap as $table => $liveIdCollection) {
-                       foreach ($liveIdCollection as $liveIdList => $commandCollection) {
-                               foreach ($commandCollection as $command => $properties) {
-                                       if ($command === 'version' && isset($properties['action']) && $properties['action'] === 'setStage') {
-                                               if (isset($properties['stageId']) && t3lib_div::testInt($properties['stageId'])) {
-                                                       $this->addWorkspacesSetStageElements($dependency, $table, $liveIdList, $properties);
-                                                       $this->explodeSetStage($table, $liveIdList, $properties);
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               $this->applyWorkspacesDependencies($dependency, $scope);
-       }
-
-       /**
-        * Adds workspaces elements for staging and takes care of the changeStageMode.
-        *
-        * @param t3lib_utility_Dependency $dependency
-        * @param string $table
-        * @param string $liveIdList
-        * @param array $properties
-        * @return void
-        */
-       protected function addWorkspacesSetStageElements(t3lib_utility_Dependency $dependency, $table, $liveIdList, array $properties) {
-               $liveIds = t3lib_div::trimExplode(',', $liveIdList, TRUE);
-               $elementList = array($table => $liveIds);
-
-               if (t3lib_div::inList('any,pages', $this->workspacesChangeStageMode)) {
-                       if (count($liveIds) === 1) {
-                               $workspaceRecord = t3lib_BEfunc::getRecord($table, $liveIds[0], 't3ver_wsid');
-                               $workspaceId = $workspaceRecord['t3ver_wsid'];
-                       } else {
-                               $workspaceId = $this->tceMain()->BE_USER->workspace;
-                       }
-
-                       if ($table === 'pages') {
-                               // Find all elements from the same ws to change stage
-                               $this->getParent()->findRealPageIds($liveIds);
-                               $this->getParent()->findPageElementsForVersionStageChange($liveIds, $workspaceId, $elementList);
-                       } elseif ($this->workspacesChangeStageMode === 'any') {
-                               // Find page to change stage:
-                               $pageIdList = array();
-                               $this->getParent()->findPageIdsForVersionStateChange($table, $liveIds, $workspaceId, $pageIdList, $elementList);
-                               // Find other elements from the same ws to change stage:
-                               $this->getParent()->findPageElementsForVersionStageChange($pageIdList, $workspaceId, $elementList);
-                       }
-               }
-
-               foreach ($elementList as $elementTable => $elementIds) {
-                       foreach($elementIds as $elementId) {
-                               $dependency->addElement(
-                                       $elementTable, $elementId,
-                                       array('properties' => $properties)
-                               );
-                       }
-               }
-       }
-
-       /**
-        * Explodes id-lists in the command map for staging actions.
-        *
-        * @throws RuntimeException
-        * @param string $table
-        * @param string $liveIdList
-        * @param array $properties
-        * @return void
-        */
-       protected function explodeSetStage($table, $liveIdList, array $properties) {
-               $extractedCommandMap = array();
-               $liveIds = t3lib_div::trimExplode(',', $liveIdList, TRUE);
-
-               if (count($liveIds) > 1) {
-                       foreach ($liveIds as $liveId) {
-                               if (isset($this->commandMap[$table][$liveId]['version'])) {
-                                       throw new RuntimeException('Command map for [' . $table . '][' . $liveId . '][version] was already set.', 1289391048);
-                               }
-
-                               $extractedCommandMap[$table][$liveId]['version'] = $properties;
-                       }
-
-                       $this->remove($table, $liveIdList, 'version');
-                       $this->mergeToBottom($extractedCommandMap);
-               }
-       }
-
-       /**
-        * Applies the workspaces dependencies and removes incomplete structures or automatically
-        * completes them, depending on the options.workspaces.considerReferences setting
-        *
-        * @param t3lib_utility_Dependency $dependency
-        * @param string $scope
-        * @return void
-        */
-       protected function applyWorkspacesDependencies(t3lib_utility_Dependency $dependency, $scope) {
-               $transformDependentElementsToUseLiveId = $this->getScopeData($scope, self::KEY_TransformDependentElementsToUseLiveId);
-
-               $elementsToBeVersionized = $dependency->getElements();
-               if ($transformDependentElementsToUseLiveId) {
-                       $elementsToBeVersionized = $this->transformDependentElementsToUseLiveId($elementsToBeVersionized);
-               }
-
-               $outerMostParents = $dependency->getOuterMostParents();
-               /** @var $outerMostParent t3lib_utility_Dependency_Element */
-               foreach ($outerMostParents as $outerMostParent) {
-                       $dependentElements = $dependency->getNestedElements($outerMostParent);
-                       if ($transformDependentElementsToUseLiveId) {
-                               $dependentElements = $this->transformDependentElementsToUseLiveId($dependentElements);
-                       }
-
-                       $intersectingElements = array_intersect_key($dependentElements, $elementsToBeVersionized);
-
-                       if (count($intersectingElements) > 0) {
-                               // If at least one element intersects but not all, throw away all elements of the depdendent structure:
-                               if (count($intersectingElements) !== count($dependentElements) && $this->workspacesConsiderReferences === FALSE) {
-                                       $this->purgeWithErrorMessage($intersectingElements, $scope);
-                               // If everything is fine or references shall be considered automatically:
-                               } else {
-                                       $this->update(current($intersectingElements), $dependentElements, $scope);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Purges incomplete structures from the command map and triggers an error message.
-        *
-        * @param array $elements
-        * @param string $scope
-        * @return void
-        */
-       protected function purgeWithErrorMessage(array $elements, $scope) {
-               /** @var $dependentElement t3lib_utility_Dependency_Element */
-               foreach ($elements as $element) {
-                       $table = $element->getTable();
-                       $id = $this->processCallback(
-                               $this->getScopeData($scope, self::KEY_PurgeWithErrorMessageGetIdCallback),
-                               array($element)
-                       );
-
-                       $this->remove($table, $id, 'version');
-                       $this->getTceMain()->log(
-                               $table, $id,
-                               5, 0, 1,
-                               $this->getScopeData($scope, self::KEY_ScopeErrorMessage),
-                               $this->getScopeData($scope, self::KEY_ScopeErrorCode),
-                               array(
-                                       t3lib_BEfunc::getRecordTitle($table, t3lib_BEfunc::getRecord($table, $id)),
-                                       $table, $id
-                               )
-                       );
-               }
-       }
-
-       /**
-        * Updates the command map accordant to valid structures and takes care of the correct order.
-        *
-        * @param t3lib_utility_Dependency_Element $intersectingElement
-        * @param array $elements
-        * @param string $scope
-        * @return void
-        */
-       protected function update(t3lib_utility_Dependency_Element $intersectingElement, array $elements, $scope) {
-               $orderedCommandMap = array();
-
-               $commonProperties = $this->processCallback(
-                       $this->getScopeData($scope, self::KEY_GetCommonPropertiesCallback),
-                       array($intersectingElement)
-               );
-
-               /** @var $dependentElement t3lib_utility_Dependency_Element */
-               foreach ($elements as $element) {
-                       $table = $element->getTable();
-                       $id = $this->processCallback(
-                               $this->getScopeData($scope, self::KEY_UpdateGetIdCallback),
-                               array($element)
-                       );
-
-                       $this->remove($table, $id, 'version');
-                       $orderedCommandMap[$table][$id]['version'] = array_merge(
-                               $commonProperties,
-                               $this->processCallback(
-                                       $this->getScopeData($scope, self::KEY_GetElementPropertiesCallback),
-                                       array($element)
-                               )
-                       );
-               }
-
-               // Ensure that ordered command map is on top of the command map:
-               $this->mergeToTop($orderedCommandMap);
-       }
-
-       /**
-        * Merges command map elements to the top of the current command map..
-        *
-        * @param array $commandMap
-        * @return void
-        */
-       protected function mergeToTop(array $commandMap) {
-               $this->commandMap = t3lib_div::array_merge_recursive_overrule($commandMap, $this->commandMap);
-       }
-
-       /**
-        * Merges command map elements to the bottom of the current command map.
-        *
-        * @param array $commandMap
-        * @return void
-        */
-       protected function mergeToBottom(array $commandMap) {
-               $this->commandMap = t3lib_div::array_merge_recursive_overrule($this->commandMap, $commandMap);
-       }
-
-       /**
-        * Removes an element from the command map.
-        *
-        * @param string $table
-        * @param string $id
-        * @param string $command (optional)
-        * @return void
-        */
-       protected function remove($table, $id, $command = NULL) {
-               if (is_string($command)) {
-                       unset($this->commandMap[$table][$id][$command]);
-               } else {
-                       unset($this->commandMap[$table][$id]);
-               }
-       }
-
-       /**
-        * Callback to get the liveId of an dependent element.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return integer
-        */
-       protected function getElementLiveIdCallback(t3lib_utility_Dependency_Element $element) {
-               return $element->getDataValue('liveId');
-       }
-
-       /**
-        * Callback to get the real id of an dependent element.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return integer
-        */
-       protected function getElementIdCallback(t3lib_utility_Dependency_Element $element) {
-               return $element->getId();
-       }
-
-       /**
-        * Callback to get the specific properties of a dependent element for swapping/publishing.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return array
-        */
-       protected function getElementSwapPropertiesCallback(t3lib_utility_Dependency_Element $element) {
-               return array(
-                       'swapWith' => $element->getId(),
-               );
-       }
-
-       /**
-        * Callback to get common properties of dependent elements for swapping/publishing.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return array
-        */
-       protected function getCommonSwapPropertiesCallback(t3lib_utility_Dependency_Element $element) {
-               $commonSwapProperties = array();
-
-               $elementProperties = $element->getDataValue('properties');
-               if (isset($elementProperties['action'])) {
-                       $commonSwapProperties['action'] = $elementProperties['action'];
-               }
-               if (isset($elementProperties['swapIntoWS'])) {
-                       $commonSwapProperties['swapIntoWS'] = $elementProperties['swapIntoWS'];
-               }
-
-               return $commonSwapProperties;
-       }
-
-       /**
-        * Callback to get the specific properties of a dependent element for staging.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return array
-        */
-       protected function getElementSetStagePropertiesCallback(t3lib_utility_Dependency_Element $element) {
-               return $this->getCommonSetStagePropertiesCallback($element);
-       }
-
-       /**
-        * Callback to get common properties of dependent elements for staging.
-        *
-        * @param t3lib_utility_Dependency_Element $element
-        * @return array
-        */
-       protected function getCommonSetStagePropertiesCallback(t3lib_utility_Dependency_Element $element) {
-               $commonSetStageProperties = array();
-
-               $elementProperties = $element->getDataValue('properties');
-               if (isset($elementProperties['stageId'])) {
-                       $commonSetStageProperties['stageId'] = $elementProperties['stageId'];
-               }
-               if (isset($elementProperties['comment'])) {
-                       $commonSetStageProperties['comment'] = $elementProperties['comment'];
-               }
-               if (isset($elementProperties['action'])) {
-                       $commonSetStageProperties['action'] = $elementProperties['action'];
-               }
-               if (isset($elementProperties['notificationAlternativeRecipients'])) {
-                       $commonSetStageProperties['notificationAlternativeRecipients'] = $elementProperties['notificationAlternativeRecipients'];
-               }
-
-               return $commonSetStageProperties;
-       }
-
-
-       /**
-        * Gets an instance of the depency resolver utility.
-        *
-        * @return t3lib_utility_Dependency
-        */
-       protected function getDependencyUtility($scope) {
-
-               /** @var $dependency t3lib_utility_Dependency */
-               $dependency = t3lib_div::makeInstance('t3lib_utility_Dependency');
-               $dependency->setOuterMostParentsRequireReferences(TRUE);
-
-               if ($this->getScopeData($scope, self::KEY_ElementConstructCallback)) {
-                       $dependency->setEventCallback(
-                               t3lib_utility_Dependency_Element::EVENT_Construct,
-                               $this->getDependencyCallback($this->getScopeData($scope, self::KEY_ElementConstructCallback))
-                       );
-               }
-               if ($this->getScopeData($scope, self::KEY_ElementCreateChildReferenceCallback)) {
-                       $dependency->setEventCallback(
-                               t3lib_utility_Dependency_Element::EVENT_CreateChildReference,
-                               $this->getDependencyCallback($this->getScopeData($scope, self::KEY_ElementCreateChildReferenceCallback))
-                       );
-               }
-               if ($this->getScopeData($scope, self::KEY_ElementCreateParentReferenceCallback)) {
-                       $dependency->setEventCallback(
-                               t3lib_utility_Dependency_Element::EVENT_CreateParentReference,
-                               $this->getDependencyCallback($this->getScopeData($scope, self::KEY_ElementCreateParentReferenceCallback))
-                       );
-               }
-
-               return $dependency;
-       }
-
-       /**
-        * Callback to determine whether a new child reference shall be considered in the dependency resolver utility.
-        *
-        * @param array $callerArguments
-        * @param array $targetArgument
-        * @param t3lib_utility_Dependency_Element $caller
-        * @param string $eventName
-        * @return string Skip response (if required)
-        */
-       public function createNewDependentElementChildReferenceCallback(array $callerArguments, array $targetArgument, t3lib_utility_Dependency_Element $caller, $eventName) {
-               /** @var $reference t3lib_utility_Dependency_Reference */
-               $reference = $callerArguments['reference'];
-
-               $fieldCOnfiguration = t3lib_BEfunc::getTcaFieldConfiguration($caller->getTable(), $reference->getField());
-
-               if (!$fieldCOnfiguration || !t3lib_div::inList('field,list', $this->getTceMain()->getInlineFieldType($fieldCOnfiguration))) {
-                       return t3lib_utility_Dependency_Element::RESPONSE_Skip;
-               }
-       }
-
-       /**
-        * Callback to determine whether a new parent reference shall be considered in the dependency resolver utility.
-        *
-        * @param array $callerArguments
-        * @param array $targetArgument
-        * @param t3lib_utility_Dependency_Element $caller
-        * @param string $eventName
-        * @return string Skip response (if required)
-        */
-       public function createNewDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, t3lib_utility_Dependency_Element $caller, $eventName) {
-               /** @var $reference t3lib_utility_Dependency_Reference */
-               $reference = $callerArguments['reference'];
-
-               $fieldCOnfiguration = t3lib_BEfunc::getTcaFieldConfiguration($reference->getElement()->getTable(), $reference->getField());
-
-               if (!$fieldCOnfiguration || !t3lib_div::inList('field,list', $this->getTceMain()->getInlineFieldType($fieldCOnfiguration))) {
-                       return t3lib_utility_Dependency_Element::RESPONSE_Skip;
-               }
-       }
-
-       /**
-        * Callback to add additional data to new elements created in the dependency resolver utility.
-        *
-        * @param t3lib_utility_Dependency_Element $caller
-        * @param array $callerArguments
-        * @param array $targetArgument
-        * @return void
-        */
-       public function createNewDependentElementCallback(array $callerArguments, array $targetArgument, t3lib_utility_Dependency_Element $caller) {
-               if ($caller->hasDataValue('liveId') === FALSE) {
-                       $liveId = t3lib_BEfunc::getLiveVersionIdOfRecord($caller->getTable(), $caller->getId());
-                       if (is_null($liveId) === FALSE) {
-                               $caller->setDataValue('liveId', $liveId);
-                       }
-               }
-       }
-
-       /**
-        * Transforms dependent elements to use the liveId as array key.
-        *
-        * @param array $elements Depedent elements, each of type t3lib_utility_Dependency_Element
-        * @return array
-        */
-       protected function transformDependentElementsToUseLiveId(array $elements) {
-               $transformedElements = array();
-
-               /** @var $element t3lib_utility_Dependency_Element */
-               foreach ($elements as $element) {
-                       $elementName = t3lib_utility_Dependency_Element::getIdentifier(
-                               $element->getTable(), $element->getDataValue('liveId')
-                       );
-                       $transformedElements[$elementName] = $element;
-               }
-
-               return $transformedElements;
-       }
-
-       /**
-        * Constructs the scope settings.
-        * Currently the scopes for swapping/publishing and staging are available.
-        *
-        * @return void
-        */
-       protected function constructScopes() {
-               $this->scopes = array(
-                       self::SCOPE_WorkspacesSwap => array(
-                               self::KEY_ScopeErrorMessage => 'Record "%s" (%s:%s) cannot be swapped or published independently, because it is related to other new or modified records.',
-                               self::KEY_ScopeErrorCode => 1288283630,
-                               self::KEY_GetElementPropertiesCallback => 'getElementSwapPropertiesCallback',
-                               self::KEY_GetCommonPropertiesCallback => 'getCommonSwapPropertiesCallback',
-                               self::KEY_ElementConstructCallback => 'createNewDependentElementCallback',
-                               self::KEY_ElementCreateChildReferenceCallback => 'createNewDependentElementChildReferenceCallback',
-                               self::KEY_ElementCreateParentReferenceCallback => 'createNewDependentElementParentReferenceCallback',
-                               self::KEY_PurgeWithErrorMessageGetIdCallback => 'getElementLiveIdCallback',
-                               self::KEY_UpdateGetIdCallback => 'getElementLiveIdCallback',
-                               self::KEY_TransformDependentElementsToUseLiveId => TRUE,
-                       ),
-                       self::SCOPE_WorkspacesSetStage => array(
-                               self::KEY_ScopeErrorMessage => 'Record "%s" (%s:%s) cannot be sent to another stage independently, because it is related to other new or modified records.',
-                               self::KEY_ScopeErrorCode => 1289342524,
-                               self::KEY_GetElementPropertiesCallback => 'getElementSetStagePropertiesCallback',
-                               self::KEY_GetCommonPropertiesCallback => 'getCommonSetStagePropertiesCallback',
-                               self::KEY_ElementConstructCallback => NULL,
-                               self::KEY_ElementCreateChildReferenceCallback => 'createNewDependentElementChildReferenceCallback',
-                               self::KEY_ElementCreateParentReferenceCallback => 'createNewDependentElementParentReferenceCallback',
-                               self::KEY_PurgeWithErrorMessageGetIdCallback => 'getElementIdCallback',
-                               self::KEY_UpdateGetIdCallback => 'getElementIdCallback',
-                               self::KEY_TransformDependentElementsToUseLiveId => FALSE,
-                       ),
-               );
-       }
-
-       /**
-        * Gets data for a particular scope.
-        *
-        * @throws RuntimeException
-        * @param string $scope
-        * @param string $key
-        * @return string
-        */
-       protected function getScopeData($scope, $key) {
-               if (!isset($this->scopes[$scope])) {
-                       throw new RuntimeException('Scope "' . $scope . '" is not defined.', 1289342187);
-               }
-
-               return $this->scopes[$scope][$key];
-       }
-
-       /**
-        * Gets a new callback to be used in the dependency resolver utility.
-        *
-        * @param string $callbackMethod
-        * @param array $targetArguments
-        * @return t3lib_utility_Dependency_Callback
-        */
-       protected function getDependencyCallback($method, array $targetArguments = array()) {
-               return t3lib_div::makeInstance('t3lib_utility_Dependency_Callback', $this, $method, $targetArguments);
-       }
-
-       /**
-        * Processes a local callback inside this object.
-        *
-        * @param string $method
-        * @param array $callbackArguments
-        * @return mixed
-        */
-       protected function processCallback($method, array $callbackArguments) {
-               return call_user_func_array(array($this, $method), $callbackArguments);
-       }
-}
-
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain_commandmap.php'])) {
-       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/version/class.tx_version_tcemain_commandmap.php']);
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/cli/conf.php b/typo3/sysext/version/cli/conf.php
deleted file mode 100644 (file)
index 9bd9650..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-// DO NOT REMOVE OR CHANGE THESE 3 LINES:
-define('TYPO3_MOD_PATH', 'sysext/version/ws/cli/');
-$BACK_PATH = '../../../../';
-$MCONF['name'] = '_CLI_user_ws';
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/cm1/clear.gif b/typo3/sysext/version/cm1/clear.gif
deleted file mode 100755 (executable)
index 9ed1269..0000000
Binary files a/typo3/sysext/version/cm1/clear.gif and /dev/null differ
diff --git a/typo3/sysext/version/cm1/cm_icon.gif b/typo3/sysext/version/cm1/cm_icon.gif
deleted file mode 100755 (executable)
index f253bca..0000000
Binary files a/typo3/sysext/version/cm1/cm_icon.gif and /dev/null differ
diff --git a/typo3/sysext/version/cm1/conf.php b/typo3/sysext/version/cm1/conf.php
deleted file mode 100755 (executable)
index 3795c19..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-       // DO NOT REMOVE OR CHANGE THESE 3 LINES:
-define('TYPO3_MOD_PATH', 'sysext/version/cm1/');
-$BACK_PATH = '../../../';
-$MCONF['name'] = 'web_txversionM1';
-
-$MLANG['default']['tabs_images']['tab'] = 'cm_icon.gif';
-$MLANG['default']['ll_ref'] = 'LLL:EXT:version/locallang.xml';
-
-$MCONF['script'] = 'index.php';
-$MCONF['access'] = 'user,group';
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/cm1/index.php b/typo3/sysext/version/cm1/index.php
deleted file mode 100755 (executable)
index a31e761..0000000
+++ /dev/null
@@ -1,1857 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2004-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  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.
-*
-*  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!
-***************************************************************/
-/**
- * Versioning module
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *  102: class tx_version_cm1 extends t3lib_SCbase
- *
- *              SECTION: Standard module initialization
- *  138:     function menuConfig()
- *  175:     function main()
- *  236:     function jumpToUrl(URL)
- *  296:     function printContent()
- *
- *              SECTION: Versioning management
- *  322:     function versioningMgm()
- *  485:     function pageSubContent($pid,$c=0)
- *  539:     function lookForOwnVersions($table,$uid)
- *  556:     function adminLinks($table,$row)
- *
- *              SECTION: Workspace management
- *  628:     function workspaceMgm()
- *  688:     function displayWorkspaceOverview()
- *  758:     function displayWorkspaceOverview_list($pArray)
- *  923:     function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row)
- *  936:     function displayWorkspaceOverview_allStageCmd()
- *
- *              SECTION: Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
- *  986:     function formatVerId($verId)
- *  996:     function formatWorkspace($wsid)
- * 1023:     function formatCount($count)
- * 1050:     function versionsInOtherWS($table,$uid)
- * 1080:     function showStageChangeLog($table,$id,$stageCommands)
- * 1129:     function subElements($uid,$treeLevel,$origId=0)
- * 1232:     function subElements_getNonPageRecords($tN, $uid, &$recList)
- * 1262:     function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata)
- * 1331:     function markupNewOriginals()
- * 1353:     function createDiffView($table, $diff_1_record, $diff_2_record)
- * 1470:     function displayWorkspaceOverview_stageCmd($table,&$rec_off)
- * 1557:     function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType)
- * 1627:     function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId)
- *
- *              SECTION: Processing
- * 1683:     function publishAction()
- *
- * TOTAL FUNCTIONS: 27
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
-
-
-       // DEFAULT initialization of a module [BEGIN]
-unset($MCONF);
-require ('conf.php');
-require ($BACK_PATH.'init.php');
-require ($BACK_PATH.'template.php');
-$LANG->includeLLFile('EXT:version/locallang.xml');
-       // DEFAULT initialization of a module [END]
-
-require_once('../ws/class.wslib.php');
-
-
-
-/**
- * Versioning module, including workspace management
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage core
- */
-class tx_version_cm1 extends t3lib_SCbase {
-
-               // Default variables for backend modules
-       var $MCONF = array();                           // Module configuration
-       var $MOD_MENU = array();                        // Module menu items
-       var $MOD_SETTINGS = array();            // Module session settings
-
-       /**
-        * document template object
-        *
-        * @var mediumDoc
-        */
-       var $doc;
-       var $content;                                           // Accumulated content
-
-
-               // Internal:
-       var $showWorkspaceCol = 0;
-       var $formatWorkspace_cache = array();
-       var $formatCount_cache = array();
-       var $targets = array();         // Accumulation of online targets.
-       var $pageModule = '';                   // Name of page module
-       var $publishAccess = FALSE;
-       var $be_user_Array = array();
-       var $stageIndex = array();
-       var $recIndex = array();
-       protected $showDraftWorkspace = FALSE; // Determines whether to show the dummy draft workspace
-
-
-
-
-
-
-       /*********************************
-        *
-        * Standard module initialization
-        *
-        *********************************/
-
-       /**
-        * Initialize menu configuration
-        *
-        * @return      void
-        */
-       function menuConfig()   {
-
-                       // fetches the configuration of the version extension
-               $versionExtconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['version']);
-                       // show draft workspace only if enabled in the version extensions config
-               if($versionExtconf['showDraftWorkspace']) {
-                       $this->showDraftWorkspace = TRUE;
-               }
-
-                       // Menu items:
-               $this->MOD_MENU = array(
-                       'filter' => array(
-                               1 => $GLOBALS['LANG']->getLL('filter_drafts'),
-                               2 => $GLOBALS['LANG']->getLL('filter_archive'),
-                               0 => $GLOBALS['LANG']->getLL('filter_all'),
-                       ),
-                       'display' => array(
-                               0 => $GLOBALS['LANG']->getLL('liveWorkspace'),
-                               -98 => $GLOBALS['LANG']->getLL('draftWorkspaces'),
-                               -99 => $GLOBALS['LANG']->getLL('filter_all'),
-                       ),
-                       'diff' => ''
-               );
-
-               if($this->showDraftWorkspace === TRUE) {
-                       $this->MOD_MENU['display'][-1] = $GLOBALS['LANG']->getLL('defaultDraft');
-               }
-
-                       // Add workspaces (only if the live workspace is currently active):
-               if (t3lib_extMgm::isLoaded('workspaces') && $GLOBALS['BE_USER']->workspace ===0 ) {
-                       $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
-                       foreach($workspaces as $rec)    {
-                               if ($GLOBALS['BE_USER']->checkWorkspace($rec))  {
-                                       $this->MOD_MENU['display'][$rec['uid']] = '['.$rec['uid'].'] '.$rec['title'];
-                               }
-                       }
-               }
-
-                       // CLEANSE SETTINGS
-               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
-       }
-
-       /**
-        * Main function of the module. Write the content to $this->content
-        *
-        * @return      void
-        */
-       function main() {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
-
-                       // Template markers
-               $markers = array(
-                       'CSH' => '',
-                       'FUNC_MENU' => '',
-                       'WS_MENU' => '',
-                       'CONTENT' => ''
-               );
-
-                       // Setting module configuration:
-               $this->MCONF = $GLOBALS['MCONF'];
-
-               $this->REQUEST_URI = str_replace('&sendToReview=1','',t3lib_div::getIndpEnv('REQUEST_URI'));
-
-                       // Draw the header.
-               $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->backPath = $BACK_PATH;
-               $this->doc->setModuleTemplate('templates/version.html');
-
-               // Add styles
-               $this->doc->inDocStylesArray[$GLOBALS['MCONF']['name']] = '
-.version-diff-1 { background-color: green; }
-.version-diff-2 { background-color: red; }
-';
-
-                       // Setting up the context sensitive menu:
-               $this->doc->getContextMenuCode();
-
-                       // Getting input data:
-               $this->id = intval(t3lib_div::_GP('id'));               // Page id. If set, indicates activation from Web>Versioning module
-               if (!$this->id) {
-                       $this->uid = intval(t3lib_div::_GP('uid'));             // Record uid. Goes with table name to indicate specific record
-                       $this->table = t3lib_div::_GP('table');                 // Record table. Goes with uid to indicate specific record
-               } else {
-                       $this->uid = $this->id;
-                       $this->table = 'pages';
-               }
-               $this->details = t3lib_div::_GP('details');             // Page id. If set, indicates activation from Web>Versioning module
-               $this->diffOnly = t3lib_div::_GP('diffOnly');           // Flag. If set, shows only the offline version and with diff-view
-
-                       // Force this setting:
-               $this->MOD_SETTINGS['expandSubElements'] = TRUE;
-               $this->MOD_SETTINGS['diff'] = $this->details || $this->MOD_SETTINGS['diff']?1:0;
-
-                       // Reading the record:
-               $record = t3lib_BEfunc::getRecord($this->table,$this->uid);
-               if ($record['pid']==-1) {
-                       $record = t3lib_BEfunc::getRecord($this->table,$record['t3ver_oid']);
-               }
-
-               $this->recordFound = is_array($record);
-
-               $pidValue = $this->table==='pages' ? $this->uid : $record['pid'];
-
-                       // Checking access etc.
-               if ($this->recordFound && $TCA[$this->table]['ctrl']['versioningWS'])   {
-                       $this->doc->form='<form action="" method="post">';
-                       $this->uid = $record['uid'];    // Might have changed if new live record was found!
-
-                               // Access check!
-                               // The page will show only if there is a valid page and if this page may be viewed by the user
-                       $this->pageinfo = t3lib_BEfunc::readPageAccess($pidValue,$this->perms_clause);
-                       $access = is_array($this->pageinfo) ? 1 : 0;
-
-                       if (($pidValue && $access) || ($BE_USER->user['admin'] && !$pidValue))  {
-
-                                       // JavaScript
-                               $this->doc->JScode.= '
-                                       <script language="javascript" type="text/javascript">
-                                               script_ended = 0;
-                                               function jumpToUrl(URL) {
-                                                       window.location.href = URL;
-                                               }
-
-                                               function hlSubelements(origId, verId, over, diffLayer)  {       //
-                                                       if (over)       {
-                                                               document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
-                                                               document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver-hl\';
-                                                               if (diffLayer)  {
-                                                                       document.getElementById(\'diff_\'+verId).style.visibility = \'visible\';
-                                                               }
-                                                       } else {
-                                                               document.getElementById(\'orig_\'+origId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
-                                                               document.getElementById(\'ver_\'+verId).attributes.getNamedItem("class").nodeValue = \'typo3-ver\';
-                                                               if (diffLayer)  {
-                                                                       document.getElementById(\'diff_\'+verId).style.visibility = \'hidden\';
-                                                               }
-                                                       }
-                                               }
-                                       </script>
-                               ';
-
-                                       // If another page module was specified, replace the default Page module with the new one
-                               $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
-                               $this->pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
-
-                                       // Setting publish access permission for workspace:
-                               $this->publishAccess = $BE_USER->workspacePublishAccess($BE_USER->workspace);
-
-                                       // Render content:
-                               if ($this->id)  {
-                                       $this->workspaceMgm();
-                               } else {
-                                       $this->versioningMgm();
-                               }
-                       }
-
-                       $this->content.=$this->doc->spacer(10);
-
-                               // Setting up the buttons and markers for docheader
-                       $docHeaderButtons = $this->getButtons();
-                       $markers['CSH'] = $docHeaderButtons['csh'];
-                       $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
-                       $markers['WS_MENU'] = $this->workspaceMenu();
-                       $markers['CONTENT'] = $this->content;
-               } else {
-                               // If no access or id value, create empty document
-                       $this->content = $this->doc->section($LANG->getLL('clickAPage_header'), $LANG->getLL('clickAPage_content'), 0, 1);
-
-                               // Setting up the buttons and markers for docheader
-                       $docHeaderButtons = $this->getButtons();
-                       $markers['CONTENT'] = $this->content;
-               }
-                       // Build the <body> for the module
-               $this->content = $this->doc->startPage($LANG->getLL('title'));
-               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
-               $this->content.= $this->doc->endPage();
-               $this->content = $this->doc->insertStylesAndJS($this->content);
-       }
-
-       /**
-        * Outputs accumulated module content to browser.
-        *
-        * @return      void
-        */
-       function printContent() {
-               echo $this->content;
-       }
-
-       /**
-        * Create the panel of buttons for submitting the form or otherwise perform operations.
-        *
-        * @return      array   all available buttons as an assoc. array
-        */
-       protected function getButtons() {
-               global $TCA, $LANG, $BACK_PATH, $BE_USER;
-
-               $buttons = array(
-                       'csh' => '',
-                       'view' => '',
-                       'record_list' => '',
-                       'shortcut' => '',
-               );
-                       // CSH
-               //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_txversionM1', '', $GLOBALS['BACK_PATH']);
-
-               if ($this->recordFound && $TCA[$this->table]['ctrl']['versioningWS']) {
-                               // View page
-                       $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
-                                               t3lib_iconWorks::getSpriteIcon('actions-document-view') .
-                                       '</a>';
-
-                               // Shortcut
-                       if ($BE_USER->mayMakeShortcut())        {
-                               $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
-                       }
-
-                               // If access to Web>List for user, then link to that module.
-                       $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
-                               array(
-                                       'id' => $this->pageinfo['uid'],
-                                       'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
-                               ),
-                               '',
-                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
-                       );
-               }
-               return $buttons;
-       }
-
-
-
-
-
-
-
-
-       /******************************
-        *
-        * Versioning management
-        *
-        ******************************/
-
-       /**
-        * Management of versions for record
-        *
-        * @return      void
-        */
-       function versioningMgm()        {
-               global $TCA;
-
-                       // Diffing:
-               $diff_1 = t3lib_div::_POST('diff_1');
-               $diff_2 = t3lib_div::_POST('diff_2');
-               if (t3lib_div::_POST('do_diff'))        {
-                       $content='';
-                       $content.='<h3>' . $GLOBALS['LANG']->getLL('diffing') . ':</h3>';
-                       if ($diff_1 && $diff_2) {
-                               $diff_1_record = t3lib_BEfunc::getRecord($this->table, $diff_1);
-                               $diff_2_record = t3lib_BEfunc::getRecord($this->table, $diff_2);
-
-                               if (is_array($diff_1_record) && is_array($diff_2_record))       {
-                                       t3lib_div::loadTCA($this->table);
-                                       $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
-
-                                       $tRows=array();
-                                                               $tRows[] = '
-                                                                       <tr class="bgColor5 tableheader">
-                                                                               <td>' . $GLOBALS['LANG']->getLL('fieldname') . '</td>
-                                                                               <td width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</td>
-                                                                       </tr>
-                                                               ';
-                                       foreach($diff_1_record as $fN => $fV)   {
-                                               if ($TCA[$this->table]['columns'][$fN] && $TCA[$this->table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN)) {
-                                                       if (strcmp($diff_1_record[$fN],$diff_2_record[$fN]))    {
-
-                                                               $diffres = $t3lib_diff_Obj->makeDiffDisplay(
-                                                                       t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_2_record[$fN],0,1),
-                                                                       t3lib_BEfunc::getProcessedValue($this->table,$fN,$diff_1_record[$fN],0,1)
-                                                               );
-
-                                                               $tRows[] = '
-                                                                       <tr class="bgColor4">
-                                                                               <td>'.$fN.'</td>
-                                                                               <td width="98%">'.$diffres.'</td>
-                                                                       </tr>
-                                                               ';
-                                                       }
-                                               }
-                                       }
-
-                                       if (count($tRows)>1)    {
-                                               $content .= '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . implode('', $tRows) . '</table><br /><br />';
-                                       } else {
-                                               $content .= $GLOBALS['LANG']->getLL('recordsMatchesCompletely');
-                                       }
-                               } else $content .= $GLOBALS['LANG']->getLL('errorRecordsNotFound');
-                       } else {
-                               $content .= $GLOBALS['LANG']->getLL('errorDiffSources');
-                       }
-               }
-
-                       // Element:
-               $record = t3lib_BEfunc::getRecord($this->table,$this->uid);
-               $recordIcon = t3lib_iconWorks::getSpriteIconForRecord($this->table, $record);
-               $recTitle = t3lib_BEfunc::getRecordTitle($this->table,$record,TRUE);
-
-                       // Display versions:
-               $content.='
-                       '.$recordIcon.$recTitle.'
-                       <form name="theform" action="'.str_replace('&sendToReview=1','',$this->REQUEST_URI).'" method="post">
-                       <table border="0" cellspacing="1" cellpadding="1">';
-                       $content.='
-                               <tr class="bgColor5 tableheader">
-                                       <td>&nbsp;</td>
-                                       <td>&nbsp;</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_title') . '">' . $GLOBALS['LANG']->getLL('tblHeader_title') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_uid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_uid') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_oid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_oid') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_id') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_id') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_wsid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_wsid') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_state') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_state') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_stage') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_stage') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_count') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_count') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_pid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_pid') . '</td>
-                                       <td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_label') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</td>
-                                       <td colspan="2"><input type="submit" name="do_diff" value="' . $GLOBALS['LANG']->getLL('diff') . '" /></td>
-                               </tr>';
-
-               $versions = t3lib_BEfunc::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
-               foreach($versions as $row)      {
-                       $adminLinks = $this->adminLinks($this->table,$row);
-
-                       $content.='
-                               <tr class="' . ($row['uid'] != $this->uid ? 'bgColor4' : 'bgColor2 tableheader') . '">
-                                       <td>'.($row['uid']!=$this->uid ? '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][action]=swap').'" title="' . $GLOBALS['LANG']->getLL('swapWithCurrent', TRUE) . '">'.
-                                               t3lib_iconWorks::getSpriteIcon('actions-version-swap-version') .
-                                               '</a>' /* (
-                                                       $this->table == 'pages' ?
-                                                       '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][action]=swap&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][swapContent]=1').'">'.
-                                               '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert2.gif','width="14" height="14"').' alt="" title="Publish page AND content!" />'.
-                                               '</a>'.
-                                                       '<a href="'.$this->doc->issueCommand('&cmd['.$this->table.']['.$this->uid.'][version][action]=swap&cmd['.$this->table.']['.$this->uid.'][version][swapWith]='.$row['uid'].'&cmd['.$this->table.']['.$this->uid.'][version][swapContent]=ALL').'">'.
-                                               '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert4.gif','width="14" height="14"').' alt="" title="Publish page AND content! - AND ALL SUBPAGES!" />'.
-                                               '</a>' : '') */ : t3lib_iconWorks::getSpriteIcon('status-status-current', array('title' =>  $GLOBALS['LANG']->getLL('currentOnlineVersion', TRUE)))) . '</td>
-                                       <td nowrap="nowrap">'.$adminLinks.'</td>
-                                       <td nowrap="nowrap">'.t3lib_BEfunc::getRecordTitle($this->table,$row,TRUE).'</td>
-                                       <td>'.$row['uid'].'</td>
-                                       <td>'.$row['t3ver_oid'].'</td>
-                                       <td>'.$row['t3ver_id'].'</td>
-                                       <td>'.$row['t3ver_wsid'].'</td>
-                                       <td>'.$row['t3ver_state'].'</td>
-                                       <td>'.$row['t3ver_stage'].'</td>
-                                       <td>'.$row['t3ver_count'].'</td>
-                                       <td>'.$row['pid'].'</td>
-                                       <td nowrap="nowrap"><a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$this->table.']['.$row['uid'].']=edit&columnsOnly=t3ver_label',$this->doc->backPath)).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.edit', TRUE) . '">' .
-                                                       t3lib_iconWorks::getSpriteIcon('actions-document-open') .
-                                               '</a>' . htmlspecialchars($row['t3ver_label']) . '</td>
-                                       <td class="version-diff-1"><input type="radio" name="diff_1" value="'.$row['uid'].'"'.($diff_1==$row['uid'] ? ' checked="checked"':'').'/></td>
-                                       <td class="version-diff-2"><input type="radio" name="diff_2" value="'.$row['uid'].'"'.($diff_2==$row['uid'] ? ' checked="checked"':'').'/></td>
-                               </tr>';
-
-                               // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
-                       if ($this->table == 'pages' && $row['uid']!=$this->uid) {
-                               $sub = $this->pageSubContent($row['uid']);
-
-                               if ($sub)       {
-                                       $content.='
-                                               <tr>
-                                                       <td></td>
-                                                       <td></td>
-                                                       <td colspan="10">'.$sub.'</td>
-                                                       <td colspan="2"></td>
-                                               </tr>';
-                               }
-                       }
-               }
-               $content.='</table></form>';
-
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
-
-
-                       // Create new:
-               $content='
-
-                       <form action="'.$this->doc->backPath.'tce_db.php" method="post">
-                       ' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . ': <input type="text" name="cmd[' . $this->table . '][' . $this->uid . '][version][label]" /><br />
-                       '.(($this->table == 'pages' && $GLOBALS['TYPO3_CONF_VARS']['BE']['elementVersioningOnly'] == FALSE)? '<select name="cmd['.$this->table.']['.$this->uid.'][version][treeLevels]">
-                               '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0) ? '<option value="0">' . $GLOBALS['LANG']->getLL('cmdPid0') . '</option>' : '').'
-                               '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(1) ? '<option value="100">' . $GLOBALS['LANG']->getLL('cmdPid100') . '</option>' : '').'
-                               '.($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(-1) ? '<option value="-1">' . $GLOBALS['LANG']->getLL('cmdPid1') . '</option>' : '').'
-                       </select>' : '').'
-                       <br /><input type="hidden" name="cmd[' . $this->table . '][' . $this->uid . '][version][action]" value="new" />
-                       <input type="hidden" name="prErr" value="1" />
-                       <input type="hidden" name="redirect" value="'.htmlspecialchars($this->REQUEST_URI).'" />
-                       <input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('createNewVersion') . '" />
-                       ' . t3lib_TCEforms::getHiddenTokenField('tceAction') . '
-                       </form>
-
-               ';
-
-               $this->content.=$this->doc->spacer(15);
-               $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('createNewVersion'), $content,0,1);
-
-       }
-
-       /**
-        * Recursively look for children for page version with $pid
-        *
-        * @param       integer         UID of page record for which to look up sub-elements following that version
-        * @param       integer         Counter, do not set (limits to 100 levels)
-        * @return      string          Table with content if any
-        */
-       function pageSubContent($pid,$c=0)      {
-               global $TCA;
-
-               $tableNames = t3lib_div::removeArrayEntryByValue(array_keys($TCA),'pages');
-               $tableNames[] = 'pages';
-
-               foreach($tableNames as $tN)     {
-                               // Basically list ALL tables - not only those being copied might be found!
-                       #if ($TCA[$tN]['ctrl']['versioning_followPages'] || $tN=='pages')       {
-                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $tN, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($tN), '', ($TCA[$tN]['ctrl']['sortby'] ? $TCA[$tN]['ctrl']['sortby'] : ''));
-
-                               if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres))  {
-                                       $content.='
-                                               <tr>
-                                                       <td colspan="4" class="'.($TCA[$tN]['ctrl']['versioning_followPages'] ? 'bgColor6' : ($tN=='pages' ? 'bgColor5' : 'bgColor-10')).'"'.(!$TCA[$tN]['ctrl']['versioning_followPages'] && $tN!='pages' ? ' style="color: #666666; font-style:italic;"':'').'>'.$tN.'</td>
-                                               </tr>';
-                                       while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))  {
-                                               $ownVer = $this->lookForOwnVersions($tN,$subrow['uid']);
-                                               $content.='
-                                                       <tr>
-                                                               <td>'.$this->adminLinks($tN,$subrow).'</td>
-                                                               <td>'.$subrow['uid'].'</td>
-                                                               '.($ownVer>1 ? '<td style="font-weight: bold; background-color: yellow;"><a href="index.php?table='.rawurlencode($tN).'&uid='.$subrow['uid'].'">'.($ownVer-1).'</a></td>' : '<td></td>').'
-                                                               <td width="98%">'.t3lib_BEfunc::getRecordTitle($tN,$subrow,TRUE).'</td>
-                                                       </tr>';
-
-                                               if ($tN == 'pages' && $c<100)   {
-                                                       $sub = $this->pageSubContent($subrow['uid'],$c+1);
-
-                                                       if ($sub)       {
-                                                               $content.='
-                                                                       <tr>
-                                                                               <td></td>
-                                                                               <td></td>
-                                                                               <td></td>
-                                                                               <td width="98%">'.$sub.'</td>
-                                                                       </tr>';
-                                                       }
-                                               }
-                                       }
-                               }
-                       #}
-               }
-
-               return $content ? '<table border="1" cellpadding="1" cellspacing="0" width="100%">'.$content.'</table>' : '';
-       }
-
-       /**
-        * Look for number of versions of a record
-        *
-        * @param       string          Table name
-        * @param       integer         Record uid
-        * @return      integer         Number of versions for record, false if none.
-        */
-       function lookForOwnVersions($table,$uid)        {
-               global $TCA;
-
-               $versions = t3lib_BEfunc::selectVersionsOfRecord($table, $uid, 'uid');
-               if (is_array($versions))        {
-                       return count($versions);
-               }
-               return FALSE;
-       }
-
-       /**
-        * Administrative links for a table / record
-        *
-        * @param       string          Table name
-        * @param       array           Record for which administrative links are generated.
-        * @return      string          HTML link tags.
-        */
-       function adminLinks($table,$row)        {
-               global $BE_USER;
-
-                       // Edit link:
-               $adminLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$table.']['.$row['uid'].']=edit',$this->doc->backPath)).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.edit', TRUE) . '">'.
-                                                       t3lib_iconWorks::getSpriteIcon('actions-document-open') .
-                                               '</a>';
-
-                       // Delete link:
-               $adminLink.= '<a href="'.htmlspecialchars($this->doc->issueCommand('&cmd['.$table.']['.$row['uid'].'][delete]=1')).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.delete', TRUE) . '">' .
-                                                       t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
-                                               '</a>';
-
-
-
-               if ($table == 'pages')  {
-
-                               // If another page module was specified, replace the default Page module with the new one
-                       $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
-                       $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
-
-                               // Perform some acccess checks:
-                       $a_wl = $BE_USER->check('modules','web_list');
-                       $a_wp = t3lib_extMgm::isLoaded('cms') && $BE_USER->check('modules',$pageModule);
-
-                       $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\''.$pageModule.'\'); return false;">'.
-                                                       t3lib_iconWorks::getSpriteIcon('actions-page-open') .
-                                               '</a>';
-                       $adminLink.='<a href="#" onclick="top.loadEditId('.$row['uid'].');top.goToModule(\'web_list\'); return false;">'.
-                                                       t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
-                                               '</a>';
-
-                               // "View page" icon is added:
-                       $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($row['uid'],$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($row['uid']))).'">'.
-                                       t3lib_iconWorks::getSpriteIcon('actions-document-view') .
-                               '</a>';
-               } else {
-                       if ($row['pid']==-1)    {
-                               $getVars = '&ADMCMD_vPrev['.rawurlencode($table.':'.$row['t3ver_oid']).']='.$row['uid'];
-
-                                       // "View page" icon is added:
-                               $adminLink.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($row['_REAL_PID'],$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($row['_REAL_PID']),'','',$getVars)).'">'.
-                                               t3lib_iconWorks::getSpriteIcon('actions-document-view') .
-                                       '</a>';
-                       }
-               }
-
-               return $adminLink;
-       }
-
-
-
-
-
-
-
-
-
-
-
-       /******************************
-        *
-        * Workspace management
-        *
-        ******************************/
-
-       /**
-        * Management of workspace for page ID
-        * Called when $this->id is set.
-        *
-        * @return      void
-        */
-       function workspaceMgm() {
-
-                       // Perform workspace publishing action if buttons are pressed:
-               $errors = $this->publishAction();
-
-                       // Generate workspace overview:
-               $WSoverview = $this->displayWorkspaceOverview();
-
-                       // Buttons for publish / swap:
-               $actionLinks = '<br />';
-               if ($GLOBALS['BE_USER']->workspace!==0) {
-                       if ($this->publishAccess)       {
-                               $actionLinks.= '<input type="submit" name="_publish" value="' . $GLOBALS['LANG']->getLL('publishPage') . '" onclick="return confirm(\'' . sprintf($GLOBALS['LANG']->getLL('publishPageQuestion'), $GLOBALS['BE_USER']->workspaceRec['publish_access'] & 1 ? $GLOBALS['LANG']->getLL('publishPageQuestionStage') : '') . '\');"/>';
-                               if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
-                                       $actionLinks.= '<input type="submit" name="_swap" value="' . $GLOBALS['LANG']->getLL('swapPage') . '" onclick="return confirm(\'' . sprintf($GLOBALS['LANG']->getLL('swapPageQuestion'), $GLOBALS['BE_USER']->workspaceRec['publish_access'] & 1 ? $GLOBALS['LANG']->getLL('publishPageQuestionStage') : '') . '\');" />';
-                               }
-                       } else {
-                               $actionLinks.= $this->doc->icons(1) . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:no_publish_permission');
-                       }
-               }
-
-               $actionLinks.= '<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('refresh') . '" />';
-               $actionLinks.= '<input type="submit" name="_previewLink" value="' . $GLOBALS['LANG']->getLL('previewLink') . '" />';
-               $actionLinks.= '<input type="checkbox" class="checkbox" name="_previewLink_wholeWorkspace" id="_previewLink_wholeWorkspace" value="1" /><label for="_previewLink_wholeWorkspace">' . $GLOBALS['LANG']->getLL('allowPreviewOfWholeWorkspace') . '</label>';
-               $actionLinks.= $this->displayWorkspaceOverview_allStageCmd();
-
-               if ($actionLinks || count($errors))     {
-                       $this->content .= $this->doc->section('', $actionLinks . (count($errors) ? '<h3>' . $GLOABLS['LANG']->getLL('errors') . '</h3><br />' . implode('<br />', $errors) . '<hr />' : ''), 0, 1);
-               }
-
-               if (t3lib_div::_POST('_previewLink'))   {
-                       $ttlHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours'));
-                       $ttlHours = ($ttlHours ? $ttlHours : 24*2);
-
-                       if (t3lib_div::_POST('_previewLink_wholeWorkspace'))    {
-                               $previewUrl = t3lib_BEfunc::getViewDomain($this->id) . '/index.php?ADMCMD_prev=' . t3lib_BEfunc::compilePreviewKeyword('', $GLOBALS['BE_USER']->user['uid'], 60*60*$ttlHours, $GLOBALS['BE_USER']->workspace) . '&id=' . intval($this->id);
-                       } else {
-                               $params = 'id='.$this->id.'&ADMCMD_previewWS='.$GLOBALS['BE_USER']->workspace;
-                               $previewUrl = t3lib_BEfunc::getViewDomain($this->id) . '/index.php?ADMCMD_prev=' . t3lib_BEfunc::compilePreviewKeyword($params, $GLOBALS['BE_USER']->user['uid'], 60*60*$ttlHours);
-                       }
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('previewUrl'), sprintf($GLOBALS['LANG']->getLL('previewInstruction'), $ttlHours) . '<br /><br /><a target="_blank" href="' . htmlspecialchars($previewUrl) . '">' . $previewUrl . '</a>', 0, 1);
-               }
-
-                       // Output overview content:
-               $this->content.= $this->doc->spacer(15);
-               $this->content.= $this->doc->section($this->details ? $GLOBALS['LANG']->getLL('versionDetails') : $GLOBALS['LANG']->getLL('wsManagement'), $WSoverview,0,1);
-
-       }
-
-       function workspaceMenu() {
-               if($this->id) {
-                       $menu = '';
-                       if ($GLOBALS['BE_USER']->workspace===0) {
-                               $menu.= t3lib_BEfunc::getFuncMenu($this->id,'SET[filter]',$this->MOD_SETTINGS['filter'],$this->MOD_MENU['filter']);
-                               $menu.= t3lib_BEfunc::getFuncMenu($this->id,'SET[display]',$this->MOD_SETTINGS['display'],$this->MOD_MENU['display']);
-                       }
-                       if (!$this->details && $GLOBALS['BE_USER']->workspace && !$this->diffOnly)      {
-                               $menu.= t3lib_BEfunc::getFuncCheck($this->id,'SET[diff]',$this->MOD_SETTINGS['diff'],'','','id="checkDiff"').' <label for="checkDiff">' . $GLOBALS['LANG']->getLL('showDiffView') . '</label>';
-                       }
-
-                       if ($menu)      {
-                               return $menu;
-                       }
-               }
-       }
-
-       /**
-        * Rendering the overview of versions in the current workspace
-        *
-        * @return      string          HTML (table)
-        * @see ws/index.php for sister function!
-        */
-       function displayWorkspaceOverview()     {
-
-                       // Initialize variables:
-               $this->showWorkspaceCol = $GLOBALS['BE_USER']->workspace===0 && $this->MOD_SETTINGS['display']<=-98;
-
-                       // Get usernames and groupnames
-               $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
-               $groupArray = array_keys($be_group_Array);
-               $this->be_user_Array = t3lib_BEfunc::getUserNames();
-               if (!$GLOBALS['BE_USER']->isAdmin())            $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,$groupArray,1);
-
-                       // Initialize Workspace ID and filter-value:
-               if ($GLOBALS['BE_USER']->workspace===0) {
-                       $wsid = $this->details ? -99 : $this->MOD_SETTINGS['display'];          // Set wsid to the value from the menu (displaying content of other workspaces)
-                       $filter = $this->details ? 0 : $this->MOD_SETTINGS['filter'];
-               } else {
-                       $wsid = $GLOBALS['BE_USER']->workspace;
-                       $filter = 0;
-               }
-
-                       // Initialize workspace object and request all pending versions:
-               $wslibObj = t3lib_div::makeInstance('wslib');
-
-                       // Selecting ALL versions belonging to the workspace:
-               $versions = $wslibObj->selectVersionsInWorkspace($wsid, $filter, -99, $this->uid);      // $this->uid is the page id of LIVE record.
-
-                       // Traverse versions and build page-display array:
-               $pArray = array();
-               foreach($versions as $table => $records)        {
-                       foreach($records as $rec)       {
-                               $pageIdField = $table==='pages' ? 't3ver_oid' : 'realpid';
-                               $this->displayWorkspaceOverview_setInPageArray(
-                                       $pArray,
-                                       $table,
-                                       $rec
-                               );
-                       }
-               }
-
-                       // Make header of overview:
-               $tableRows = array();
-               if (count($pArray))     {
-                       $tableRows[] = '
-                               <tr class="bgColor5 tableheader">
-                                       '.($this->diffOnly?'':'<td nowrap="nowrap" colspan="2">' . $GLOBALS['LANG']->getLL('liveVersion') . '</td>').'
-                                       <td nowrap="nowrap" colspan="2">' . $GLOBALS['LANG']->getLL('wsVersions') . '</td>
-                                       <td nowrap="nowrap"'.($this->diffOnly?' colspan="2"':' colspan="4"').'>' . $GLOBALS['LANG']->getLL('controls') . '</td>
-                               </tr>';
-
-                               // Add lines from overview:
-                       $tableRows = array_merge($tableRows, $this->displayWorkspaceOverview_list($pArray));
-
-                       $table = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding workspace-overview">'.implode('',$tableRows).'</table>';
-               } else $table = '';
-
-               $returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
-               $linkBack = t3lib_div::_GP('returnUrl') ? '<a href="' . htmlspecialchars($returnUrl) . '" class="typo3-goBack">' .
-                               t3lib_iconWorks::getSpriteIcon('actions-view-go-back') . $GLOBALS['LANG']->getLL('goBack', TRUE) .
-                       '</a><br /><br />' : '';
-               $resetDiffOnly = $this->diffOnly ? '<a href="index.php?id=' . intval($this->id) . '" class="typo3-goBack">' . $GLOBALS['LANG']->getLL('showAllInformation') . '</a><br /><br />' : '';
-
-               $versionSelector = $GLOBALS['BE_USER']->workspace ? $this->doc->getVersionSelector($this->id) : '';
-
-               return $versionSelector.$linkBack.$resetDiffOnly.$table.$this->markupNewOriginals();
-       }
-
-       /**
-        * Rendering the content for the publish / review overview:
-        * (Made for internal recursive calling)
-        *
-        * @param       array           Storage of the elements to display (see displayWorkspaceOverview() / displayWorkspaceOverview_setInPageArray())
-        * @return      array           Table rows, see displayWorkspaceOverview()
-        */
-       function displayWorkspaceOverview_list($pArray) {
-               global $TCA;
-
-                       // If there ARE elements on this level, print them:
-               $warnAboutVersions_nonPages = FALSE;
-               $warnAboutVersions_page = FALSE;
-               if (is_array($pArray))  {
-                       foreach($pArray as $table => $oidArray) {
-                               foreach($oidArray as $oid => $recs)     {
-
-                                               // Get CURRENT online record and icon based on "t3ver_oid":
-                                       $rec_on = t3lib_BEfunc::getRecord($table,$oid);
-                                       $icon = t3lib_iconWorks::getSpriteIconForRecord($table, $rec_on, array('title' => t3lib_BEfunc::getRecordIconAltText($rec_on,$table)));
-                                       if ($GLOBALS['BE_USER']->workspace===0) {       // Only edit online records if in ONLINE workspace:
-                                               $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $rec_on['uid'], 1, '', '+edit,view,info,delete');
-                                       }
-
-                                               // Online version display:
-                                               // Create the main cells which will span over the number of versions there is.
-                                       $verLinkUrl = $TCA[$table]['ctrl']['versioningWS'];
-                                       $origElement = $icon.
-                                               ($verLinkUrl ? '<a href="'.htmlspecialchars('index.php?table='.$table.'&uid='.$rec_on['uid']).'">' : '').
-                                               t3lib_BEfunc::getRecordTitle($table,$rec_on,TRUE).
-                                               ($verLinkUrl ? '</a>' : '');
-                                       $mainCell_rowSpan = count($recs)>1 ? ' rowspan="'.count($recs).'"' : '';
-                                       $mainCell = '
-                                                               <td align="center"'.$mainCell_rowSpan.'>'.$this->formatVerId($rec_on['t3ver_id']).'</td>
-                                                               <td nowrap="nowrap"'.$mainCell_rowSpan.'>'.
-                                                                       $origElement.
-                                                                       '###SUB_ELEMENTS###'.   // For substitution with sub-elements, if any.
-                                                               '</td>';
-
-                                               // Offline versions display:
-                                               // Traverse the versions of the element
-                                       foreach($recs as $rec)  {
-
-                                                       // Get the offline version record and icon:
-                                               $rec_off = t3lib_BEfunc::getRecord($table,$rec['uid']);
-
-                                               // Prepare swap-mode values:
-                                               if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
-                                                       if ($rec_off['t3ver_swapmode']>0)       {
-                                                               $vType = 'branch';
-                                                       } else {
-                                                               $vType = 'page';
-                                                       }
-                                               } else {
-                                                       $vType = 'element';
-                                               }
-
-                                               // Get icon
-                                               $icon = t3lib_iconWorks::getSpriteIconForRecord($table, $rec_off, array('title' => t3lib_BEfunc::getRecordIconAltText($rec_off, $table)));
-                                               $tempUid = ($table != 'pages' || $vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']);
-                                               $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $tempUid, 1, '', '+edit,' . ($table == 'pages' ? 'view,info,' : '') . 'delete');
-
-                                                       // Prepare diff-code:
-                                               if ($this->MOD_SETTINGS['diff'] || $this->diffOnly)     {
-                                                       $diffCode = '';
-                                                       list($diffHTML,$diffPct) = $this->createDiffView($table, $rec_off, $rec_on);
-                                                       if ($rec_on['t3ver_state']==1)  {       // New record:
-                                                               $diffCode.= $this->doc->icons(1) . $GLOBALS['LANG']->getLL('newElement') . '<br />';
-                                                               $diffCode.= $diffHTML;
-                                                       } elseif ($rec_off['t3ver_state']==2)   {
-                                                               $diffCode.= $this->doc->icons(2) . $GLOBALS['LANG']->getLL('deletedElement') . '<br />';
-                                                       } elseif ($rec_on['t3ver_state']==3)    {
-                                                               $diffCode.= $this->doc->icons(1) . $GLOBALS['LANG']->getLL('moveToPlaceholder') . '<br />';
-                                                       } elseif ($rec_off['t3ver_state']==4)   {
-                                                               $diffCode.= $this->doc->icons(1) . $GLOBALS['LANG']->getLL('moveToPointer') . '<br />';
-                                                       } else {
-                                                               $diffCode.= ($diffPct<0 ? $GLOBALS['LANG']->getLL('notAvailable') : ($diffPct ? $diffPct . '% ' . $GLOBALS['LANG']->getLL('change') : ''));
-                                                               $diffCode.= $diffHTML;
-                                                       }
-                                               } else $diffCode = '';
-
-                                               switch($vType) {
-                                                       case 'element':
-                                                               $swapLabel = $GLOBALS['LANG']->getLL('element');
-                                                               $swapClass = 'ver-element';
-                                                               $warnAboutVersions_nonPages = $warnAboutVersions_page;  // Setting this if sub elements are found with a page+content (must be rendered prior to this of course!)
-                                                       break;
-                                                       case 'page':
-                                                               $swapLabel = $GLOBALS['LANG']->getLL('page');
-                                                               $swapClass = 'ver-page';
-                                                               $warnAboutVersions_page = !$this->showWorkspaceCol;             // This value is true only if multiple workspaces are shown and we need the opposite here.
-                                                       break;
-                                                       case 'branch':
-                                                               $swapLabel = $GLOBALS['LANG']->getLL('branch');
-                                                               $swapClass = 'ver-branch';
-                                                       break;
-                                               }
-
-                                                       // Modify main cell based on first version shown:
-                                               $subElements = array();
-                                               if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1 && $mainCell)    {       // For "Page" and "Branch" swap modes where $mainCell is still carrying content (only first version)
-                                                       $subElements['on'] = $this->subElements($rec_on['uid'], $rec_off['t3ver_swapmode']);
-                                                       $subElements['off'] = $this->subElements($rec_off['uid'],$rec_off['t3ver_swapmode'],$rec_on['uid']);
-                                               }
-                                               $mainCell = str_replace('###SUB_ELEMENTS###', $subElements['on'], $mainCell);
-
-                                                       // Create version element:
-                                               $versionsInOtherWS = $this->versionsInOtherWS($table, $rec_on['uid']);
-                                               $versionsInOtherWSWarning = $versionsInOtherWS && $GLOBALS['BE_USER']->workspace !== 0 ? '<br />' . $this->doc->icons(2) . $GLOBALS['LANG']->getLL('otherVersions') . $versionsInOtherWS : '';
-                                               $multipleWarning = (!$mainCell && $GLOBALS['BE_USER']->workspace !== 0 ? '<br />' . $this->doc->icons(3) . '<strong>' . $GLOBALS['LANG']->getLL('multipleVersions') . '</strong>' : '');
-                                               $verWarning = $warnAboutVersions || ($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages']) ? '<br />' . $this->doc->icons(3) . '<strong>' . $GLOBALS['LANG']->getLL('versionInVersion') . '</strong>' : '';
-                                               $verElement = $icon.
-                                                       (!$this->details ? '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table==='pages'?$rec_on['uid']:$rec_on['pid']).'&details='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode($this->REQUEST_URI)).'">' : '').
-                                                       t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
-                                                       (!$this->details ? '</a>' : '').
-                                                       $versionsInOtherWSWarning.
-                                                       $multipleWarning.
-                                                       $verWarning;
-
-                                               $ctrlTable = '
-                                                               <td nowrap="nowrap">'.$this->showStageChangeLog($table,$rec_off['uid'],$this->displayWorkspaceOverview_stageCmd($table,$rec_off)).'</td>
-                                                               <td nowrap="nowrap" class="'.$swapClass.'">'.
-                                                                       $this->displayWorkspaceOverview_commandLinks($table,$rec_on,$rec_off,$vType).
-                                                                       htmlspecialchars($swapLabel).
-                                                                       '&nbsp;&nbsp;</td>
-                                                               '.(!$this->diffOnly?'<td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('lifecycle')  . ':</strong> '.htmlspecialchars($this->formatCount($rec_off['t3ver_count'])).'</td>'.               // Lifecycle
-                                                                       ($this->showWorkspaceCol ? '
-                                                               <td nowrap="nowrap">&nbsp;&nbsp;<strong>' . $GLOBALS['LANG']->getLL('workspace')  . ':</strong> '.htmlspecialchars($this->formatWorkspace($rec_off['t3ver_wsid'])).'</td>' : ''):'');
-
-                                               if ($diffCode)  {
-                                                       $verElement = $verElement.'
-                                                       <br /><strong>' . $GLOBALS['LANG']->getLL('diffToLiveElement') . '</strong>
-                                                       <table border="0" cellpadding="0" cellspacing="0" class="ver-verElement">
-                                                               <tr>
-                                                                       <td class="c-diffCell">'.$diffCode.'</td>
-                                                               </tr>
-                                                       </table>';
-                                               }
-
-
-                                                       // Create version cell:
-                                               $verCell = '
-                                                               <td align="center">'.$this->formatVerId($rec_off['t3ver_id']).'</td>
-                                                               <td nowrap="nowrap">'.
-                                                                       $verElement.
-                                                                       $subElements['off'].
-                                                                       '</td>
-                                                               ';
-
-                                                       // Compile table row:
-                                               $tableRows[] = '
-                                                       <tr class="bgColor4">
-                                                               '.
-                                                               ($this->diffOnly?'':$mainCell).
-                                                               $verCell.
-                                                               $ctrlTable.
-                                                               '
-                                                       </tr>';
-
-                                                       // Reset the main cell:
-                                               $mainCell = '';
-
-                                       }
-                               }
-                       }
-               }
-
-               return $tableRows;
-       }
-
-       /**
-        * Building up of the $pArray
-        * (Internal)
-        *
-        * @param       array           Array that is built up with the page tree structure
-        * @param       string          Table name
-        * @param       array           Table row
-        * @return      void            $pArray is passed by reference and modified internally
-        */
-       function displayWorkspaceOverview_setInPageArray(&$pArray,$table,$row)  {
-               if (!$this->details || $this->details==$table.':'.$row['uid'])  {
-                       $pArray[$table][$row['t3ver_oid']][] = $row;
-               }
-       }
-
-       /**
-        * Links to stage change of a version
-        *
-        * @param       string          Table name
-        * @param       array           Offline record (version)
-        * @return      string          HTML content, mainly link tags and images.
-        */
-       function displayWorkspaceOverview_allStageCmd() {
-
-               $table = t3lib_div::_GP('table');
-               if ($table && $table!='pages')  {
-                       $uid = t3lib_div::_GP('uid');
-                       if ($rec_off = t3lib_BEfunc::getRecordWSOL($table,$uid)) {
-                               $uid = $rec_off['_ORIG_uid'];
-                       }
-               } else $table = '';
-
-               if ($table)     {
-                       if ($uid && $this->recIndex[$table][$uid])      {
-                               $sId = $this->recIndex[$table][$uid];
-                               switch($sId)    {
-                                       case 1:
-                                               $label = $GLOBALS['LANG']->getLL('commentForReviewer');
-                                       break;
-                                       case 10:
-                                               $label = $GLOBALS['LANG']->getLL('commentForPublisher');
-                                       break;
-                               }
-                       } else $sId = 0;
-               } else {
-                       if (count($this->stageIndex[1]))        {       // Review:
-                               $sId = 1;
-                               $color = '#666666';
-                               $label = $GLOBALS['LANG']->getLL('sendItemsToReview') . $GLOBALS['LANG']->getLL('commentForReviewer');
-                               $titleAttrib = $GLOBALS['LANG']->getLL('sendAllToReview');
-                       } elseif(count($this->stageIndex[10]))  {       // Publish:
-                               $sId = 10;
-                               $color = '#6666cc';
-                               $label = $GLOBALS['LANG']->getLL('approveToPublish') . $GLOBALS['LANG']->getLL('commentForPublisher');
-                               $titleAttrib = $GLOBALS['LANG']->getLL('approveAllToPublish');
-                       } else {
-                               $sId = 0;
-                       }
-               }
-
-               if ($sId>0)     {
-                       $issueCmd = '';
-                       $itemCount = 0;
-
-                       if ($table && $uid && $this->recIndex[$table][$uid])    {
-                               $issueCmd.='&cmd['.$table.']['.$uid.'][version][action]=setStage';
-                               $issueCmd.='&cmd['.$table.']['.$uid.'][version][stageId]='.$this->recIndex[$table][$uid];
-                       } else {
-                               foreach($this->stageIndex[$sId] as $table => $uidArray) {
-                                       $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][action]=setStage';
-                                       $issueCmd.='&cmd['.$table.']['.implode(',',$uidArray).'][version][stageId]='.$sId;
-                                       $itemCount+=count($uidArray);
-                               }
-                       }
-
-                       $onClick = 'var commentTxt=window.prompt("'.sprintf($label,$itemCount).'","");
-                                                       if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand($issueCmd,$this->REQUEST_URI).'&generalComment="+escape(commentTxt);}';
-
-                       if (t3lib_div::_GP('sendToReview'))     {
-                               $onClick.= ' else {window.location.href = "'.$this->REQUEST_URI.'"}';
-                               $actionLinks.=
-                                       $this->doc->wrapScriptTags($onClick);
-                       } else {
-                               $onClick.= ' return false;';
-                               $actionLinks.=
-                                       '<input type="submit" name="_" value="'.htmlspecialchars($titleAttrib).'" onclick="'.htmlspecialchars($onClick).'" />';
-                       }
-               } elseif (t3lib_div::_GP('sendToReview'))       {
-                       $onClick = 'window.location.href = "'.$this->REQUEST_URI.'";';
-                       $actionLinks.=
-                               $this->doc->wrapScriptTags($onClick);
-               } else $actionLinks = '';
-
-               return $actionLinks;
-       }
-
-
-
-
-
-
-       /**************************************
-        *
-        * Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...)
-        *
-        *************************************/
-
-       /**
-        * Formatting the version number for HTML output
-        *
-        * @param       integer         Version number
-        * @return      string          Version number for output
-        */
-       function formatVerId($verId)    {
-               return '1.'.$verId;
-       }
-
-       /**
-        * Formatting workspace ID into a visual label
-        *
-        * @param       integer         Workspace ID
-        * @return      string          Workspace title
-        */
-       function formatWorkspace($wsid) {
-
-                       // Render, if not cached:
-               if (!isset($this->formatWorkspace_cache[$wsid]))        {
-                       switch($wsid)   {
-                               case -1:
-                                       $this->formatWorkspace_cache[$wsid] = $GLOBALS['LANG']->getLL('offline');
-                               break;
-                               case 0:
-                                       $this->formatWorkspace_cache[$wsid] = '';       // Does not output anything for ONLINE because it might confuse people to think that the elemnet IS online which is not the case - only that it exists as an offline version in the online workspace...
-                               break;
-                               default:
-                                       $titleRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('title', 'sys_workspace', 'uid=' . intval($wsid) . t3lib_BEfunc::deleteClause('sys_workspace'));
-                                       $this->formatWorkspace_cache[$wsid] = '['.$wsid.'] '.$titleRec['title'];
-                               break;
-                       }
-               }
-
-               return $this->formatWorkspace_cache[$wsid];
-       }
-
-       /**
-        * Format publishing count for version (lifecycle state)
-        *
-        * @param       integer         t3ver_count value (number of times it has been online)
-        * @return      string          String translation of count.
-        */
-       function formatCount($count)    {
-
-                       // Render, if not cached:
-               if (!isset($this->formatCount_cache[$count]))   {
-                       switch($count)  {
-                               case 0:
-                                       $this->formatCount_cache[$count] = $GLOBALS['LANG']->getLL('draft');
-                               break;
-                               case 1:
-                                       $this->formatCount_cache[$count] = $GLOBALS['LANG']->getLL('archive');
-                               break;
-                               default:
-                                       $this->formatCount_cache[$count] = sprintf($GLOBALS['LANG']->getLL('publishedXTimes'), $count);
-                               break;
-                       }
-               }
-
-               return $this->formatCount_cache[$count];
-       }
-
-       /**
-        * Looking for versions of a record in other workspaces than the current
-        *
-        * @param       string          Table name
-        * @param       integer         Record uid
-        * @return      string          List of other workspace IDs
-        */
-       function versionsInOtherWS($table,$uid) {
-
-                       // Check for duplicates:
-                       // Select all versions of record NOT in this workspace:
-               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       't3ver_wsid',
-                       $table,
-                       'pid=-1
-                               AND t3ver_oid='.intval($uid).'
-                               AND t3ver_wsid!='.intval($GLOBALS['BE_USER']->workspace).'
-                               AND (t3ver_wsid=-1 OR t3ver_wsid>0)'.
-                               t3lib_BEfunc::deleteClause($table),
-                       '',
-                       't3ver_wsid',
-                       '',
-                       't3ver_wsid'
-               );
-               if (count($rows))       {
-                       return implode(',',array_keys($rows));
-               }
-       }
-
-       /**
-        * Looks up stage changes for version and displays a formatted view on mouseover.
-        *
-        * @param       string          Table name
-        * @param       integer         Record ID
-        * @param       string          HTML string to wrap the mouseover around (should be stage change links)
-        * @return      string          HTML code.
-        */
-       function showStageChangeLog($table,$id,$stageCommands)  {
-               $rows = $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($id)
-               );
-
-               $entry = array();
-               foreach($rows as $dat)  {
-                       $data = unserialize($dat['log_data']);
-                       $username = $this->be_user_Array[$dat['userid']] ? $this->be_user_Array[$dat['userid']]['username'] : '['.$dat['userid'].']';
-
-                       switch($data['stage'])  {
-                               case 1:
-                                       $text = $GLOBALS['LANG']->getLL('stage.sentToReview');
-                               break;
-                               case 10:
-                                       $text = $GLOBALS['LANG']->getLL('stage.approvedForPublish');
-                               break;
-                               case -1:
-                                       $text = $GLOBALS['LANG']->getLL('stage.rejectedElement');
-                               break;
-                               case 0:
-                                       $text = $GLOBALS['LANG']->getLL('stage.resetToEdit');
-                               break;
-                               default:
-                                       $text = $GLOBALS['LANG']->getLL('stage.undefined');
-                               break;
-                       }
-                       $text = t3lib_BEfunc::dateTime($dat['tstamp']).': "'.$username.'" '.$text;
-                       $text.= ($data['comment'] ? '<br />' . $GLOBALS['LANG']->getLL('userComment') . ': <em>' . htmlspecialchars($data['comment']) . '</em>' : '');
-
-                       $entry[] = $text;
-               }
-
-               return count($entry) ? '<span onmouseover="document.getElementById(\'log_' . $table . $id . '\').style.visibility = \'visible\';" onmouseout="document.getElementById(\'log_' . $table . $id . '\').style.visibility = \'hidden\';">' . $stageCommands . ' (' . count($entry) . ')</span>' .
-                               '<div class="t3-version-infolayer logLayer" id="log_' . $table . $id . '">' . implode('<hr/>', array_reverse($entry)) . '</div>' : $stageCommands;
-       }
-
-       /**
-        * Creates display of sub elements of a page when the swap mode is either "Page" or "Branch" (0 / ALL)
-        *
-        * @param       integer         Page uid (for either online or offline version, but it MUST have swapmode/treeLevel set to >0 (not -1 indicating element versioning)
-        * @param       integer         The treeLevel value, >0 indicates "branch" while 0 means page+content. (-1 would have meant element versioning, but that should never happen for a call to this function!)
-        * @param       integer         For offline versions; This is t3ver_oid, the original ID of the online page.
-        * @return      string          HTML content.
-        */
-       function subElements($uid,$treeLevel,$origId=0) {
-               global $TCA;
-
-               if (!$this->details && ($GLOBALS['BE_USER']->workspace===0 || !$this->MOD_SETTINGS['expandSubElements']))       {       // In online workspace we have a reduced view because otherwise it will bloat the listing:
-                       return '<br />
-                                       <img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' align="top" alt="" title="" />'.
-                                       ($origId ?
-                                               '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.$uid.'&details='.rawurlencode('pages:'.$uid).'&returnUrl='.rawurlencode($this->REQUEST_URI)).'">'.
-                                               '<span class="typo3-dimmed"><em>' . $GLOBALS['LANG']->getLL('subElementsClick')  . '</em><span></a>' :
-                                               '<span class="typo3-dimmed"><em>' . $GLOBALS['LANG']->getLL('subElements') . '</em><span>');
-               } else {        // For an offline workspace, show sub elements:
-
-                       $tCell = array();
-
-                               // Find records that follow pages when swapping versions:
-                       $recList = array();
-                       foreach($TCA as $tN => $tCfg)   {
-                               if ($tN!='pages' && ($treeLevel>0 || $TCA[$tN]['ctrl']['versioning_followPages']))      {
-                                       $this->subElements_getNonPageRecords($tN, $uid, $recList);
-                               }
-                       }
-
-                               // Render records collected above:
-                       $elCount = count($recList)-1;
-                       foreach($recList as $c => $comb)        {
-                               list($tN,$rec) = $comb;
-
-                               $this->subElements_renderItem(
-                                       $tCell,
-                                       $tN,
-                                       $uid,
-                                       $rec,
-                                       $origId,
-                                       $c==$elCount && $treeLevel==0 ? 1 : 0,          // If true, will show bottom-join icon.
-                                       ''
-                               );
-                       }
-
-                               // For branch, dive into the subtree:
-                       if ($treeLevel>0) {
-
-                                       // Drawing tree:
-                               $tree = t3lib_div::makeInstance('t3lib_pageTree');
-                               $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
-                               $tree->makeHTML = 2;            // 2=Also rendering depth-data into the result array
-                               $tree->getTree($uid, 99, '');
-
-                                       // Traverse page tree:
-                               foreach($tree->tree as $data)   {
-
-                                               // Render page in table cell:
-                                       $this->subElements_renderItem(
-                                               $tCell,
-                                               'pages',
-                                               $uid,
-                                               t3lib_BEfunc::getRecord('pages',$data['row']['uid']),   // Needs all fields, at least more than what is given in $data['row']...
-                                               $origId,
-                                               2,              // 2=the join icon and icon for the record is not rendered for pages (where all is in $data['HTML']
-                                               $data['HTML']
-                                       );
-
-                                               // Find all records from page and collect in $recList:
-                                       $recList = array();
-                                       foreach($TCA as $tN => $tCfg)   {
-                                               if ($tN!=='pages')      {
-                                                       $this->subElements_getNonPageRecords($tN, $data['row']['uid'], $recList);
-                                               }
-                                       }
-
-                                               // Render records collected above:
-                                       $elCount = count($recList)-1;
-                                       foreach($recList as $c => $comb)        {
-                                               list($tN,$rec) = $comb;
-
-                                               $this->subElements_renderItem(
-                                                       $tCell,
-                                                       $tN,
-                                                       $uid,
-                                                       $rec,
-                                                       $origId,
-                                                       $c==$elCount?1:0,       // If true, will show bottom-join icon.
-                                                       $data['HTML_depthData']
-                                               );
-                                       }
-                               }
-                       }
-
-                       return '
-                                       <!-- Sub-element tree for versions -->
-                                       <table border="0" cellpadding="0" cellspacing="1" class="ver-subtree">
-                                               '.implode('',$tCell).'
-                                       </table>';
-               }
-       }
-
-       /**
-        * Select records from a table and add them to recList
-        *
-        * @param       string          Table name (from TCA)
-        * @param       integer         PID to select records from
-        * @param       array           Array where records are accumulated, passed by reference
-        * @return      void
-        */
-       function subElements_getNonPageRecords($tN, $uid, &$recList)    {
-               global $TCA;
-
-               $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $tN,
-                       'pid='.intval($uid).
-                               ($TCA[$tN]['ctrl']['versioningWS'] ? ' AND t3ver_state=0' : '').
-                               t3lib_BEfunc::deleteClause($tN),
-                       '',
-                       $TCA[$tN]['ctrl']['sortby'] ? $TCA[$tN]['ctrl']['sortby'] : $GLOBALS['TYPO3_DB']->stripOrderBy($TCA[$tN]['ctrl']['default_sortby'])
-               );
-
-               foreach($records as $rec)       {
-                       $recList[] = array($tN,$rec);
-               }
-       }
-
-       /**
-        * Render a single item in a subelement list into a table row:
-        *
-        * @param       array           Table rows, passed by reference
-        * @param       string          Table name
-        * @param       integer         Page uid for which the subelements are selected/shown
-        * @param       array           Row of element in list
-        * @param       integer         The uid of the online version of $uid. If zero it means we are drawing a row for the online version itself while a value means we are drawing display for an offline version.
-        * @param       integer         Mode of icon display: 0=not the last, 1= is the last in list (make joinbottom icon then), 2=do not shown icons are all (for pages from the page tree already rendered)
-        * @param       string          Prefix HTML data (icons for tree rendering)
-        * @return      void            (Content accumulated in $tCell!)
-        */
-       function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata)      {
-               global $TCA;
-
-                       // Initialize:
-               $origUidFields = $TCA[$tN]['ctrl']['origUid'];
-               $diffCode = '';
-
-               if ($origUidFields)     {       // If there is a field for this table with original uids we will use that to connect records:
-                       if (!$origId)   {       // In case we are displaying the online originals:
-                               $this->targets['orig_'.$uid.'_'.$tN.'_'.$rec['uid']] = $rec;    // Build up target array (important that
-                               $tdParams =  ' id="orig_'.$uid.'_'.$tN.'_'.$rec['uid'].'" class="typo3-ver"';           // Setting ID of the table row
-                       } else {        // Version branch:
-                               if ($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]])   {       // If there IS a corresponding original record...:
-
-                                               // Prepare Table row parameters:
-                                       $tdParams =  ' onmouseover="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 1, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'.
-                                                               ' onmouseout="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 0, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'.
-                                                               ' id="ver_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="typo3-ver"';
-
-                                               // Create diff view:
-                                       if ($this->MOD_SETTINGS['diff'])        {
-                                               list($diffHTML,$diffPct) = $this->createDiffView($tN, $rec, $this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
-
-                                               if ($this->MOD_SETTINGS['diff']==2)     {
-                                                       $diffCode =
-                                                               ($diffPct ? '<span class="nobr">'.$diffPct.'% change</span>' : '-').
-                                                               '<div style="visibility: hidden; position: absolute;" id="diff_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="diffLayer">'.
-                                                               $diffHTML.
-                                                               '</div>';
-                                               } else {
-                                                       $diffCode =
-                                                               ($diffPct<0 ? $GLOBALS['LANG']->getLL('notAvailable') : ($diffPct ? $diffPct . '% ' . $GLOBALS['LANG']->getLL('change') : '')).
-                                                               $diffHTML;
-                                               }
-                                       }
-
-                                               // Unsetting the target fields allows us to mark all originals without a version in the subtree (see ->markupNewOriginals())
-                                       unset($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]);
-                               } else {        // No original record, so must be new:
-                                       $tdParams =  ' class="typo3-ver-new"';
-                               }
-                       }
-               } else {        // If no original uid column is supported for this table we are forced NOT to display any diff or highlighting.
-                       $tdParams = ' class="typo3-ver-noComp"';
-               }
-
-                       // Compile the cell:
-               $tCell[] = '
-                                               <tr'.$tdParams.'>
-                                                       <td class="iconTitle">'.
-                                                               $HTMLdata.
-                                                               ($iconMode < 2 ?
-                                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/join'.($iconMode ? 'bottom' : '').'.