/** * Will set up various stuff in the class based on input TypoScript * * @param array TypoScript options * @return void */ function initVars($conf) { $this->inheritValueFromDefault = $conf['dontInheritValueFromDefault'] ? 0 : 1; // naming choosen to fit the regular TYPO3 integrators needs ;) self::$enablePageRenderer = isset($conf['advancedHeaderInclusion']) ? $conf['advancedHeaderInclusion'] : self::$enablePageRenderer; $this->conf=$conf; }
/** * get content of current page and save data to db * @param $uid page-UID that has to be indexed */ public function getPageContent($uid) { $flex = $this->pageRecords[$uid]['tx_templavoila_flex']; if (empty($flex)) { return ''; } if (TYPO3_VERSION_INTEGER >= 7000000) { $flex = TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($flex); } else { $flex = t3lib_div::xml2array($flex); } // TODO: Maybe I need a more detailed collection of retrieving CE UIDS $contentElementUids = array(); if (!$this->indexerConfig['tvpath']) { $tvPaths = 'field_content'; } else { $tvPaths = $this->indexerConfig['tvpath']; } if (TYPO3_VERSION_INTEGER >= 7000000) { $tvPaths = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tvPaths); } else { $tvPaths = t3lib_div::trimExplode(',', $tvPaths); } foreach ($tvPaths as $tvPath) { $contentElementUids[] = $flex['data']['sDEF']['lDEF'][$tvPath]['vDEF']; } if (TYPO3_VERSION_INTEGER >= 7000000) { $contentElementUids = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList(implode(',', $contentElementUids)); } else { $contentElementUids = t3lib_div::uniqueList(implode(',', $contentElementUids)); } if (empty($contentElementUids)) { return ''; } // TODO: Maybe it's good to check comma seperated list for int values // get content elements for this page $fields = '*'; $table = 'tt_content'; $where = 'uid IN (' . $contentElementUids . ')'; $where .= ' AND (' . $this->whereClauseForCType . ')'; if (TYPO3_VERSION_INTEGER >= 7000000) { $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table); $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); } else { $where .= t3lib_BEfunc::BEenableFields($table); $where .= t3lib_BEfunc::deleteClause($table); } // if indexing of content elements with restrictions is not allowed // get only content elements that have empty group restrictions if ($this->indexerConfig['index_content_with_restrictions'] != 'yes') { $where .= ' AND (fe_group = "" OR fe_group = "0") '; } $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where); if (count($rows)) { $this->counter++; foreach ($rows as $row) { // header // add header only if not set to "hidden" if ($row['header_layout'] != 100) { $pageContent[$row['sys_language_uid']] .= strip_tags($row['header']) . "\n"; } // bodytext $bodytext = $row['bodytext']; if ($row['CType'] == 'table') { // replace table dividers with whitespace $bodytext = str_replace('|', ' ', $bodytext); } if ($row['CType'] == 'templavoila_pi1') { //$bodytext = $this->getContentForTV($row); $bodytext = $this->tv->renderElement($row, 'tt_content'); } // following lines prevents having words one after the other like: HelloAllTogether $bodytext = str_replace('<td', ' <td', $bodytext); $bodytext = str_replace('<br', ' <br', $bodytext); $bodytext = str_replace('<p', ' <p', $bodytext); $bodytext = str_replace('<li', ' <li', $bodytext); $bodytext = strip_tags($bodytext); $pageContent[$row['sys_language_uid']] .= $bodytext . "\n"; } } // get Tags for current page $tags = $this->pageRecords[intval($uid)]['tags']; // make it possible to modify the indexerConfig via hook $indexerConfig = $this->indexerConfig; // hook for custom modifications of the indexed data, e. g. the tags if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->modifyPagesIndexEntry($uid, $pageContent, $tags, $this->cachedPageRecords, $additionalFields, $indexerConfig); } } // store record in index table foreach ($pageContent as $langKey => $content) { $this->pObj->storeInIndex($indexerConfig['storagepid'], $this->cachedPageRecords[$langKey][$uid]['title'], 'templavoila', $uid, $content, $tags, '', '', $langKey, $this->cachedPageRecords[$langKey][$uid]['starttime'], $this->cachedPageRecords[$langKey][$uid]['endtime'], $this->cachedPageRecords[$langKey][$uid]['fe_group'], false, $additionalFields); } }