/**
  * This function was called from indexer object and saves content to index table
  * @return string content which will be displayed in backend
  */
 public function startIndexing()
 {
     $content = '';
     // get all the records to index
     // don't index hidden, deleted or not approved comments
     $fields = '*';
     $table = 'tx_comments_comments';
     $indexPids = $this->getPidList($this->indexerConfig['startingpoints_recursive'], $this->indexerConfig['sysfolder'], $table);
     if ($this->indexerConfig['index_use_page_tags']) {
         // add the tags of each page to the global page array
         $this->pageRecords = $this->getPageRecords($indexPids);
         $this->addTagsToRecords($indexPids);
     }
     $where = 'pid IN (' . implode(',', $indexPids) . ') ';
     $where .= ' AND approved=1';
     $where .= ' AND external_prefix IN ("' . implode('","', TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->indexerConfig['commenttypes'])) . '")';
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
         $count = 0;
         while ($comment = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             // compile the information which should go into the index
             $title = $this->compileCommentTitle($comment);
             $abstract = '';
             $content = trim(strip_tags($comment['content']));
             // use page ID stored in field "external_ref" as target page
             // makes sense for comments to page
             // Should be adjusted for other comments?
             if ($comment['external_prefix'] == 'pages') {
                 $external_ref_exploded = explode('_', $comment['external_ref']);
                 $targetPage = $external_ref_exploded[1];
             } else {
                 // TODO: Make the target page configurable, eg. for tt_news comments
                 //$targetPage = $indexerConfig['targetpid'];
                 $targetPage = 0;
             }
             // create tags
             if ($this->indexerConfig['index_use_page_tags']) {
                 $tags = $this->pageRecords[intval($comment['pid'])]['tags'];
             } else {
                 $tags = '';
             }
             // fill additional fields
             $additionalFields = array('orig_uid' => $comment['uid'], 'orig_pid' => $comment['pid'], 'sortdate' => $comment['crdate']);
             // make it possible to modify the indexerConfig via hook
             $indexerConfig = $this->indexerConfig;
             $params = '';
             // hook for custom modifications of the indexed data, e. g. the tags
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyCommentsIndexEntry'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyCommentsIndexEntry'] as $_classRef) {
                     $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
                     $_procObj->modifyCommentsIndexEntry($title, $abstract, $content, $params, $tags, $comment, $additionalFields, $indexerConfig);
                 }
             }
             // ... and store them
             $this->pObj->storeInIndex($indexerConfig['storagepid'], $title, 'comments', $targetPage, $content, $tags, $params, $abstract, -1, 0, 0, '', false, $additionalFields);
             $count++;
         }
         $content = '<p><b>Indexer "' . $this->indexerConfig['title'] . '":</b><br />' . "\n" . $count . ' Comments have been indexed.</p>' . "\n";
         $content .= $this->showErrors();
         $content .= $this->showTime();
     }
     return $content;
 }
 /**
  * @param $eventUid
  * @param $tags
  */
 private function buildCategoryTags($eventUid, &$tags)
 {
     $table = 'tx_cal_event_category_mm, tx_cal_category';
     $fields = 'title';
     $where = 'tx_cal_category.uid = tx_cal_event_category_mm.uid_foreign';
     $where .= ' AND tx_cal_event_category_mm.uid_local = ' . intval($eventUid);
     // add enablefields
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_cal_category');
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_cal_category');
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
     $resCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res, 'res count: ');
     if ($resCount) {
         while ($catRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             // build tags for connected categories
             tx_kesearch_helper::makeTags($tags, array($catRecord['title']));
         }
     }
 }
 /**
  * This function was called from indexer object and saves content to index table
  *
  * @return string content which will be displayed in backend
  */
 public function startIndexing()
 {
     // get all address records from pid set in indexerConfig
     $fields = '*';
     $table = 'tt_address';
     $indexPids = $this->getPidList($this->indexerConfig['startingpoints_recursive'], $this->indexerConfig['sysfolder'], $table);
     if ($this->indexerConfig['index_use_page_tags']) {
         // add the tags of each page to the global page array
         $this->pageRecords = $this->getPageRecords($indexPids);
         $this->addTagsToRecords($indexPids);
     }
     $where = 'pid IN (' . implode(',', $indexPids) . ') ';
     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);
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
     $resCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
     // no address records found
     if (!$resCount) {
         $content = '<p>No address records found!</p>';
         return $content;
     }
     // if records found: process them
     while ($addressRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $abstract = '';
         $content = '';
         // set title, use company if set, otherwise name
         $title = !empty($addressRow['company']) ? $addressRow['company'] : (!empty($addressRow['name']) ? $addressRow['name'] : $addressRow['first_name'] . ' ' . $addressRow['last_name']);
         // use description as abstract if set
         if (!empty($addressRow['description'])) {
             $abstract = $addressRow['description'];
         }
         // build content
         if (!empty($addressRow['company'])) {
             $content .= $addressRow['company'] . "\n";
         }
         if (!empty($addressRow['title'])) {
             $content .= $addressRow['title'] . ' ';
         }
         if (!empty($addressRow['name'])) {
             $content .= $addressRow['name'] . "\n";
             // name
         } else {
             if (!empty($addressRow['first_name'])) {
                 $content .= $addressRow['first_name'] . ' ';
             }
             if (!empty($addressRow['middle_name'])) {
                 $content .= $addressRow['middle_name'] . ' ';
             }
             if (!empty($addressRow['last_name'])) {
                 $content .= $addressRow['last_name'] . ' ';
             }
             if (!empty($addressRow['last_name']) || !empty($addressRow['middle_name']) || !empty($addressRow['middle_name'])) {
                 $content .= "\n";
             }
         }
         if (!empty($addressRow['address'])) {
             $content .= $addressRow['address'] . "\n";
         }
         if (!empty($addressRow['zip'])) {
             $content .= $addressRow['zip'] . "\n";
         }
         if (!empty($addressRow['city'])) {
             $content .= $addressRow['city'] . "\n";
         }
         if (!empty($addressRow['country'])) {
             $content .= $addressRow['country'] . "\n";
         }
         if (!empty($addressRow['region'])) {
             $content .= $addressRow['region'] . "\n";
         }
         if (!empty($addressRow['email'])) {
             $content .= $addressRow['email'] . "\n";
         }
         if (!empty($addressRow['phone'])) {
             $content .= $addressRow['phone'] . "\n";
         }
         if (!empty($addressRow['fax'])) {
             $content .= $addressRow['fax'] . "\n";
         }
         if (!empty($addressRow['mobile'])) {
             $content .= $addressRow['mobile'] . "\n";
         }
         if (!empty($addressRow['www'])) {
             $content .= $addressRow['www'];
         }
         // put content together
         $fullContent = $abstract . "\n" . $content;
         // there is no tt_address default param like this; you have to modify this by hook to fit your needs
         $params = '&tt_address[showUid]=' . $addressRow['uid'];
         // no tags yet
         if ($this->indexerConfig['index_use_page_tags']) {
             $tagContent = $this->pageRecords[intval($addressRow['pid'])]['tags'];
         } else {
             $tagContent = '';
         }
         // set additional fields for sorting
         $additionalFields = array('sortdate' => $addressRow['tstamp']);
         // fill orig_uid
         if (isset($addressRow['uid']) && $addressRow['uid'] > 0) {
             $additionalFields['orig_uid'] = $addressRow['uid'];
         }
         // fill orig_pid
         if (isset($addressRow['pid']) && $addressRow['pid'] > 0) {
             $additionalFields['orig_pid'] = $addressRow['pid'];
         }
         // make it possible to modify the indexerConfig via hook
         $indexerConfig = $this->indexerConfig;
         // add some fields which you may set in your own hook
         $customfields = array('sys_language_uid' => 0, 'starttime' => 0, 'endtime' => 0, 'fe_group' => '');
         // hook for custom modifications of the indexed data, e. g. the tags
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyAddressIndexEntry'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyAddressIndexEntry'] as $_classRef) {
                 if (TYPO3_VERSION_INTEGER >= 7000000) {
                     $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
                 } else {
                     $_procObj =& t3lib_div::getUserObj($_classRef);
                 }
                 $_procObj->modifyAddressIndexEntry($title, $abstract, $fullContent, $params, $tagContent, $addressRow, $additionalFields, $indexerConfig, $customfields);
             }
         }
         // store in index
         $this->pObj->storeInIndex($indexerConfig['storagepid'], $title, 'tt_address', $indexerConfig['targetpid'], $fullContent, $tagContent, $params, $abstract, $customfields['sys_language_uid'], $customfields['starttime'], $customfields['endtime'], $customfields['fe_group'], false, $additionalFields);
     }
     $content = '<p><b>Indexer "' . $this->indexerConfig['title'] . '": ' . $resCount . ' address records have been indexed.</b></p>' . "\n";
     $content .= $this->showErrors();
     $content .= $this->showTime();
     return $content;
 }
 /**
  * Searches the category rootline (up) for a single view pid. If nothing is found in the current
  * category, the single view pid of the parent categories is taken (recusivly).
  * taken from tx_ttnews
  *
  * @param int $currentCategory: Uid of the current category
  * @return int first found single view pid
  */
 function getRecursiveCategorySinglePid($currentCategory)
 {
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $addWhere = ' AND tt_news_cat.deleted=0' . TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_news_cat');
     } else {
         $addWhere = ' AND tt_news_cat.deleted=0' . t3lib_befunc::BEenableFields('tt_news_cat');
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,parent_category,single_pid', 'tt_news_cat', 'tt_news_cat.uid=' . $currentCategory . $addWhere);
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     if ($row['single_pid'] > 0) {
         return $row['single_pid'];
     } elseif ($row['parent_category'] > 0) {
         return $this->getRecursiveCategorySinglePid($row['parent_category']);
     }
 }
 /**
  * This function was called from indexer object and saves content to index table
  *
  * @return string content which will be displayed in backend
  */
 public function startIndexing()
 {
     $content = '';
     $table = 'tx_a21glossary_main';
     // get the pages from where to index the news
     $indexPids = $this->getPidList($this->indexerConfig['startingpoints_recursive'], $this->indexerConfig['sysfolder'], $table);
     // add the tags of the parent page
     if ($this->indexerConfig['index_use_page_tags']) {
         $this->pageRecords = $this->getPageRecords($indexPids);
         $this->addTagsToRecords($indexPids);
     }
     // get all the glossary records to index, don't index hidden or
     // deleted glossary records, BUT  get the records with frontend user group
     // access restrictions or time (start / stop) restrictions.
     // Copy those restrictions to the index.
     $fields = '*';
     $where = 'pid IN (' . implode(',', $indexPids) . ') ';
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
     $indexedRecordsCounter = 0;
     $resCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
     if ($resCount) {
         while ($record = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             // compile the information which should go into the index:
             // short, shortcut, longversion, shorttype, description, link
             $title = strip_tags($record['short']);
             $abstract = strip_tags($record['longversion']);
             $fullContent = strip_tags($record['shortcut'] . "\n" . $record['longversion'] . "\n" . $record['description'] . "\n" . $record['link']);
             // compile params for single view, example:
             // index.php?id=16&tx_a21glossary[uid]=71&cHash=9f9368211d8ae742a8d3ad29c4f0a308
             $paramsSingleView = array();
             $paramsSingleView['tx_a21glossary']['uid'] = $record['uid'];
             $params = rawurldecode('&' . http_build_query($paramsSingleView, NULL, '&'));
             // add tags from pages
             if ($this->indexerConfig['index_use_page_tags']) {
                 $tags = $this->pageRecords[intval($record['pid'])]['tags'];
             } else {
                 $tags = '';
             }
             // make it possible to modify the indexerConfig via hook
             $indexerConfig = $this->indexerConfig;
             // set additional fields
             $additionalFields = array();
             $additionalFields['orig_uid'] = $record['uid'];
             $additionalFields['orig_pid'] = $record['pid'];
             $additionalFields['sortdate'] = $record['crdate'];
             // hook for custom modifications of the indexed data, e.g. the tags
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifya21glossaryIndexEntry'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifya21glossaryIndexEntry'] as $_classRef) {
                     $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
                     $_procObj->modifya21glossaryIndexEntry($title, $abstract, $fullContent, $params, $tags, $record, $additionalFields, $indexerConfig, $this);
                 }
             }
             // store this record to the index
             $this->pObj->storeInIndex($indexerConfig['storagepid'], $title, 'a21glossary', $indexerConfig['targetpid'], $fullContent, $tags, $params, $abstract, $record['sys_language_uid'], $record['starttime'], $record['endtime'], $record['fe_group'], false, $additionalFields);
             $indexedRecordsCounter++;
         }
         $content = '<p><b>Indexer "' . $this->indexerConfig['title'] . '":</b><br />' . "\n" . $indexedRecordsCounter . ' glossary records have been indexed.</p>' . "\n";
         $content .= $this->showErrors();
         $content .= $this->showTime();
     }
     return $content;
 }
 /**
  * get recursive DAM categories
  *
  * @param integer $catUid The category uid to search in recursive records
  * @param integer $depth Recursive depth. Normally you don't have to set it.
  * @return string A commaseperated list of category uids
  */
 public function getRecursiveDAMCategories($catUid, $depth = 0)
 {
     if ($catUid) {
         $enableFields = TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_dam_cat') . TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_dam_cat');
         $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('GROUP_CONCAT(uid) AS categoryUids', 'tx_dam_cat', 'parent_id = ' . intval($catUid) . $enableFields, '', '', '');
         // add categories to list
         $listOfCategories = $row['categoryUids'];
         $categories = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $row['categoryUids']);
         if (is_array($categories) && count($categories)) {
             foreach ($categories as $category) {
                 // only if further categories are found, add them to list
                 $tempCatList = $this->getRecursiveDAMCategories($category, $depth + 1);
                 $addCategory = count(TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tempCatList, true));
                 if ($addCategory) {
                     $listOfCategories .= ',' . $tempCatList;
                 }
             }
         }
         return ($depth === 0 ? $catUid . ',' : '') . $listOfCategories;
     } else {
         return '';
     }
 }
 /**
  * This function was called from indexer object and saves content to index table
  *
  * @return string content which will be displayed in backend
  */
 public function startIndexing()
 {
     $content = '';
     $table = 'tx_mmforum_forums';
     $indexPids = $this->getPidList($this->indexerConfig['startingpoints_recursive'], $this->indexerConfig['sysfolder'], $table);
     if ($this->indexerConfig['index_use_page_tags']) {
         // add the tags of each page to the global page array
         $this->pageRecords = $this->getPageRecords($indexPids);
         $this->addTagsToRecords($indexPids);
     }
     // get all the mm_forum forums to index
     // don't index hidden or deleted entries, BUT
     // get the entries with frontend user group access restrictions
     // or time (start / stop) restrictions.
     // Copy those restrictions to the index.
     $table = 'tx_mmforum_forums';
     $where = 'tx_mmforum_forums.pid IN (' . implode(',', $indexPids) . ') ';
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_mmforum_forums');
     $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_mmforum_forums');
     // Select forums
     $forumRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_mmforum_forums', $where, '', '', '', 'uid');
     $topicCount = 0;
     foreach ($forumRecords as $forumRecord) {
         // calculate effective group-rights recursively
         if (!empty($forumRecord['grouprights_read'])) {
             $groups = explode(',', $forumRecord['grouprights_read']);
         } else {
             $groups = array();
         }
         $parentID = $forumRecord['parentID'];
         if ($parentID) {
             $parentForum = $forumRecords[$parentID];
             if (!empty($parentForum['grouprights_read'])) {
                 $groups = array_merge($groups, explode(',', $parentForum['grouprights_read']));
             }
             $parentID = $parentForum['parentID'];
         }
         $uniqueGroups = array();
         foreach ($groups as $group) {
             $uniqueGroups[intval($group)] = intval($group);
         }
         $fegroups = implode(',', $uniqueGroups);
         // get all the mm_forum topics to index
         // don't index hidden or deleted entries, BUT
         // get the entries with frontend user group access restrictions
         // or time (start / stop) restrictions.
         // Copy those restrictions to the index.
         $table = 'tx_mmforum_topics';
         $where = 'tx_mmforum_topics.forum_id = ' . $forumRecord['uid'] . ' ';
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_mmforum_topics');
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_mmforum_topics');
         // Select topics
         $resTopic = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $where, '', '', '');
         if ($resTopic) {
             while ($topicRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resTopic)) {
                 ++$topicCount;
                 // get all the mm_forum text entries to index
                 // don't index hidden or deleted entries, BUT
                 // get the entries with frontend user group access restrictions
                 // or time (start / stop) restrictions.
                 // Copy those restrictions to the index.
                 $table = 'tx_mmforum_posts_text, tx_mmforum_posts';
                 $where = 'tx_mmforum_posts_text.post_id = tx_mmforum_posts.uid ';
                 $where .= 'AND tx_mmforum_posts.topic_id = ' . $topicRecord['uid'] . ' ';
                 $where .= 'AND tx_mmforum_posts.forum_id = ' . $forumRecord['uid'] . ' ';
                 $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_mmforum_posts_text');
                 $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_mmforum_posts');
                 $groupBy = '';
                 $orderBy = '';
                 $limit = '';
                 // Select post-texts
                 $resTexts = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_mmforum_posts_text.post_text', $table, $where, $groupBy, $orderBy, $limit);
                 $content = '';
                 if ($resTexts) {
                     while ($textRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resTexts)) {
                         $content .= strip_tags($textRecord['post_text']) . "\n";
                     }
                 }
                 // compile the information which should go into the index
                 $title = strip_tags($topicRecord['topic_title']);
                 $abstract = '';
                 $fullContent = $abstract . "\n" . $content . "\n";
                 // create params
                 $paramsSingleView = array();
                 $paramsSingleView['tx_mmforum_pi1']['action'] = 'list_post';
                 $paramsSingleView['tx_mmforum_pi1']['fid'] = $forumRecord['uid'];
                 // ###FORUM_ID###
                 $paramsSingleView['tx_mmforum_pi1']['tid'] = $topicRecord['uid'];
                 // ###TOPIC_ID###
                 $params = '&' . http_build_query($paramsSingleView, NULL, '&');
                 $params = rawurldecode($params);
                 // create tags
                 if ($this->indexerConfig['index_use_page_tags']) {
                     $tags = $this->pageRecords[intval($topicRecord['pid'])]['tags'];
                 } else {
                     $tags = '';
                 }
                 $additionalFields = array();
                 // crdate is always given, but can be overwritten
                 if (isset($topicRecord['topic_time']) && $topicRecord['topic_time'] > 0) {
                     $additionalFields['sortdate'] = $topicRecord['topic_time'];
                 }
                 // fill orig_uid
                 if (isset($topicRecord['uid']) && $topicRecord['uid'] > 0) {
                     $additionalFields['orig_uid'] = $topicRecord['uid'];
                 }
                 // fill orig_pid
                 if (isset($topicRecord['pid']) && $topicRecord['pid'] > 0) {
                     $additionalFields['orig_pid'] = $topicRecord['pid'];
                 }
                 // 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']['modifyMMForumIndexEntry'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyMMForumIndexEntry'] as $_classRef) {
                         $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
                         $_procObj->modifyMMForumIndexEntry($title, $abstract, $fullContent, $params, $tags, $postRecord, $additionalFields, $indexerConfig);
                     }
                 }
                 // ... and store them
                 $this->pObj->storeInIndex($indexerConfig['storagepid'], $title, 'mm_forum', $indexerConfig['targetpid'], $fullContent, $tags, $params, $abstract, 0, 0, 0, $fegroups, false, $additionalFields);
             }
         }
     }
     if ($topicCount) {
         $content = '<p><b>Indexer "' . $this->indexerConfig['title'] . '":</b><br />' . "\n" . $topicCount . ' mm_forum topics have been indexed.</p>' . "\n";
         $content .= $this->showTime();
     }
     $content .= $this->showErrors();
     return $content;
 }
 /**
  * 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);
     }
 }