2 namespace TYPO3\CMS\IndexedSearch\Domain\Repository;
61 $res = $db->exec_SELECTquery(
'index_grlist.*',
'index_grlist',
'phash=' . (
int)$phash);
63 $numberOfRows = $db->sql_num_rows($res);
64 while ($row = $db->sql_fetch_assoc($res)) {
65 $row[
'pcount'] = $numberOfRows;
68 $db->sql_free_result($res);
80 return $this->
getDatabaseConnection()->exec_SELECTcountRows(
'phash',
'index_fulltext',
'phash=' . (
int)$phash);
91 return $this->
getDatabaseConnection()->exec_SELECTcountRows(
'*',
'index_rel',
'phash=' . (
int)$phash);
104 $res = $db->exec_SELECTquery(
105 'count(*) AS pcount,index_phash.*',
108 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid,freeIndexSetId',
111 while ($row = $db->sql_fetch_assoc($res)) {
116 if ($row[
'pcount'] > 1) {
117 $res2 = $db->exec_SELECTquery(
120 'phash_grouping=' . (
int)$row[
'phash_grouping'] .
' AND phash<>' . (
int)$row[
'phash']
122 while ($row2 = $db->sql_fetch_assoc($res2)) {
126 $db->sql_free_result($res2);
129 $db->sql_free_result($res);
149 $recordList = array();
150 foreach ($tables as $tableName) {
171 $revTypes = array_flip($types);
172 $revTypes[0] =
'TYPO3 page';
174 $res = $db->exec_SELECTquery(
'count(*),item_type',
'index_phash',
'',
'item_type',
'item_type');
175 while ($row = $db->sql_fetch_row($res)) {
179 'name' => $revTypes[$itemType],
184 $db->sql_free_result($res);
198 $res = $db->exec_SELECTquery(
201 'item_type=' . $db->fullQuoteStr($itemType,
'index_phash'),
205 while ($row = $db->sql_fetch_row($res)) {
208 $db->sql_free_result($res);
210 return count($items);
221 return $this->
getDatabaseConnection()->exec_SELECTcountRows(
'phash',
'index_section',
'phash=' . (
int)$pageHash);
233 $res = $db->exec_SELECTquery(
234 'count(*) AS pcount,index_phash.*',
237 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid,freeIndexSetId',
240 while ($row = $db->sql_fetch_assoc($res)) {
244 if ($row[
'pcount'] > 1) {
245 $res2 = $db->exec_SELECTquery(
248 'phash_grouping=' . (
int)$row[
'phash_grouping'] .
' AND phash<>' . (
int)$row[
'phash']
250 while ($row2 = $db->sql_fetch_assoc($res2)) {
254 $db->sql_free_result($res2);
257 $db->sql_free_result($res);
273 'SELECT' =>
'word, COUNT(*) AS c',
274 'FROM' =>
'index_stat_word',
275 'WHERE' => sprintf(
'pageid= %d ' . $additionalWhere, $pageUid),
281 $res = $db->exec_SELECTquery(
282 $queryParts[
'SELECT'],
284 $queryParts[
'WHERE'],
285 $queryParts[
'GROUPBY'],
286 $queryParts[
'ORDERBY'],
292 $count = $db->sql_num_rows($res);
295 $db->sql_free_result($res);
300 $secureAddWhere =
' AND pageid IN (' . $this->
extGetTreeList((
int)$pageUid, 100, 0,
'1=1') .
') ';
301 $queryParts[
'WHERE'] =
'1=1 ' . $additionalWhere . $secureAddWhere;
304 return $db->exec_SELECTgetRows(
305 $queryParts[
'SELECT'],
307 $queryParts[
'WHERE'],
308 $queryParts[
'GROUPBY'],
309 $queryParts[
'ORDERBY'],
323 $unserializedCHashParams = unserialize($row[
'cHashParams']);
328 $row[
'cHashParams'] = !empty($unserializedCHashParams) ? $unserializedCHashParams :
'';
329 $row[
'grList'] = $grListRec;
340 public function getTree($pageId, $depth = 4, $mode)
350 $tree->init(
'AND ' . $perms_clause);
352 $HTML =
'<span title="' . htmlspecialchars($pageRecord[
'title']) .
'">' . $iconFactory->getIconForRecord(
'pages', $pageRecord,
Icon::SIZE_SMALL)->render() .
'</span>';
353 $tree->tree[] = array(
354 'row' => $pageRecord,
359 $tree->getTree((
int)$pageId, $depth,
'');
362 foreach ($tree->tree as $singleLine) {
363 $res = $db->exec_SELECTquery(
364 'ISEC.phash_t3, ISEC.rl0, ISEC.rl1, ISEC.rl2, ISEC.page_id, ISEC.uniqid, ' .
365 'IP.phash, IP.phash_grouping, IP.cHashParams, IP.data_filename, IP.data_page_id, ' .
366 'IP.data_page_reg1, IP.data_page_type, IP.data_page_mp, IP.gr_list, IP.item_type, ' .
367 'IP.item_title, IP.item_description, IP.item_mtime, IP.tstamp, IP.item_size, ' .
368 'IP.contentHash, IP.crdate, IP.parsetime, IP.sys_language_uid, IP.item_crdate, ' .
369 'IP.externalUrl, IP.recordUid, IP.freeIndexUid, IP.freeIndexSetId, count(*) AS count_val',
370 'index_phash IP, index_section ISEC',
371 'IP.phash = ISEC.phash AND ISEC.page_id = ' . (
int)$singleLine[
'row'][
'uid'],
372 'IP.phash,IP.phash_grouping,IP.cHashParams,IP.data_filename,IP.data_page_id,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2,ISEC.page_id,ISEC.uniqid,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId',
373 'IP.item_type, IP.tstamp',
379 while ($row = $db->sql_fetch_assoc($res)) {
380 $this->allPhashListed[] = $row[
'phash'];
383 $row[
'wordCount'] = count($db->exec_SELECTgetRows(
384 'index_words.baseword, index_rel.*',
385 'index_rel, index_words',
386 'index_rel.phash = ' . (
int)$row[
'phash'] .
' AND index_words.wid = index_rel.wid',
393 if ($mode ===
'content') {
394 $row[
'fulltextData'] = $db->exec_SELECTgetSingleRow(
397 'phash = ' . $row[
'phash']);
398 $wordRecords = $db->exec_SELECTgetRows(
399 'index_words.baseword, index_rel.*',
400 'index_rel, index_words',
401 'index_rel.phash = ' . (
int)$row[
'phash'] .
' AND index_words.wid = index_rel.wid',
402 '',
'',
'',
'baseword');
403 if (is_array($wordRecords)) {
404 $indexed_words = array_keys($wordRecords);
405 sort($indexed_words);
406 $row[
'allWords'] = $indexed_words;
413 $singleLine[
'lines'] = $lines;
414 $allLines[] = $singleLine;
451 public function removeIndexedPhashRow($phashList, $pageId, $depth = 4)
453 if ($phashList ===
'ALL') {
454 $this->getTree($pageId, $depth,
'');
456 $this->allPhashListed = array();
462 foreach ($phashRows as $phash) {
463 $phash = (int)$phash;
466 $res = $db->exec_SELECTquery(
'page_id',
'index_section',
'phash=' . $phash);
467 while ($row = $db->sql_fetch_assoc($res)) {
468 $idList[] = (int)$row[
'page_id'];
470 $db->sql_free_result($res);
472 if (!empty($idList)) {
475 foreach ($idList as $pageId) {
476 $pageCache->flushByTag(
'pageId_' . $pageId);
481 $tableArr = array(
'index_phash',
'index_rel',
'index_section',
'index_grlist',
'index_fulltext',
'index_debug');
482 foreach ($tableArr as $table) {
483 $db->exec_DELETEquery($table,
'phash=' . $phash);
497 foreach ($words as $wid => $state) {
499 'is_stopword' => (
int)$state
516 if (!is_array($pageRec)) {
521 foreach ($words as $key => $v) {
525 unset($keywords[$key]);
530 $data[
'pages'][$pageId][
'keywords'] = implode(
', ', array_keys($keywords));
532 $dataHandler->stripslashes_values = 0;
533 $dataHandler->start($data, array());
534 $dataHandler->process_datamap();
545 if (!isset($this->iconFileNameCache[$itemType])) {
547 if ($itemType ===
'0') {
548 $icon =
'EXT:indexed_search/Resources/Public/Icons/FileTypes/pages.gif';
549 }
elseif ($this->external_parsers[$itemType]) {
550 $icon = $this->external_parsers[$itemType]->getIcon($itemType);
552 $this->iconFileNameCache[$itemType] = $icon;
554 return $this->iconFileNameCache[$itemType];