/** * Create a new database connection mock object for every test. * * @return void */ protected function setUp() { parent::setUp(); $this->typoScriptFrontendController = $this->prophesize(TypoScriptFrontendController::class); $GLOBALS['TSFE'] = $this->typoScriptFrontendController->reveal(); $this->subject = GeneralUtility::makeInstance(QueryContext::class); }
protected function initialize() { if (!is_object($this->typoScriptFrontendController->cObj)) { $this->typoScriptFrontendController->initTemplate(); $this->typoScriptFrontendController->getConfigArray(); $this->typoScriptFrontendController->settingLanguage(); $this->typoScriptFrontendController->newCObj(); } }
/** * Initialize * * @param array $parameters * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $frontendController */ public function initialize(array $parameters, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $frontendController) { $frontendUserId = (int) GeneralUtility::_GP('frontendUserId'); $frontendController->fe_user->checkPid = 0; $frontendUser = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', 'fe_users', 'uid =' . $frontendUserId); if (is_array($frontendUser)) { $frontendController->loginUser = 1; $frontendController->fe_user->createUserSession($frontendUser); $frontendController->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession(); $frontendController->initUserGroups(); } }
/** * Checks if cHash is required for the current request and calls * TypoScriptFrontendController::reqCHash() if so. * This call will trigger a PageNotFoundException if arguments are required and cHash is not present. * * @param Request $request * @param string $pluginNamespace */ public function enforceForRequest(Request $request, string $pluginNamespace) { $arguments = $request->getArguments(); if (is_array($arguments) && count($arguments) > 0) { $parameters = [$pluginNamespace => $arguments]; $parameters['id'] = $this->typoScriptFrontendController->id; $relevantParameters = $this->cacheHashCalculator->getRelevantParameters(http_build_query($parameters)); if (count($relevantParameters) > 0) { $this->typoScriptFrontendController->reqCHash(); } } }
/** * @param TypoScriptFrontendController $typoScriptFrontendController */ public function checkDataSubmission(TypoScriptFrontendController $typoScriptFrontendController) { // Do not do anything in this hook, if there are no parameters if ($typoScriptFrontendController->isGeneratePage() && GeneralUtility::_GET($this->argumentNamespace)) { $this->ensureRequiredEnvironment(); $frontendRenderingProvisioner = new FrontendRenderingProvisioner(); $frontendRenderingProvisioner->provision($typoScriptFrontendController); $request = $this->requestBuilder->build(GeneralUtility::_GET($this->argumentNamespace)); $response = new Response(); $renderer = $this->resolveRenderer($request); $renderingContext = new RenderingContext($typoScriptFrontendController); $renderer->renderRequest($request, $response, $renderingContext); $typoScriptFrontendController->content = $response->getContent(); $typoScriptFrontendController->config['config']['pageGenScript'] = 'EXT:typoscript_rendering/Scripts/DummyRendering.php'; } }
/** * Throws a 404 error with the corresponding message. * * @param string $errorMessage * @return void */ protected function throw404($errorMessage) { // TODO Write to our own error log here // Set language to allow localized error pages $_GET['L'] = $this->detectedLanguageId; $this->caller->pageNotFoundAndExit($errorMessage); }
/** * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context. * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * * @param string $content The content to which the edit icons should be appended * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController * @param array $conf TypoScript properties for configuring the edit icons. * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param array $dataArr Alternative data array to use. Default is $this->data * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController * @param string $table * @param int $editUid * @param string $fieldList * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. */ public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList) { // Special content is about to be shown, so the cache must be disabled. $this->frontendController->set_no_cache('Display frontend edit icons', TRUE); $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $optionsArray = array('title' => htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', FALSE), 'class' => 'frontEndEditIcons', 'style' => $conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : ''); $iconImg = $conf['iconImg'] ? $conf['iconImg'] : IconUtility::getSpriteIcon('actions-document-open', $optionsArray); $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; $url = BackendUtility::getModuleUrl('record_edit', array('edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV)) . $addUrlParamStr; $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url); if ($conf['beforeLastTag'] < 0) { $content = $icon . $content; } elseif ($conf['beforeLastTag'] > 0) { $cBuf = rtrim($content); $secureCount = 30; while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $secureCount--; } $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); } else { $content .= $icon; } return $content; }
/** * Remove boundaries from TYPO3 content * * @param string $content the content with boundaries in comment * * @return string the content without boundaries */ public function stripInnerBoundaries($content) { // only dummy code at the moment $searchString = $this->cObj->wrap('[\\d,]*', $this->boundaryStartWrap); $content = preg_replace('/' . $searchString . '/', '', $content); $content = preg_replace('/' . $this->boundaryEnd . '/', '', $content); return $content; }
/** * Throws a 404 error with the corresponding message. * * @param string $errorMessage * @return void */ protected function throw404($errorMessage) { // TODO Write to our own error log here // Set language to allow localized error pages if (MathUtility::canBeInterpretedAsInteger($this->detectedLanguageId)) { $_GET['L'] = $this->detectedLanguageId; } $this->caller->pageNotFoundAndExit($errorMessage); }
/** * Destroy the session data for the form * * @return void */ public function destroySession() { $this->removeFiles(); if ($this->frontendController->loginUser) { $this->frontendController->fe_user->setKey('user', $this->prefix, NULL); } else { $this->frontendController->fe_user->setKey('ses', $this->prefix, NULL); } $this->frontendController->storeSessionData(); }
/** * Initialize the TSFE. * * @param integer $pageUid The page UID * @param boolean $overrule * @return void */ public function initTSFE($pageUid = -1, $overrule = FALSE) { $rootLine = NULL; $typo3confVariables = $GLOBALS['TYPO3_CONF_VARS']; if ($pageUid == -1 && GeneralUtility::_GP('pid') !== NULL) { $pageUid = intval(GeneralUtility::_GP('pid')); } if ($pageUid === -1) { $pageUid = 0; } // begin if (!is_object($GLOBALS['TT']) || $overrule === TRUE) { $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\TimeTracker(); $GLOBALS['TT']->start(); } if ((!is_object($GLOBALS['TSFE']) || $GLOBALS['TSFE'] instanceof \stdClass || $overrule === TRUE) && is_int($pageUid)) { // builds TSFE object $GLOBALS['TSFE'] = $typoScriptFrontendController = new \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController($typo3confVariables, $pageUid, 0, 0, '', '', '', ''); $typoScriptFrontendController->initTemplate(); // builds a cObj if (is_array($typoScriptFrontendController->page) === FALSE) { $typoScriptFrontendController->page = array(); } $typoScriptFrontendController->newCObj(); // Add the FE user $typoScriptFrontendController->fe_user = EidUtility::initFeUser(); $typoScriptFrontendController->determineId(); $typoScriptFrontendController->getConfigArray(); $this->setRequestedLanguage($typoScriptFrontendController); $typoScriptFrontendController->settingLanguage(); $typoScriptFrontendController->settingLocale(); } }
/** * Create a fake frontend * * @param integer $pageUid * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController * @throws InvalidArgumentException */ public function createFakeFrontEnd($pageUid = 0) { if ($this->fakeFrontend && $this->fakeFrontend === $GLOBALS['TSFE']) { return $this->fakeFrontend; } if ($pageUid < 0) { throw new InvalidArgumentException('$pageUid must be >= 0.'); } $GLOBALS['TT'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\NullTimeTracker'); /** @var $this->fakeFrontend \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */ $this->fakeFrontend = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $pageUid, 0); // simulates a normal FE without any logged-in FE or BE user $this->fakeFrontend->beUserLogin = false; $this->fakeFrontend->workspacePreview = ''; $this->fakeFrontend->initFEuser(); $this->fakeFrontend->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $this->fakeFrontend->page = $pageUid; $this->fakeFrontend->initTemplate(); $this->fakeFrontend->config = array(); $this->fakeFrontend->tmpl->getFileName_backPath = PATH_site; $this->fakeFrontend->newCObj(); $GLOBALS['TSFE'] = $this->fakeFrontend; return $this->fakeFrontend; }
/** * Check if there are no _INT scripts * * @param TypoScriptFrontendController $frontendController * @param string $uri * @param array $explanation * @param bool $skipProcessing * * @return array */ public function checkRule($frontendController, $uri, &$explanation, &$skipProcessing) { if ($frontendController->isINTincScript()) { foreach ($frontendController->config['INTincScript'] as $key => $value) { $info = []; if (isset($value['type'])) { $info[] = 'type: ' . $value['type']; } if (isset($value['conf']['userFunc'])) { $info[] = 'userFunc: ' . $value['conf']['userFunc']; } if (isset($value['conf']['includeLibs'])) { $info[] = 'includeLibs: ' . $value['conf']['includeLibs']; } if (isset($value['conf']['extensionName'])) { $info[] = 'extensionName: ' . $value['conf']['extensionName']; } if (isset($value['conf']['pluginName'])) { $info[] = 'pluginName: ' . $value['conf']['pluginName']; } $explanation[__CLASS__ . ':' . $key] = 'The page has a INTincScript: ' . implode(', ', $info); } } }
/** * @test * @dataProvider jumpUrlDefaultValidParametersDataProvider * @param string $hash * @param string $jumpUrl */ public function jumpUrlDefaultTransfersSession($hash, $jumpUrl) { $tsConfig['TSFE.']['jumpUrl_transferSession'] = 1; /** @var \PHPUnit_Framework_MockObject_MockObject|FrontendUserAuthentication $frontendUserMock */ $frontendUserMock = $this->getMock(FrontendUserAuthentication::class); $frontendUserMock->id = 123; $this->tsfe->_set('fe_user', $frontendUserMock); $this->tsfe->expects($this->once())->method('getPagesTSconfig')->will($this->returnValue($tsConfig)); $sessionGetParameter = (strpos($jumpUrl, '?') === false ? '?' : '') . '&FE_SESSION_KEY=123-fc9f825a9af59169895f3bb28267a42f'; $expectedJumpUrl = $jumpUrl . $sessionGetParameter; $this->jumpUrlHandler->expects($this->once())->method('redirect')->with($expectedJumpUrl, HttpUtility::HTTP_STATUS_303); $_GET['jumpurl'] = $jumpUrl; $_GET['juHash'] = $hash; $this->jumpUrlHandler->canHandleCurrentUrl(); $this->jumpUrlHandler->handle(); }
/** * @test */ public function isModifyPageIdTestCalled() { $GLOBALS['TT'] = $this->getMock('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker'); $this->fixture = $this->getMock('\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array('initUserGroups', 'setSysPageWhereClause', 'checkAndSetAlias', 'findDomainRecord', 'getPageAndRootlineWithDomain'), array(), '', FALSE); $this->fixture->page = array(); $pageRepository = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository', $pageRepository); $initialId = rand(1, 500); $expectedId = $initialId + 42; $this->fixture->id = $initialId; $this->fixture->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'][] = function ($params, $frontendController) { return $params['id'] + 42; }; $this->fixture->fetch_the_id(); $this->assertSame($expectedId, $this->fixture->id); }
/** * Tracks display of an object on a page * * @param \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object Object to use * @param mixed $hash Hash or page id (depending on the type) for which the object display will be associated * @param string $type 'hash' (for only one hash) or 'id' (for complete page cache of a page, for all hash combinations) * @return void */ public function trackObjectOnPage(\TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object = NULL, $type = 'hash', $hash = false) { if ($object && !$this->ajaxDispatcher->getIsActive()) { $this->signalSlotDispatcher->dispatch(__CLASS__, self::SIGNAL_PreTrackObjectOnPage, array('object' => $object, 'type' => $type, 'hash' => $hash)); if ($type) { switch ($type) { case 'id': if (!$hash) { $hash = intval($this->fe->id); } $pageHash = 'id-' . $hash; break; case 'hash': default: if (!$hash) { $hash = $this->fe->getHash(); } $pageHash = 'hash-' . $hash; break; } $objectIdentifier = $this->getObjectIdentifierForObject($object); $sharedLock = null; $sharedLockAcquired = $this->acquireLock($sharedLock, $objectIdentifier, FALSE); if ($sharedLockAcquired) { if ($this->trackingCache->has($objectIdentifier)) { $pageHashs = $this->trackingCache->get($objectIdentifier); if (!in_array($pageHash, $pageHashs)) { $exclusiveLock = null; $exclusiveLockAcquired = $this->acquireLock($exclusiveLock, $objectIdentifier . '-e', TRUE); if ($exclusiveLockAcquired) { $pageHashs = $this->trackingCache->get($objectIdentifier); if (!in_array($pageHash, $pageHashs)) { $pageHashs[] = $pageHash; $this->trackingCache->set($objectIdentifier, array_unique($pageHashs)); } $this->releaseLock($exclusiveLock); } } } else { $this->trackingCache->set($objectIdentifier, array($pageHash)); } $this->releaseLock($sharedLock); } } } return; }
/** * Substitutes all occurrences of <a href="#"... in $this->content with <a href="[path-to-url]#"... * * @return void Works directly on $this->content */ protected function prefixLocalAnchorsWithScript() { if (!$this->pObj->beUserLogin) { if (!is_object($this->pObj->cObj)) { $this->pObj->newCObj(); } $scriptPath = $this->pObj->cObj->getUrlToCurrentLocation(); } else { // To break less existing sites, we allow the REQUEST_URI to be used for the prefix $scriptPath = GeneralUtility::getIndpEnv('REQUEST_URI'); // Disable the cache so that these URI will not be the ones to be cached $this->pObj->no_cache = true; } $originalContent = $this->pObj->content; $this->pObj->content = preg_replace('/(<(?:a|area).*?href=")(#[^"]*")/i', '${1}' . htmlspecialchars($scriptPath) . '${2}', $originalContent); // There was an error in the call to preg_replace, so keep the original content (behavior prior to PHP 5.2) if (preg_last_error() > 0) { GeneralUtility::sysLog('preg_replace returned error-code: ' . preg_last_error() . ' in function prefixLocalAnchorsWithScript. Replacement not done!', 'cms', GeneralUtility::SYSLOG_SEVERITY_FATAL); $this->pObj->content = $originalContent; } }
/** * Initialize frontend environment * * @return void */ public function __construct() { $this->bootstrap = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Core\\Bootstrap'); $feUserObj = EidUtility::initFeUser(); $pageId = GeneralUtility::_GET('id') ?: 1; $pageType = GeneralUtility::_GET('type') ?: 0; /** @var TypoScriptFrontendController $typoScriptFrontendController */ $this->typoScriptFrontendController = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $pageId, $pageType, true); $GLOBALS['TSFE'] = $this->typoScriptFrontendController; $this->typoScriptFrontendController->connectToDB(); $this->typoScriptFrontendController->fe_user = $feUserObj; $this->typoScriptFrontendController->id = $pageId; $this->typoScriptFrontendController->determineId(); $this->typoScriptFrontendController->checkAlternativeIdMethods(); $this->typoScriptFrontendController->getCompressedTCarray(); $this->typoScriptFrontendController->initTemplate(); $this->typoScriptFrontendController->getConfigArray(); $this->typoScriptFrontendController->includeTCA(); $this->typoScriptFrontendController->settingLanguage(); $this->typoScriptFrontendController->settingLocale(); }
/** * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context. * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * * @param string $content The content to which the edit icons should be appended * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController * @param array $conf TypoScript properties for configuring the edit icons. * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param array $dataArr Alternative data array to use. Default is $this->data * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController * @param string $table * @param int $editUid * @param string $fieldList * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. */ public function editIcons($content, $params, array $conf = [], $currentRecord = '', array $dataArr = [], $addUrlParamStr = '', $table, $editUid, $fieldList) { // Special content is about to be shown, so the cache must be disabled. $this->frontendController->set_no_cache('Display frontend edit icons', true); $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $iconImg = '<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', false) . '" class="frontEndEditIcons" style="' . ($conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</span>'; $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; $url = BackendUtility::getModuleUrl('record_edit', ['edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV, 'feEdit' => 1]) . $addUrlParamStr; $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url, 'content-link'); if ($conf['beforeLastTag'] < 0) { $content = $icon . $content; } elseif ($conf['beforeLastTag'] > 0) { $cBuf = rtrim($content); $secureCount = 30; while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $secureCount--; } $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); } else { $content .= $icon; } return $content; }
/** * @param array $parameter Parameter by TYPO3. * @param TypoScriptFrontendController $parentObject Current instance. * * @return void */ protected function handleNotFound(array $parameter, TypoScriptFrontendController $parentObject) { $domainConfiguration = $this->getDomainConfiguration(); $parentObject->pageNotFoundHandler($domainConfiguration['pageNotFound_handling'], $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader'], $parameter['reasonText']); }
/** * Check if the page is static cachable * * @param TypoScriptFrontendController $frontendController * @param string $uri * @param array $explanation * @param bool $skipProcessing * * @return array */ public function checkRule($frontendController, $uri, &$explanation, &$skipProcessing) { if (!$frontendController->isStaticCacheble()) { $explanation[__CLASS__] = 'The page is not static chachable via TypoScriptFrontend'; } }
/** * @test */ public function NoNewsFoundConfigurationCallsPageNotFoundHandler() { $mock = $this->getAccessibleMock('Tx_MooxNews_Controller_NewsBaseController', array('dummy')); $this->tsfe->expects($this->once())->method('pageNotFoundAndExit'); $mock->_call('handleNoNewsFoundError', 'pageNotFoundHandler'); }
/** * Parent Object (TSFE) Initialization * * @param TypoScriptFrontendController $pObj Parent Object, passed by reference * @return void */ public function hook_indexContent(&$pObj) { // Indexer configuration from Extension Manager interface: $indexerConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['indexed_search']); // Crawler activation: // Requirements are that the crawler is loaded, a crawler session is running and re-indexing requested as processing instruction: if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('crawler') && $pObj->applicationData['tx_crawler']['running'] && in_array('tx_indexedsearch_reindex', $pObj->applicationData['tx_crawler']['parameters']['procInstructions'])) { // Setting simple log message: $pObj->applicationData['tx_crawler']['log'][] = 'Forced Re-indexing enabled'; // Setting variables: $this->crawlerActive = true; // Crawler active flag $this->forceIndexing = true; } // Determine if page should be indexed, and if so, configure and initialize indexer if ($pObj->config['config']['index_enable']) { $this->log_push('Index page', ''); if (!$indexerConfig['disableFrontendIndexing'] || $this->crawlerActive) { if (!$pObj->page['no_search']) { if (!$pObj->no_cache) { if ((int) $pObj->sys_language_uid === (int) $pObj->sys_language_content) { // Setting up internal configuration from config array: $this->conf = array(); // Information about page for which the indexing takes place $this->conf['id'] = $pObj->id; // Page id $this->conf['type'] = $pObj->type; // Page type $this->conf['sys_language_uid'] = $pObj->sys_language_uid; // sys_language UID of the language of the indexing. $this->conf['MP'] = $pObj->MP; // MP variable, if any (Mount Points) $this->conf['gr_list'] = $pObj->gr_list; // Group list $this->conf['cHash'] = $pObj->cHash; // cHash string for additional parameters $this->conf['cHash_array'] = $pObj->cHash_array; // Array of the additional parameters $this->conf['crdate'] = $pObj->page['crdate']; // The creation date of the TYPO3 page $this->conf['page_cache_reg1'] = $pObj->page_cache_reg1; // reg1 of the caching table. Not known what practical use this has. // Root line uids $this->conf['rootline_uids'] = array(); foreach ($pObj->config['rootLine'] as $rlkey => $rldat) { $this->conf['rootline_uids'][$rlkey] = $rldat['uid']; } // Content of page: $this->conf['content'] = $pObj->content; // Content string (HTML of TYPO3 page) $this->conf['indexedDocTitle'] = $pObj->convOutputCharset($pObj->indexedDocTitle); // Alternative title for indexing $this->conf['metaCharset'] = $pObj->metaCharset; // Character set of content (will be converted to utf-8 during indexing) $this->conf['mtime'] = isset($pObj->register['SYS_LASTCHANGED']) ? $pObj->register['SYS_LASTCHANGED'] : $pObj->page['SYS_LASTCHANGED']; // Most recent modification time (seconds) of the content on the page. Used to evaluate whether it should be re-indexed. // Configuration of behavior: $this->conf['index_externals'] = $pObj->config['config']['index_externals']; // Whether to index external documents like PDF, DOC etc. (if possible) $this->conf['index_descrLgd'] = $pObj->config['config']['index_descrLgd']; // Length of description text (max 250, default 200) $this->conf['index_metatags'] = isset($pObj->config['config']['index_metatags']) ? $pObj->config['config']['index_metatags'] : true; // Set to zero: $this->conf['recordUid'] = 0; $this->conf['freeIndexUid'] = 0; $this->conf['freeIndexSetId'] = 0; // Init and start indexing: $this->init(); $this->indexTypo3PageContent(); } else { $this->log_setTSlogMessage('Index page? No, ->sys_language_uid was different from sys_language_content which indicates that the page contains fall-back content and that would be falsely indexed as localized content.'); } } else { $this->log_setTSlogMessage('Index page? No, page was set to "no_cache" and so cannot be indexed.'); } } else { $this->log_setTSlogMessage('Index page? No, The "No Search" flag has been set in the page properties!'); } } else { $this->log_setTSlogMessage('Index page? No, Ordinary Frontend indexing during rendering is disabled.'); } $this->log_pull(); } }
/** * Returns the localized label of the LOCAL_LANG key, $key * Notice that for debugging purposes prefixes for the output values can be set with the internal vars ->LLtestPrefixAlt and ->LLtestPrefix * * @param string $key The key from the LOCAL_LANG array for which to return the value. * @param string $alternativeLabel Alternative string to return IF no value is found set for the key, neither for the local language nor the default. * @param bool $hsc If TRUE, the output label is passed through htmlspecialchars() * @return string The value from LOCAL_LANG. */ public function pi_getLL($key, $alternativeLabel = '', $hsc = FALSE) { $word = NULL; if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0]['target']) || isset($this->LOCAL_LANG_UNSET[$this->LLkey][$key])) { // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG if (isset($this->LOCAL_LANG_charset[$this->LLkey][$key])) { $word = $this->frontendController->csConv($this->LOCAL_LANG[$this->LLkey][$key][0]['target'], $this->LOCAL_LANG_charset[$this->LLkey][$key]); } else { $word = $this->LOCAL_LANG[$this->LLkey][$key][0]['target']; } } elseif ($this->altLLkey) { $alternativeLanguageKeys = GeneralUtility::trimExplode(',', $this->altLLkey, TRUE); $alternativeLanguageKeys = array_reverse($alternativeLanguageKeys); foreach ($alternativeLanguageKeys as $languageKey) { if (!empty($this->LOCAL_LANG[$languageKey][$key][0]['target']) || isset($this->LOCAL_LANG_UNSET[$languageKey][$key])) { // Alternative language translation for key exists $word = $this->LOCAL_LANG[$languageKey][$key][0]['target']; // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG if (isset($this->LOCAL_LANG_charset[$languageKey][$key])) { $word = $this->frontendController->csConv($word, $this->LOCAL_LANG_charset[$this->altLLkey][$key]); } break; } } } if ($word === NULL) { if (!empty($this->LOCAL_LANG['default'][$key][0]['target']) || isset($this->LOCAL_LANG_UNSET['default'][$key])) { // Get default translation (without charset conversion, english) $word = $this->LOCAL_LANG['default'][$key][0]['target']; } else { // Return alternative string or empty $word = isset($this->LLtestPrefixAlt) ? $this->LLtestPrefixAlt . $alternativeLabel : $alternativeLabel; } } $output = isset($this->LLtestPrefix) ? $this->LLtestPrefix . $word : $word; if ($hsc) { $output = htmlspecialchars($output); } return $output; }
/** * Handles a frontend request * * @param \Psr\Http\Message\ServerRequestInterface $request * @return NULL|\Psr\Http\Message\ResponseInterface */ public function handleRequest(\Psr\Http\Message\ServerRequestInterface $request) { $response = null; $this->request = $request; $this->initializeTimeTracker(); // Hook to preprocess the current request: if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) { $hookParameters = array(); GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters); } unset($hookFunction); unset($hookParameters); } $this->initializeController(); if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_force'] && !GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) { $this->controller->pageUnavailableAndExit('This page is temporarily unavailable.'); } $this->controller->connectToDB(); $this->controller->sendRedirect(); // Output compression // Remove any output produced until now $this->bootstrap->endOutputBufferingAndCleanPreviousOutput(); $this->initializeOutputCompression(); // Initializing the Frontend User $this->timeTracker->push('Front End user initialized', ''); $this->controller->initFEuser(); $this->timeTracker->pull(); // Initializing a possible logged-in Backend User /** @var $GLOBALS['BE_USER'] \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */ $GLOBALS['BE_USER'] = $this->controller->initializeBackendUser(); // Process the ID, type and other parameters. // After this point we have an array, $page in TSFE, which is the page-record // of the current page, $id. $this->timeTracker->push('Process ID', ''); // Initialize admin panel since simulation settings are required here: if ($this->controller->isBackendUserLoggedIn()) { $GLOBALS['BE_USER']->initializeAdminPanel(); $this->bootstrap->initializeBackendRouter()->loadExtensionTables(); } else { $this->bootstrap->loadCachedTca(); } $this->controller->checkAlternativeIdMethods(); $this->controller->clear_preview(); $this->controller->determineId(); // Now, if there is a backend user logged in and he has NO access to this page, // then re-evaluate the id shown! _GP('ADMCMD_noBeUser') is placed here because // \TYPO3\CMS\Version\Hook\PreviewHook might need to know if a backend user is logged in. if ($this->controller->isBackendUserLoggedIn() && (!$GLOBALS['BE_USER']->extPageReadAccess($this->controller->page) || GeneralUtility::_GP('ADMCMD_noBeUser'))) { // Remove user unset($GLOBALS['BE_USER']); $this->controller->beUserLogin = false; // Re-evaluate the page-id. $this->controller->checkAlternativeIdMethods(); $this->controller->clear_preview(); $this->controller->determineId(); } $this->controller->makeCacheHash(); $this->timeTracker->pull(); // Admin Panel & Frontend editing if ($this->controller->isBackendUserLoggedIn()) { $GLOBALS['BE_USER']->initializeFrontendEdit(); if ($GLOBALS['BE_USER']->adminPanel instanceof AdminPanelView) { $this->bootstrap->initializeLanguageObject(); } if ($GLOBALS['BE_USER']->frontendEdit instanceof FrontendEditingController) { $GLOBALS['BE_USER']->frontendEdit->initConfigOptions(); } } // Starts the template $this->timeTracker->push('Start Template', ''); $this->controller->initTemplate(); $this->timeTracker->pull(); // Get from cache $this->timeTracker->push('Get Page from cache', ''); $this->controller->getFromCache(); $this->timeTracker->pull(); // Get config if not already gotten // After this, we should have a valid config-array ready $this->controller->getConfigArray(); // Setting language and locale $this->timeTracker->push('Setting language and locale', ''); $this->controller->settingLanguage(); $this->controller->settingLocale(); $this->timeTracker->pull(); // Convert POST data to utf-8 for internal processing if metaCharset is different $this->controller->convPOSTCharset(); $this->controller->initializeRedirectUrlHandlers(); $this->controller->handleDataSubmission(); // Check for shortcut page and redirect $this->controller->checkPageForShortcutRedirect(); $this->controller->checkPageForMountpointRedirect(); // Generate page $this->controller->setUrlIdToken(); $this->timeTracker->push('Page generation', ''); if ($this->controller->isGeneratePage()) { $this->controller->generatePage_preProcessing(); $temp_theScript = $this->controller->generatePage_whichScript(); if ($temp_theScript) { include $temp_theScript; } else { PageGenerator::pagegenInit(); // Global content object $this->controller->newCObj(); // Content generation if (!$this->controller->isINTincScript()) { PageGenerator::renderContent(); $this->controller->setAbsRefPrefix(); } } $this->controller->generatePage_postProcessing(); } elseif ($this->controller->isINTincScript()) { PageGenerator::pagegenInit(); // Global content object $this->controller->newCObj(); } $this->controller->releaseLocks(); $this->timeTracker->pull(); // Render non-cached parts if ($this->controller->isINTincScript()) { $this->timeTracker->push('Non-cached objects', ''); $this->controller->INTincScript(); $this->timeTracker->pull(); } // Output content $sendTSFEContent = false; if ($this->controller->isOutputting()) { $this->timeTracker->push('Print Content', ''); $this->controller->processOutput(); $sendTSFEContent = true; $this->timeTracker->pull(); } // Store session data for fe_users $this->controller->storeSessionData(); // Statistics $GLOBALS['TYPO3_MISC']['microtime_end'] = microtime(true); $this->controller->setParseTime(); if (isset($this->controller->config['config']['debug'])) { $debugParseTime = (bool) $this->controller->config['config']['debug']; } else { $debugParseTime = !empty($this->controller->TYPO3_CONF_VARS['FE']['debug']); } if ($this->controller->isOutputting() && $debugParseTime) { $this->controller->content .= LF . '<!-- Parsetime: ' . $this->controller->scriptParseTime . 'ms -->'; } $this->controller->redirectToExternalUrl(); // Preview info $this->controller->previewInfo(); // Hook for end-of-frontend $this->controller->hook_eofe(); // Finish timetracking $this->timeTracker->pull(); // Check memory usage MonitorUtility::peakMemoryUsage(); // beLoginLinkIPList echo $this->controller->beLoginLinkIPList(); // Admin panel if ($this->controller->isBackendUserLoggedIn() && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) { if ($GLOBALS['BE_USER']->extAdmEnabled) { // Style sheet is also used for frontend editing. $this->controller->content = str_ireplace('</head>', $GLOBALS['BE_USER']->adminPanel->getAdminPanelHeaderData() . '</head>', $this->controller->content); } if ($GLOBALS['BE_USER']->isAdminPanelVisible()) { $this->controller->content = str_ireplace('</body>', $GLOBALS['BE_USER']->displayAdminPanel() . '</body>', $this->controller->content); } } if ($sendTSFEContent) { /** @var \TYPO3\CMS\Core\Http\Response $response */ $response = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\Response::class); $response->getBody()->write($this->controller->content); } // Debugging Output if (isset($GLOBALS['error']) && is_object($GLOBALS['error']) && @is_callable(array($GLOBALS['error'], 'debugOutput'))) { $GLOBALS['error']->debugOutput(); } if (TYPO3_DLOG) { GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, array('_FLUSH' => true)); } return $response; }
/** * @return bool */ public function isBackendAdminLoggedIn() { $backendUser = $this->typoScriptFrontend->initializeBackendUser(); return $this->typoScriptFrontend->isBackendUserLoggedIn() && $backendUser->isAdmin(); }
/** * Implements the stdWrap property "tableStyle"; Basically this generates a <table>-tag with properties which is wrapped around the input value. * * @param string $theValue The input value * @param array $conf TypoScript properties for the "TypoScript function" '->textStyle' * @return string The processed output value * @access private * @see stdWrap() * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 */ public function tableStyle($theValue, $conf) { $this->typoScriptFrontendController->logDeprecatedTyposcript('tableStyle', 'Deprecated since 7.1 and will be removed with CMS 8. Use CSS instead'); $conf['color.'][240] = 'black'; $conf['color.'][241] = 'white'; $conf['color.'][242] = '#333333'; $conf['color.'][243] = 'gray'; $conf['color.'][244] = 'silver'; $align = isset($conf['align.']) ? $this->stdWrap($conf['align'], $conf['align.']) : $conf['align']; $border = isset($conf['border.']) ? (int) $this->stdWrap($conf['border'], $conf['border.']) : (int) $conf['border']; $cellspacing = isset($conf['cellspacing.']) ? (int) $this->stdWrap($conf['cellspacing'], $conf['cellspacing.']) : (int) $conf['cellspacing']; $cellpadding = isset($conf['cellpadding.']) ? (int) $this->stdWrap($conf['cellpadding'], $conf['cellpadding.']) : (int) $conf['cellpadding']; $color = $this->data[$conf['color.']['field']]; $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $conf['color.']['default']; // Assembling the table tag $tableTagArray = array('<table'); $tableTagArray[] = 'border="' . $border . '"'; $tableTagArray[] = 'cellspacing="' . $cellspacing . '"'; $tableTagArray[] = 'cellpadding="' . $cellpadding . '"'; if ($align) { $tableTagArray[] = 'align="' . $align . '"'; } if ($theColor) { $tableTagArray[] = 'bgcolor="' . $theColor . '"'; } if ($conf['params']) { $tableTagArray[] = $conf['params']; } $tableWrap = implode(' ', $tableTagArray) . '> | </table>'; $theValue = $this->wrap($theValue, $tableWrap); // return return $theValue; }
/** * @param array $expectedTags * @param array $configuration * @test * @dataProvider stdWrap_addPageCacheTagsAddsPageTagsDataProvider */ public function stdWrap_addPageCacheTagsAddsPageTags(array $expectedTags, array $configuration) { $this->subject->stdWrap_addPageCacheTags('', $configuration); $this->assertEquals($expectedTags, $this->typoScriptFrontendControllerMock->_get('pageCacheTags')); }
/** * @param string $currentDomain * @param string $domainRecord * @param string $scriptName * @param bool $expectedResult * @test * @dataProvider domainNameMatchesCurrentRequestDataProvider */ public function domainNameMatchesCurrentRequest($currentDomain, $domainRecord, $scriptName, $expectedResult) { $_SERVER['HTTP_HOST'] = $currentDomain; $_SERVER['SCRIPT_NAME'] = $scriptName; $this->assertEquals($expectedResult, $this->subject->domainNameMatchesCurrentRequest($domainRecord)); }
/** * @test */ public function NoNewsFoundConfigurationCallsPageNotFoundHandler() { $mock = $this->getAccessibleMock('GeorgRinger\\News\\Controller\\NewsBaseController', ['dummy']); $this->tsfe->expects($this->once())->method('pageNotFoundAndExit'); $mock->_call('handleNoNewsFoundError', 'pageNotFoundHandler'); }