2 namespace TYPO3\CMS\Impexp\Task
;
4 /***************************************************************
7 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
8 * (c) 2010-2011 Georg Ringer (typo3@ringerge.org)
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.
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * This class provides a textarea to save personal notes
30 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @author Georg Ringer <typo3@ringerge.org>
33 class ImportExportTask
implements \TYPO3\CMS\Taskcenter\TaskInterface
{
36 * Back-reference to the calling reports module
38 * @var tx_reports_Module $taskObject
40 protected $taskObject;
45 public function __construct(\TYPO3\CMS\Taskcenter\Controller\TaskModuleController
$taskObject) {
46 $this->taskObject
= $taskObject;
47 $GLOBALS['LANG']->includeLLFile('EXT:impexp/locallang_csh.xml');
51 * This method renders the report
53 * @return string The status report as HTML
55 public function getTask() {
60 * Render an optional additional information for the 1st view in taskcenter.
63 * @return string Overview as HTML
65 public function getOverview() {
70 * Main Task center module
72 * @return string HTML content.
74 public function main() {
76 $id = intval(\TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('display'));
77 // If a preset is found, it is rendered using an iframe
79 $url = $GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id;
80 return $this->taskObject
->urlInIframe($url, 1);
83 $content .= $this->taskObject
->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description'));
84 $thumbnails = ($lines = array());
85 // Thumbnail folder and files:
86 $tempDir = $this->userTempFolder();
88 $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($tempDir, 'png,gif,jpg', 1);
90 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
91 $usernames = \TYPO3\CMS\Backend\Utility\BackendUtility
::getUserNames();
92 // Create preset links:
93 $presets = $this->getPresets();
94 // If any presets found
95 if (is_array($presets)) {
96 foreach ($presets as $key => $presetCfg) {
97 $configuration = unserialize($presetCfg['preset_data']);
98 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
99 $title = strlen($presetCfg['title']) ?
$presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
100 $icon = 'EXT:impexp/export.gif';
101 $description = array();
103 if ($presetCfg['public']) {
104 $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
107 $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']) . ']');
109 if ($configuration['pagetree']['id']) {
110 $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
111 $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordPath($configuration['pagetree']['id'], $clause, 20));
113 $description[] = $GLOBALS['LANG']->getLL('single-record');
116 if ($configuration['meta']['title'] ||
$configuration['meta']['description'] ||
$configuration['meta']['notes']) {
117 $metaInformation = '';
118 if ($configuration['meta']['title']) {
119 $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
121 if ($configuration['meta']['description']) {
122 $metaInformation .= htmlspecialchars($configuration['meta']['description']);
124 if ($configuration['meta']['notes']) {
125 $metaInformation .= '<br /><br />
126 <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
127 <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
129 $description[] = '<br />' . $metaInformation;
131 // Collect all preset information
132 $lines[$key] = array(
135 'descriptionHtml' => implode('<br />', $description),
136 'link' => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']
139 // Render preset list
140 $content .= $this->taskObject
->renderListMenu($lines);
143 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('no-presets'), '', \TYPO3\CMS\Core\Messaging\FlashMessage
::NOTICE
);
144 $content .= $flashMessage->render();
151 * Select presets for this user
153 * @return array Array of preset records
155 protected function getPresets() {
156 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public > 0 OR user_uid=' . $GLOBALS['BE_USER']->user
['uid'] . ')', '', 'item_uid DESC, title');
161 * Returns first temporary folder of the user account (from $FILEMOUNTS)
163 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
165 protected function userTempFolder() {
166 foreach ($GLOBALS['FILEMOUNTS'] as $filePathInfo) {
167 $tempFolder = $filePathInfo['path'] . '_temp_/';
168 if (@is_dir
($tempFolder)) {