[TASK] Replace sprite icon "actions-document-export-t3d" with the new IconFactory
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / Clickmenu.php
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
17 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 /**
22 * Adding Import/Export clickmenu item
23 */
24 class Clickmenu {
25 /**
26 * @var IconFactory
27 */
28 protected $iconFactory;
29
30 /**
31 * Construct
32 */
33 public function __construct() {
34 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
35 }
36
37 /**
38 * Processing of clickmenu items
39 *
40 * @param \TYPO3\CMS\Backend\ClickMenu\ClickMenu $backRef parent
41 * @param array $menuItems Menu items array to modify
42 * @param string $table Table name
43 * @param int $uid Uid of the record
44 * @return array Menu item array, returned after modification
45 * @todo Skinning for icons...
46 */
47 public function main(&$backRef, $menuItems, $table, $uid) {
48 $localItems = array();
49 // Show import/export on second level menu OR root level.
50 if ($backRef->cmLevel && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
51 $LL = $this->includeLL();
52 $urlParameters = array(
53 'tx_impexp' => array(
54 'action' => 'export'
55 ),
56 'id' => ($table == 'pages' ? $uid : $backRef->rec['pid'])
57 );
58 if ($table == 'pages') {
59 $urlParameters['tx_impexp']['pagetree']['id'] = $uid;
60 $urlParameters['tx_impexp']['pagetree']['levels'] = 0;
61 $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL';
62 } else {
63 $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid;
64 $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL';
65 }
66 $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
67 $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);
68 if ($table == 'pages') {
69 $urlParameters = array(
70 'id' => $uid,
71 'table' => $table,
72 'tx_impexp' => array(
73 'action' => 'import'
74 ),
75 );
76 $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
77 $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);
78 }
79 }
80 return array_merge($menuItems, $localItems);
81 }
82
83 /**
84 * Include local lang file and return $LOCAL_LANG array loaded.
85 *
86 * @return array Local lang array
87 */
88 public function includeLL() {
89 return $GLOBALS['LANG']->includeLLFile('EXT:impexp/Resources/Private/Language/locallang.xlf', FALSE);
90 }
91
92 }