TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Clickmenu.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Impexp;
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 
23 
27 class Clickmenu
28 {
32  protected $iconFactory;
33 
37  public function __construct()
38  {
39  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
40  }
41 
52  public function main(&$backRef, $menuItems, $table, $uid)
53  {
54  $localItems = [];
55  // Show import/export on second level menu OR root level.
56  if ($backRef->cmLevel && GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
57  $LL = $this->includeLL();
58  $urlParameters = [
59  'tx_impexp' => [
60  'action' => 'export'
61  ],
62  'id' => ($table == 'pages' ? $uid : $backRef->rec['pid'])
63  ];
64  if ($table == 'pages') {
65  $urlParameters['tx_impexp']['pagetree']['id'] = $uid;
66  $urlParameters['tx_impexp']['pagetree']['levels'] = 0;
67  $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL';
68  } else {
69  $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid;
70  $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL';
71  }
72  $url = BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
73  $localItems[] = $backRef->linkItem(
74  htmlspecialchars($this->getLanguageService()->getLLL('export', $LL)),
75  $this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL),
76  $backRef->urlRefForCM($url),
77  1
78  );
79  if ($table === 'pages') {
80  $backendUser = $this->getBackendUser();
81  $isEnabledForNonAdmin = $backendUser->getTSConfig('options.impexp.enableImportForNonAdminUser');
82  if ($backendUser->isAdmin() || !empty($isEnabledForNonAdmin['value'])) {
83  $urlParameters = [
84  'id' => $uid,
85  'table' => $table,
86  'tx_impexp' => [
87  'action' => 'import'
88  ],
89  ];
90  $url = BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
91  $localItems[] = $backRef->linkItem(
92  htmlspecialchars($this->getLanguageService()->getLLL('import', $LL)),
93  $this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL),
94  $backRef->urlRefForCM($url),
95  1
96  );
97  }
98  }
99  }
100  return array_merge($menuItems, $localItems);
101  }
102 
108  public function includeLL()
109  {
110  return $this->getLanguageService()->includeLLFile('EXT:impexp/Resources/Private/Language/locallang.xlf', false);
111  }
112 
116  protected function getLanguageService()
117  {
118  return $GLOBALS['LANG'];
119  }
120 
124  protected function getBackendUser()
125  {
126  return $GLOBALS['BE_USER'];
127  }
128 }
main(&$backRef, $menuItems, $table, $uid)
Definition: Clickmenu.php:52
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)