Updates mainly to import/export extension. Many smaller changes / additions. See...
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / modfunc1 / class.tx_impexp_modfunc1.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 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 * Export Preset listing
29 *
30 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [CLASS/FUNCTION INDEX of SCRIPT]
34 *
35 *
36 *
37 * 63: class tx_impexp_modfunc1 extends mod_user_task
38 * 72: function overview_main(&$pObj)
39 * 102: function main()
40 *
41 * SECTION: Helper functions
42 * 182: function getPresets()
43 * 199: function userTempFolder()
44 *
45 * TOTAL FUNCTIONS: 4
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50
51
52 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
53 t3lib_extMgm::isLoaded('impexp',1);
54
55
56 /**
57 * Export Preset listing for the task center
58 *
59 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
60 * @package TYPO3
61 * @subpackage tx_impexp
62 */
63 class tx_impexp_modfunc1 extends mod_user_task {
64
65
66 /**
67 * Create preset overview for task center overview.
68 *
69 * @param object Parent object
70 * @return string HTML for the task center overview listing.
71 */
72 function overview_main(&$pObj) {
73
74 // Create preset links:
75 $presets = $this->getPresets();
76 $opt = array();
77 if (is_array($presets)) {
78 foreach($presets as $presetCfg) {
79 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
80 $opt[] = '
81 <tr class="bgColor4">
82 <td nowrap="nowrap"><a href="'.$this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]='.$presetCfg['uid'].'" target="list_frame">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,30)).'</a>&nbsp;</td>
83 <td>'.($presetCfg['item_uid'] ? $presetCfg['item_uid'] : '&nbsp;').'</td>
84 <td>'.($presetCfg['public'] ? '[Public]' : '&nbsp;').'</td>
85 <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? '[Own]' : '&nbsp;').'</td>
86 </tr>';
87 }
88 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
89
90 $icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath('impexp').'export.gif" width="18" height="16" class="absmiddle" alt="" />';
91 $content.= $pObj->doc->section($icon.'&nbsp;'.$this->headLink('tx_impexp_modfunc1',0),$presets,1,1,0,1);
92 }
93
94 return $content;
95 }
96
97 /**
98 * Main Task center module
99 *
100 * @return string HTML content.
101 */
102 function main() {
103
104 // Thumbnail folder and files:
105 $tempDir = $this->userTempFolder();
106 if ($tempDir) {
107 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
108 }
109
110 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
111 $usernames = t3lib_BEfunc::getUserNames();
112
113 // Create preset links:
114 $presets = $this->getPresets();
115 $opt = array();
116 $opt[] = '
117 <tr class="bgColor5 tableheader">
118 <td>Icon:</td>
119 <td>Preset Title:</td>
120 <td>Public</td>
121 <td>Owner:</td>
122 <td>Page:</td>
123 <td>Path:</td>
124 <td>Meta data:</td>
125 </tr>';
126 if (is_array($presets)) {
127 foreach($presets as $presetCfg) {
128 $configuration = unserialize($presetCfg['preset_data']);
129 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
130 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
131
132 $opt[] = '
133 <tr class="bgColor4">
134 <td>'.($thumbnailFile ? '<img src="'.$this->backPath.'../'.substr($tempDir,strlen(PATH_site)).basename($thumbnailFile).'" hspace="2" width="70" style="border: solid black 1px;" alt="" /><br/>' : '&nbsp;').'</td>
135 <td nowrap="nowrap"><b><a href="'.$this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]='.$presetCfg['uid'].'" target="list_frame">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,30)).'</a></b></td>
136 <td>'.($presetCfg['public'] ? 'Yes' : '&nbsp;').'</td>
137 <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? 'Own' : '['.$usernames[$presetCfg['user_uid']]['username'].']').'</td>
138 <td>'.($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;').'</td>
139 <td>'.htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'],$clause,20) : '[Single Records]').'</td>
140 <td>
141 <b>'.htmlspecialchars($configuration['meta']['title']).'</b><br/>'.
142 htmlspecialchars($configuration['meta']['description']).
143 ($configuration['meta']['notes'] ? '<br/><br/><b>Notes:</b> <em>'.htmlspecialchars($configuration['meta']['notes']).'</em>' : '').
144 '
145 </td>
146 </tr>';
147 }
148 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
149 }
150
151 // Output:
152 $theOutput.= $this->pObj->doc->spacer(5);
153 $theOutput.= $this->pObj->doc->section('Export presets',$presets,0,1);
154
155 return $theOutput;
156 }
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171 /*****************************
172 *
173 * Helper functions
174 *
175 *****************************/
176
177 /**
178 * Select presets for this user
179 *
180 * @return array Array of preset records
181 */
182 function getPresets() {
183 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
184 '*',
185 'tx_impexp_presets',
186 '(public>0 || user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')',
187 '',
188 'item_uid DESC, title'
189 );
190
191 return $presets;
192 }
193
194 /**
195 * Returns first temporary folder of the user account (from $FILEMOUNTS)
196 *
197 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
198 */
199 function userTempFolder() {
200 global $FILEMOUNTS;
201
202 foreach($FILEMOUNTS as $filePathInfo) {
203 $tempFolder = $filePathInfo['path'].'_temp_/';
204 if (@is_dir($tempFolder)) {
205 return $tempFolder;
206 }
207 }
208 }
209 }
210
211 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']) {
212 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']);
213 }
214 ?>