8b1becc0adc0ac9ccde33fdbdb033e3c986f9842
[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 /**
18 * Adding Import/Export clickmenu item
19 */
20 class Clickmenu {
21
22 /**
23 * Processing of clickmenu items
24 *
25 * @param \TYPO3\CMS\Backend\ClickMenu\ClickMenu $backRef parent
26 * @param array $menuItems Menu items array to modify
27 * @param string $table Table name
28 * @param int $uid Uid of the record
29 * @return array Menu item array, returned after modification
30 * @todo Skinning for icons...
31 */
32 public function main(&$backRef, $menuItems, $table, $uid) {
33 $localItems = array();
34 // Show import/export on second level menu OR root level.
35 if ($backRef->cmLevel && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
36 $LL = $this->includeLL();
37 $urlParameters = array(
38 'tx_impexp' => array(
39 'action' => 'export'
40 ),
41 'id' => ($table == 'pages' ? $uid : $backRef->rec['pid'])
42 );
43 if ($table == 'pages') {
44 $urlParameters['tx_impexp']['pagetree']['id'] = $uid;
45 $urlParameters['tx_impexp']['pagetree']['levels'] = 0;
46 $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL';
47 } else {
48 $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid;
49 $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL';
50 }
51 $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
52 $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export', $LL)), $backRef->excludeIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-export-t3d')), $backRef->urlRefForCM($url), 1);
53 if ($table == 'pages') {
54 $urlParameters = array(
55 'id' => $uid,
56 'table' => $table,
57 'tx_impexp' => array(
58 'action' => 'import'
59 ),
60 );
61 $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters);
62 $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import', $LL)), $backRef->excludeIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-import-t3d')), $backRef->urlRefForCM($url), 1);
63 }
64 }
65 return array_merge($menuItems, $localItems);
66 }
67
68 /**
69 * Include local lang file and return $LOCAL_LANG array loaded.
70 *
71 * @return array Local lang array
72 */
73 public function includeLL() {
74 return $GLOBALS['LANG']->includeLLFile('EXT:impexp/Resources/Private/Language/locallang.xlf', FALSE);
75 }
76
77 }