d0a33275620ad750ebc39063e40dd3e18cdfe890
[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-2011 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 textfile 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 * Adding Import/Export clickmenu item
31 *
32 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 /**
38 * Adding Import/Export clickmenu item
39 *
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @package TYPO3
42 * @subpackage tx_impexp
43 */
44 class Clickmenu {
45
46 /**
47 * Processing of clickmenu items
48 *
49 * @param object $backRef Reference to parent
50 * @param array $menuItems Menu items array to modify
51 * @param string $table Table name
52 * @param integer $uid Uid of the record
53 * @return array Menu item array, returned after modification
54 * @todo Skinning for icons...
55 * @todo Define visibility
56 */
57 public function main(&$backRef, $menuItems, $table, $uid) {
58 $localItems = array();
59 // Show import/export on second level menu OR root level.
60 if ($backRef->cmLevel && \t3lib_div::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
61 $LL = $this->includeLL();
62 $modUrl = ($backRef->backPath . t3lib_extMgm::extRelPath('impexp')) . 'app/index.php';
63 $url = ($modUrl . '?tx_impexp[action]=export&id=') . ($table == 'pages' ? $uid : $backRef->rec['pid']);
64 if ($table == 'pages') {
65 $url .= '&tx_impexp[pagetree][id]=' . $uid;
66 $url .= '&tx_impexp[pagetree][levels]=0';
67 $url .= '&tx_impexp[pagetree][tables][]=_ALL';
68 } else {
69 $url .= '&tx_impexp[record][]=' . rawurlencode((($table . ':') . $uid));
70 $url .= '&tx_impexp[external_ref][tables][]=_ALL';
71 }
72 $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export', $LL)), $backRef->excludeIcon(\t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d')), $backRef->urlRefForCM($url), 1);
73 if ($table == 'pages') {
74 $url = (((($modUrl . '?id=') . $uid) . '&table=') . $table) . '&tx_impexp[action]=import';
75 $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import', $LL)), $backRef->excludeIcon(\t3lib_iconWorks::getSpriteIcon('actions-document-import-t3d')), $backRef->urlRefForCM($url), 1);
76 }
77 }
78 return array_merge($menuItems, $localItems);
79 }
80
81 /**
82 * Include local lang file and return $LOCAL_LANG array loaded.
83 *
84 * @return array Local lang array
85 * @todo Define visibility
86 */
87 public function includeLL() {
88 global $LANG;
89 return $LANG->includeLLFile('EXT:impexp/app/locallang.php', FALSE);
90 }
91
92 }
93
94
95 ?>