[BUGFIX] Impexp is broken
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / Controller / ModuleFunctionController.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Controller;
3
4 /**
5 * Export Preset listing for the task center
6 *
7 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
8 */
9 class ModuleFunctionController extends mod_user_task {
10
11 /**
12 * Create preset overview for task center overview.
13 *
14 * @return string HTML for the task center overview listing.
15 * @todo Define visibility
16 */
17 public function overview_main() {
18 global $LANG;
19 // Create preset links:
20 $presets = $this->getPresets();
21 $opt = array();
22 if (is_array($presets)) {
23 foreach ($presets as $presetCfg) {
24 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
25 $opt[] = '
26 <tr class="bgColor4">
27 <td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display=' . $presetCfg['uid'] . '">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($title, 30)) . '</a>&nbsp;</td>
28 <td>' . ($presetCfg['item_uid'] ? $presetCfg['item_uid'] : '&nbsp;') . '</td>
29 <td>' . ($presetCfg['public'] ? '[Public]' : '&nbsp;') . '</td>
30 <td>' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? '[Own]' : '&nbsp;') . '</td>
31 </tr>';
32 }
33 if (sizeof($opt) > 0) {
34 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">' . implode('', $opt) . '</table>';
35 $presets .= '<a href="index.php?SET[function]=tx_impexp"><em>' . $LANG->getLL('link_allRecs') . '</em></a>';
36 } else {
37 $presets = '';
38 }
39 $icon = '<img src="' . $this->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('impexp') . 'export.gif" width="18" height="16" class="absmiddle" alt="" />';
40 $config = $this->mkMenuConfig($icon . $this->headLink('tx_impexp_modfunc1', 1), '', $presets);
41 }
42 return $config;
43 }
44
45 /**
46 * Main Task center module
47 *
48 * @return string HTML content.
49 * @todo Define visibility
50 */
51 public function main() {
52 if ($id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('display')) {
53 return $this->urlInIframe($this->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id, 1);
54 } else {
55 // Thumbnail folder and files:
56 $tempDir = $this->userTempFolder();
57 if ($tempDir) {
58 $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempDir, 'png,gif,jpg', 1);
59 }
60 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
61 $usernames = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames();
62 // Create preset links:
63 $presets = $this->getPresets();
64 $opt = array();
65 $opt[] = '
66 <tr class="bgColor5 tableheader">
67 <td>Icon:</td>
68 <td>Preset Title:</td>
69 <td>Public</td>
70 <td>Owner:</td>
71 <td>Page:</td>
72 <td>Path:</td>
73 <td>Meta data:</td>
74 </tr>';
75 if (is_array($presets)) {
76 foreach ($presets as $presetCfg) {
77 $configuration = unserialize($presetCfg['preset_data']);
78 $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
79 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
80 $opt[] = '
81 <tr class="bgColor4">
82 <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>
83 <td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display=' . $presetCfg['uid'] . '">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($title, 30)) . '</a>&nbsp;</td>
84 <td>' . ($presetCfg['public'] ? 'Yes' : '&nbsp;') . '</td>
85 <td>' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? 'Own' : '[' . $usernames[$presetCfg['user_uid']]['username'] . ']') . '</td>
86 <td>' . ($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;') . '</td>
87 <td>' . htmlspecialchars(($configuration['pagetree']['id'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($configuration['pagetree']['id'], $clause, 20) : '[Single Records]')) . '</td>
88 <td>
89 <strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />' . htmlspecialchars($configuration['meta']['description']) . ($configuration['meta']['notes'] ? '<br /><br /><strong>Notes:</strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>' : '') . '
90 </td>
91 </tr>';
92 }
93 $content = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">' . implode('', $opt) . '</table>';
94 }
95 }
96 // Output:
97 $theOutput .= $this->pObj->doc->spacer(5);
98 $theOutput .= $this->pObj->doc->section('Export presets', $content, 0, 1);
99 return $theOutput;
100 }
101
102 /*****************************
103 *
104 * Helper functions
105 *
106 *****************************/
107 /**
108 * Select presets for this user
109 *
110 * @return array Array of preset records
111 * @todo Define visibility
112 */
113 public function getPresets() {
114 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public>0 OR user_uid=' . intval($GLOBALS['BE_USER']->user['uid']) . ')', '', 'item_uid DESC, title');
115 return $presets;
116 }
117
118 /**
119 * Returns first temporary folder of the user account (from $FILEMOUNTS)
120 *
121 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
122 * @todo Define visibility
123 */
124 public function userTempFolder() {
125 global $FILEMOUNTS;
126 foreach ($FILEMOUNTS as $filePathInfo) {
127 $tempFolder = $filePathInfo['path'] . '_temp_/';
128 if (@is_dir($tempFolder)) {
129 return $tempFolder;
130 }
131 }
132 }
133
134 }
135
136
137 ?>