/** * Retrieve page details from given page id * * @param integer $pageId * @param string $as * @return string Rendered string */ public function render($pageId, $as = 'page') { $this->templateVariableContainer->add($as, $this->pageRepository->getPage($pageId)); $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); return $output; }
/** * return void */ protected function collectPages() { $rootline = $this->pageRepository->getRootLine($GLOBALS['TSFE']->id); foreach ($rootline as $page) { $this->collectPage($this->pageRepository->getPage($page['uid'])); } $this->generateUrlCollection(); }
/** * Initializes the class. */ public function __construct() { $this->databaseConnection = $GLOBALS['TYPO3_DB']; $this->tsfe = $GLOBALS['TSFE']; // Warning! It is important to init the new object and not reuse any existing object // $this->pageRepository->sys_language_uid must stay 0 because we will do overlays manually $this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $this->pageRepository->init(FALSE); }
/** * @test * @dataProvider conteRowsOfDifferentTypesDataProvider */ public function migrationOfLegacyFieldsIsOnlyDoneWhenRelationFieldIsVisibleInType($dbRow, $expectedCaption, $fileProperties) { $fileReference = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileReference', array(), array(), '', FALSE); $fileReference->expects($this->once())->method('getProperties')->will($this->returnValue($fileProperties)); $fileReference->expects($this->any())->method('getOriginalFile')->will($this->returnValue($this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE))); $fileReference->expects($this->any())->method('getPublicUrl')->will($this->returnValue('path/to/file')); $this->pageRepositoryMock->expects($this->any())->method('getFileReferences')->will($this->returnValue(array($fileReference))); \TYPO3\CMS\Core\Resource\Service\FrontendContentAdapterService::modifyDBRow($dbRow, 'tt_content'); $this->assertSame($expectedCaption, $dbRow['imagecaption']); }
/** * renders the given theme * * @return void */ public function indexAction() { $this->templateName = $this->evaluateTypoScript('plugin.tx_themes.settings.templateName'); $templateFile = $this->getTemplateFile(); if ($templateFile !== NULL) { $this->view->setTemplatePathAndFilename($templateFile); } $this->view->assign('templateName', $this->templateName); $this->view->assign('theme', $this->themeRepository->findByPageOrRootline($GLOBALS['TSFE']->id)); $this->view->assign('page', $this->pageRepository->getPage($GLOBALS['TSFE']->id)); $this->view->assign('data', $this->pageRepository->getPage($GLOBALS['TSFE']->id)); $this->view->assign('TSFE', $GLOBALS['TSFE']); }
/** * This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality. * * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method. * @return bool */ protected static function evaluateCondition($arguments = NULL) { $pageUid = $arguments['pageUid']; $respectSiteRoot = $arguments['respectSiteRoot']; if (NULL === $pageUid || TRUE === empty($pageUid) || 0 === intval($pageUid)) { $pageUid = $GLOBALS['TSFE']->id; } $pageSelect = new PageRepository(); $page = $pageSelect->getPage($pageUid); if (TRUE === (bool) $respectSiteRoot && TRUE === isset($page['is_siteroot']) && TRUE === (bool) $page['is_siteroot']) { return FALSE; } return TRUE === isset($page['pid']) && 0 < $page['pid']; }
/** * @param array $arguments * @return bool */ protected static function evaluateCondition($arguments = null) { $pageUid = $arguments['pageUid']; $respectSiteRoot = $arguments['respectSiteRoot']; if (null === $pageUid || true === empty($pageUid) || 0 === intval($pageUid)) { $pageUid = $GLOBALS['TSFE']->id; } $pageSelect = new PageRepository(); $page = $pageSelect->getPage($pageUid); if ($respectSiteRoot && isset($page['is_siteroot']) && $page['is_siteroot']) { return false; } return true === isset($page['pid']) && 0 < $page['pid']; }
/** * Creates $this->sysPage if it does not exist yet * * @return void */ protected function createSysPageIfNecessary() { if (!is_object($this->sysPage)) { $this->sysPage = $this->apiWrapper->getPageRepository(); $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn()); } }
/** * Queries the database for the page record and returns it. * * @param int $uid Page id * @throws \RuntimeException * @return array */ protected function getRecordArray($uid) { $currentCacheIdentifier = $this->getCacheIdentifier($uid); if (!isset(self::$pageRecordCache[$currentCacheIdentifier])) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $row = $queryBuilder->select(...self::$rootlineFields)->from('pages')->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)), $queryBuilder->expr()->neq('doktype', $queryBuilder->createNamedParameter(PageRepository::DOKTYPE_RECYCLER, \PDO::PARAM_INT)))->execute()->fetch(); if (empty($row)) { throw new \RuntimeException('Could not fetch page data for uid ' . $uid . '.', 1343589451); } $this->pageContext->versionOL('pages', $row, false, true); $this->pageContext->fixVersioningPid('pages', $row); if (is_array($row)) { if ($this->languageUid > 0) { $row = $this->pageContext->getPageOverlay($row, $this->languageUid); } $row = $this->enrichWithRelationFields(isset($row['_PAGES_OVERLAY_UID']) ? $row['_PAGES_OVERLAY_UID'] : $uid, $row); self::$pageRecordCache[$currentCacheIdentifier] = $row; } } if (!is_array(self::$pageRecordCache[$currentCacheIdentifier])) { throw new \RuntimeException('Broken rootline. Could not resolve page with uid ' . $uid . '.', 1343464101); } return self::$pageRecordCache[$currentCacheIdentifier]; }
/** * recursive function for building a page array * * @param array $page the current page * @param int $depth the current depth * @param array $pages contains all pages so far * @param int $level the tree level required for the UI grid * @return array */ protected function getPageTree($page, $depth, $pages = [], $level = 0) { // default query settings $fields = '*'; $sortField = 'sorting'; // decrease the depth $depth--; // add the current language value if ($this->modParams['lang'] > 0) { $page['sys_language_uid'] = $this->languages[$page['_PAGES_OVERLAY_LANGUAGE'] ?: 0]; } if ($this->showResults) { $results = $this->getResults($page); $page['results'] = $results['Percentage']['count']; } $page['level'] = $level; // add the page to the pages array $pages[] =& $page; // fetch subpages and set the treelevel if ($depth > 0) { $subPages = $this->pageRepository->getMenu($page['uid'], $fields, $sortField); if (count($subPages) > 0) { $page['$$treeLevel'] = $level; $level++; foreach ($subPages as &$subPage) { $pages = $this->getPageTree($subPage, $depth, $pages, $level); } } } return $pages; }
/** * Creates $this->sysPage if it does not exist yet * * @return void */ protected function createSysPageIfNecessary() { if (!is_object($this->sysPage)) { $this->sysPage = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn()); } }
/** * Queries the database for the page record and returns it. * * @param integer $uid Page id * @throws RuntimeException * @return array */ protected function getRecordArray($uid) { if (!isset(self::$pageRecordCache[$this->getCacheIdentifier($uid)])) { if (!is_array($GLOBALS['TCA']['pages']['columns'])) { if (isset($GLOBALS['TSFE'])) { $GLOBALS['TSFE']->includeTCA($GLOBALS['TSFE']->TCAloaded); } \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('pages'); } $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(implode(',', self::$rootlineFields), 'pages', 'uid = ' . intval($uid) . ' AND pages.deleted = 0 AND pages.doktype <> ' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER); if (empty($row)) { throw new \RuntimeException('Could not fetch page data for uid ' . $uid . '.', 1343589451); } $this->pageContext->versionOL('pages', $row, FALSE, TRUE); $this->pageContext->fixVersioningPid('pages', $row); if (is_array($row)) { $row = $this->enrichWithRelationFields($uid, $row); $this->pageContext->getPageOverlay($row, $this->languageUid); self::$pageRecordCache[$this->getCacheIdentifier($uid)] = $row; } } if (!is_array(self::$pageRecordCache[$this->getCacheIdentifier($uid)])) { throw new \RuntimeException('Broken rootline. Could not resolve page with uid ' . $uid . '.', 1343464101); } return self::$pageRecordCache[$this->getCacheIdentifier($uid)]; }
/** * generates a string for the URL * * @param array $uParts the parts of the URL * @return string the URL string */ function getUrlStr($uParts) { $baseURL = $this->getBaseURL(); if (is_array($uParts) && GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') == $uParts['host']) { $m = array(); // do we have an id? if (preg_match('/(?:^|&)id=([0-9a-z_]+)/', $uParts['query'], $m)) { $isInt = MathUtility::canBeInterpretedAsInteger($m[1]); if ($isInt) { $uid = intval($m[1]); } else { $uid = $this->sys_page->getPageIdFromAlias($m[1]); } $temp_root_line = $this->sys_page->getRootLine($uid); $temp_page = array_shift($temp_root_line); // array_shift reverses the array (rootline has numeric index in the wrong order!) $temp_root_line = array_reverse($temp_root_line); $query = preg_replace('/(?:^|&)id=([0-9a-z_]+)/', '', $uParts['query']); $urlstr = GeneralUtility::fixed_lgd_cs($temp_page['title'], 50) . GeneralUtility::fixed_lgd_cs($query ? ' / ' . $query : '', 20); } else { $urlstr = $baseURL . substr($uParts['path'], 1); $urlstr .= $uParts['query'] ? '?' . $uParts['query'] : ''; $urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : ''; } } else { $urlstr = ($uParts['host'] ? $uParts['scheme'] . '://' . $uParts['host'] : $baseURL) . $uParts['path']; $urlstr .= $uParts['query'] ? '?' . $uParts['query'] : ''; $urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : ''; } return $urlstr; }
/** * Render method * * @param integer $pageUid * @param boolean $respectSiteRoot * @return string */ public function render($pageUid = NULL, $respectSiteRoot = FALSE) { if (NULL === $pageUid || TRUE === empty($pageUid) || 0 === intval($pageUid)) { $pageUid = $GLOBALS['TSFE']->id; } $pageSelect = new PageRepository(); $page = $pageSelect->getPage($pageUid); if (TRUE === (bool) $respectSiteRoot && TRUE === isset($page['is_siteroot']) && TRUE === (bool) $page['is_siteroot']) { return $this->renderElseChild(); } if (TRUE === isset($page['pid']) && 0 < $page['pid']) { return $this->renderThenChild(); } else { return $this->renderElseChild(); } }
/** * @param null $data * @param null $hashVars * @return null */ public function setCache($data = null, $hashVars = null) { $lifetime = mktime(23, 59, 59) + 1 - time(); $cacheID = $this->getCacheID(array($hashVars)); PageRepository::storeHash($cacheID, serialize($data), $this->_extKey . '_cache', $lifetime); return $data; }
/** * Resolves shortcuts for the shortcut of type PageRepository::SHORTCUT_MODE_PARENT_PAGE. * * @param array $page * @param array $processedPages * @return array */ private function resolveShortcutParentPage(array $page, array &$processedPages) { $page = $this->pageRepository->getPage($page['pid'], FALSE); if ($page && $page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) { $page = $this->resolveShortcutProcess($page, $processedPages); } return $page; }
/** * @test */ public function enableFieldsDoesNotHideVersionedRecordsWhenCheckingVersionOverlays() { $table = $this->getUniqueId('aTable'); $GLOBALS['TCA'] = array($table => array('ctrl' => array('versioningWS' => 2))); $this->pageSelectObject->versioningPreview = TRUE; $this->pageSelectObject->init(FALSE); $conditions = $this->pageSelectObject->enableFields($table, -1, array(), TRUE); $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.t3ver_state<=0')), 'No versioning placeholders'); $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.pid<>-1')), 'No ecords from page -1'); }
/** * Fixes page id if it is not a direct numeric page id. */ protected function fixPageId() { if (!MathUtility::canBeInterpretedAsInteger($this->urlParameters['id'])) { // Seems to be an alias $alias = $this->urlParameters['id']; $this->urlParameters['id'] = $this->pageRepository->getPageIdFromAlias($alias); if ($this->urlParameters['id'] === 0) { throw new \Exception(sprintf('Page with alias "%s" does not exist.', $alias), 1457183797); } } }
public function setCache($data, $funcName = null, $hashVars = null) { $tmp = $data; if (!is_array($data)) { $tmp = array('__string' => $data); } // Um Mitternacht endet der Cache $lifetime = mktime(23, 59, 59) + 1 - time(); \TYPO3\CMS\Frontend\Page\PageRepository::storeHash($this->getCacheHash($hashVars, $funcName), serialize($tmp), $this->getCacheIdentifier($funcName), $lifetime); return $data; }
/** * renders the given theme. * * @return void */ public function indexAction() { $this->templateName = $this->evaluateTypoScript('plugin.tx_themes.settings.templateName'); $templateFile = $this->getTemplateFile(); if ($templateFile !== null) { $this->view->setTemplatePathAndFilename($templateFile); } $this->view->assign('templateName', $this->templateName); $frontendController = $this->getFrontendController(); $this->view->assign('theme', $this->themeRepository->findByPageOrRootline($frontendController->id)); // Get page data $pageArray = $this->pageRepository->getPage($frontendController->id); $pageArray['icon'] = ''; // Map page icon if (isset($pageArray['tx_themes_icon']) && $pageArray['tx_themes_icon'] != '') { $setup = $frontendController->tmpl->setup; $pageArray['icon'] = $setup['lib.']['icons.']['cssMap.'][$pageArray['tx_themes_icon']]; } $this->view->assign('page', $pageArray); $this->view->assign('data', $pageArray); $this->view->assign('TSFE', $frontendController); }
/** * Get alle images on the given pages * * @param array $pages * * @return array */ protected function getImagesByPages(array $pages) { $images = array(); if (!sizeof($pages)) { return $images; } $enabledFields = $this->pageRepository->enableFields('sys_file_reference'); $enabledFields .= $this->pageRepository->enableFields('tt_content'); $enabledFields .= $this->pageRepository->enableFields('pages'); $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_file_reference.*', 'sys_file_reference, tt_content, pages', 'sys_file_reference.tablenames = \'tt_content\' AND sys_file_reference.fieldname =\'image\' AND sys_file_reference.uid_foreign = tt_content.uid AND tt_content.pid = pages.uid AND pages.uid IN (' . implode(',', $pages) . ') ' . $enabledFields); foreach ($rows as $row) { $images[] = $this->resourceFactory->getFileReferenceObject($row['uid'], $row); } return $images; }
/** * @return array */ protected function getTypoScriptTemplatesInRootline() { $rootline = $this->pageRepository->getRootLine($this->configurationManager->getCurrentPageId()); $pageUids = array(); foreach ($rootline as $page) { $pageUids[] = $page['uid']; } if (empty($pageUids)) { return array(); } $condition = 'deleted = 0 AND hidden = 0 AND starttime <= :starttime AND (endtime = 0 OR endtime > :endtime) AND pid IN (' . implode(',', $pageUids) . ')'; $parameters = array(':starttime' => $GLOBALS['SIM_ACCESS_TIME'], ':endtime' => $GLOBALS['SIM_ACCESS_TIME']); $rootTypoScriptTemplates = $this->recordService->preparedGet('sys_template', 'pid', $condition, $parameters); return $rootTypoScriptTemplates; }
/** * Wrapper function for \TYPO3\CMS\Frontend\Page\PageRepository::enableFields() since it is no * longer accessible statically. * * Returns a part of a WHERE clause which will filter out records with * start/end times or deleted/hidden/fe_groups fields set to values that * should de-select them according to the current time, preview settings or * user login. * Is using the $TCA arrays "ctrl" part where the key "enablefields" * determines for each table which of these features applies to that table. * * @param string $tableName * table name found in the $TCA array * @param int $showHidden * If $showHidden is set (0/1), any hidden-fields in records are * ignored. NOTICE: If you call this function, consider what to do * with the show_hidden parameter. * @param array $ignoreArray * Array you can pass where keys can be "disabled", "starttime", * "endtime", "fe_group" (keys from "enablefields" in TCA) and if set * they will make sure that part of the clause is not added. Thus * disables the specific part of the clause. For previewing etc. * @param bool $noVersionPreview * If set, enableFields will be applied regardless of any versioning * preview settings which might otherwise disable enableFields. * * @return string the WHERE clause starting like " AND ...=... AND ...=..." * * @throws InvalidArgumentException */ public static function enableFields($tableName, $showHidden = -1, array $ignoreArray = array(), $noVersionPreview = false) { if (!in_array($showHidden, array(-1, 0, 1))) { throw new InvalidArgumentException('$showHidden may only be -1, 0 or 1, but actually is ' . $showHidden, 1331315445); } // maps $showHidden (-1..1) to (0..2) which ensures valid array keys $showHiddenKey = $showHidden + 1; $ignoresKey = serialize($ignoreArray); $previewKey = (int) $noVersionPreview; if (!isset(self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey])) { self::retrievePageForEnableFields(); self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey] = self::$pageForEnableFields->enableFields($tableName, $showHidden, $ignoreArray, $noVersionPreview); } return self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey]; }
/** * Resolve relations as defined in TCA and add them to the provided $pageRecord array. * * @param int $uid Page id * @param array $pageRecord Array with page data to add relation data to. * @throws \RuntimeException * @return array $pageRecord with additional relations */ protected function enrichWithRelationFields($uid, array $pageRecord) { $pageOverlayFields = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']); foreach ($GLOBALS['TCA']['pages']['columns'] as $column => $configuration) { if ($this->columnHasRelationToResolve($configuration)) { $configuration = $configuration['config']; if ($configuration['MM']) { /** @var $loadDBGroup \TYPO3\CMS\Core\Database\RelationHandler */ $loadDBGroup = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\RelationHandler::class); $loadDBGroup->start($pageRecord[$column], isset($configuration['allowed']) ? $configuration['allowed'] : $configuration['foreign_table'], $configuration['MM'], $uid, 'pages', $configuration); $relatedUids = isset($loadDBGroup->tableArray[$configuration['foreign_table']]) ? $loadDBGroup->tableArray[$configuration['foreign_table']] : array(); } else { $columnIsOverlaid = in_array($column, $pageOverlayFields, true); $table = $configuration['foreign_table']; $field = $configuration['foreign_field']; $whereClauseParts = array($field . ' = ' . (int) ($columnIsOverlaid ? $uid : $pageRecord['uid'])); if (isset($configuration['foreign_match_fields']) && is_array($configuration['foreign_match_fields'])) { foreach ($configuration['foreign_match_fields'] as $field => $value) { $whereClauseParts[] = $field . ' = ' . $this->databaseConnection->fullQuoteStr($value, $table); } } if (isset($configuration['foreign_table_field'])) { if ((int) $this->languageUid > 0 && $columnIsOverlaid) { $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages_language_overlay\''; } else { $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages\''; } } if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) { $whereClauseParts[] = $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] . ' = 0'; } $whereClause = implode(' AND ', $whereClauseParts); $whereClause .= $this->pageContext->deleteClause($table); $orderBy = isset($configuration['foreign_sortby']) ? $configuration['foreign_sortby'] : ''; $rows = $this->databaseConnection->exec_SELECTgetRows('uid', $table, $whereClause, '', $orderBy); if (!is_array($rows)) { throw new \RuntimeException('Could to resolve related records for page ' . $uid . ' and foreign_table ' . htmlspecialchars($configuration['foreign_table']), 1343589452); } $relatedUids = array(); foreach ($rows as $row) { $relatedUids[] = $row['uid']; } } $pageRecord[$column] = implode(',', $relatedUids); } } return $pageRecord; }
/** * Returns all accessible error pages from all websites. * * @return array<\R3H6\Error404page\Domain\Model\Page> */ protected function findAllByDoktype($doktype) { if (!isset($this->cachedPagesByDoktype[$doktype])) { $result = $this->getDatabaseConnection()->exec_SELECTquery('uid', 'pages', sprintf('doktype=%d', $doktype) . $this->pageRepository->enableFields('pages'), '', 'sorting'); $pages = array(); while ($record = $this->getDatabaseConnection()->sql_fetch_assoc($result)) { $page = $this->findByIdentifier($record['uid']); if ($page !== null) { $pages[] = $page; } } $this->getLogger()->debug(sprintf('Found "%d" pages for doktype "%d"', count($pages), $doktype)); $this->cachedPagesByDoktype[$doktype] = $pages; } return $this->cachedPagesByDoktype[$doktype]; }
/** * @test */ public function enrichWithRelationFieldsCreatesWhereClauseForDisabledField() { $mockDatabaseConnection = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array('exec_SELECTgetRows'), array(), '', false); $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Utility\RootlineUtility::class, array('columnHasRelationToResolve'), array(1, '', $this->pageContextMock)); $subject->_set('databaseConnection', $mockDatabaseConnection); $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = ''; $foreign_table = $this->getUniqueId('foreign_table'); $foreign_field = $this->getUniqueId('foreign_field'); $GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'] = $this->getUniqueId('disabled'); $GLOBALS['TCA']['pages']['columns'] = array('test' => array('config' => array('foreign_table' => $foreign_table, 'foreign_field' => $foreign_field))); $expected = array($foreign_field . ' = 0', $foreign_table . '.' . $GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'] . ' = 0'); $this->pageContextMock->expects($this->once())->method('deleteClause')->will($this->returnValue('')); $mockDatabaseConnection->expects($this->once())->method('exec_SELECTgetRows')->with('uid', $foreign_table, implode(' AND ', $expected), '', '', '', '')->will($this->returnValue(array('uid' => 17))); $subject->expects($this->once())->method('columnHasRelationToResolve')->will($this->returnValue(true)); $subject->_call('enrichWithRelationFields', 17, array()); }
/** * Resolve relations as defined in TCA and add them to the provided $pageRecord array. * * @param integer $uid Page id * @param array $pageRecord Array with page data to add relation data to. * @throws \RuntimeException * @return array $pageRecord with additional relations */ protected function enrichWithRelationFields($uid, array $pageRecord) { foreach ($GLOBALS['TCA']['pages']['columns'] as $column => $configuration) { if ($this->columnHasRelationToResolve($configuration)) { $configuration = $configuration['config']; if ($configuration['MM']) { /** @var $loadDBGroup \TYPO3\CMS\Core\Database\RelationHandler */ $loadDBGroup = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler'); $loadDBGroup->start($pageRecord[$column], $configuration['foreign_table'], $configuration['MM'], $uid, 'pages', $configuration); $relatedUids = $loadDBGroup->tableArray[$configuration['foreign_table']]; } elseif ($configuration['foreign_field']) { $table = $configuration['foreign_table']; $field = $configuration['foreign_field']; $whereClauseParts = array($field . ' = ' . intval($uid)); if (isset($configuration['foreign_match_fields']) && is_array($configuration['foreign_match_fields'])) { foreach ($configuration['foreign_match_fields'] as $field => $value) { $whereClauseParts[] = $field . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table); } } if (isset($configuration['foreign_table_field'])) { if (intval($this->languageUid) > 0) { $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages_language_overlay\''; } else { $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages\''; } } $whereClause = implode(' AND ', $whereClauseParts); $whereClause .= $this->pageContext->deleteClause($table); $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, $whereClause); if (!is_array($rows)) { throw new \RuntimeException('Could to resolve related records for page ' . $uid . ' and foreign_table ' . htmlspecialchars($configuration['foreign_table']), 1343589452); } $relatedUids = array(); foreach ($rows as $row) { $relatedUids[] = $row['uid']; } } $pageRecord[$column] = implode(',', $relatedUids); } } return $pageRecord; }
/** * Wrapper for \TYPO3\CMS\Frontend\Page\PageRepository::getRootLine() * * @param integer $pageUid * @param string $MP * @param boolean $reverse * @return array */ public function getRootLine($pageUid = NULL, $MP = NULL, $reverse = FALSE) { if (NULL === $pageUid) { $pageUid = $GLOBALS['TSFE']->id; } if (NULL === $MP) { $MP = GeneralUtility::_GP('MP'); if (TRUE === empty($MP)) { $MP = ''; } } $key = md5($pageUid . $MP . (string) $reverse); if (FALSE === isset(self::$cachedRootLines[$key])) { $rootLine = self::$pageSelect->getRootLine($pageUid, $MP); if (TRUE === $reverse) { $rootLine = array_reverse($rootLine); } self::$cachedRootLines[$key] = $rootLine; } return self::$cachedRootLines[$key]; }
/** * @return array * @throws Exception */ protected function getArticlePagesList() { $pageList = array(); if ($this->settings['pidOrganizationFolder'] > 0) { $organizations = $this->organizationRepository->findAll(); $usedLeisureFolderPids = array(); /** @var $organization \MUM\BjrFreizeit\Domain\Model\Organization $organization */ foreach ($organizations as $organization) { $usedLeisureFolderPids[] = $organization->getLeisureFolderPid(); } $ret = $this->pageRepository->getMenu($this->settings['pidOrganizationFolder'], '*', 'sorting', 'AND deleted =0 AND hidden = 0'); foreach ($ret as $pageUid => $row) { if (!in_array($pageUid, $usedLeisureFolderPids)) { $pageList[$pageUid] = $row['title']; } } } else { throw new Exception('PID für Seite mit Anbieter ist nicht gesetzt.'); } return $pageList; }
/** * Itemsproc function to extend the selection of storage pid in flexform * * @param array &$config configuration array * @param mixed &$pObj configuration array * @return void */ public function storagePid(array &$config, &$pObj) { // initialize $this->initialize(); // if valid persistence storage pid is set within typoscript setup if ($this->configuration['persistence']['storagePid'] != "") { // get page info for storage pid set by typoscript $page = $this->pageRepository->getPage($configuration['persistence']['storagePid']); $definedByTs = [["[Defined by TS]: " . $page['title'] . " [PID: " . $this->configuration['persistence']['storagePid'] . "]", "TS"]]; } // add pid postfix to item array element and remove invalid pids from array for ($i = 0; $i < count($config['items']); $i++) { if ($config['items'][$i][1] != "") { $config['items'][$i][0] = $config['items'][$i][0] . " [PID: " . $config['items'][$i][1] . "]"; } } // if available add defined by ts value to items array if ($definedByTsTxt) { $config['items'] = array_merge($definedByTs, $config['items']); } }