TYPO3 CMS  TYPO3_6-2
ImportExportTask.php
Go to the documentation of this file.
1 <?php
3 
17 
25 
31  protected $taskObject;
32 
36  public function __construct(\TYPO3\CMS\Taskcenter\Controller\TaskModuleController $taskObject) {
37  $this->taskObject = $taskObject;
38  $GLOBALS['LANG']->includeLLFile('EXT:impexp/locallang_csh.xlf');
39  }
40 
46  public function getTask() {
47  return $this->main();
48  }
49 
56  public function getOverview() {
57  return '';
58  }
59 
65  public function main() {
66  $content = '';
67  $id = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('display');
68  // If a preset is found, it is rendered using an iframe
69  if ($id > 0) {
71  'xMOD_tximpexp',
72  array(
73  'tx_impexp[action]' => 'export',
74  'preset[load]' => 1,
75  'preset[select]' => $id)
76  );
77  return $this->taskObject->urlInIframe($url, 1);
78  } else {
79  // Header
80  $content .= $this->taskObject->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description'));
81  $thumbnails = ($lines = array());
82  // Thumbnail folder and files:
83  $tempDir = $this->userTempFolder();
84  if ($tempDir) {
85  $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempDir, 'png,gif,jpg', 1);
86  }
87  $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
89  // Create preset links:
90  $presets = $this->getPresets();
91  // If any presets found
92  if (is_array($presets)) {
93  foreach ($presets as $key => $presetCfg) {
94  $configuration = unserialize($presetCfg['preset_data']);
95  $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
96  $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
97  $icon = 'EXT:impexp/export.gif';
98  $description = array();
99  // Is public?
100  if ($presetCfg['public']) {
101  $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:yes');
102  }
103  // Owner
104  $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']) . ']');
105  // Page & path
106  if ($configuration['pagetree']['id']) {
107  $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
108  $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($configuration['pagetree']['id'], $clause, 20));
109  } else {
110  $description[] = $GLOBALS['LANG']->getLL('single-record');
111  }
112  // Meta information
113  if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) {
114  $metaInformation = '';
115  if ($configuration['meta']['title']) {
116  $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
117  }
118  if ($configuration['meta']['description']) {
119  $metaInformation .= htmlspecialchars($configuration['meta']['description']);
120  }
121  if ($configuration['meta']['notes']) {
122  $metaInformation .= '<br /><br />
123  <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
124  <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
125  }
126  $description[] = '<br />' . $metaInformation;
127  }
128  // Collect all preset information
129  $lines[$key] = array(
130  'icon' => $icon,
131  'title' => $title,
132  'descriptionHtml' => implode('<br />', $description),
133  'link' => BackendUtility::getModuleUrl('user_task') . '&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']
134  );
135  }
136  // Render preset list
137  $content .= $this->taskObject->renderListMenu($lines);
138  } else {
139  // No presets found
141  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
142  $GLOBALS['LANG']->getLL('no-presets'),
143  '',
144  \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE
145  );
146  $content .= $flashMessage->render();
147  }
148  }
149  return $content;
150  }
151 
157  protected function getPresets() {
158  $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
159  '*',
160  'tx_impexp_presets',
161  '(public > 0 OR user_uid=' . $GLOBALS['BE_USER']->user['uid'] . ')',
162  '',
163  'item_uid DESC, title'
164  );
165  return $presets;
166  }
167 
173  protected function userTempFolder() {
174  // @TODO: This is broken since move to FAL
175  return '';
176  }
177 
178 }
__construct(\TYPO3\CMS\Taskcenter\Controller\TaskModuleController $taskObject)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static getUserNames($fields='username, usergroup, usergroup_cached_list, uid', $where='')
static getFilesInDir($path, $extensionList='', $prependPath=FALSE, $order='', $excludePattern='')
static getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]