Minor changes in taskcenter, impexp taskcenter module adjusted to new taskcenter
[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() {
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 if(sizeof($opt)>0) {
89 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
90 } else {
91 $presets = '';
92 }
93
94 $icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath('impexp').'export.gif" width="18" height="16" class="absmiddle" alt="" />';
95 $config= $this->mkMenuConfig($icon.$this->headLink('tx_impexp_modfunc1',1),'',$presets);
96 }
97
98 return $config;
99 }
100
101 /**
102 * Main Task center module
103 *
104 * @return string HTML content.
105 */
106 function main() {
107
108 // Thumbnail folder and files:
109 $tempDir = $this->userTempFolder();
110 if ($tempDir) {
111 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
112 }
113
114 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
115 $usernames = t3lib_BEfunc::getUserNames();
116
117 // Create preset links:
118 $presets = $this->getPresets();
119 $opt = array();
120 $opt[] = '
121 <tr class="bgColor5 tableheader">
122 <td>Icon:</td>
123 <td>Preset Title:</td>
124 <td>Public</td>
125 <td>Owner:</td>
126 <td>Page:</td>
127 <td>Path:</td>
128 <td>Meta data:</td>
129 </tr>';
130 if (is_array($presets)) {
131 foreach($presets as $presetCfg) {
132 $configuration = unserialize($presetCfg['preset_data']);
133 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
134 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
135
136 $opt[] = '
137 <tr class="bgColor4">
138 <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>
139 <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>
140 <td>'.($presetCfg['public'] ? 'Yes' : '&nbsp;').'</td>
141 <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? 'Own' : '['.$usernames[$presetCfg['user_uid']]['username'].']').'</td>
142 <td>'.($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;').'</td>
143 <td>'.htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'],$clause,20) : '[Single Records]').'</td>
144 <td>
145 <b>'.htmlspecialchars($configuration['meta']['title']).'</b><br/>'.
146 htmlspecialchars($configuration['meta']['description']).
147 ($configuration['meta']['notes'] ? '<br/><br/><b>Notes:</b> <em>'.htmlspecialchars($configuration['meta']['notes']).'</em>' : '').
148 '
149 </td>
150 </tr>';
151 }
152 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
153 }
154
155 // Output:
156 $theOutput.= $this->pObj->doc->spacer(5);
157 $theOutput.= $this->pObj->doc->section('Export presets',$presets,0,1);
158
159 return $theOutput;
160 }
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 /*****************************
176 *
177 * Helper functions
178 *
179 *****************************/
180
181 /**
182 * Select presets for this user
183 *
184 * @return array Array of preset records
185 */
186 function getPresets() {
187 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
188 '*',
189 'tx_impexp_presets',
190 '(public>0 || user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')',
191 '',
192 'item_uid DESC, title'
193 );
194
195 return $presets;
196 }
197
198 /**
199 * Returns first temporary folder of the user account (from $FILEMOUNTS)
200 *
201 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
202 */
203 function userTempFolder() {
204 global $FILEMOUNTS;
205
206 foreach($FILEMOUNTS as $filePathInfo) {
207 $tempFolder = $filePathInfo['path'].'_temp_/';
208 if (@is_dir($tempFolder)) {
209 return $tempFolder;
210 }
211 }
212 }
213 }
214
215 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']) {
216 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']);
217 }
218 ?>