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