Index: typo3/template.php =================================================================== --- typo3/template.php (Revision 9067) +++ typo3/template.php (Arbeitskopie) @@ -1859,183 +1859,10 @@ * @param boolean If set, there will be no button for swapping page. * @return void */ - function getVersionSelector($id,$noAction=FALSE) { - - if ($id>0) { - if (t3lib_extMgm::isLoaded('version') && $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 = '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.label', TRUE) . ''; - - // 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[] = ''; - } - - // Add management link: - $management = ''; - // Create onchange handler: - $onChange = "window.location.href=this.options[this.selectedIndex].value;"; - - // Controls: - if ($id == $onlineId) { - $controls .= 'backPath, 'gfx/blinkarrow_left.gif','width="5" height="9"') . - ' class="absmiddle" alt="" /> ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online', TRUE) . - ''; - } elseif (!$noAction) { - $controls .= '' . 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;' - )) . '' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap', TRUE) . ''; - } - - // Write out HTML code: - return ' - - - - - - - - - -
' . $selectorLabel . ' - ' . $controls . '' . $management . '
- '; - } - } 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 ' - - - - - - - - -
' . $selectorLabel . 'Workspace: "' . htmlspecialchars($wsTitle) . '"' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.inBranch', TRUE) . '
- '; - } 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 = $this->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 ' - - - - - - - - -
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '" -
- '; - } - } 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 ' - - - - - - - - -
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.versionsFound', TRUE) . '
- '; - } - } elseif ($verPage['t3ver_swapmode']==0) { - $onClick = $this->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 ' - - - - - - - - -
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '" -
- '; - } - } - } + public function getVersionSelector($id, $noAction = FALSE) { + if (t3lib_extMgm::isLoaded('version')) { + $versionGuiObj = t3lib_div::makeInstance('tx_version_gui'); + return $versionGuiObj->getVersionSelector($id, $noAction); } } Index: typo3/sysext/version/class.tx_version_gui.php =================================================================== --- typo3/sysext/version/class.tx_version_gui.php (Revision 0) +++ typo3/sysext/version/class.tx_version_gui.php (Revision 0) @@ -0,0 +1,227 @@ +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 = '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.label', TRUE) . ''; + + // 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[] = ''; + } + + // Add management link: + $management = ''; + // Create onchange handler: + $onChange = "window.location.href=this.options[this.selectedIndex].value;"; + + // Controls: + if ($id == $onlineId) { + $controls .= 'backPath, 'gfx/blinkarrow_left.gif','width="5" height="9"') . + ' class="absmiddle" alt="" /> ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online', TRUE) . + ''; + } elseif (!$noAction) { + $controls .= '' . 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;' + )) . '' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap', TRUE) . ''; + } + + // Write out HTML code: + return ' + + + + + + + + +
' . $selectorLabel . ' + ' . $controls . '' . $management . '
+ '; + } + } 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 ' + + + + + + + + +
' . $selectorLabel . 'Workspace: "' . htmlspecialchars($wsTitle) . '"' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.inBranch', TRUE) . '
+ '; + } 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 ' + + + + + + + + +
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '" +
+ '; + } + } 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 ' + + + + + + + + +
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.versionsFound', TRUE) . '
+ '; + } + } 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 ' + + + + + + + + +
' . $selectorLabel . '' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '" +
+ '; + } + } + } + } + +} + +?> \ No newline at end of file Index: typo3/sysext/version/ext_autoload.php =================================================================== --- typo3/sysext/version/ext_autoload.php (Revision 9067) +++ typo3/sysext/version/ext_autoload.php (Arbeitskopie) @@ -5,6 +5,7 @@ * $Id: ext_autoload.php 6536 2009-11-25 14:07:18Z stucki $ */ return array( - 'tx_version_tasks_autopublish' => t3lib_extMgm::extPath('version', 'tasks/class.tx_version_tasks_autopublish.php') + 'tx_version_tasks_autopublish' => t3lib_extMgm::extPath('version', 'tasks/class.tx_version_tasks_autopublish.php'), + 'tx_version_gui' => t3lib_extMgm::extPath('version', 'class.tx_version_gui.php') ); ?>