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