TYPO3 CMS  TYPO3_7-6
VersionView.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
27 {
37  public function getVersionSelector($id, $noAction = false)
38  {
39  if ($id <= 0) {
40  return '';
41  }
42  if ($GLOBALS['BE_USER']->workspace == 0) {
43  // Get Current page record:
44  $curPage = BackendUtility::getRecord('pages', $id);
45  // If the selected page is not online, find the right ID
46  $onlineId = $curPage['pid'] == -1 ? $curPage['t3ver_oid'] : $id;
47  // Select all versions of online version:
48  $versions = BackendUtility::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id', null);
49  // If more than one was found...:
50  if (count($versions) > 1) {
51  // Create selector box entries:
52  $opt = [];
53  foreach ($versions as $vRow) {
54  if ($vRow['uid'] == $onlineId) {
55  // Live version
56  $label = '[' . $GLOBALS['LANG']->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionSelect.live', true) . ']';
57  } else {
58  $label = $vRow['t3ver_label'] . ' (' . $GLOBALS['LANG']->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionId', true) . ' ' . $vRow['t3ver_id'] . ($vRow['t3ver_wsid'] != 0 ? ' ' . $GLOBALS['LANG']->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:workspaceId', true) . ' ' . $vRow['t3ver_wsid'] : '') . ')';
59  }
60  $opt[] = '<option value="' . htmlspecialchars(GeneralUtility::linkThisScript(['id' => $vRow['uid']])) . '"' . ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
61  }
63  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
64  // Add management link:
65  $management = '
66  <a class="btn btn-default" href="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', ['table' => 'pages', 'uid' => $onlineId])) . '">
67  ' . $iconFactory->getIcon('actions-version-page-open', Icon::SIZE_SMALL)->render() . '
68  ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.mgm', true) . '
69  </a>';
70  // Create onchange handler:
71  $onChange = 'window.location.href=this.options[this.selectedIndex].value;';
72  // Controls:
73  if ($id == $onlineId) {
74  $controls = '<strong class="text-success">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.online', true) . '</strong>';
75  } elseif (!$noAction) {
77  '&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id . '&cmd[pages][' . $onlineId . '][version][action]=swap',
78  GeneralUtility::linkThisScript(['id' => $onlineId])
79  );
80  $controls = '
81  <a href="' . htmlspecialchars($href) . '" class="btn btn-default" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swapPage', true) . '">
82  ' . $iconFactory->getIcon('actions-version-swap-version', Icon::SIZE_SMALL)->render() . '
83  ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:ver.swap', true) . '
84  </a>';
85  }
86  // Write out HTML code:
87  return '
88  <!--
89  Version selector:
90  -->
91  <div id="typo3-version-selector" class="form-inline form-inline-spaced">
92  <div class="form-group">
93  <label for="version-selector">' . $GLOBALS['LANG']->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionSelect.label', true) . '</label>
94  <select id="version-selector" class="form-control" onchange="' . htmlspecialchars($onChange) . '">
95  ' . implode('', $opt) . '
96  </select>
97  </div>
98  <div class="form-group">
99  ' . $controls . '
100  </div>
101  <div class="form-group">
102  ' . $management . '
103  </div>
104  </div>
105  ';
106  }
107  }
108  }
109 }
static linkThisScript(array $getParams=[])
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static selectVersionsOfRecord($table, $uid, $fields=' *', $workspace=0, $includeDeletedRecords=false, $row=null)
static getLinkToDataHandlerAction($parameters, $redirectUrl='')