/** * 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(); }
/** * Tests whether the getPage Hook is called correctly. * * @test */ public function isGetPageHookCalled() { // Create a hook mock object $className = uniqid('tx_coretest'); $getPageHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetPageHookInterface', array('getPage_preProcess'), array(), $className); // Register hook mock object $GLOBALS['T3_VAR']['getUserObj'][$className] = $getPageHookMock; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][] = $className; // Test if hook is called and register a callback method to check given arguments $getPageHookMock->expects($this->once())->method('getPage_preProcess')->will($this->returnCallback(array($this, 'isGetPagePreProcessCalledCallback'))); $this->pageSelectObject->getPage(42, FALSE); }
/** * 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']); }
/** * Get pages from Database * * @return array */ private function getPages() { $rootPageId = $this->pluginConfig['1']['urlEntries.']['pages.']['rootPageId']; $rootPage = $this->pageRepo->getPage($rootPageId); $pages = $this->getSubPagesRecursive($rootPageId); return array_merge([$rootPage], $pages); }
protected function findByIdentifier($identifier) { $page = $this->pageRepository->getPage((int) $identifier); if (is_array($page) && isset($page['uid'])) { return $this->createDomainObject($page); } return null; }
/** * 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; }
/** * Wrapper for \TYPO3\CMS\Frontend\Page\PageRepository::getPage() * * @param integer $pageUid * @return array */ public function getPage($pageUid = NULL) { if (NULL === $pageUid) { $pageUid = $GLOBALS['TSFE']->id; } if (FALSE === isset(self::$cachedPages[$pageUid])) { self::$cachedPages[$pageUid] = self::$pageSelect->getPage($pageUid); } return self::$cachedPages[$pageUid]; }
/** * @test */ public function previewShowsPagesFromLiveAndCurrentWorkspace() { // initialization $wsid = 987654321; // simulate calls from tslib_fe->fetch_the_id() $this->pageSelectObject->versioningPreview = TRUE; $this->pageSelectObject->versioningWorkspaceId = $wsid; $this->pageSelectObject->init(FALSE); // check SQL created by t3lib_pageSelect->getPage() $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTquery')->with('*', 'pages', $this->stringContains('(pages.t3ver_wsid=0 or pages.t3ver_wsid=' . $wsid . ')')); $this->pageSelectObject->getPage(1); }
/** * Checks if the URL can be cached. This function may prevent RealURL cache * pollution with Solr or Indexed search URLs. Also some doktypes are ignored * for the cache. * * @param string $url * @return bool */ protected function canCacheUrl($url) { $bannedUrlsRegExp = $this->configuration->get('cache/banUrlsRegExp'); $result = !$bannedUrlsRegExp || !preg_match($bannedUrlsRegExp, $url); if ($result) { // Check page type: do not cache separators $pageRecord = $this->pageRepository->getPage($this->urlParameters['id']); if (is_array($pageRecord) && ($pageRecord['doktype'] == PageRepository::DOKTYPE_SPACER || $pageRecord['doktype'] == PageRepository::DOKTYPE_RECYCLER)) { $result = false; } } return $result; }
/** * 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); }
/** * @test */ public function previewShowsPagesFromLiveAndCurrentWorkspace() { // initialization $wsid = 987654321; $GLOBALS['TCA'] = array('pages' => $this->defaultTcaForPages); // simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id() $this->pageSelectObject->versioningPreview = true; $this->pageSelectObject->versioningWorkspaceId = $wsid; $this->pageSelectObject->init(false); // check SQL created by \TYPO3\CMS\Frontend\Page\PageRepository->getPage() $GLOBALS['TYPO3_DB']->expects($this->at(2))->method('exec_SELECTgetSingleRow')->with('*', 'pages', $this->stringContains('(pages.t3ver_wsid=0 or pages.t3ver_wsid=' . $wsid . ')')); $this->pageSelectObject->getPage(1); }
/** * 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']; }
/** * 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(); } }
/** * process all fields for the UI grid JSON * @param $fieldNames */ protected function processFields($fieldNames) { // build the rows if ($this->modParams['id'] == 0) { return; } // build the columns $columnDefs = []; foreach ($fieldNames as $fieldName) { $columnDefs[] = $this->getColumnDefinition($fieldName); } // fetch the rows if ($this->modParams['lang'] > 0) { $this->pageRepository->sys_language_uid = $this->modParams['lang']; $columnDefs[] = $this->getColumnDefinition('sys_language_uid'); } $page = $this->pageRepository->getPage($this->modParams['id']); $rowEntries = $this->getPageTree($page, $this->modParams['depth']); $this->view->assignMultiple(['pageJSON' => $this->buildGridJSON($rowEntries, $columnDefs), 'depth' => $this->modParams['depth'], 'lang' => $this->modParams['lang'], 'languages' => $this->languages]); }
/** * 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']); } }
/** * @test */ public function getPagesOverlayByRowMultipleSomeNotOverlaid() { $orig1 = $this->pageRepo->getPage(1); $orig2 = $this->pageRepo->getPage(7); $orig3 = $this->pageRepo->getPage(9); $this->pageRepo->sys_language_uid = 1; $rows = $this->pageRepo->getPagesOverlay(array($orig1, $orig2, $orig3)); $this->assertInternalType('array', $rows); $this->assertCount(3, $rows); $this->assertArrayHasKey(0, $rows); $this->assertArrayHasKey(1, $rows); $this->assertArrayHasKey(2, $rows); $row = $rows[0]; $this->assertOverlayRow($row); $this->assertEquals('Wurzel 1', $row['title']); $row = $rows[1]; $this->assertNotOverlayRow($row); $this->assertEquals('Dummy 1-2-7', $row['title']); $row = $rows[2]; $this->assertOverlayRow($row); $this->assertEquals('Attrappe 1-3-9', $row['title']); }
/** * Get array of folders with news module * * @param Tx_MooxNews_Domain_Model_Dto_AdministrationDemand $demand * @return array folders with news module */ public function getFolders($demand) { global $BE_USER; $folders = array(); if ($demand->getType() != '' && false) { $typeStmt = 'AND news_type="' . $demand->getType() . '"'; } $query = array('SELECT' => '*', 'FROM' => 'pages', 'WHERE' => $BE_USER->getPagePermsClause(1) . ' AND deleted=0 AND doktype=254 AND module="mxnews"' . $typeStmt); $pages = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query); $folderCnt = 0; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($pages)) { $folders[$folderCnt] = $row; $rootline = $this->pageRepository->getRootLine($row['uid']); foreach ($rootline as $rootlinepage) { if ($rootlinepage['is_siteroot']) { $rootlinepage['title'] = $rootlinepage['title']; $folders[$folderCnt]['rootpage'] = $rootlinepage; break; } } if (!$folders[$folderCnt]['rootpage']) { $folders[$folderCnt]['rootpage'] = $rootline[0]; } $rootline = array_reverse($rootline); if (isset($rootline[count($rootline) - 2])) { $pageInfo = $this->pageRepository->getPage((int) $rootline[count($rootline) - 2]['uid']); if ($pageInfo['module'] == 'mxnews') { $folders[$folderCnt]['folder'] = $pageInfo['uid']; } } $folders[$folderCnt]['rootline'] = $rootline; $folderCnt++; } usort($folders, "sortByFolderAndTitle"); $folders = array_reverse($folders); return $folders; }
/** * Get configuration * * @param string $mode * @return array configuration */ public function getConfiguration($mode = "comment") { $this->initialize(); $configuration = NULL; $params = GeneralUtility::_GET(); if ($this->foreignType == "pages" && $this->pageUid > 0) { $pageUid = $this->pageUid; } else { $pageUid = $GLOBALS["TSFE"]->id; } if ($this->foreignType == "self") { $target = $this->contentRepository->findByUid($this->contentUid); if (is_object($target)) { $configuration = ["uid_foreign" => $target->getUid(), "title_foreign" => $target->getHeader(), "tablenames" => 'tt_content']; $this->autoDetectionOrder = NULL; } } elseif ($this->foreignType == "tt_content") { $target = $this->contentRepository->findByUid($this->contentUid); if (is_object($target)) { $configuration = ["uid_foreign" => $target->getUid(), "title_foreign" => $target->getHeader(), "tablenames" => 'tt_content']; $this->autoDetectionOrder = NULL; } } elseif (in_array($this->foreignType, ["tx_mooxnews_domain_model_news", "tx_mooxshop_domain_model_product", "pages"])) { $this->autoDetectionOrder = $this->foreignType; } elseif ($this->autoDetectionOrder == "") { $this->autoDetectionOrder = "pages"; } if ($this->autoDetectionOrder) { foreach (explode(",", $this->autoDetectionOrder) as $tablenames) { if (ExtensionManagementUtility::isLoaded('moox_news') && $tablenames == "tx_mooxnews_domain_model_news") { if (isset($params['tx_mooxnews_pi1']) && $params['tx_mooxnews_pi1']['action'] == 'detail' && $params['tx_mooxnews_pi1']['news'] > 0) { $target = $this->newsRepository->findByUid($params['tx_mooxnews_pi1']['news']); if (is_object($target)) { if ($mode == "comment" && $target->getCommentActive() || $mode == "rating" && $target->getRatingActive() || $mode == "review" && $target->getReviewActive()) { $configuration = ["uid_foreign" => $target->getUid(), "title_foreign" => $target->getTitle(), "tablenames" => $tablenames]; } } break; } } if (ExtensionManagementUtility::isLoaded('moox_shop') && $tablenames == "tx_mooxshop_domain_model_product") { if (isset($params['tx_mooxshop_pi2']) && $params['tx_mooxshop_pi2']['action'] == 'detail' && $params['tx_mooxshop_pi2']['item'] > 0) { $target = $this->productRepository->findByUid($params['tx_mooxshop_pi2']['item']); if (is_object($target)) { if ($mode == "comment" && $target->getCommentActive() || $mode == "rating" && $target->getRatingActive() || $mode == "review" && $target->getReviewActive()) { $configuration = ["uid_foreign" => $target->getUid(), "title_foreign" => $target->getTitle(), "tablenames" => $tablenames]; } } break; } } if ($tablenames == "pages") { if ($GLOBALS["TSFE"]->id > 0) { $page = $this->pageRepository->getPage($pageUid); if ($page['uid'] > 0) { $configuration = ["uid_foreign" => $page['uid'], "title_foreign" => $page['title'], "tablenames" => $tablenames]; } break; } } } } return $configuration; }
/** * Generates a list of content objects with sectionIndex enabled * available on a specific page * * Used for menus with sectionIndex enabled * * @param string $altSortField Alternative sorting field * @param integer $pid The page id to search for sections * @throws UnexpectedValueException if the query to fetch the content elements unexpectedly fails * @return array */ protected function sectionIndex($altSortField, $pid = NULL) { $pid = (int) ($pid ?: $this->id); $basePageRow = $this->sys_page->getPage($pid); if (!is_array($basePageRow)) { return array(); } $configuration = $this->mconf['sectionIndex.']; $useColPos = 0; if (trim($configuration['useColPos']) !== '' || is_array($configuration['useColPos.'])) { $useColPos = $GLOBALS['TSFE']->cObj->stdWrap($configuration['useColPos'], $configuration['useColPos.']); $useColPos = (int) $useColPos; } $selectSetup = array('pidInList' => $pid, 'orderBy' => $altSortField, 'languageField' => 'sys_language_uid', 'where' => $useColPos >= 0 ? 'colPos=' . $useColPos : ''); if ($basePageRow['content_from_pid']) { // If the page is configured to show content from a referenced page the sectionIndex contains only contents of // the referenced page $selectSetup['pidInList'] = $basePageRow['content_from_pid']; } $resource = $this->parent_cObj->exec_getQuery('tt_content', $selectSetup); if (!$resource) { $message = 'SectionIndex: Query to fetch the content elements failed!'; throw new \UnexpectedValueException($message, 1337334849); } $result = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resource)) { $this->sys_page->versionOL('tt_content', $row); if ($GLOBALS['TSFE']->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) { $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $GLOBALS['TSFE']->sys_language_contentOL); } if ($this->mconf['sectionIndex.']['type'] !== 'all') { $doIncludeInSectionIndex = $row['sectionIndex'] >= 1; $doHeaderCheck = $this->mconf['sectionIndex.']['type'] === 'header'; $isValidHeader = ((int) $row['header_layout'] !== 100 || !empty($this->mconf['sectionIndex.']['includeHiddenHeaders'])) && trim($row['header']) !== ''; if (!$doIncludeInSectionIndex || $doHeaderCheck && !$isValidHeader) { continue; } } if (is_array($row)) { $uid = $row['uid']; $result[$uid] = $basePageRow; $result[$uid]['title'] = $row['header']; $result[$uid]['nav_title'] = $row['header']; $result[$uid]['subtitle'] = $row['subheader']; $result[$uid]['starttime'] = $row['starttime']; $result[$uid]['endtime'] = $row['endtime']; $result[$uid]['fe_group'] = $row['fe_group']; $result[$uid]['media'] = $row['media']; $result[$uid]['header_layout'] = $row['header_layout']; $result[$uid]['bodytext'] = $row['bodytext']; $result[$uid]['image'] = $row['image']; $result[$uid]['sectionIndex_uid'] = $uid; } } $GLOBALS['TYPO3_DB']->sql_free_result($resource); return $result; }
/** * Checks if a formmail submission can be sent as email * * @param string $locationData The input from $_POST['locationData'] * @return void * @access private * @see checkDataSubmission() * @todo Define visibility */ public function locDataCheck($locationData) { $locData = explode(':', $locationData); if (!$locData[1] || $this->sys_page->checkRecord($locData[1], $locData[2], 1)) { // $locData[1] -check means that a record is checked only if the locationData has a value for a record else than the page. if (count($this->sys_page->getPage($locData[0]))) { return 1; } else { $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data (' . $locationData . ') was not accessible.', 2); } } else { $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data (' . $locationData . ') record pointed to was not accessible.', 2); } }
/** * Checks whether a translated shortcut page has a different shortcut * target than the original language page. * If that is the case, things get corrected to follow that alternative * shortcut * * @return void */ protected function checkTranslatedShortcut() { if (!is_null($this->originalShortcutPage)) { $originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $this->sys_language_uid); if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) { // the translation of the original shortcut page has a different shortcut target! // set the correct page and id $shortcut = $this->getPageShortcut($originalShortcutPageOverlay['shortcut'], $originalShortcutPageOverlay['shortcut_mode'], $originalShortcutPageOverlay['uid']); $this->id = $this->contentPid = $shortcut['uid']; $this->page = $this->sys_page->getPage($this->id); // Fix various effects on things like menus f.e. $this->fetch_the_id(); $this->tmpl->rootLine = array_reverse($this->rootLine); } } }
/** * Generates a list of content objects with sectionIndex enabled * available on a specific page * * Used for menus with sectionIndex enabled * * @param string $altSortField Alternative sorting field * @param int $pid The page id to search for sections * @throws \UnexpectedValueException if the query to fetch the content elements unexpectedly fails * @return array */ protected function sectionIndex($altSortField, $pid = null) { $pid = (int) ($pid ?: $this->id); $basePageRow = $this->sys_page->getPage($pid); if (!is_array($basePageRow)) { return []; } $tsfe = $this->getTypoScriptFrontendController(); $configuration = $this->mconf['sectionIndex.']; $useColPos = 0; if (trim($configuration['useColPos']) !== '' || is_array($configuration['useColPos.'])) { $useColPos = $tsfe->cObj->stdWrap($configuration['useColPos'], $configuration['useColPos.']); $useColPos = (int) $useColPos; } $selectSetup = ['pidInList' => $pid, 'orderBy' => $altSortField, 'languageField' => 'sys_language_uid', 'where' => $useColPos >= 0 ? 'colPos=' . $useColPos : '']; if ($basePageRow['content_from_pid']) { // If the page is configured to show content from a referenced page the sectionIndex contains only contents of // the referenced page $selectSetup['pidInList'] = $basePageRow['content_from_pid']; } $statement = $this->parent_cObj->exec_getQuery('tt_content', $selectSetup); if (!$statement) { $message = 'SectionIndex: Query to fetch the content elements failed!'; throw new \UnexpectedValueException($message, 1337334849); } $result = []; while ($row = $statement->fetch()) { $this->sys_page->versionOL('tt_content', $row); if ($tsfe->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) { $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $tsfe->sys_language_contentOL); } if ($this->mconf['sectionIndex.']['type'] !== 'all') { $doIncludeInSectionIndex = $row['sectionIndex'] >= 1; $doHeaderCheck = $this->mconf['sectionIndex.']['type'] === 'header'; $isValidHeader = ((int) $row['header_layout'] !== 100 || !empty($this->mconf['sectionIndex.']['includeHiddenHeaders'])) && trim($row['header']) !== ''; if (!$doIncludeInSectionIndex || $doHeaderCheck && !$isValidHeader) { continue; } } if (is_array($row)) { $uid = $row['uid']; $result[$uid] = $basePageRow; $result[$uid]['title'] = $row['header']; $result[$uid]['nav_title'] = $row['header']; // Prevent false exclusion in filterMenuPages, thus: Always show tt_content records $result[$uid]['nav_hide'] = 0; $result[$uid]['subtitle'] = $row['subheader']; $result[$uid]['starttime'] = $row['starttime']; $result[$uid]['endtime'] = $row['endtime']; $result[$uid]['fe_group'] = $row['fe_group']; $result[$uid]['media'] = $row['media']; $result[$uid]['header_layout'] = $row['header_layout']; $result[$uid]['bodytext'] = $row['bodytext']; $result[$uid]['image'] = $row['image']; $result[$uid]['sectionIndex_uid'] = $uid; } } return $result; }