[TASK] Remove superfluous parenthesis in sysexts
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / classes / Task / ImportExportTask.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Task;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
8 * (c) 2010-2011 Georg Ringer (typo3@ringerge.org)
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
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 * 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 class ImportExportTask implements \TYPO3\CMS\Taskcenter\TaskInterface {
36
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(\TYPO3\CMS\Taskcenter\Controller\TaskModuleController $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('display'));
79 // If a preset is found, it is rendered using an iframe
80 if ($id > 0) {
81 $url = $GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Extension\ExtensionManager::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id;
82 return $this->taskObject->urlInIframe($url, 1);
83 } else {
84 // Header
85 $content .= $this->taskObject->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description'));
86 $thumbnails = ($lines = array());
87 // Thumbnail folder and files:
88 $tempDir = $this->userTempFolder();
89 if ($tempDir) {
90 $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempDir, 'png,gif,jpg', 1);
91 }
92 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
93 $usernames = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames();
94 // Create preset links:
95 $presets = $this->getPresets();
96 // If any presets found
97 if (is_array($presets)) {
98 foreach ($presets as $key => $presetCfg) {
99 $configuration = unserialize($presetCfg['preset_data']);
100 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
101 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
102 $icon = 'EXT:impexp/export.gif';
103 $description = array();
104 // Is public?
105 if ($presetCfg['public']) {
106 $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
107 }
108 // Owner
109 $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']) . ']');
110 // Page & path
111 if ($configuration['pagetree']['id']) {
112 $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
113 $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($configuration['pagetree']['id'], $clause, 20));
114 } else {
115 $description[] = $GLOBALS['LANG']->getLL('single-record');
116 }
117 // Meta information
118 if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) {
119 $metaInformation = '';
120 if ($configuration['meta']['title']) {
121 $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
122 }
123 if ($configuration['meta']['description']) {
124 $metaInformation .= htmlspecialchars($configuration['meta']['description']);
125 }
126 if ($configuration['meta']['notes']) {
127 $metaInformation .= '<br /><br />
128 <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
129 <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
130 }
131 $description[] = '<br />' . $metaInformation;
132 }
133 // Collect all preset information
134 $lines[$key] = array(
135 'icon' => $icon,
136 'title' => $title,
137 'descriptionHtml' => implode('<br />', $description),
138 'link' => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']
139 );
140 }
141 // Render preset list
142 $content .= $this->taskObject->renderListMenu($lines);
143 } else {
144 // No presets found
145 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('no-presets'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
146 $content .= $flashMessage->render();
147 }
148 }
149 return $content;
150 }
151
152 /**
153 * Select presets for this user
154 *
155 * @return array Array of preset records
156 */
157 protected function getPresets() {
158 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public > 0 OR user_uid=' . $GLOBALS['BE_USER']->user['uid'] . ')', '', 'item_uid DESC, title');
159 return $presets;
160 }
161
162 /**
163 * Returns first temporary folder of the user account (from $FILEMOUNTS)
164 *
165 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
166 */
167 protected function userTempFolder() {
168 foreach ($GLOBALS['FILEMOUNTS'] as $filePathInfo) {
169 $tempFolder = $filePathInfo['path'] . '_temp_/';
170 if (@is_dir($tempFolder)) {
171 return $tempFolder;
172 }
173 }
174 return '';
175 }
176
177 }
178
179
180 ?>