TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
VersionView.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Version\View;
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 
22 
28 {
38  public function getVersionSelector($id, $noAction = false)
39  {
40  if ($id <= 0) {
41  return '';
42  }
43  if ($GLOBALS['BE_USER']->workspace == 0) {
44  $lang = $this->getLanguageService();
45  // Get Current page record:
46  $curPage = BackendUtility::getRecord('pages', $id);
47  // If the selected page is not online, find the right ID
48  $onlineId = $curPage['pid'] == -1 ? $curPage['t3ver_oid'] : $id;
49  // Select all versions of online version:
50  $versions = BackendUtility::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id', null);
51  // If more than one was found...:
52  if (count($versions) > 1) {
53  // Create selector box entries:
54  $opt = [];
55  foreach ($versions as $vRow) {
56  if ($vRow['uid'] == $onlineId) {
57  // Live version
58  $label = '[' . htmlspecialchars($lang->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionSelect.live')) . ']';
59  } else {
60  $label = $vRow['t3ver_label'] . ' (' . htmlspecialchars($lang->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionId')) . ' ' . $vRow['t3ver_id'] . ($vRow['t3ver_wsid'] != 0 ? ' ' . htmlspecialchars($lang->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:workspaceId')) . ' ' . $vRow['t3ver_wsid'] : '') . ')';
61  }
62  $opt[] = '<option value="' . htmlspecialchars(GeneralUtility::linkThisScript(['id' => $vRow['uid']])) . '"' . ($id == $vRow['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
63  }
65  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
66  // Add management link:
67  $management = '
68  <a class="btn btn-default" href="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', ['table' => 'pages', 'uid' => $onlineId])) . '">
69  ' . $iconFactory->getIcon('actions-version-page-open', Icon::SIZE_SMALL)->render() . '
70  ' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:ver.mgm')) . '
71  </a>';
72  // Create onchange handler:
73  $onChange = 'window.location.href=this.options[this.selectedIndex].value;';
74  // Controls:
75  if ($id == $onlineId) {
76  $controls = '<strong class="text-success">' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:ver.online')) . '</strong>';
77  } elseif (!$noAction) {
79  '&cmd[pages][' . $onlineId . '][version][swapWith]=' . $id . '&cmd[pages][' . $onlineId . '][version][action]=swap',
80  GeneralUtility::linkThisScript(['id' => $onlineId])
81  );
82  $controls = '
83  <a href="' . htmlspecialchars($href) . '" class="btn btn-default" title="' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:ver.swapPage')) . '">
84  ' . $iconFactory->getIcon('actions-version-swap-version', Icon::SIZE_SMALL)->render() . '
85  ' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:ver.swap')) . '
86  </a>';
87  }
88  // Write out HTML code:
89  return '
90  <!--
91  Version selector:
92  -->
93  <div id="typo3-version-selector" class="form-inline form-inline-spaced">
94  <div class="form-group">
95  <label for="version-selector">' . htmlspecialchars($lang->sL('LLL:EXT:version/Resources/Private/Language/locallang.xlf:versionSelect.label')) . '</label>
96  <select id="version-selector" class="form-control" onchange="' . htmlspecialchars($onChange) . '">
97  ' . implode('', $opt) . '
98  </select>
99  </div>
100  <div class="form-group">
101  ' . $controls . '
102  </div>
103  <div class="form-group">
104  ' . $management . '
105  </div>
106  </div>
107  ';
108  }
109  }
110  }
111 
115  protected function getLanguageService()
116  {
117  return $GLOBALS['LANG'];
118  }
119 }
static getLinkToDataHandlerAction($parameters, $redirectUrl= '')
static selectVersionsOfRecord($table, $uid, $fields= '*', $workspace=0, $includeDeletedRecords=false, $row=null)
static getRecord($table, $uid, $fields= '*', $where= '', $useDeleteClause=true)
static linkThisScript(array $getParams=[])
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)