TYPO3  7.6
impexp/Classes/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 
20 
24 class Clickmenu
25 {
29  protected $iconFactory;
30 
34  public function __construct()
35  {
36  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
37  }
38 
49  public function main(&$backRef, $menuItems, $table, $uid)
50  {
51  $localItems = array();
52  // Show import/export on second level menu OR root level.
53  if ($backRef->cmLevel && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
54  $LL = $this->includeLL();
55  $urlParameters = array(
56  'tx_impexp' => array(
57  'action' => 'export'
58  ),
59  'id' => ($table == 'pages' ? $uid : $backRef->rec['pid'])
60  );
61  if ($table == 'pages') {
62  $urlParameters['tx_impexp']['pagetree']['id'] = $uid;
63  $urlParameters['tx_impexp']['pagetree']['levels'] = 0;
64  $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL';
65  } else {
66  $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid;
67  $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL';
68  }
69  $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
70  $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export', $LL)), $backRef->excludeIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL)), $backRef->urlRefForCM($url), 1);
71  if ($table == 'pages') {
72  $urlParameters = array(
73  'id' => $uid,
74  'table' => $table,
75  'tx_impexp' => array(
76  'action' => 'import'
77  ),
78  );
79  $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
80  $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import', $LL)), $backRef->excludeIcon($this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL)), $backRef->urlRefForCM($url), 1);
81  }
82  }
83  return array_merge($menuItems, $localItems);
84  }
85 
91  public function includeLL()
92  {
93  return $GLOBALS['LANG']->includeLLFile('EXT:impexp/Resources/Private/Language/locallang.xlf', false);
94  }
95 }