TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
VersionClickMenu.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Version\ClickMenu;
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 
27 {
31  protected $iconFactory;
32 
36  public function __construct()
37  {
38  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
39  }
40 
50  public function main(&$backRef, $menuItems, $table, $uid)
51  {
52  $localItems = [];
53  if (!$backRef->cmLevel && $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) {
54  // Returns directly, because the clicked item was not from the pages table
55  if (in_array('versioning', $backRef->disabledItems) || !$GLOBALS['TCA'][$table] || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
56  return $menuItems;
57  }
58  // Adds the regular item
59  $LL = $this->includeLL();
60  // "Versioning" element added:
61  $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', ['table' => $table, 'uid' => $uid]);
62  $localItems[] = $backRef->linkItem(
63  $this->getLanguageService()->getLLL('title', $LL),
64  $this->iconFactory->getIcon('actions-version-page-open', Icon::SIZE_SMALL)->render(),
65  $backRef->urlRefForCM($url),
66  true
67  );
68  // Find position of "delete" element:
69  $c = 0;
70  foreach ($menuItems as $k => $value) {
71  $c++;
72  if ($k === 'delete') {
73  break;
74  }
75  }
76  // .. subtract two (delete item + divider line)
77  $c -= 2;
78  // ... and insert the items just before the delete element.
79  array_splice($menuItems, $c, 0, $localItems);
80  }
81  return $menuItems;
82  }
83 
89  public function includeLL()
90  {
91  return $this->getLanguageService()->includeLLFile('EXT:version/Resources/Private/Language/locallang.xlf', false);
92  }
93 
97  protected function getLanguageService()
98  {
99  return $GLOBALS['LANG'];
100  }
101 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)
main(&$backRef, $menuItems, $table, $uid)