7de2d69c714d29c2f853e9e8ac742c186861c5e6
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / Clickmenu.php
1 <?php
2 namespace TYPO3\CMS\Impexp;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Adding Import/Export clickmenu item
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 class Clickmenu {
36
37 /**
38 * Processing of clickmenu items
39 *
40 * @param object $backRef Reference to parent
41 * @param array $menuItems Menu items array to modify
42 * @param string $table Table name
43 * @param integer $uid Uid of the record
44 * @return array Menu item array, returned after modification
45 * @todo Skinning for icons...
46 * @todo Define visibility
47 */
48 public function main(&$backRef, $menuItems, $table, $uid) {
49 $localItems = array();
50 // Show import/export on second level menu OR root level.
51 if ($backRef->cmLevel && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
52 $LL = $this->includeLL();
53 $modUrl = $backRef->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('impexp') . 'app/index.php';
54 $url = $modUrl . '?tx_impexp[action]=export&id=' . ($table == 'pages' ? $uid : $backRef->rec['pid']);
55 if ($table == 'pages') {
56 $url .= '&tx_impexp[pagetree][id]=' . $uid;
57 $url .= '&tx_impexp[pagetree][levels]=0';
58 $url .= '&tx_impexp[pagetree][tables][]=_ALL';
59 } else {
60 $url .= '&tx_impexp[record][]=' . rawurlencode(($table . ':' . $uid));
61 $url .= '&tx_impexp[external_ref][tables][]=_ALL';
62 }
63 $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);
64 if ($table == 'pages') {
65 $url = $modUrl . '?id=' . $uid . '&table=' . $table . '&tx_impexp[action]=import';
66 $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);
67 }
68 }
69 return array_merge($menuItems, $localItems);
70 }
71
72 /**
73 * Include local lang file and return $LOCAL_LANG array loaded.
74 *
75 * @return array Local lang array
76 * @todo Define visibility
77 */
78 public function includeLL() {
79 global $LANG;
80 return $LANG->includeLLFile('EXT:impexp/app/locallang.xlf', FALSE);
81 }
82
83 }