/** * This method renders the task * * @return string The task as HTML */ public function getTask() { $content = ''; $show = (int)GeneralUtility::_GP('show'); foreach ($this->hookObjects as $hookObject) { if (method_exists($hookObject, 'getTask')) { $show = $hookObject->getTask($show, $this); } } // If no task selected, render the menu if ($show == 0) { $content .= $this->taskObject->description($this->getLanguageService()->getLL('sys_action'), $this->getLanguageService()->getLL('description')); $content .= $this->renderActionList(); } else { $record = BackendUtility::getRecord('sys_action', $show); // If the action is not found if (count($record) == 0) { $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $this->getLanguageService()->getLL('action_error-not-found', TRUE), $this->getLanguageService()->getLL('action_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $content .= $flashMessage->render(); } else { // Render the task $content .= $this->taskObject->description($record['title'], $record['description']); // Output depends on the type switch ($record['type']) { case 1: $content .= $this->viewNewBackendUser($record); break; case 2: $content .= $this->viewSqlQuery($record); break; case 3: $content .= $this->viewRecordList($record); break; case 4: $content .= $this->viewEditRecord($record); break; case 5: $content .= $this->viewNewRecord($record); break; default: $flashMessage = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $this->getLanguageService()->getLL('action_noType', TRUE), $this->getLanguageService()->getLL('action_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR ); $content .= '<br />' . $flashMessage->render(); } } } return $content; }
/** * This method renders the task * * @return string The task as HTML */ public function getTask() { $content = ''; $show = (int) GeneralUtility::_GP('show'); foreach ($this->hookObjects as $hookObject) { if (method_exists($hookObject, 'getTask')) { $show = $hookObject->getTask($show, $this); } } // If no task selected, render the menu if ($show == 0) { $content .= $this->taskObject->description($this->getLanguageService()->getLL('sys_action'), $this->getLanguageService()->getLL('description')); $content .= $this->renderActionList(); } else { $record = BackendUtility::getRecord('sys_action', $show); // If the action is not found if (empty($record)) { $this->addMessage($this->getLanguageService()->getLL('action_error-not-found'), $this->getLanguageService()->getLL('action_error'), FlashMessage::ERROR); } else { // Render the task $content .= $this->taskObject->description($record['title'], $record['description']); // Output depends on the type switch ($record['type']) { case 1: $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/SysAction/ActionTask'); $content .= $this->viewNewBackendUser($record); break; case 2: $content .= $this->viewSqlQuery($record); break; case 3: $content .= $this->viewRecordList($record); break; case 4: $content .= $this->viewEditRecord($record); break; case 5: $content .= $this->viewNewRecord($record); break; default: $this->addMessage($this->getLanguageService()->getLL('action_noType'), $this->getLanguageService()->getLL('action_error'), FlashMessage::ERROR); $content .= $this->renderFlashMessages(); } } } return $content; }
/** * Main Task center module * * @return string HTML content. */ public function main() { $content = ''; $id = (int) GeneralUtility::_GP('display'); // If a preset is found, it is rendered using an iframe if ($id > 0) { $url = BackendUtility::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export', 'preset[load]' => 1, 'preset[select]' => $id)); return $this->taskObject->urlInIframe($url); } else { // Header $lang = $this->getLanguageService(); $content .= $this->taskObject->description($lang->getLL('.alttitle'), $lang->getLL('.description')); $clause = $this->getBackendUser()->getPagePermsClause(1); $usernames = BackendUtility::getUserNames(); // Create preset links: $presets = $this->getPresets(); // If any presets found if (is_array($presets) && !empty($presets)) { $lines = []; foreach ($presets as $key => $presetCfg) { $configuration = unserialize($presetCfg['preset_data']); $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']'; $icon = 'EXT:impexp/Resources/Public/Images/export.gif'; $description = array(); // Is public? if ($presetCfg['public']) { $description[] = $lang->getLL('task.public') . ': ' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:yes'); } // Owner $description[] = $lang->getLL('task.owner') . ': ' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? $lang->getLL('task.own') : '[' . htmlspecialchars($usernames[$presetCfg['user_uid']]['username']) . ']'); // Page & path if ($configuration['pagetree']['id']) { $description[] = $lang->getLL('task.page') . ': ' . $configuration['pagetree']['id']; $description[] = $lang->getLL('task.path') . ': ' . htmlspecialchars(BackendUtility::getRecordPath($configuration['pagetree']['id'], $clause, 20)); } else { $description[] = $lang->getLL('single-record'); } // Meta information if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) { $metaInformation = ''; if ($configuration['meta']['title']) { $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />'; } if ($configuration['meta']['description']) { $metaInformation .= htmlspecialchars($configuration['meta']['description']); } if ($configuration['meta']['notes']) { $metaInformation .= '<br /><br /> <strong>' . $lang->getLL('notes') . ': </strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>'; } $description[] = '<br />' . $metaInformation; } // Collect all preset information $lines[$key] = array('icon' => $icon, 'title' => $title, 'descriptionHtml' => implode('<br />', $description), 'link' => BackendUtility::getModuleUrl('user_task') . '&SET[function]=impexp.TYPO3\\CMS\\Impexp\\Task\\ImportExportTask&display=' . $presetCfg['uid']); } // Render preset list $content .= $this->taskObject->renderListMenu($lines); } else { // No presets found $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('no-presets'), $lang->getLL('.alttitle'), FlashMessage::NOTICE); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } } return $content; }
/** * Main Task center module * * @return string HTML content. */ public function main() { $content = ''; $id = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('display'); // If a preset is found, it is rendered using an iframe if ($id > 0) { $url = BackendUtility::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export', 'preset[load]' => 1, 'preset[select]' => $id)); return $this->taskObject->urlInIframe($url, 1); } else { // Header $content .= $this->taskObject->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description')); $thumbnails = $lines = array(); // Thumbnail folder and files: $tempDir = $this->userTempFolder(); if ($tempDir) { $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempDir, 'png,gif,jpg', 1); } $clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $usernames = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames(); // Create preset links: $presets = $this->getPresets(); // If any presets found if (is_array($presets)) { foreach ($presets as $key => $presetCfg) { $configuration = unserialize($presetCfg['preset_data']); $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']]; $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']'; $icon = 'EXT:impexp/export.gif'; $description = array(); // Is public? if ($presetCfg['public']) { $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:yes'); } // Owner $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']) . ']'); // Page & path if ($configuration['pagetree']['id']) { $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id']; $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($configuration['pagetree']['id'], $clause, 20)); } else { $description[] = $GLOBALS['LANG']->getLL('single-record'); } // Meta information if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) { $metaInformation = ''; if ($configuration['meta']['title']) { $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />'; } if ($configuration['meta']['description']) { $metaInformation .= htmlspecialchars($configuration['meta']['description']); } if ($configuration['meta']['notes']) { $metaInformation .= '<br /><br /> <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>'; } $description[] = '<br />' . $metaInformation; } // Collect all preset information $lines[$key] = array('icon' => $icon, 'title' => $title, 'descriptionHtml' => implode('<br />', $description), 'link' => BackendUtility::getModuleUrl('user_task') . '&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']); } // Render preset list $content .= $this->taskObject->renderListMenu($lines); } else { // No presets found $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('no-presets'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); $content .= $flashMessage->render(); } } return $content; }