/** * Action to edit records * * @param array $record sys_action record * @return string list of records */ protected function viewEditRecord($record) { $content = ''; $actionList = array(); $dbAnalysis = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\RelationHandler::class); $dbAnalysis->setFetchAllFields(true); $dbAnalysis->start($record['t4_recordsToEdit'], '*'); $dbAnalysis->getFromDB(); // collect the records foreach ($dbAnalysis->itemArray as $el) { $path = BackendUtility::getRecordPath($el['id'], $this->taskObject->perms_clause, $this->getBackendUser()->uc['titleLen']); $record = BackendUtility::getRecord($el['table'], $dbAnalysis->results[$el['table']][$el['id']]); $title = BackendUtility::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]); $description = $this->getLanguageService()->sL($GLOBALS['TCA'][$el['table']]['ctrl']['title'], true); // @todo: which information could be needful if (isset($record['crdate'])) { $description .= ' - ' . BackendUtility::dateTimeAge($record['crdate']); } $link = BackendUtility::getModuleUrl('record_edit', array('edit[' . $el['table'] . '][' . $el['id'] . ']' => 'edit', 'returnUrl' => $this->moduleUrl), false, true); $actionList[$el['id']] = array('title' => $title, 'description' => BackendUtility::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]), 'descriptionHtml' => $description, 'link' => $link, 'icon' => '<span title="' . htmlspecialchars($path) . '">' . $this->iconFactory->getIconForRecord($el['table'], $dbAnalysis->results[$el['table']][$el['id']], Icon::SIZE_SMALL)->render() . '</span>'); } // Render the record list $content .= $this->taskObject->renderListMenu($actionList); return $content; }
/** * Action to edit records * * @param array $record sys_action record * @return string list of records */ protected function viewEditRecord($record) { $content = ''; $actionList = array(); $dbAnalysis = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler'); $dbAnalysis->setFetchAllFields(TRUE); $dbAnalysis->start($record['t4_recordsToEdit'], '*'); $dbAnalysis->getFromDB(); // collect the records foreach ($dbAnalysis->itemArray as $el) { $path = BackendUtility::getRecordPath($el['id'], $this->taskObject->perms_clause, $GLOBALS['BE_USER']->uc['titleLen']); $record = BackendUtility::getRecord($el['table'], $dbAnalysis->results[$el['table']][$el['id']]); $title = BackendUtility::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]); $description = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$el['table']]['ctrl']['title'], TRUE); // @todo: which information could be needful if (isset($record['crdate'])) { $description .= ' - ' . BackendUtility::dateTimeAge($record['crdate']); } $actionList[$el['id']] = array('title' => $title, 'description' => BackendUtility::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]), 'descriptionHtml' => $description, 'link' => $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '&edit[' . $el['table'] . '][' . $el['id'] . ']=edit', 'icon' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($el['table'], $dbAnalysis->results[$el['table']][$el['id']], array('title' => htmlspecialchars($path)))); } // Render the record list $content .= $this->taskObject->renderListMenu($actionList); return $content; }
/** * Action to create a list of records of a specific table and pid * * @param array $record sys_action record * @return string list of records */ protected function viewRecordList($record) { $content = ''; $this->id = (int) $record['t3_listPid']; $this->table = $record['t3_tables']; if ($this->id == 0) { $this->addMessage($this->getLanguageService()->getLL('action_notReady'), $this->getLanguageService()->getLL('action_error'), FlashMessage::ERROR); $content .= $this->renderFlashMessages(); return $content; } // Loading current page record and checking access: $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->taskObject->perms_clause); $access = is_array($this->pageinfo) ? 1 : 0; // If there is access to the page, then render the list contents and set up the document template object: if ($access) { // Initialize the dblist object: $dblist = GeneralUtility::makeInstance(\TYPO3\CMS\SysAction\ActionList::class); $dblist->script = GeneralUtility::getIndpEnv('REQUEST_URI'); $dblist->calcPerms = $this->getBackendUser()->calcPerms($this->pageinfo); $dblist->thumbs = $this->getBackendUser()->uc['thumbnailsByDefault']; $dblist->returnUrl = $this->taskObject->returnUrl; $dblist->allFields = 1; $dblist->localizationView = 1; $dblist->showClipboard = 0; $dblist->disableSingleTableView = 1; $dblist->pageRow = $this->pageinfo; $dblist->counter++; $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => ''); $dblist->modTSconfig = $this->taskObject->modTSconfig; $dblist->dontShowClipControlPanels = !$this->taskObject->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers']; // Initialize the listing object, dblist, for rendering the list: $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(GeneralUtility::_GP('pointer'), 0, 100000); $dblist->start($this->id, $this->table, $this->pointer, $this->taskObject->search_field, $this->taskObject->search_levels, $this->taskObject->showLimit); $dblist->setDispFields(); // Render the list of tables: $dblist->generateList(); // Add JavaScript functions to the page: $this->taskObject->getModuleTemplate()->addJavaScriptCode('ActionTaskInlineJavascript', ' function jumpExt(URL,anchor) { var anc = anchor?anchor:""; window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc; return false; } function jumpSelf(URL) { window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:""); return false; } function setHighlight(id) { top.fsMod.recentIds["web"]=id; top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { top.content.nav_frame.refresh_nav(); } } ' . $dblist->CBfunctions() . ' function editRecords(table,idList,addParams,CBflag) { window.location.href="' . BackendUtility::getModuleUrl('record_edit', array('returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'))) . '&edit["+table+"]["+idList+"]=edit"+addParams; } function editList(table,idList) { var list=""; // Checking how many is checked, how many is not var pointer=0; var pos = idList.indexOf(","); while (pos!=-1) { if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) { list+=idList.substr(pointer,pos-pointer)+","; } pointer=pos+1; pos = idList.indexOf(",",pointer); } if (cbValue(table+"|"+idList.substr(pointer))) { list+=idList.substr(pointer)+","; } return list ? list : idList; } T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . '; if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . '; '); // Setting up the context sensitive menu: $this->taskObject->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); // Begin to compile the whole page $content .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">' . $dblist->HTMLcode . '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /> </form>'; // If a listing was produced, create the page footer with search form etc: // Making field select box (when extended view for a single table is enabled): if ($dblist->HTMLcode && $dblist->table) { $content .= $dblist->fieldSelectBox($dblist->table); } } else { // Not enough rights to access the list view or the page $this->addMessage($this->getLanguageService()->getLL('action_error-access'), $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; }