public function setUp() { Util::initializeTsfe('1'); $GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site; $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage'] = '0'; $GLOBALS['TSFE']->tmpl->setup['config.']['tx_realurl_enable'] = '0'; // setup up ts objects $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['detailPage'] = 5050; $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['renderObjects.'] = array('testContent' => 'TEXT', 'testContent.' => array('field' => 'argument_0'), 'testContent2' => 'TEXT', 'testContent2.' => array('field' => 'argument_1', 'stripHtml' => 1)); $this->fixtures = array('argument content', '<span>argument content with html</span>', 'third argument content'); $this->viewHelper = new Ts(); }
public function setUp() { Util::initializeTsfe('1'); $GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site; $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage'] = '0'; $GLOBALS['TSFE']->tmpl->setup['config.']['tx_realurl_enable'] = '0'; $facetName = 'TestFacet'; $facetOptions = array('testoption' => 1); $facetConfiguration = array('selectingSelectedFacetOptionRemovesFilter' => 0, 'renderingInstruction'); $parentPlugin = GeneralUtility::makeInstance('Tx_Solr_PiResults_Results'); $parentPlugin->cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $parentPlugin->main('', array()); $query = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query', array('test')); $this->facetRenderer = GeneralUtility::makeInstance('Tx_Solr_Facet_SimpleFacetRenderer', $facetName, $facetOptions, $facetConfiguration, $parentPlugin->getTemplate(), $query); $this->facetRenderer->setLinkTargetPageId($parentPlugin->getLinkTargetPageId()); }
/** * Gets the site's config.sys_language_mode setting * * @return string The site's config.sys_language_mode */ public function getSysLanguageMode() { if (is_null($this->sysLanguageMode)) { Util::initializeTsfe($this->getRootPageId()); $this->sysLanguageMode = $GLOBALS['TSFE']->sys_language_mode; } return $this->sysLanguageMode; }
/** * Gets the full item record. * * This general record indexer simply gets the record from the item. Other * more specialized indexers may provide more data for their specific item * types. * * @param Item $item The item to be indexed * @param integer $language Language Id (sys_language.uid) * @return array|NULL The full record with fields of data to be used for indexing or NULL to prevent an item from being indexed */ protected function getFullItemRecord(Item $item, $language = 0) { $rootPageUid = $item->getRootPageUid(); $overlayIdentifier = $rootPageUid . '|' . $language; if (!isset($this->sysLanguageOverlay[$overlayIdentifier])) { Util::initializeTsfe($rootPageUid, $language); $this->sysLanguageOverlay[$overlayIdentifier] = $GLOBALS['TSFE']->sys_language_contentOL; } $itemRecord = $item->getRecord(); if ($language > 0) { $page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $page->init(FALSE); $itemRecord = $page->getRecordOverlay($item->getType(), $itemRecord, $language, $this->sysLanguageOverlay[$rootPageUid . '|' . $language]); } if (!$itemRecord) { $itemRecord = NULL; } /* * Skip disabled records. This happens if the default language record * is hidden but a certain translation isn't. Then the default language * document appears here but must not be indexed. */ if (!empty($GLOBALS['TCA'][$item->getType()]['ctrl']['enablecolumns']['disabled']) && $itemRecord[$GLOBALS['TCA'][$item->getType()]['ctrl']['enablecolumns']['disabled']]) { $itemRecord = NULL; } /* * Skip translation mismatching records. Sometimes the requested language * doesn't fit the returned language. This might happen with content fallback * and is perfectly fine in general. * But if the requested language doesn't match the returned language and * the given record has no translation parent, the indexqueue_item most * probably pointed to a non-translated language record that is dedicated * to a very specific language. Now we have to avoid indexing this record * into all language cores. */ $translationOriginalPointerField = 'l10n_parent'; if (!empty($GLOBALS['TCA'][$item->getType()]['ctrl']['transOrigPointerField'])) { $translationOriginalPointerField = $GLOBALS['TCA'][$item->getType()]['ctrl']['transOrigPointerField']; } $languageField = $GLOBALS['TCA'][$item->getType()]['ctrl']['languageField']; if ($itemRecord[$translationOriginalPointerField] == 0 && $this->sysLanguageOverlay[$overlayIdentifier] != 1 && !empty($languageField) && $itemRecord[$languageField] != $language && $itemRecord[$languageField] != '-1') { $itemRecord = NULL; } if (!is_null($itemRecord)) { $itemRecord['__solr_index_language'] = $language; } return $itemRecord; }
/** * Checks whether config.index_enable is set to 1, otherwise indexing will * not work. * * @return NULL|Status An error status is returned for each site root page config.index_enable = 0. */ protected function getConfigIndexEnableStatus() { $status = null; $rootPages = $this->getRootPages(); $rootPagesWithIndexingOff = array(); foreach ($rootPages as $rootPage) { try { Util::initializeTsfe($rootPage['uid']); if (!$GLOBALS['TSFE']->config['config']['index_enable']) { $rootPagesWithIndexingOff[] = $rootPage; } } catch (\RuntimeException $rte) { $rootPagesWithIndexingOff[] = $rootPage; } catch (ServiceUnavailableException $sue) { if ($sue->getCode() == 1294587218) { // No TypoScript template found, continue with next site $rootPagesWithIndexingOff[] = $rootPage; continue; } } } if (!empty($rootPagesWithIndexingOff)) { foreach ($rootPagesWithIndexingOff as $key => $rootPageWithIndexingOff) { $rootPagesWithIndexingOff[$key] = '[' . $rootPageWithIndexingOff['uid'] . '] ' . $rootPageWithIndexingOff['title']; } $status = GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Page Indexing', 'Indexing is disabled', 'You need to set config.index_enable = 1 to allow page indexing. The following sites were found with indexing disabled: <ul><li>' . implode('</li><li>', $rootPagesWithIndexingOff) . '</li></ul>', Status::ERROR); } return $status; }