Fixed bug #9049: Page ID is always 0 in export module for impexp (thanks to Christian...
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / class.tx_impexp_clickmenu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Adding Import/Export clickmenu item
29 *
30 * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
31 * XHTML compliant
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 67: class tx_impexp_clickmenu
41 * 79: function main(&$backRef,$menuItems,$table,$uid)
42 * 121: function includeLL()
43 *
44 * TOTAL FUNCTIONS: 2
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49
50
51
52
53
54
55
56
57
58
59
60 /**
61 * Adding Import/Export clickmenu item
62 *
63 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
64 * @package TYPO3
65 * @subpackage tx_impexp
66 */
67 class tx_impexp_clickmenu {
68
69 /**
70 * Processing of clickmenu items
71 *
72 * @param object Reference to parent
73 * @param array Menu items array to modify
74 * @param string Table name
75 * @param integer Uid of the record
76 * @return array Menu item array, returned after modification
77 * @todo Skinning for icons...
78 */
79 function main(&$backRef,$menuItems,$table,$uid) {
80 global $BE_USER,$TCA;
81
82 $localItems=array();
83 if (($backRef->cmLevel && t3lib_div::_GP('subname')=='moreoptions') || ($table==='pages' && $uid==0)) { // Show import/export on second level menu OR root level.
84
85 $LL = $this->includeLL();
86
87 $url = 'mod.php?M=xMOD_tximpexp&tx_impexp[action]=export&id=' . ($table == 'pages' ? $uid : $backRef->rec['pid']);
88 if ($table=='pages') {
89 $url.='&tx_impexp[pagetree][id]='.$uid;
90 $url.='&tx_impexp[pagetree][levels]=0';
91 $url.='&tx_impexp[pagetree][tables][]=_ALL';
92 } else {
93 $url.='&tx_impexp[record][]='.rawurlencode($table.':'.$uid);
94 $url.='&tx_impexp[external_ref][tables][]=_ALL';
95 }
96 $localItems[] = $backRef->linkItem(
97 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export',$LL)),
98 $backRef->excludeIcon('<img'.t3lib_iconWorks::skinImg($backRef->backPath,t3lib_extMgm::extRelPath('impexp').'export.gif','width="18" height="16"').' alt="" />'),
99 $backRef->urlRefForCM($url),
100 1 // Disables the item in the top-bar
101 );
102
103 if ($table=='pages') {
104 $url = 'mod.php?M=xMOD_tximpexp&id='.$uid.'&table='.$table.'&tx_impexp[action]=import';
105 $localItems[] = $backRef->linkItem(
106 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import',$LL)),
107 $backRef->excludeIcon('<img'.t3lib_iconWorks::skinImg($backRef->backPath,t3lib_extMgm::extRelPath('impexp').'import.gif','width="18" height="16"').' alt="" />'),
108 $backRef->urlRefForCM($url),
109 1 // Disables the item in the top-bar
110 );
111 }
112 }
113 return array_merge($menuItems,$localItems);
114 }
115
116 /**
117 * Include local lang file and return $LOCAL_LANG array loaded.
118 *
119 * @return array Local lang array
120 */
121 function includeLL() {
122 global $LANG;
123
124 return $LANG->includeLLFile('EXT:impexp/app/locallang.php',FALSE);
125 }
126 }
127
128 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp_clickmenu.php']) {
129 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp_clickmenu.php']);
130 }
131 ?>