TYPO3 CMS  TYPO3_6-2
VersionView.php
Go to the documentation of this file.
1 <?php
3 
21 class VersionView {
22 
32  public function getVersionSelector($id, $noAction = FALSE) {
33  if ($id <= 0) {
34  return;
35  }
36  if ($GLOBALS['BE_USER']->workspace == 0) {
37  // Get Current page record:
38  $curPage = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $id);
39  // If the selected page is not online, find the right ID
40  $onlineId = $curPage['pid'] == -1 ? $curPage['t3ver_oid'] : $id;
41  // Select all versions of online version:
42  $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id', NULL);
43  // If more than one was found...:
44  if (count($versions) > 1) {
45  $selectorLabel = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionSelect.label', TRUE) . '</strong>';
46  // Create selector box entries:
47  $opt = array();
48  foreach ($versions as $vRow) {
49  if ($vRow['uid'] == $onlineId) {
50  // Live version
51  $label = '[' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionSelect.live', TRUE) . ']';
52  } else {
53  $label = $vRow['t3ver_label'] . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:versionId', TRUE) . ' ' . $vRow['t3ver_id'] . ($vRow['t3ver_wsid'] != 0 ? ' ' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xlf:workspaceId', TRUE) . ' ' . $vRow['t3ver_wsid'] : '') . ')';
54  }
55  $opt[] = '<option value="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('id' => $vRow['uid']))) . '"' . ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
56  }
57  // Add management link:
58  $management = '<input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.mgm', TRUE) . '" onclick="window.location.href=\'' . htmlspecialchars($GLOBALS['BACK_PATH'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', array('table' => 'pages', 'uid' => $onlineId))) . '\';" />';
59  // Create onchange handler:
60  $onChange = 'window.location.href=this.options[this.selectedIndex].value;';
61  // Controls:
62  if ($id == $onlineId) {
63  $controls .= '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="absmiddle" alt="" /> <strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.online', TRUE) . '</strong>';
64  } elseif (!$noAction) {
65  $controls .= '<a href="' . $GLOBALS['TBE_TEMPLATE']->issueCommand(('&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id . '&cmd[pages][' . $onlineId . '][version][action]=swap'), \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('id' => $onlineId))) . '" class="nobr">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-version-swap-version', array(
66  'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swapPage', TRUE),
67  'style' => 'margin-left:5px;vertical-align:bottom;'
68  )) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swap', TRUE) . '</strong></a>';
69  }
70  // Write out HTML code:
71  return '
72  <!--
73  Version selector:
74  -->
75  <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
76  <tr>
77  <td>' . $selectorLabel . '</td>
78  <td>
79  <select onchange="' . htmlspecialchars($onChange) . '">
80  ' . implode('', $opt) . '
81  </select></td>
82  <td>' . $controls . '</td>
83  <td>' . $management . '</td>
84  </tr>
85  </table>
86  ';
87  }
88  }
89  }
90 }
getVersionSelector($id, $noAction=FALSE)
Definition: VersionView.php:32
static selectVersionsOfRecord($table, $uid, $fields=' *', $workspace=0, $includeDeletedRecords=FALSE, $row=NULL)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]