Fixed bug #16000: Move versioning selector to the version extension
authorBenni Mack <benni.mack@typo3.org>
Tue, 19 Oct 2010 17:37:10 +0000 (17:37 +0000)
committerBenni Mack <benni.mack@typo3.org>
Tue, 19 Oct 2010 17:37:10 +0000 (17:37 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9167 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/version/ext_autoload.php
typo3/template.php

index 0962556..9ccd21f 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-19  Benjamin Mack  <benni@typo3.org>
+
+       * Fixed bug #16000: Move versioning selector to the version extension
+
 2010-10-19  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Raised DBAL to version 1.2.0alpha3
index 936247c..fa789cf 100644 (file)
@@ -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')
 );
 ?>
index fd0290c..d02a1c6 100644 (file)
@@ -1870,183 +1870,10 @@ $str.=$this->docBodyTagBegin().
         * @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 = '<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($this->backPath . 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($this->backPath, '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="' . $this->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 = $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 '
-
-                                                                       <!--
-                                                                               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 = $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 '
-
-                                                       <!--
-                                                               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>
-                                               ';
-                                       }
-                               }
-                       }
+       public function getVersionSelector($id, $noAction = FALSE) {
+               if (t3lib_extMgm::isLoaded('version')) {
+                       $versionGuiObj = t3lib_div::makeInstance('tx_version_gui');
+                       return $versionGuiObj->getVersionSelector($id, $noAction);
                }
        }