Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / task / class.tx_impexp_task.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
6 * (c) 2010-2011 Georg Ringer (typo3@ringerge.org)
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25
26
27 /**
28 * This class provides a textarea to save personal notes
29 *
30 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @author Georg Ringer <typo3@ringerge.org>
32 * @package TYPO3
33 * @subpackage impexp
34 *
35 */
36 class tx_impexp_task implements tx_taskcenter_Task {
37 /**
38 * Back-reference to the calling reports module
39 *
40 * @var tx_reports_Module $taskObject
41 */
42 protected $taskObject;
43
44 /**
45 * Constructor
46 */
47 public function __construct(SC_mod_user_task_index $taskObject) {
48 $this->taskObject = $taskObject;
49 $GLOBALS['LANG']->includeLLFile('EXT:impexp/locallang_csh.xml');
50 }
51
52 /**
53 * This method renders the report
54 *
55 * @return string The status report as HTML
56 */
57 public function getTask() {
58 return $this->main();
59 }
60
61 /**
62 * Render an optional additional information for the 1st view in taskcenter.
63 * Empty for this task
64 *
65 * @return string Overview as HTML
66 */
67 public function getOverview() {
68 return '';
69 }
70
71 /**
72 * Main Task center module
73 *
74 * @return string HTML content.
75 */
76 public function main() {
77 $content = '';
78 $id = intval(t3lib_div::_GP('display'));
79
80 // if a preset is found, it is rendered using an iframe
81 if($id > 0) {
82 $url = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id;
83 return $this->taskObject->urlInIframe($url, 1);
84 } else {
85 // header
86 $content .= $this->taskObject->description(
87 $GLOBALS['LANG']->getLL('.alttitle'),
88 $GLOBALS['LANG']->getLL('.description')
89 );
90
91 $thumbnails = $lines = array();
92
93 // Thumbnail folder and files:
94 $tempDir = $this->userTempFolder();
95 if ($tempDir) {
96 $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1);
97 }
98
99 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
100 $usernames = t3lib_BEfunc::getUserNames();
101
102 // Create preset links:
103 $presets = $this->getPresets();
104
105 // if any presets found
106 if (is_array($presets)) {
107 foreach($presets as $key => $presetCfg) {
108 $configuration = unserialize($presetCfg['preset_data']);
109 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
110 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
111 $icon = 'EXT:impexp/export.gif';
112
113 $description = array();
114
115 // is public?
116 if ($presetCfg['public']) {
117 $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
118 }
119
120 // owner
121 $description[] = $GLOBALS['LANG']->getLL('task.owner') . ': ' . (($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid']) ? $GLOBALS['LANG']->getLL('task.own') : '[' . htmlspecialchars($usernames[$presetCfg['user_uid']]['username']) . ']');
122
123 // page & path
124 if ($configuration['pagetree']['id']) {
125 $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
126 $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20));
127 } else {
128 $description[] = $GLOBALS['LANG']->getLL('single-record');
129 }
130
131 // Meta information
132 if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) {
133 $metaInformation = '';
134 if ($configuration['meta']['title']) {
135 $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
136 }
137 if ($configuration['meta']['description']) {
138 $metaInformation .= htmlspecialchars($configuration['meta']['description']);
139 }
140 if ($configuration['meta']['notes']) {
141 $metaInformation .= '<br /><br />
142 <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
143 <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
144 }
145
146 $description[] = '<br />' . $metaInformation;
147 }
148
149 // collect all preset information
150 $lines[$key] = array(
151 'icon' => $icon,
152 'title' => $title,
153 'descriptionHtml' => implode('<br />', $description),
154 'link' => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']
155 );
156
157 }
158
159 // render preset list
160 $content .= $this->taskObject->renderListMenu($lines);
161 } else {
162 // no presets found
163 $flashMessage = t3lib_div::makeInstance(
164 't3lib_FlashMessage',
165 $GLOBALS['LANG']->getLL('no-presets'),
166 '',
167 t3lib_FlashMessage::NOTICE
168 );
169 $content .= $flashMessage->render();
170 }
171 }
172
173 return $content;
174 }
175
176
177 /**
178 * Select presets for this user
179 *
180 * @return array Array of preset records
181 */
182 protected function getPresets() {
183 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
184 '*',
185 'tx_impexp_presets',
186 '(public > 0 OR user_uid=' . $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 protected function userTempFolder() {
200 foreach($GLOBALS['FILEMOUNTS'] as $filePathInfo) {
201 $tempFolder = $filePathInfo['path'] . '_temp_/';
202 if (@is_dir($tempFolder)) {
203 return $tempFolder;
204 }
205 }
206
207 return '';
208 }
209
210 }
211
212
213 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/task/class.tx_impexp_task.php'])) {
214 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/task/class.tx_impexp_task.php']);
215 }
216
217 ?>