Fixed bug #11133: Validation issue: End tag for "br" omitted, but OMITTAG NO was...
[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 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 * Create preset overview for task center overview.
67 *
68 * @param object Parent object
69 * @return string HTML for the task center overview listing.
70 */
71 function overview_main() {
72 global $LANG;
73 // Create preset links:
74 $presets = $this->getPresets();
75 $opt = array();
76 if (is_array($presets)) {
77 foreach($presets as $presetCfg) {
78 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
79 $opt[] = '
80 <tr class="bgColor4">
81 <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>
82 <td>'.($presetCfg['item_uid'] ? $presetCfg['item_uid'] : '&nbsp;').'</td>
83 <td>'.($presetCfg['public'] ? '[Public]' : '&nbsp;').'</td>
84 <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? '[Own]' : '&nbsp;').'</td>
85 </tr>';
86 }
87 if(sizeof($opt)>0) {
88 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
89 $presets .= '<a href="index.php?SET[function]=tx_impexp"><em>'.$LANG->getLL('link_allRecs').'</em></a>';
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
103 /**
104 * Main Task center module
105 *
106 * @return string HTML content.
107 */
108 function main() {
109 if($id = t3lib_div::_GP('display')) {
110 return $this->urlInIframe($this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]='.$id,1);
111 } else {
112 // Thumbnail folder and files:
113 $tempDir = $this->userTempFolder();
114 if ($tempDir) {
115 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
116 }
117
118 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
119 $usernames = t3lib_BEfunc::getUserNames();
120
121 // Create preset links:
122 $presets = $this->getPresets();
123 $opt = array();
124 $opt[] = '
125 <tr class="bgColor5 tableheader">
126 <td>Icon:</td>
127 <td>Preset Title:</td>
128 <td>Public</td>
129 <td>Owner:</td>
130 <td>Page:</td>
131 <td>Path:</td>
132 <td>Meta data:</td>
133 </tr>';
134 if (is_array($presets)) {
135 foreach($presets as $presetCfg) {
136 $configuration = unserialize($presetCfg['preset_data']);
137 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
138 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
139
140 $opt[] = '
141 <tr class="bgColor4">
142 <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>
143 <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>
144 <td>'.($presetCfg['public'] ? 'Yes' : '&nbsp;').'</td>
145 <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? 'Own' : '['.$usernames[$presetCfg['user_uid']]['username'].']').'</td>
146 <td>'.($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;').'</td>
147 <td>'.htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'],$clause,20) : '[Single Records]').'</td>
148 <td>
149 <b>' . htmlspecialchars($configuration['meta']['title']) . '</b><br />' .
150 htmlspecialchars($configuration['meta']['description']).
151 ($configuration['meta']['notes'] ? '<br /><br /><b>Notes:</b> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>' : '') .
152 '
153 </td>
154 </tr>';
155 }
156 $content = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
157 }
158 }
159
160 // Output:
161 $theOutput.= $this->pObj->doc->spacer(5);
162 $theOutput.= $this->pObj->doc->section('Export presets',$content,0,1);
163
164 return $theOutput;
165 }
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 /*****************************
181 *
182 * Helper functions
183 *
184 *****************************/
185
186 /**
187 * Select presets for this user
188 *
189 * @return array Array of preset records
190 */
191 function getPresets() {
192 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
193 '*',
194 'tx_impexp_presets',
195 '(public>0 || user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')',
196 '',
197 'item_uid DESC, title'
198 );
199
200 return $presets;
201 }
202
203 /**
204 * Returns first temporary folder of the user account (from $FILEMOUNTS)
205 *
206 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
207 */
208 function userTempFolder() {
209 global $FILEMOUNTS;
210
211 foreach($FILEMOUNTS as $filePathInfo) {
212 $tempFolder = $filePathInfo['path'].'_temp_/';
213 if (@is_dir($tempFolder)) {
214 return $tempFolder;
215 }
216 }
217 }
218 }
219
220 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']) {
221 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']);
222 }
223 ?>