/** * Gets all localizations of the current record. * * @param string $table The table * @param array $parentRec The current record * @param string $bgColClass Class for the background color of a column * @param string $pad Pad reference * @return string HTML table rows */ public function getLocalizations($table, $parentRec, $bgColClass, $pad) { $lines = array(); $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl']; if ($table != 'pages' && BackendUtility::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); $queryBuilder->getQueryContext()->setContext(QueryContextType::UNRESTRICTED); $queryBuilder->select('*')->from($table)->where($queryBuilder->expr()->eq($tcaCtrl['transOrigPointerField'], (int) $parentRec['uid']))->andWhere($queryBuilder->expr()->neq($tcaCtrl['languageField'], 0)); if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) { $queryBuilder->andWhere($queryBuilder->expr()->eq($tcaCtrl['delete'], 0)); } if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) { $queryBuilder->andWhere($queryBuilder->expr()->eq('t3ver_wsid', $parentRec['t3ver_wsid'])); } $rows = $queryBuilder->execute()->fetchAll(); if (is_array($rows)) { $modeData = ''; if ($pad == 'normal') { $mode = $this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut'; $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>'; } foreach ($rows as $rec) { $lines[] = ' <tr> <td nowrap="nowrap" class="col-icon">' . $this->iconFactory->getIconForRecord($table, $rec, Icon::SIZE_SMALL)->render() . '</td> <td nowrap="nowrap" width="95%">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $rec), $this->getBackendUser()->uc['titleLen'])) . $modeData . '</td> <td nowrap="nowrap" class="col-control"></td> </tr>'; } } } return implode('', $lines); }
/** * Shows the infos of a directmail record in a table * * @param array $row DirectMail DB record * * @return string the HTML output */ protected function renderRecordDetailsTable(array $row) { if (!$row['issent']) { if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_dmail')) { // $requestUri = rawurlencode(GeneralUtility::linkThisScript(array('sys_dmail_uid' => $row['uid'], 'createMailFrom_UID' => '', 'createMailFrom_URL' => ''))); $requestUri = BackendUtility::getModuleUrl('DirectMailNavFrame_DirectMail') . '&id=' . $this->id . '&CMD=info&sys_dmail_uid=' . $row['uid'] . '&fetchAtOnce=1'; $editParams = BackendUtility::editOnClick('&edit[sys_dmail][' . $row['uid'] . ']=edit', $GLOBALS['BACK_PATH'], $requestUri); $content = '<a href="#" onClick="' . $editParams . '" title="' . $this->getLanguageService()->getLL("dmail_edit") . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . '<b>' . $this->getLanguageService()->getLL('dmail_edit') . '</b></a>'; } else { $content = $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . ' (' . $this->getLanguageService()->getLL('dmail_noEdit_noPerms') . ')'; } } else { $content = $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . '(' . $this->getLanguageService()->getLL('dmail_noEdit_isSent') . ')'; } $content = '<thead > <th>' . DirectMailUtility::fName('subject') . ' <b>' . GeneralUtility::fixed_lgd_cs(htmlspecialchars($row['subject']), 60) . '</b></th> <th style="text-align: right;">' . $content . '</th> </thead>'; $nameArr = explode(',', 'from_name,from_email,replyto_name,replyto_email,organisation,return_path,priority,attachment,type,page,sendOptions,includeMedia,flowedFormat,sys_language_uid,plainParams,HTMLParams,encoding,charset,issent,renderedsize'); foreach ($nameArr as $name) { $content .= ' <tr class="db_list_normal"> <td>' . DirectMailUtility::fName($name) . '</td> <td>' . htmlspecialchars(BackendUtility::getProcessedValue('sys_dmail', $name, $row[$name])) . '</td> </tr>'; } $content = '<table width="460" class="table table-striped table-hover">' . $content . '</table>'; $sectionTitle = $this->iconFactory->getIconForRecord('sys_dmail', $row, Icon::SIZE_SMALL)->render() . ' ' . htmlspecialchars($row['subject']); return $this->doc->section($sectionTitle, $content, 1, 1, 0, true); }
/** * Gets all localizations of the current record. * * @param string $table The table * @param array $parentRec The current record * @param string $bgColClass Class for the background color of a column * @param string $pad Pad reference * @return string HTML table rows */ public function getLocalizations($table, $parentRec, $bgColClass, $pad) { $lines = array(); $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl']; if ($table != 'pages' && BackendUtility::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) { $where = array(); $where[] = $tcaCtrl['transOrigPointerField'] . '=' . (int) $parentRec['uid']; $where[] = $tcaCtrl['languageField'] . '<>0'; if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) { $where[] = $tcaCtrl['delete'] . '=0'; } if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) { $where[] = 't3ver_wsid=' . $parentRec['t3ver_wsid']; } $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $table, implode(' AND ', $where)); if (is_array($rows)) { $modeData = ''; if ($pad == 'normal') { $mode = $this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut'; $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>'; } foreach ($rows as $rec) { $lines[] = ' <tr> <td nowrap="nowrap" class="col-icon">' . $this->iconFactory->getIconForRecord($table, $rec, Icon::SIZE_SMALL)->render() . '</td> <td nowrap="nowrap" width="95%">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $rec), $this->getBackendUser()->uc['titleLen'])) . $modeData . '</td> <td nowrap="nowrap" class="col-control"></td> </tr>'; } } } return implode('', $lines); }
/** * Get the list of pages to show. * This function is called recursively * * @param array $pageArray The Page Array * @param array $lines Lines that have been processed up to this point * @param int $pageDepth The level of the current $pageArray being processed * @return array */ protected function getList($pageArray, $lines = array(), $pageDepth = 0) { if (!is_array($pageArray)) { return $lines; } foreach ($pageArray as $identifier => $_) { if (!MathUtility::canBeInterpretedAsInteger($identifier)) { continue; } $line = array(); $line['padding'] = $pageDepth * 20; if (isset($pageArray[$identifier . '_'])) { $line['link'] = htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $identifier))); $line['icon'] = $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render(); $line['title'] = htmlspecialchars('ID: ' . $identifier); $line['pageTitle'] = GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30); $line['includedFiles'] = $pageArray[$identifier . '_']['includeLines'] === 0 ? '' : $pageArray[$identifier . '_']['includeLines']; $line['lines'] = $pageArray[$identifier . '_']['writtenLines'] === 0 ? '' : $pageArray[$identifier . '_']['writtenLines']; } else { $line['link'] = ''; $line['icon'] = $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render(); $line['title'] = ''; $line['pageTitle'] = GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30); $line['includedFiles'] = ''; $line['lines'] = ''; } $lines[] = $line; $lines = $this->getList($pageArray[$identifier . '.'], $lines, $pageDepth + 1); } return $lines; }
/** * Returns the recent documents list as an array * * @param array $document * @param string $md5sum * @param bool $isRecentDoc * @param bool $isFirstDoc * @return array All recent documents as list-items */ protected function renderMenuEntry($document, $md5sum, $isRecentDoc = false, $isFirstDoc = false) { $table = $document[3]['table']; $uid = $document[3]['uid']; $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid); if (!is_array($record)) { // Record seems to be deleted return ''; } $label = htmlspecialchars(strip_tags(htmlspecialchars_decode($document[0]))); $icon = $this->iconFactory->getIconForRecord($table, $record, Icon::SIZE_SMALL)->render(); $link = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit') . '&' . $document[2]; $pageId = (int) $document[3]['uid']; if ($document[3]['table'] !== 'pages') { $pageId = (int) $document[3]['pid']; } $onClickCode = 'jump(' . GeneralUtility::quoteJSvalue($link) . ', \'web_list\', \'web\', ' . $pageId . '); TYPO3.OpendocsMenu.toggleMenu(); return false;'; if (!$isRecentDoc) { $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', true); // Open document $closeIcon = $this->iconFactory->getIcon('actions-close', Icon::SIZE_SMALL)->render('inline'); $entry = ' <li class="opendoc"> <a href="#" class="dropdown-list-link dropdown-link-list-add-close" onclick="' . htmlspecialchars($onClickCode) . '" target="content">' . $icon . ' ' . $label . '</a> <a href="#" class="dropdown-list-link-close" data-opendocsidentifier="' . $md5sum . '" title="' . $title . '">' . $closeIcon . '</a> </li>'; } else { // Recently used document $entry = ' <li> <a href="#" class="dropdown-list-link" onclick="' . htmlspecialchars($onClickCode) . '" target="content">' . $icon . ' ' . $label . '</a> </li>'; } return $entry; }
/** * 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('uid' => 'record-' . $el['table'] . '-' . $el['id'], '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; }
/** * Render the list of pages to show. * This function is called recursively * * @param array $pageArray The Page Array * @param array $lines Lines that have been processed up to this point * @param int $pageDepth The level of the current $pageArray being processed * @return array */ protected function renderList($pageArray, $lines = array(), $pageDepth = 0) { $cellStyle = 'padding-left: ' . $pageDepth * 20 . 'px'; if (!is_array($pageArray)) { return $lines; } foreach ($pageArray as $identifier => $_) { if (!MathUtility::canBeInterpretedAsInteger($identifier)) { continue; } if (isset($pageArray[$identifier . '_'])) { $lines[] = ' <tr> <td nowrap style="' . $cellStyle . '"> <a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $identifier))) . '" title="' . htmlspecialchars('ID: ' . $identifier) . '">' . $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render() . GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30) . '</a></td> <td>' . ($pageArray[$identifier . '_']['includeLines'] === 0 ? '' : $pageArray[$identifier . '_']['includeLines']) . '</td> <td>' . ($pageArray[$identifier . '_']['writtenLines'] === 0 ? '' : $pageArray[$identifier . '_']['writtenLines']) . '</td> </tr>'; } else { $lines[] = '<tr> <td nowrap style="' . $cellStyle . '">' . $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render() . GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30) . '</td> <td></td> <td></td> </tr>'; } $lines = $this->renderList($pageArray[$identifier . '.'], $lines, $pageDepth + 1); } return $lines; }
/** * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc. * Later on the command-icons are inserted here. * * @param array $data Current data * @return string The HTML code of the header */ protected function renderForeignRecordHeader(array $data) { $languageService = $this->getLanguageService(); $inlineConfig = $data['inlineParentConfig']; $foreignTable = $inlineConfig['foreign_table']; $rec = $data['databaseRow']; // Init: $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']); $objectId = $domObjectId . '-' . $foreignTable . '-' . $rec['uid']; $recordTitle = $data['recordTitle']; if (empty($recordTitle)) { $recordTitle = '<em>[' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', true) . ']</em>'; } $altText = BackendUtility::getRecordIconAltText($rec, $foreignTable); $iconImg = '<span title="' . $altText . '" id="' . htmlspecialchars($objectId) . '_icon' . '">' . $this->iconFactory->getIconForRecord($foreignTable, $rec, Icon::SIZE_SMALL)->render() . '</span>'; $label = '<span id="' . $objectId . '_label">' . $recordTitle . '</span>'; $ctrl = $this->renderForeignRecordHeaderControl($data); $thumbnail = false; // Renders a thumbnail for the header if (!empty($inlineConfig['appearance']['headerThumbnail']['field'])) { $fieldValue = $rec[$inlineConfig['appearance']['headerThumbnail']['field']]; $firstElement = array_shift(GeneralUtility::trimExplode('|', array_shift(GeneralUtility::trimExplode(',', $fieldValue)))); $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement)); if (!empty($fileUid)) { try { $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid); } catch (\InvalidArgumentException $e) { $fileObject = null; } if ($fileObject && $fileObject->isMissing()) { $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject); $thumbnail = $flashMessage->render(); } elseif ($fileObject) { $imageSetup = $inlineConfig['appearance']['headerThumbnail']; unset($imageSetup['field']); if (!empty($rec['crop'])) { $imageSetup['crop'] = $rec['crop']; } $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup); $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup); // Only use a thumbnail if the processing process was successful by checking if image width is set if ($processedImage->getProperty('width')) { $imageUrl = $processedImage->getPublicUrl(true); $thumbnail = '<img src="' . $imageUrl . '" ' . 'width="' . $processedImage->getProperty('width') . '" ' . 'height="' . $processedImage->getProperty('height') . '" ' . 'alt="' . htmlspecialchars($altText) . '" ' . 'title="' . htmlspecialchars($altText) . '">'; } } } } if (!empty($inlineConfig['appearance']['headerThumbnail']['field']) && $thumbnail) { $mediaContainer = '<div class="form-irre-header-cell form-irre-header-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>'; } else { $mediaContainer = '<div class="form-irre-header-cell form-irre-header-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>'; } $header = $mediaContainer . ' <div class="form-irre-header-cell form-irre-header-body">' . $label . '</div> <div class="form-irre-header-cell form-irre-header-control t3js-formengine-irre-control">' . $ctrl . '</div>'; return $header; }
/** * Tests the returns of tt_content + mock record with hidden flag * * @test */ public function getIconForRecordWithMockRecordWithHiddenFlagReturnsNormalIconAndOverlay() { $GLOBALS['TCA'] = array('tt_content' => array('ctrl' => array('enablecolumns' => array('disabled' => 'hidden'), 'typeicon_column' => 'CType', 'typeicon_classes' => array('text' => 'mimetypes-x-content-text')))); $mockRecord = $this->mockRecord; $mockRecord['hidden'] = '1'; $result = $this->subject->getIconForRecord('tt_content', $mockRecord)->render(); $this->assertContains('<span class="t3js-icon icon icon-size-default icon-state-default icon-mimetypes-x-content-text" data-identifier="mimetypes-x-content-text">', $result); $this->assertContains('<span class="icon-overlay icon-overlay-hidden">', $result); }
/** * Return one line in the form * * @param int|string $index An integer: the line counter for which to create the line. Use "#" to create an template for javascript (used by ExtJS) * @return string HTML code for one input line for one new page */ protected function getFormLine($index) { if (is_numeric($index)) { $label = $index + 1; } else { // used as template for JavaScript $index = '{0}'; $label = '{1}'; } $content = '' . '<div class="form-section" id="form-line-' . $index . '">' . '<div class="row">' . '<div class="form-group col-sm-6">' . '<label for="page_new_' . $index . '">' . $this->getLanguageService()->getLL('wiz_newPages_page') . ' ' . $label . ':' . '</label>' . '<div class="form-control-wrap">' . '<input class="form-control" type="text" id="page_new_' . $index . '" name="data[pages][NEW' . $index . '][title]" />' . '</div>' . '</div>' . '<div class="form-group col-sm-6">' . '<label>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.type') . '</label>' . '<div class="form-control-wrap">' . '<div class="input-group">' . '<div id="page_new_icon_' . $index . '" class="input-group-addon input-group-icon">' . $this->iconFactory->getIconForRecord('pages', array(), Icon::SIZE_SMALL)->render() . '</div>' . '<select class="form-control form-control-adapt t3js-wizardcrpages-select-doktype" name="data[pages][NEW' . $index . '][doktype]" data-target="#page_new_icon_' . $index . '">' . $this->typeSelectHtml . '</select>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; return $content; }
/** * Create the panel of buttons * * @return void */ protected function createButtons() { $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($this->request); $buttons = [['table' => 'tx_news_domain_model_news', 'label' => 'module.createNewNewsRecord', 'action' => 'newNews'], ['table' => 'tx_news_domain_model_tag', 'label' => 'module.createNewTag', 'action' => 'newTag'], ['table' => 'sys_category', 'label' => 'module.createNewCategory', 'action' => 'newCategory']]; foreach ($buttons as $key => $tableConfiguration) { if ($this->getBackendUser()->isAdmin() || GeneralUtility::inList($this->getBackendUser()->groupData['tables_modify'], $tableConfiguration['table'])) { $viewButton = $buttonBar->makeLinkButton()->setHref($uriBuilder->reset()->setRequest($this->request)->uriFor($tableConfiguration['action'], array(), 'Administration'))->setTitle($this->getLanguageService()->sL('LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:' . $tableConfiguration['label'], true))->setIcon($this->iconFactory->getIconForRecord($tableConfiguration['table'], [], Icon::SIZE_SMALL)); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $key); } } }
/** * Create configuration form * * @param array $inData Form configuration data * @return void */ public function makeConfigurationForm($inData) { $nameSuggestion = ''; // Page tree export options: if (isset($inData['pagetree']['id'])) { $this->standaloneView->assign('treeHTML', $this->treeHTML); $opt = array('-2' => $this->lang->getLL('makeconfig_tablesOnThisPage'), '-1' => $this->lang->getLL('makeconfig_expandedTree'), '0' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'), '1' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'), '2' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'), '3' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'), '4' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'), '999' => $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')); $this->standaloneView->assign('levelSelectOptions', $opt); $this->standaloneView->assign('tableSelectOptions', $this->getTableSelectOptions('pages')); $nameSuggestion .= 'tree_PID' . $inData['pagetree']['id'] . '_L' . $inData['pagetree']['levels']; } // Single record export: if (is_array($inData['record'])) { $records = array(); foreach ($inData['record'] as $ref) { $rParts = explode(':', $ref); $tName = $rParts[0]; $rUid = $rParts[1]; $nameSuggestion .= $tName . '_' . $rUid; $rec = BackendUtility::getRecordWSOL($tName, $rUid); if (!empty($rec)) { $records[] = array('icon' => $this->iconFactory->getIconForRecord($tName, $rec, Icon::SIZE_SMALL)->render(), 'title' => BackendUtility::getRecordTitle($tName, $rec, true), 'tableName' => $tName, 'recordUid' => $rUid); } } $this->standaloneView->assign('records', $records); } // Single tables/pids: if (is_array($inData['list'])) { // Display information about pages from which the export takes place $tableList = array(); foreach ($inData['list'] as $reference) { $referenceParts = explode(':', $reference); $tableName = $referenceParts[0]; if ($this->getBackendUser()->check('tables_select', $tableName)) { // If the page is actually the root, handle it differently // NOTE: we don't compare integers, because the number actually comes from the split string above if ($referenceParts[1] === '0') { $iconAndTitle = $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } else { $record = BackendUtility::getRecordWSOL('pages', $referenceParts[1]); $iconAndTitle = $this->iconFactory->getIconForRecord('pages', $record, Icon::SIZE_SMALL)->render() . BackendUtility::getRecordTitle('pages', $record, true); } $tableList[] = array('tableName' => $tableName, 'iconAndTitle' => $iconAndTitle, 'reference' => $reference); } } $this->standaloneView->assign('tableList', $tableList); } $this->standaloneView->assign('externalReferenceTableSelectOptions', $this->getTableSelectOptions()); $this->standaloneView->assign('externalStaticTableSelectOptions', $this->getTableSelectOptions()); $this->standaloneView->assign('nameSuggestion', $nameSuggestion); }
/** * Get the rendered page title including onclick menu * * @param $detailPid * @return string */ public function getPageRecordData($detailPid) { $pageRecord = BackendUtilityCore::getRecord('pages', $detailPid); if (is_array($pageRecord)) { $data = '<span title="Uid: ' . htmlspecialchars($pageRecord['uid']) . '">' . $this->iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>' . htmlspecialchars(BackendUtilityCore::getRecordTitle('pages', $pageRecord)); $content = BackendUtilityCore::wrapClickMenuOnIcon($data, 'pages', $pageRecord['uid'], true, '', '+info,edit'); } else { /** @var $message FlashMessage */ $text = sprintf($this->getLanguageService()->sL(self::LLPATH . 'pagemodule.pageNotAvailable', true), $detailPid); $message = GeneralUtility::makeInstance(FlashMessage::class, $text, '', FlashMessage::WARNING); $content = $message->render(); } return $content; }
/** * Get a prepared summary of records being translated * * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface */ public function getRecordLocalizeSummary(ServerRequestInterface $request, ResponseInterface $response) { $params = $request->getQueryParams(); if (!isset($params['pageId'], $params['colPos'], $params['destLanguageId'], $params['languageId'])) { $response = $response->withStatus(500); return $response; } $records = []; $result = $this->localizationRepository->getRecordsToCopyDatabaseResult($params['pageId'], $params['colPos'], $params['destLanguageId'], $params['languageId'], '*'); while ($row = $result->fetch()) { $records[] = ['icon' => $this->iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL)->render(), 'title' => $row[$GLOBALS['TCA']['tt_content']['ctrl']['label']], 'uid' => $row['uid']]; } $response->getBody()->write(json_encode($records)); return $response; }
/** * Queries a table for records and completely processes them * * Returns a two-dimensional array of almost finished records; the only need to be put into a <li>-structure * * If you subclass this class, you will most likely only want to overwrite the functions called from here, but not * this function itself * * @param array $params * @param int $recursionCounter The parent object * @return array Array of rows or FALSE if nothing found */ public function queryTable(&$params, $recursionCounter = 0) { $rows = []; $this->params =& $params; $start = $recursionCounter * 50; $this->prepareSelectStatement(); $this->prepareOrderByStatement(); $result = $this->queryBuilder->select('*')->from($this->table)->setFirstResult($start)->setMaxResults(50)->execute(); $allRowsCount = $result->rowCount(); if ($allRowsCount) { /** @var CharsetConverter $charsetConverter */ $charsetConverter = GeneralUtility::makeInstance(CharsetConverter::class); while ($row = $result->fetch()) { // check if we already have collected the maximum number of records if (count($rows) > $this->maxItems) { break; } $this->manipulateRecord($row); $this->makeWorkspaceOverlay($row); // check if the user has access to the record if (!$this->checkRecordAccess($row, $row['uid'])) { continue; } $spriteIcon = $this->iconFactory->getIconForRecord($this->table, $row, Icon::SIZE_SMALL)->render(); $uid = $row['t3ver_oid'] > 0 ? $row['t3ver_oid'] : $row['uid']; $path = $this->getRecordPath($row, $uid); if (strlen($path) > 30) { $croppedPath = '<abbr title="' . htmlspecialchars($path) . '">' . htmlspecialchars($charsetConverter->crop('utf-8', $path, 10) . '...' . $charsetConverter->crop('utf-8', $path, -20)) . '</abbr>'; } else { $croppedPath = htmlspecialchars($path); } $label = $this->getLabel($row); $entry = ['text' => '<span class="suggest-label">' . $label . '</span><span class="suggest-uid">[' . $uid . ']</span><br /> <span class="suggest-path">' . $croppedPath . '</span>', 'table' => $this->mmForeignTable ? $this->mmForeignTable : $this->table, 'label' => $label, 'path' => $path, 'uid' => $uid, 'style' => '', 'class' => isset($this->config['cssClass']) ? $this->config['cssClass'] : '', 'sprite' => $spriteIcon]; $rows[$this->table . '_' . $uid] = $this->renderRecord($row, $entry); } // if there are less records than we need, call this function again to get more records if (count($rows) < $this->maxItems && $allRowsCount >= 50 && $recursionCounter < $this->maxItems) { $tmp = self::queryTable($params, ++$recursionCounter); $rows = array_merge($tmp, $rows); } } return $rows; }
/** * Shows the status of the mailer engine. * TODO: Should really only show some entries, or provide a browsing interface. * * @return string List of the mailing status */ function cmd_mailerengine() { $invokeMessage = ""; // enable manual invocation of mailer engine; enabled by default $enableTrigger = !(isset($this->params['menu.']['dmail_mode.']['mailengine.']['disable_trigger']) && $this->params['menu.']['dmail_mode.']['mailengine.']['disable_trigger']); if ($enableTrigger && GeneralUtility::_GP('invokeMailerEngine')) { /* @var $flashMessage FlashMessage */ $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '<strong>' . $this->getLanguageService()->getLL('dmail_mailerengine_log') . '</strong><br />' . nl2br($this->invokeMEngine()), $this->getLanguageService()->getLL('dmail_mailerengine_invoked'), FlashMessage::INFO); $invokeMessage = $flashMessage->render(); } // Invoke engine if ($enableTrigger) { $out = '<p>' . $this->getLanguageService()->getLL('dmail_mailerengine_manual_explain') . '<br /><br /><a class="t3-link" href="' . BackendUtility::getModuleUrl('txdirectmailM1_txdirectmailM5') . '&id=' . $this->id . '&invokeMailerEngine=1"><strong>' . $this->getLanguageService()->getLL('dmail_mailerengine_invoke_now') . '</strong></a></p>'; $invokeMessage .= '<div style="padding-top: 20px;"></div>'; $invokeMessage .= $this->doc->section(BackendUtility::cshItem($this->cshTable, 'mailerengine_invoke', $GLOBALS["BACK_PATH"]) . $this->getLanguageService()->getLL('dmail_mailerengine_manual_invoke'), $out, 1, 1, 0, TRUE); $invokeMessage .= '<div style="padding-top: 20px;"></div>'; } // Display mailer engine status $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('uid,pid,subject,scheduled,scheduled_begin,scheduled_end', 'sys_dmail', 'pid=' . intval($this->id) . ' AND scheduled>0' . BackendUtility::deleteClause('sys_dmail'), '', 'scheduled DESC'); $out = '<tr class="t3-row-header"> <td> </td> <td><b>' . $this->getLanguageService()->getLL('dmail_mailerengine_subject') . ' </b></td> <td><b>' . $this->getLanguageService()->getLL('dmail_mailerengine_scheduled') . ' </b></td> <td><b>' . $this->getLanguageService()->getLL('dmail_mailerengine_delivery_begun') . ' </b></td> <td><b>' . $this->getLanguageService()->getLL('dmail_mailerengine_delivery_ended') . ' </b></td> <td style="text-align: center;"><b> ' . $this->getLanguageService()->getLL('dmail_mailerengine_number_sent') . ' </b></td> <td style="text-align: center;"><b> ' . $this->getLanguageService()->getLL('dmail_mailerengine_delete') . ' </b></td> </tr>'; while ($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) { $countres = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('count(*)', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=0' . ' AND html_sent>0'); list($count) = $GLOBALS["TYPO3_DB"]->sql_fetch_row($countres); $out .= '<tr class="db_list_normal"> <td>' . $this->iconFactory->getIconForRecord('sys_dmail', $row, Icon::SIZE_SMALL)->render() . '</td> <td>' . $this->linkDMail_record(htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['subject'], 100)) . ' ', $row['uid']) . '</td> <td>' . BackendUtility::datetime($row['scheduled']) . ' </td> <td>' . ($row['scheduled_begin'] ? BackendUtility::datetime($row['scheduled_begin']) : '') . ' </td> <td>' . ($row['scheduled_end'] ? BackendUtility::datetime($row['scheduled_end']) : '') . ' </td> <td style="text-align: center;">' . ($count ? $count : ' ') . '</td> <td style="text-align: center;">' . $this->deleteLink($row['uid']) . '</td> </tr>'; } $out = $invokeMessage . '<table class="table table-striped table-hover">' . $out . '</table>'; return $this->doc->section(BackendUtility::cshItem($this->cshTable, 'mailerengine_status', $GLOBALS["BACK_PATH"]) . $this->getLanguageService()->getLL('dmail_mailerengine_status'), $out, 1, 1, 0, TRUE); }
/** * Gets all localizations of the current record. * * @param string $table The table * @param array $parentRec The current record * @param string $bgColClass Class for the background color of a column * @param string $pad Pad reference * @return string HTML table rows */ public function getLocalizations($table, $parentRec, $bgColClass, $pad) { $lines = []; $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl']; if ($table !== 'pages' && BackendUtility::isTableLocalizable($table) && $table !== 'pages_language_overlay') { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $queryBuilder->select('*')->from($table)->where($queryBuilder->expr()->eq($tcaCtrl['transOrigPointerField'], $queryBuilder->createNamedParameter($parentRec['uid'], \PDO::PARAM_INT)), $queryBuilder->expr()->neq($tcaCtrl['languageField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))); if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) { $queryBuilder->andWhere($queryBuilder->expr()->eq('t3ver_wsid', $queryBuilder->createNamedParameter($parentRec['t3ver_wsid'], \PDO::PARAM_INT))); } $rows = $queryBuilder->execute()->fetchAll(); if (is_array($rows)) { foreach ($rows as $rec) { $lines[] = ['icon' => $this->iconFactory->getIconForRecord($table, $rec, Icon::SIZE_SMALL)->render(), 'title' => htmlspecialchars(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $rec), $this->getBackendUser()->uc['titleLen']))]; } } } return $lines; }
/** * Create the panel of buttons * * @return void */ protected function createButtons() { $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($this->request); $buttons = [['table' => 'tx_news_domain_model_news', 'label' => 'module.createNewNewsRecord', 'action' => 'newNews'], ['table' => 'tx_news_domain_model_tag', 'label' => 'module.createNewTag', 'action' => 'newTag'], ['table' => 'sys_category', 'label' => 'module.createNewCategory', 'action' => 'newCategory']]; foreach ($buttons as $key => $tableConfiguration) { if ($this->getBackendUser()->isAdmin() || GeneralUtility::inList($this->getBackendUser()->groupData['tables_modify'], $tableConfiguration['table'])) { $viewButton = $buttonBar->makeLinkButton()->setHref($uriBuilder->reset()->setRequest($this->request)->uriFor($tableConfiguration['action'], [], 'Administration'))->setTitle($this->getLanguageService()->sL('LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:' . $tableConfiguration['label']))->setIcon($this->iconFactory->getIconForRecord($tableConfiguration['table'], [], Icon::SIZE_SMALL)); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $key); } } /** @var Clipboard clipObj */ $clipBoard = GeneralUtility::makeInstance(Clipboard::class); $clipBoard->initializeClipboard(); $elFromTable = $clipBoard->elFromTable('tx_news_domain_model_news'); if (!empty($elFromTable)) { $viewButton = $buttonBar->makeLinkButton()->setHref($clipBoard->pasteUrl('', $this->pageUid))->setOnClick('return ' . $clipBoard->confirmMsg('pages', BackendUtilityCore::getRecord('pages', $this->pageUid), 'into', $elFromTable))->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:clip_pasteInto'))->setIcon($this->iconFactory->getIcon('actions-document-paste-into', ICON::SIZE_SMALL)); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 4); } }
/** * Gets the entries for the action menu * * @return array Array of action menu entries */ protected function initializeActionEntries() { $backendUser = $this->getBackendUser(); $databaseConnection = $this->getDatabaseConnection(); $actions = array(); if ($backendUser->isAdmin()) { $queryResource = $databaseConnection->exec_SELECTquery('*', 'sys_action', 'pid = 0 AND hidden=0', '', 'sys_action.sorting'); } else { $groupList = 0; if ($backendUser->groupList) { $groupList = $backendUser->groupList; } $queryResource = $databaseConnection->exec_SELECT_mm_query('sys_action.*', 'sys_action', 'sys_action_asgr_mm', 'be_groups', ' AND be_groups.uid IN (' . $groupList . ') AND sys_action.pid = 0 AND sys_action.hidden = 0', 'sys_action.uid', 'sys_action.sorting'); } if ($queryResource) { while ($actionRow = $databaseConnection->sql_fetch_assoc($queryResource)) { $actions[] = array($actionRow['title'], BackendUtility::getModuleUrl('user_task') . '&SET[mode]=tasks&SET[function]=sys_action.TYPO3\\CMS\\SysAction\\ActionTask&show=' . $actionRow['uid'], $this->iconFactory->getIconForRecord('sys_action', $actionRow, Icon::SIZE_SMALL)->render()); } $databaseConnection->sql_free_result($queryResource); } $this->actionEntries = $actions; }
/** * Show the compact information of a direct mail record * * @param array $row Direct mail record * * @return string The compact infos of the direct mail record */ function directMail_compactView($row) { // Render record: if ($row['type']) { $dmailData = $row['plainParams'] . ', ' . $row['HTMLParams']; } else { $page = BackendUtility::getRecord('pages', $row['page'], 'title'); $dmailData = $row['page'] . ', ' . htmlspecialchars($page['title']); $dmailInfo = DirectMailUtility::fName('plainParams') . ' ' . htmlspecialchars($row['plainParams'] . LF . DirectMailUtility::fName('HTMLParams') . $row['HTMLParams']) . '; ' . LF; } $dmailInfo .= $this->getLanguageService()->getLL('view_media') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'includeMedia', $row['includeMedia']) . '; ' . LF . $this->getLanguageService()->getLL('view_flowed') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'flowedFormat', $row['flowedFormat']); $dmailInfo = '<span title="' . $dmailInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>'; $fromInfo = $this->getLanguageService()->getLL('view_replyto') . ' ' . htmlspecialchars($row['replyto_name'] . ' <' . $row['replyto_email'] . '>') . '; ' . LF . DirectMailUtility::fName('organisation') . ' ' . htmlspecialchars($row['organisation']) . '; ' . LF . DirectMailUtility::fName('return_path') . ' ' . htmlspecialchars($row['return_path']); $fromInfo = '<span title="' . $fromInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>'; $mailInfo = DirectMailUtility::fName('priority') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'priority', $row['priority']) . '; ' . LF . DirectMailUtility::fName('encoding') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'encoding', $row['encoding']) . '; ' . LF . DirectMailUtility::fName('charset') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'charset', $row['charset']); $mailInfo = '<span title="' . $mailInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>'; $delBegin = $row["scheduled_begin"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-'; $delEnd = $row["scheduled_end"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-'; // count total recipient from the query_info $totalRecip = 0; $idLists = unserialize($row['query_info']); foreach ($idLists['id_lists'] as $idArray) { $totalRecip += count($idArray); } $sentRecip = $GLOBALS['TYPO3_DB']->sql_num_rows($GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail_maillog', 'mid=' . $row['uid'] . ' AND response_type = 0', '', 'rid ASC')); $out = '<table class="table table-striped table-hover">'; $out .= '<tr class="t3-row-header"><td colspan="3">' . $this->iconFactory->getIconForRecord('sys_dmail', $row)->render() . htmlspecialchars($row['subject']) . '</td></tr>'; $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_from') . '</td>' . '<td>' . htmlspecialchars($row['from_name'] . ' <' . htmlspecialchars($row['from_email']) . '>') . '</td>' . '<td>' . $fromInfo . '</td></tr>'; $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_dmail') . '</td>' . '<td>' . BackendUtility::getProcessedValue('sys_dmail', 'type', $row['type']) . ': ' . $dmailData . '</td>' . '<td>' . $dmailInfo . '</td></tr>'; $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_mail') . '</td>' . '<td>' . BackendUtility::getProcessedValue('sys_dmail', 'sendOptions', $row['sendOptions']) . ($row['attachment'] ? '; ' : '') . BackendUtility::getProcessedValue('sys_dmail', 'attachment', $row['attachment']) . '</td>' . '<td>' . $mailInfo . '</td></tr>'; $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_delivery_begin_end') . '</td>' . '<td>' . $delBegin . ' / ' . $delEnd . '</td>' . '<td> </td></tr>'; $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_recipient_total_sent') . '</td>' . '<td>' . $totalRecip . ' / ' . $sentRecip . '</td>' . '<td> </td></tr>'; $out .= '</table>'; $out .= '<div style="padding-top: 5px;"></div>'; return $out; }
/** * Add entries for a single record * * @param string $table Table name * @param int $uid Record uid * @param array $lines Output lines array (is passed by reference and modified) * @param string $preCode Pre-HTML code * @param bool $checkImportInPidRecord If you want import validation, you can set this so it checks if the import can take place on the specified page. * @return void */ public function singleRecordLines($table, $uid, &$lines, $preCode, $checkImportInPidRecord = false) { // Get record: $record = $this->dat['header']['records'][$table][$uid]; unset($this->remainHeader['records'][$table][$uid]); if (!is_array($record) && !($table === 'pages' && !$uid)) { $this->error('MISSING RECORD: ' . $table . ':' . $uid); } // Begin to create the line arrays information record, pInfo: $pInfo = array(); $pInfo['ref'] = $table . ':' . $uid; // Unknown table name: $lang = $this->getLanguageService(); if ($table === '_SOFTREF_') { $pInfo['preCode'] = $preCode; $pInfo['title'] = '<em>' . $lang->getLL('impexpcore_singlereco_softReferencesFiles', true) . '</em>'; } elseif (!isset($GLOBALS['TCA'][$table])) { // Unknown table name: $pInfo['preCode'] = $preCode; $pInfo['msg'] = 'UNKNOWN TABLE \'' . $pInfo['ref'] . '\''; $pInfo['title'] = '<em>' . htmlspecialchars($record['title']) . '</em>'; } else { // Otherwise, set table icon and title. // Import Validation (triggered by $this->display_import_pid_record) will show messages if import is not possible of various items. if (is_array($this->display_import_pid_record) && !empty($this->display_import_pid_record)) { if ($checkImportInPidRecord) { if (!$this->getBackendUser()->doesUserHaveAccess($this->display_import_pid_record, $table === 'pages' ? 8 : 16)) { $pInfo['msg'] .= '\'' . $pInfo['ref'] . '\' cannot be INSERTED on this page! '; } if (!$this->checkDokType($table, $this->display_import_pid_record['doktype']) && !$GLOBALS['TCA'][$table]['ctrl']['rootLevel']) { $pInfo['msg'] .= '\'' . $table . '\' cannot be INSERTED on this page type (change page type to \'Folder\'.) '; } } if (!$this->getBackendUser()->check('tables_modify', $table)) { $pInfo['msg'] .= 'You are not allowed to CREATE \'' . $table . '\' tables! '; } if ($GLOBALS['TCA'][$table]['ctrl']['readOnly']) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is READ ONLY! '; } if ($GLOBALS['TCA'][$table]['ctrl']['adminOnly'] && !$this->getBackendUser()->isAdmin()) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is ADMIN ONLY! '; } if ($GLOBALS['TCA'][$table]['ctrl']['is_static']) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is a STATIC TABLE! '; } if ((int) $GLOBALS['TCA'][$table]['ctrl']['rootLevel'] === 1) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' will be inserted on ROOT LEVEL! '; } $diffInverse = false; $recInf = null; if ($this->update) { // In case of update-PREVIEW we swap the diff-sources. $diffInverse = true; $recInf = $this->doesRecordExist($table, $uid, $this->showDiff ? '*' : ''); $pInfo['updatePath'] = $recInf ? htmlspecialchars($this->getRecordPath($recInf['pid'])) : '<strong>NEW!</strong>'; // Mode selector: $optValues = array(); $optValues[] = $recInf ? $lang->getLL('impexpcore_singlereco_update') : $lang->getLL('impexpcore_singlereco_insert'); if ($recInf) { $optValues['as_new'] = $lang->getLL('impexpcore_singlereco_importAsNew'); } if ($recInf) { if (!$this->global_ignore_pid) { $optValues['ignore_pid'] = $lang->getLL('impexpcore_singlereco_ignorePid'); } else { $optValues['respect_pid'] = $lang->getLL('impexpcore_singlereco_respectPid'); } } if (!$recInf && $this->getBackendUser()->isAdmin()) { $optValues['force_uid'] = sprintf($lang->getLL('impexpcore_singlereco_forceUidSAdmin'), $uid); } $optValues['exclude'] = $lang->getLL('impexpcore_singlereco_exclude'); if ($table === 'sys_file') { $pInfo['updateMode'] = ''; } else { $pInfo['updateMode'] = $this->renderSelectBox('tx_impexp[import_mode][' . $table . ':' . $uid . ']', $this->import_mode[$table . ':' . $uid], $optValues); } } // Diff view: if ($this->showDiff) { // For IMPORTS, get new id: if ($newUid = $this->import_mapId[$table][$uid]) { $diffInverse = false; $recInf = $this->doesRecordExist($table, $newUid, '*'); BackendUtility::workspaceOL($table, $recInf); } if (is_array($recInf)) { $pInfo['showDiffContent'] = $this->compareRecords($recInf, $this->dat['records'][$table . ':' . $uid]['data'], $table, $diffInverse); } } } $pInfo['preCode'] = $preCode . '<span title="' . htmlspecialchars($table . ':' . $uid) . '">' . $this->iconFactory->getIconForRecord($table, (array) $this->dat['records'][$table . ':' . $uid]['data'], Icon::SIZE_SMALL)->render() . '</span>'; $pInfo['title'] = htmlspecialchars($record['title']); // View page: if ($table === 'pages') { $viewID = $this->mode === 'export' ? $uid : ($this->doesImport ? $this->import_mapId['pages'][$uid] : 0); if ($viewID) { $pInfo['title'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($viewID)) . 'return false;">' . $pInfo['title'] . '</a>'; } } } $pInfo['class'] = $table == 'pages' ? 'bgColor4-20' : 'bgColor4'; $pInfo['type'] = 'record'; $pInfo['size'] = $record['size']; $lines[] = $pInfo; // File relations: if (is_array($record['filerefs'])) { $this->addFiles($record['filerefs'], $lines, $preCode); } // DB relations if (is_array($record['rels'])) { $this->addRelations($record['rels'], $lines, $preCode); } // Soft ref if (!empty($record['softrefs'])) { $preCode_A = $preCode . ' '; $preCode_B = $preCode . ' '; foreach ($record['softrefs'] as $info) { $pInfo = array(); $pInfo['preCode'] = $preCode_A . $this->iconFactory->getIcon('status-status-reference-soft', Icon::SIZE_SMALL)->render(); $pInfo['title'] = '<em>' . $info['field'] . ', "' . $info['spKey'] . '" </em>: <span title="' . htmlspecialchars($info['matchString']) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['matchString'], 60)) . '</span>'; if ($info['subst']['type']) { if (strlen($info['subst']['title'])) { $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $lang->getLL('impexpcore_singlereco_title', true) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['title'], 60)); } if (strlen($info['subst']['description'])) { $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $lang->getLL('impexpcore_singlereco_descr', true) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['description'], 60)); } $pInfo['title'] .= '<br/>' . $preCode_B . ($info['subst']['type'] == 'file' ? $lang->getLL('impexpcore_singlereco_filename', true) . ' <strong>' . $info['subst']['relFileName'] . '</strong>' : '') . ($info['subst']['type'] == 'string' ? $lang->getLL('impexpcore_singlereco_value', true) . ' <strong>' . $info['subst']['tokenValue'] . '</strong>' : '') . ($info['subst']['type'] == 'db' ? $lang->getLL('impexpcore_softrefsel_record', true) . ' <strong>' . $info['subst']['recordRef'] . '</strong>' : ''); } $pInfo['ref'] = 'SOFTREF'; $pInfo['size'] = ''; $pInfo['class'] = 'bgColor3'; $pInfo['type'] = 'softref'; $pInfo['_softRefInfo'] = $info; $pInfo['type'] = 'softref'; $mode = $this->softrefCfg[$info['subst']['tokenID']]['mode']; if ($info['error'] && $mode !== 'editable' && $mode !== 'exclude') { $pInfo['msg'] .= $info['error']; } $lines[] = $pInfo; // Add relations: if ($info['subst']['type'] == 'db') { list($tempTable, $tempUid) = explode(':', $info['subst']['recordRef']); $this->addRelations(array(array('table' => $tempTable, 'id' => $tempUid, 'tokenID' => $info['subst']['tokenID'])), $lines, $preCode_B, array(), ''); } // Add files: if ($info['subst']['type'] == 'file') { $this->addFiles(array($info['file_ID']), $lines, $preCode_B, '', $info['subst']['tokenID']); } } } }
/** * Creates a menu of the tables that can be listed by this function * Only tables which has records on the page will be included. * Notice: The function also fills in the internal variable $this->activeTables with icon/titles. * * @param int $id Page id from which we are listing records (the function will look up if there are records on the page) * @return string HTML output. */ public function getTableMenu($id) { // Initialize: $this->activeTables = array(); $theTables = array('tt_content'); // External tables: if (is_array($this->externalTables)) { $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables))); } $out = ''; // Traverse tables to check: foreach ($theTables as $tName) { // Check access and whether the proper extensions are loaded: if ($this->getBackendUser()->check('tables_select', $tName) && (isset($this->externalTables[$tName]) || GeneralUtility::inList('fe_users,tt_content', $tName) || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName))) { // Make query to count records from page: $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int) $id . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName)); // If records were found (or if "tt_content" is the table...): if ($c || GeneralUtility::inList('tt_content', $tName)) { // Add row to menu: $out .= ' <td><a href="#' . $tName . '" title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . '"></a>' . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render() . '</td>'; // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere) $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', true); $this->activeTables[$tName] = '<span title="' . $title . '">' . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render() . '</span>' . ' ' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true); } } } // Wrap cells in table tags: $out = ' <!-- Menu of tables on the page (table menu) --> <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu"> <tr>' . $out . ' </tr> </table>'; // Return the content: return $out; }
/** * Return the icon for a record - just a wrapper for two functions from \TYPO3\CMS\Backend\Utility\IconUtility * * @param array $row The record to get the icon for * @return string The path to the icon * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use IconFactory::getIconForRecord() directly */ protected function getIcon($row) { GeneralUtility::logDeprecatedFunction(); return $this->iconFactory->getIconForRecord($this->mmForeignTable ?: $this->table, $row, Icon::SIZE_SMALL)->render(); }
/** * Make reference display (what this elements points to) * * @param string $table Table name * @param string $ref Filename or uid * @return string HTML */ protected function makeRefFrom($table, $ref) { $lang = $this->getLanguageService(); $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_refindex', 'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int) $ref); // Compile information for title tag: $infoData = array(); $infoDataHeader = ''; if (!empty($rows)) { $infoDataHeader = ' <tr> <th class="col-icon"></th> <th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th> <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th> <th class="col-control"></th> </tr>'; } foreach ($rows as $row) { $record = BackendUtility::getRecord($row['ref_table'], $row['ref_uid']); if ($record) { $icon = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render(); $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']); $urlParameters = ['edit' => [$row['ref_table'] => [$row['ref_uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); $infoData[] = ' <tr> <td class="col-icon"> <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '"> ' . $icon . ' </a> </td> <td class="col-title"> <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '" > ' . BackendUtility::getRecordTitle($row['ref_table'], $record, true) . ' </a> </td> <td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], true) . '</td> <td>' . htmlspecialchars($row['ref_uid']) . '</td> <td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td> <td>' . htmlspecialchars($row['flexpointer']) . '</td> <td>' . htmlspecialchars($row['softref_key']) . '</td> <td>' . htmlspecialchars($row['sorting']) . '</td> <td>' . htmlspecialchars($row['ref_string']) . '</td> <td class="col-control">' . $actions . '</td> </tr>'; } else { $infoData[] = ' <tr> <td class="col-icon"></td> <td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . (int) $row['recuid'] . ')</td> <td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], true) . '</td> <td></td> <td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td> <td>' . htmlspecialchars($row['flexpointer']) . '</td> <td>' . htmlspecialchars($row['softref_key']) . '</td> <td>' . htmlspecialchars($row['sorting']) . '</td> <td>' . htmlspecialchars($row['ref_string']) . '</td> <td class="col-control"></td> </tr>'; } } if (empty($infoData)) { return ''; } return ' <div class="table-fit"> <table class="table table-striped table-hover"> <thead>' . $infoDataHeader . '</thead> <tbody>' . implode('', $infoData) . '</tbody> </table> </div>'; }
/** * Gets the icon for the shortcut * * @param array $row * @param array $shortcut * @return string Shortcut icon as img tag */ protected function getShortcutIcon($row, $shortcut) { $databaseConnection = $this->getDatabaseConnection(); $languageService = $this->getLanguageService(); $titleAttribute = htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut')); switch ($row['module_name']) { case 'xMOD_alt_doc.php': $table = $shortcut['table']; $recordid = $shortcut['recordid']; $icon = ''; if ($shortcut['type'] == 'edit') { // Creating the list of fields to include in the SQL query: $selectFields = $this->fieldArray; $selectFields[] = 'uid'; $selectFields[] = 'pid'; if ($table == 'pages') { $selectFields[] = 'module'; $selectFields[] = 'extendToSubpages'; $selectFields[] = 'doktype'; } if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) { $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']); } if ($GLOBALS['TCA'][$table]['ctrl']['type']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type']; } if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column']; } if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { $selectFields[] = 't3ver_state'; } // Unique list! $selectFields = array_unique($selectFields); $permissionClause = $table === 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; $sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table)); $result = $databaseConnection->exec_SELECT_queryArray($sqlQueryParts); $row = $databaseConnection->sql_fetch_assoc($result); $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIconForRecord($table, (array) $row, Icon::SIZE_SMALL)->render() . '</span>'; } elseif ($shortcut['type'] == 'new') { $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIconForRecord($table, array(), Icon::SIZE_SMALL)->render() . '</span>'; } break; case 'file_edit': $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon('mimetypes-text-html', Icon::SIZE_SMALL)->render() . '</span>'; break; case 'wizard_rte': $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon('mimetypes-word', Icon::SIZE_SMALL)->render() . '</span>'; break; default: if ($languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) { $icon = $languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']; // Change icon of fileadmin references - otherwise it doesn't differ with Web->List $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon); if (GeneralUtility::isAbsPath($icon)) { $icon = '../' . PathUtility::stripPathSitePrefix($icon); } // @todo: hardcoded width as we don't have a way to address module icons with an API yet. $icon = '<img src="' . htmlspecialchars($icon) . '" alt="' . $titleAttribute . '" width="16">'; } else { $icon = '<span title="' . $titleAttribute . '">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>'; } } return $icon; }
/** * Rendering a single row for the list * * @param string $table Table name * @param mixed[] $row Current record * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors) * @param string $titleCol Table field (column) where header value is found * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found * @param int $indent Indent from left. * @return string Table row for the element * @access private * @see getTable() */ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0) { if (!is_array($row)) { return ''; } $rowOutput = ''; $id_orig = null; // If in search mode, make sure the preview will show the correct page if ((string) $this->searchString !== '') { $id_orig = $this->id; $this->id = $row['pid']; } // Add special classes for first and last row $rowSpecial = ''; if ($cc == 1 && $indent == 0) { $rowSpecial .= ' firstcol'; } if ($cc == $this->totalRowCount || $cc == $this->iLimit) { $rowSpecial .= ' lastcol'; } $row_bgColor = ' class="' . $rowSpecial . '"'; // Overriding with versions background color if any: $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor; // Incr. counter. $this->counter++; // The icon with link $toolTip = BackendUtility::getRecordToolTip($row, $table); $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : ''; $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>'; $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg; // Preparing and getting the data-array $theData = array(); $localizationMarkerClass = ''; foreach ($this->fieldArray as $fCol) { if ($fCol == $titleCol) { $recTitle = BackendUtility::getRecordTitle($table, $row, false, true); $warning = ''; // If the record is edit-locked by another user, we will show a little warning sign: $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']); if ($lockInfo) { $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>'; } $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row); // Render thumbnails, if: // - a thumbnail column exists // - there is content in it // - the thumbnail column is visible for the current type $type = 0; if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) { $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type']; $type = $row[$typeColumn]; } // If current type doesn't exist, set it to 0 (or to 1 for historical reasons, // if 0 doesn't exist) if (!isset($GLOBALS['TCA'][$table]['types'][$type])) { $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1; } $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem']; if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) { $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol); } if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) { // It's a translated record with a language parent $localizationMarkerClass = ' localization'; } } elseif ($fCol == 'pid') { $theData[$fCol] = $row[$fCol]; } elseif ($fCol == '_PATH_') { $theData[$fCol] = $this->recPath($row['pid']); } elseif ($fCol == '_REF_') { $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']); } elseif ($fCol == '_CONTROL_') { $theData[$fCol] = $this->makeControl($table, $row); } elseif ($fCol == '_CLIPBOARD_') { $theData[$fCol] = $this->makeClip($table, $row); } elseif ($fCol == '_LOCALIZATION_') { list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row); $theData[$fCol] = $lC1; $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>'; } elseif ($fCol == '_LOCALIZATION_b') { // deliberately empty } else { $pageId = $table === 'pages' ? $row['uid'] : $row['pid']; $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId); $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]); if ($this->csvOutput) { $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']); } } } // Reset the ID if it was overwritten if ((string) $this->searchString !== '') { $this->id = $id_orig; } // Add row to CSV list: if ($this->csvOutput) { $this->addToCSV($row); } // Add classes to table cells $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass; $this->addElement_tdCssClass['_CONTROL_'] = 'col-control'; if ($this->getModule()->MOD_SETTINGS['clipBoard']) { $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard'; } $this->addElement_tdCssClass['_PATH_'] = 'col-path'; $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa'; $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb'; // Create element in table cells: $theData['uid'] = $row['uid']; if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) { $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]; } $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor); // Finally, return table row element: return $rowOutput; }
/** * The main processing method if this class * * @return string Information of the template status or the taken actions as HTML string */ public function main() { $lang = $this->getLanguageService(); $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_info.xlf'); $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = true; $e = $this->pObj->e; // Checking for more than one template an if, set a menu... $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } // Initialize $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); $tplRow = $GLOBALS['tplRow']; $saveId = 0; if ($existTemplate) { $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; } // Create extension template $newId = $this->pObj->createTemplate($this->pObj->id, $saveId); if ($newId) { // Switch to new template $urlParameters = ['id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId]; $url = BackendUtility::getModuleUrl('web_ts', $urlParameters); HttpUtility::redirect($url); } $tce = null; $theOutput = ''; if ($existTemplate) { // Update template ? $POST = GeneralUtility::_POST(); if (isset($POST['_savedok']) || isset($POST['_saveandclosedok'])) { // Set the data to be saved $recData = array(); $alternativeFileName = array(); if (is_array($POST['data'])) { foreach ($POST['data'] as $field => $val) { switch ($field) { case 'constants': case 'config': $recData['sys_template'][$saveId][$field] = $val; break; } } } if (!empty($recData)) { $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]); // Create new tce-object $tce = GeneralUtility::makeInstance(DataHandler::class); $tce->alternativeFileName = $alternativeFileName; // Initialize $tce->start($recData, array()); // Saved the stuff $tce->process_datamap(); // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) $tce->clear_cacheCmd('all'); // tce were processed successfully $this->tce_processed = true; // re-read the template ... $this->initialize_editor($this->pObj->id, $template_uid); $tplRow = $GLOBALS['tplRow']; // reload template menu $manyTemplatesMenu = $this->pObj->templateMenu(); } } // Hook post updating template/TCE processing if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) { $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook']; if (is_array($postTCEProcessingHook)) { $hookParameters = array('POST' => $POST, 'tce' => $tce); foreach ($postTCEProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $content = '<a href="#" class="t3-js-clickmenutrigger" data-table="sys_template" data-uid="' . $tplRow['uid'] . '" data-listframe="1">' . $this->iconFactory->getIconForRecord('sys_template', $tplRow, Icon::SIZE_SMALL)->render() . '</a><strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . (trim($tplRow['sitetitle']) ? htmlspecialchars(' (' . $tplRow['sitetitle'] . ')') : ''); $theOutput .= '<h2>' . $lang->getLL('templateInformation', true) . '</h2><div>' . $content . '</div>'; if ($manyTemplatesMenu) { $theOutput .= '<div>' . $manyTemplatesMenu . '</div>'; } $theOutput .= '<div style="padding-top: 10px;"></div>'; $numberOfRows = 35; // If abort pressed, nothing should be edited: if (isset($POST['_saveandclosedok'])) { unset($e); } if (isset($e['constants'])) { $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['constants']) . '</textarea>'; $outCode .= '<input type="hidden" name="e[constants]" value="1">'; // Display "Include TypoScript file content?" checkbox $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"'); $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />'; $theOutput .= '<div style="padding-top: 15px;"></div>'; $theOutput .= '<h3>' . $lang->getLL('constants', true) . '</h3>'; $theOutput .= $outCode; } if (isset($e['config'])) { $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['config']) . '</textarea>'; $outCode .= '<input type="hidden" name="e[config]" value="1">'; // Display "Include TypoScript file content?" checkbox $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"'); $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />'; $theOutput .= '<div style="padding-top: 15px;"></div>'; $theOutput .= '<h3>' . $lang->getLL('setup', true) . '</h3>'; $theOutput .= $outCode; } // Processing: $outCode = ''; $outCode .= $this->tableRow($lang->getLL('title'), htmlspecialchars($tplRow['title']), 'title', $tplRow['uid']); $outCode .= $this->tableRow($lang->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle', $tplRow['uid']); $outCode .= $this->tableRow($lang->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description', $tplRow['uid']); $outCode .= $this->tableRow($lang->getLL('constants'), sprintf($lang->getLL('editToView'), trim($tplRow['constants']) ? count(explode(LF, $tplRow['constants'])) : 0), 'constants', $tplRow['uid']); $outCode .= $this->tableRow($lang->getLL('setup'), sprintf($lang->getLL('editToView'), trim($tplRow['config']) ? count(explode(LF, $tplRow['config'])) : 0), 'config', $tplRow['uid']); $outCode = '<div class="table-fit"><table class="table table-striped table-hover">' . $outCode . '</table></div>'; // Edit all icon: $urlParameters = ['edit' => ['sys_template' => [$tplRow['uid'] => 'edit']], 'createExtension' => 0, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); $title = $lang->getLL('editTemplateRecord', true); $icon = $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render(); $outCode .= '<br /><a class="btn btn-default" href="' . htmlspecialchars($url) . '"><strong>' . $icon . ' ' . $title . '</strong></a>'; $theOutput .= '<div>' . $outCode . '</div>'; // hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows); foreach ($postOutputProcessingHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } } else { $theOutput .= $this->pObj->noTemplate(1); } return $theOutput; }
/** * Creates a "position tree" based on the page tree. * * @param int $id Current page id * @param array $pageinfo Current page record. * @param string $perms_clause Page selection permission clause. * @param string $R_URI Current REQUEST_URI * @return string HTML code for the tree. */ public function positionTree($id, $pageinfo, $perms_clause, $R_URI) { // Make page tree object: /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $pageTree */ $pageTree = GeneralUtility::makeInstance($this->pageTreeClassName); $pageTree->init(' AND ' . $perms_clause); $pageTree->addField('pid'); // Initialize variables: $this->R_URI = $R_URI; $this->elUid = $id; // Create page tree, in $this->depth levels. $pageTree->getTree($pageinfo['pid'], $this->depth); // Initialize variables: $saveLatestUid = []; $latestInvDepth = $this->depth; // Traverse the tree: $lines = []; foreach ($pageTree->tree as $cc => $dat) { if ($latestInvDepth > $dat['invertedDepth']) { $margin = 'style="margin-left: ' . ($dat['invertedDepth'] * 16 + 9) . 'px;"'; $lines[] = '<ul class="list-tree" ' . $margin . '>'; } // Make link + parameters. $latestInvDepth = $dat['invertedDepth']; $saveLatestUid[$latestInvDepth] = $dat; if (isset($pageTree->tree[$cc - 1])) { $prev_dat = $pageTree->tree[$cc - 1]; // If current page, subpage? if ($prev_dat['row']['uid'] == $id) { // 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages... if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth'])) { end($lines); $lines[] = '<li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id, 1)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li>'; } } // If going down if ($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth']) { $prevPid = $pageTree->tree[$cc]['row']['pid']; } elseif ($prev_dat['invertedDepth'] < $pageTree->tree[$cc]['invertedDepth']) { // If going up // First of all the previous level should have an icon: if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid'])) { $prevPid = -$prev_dat['row']['uid']; end($lines); $lines[] = '<li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $prev_dat['row']['pid'], 2)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li>'; } // Then set the current prevPid $prevPid = -$prev_dat['row']['pid']; if ($prevPid !== $dat['row']['pid']) { $lines[] = '</ul>'; } } else { // In on the same level $prevPid = -$prev_dat['row']['uid']; } } else { // First in the tree $prevPid = $dat['row']['pid']; } // print arrow on the same level if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) { $lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'], 3)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>'; } // The line with the icon and title: $toolTip = BackendUtility::getRecordToolTip($dat['row'], 'pages'); $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord('pages', $dat['row'], Icon::SIZE_SMALL)->render() . '</span>'; $lines[] = '<span class="text-nowrap">' . $icon . $this->linkPageTitle($this->boldTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($dat['row']['title'], $this->getBackendUser()->uc['titleLen'])), $dat, $id), $dat['row']) . '</span>'; } // If the current page was the last in the tree: $prev_dat = end($pageTree->tree); if ($prev_dat['row']['uid'] == $id) { if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id)) { $lines[] = '<ul class="list-tree" style="margin-left: 25px"><li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id, 4)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>'; } } for ($a = $latestInvDepth; $a <= $this->depth; $a++) { $dat = $saveLatestUid[$a]; $prevPid = -$dat['row']['uid']; if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) { if ($latestInvDepth < $dat['invertedDepth']) { $lines[] = '</ul>'; } $lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'], 5)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>'; } } $code = '<ul class="list-tree">'; foreach ($lines as $line) { if (substr($line, 0, 3) === '<ul' || substr($line, 0, 4) === '</ul') { $code .= $line; } else { $code .= '<li>' . $line . '</li>'; } } $code .= '</ul>'; return $code; }
/** * Setting page icon with clickmenu + uid for docheader * * @param array $pageRecord Current page * @return string Page info */ protected function getPageInfo($pageRecord) { // Add icon with clickmenu, etc: // If there IS a real page if (is_array($pageRecord) && $pageRecord['uid']) { $alttext = BackendUtility::getRecordIconAltText($pageRecord, 'pages'); $iconImg = '<span title="' . htmlspecialchars($alttext) . '">' . $this->iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>'; // Make Icon: $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']); $uid = $pageRecord['uid']; $title = BackendUtility::getRecordTitle('pages', $pageRecord); } else { // On root-level of page tree // Make Icon $iconImg = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . '</span>'; if ($GLOBALS['BE_USER']->user['admin']) { $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', 0); } else { $theIcon = $iconImg; } $uid = '0'; $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } // Setting icon with clickmenu + uid $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . ' [' . $uid . ']</strong>'; return $pageInfo; }
/** * Records overview * * @return void */ public function func_records() { /** @var $admin DatabaseIntegrityCheck */ $admin = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class); $admin->genTree(0); // Pages stat $pageStatistic = ['total_pages' => ['icon' => $this->iconFactory->getIconForRecord('pages', [], Icon::SIZE_SMALL)->render(), 'count' => count($admin->page_idArray)], 'hidden_pages' => ['icon' => $this->iconFactory->getIconForRecord('pages', ['hidden' => 1], Icon::SIZE_SMALL)->render(), 'count' => $admin->recStats['hidden']], 'deleted_pages' => ['icon' => $this->iconFactory->getIconForRecord('pages', ['deleted' => 1], Icon::SIZE_SMALL)->render(), 'count' => count($admin->recStats['deleted']['pages'])]]; $lang = $this->getLanguageService(); // Doktype $doktypes = []; $doktype = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items']; if (is_array($doktype)) { foreach ($doktype as $setup) { if ($setup[1] != '--div--') { $doktypes[] = ['icon' => $this->iconFactory->getIconForRecord('pages', ['doktype' => $setup[1]], Icon::SIZE_SMALL)->render(), 'title' => $lang->sL($setup[0]) . ' (' . $setup[1] . ')', 'count' => (int) $admin->recStats['doktype'][$setup[1]]]; } } } // Tables and lost records $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray)); $id_list = rtrim($id_list, ','); $admin->lostRecords($id_list); if ($admin->fixLostRecord(GeneralUtility::_GET('fixLostRecords_table'), GeneralUtility::_GET('fixLostRecords_uid'))) { $admin = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class); $admin->genTree(0); $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray)); $id_list = rtrim($id_list, ','); $admin->lostRecords($id_list); } $tableStatistic = []; $countArr = $admin->countRecords($id_list); if (is_array($GLOBALS['TCA'])) { foreach ($GLOBALS['TCA'] as $t => $value) { if ($GLOBALS['TCA'][$t]['ctrl']['hideTable']) { continue; } if ($t === 'pages' && $admin->lostPagesList !== '') { $lostRecordCount = count(explode(',', $admin->lostPagesList)); } else { $lostRecordCount = count($admin->lRecords[$t]); } if ($countArr['all'][$t]) { $theNumberOfRe = (int) $countArr['non_deleted'][$t] . '/' . $lostRecordCount; } else { $theNumberOfRe = ''; } $lr = ''; if (is_array($admin->lRecords[$t])) { foreach ($admin->lRecords[$t] as $data) { if (!GeneralUtility::inList($admin->lostPagesList, $data['pid'])) { $lr .= '<div class="record"><a href="' . htmlspecialchars(BackendUtility::getModuleUrl('system_dbint') . '&SET[function]=records&fixLostRecords_table=' . $t . '&fixLostRecords_uid=' . $data['uid']) . '" title="' . htmlspecialchars($lang->getLL('fixLostRecord')) . '">' . $this->iconFactory->getIcon('status-dialog-error', Icon::SIZE_SMALL)->render() . '</a>uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</div>'; } else { $lr .= '<div class="record-noicon">uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</div>'; } } } $tableStatistic[$t] = ['icon' => $this->iconFactory->getIconForRecord($t, [], Icon::SIZE_SMALL)->render(), 'title' => $lang->sL($GLOBALS['TCA'][$t]['ctrl']['title']), 'count' => $theNumberOfRe, 'lostRecords' => $lr]; } } $this->view->assignMultiple(['pages' => $pageStatistic, 'doktypes' => $doktypes, 'tables' => $tableStatistic]); }