/** * Test additional query parts for additional fields * @test */ public function getTagTest() { $fields = 'uid, title, tag'; $table = 'tx_kesearch_filteroptions'; $where = '1=1 '; $where .= t3lib_befunc::BEenableFields($table, 0); $where .= t3lib_befunc::deleteClause($table, 0); $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow($fields, $table, $where); if (is_array($row) && count($row)) { $return = $this->indexer->getTag($row['uid'], false); $this->assertEquals($row['tag'], $return); $return = $this->indexer->getTag($row['uid'], true); $this->assertEquals($row['title'], $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() { // 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; }
/** * Adds tags from the ext:news table "tags" as ke_search tags to the index entry * * @author Christian Bülter <*****@*****.**> * @since 26.06.13 14:25 * @param string $tags * @param array $newsRecord * @return string comma-separated list of tags */ private function addTagsFromNewsTags($tags, $newsRecord) { if (TYPO3_VERSION_INTEGER >= 7000000) { $addWhere = \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_news_domain_model_tag') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_news_domain_model_tag'); } else { $addWhere = t3lib_befunc::BEenableFields('tx_news_domain_model_tag') . t3lib_befunc::deleteClause('tx_news_domain_model_tag'); } $resTag = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_news_domain_model_tag.title', 'tx_news_domain_model_news', 'tx_news_domain_model_news_tag_mm', 'tx_news_domain_model_tag', ' AND tx_news_domain_model_news.uid = ' . $newsRecord['uid'] . $addWhere); while ($newsTag = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resTag)) { tx_kesearch_helper::makeTags($tags, array($newsTag['title'])); } return $tags; }
/** * Returns an array of available Page Template Object records from the scope of the given page. * * Note: All TO records which are found in the selected storage folder will be returned, no matter * if they match the currently selected data structure for the given page. * * @param integer $pageUid: (current) page uid, used for finding the correct storage folder * @return mixed Array of Template Object records or FALSE if an error occurred. * @access public */ function ds_getAvailablePageTORecords($pageUid) { global $TYPO3_DB; $storageFolderPID = $this->getStorageFolderPid($pageUid); $tTO = 'tx_templavoila_tmplobj'; $tDS = 'tx_templavoila_datastructure'; $res = $TYPO3_DB->exec_SELECTquery("{$tTO}.*", "{$tTO} LEFT JOIN {$tDS} ON {$tTO}.datastructure = {$tDS}.uid", "{$tTO}.pid=" . intval($storageFolderPID) . " AND {$tDS}.scope=1" . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS)); if (!$res) { return FALSE; } $templateObjectRecords = array(); while (false != ($row = $TYPO3_DB->sql_fetch_assoc($res))) { $templateObjectRecords[$row['uid']] = $row; } return $templateObjectRecords; }
/** * 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 = ''; $this->conf['useHRDatesSingle'] = $this->indexerConfig['index_news_useHRDatesSingle']; $this->conf['useHRDatesSingleWithoutDay'] = $this->indexerConfig['index_news_useHRDatesSingleWithoutDay']; // get all the tt_news entries to index // don't index hidden or deleted news, BUT // get the news with frontend user group access restrictions // or time (start / stop) restrictions. // Copy those restrictions to the index. $fields = '*'; $table = 'tt_news'; $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); $counter = 0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { while ($newsRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // if mode equals 'choose categories for indexing' (2). 1 = All if ($this->indexerConfig['index_news_category_mode'] == '2') { if (TYPO3_VERSION_INTEGER >= 7000000) { $enableFields = TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_news_cat') . TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_news_cat'); } else { $enableFields = t3lib_befunc::BEenableFields('tt_news_cat') . t3lib_befunc::deleteClause('tt_news_cat'); } $resCat = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tt_news_cat.uid', 'tt_news', 'tt_news_cat_mm', 'tt_news_cat', ' AND tt_news.uid = ' . $newsRecord['uid'] . $enableFields, '', '', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($resCat)) { $isInList = false; while ($newsCat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resCat)) { // if category was found in list, set isInList to true and break further processing. if (TYPO3_VERSION_INTEGER >= 7000000) { if (TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->indexerConfig['index_news_category_selection'], $newsCat['uid'])) { $isInList = true; break; } } else { if (t3lib_div::inList($this->indexerConfig['index_news_category_selection'], $newsCat['uid'])) { $isInList = true; break; } } } // if category was not found stop further processing and loop with next news record if (!$isInList) { continue; } } } // compile the information which should go into the index $type = 'tt_news'; $title = strip_tags($newsRecord['title']); $abstract = strip_tags($newsRecord['short']); $content = strip_tags($newsRecord['bodytext']); // add keywords to content if not empty if (!empty($newsRecord['keywords'])) { $content .= "\n" . $newsRecord['keywords']; } // create content $fullContent = $abstract . "\n" . $content; // create params and custom single view page: // if it is a default news (type = 0), add params // if it is an internal page (type = 1), put that into the "targetpid" field // if it is an external url (type = 2), put that into the "params" field if ($newsRecord['type'] == 1) { $singleViewPage = $newsRecord['page']; $params = ''; } else { if ($newsRecord['type'] == 2) { $type = 'external:tt_news'; $singleViewPage = ''; $params = $newsRecord['ext_url']; } else { // get target page from category if set (first assigned category) if (TYPO3_VERSION_INTEGER < 6002000) { $ttnewsIsLoaded = t3lib_extMgm::isLoaded('tt_news'); } else { $ttnewsIsLoaded = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tt_news'); } if ($ttnewsIsLoaded) { $singleViewPage = $this->getSingleViewPageFromCategories($newsRecord['uid']); } $paramsSingleView = $this->getParamsForHrDateSingleView($newsRecord['datetime']); $paramsSingleView['tx_ttnews']['tt_news'] = $newsRecord['uid']; $params = '&' . http_build_query($paramsSingleView, NULL, '&'); $params = rawurldecode($params); } } // create tags if ($this->indexerConfig['index_use_page_tags']) { $tags = $this->pageRecords[intval($newsRecord['pid'])]['tags']; } else { $tags = ''; } // add additional fields $additionalFields = array(); // crdate is always given, but can be overwritten $additionalFields['sortdate'] = $newsRecord['crdate']; // last changed date if (isset($newsRecord['datetime']) && $newsRecord['datetime'] > 0) { $additionalFields['sortdate'] = $newsRecord['datetime']; } // fill orig_uid and orig_pid $additionalFields['orig_uid'] = $newsRecord['uid']; $additionalFields['orig_pid'] = $newsRecord['pid']; // make it possible to modify the indexerConfig via hook $indexerConfig = $this->indexerConfig; // overwrite default targetpid value from indexerconfig // only if $singleViewPage is set if ($singleViewPage) { $indexerConfig['targetpid'] = $singleViewPage; } // hook for custom modifications of the indexed data, e. g. the tags if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyNewsIndexEntry'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyNewsIndexEntry'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->modifyNewsIndexEntry($title, $abstract, $fullContent, $params, $tags, $newsRecord, $additionalFields, $indexerConfig); } } // ... and store them $this->pObj->storeInIndex($indexerConfig['storagepid'], $title, $type, $indexerConfig['targetpid'], $fullContent, $tags, $params, $abstract, $newsRecord['sys_language_uid'], $newsRecord['starttime'], $newsRecord['endtime'], $newsRecord['fe_group'], false, $additionalFields); $counter++; } $content = '<p><b>Indexer "' . $this->indexerConfig['title'] . '":</b><br />' . "\n" . $counter . ' news have been indexed.</p>' . "\n"; $content .= $this->showErrors(); $content .= $this->showTime(); } return $content; }
/** * Renders the template selector. * * @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page. * @param string $templateType: The template type, 'tmplobj' or 't3d' * @return string HTML output containing a table with the template selector */ function renderTemplateSelector($positionPid, $templateType = 'tmplobj') { global $LANG, $TYPO3_DB; $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid); $tmplHTML = array(); switch ($templateType) { case 'tmplobj': // Create the "Default template" entry $previewIconFilename = $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif'; $previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />'; $description = htmlspecialchars($LANG->getLL('template_descriptiondefault')); $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titledefault')) . '</h3></td></tr> <tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>'; $tTO = 'tx_templavoila_tmplobj'; $tDS = 'tx_templavoila_datastructure'; $where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . $tDS . '.scope=1' . $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS); $res = $TYPO3_DB->exec_SELECTquery($tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', $where); while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) { // Check if preview icon exists, otherwise use default icon: $tmpFilename = 'uploads/tx_templavoila/' . $row['previewicon']; $previewIconFilename = @is_file(PATH_site . $tmpFilename) ? $GLOBALS['BACK_PATH'] . '../' . $tmpFilename : $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif'; // Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376 $previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $row['uid'] . '" src="' . $previewIconFilename . '" title="" />'; $description = $row['description'] ? htmlspecialchars($row['description']) : $LANG->getLL('template_nodescriptionavailable'); $tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($row['title']) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>'; } $tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />'; break; case 't3d': if (t3lib_extMgm::isLoaded('impexp')) { // Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests. $templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/'; $files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1); // Traverse the files found: foreach ($files as $absPath) { // Initialize the import object: $import = $this->getImportObject(); if ($import->loadFile($absPath)) { if (is_array($import->dat['header']['pagetree'])) { // This means there are pages in the file, we like that...: // Page tree: reset($import->dat['header']['pagetree']); $pageTree = current($import->dat['header']['pagetree']); // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension']; t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; } else { t3lib_div::unlink_tempfile($fileName); $iconTag = ''; } } } $aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">'; $aTagE = '</a>'; $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"> <h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr> <tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p> <em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/> File: ' . basename($absPath) . '</em></td></tr></table>'; } } } } break; } if (is_array($tmplHTML) && count($tmplHTML)) { $counter = 0; $content .= '<table>'; foreach ($tmplHTML as $single) { $content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : ''); $counter++; if ($counter > 1) { $counter = 0; } } $content .= '</table>'; } return $content; }
/** * this function returns all indexer configurations found in DB * independant of PID */ public function getConfigurations() { $fields = '*'; $table = 'tx_kesearch_indexerconfig'; $where = '1=1 '; 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); } return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where); }
function checkTicketAdmin() { // get cobj from db $where = 'uid=' . $this->cObjId; $where .= t3lib_BEfunc::BEenableFields('tt_content'); $where .= t3lib_befunc::deleteClause('tt_content'); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pi_flexform', 'tt_content', $where, '', '', $limit = 1); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); if (!empty($row['pi_flexform'])) { $ffData = t3lib_div::xml2array($row['pi_flexform']); } $ticketAdmins = $ffData['data']['sheetUsers']['lDEF']['ticket_administrators']['vDEF']; if ($ticketAdmins) { if (t3lib_div::inList($ticketAdmins, $this->feUserObj->user['ses_userid'])) { return true; } } else { return false; } }
function getListOfAvailableFilteroptionsForFlexforms(&$config) { // get id from string if (strstr($config['row']['pages'], 'pages_')) { $intString = str_replace('pages_', '', $config['row']['pages']); $intString = substr($intString, 0, strpos($intString, '|')); $intString = intval($intString); } else { $intString = intval($config['row']['pages']); } // print message if no startingpoint is set in plugin config if (empty($intString)) { $config['items'][] = array('[SET STARTINGPOINT FIRST!]', ''); } // get filters $fields = '*'; $table = 'tx_kesearch_filters'; $where = 'pid IN(' . $intString . ') '; if (TYPO3_VERSION_INTEGER > 7000000) { $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table, $inv = 0); $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table, $inv = 0); } else { $where .= t3lib_befunc::BEenableFields($table, $inv = 0); $where .= t3lib_befunc::deleteClause($table, $inv = 0); } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where, $groupBy = '', $orderBy = '', $limit = ''); while ($rowFilter = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if (!empty($rowFilter['options'])) { // get filteroptions $fieldsOpts = '*'; $tableOpts = 'tx_kesearch_filteroptions'; $whereOpts = 'uid in (' . $rowFilter['options'] . ')'; if (TYPO3_VERSION_INTEGER > 7000000) { $whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableOpts, $inv = 0); $whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableOpts, $inv = 0); } else { $whereOpts .= t3lib_befunc::BEenableFields($tableOpts, $inv = 0); $whereOpts .= t3lib_befunc::deleteClause($tableOpts, $inv = 0); } $resOpts = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fieldsOpts, $tableOpts, $whereOpts, $groupBy = '', $orderBy = '', $limit = ''); while ($rowOpts = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resOpts)) { $config['items'][] = array($rowFilter['title'] . ': ' . $rowOpts['title'], $rowOpts['uid']); } } } }
/** * 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) { if (TYPO3_VERSION_INTEGER >= 7000000) { $enableFields = TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_dam_cat') . TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_dam_cat'); } else { $enableFields = t3lib_befunc::BEenableFields('tx_dam_cat') . t3lib_befunc::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']; if (TYPO3_VERSION_INTEGER >= 7000000) { $categories = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $row['categoryUids']); } else { $categories = t3lib_div::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); if (TYPO3_VERSION_INTEGER >= 7000000) { $addCategory = count(TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tempCatList, true)); } else { $addCategory = count(t3lib_div::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_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) . ') '; 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); $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) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::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; }
/** * 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'; if (TYPO3_VERSION_INTEGER >= 7000000) { $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); } else { $where .= ' AND external_prefix IN ("' . implode('","', t3lib_div::trimExplode(',', $this->indexerConfig['commenttypes'])) . '")'; $where .= t3lib_befunc::BEenableFields($table); $where .= t3lib_befunc::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; // 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) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::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; }
/** * returns the list of assigned categories to a certain record in a certain table * * @param integer $uid * @param string $table * @author Christian Bülter <*****@*****.**> * @since 17.10.14 * @return array */ public static function getCategories($uid, $table) { $categoryData = array('uid_list' => array(), 'title_list' => array()); if ($uid && $table) { if (TYPO3_VERSION_INTEGER >= 7000000) { $enableFields = \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('sys_category') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_category'); } else { $enableFields = t3lib_befunc::BEenableFields('sys_category') . t3lib_befunc::deleteClause('sys_category'); } $resCat = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('sys_category.uid, sys_category.title', 'sys_category', 'sys_category_record_mm', $table, ' AND ' . $table . '.uid = ' . $uid . ' AND sys_category_record_mm.tablenames = "' . $table . '"' . $enableFields, '', 'sys_category_record_mm.sorting'); if ($GLOBALS['TYPO3_DB']->sql_num_rows($resCat)) { while ($cat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resCat)) { $categoryData['uid_list'][] = $cat['uid']; $categoryData['title_list'][] = $cat['title']; } } } return $categoryData; }
public function getTag($tagUid, $clearText = false) { $fields = 'title,tag'; $table = 'tx_kesearch_filteroptions'; $where = 'uid="' . intval($tagUid) . '" '; 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, $groupBy = '', $orderBy = '', $limit = '1'); $anz = $GLOBALS['TYPO3_DB']->sql_num_rows($res); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); if ($clearText) { return $row['title']; } else { return $row['tag']; } }