Commit 9746ed4c authored by Georg Ringer's avatar Georg Ringer Committed by Tymoteusz Motylewski
Browse files

[!!!][TASK] Remove old BE implementation of indexed_search

The old code can be removed as the new module has been merged.

The breaking change is already documented in the file
'Breaking-61510-IndexedSearch.rst'

Change-Id: Ief1867cbaa2f0768e3e8c08c490e64963b91a06c
Resolves: #61638
Releases: master
Reviewed-on: http://review.typo3.org/35338


Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Tested-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Reviewed-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
parent f2a8ef9c
......@@ -1028,9 +1028,6 @@ return array(
'tx_impexp' => \TYPO3\CMS\Impexp\ImportExport::class,
'tx_impexp_localPageTree' => \TYPO3\CMS\Impexp\LocalPageTree::class,
'tx_impexp_task' => \TYPO3\CMS\Impexp\Task\ImportExportTask::class,
'tx_indexedsearch_modfunc1' => \TYPO3\CMS\IndexedSearch\Controller\IndexedPagesController::class,
'tx_indexedsearch_modfunc2' => \TYPO3\CMS\IndexedSearch\Controller\IndexingStatisticsController::class,
'SC_mod_tools_isearch_index' => \TYPO3\CMS\IndexedSearch\Controller\ModuleController::class,
'Tx_IndexedSearch_Controller_SearchController' => \TYPO3\CMS\IndexedSearch\Controller\SearchController::class,
'tx_indexedsearch' => \TYPO3\CMS\IndexedSearch\Controller\SearchFormController::class,
'Tx_IndexedSearch_Domain_Repository_IndexSearchRepository' => \TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::class,
......
......@@ -5121,21 +5121,6 @@ class tx_impexp_localPageTree extends \TYPO3\CMS\Impexp\LocalPageTree {}
*/
class tx_impexp_task extends \TYPO3\CMS\Impexp\Task\ImportExportTask {}
/**
* @deprecated since 6.0, removed since 7.0
*/
class tx_indexedsearch_modfunc1 extends \TYPO3\CMS\IndexedSearch\Controller\IndexedPagesController {}
/**
* @deprecated since 6.0, removed since 7.0
*/
class tx_indexedsearch_modfunc2 extends \TYPO3\CMS\IndexedSearch\Controller\IndexingStatisticsController {}
/**
* @deprecated since 6.0, removed since 7.0
*/
class SC_mod_tools_isearch_index extends \TYPO3\CMS\IndexedSearch\Controller\ModuleController {}
/**
* @deprecated since 6.0, removed since 7.0
*/
......
<?php
namespace TYPO3\CMS\IndexedSearch\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Module extension (addition to function menu) 'Indexed search statistics' for the 'indexed_search' extension.
*
* @author Dimitri Ebert <dimitri.ebert@dkd.de>
*/
class IndexingStatisticsController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
/**
* Default constructor loads additional locallang
*/
public function __construct() {
$GLOBALS['LANG']->includeLLFile('EXT:indexed_search/modfunc2/locallang.xlf');
}
/**
* Calls showStats to generate output.
*
* @return string html table with results from showStats()
*/
public function main() {
// Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
$theOutput = $this->pObj->doc->header($GLOBALS['LANG']->getLL('title'));
$theOutput .= $this->pObj->doc->section('', $this->showStats(), 0, 1);
$menu = array();
$functionMenu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[tx_indexedsearch_modfunc2_check]', $this->pObj->MOD_SETTINGS['tx_indexedsearch_modfunc2_check'], '', '', 'id="checkTx_indexedsearch_modfunc2_check"');
$menu[] = $functionMenu . '<label for="checkTx_indexedsearch_modfunc2_check"' . $GLOBALS['LANG']->getLL('checklabel') . '</label>';
$theOutput .= $this->pObj->doc->spacer(5);
return $theOutput;
}
/**
* Generates html table containing the statistics.
* Calls listSeveralStats 3 times, for all statistics, statistics of the last 30 days and statistics of the last 24 hours.
*
* @return string html table with results
*/
public function showStats() {
$conf['words'] = 50;
// max words in result list
$conf['bid'] = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id');
// pageid for several statistics
$addwhere1 = '';
// all records
$addwhere2 = ' AND tstamp > ' . ($GLOBALS['EXEC_TIME'] - 30 * 24 * 60 * 60);
// last 30 days
$addwhere3 = ' AND tstamp > ' . ($GLOBALS['EXEC_TIME'] - 24 * 60 * 60);
// last 24 hours
$content = '<p class="lead">' . $GLOBALS['LANG']->getLL('title2') . '</p>';
$content .= '<table cellpading="5" cellspacing="5" valign="top" class=""><tr><td valign="top">' . $this->listSeveralStats($GLOBALS['LANG']->getLL('all'), $addwhere1, $conf) . '</td><td valign="top">' . $this->listSeveralStats($GLOBALS['LANG']->getLL('last30days'), $addwhere2, $conf) . '</td><td valign="top">' . $this->listSeveralStats($GLOBALS['LANG']->getLL('last24hours'), $addwhere3, $conf) . '</td></tr></table>';
$content .= '<p>' . $this->note . '</p>';
// Ask hook to include more on the page:
if ($hookObj = $this->hookRequest('additionalSearchStat')) {
$content .= $hookObj->additionalSearchStat();
}
return $content;
}
/**
* Generates html table with title and several statistics
*
* @param string title for statistic, like 'Last 30 days' or 'Last 24 hours'
* @param string add where for sql query
* @param array configuration: words = max words for results, bid = pageid
* @return string html table with results
*/
public function listSeveralStats($title, $addwhere, $conf) {
$queryParts['SELECT'] = 'word, COUNT(*) AS c';
$queryParts['FROM'] = 'index_stat_word';
$queryParts['WHERE'] = sprintf('pageid= %d ' . $addwhere, $conf['bid']);
$queryParts['GROUPBY'] = 'word';
$queryParts['ORDERBY'] = 'c DESC,word';
$queryParts['LIMIT'] = $conf['words'];
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']);
if ($res) {
$count = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
} else {
$count = 0;
}
// exist several statistics for this page?
if ($count > 0) {
$this->note = $GLOBALS['LANG']->getLL('justthispage');
} else {
// Limit access to pages of the current site
$secureaddwhere = ' AND pageid IN (' . $this->extGetTreeList($conf['bid'], 100, 0, '1=1') . $conf['bid'] . ') ';
$this->note = $GLOBALS['LANG']->getLL('allpages');
$queryParts['WHERE'] = '1=1 ' . $addwhere . $secureaddwhere;
}
// make real query
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']);
$table1 = '';
$i = 0;
if ($res) {
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$i++;
$table1 .= '<tr class="bgColor4"><td>' . $i . '.</td><td>' . htmlspecialchars($row['word']) . '</td><td>&nbsp;&nbsp;' . $row['c'] . '</td></tr>';
}
}
if ($i == 0) {
$table1 = '<tr class="bgColor4"><td callspan="3">' . $GLOBALS['LANG']->getLL('noresults') . '</td></tr>';
}
$table1 = '<table class="bgColor5" cellpadding="2" cellspacing="1"><tr class="tableheader"><td colspan="3">' . $title . '</td></tr>' . $table1 . '</table>';
return $note . $table1;
}
/**
* Calls \TYPO3\CMS\Backend\FrontendBackendUserAuthentication::extGetTreeList.
* Although this duplicates the function \TYPO3\CMS\Backend\FrontendBackendUserAuthentication::extGetTreeList
* this is necessary to create the object that is used recursively by the original function.
*
* Generates a list of Page-uid's from $id. List does not include $id itself
* The only pages excluded from the list are deleted pages.
*
* @param int Start page id
* @param int Depth to traverse down the page tree.
* @param int $begin is an optional integer that determines at which level in the tree to start collecting uid's. Zero means 'start right away', 1 = 'next level and out'
* @param string Perms clause
* @return string Returns the list with a comma in the end (if any pages selected!)
*/
public function extGetTreeList($id, $depth, $begin = 0, $perms_clause) {
return GeneralUtility::makeInstance(\TYPO3\CMS\Backend\FrontendBackendUserAuthentication::class)->extGetTreeList($id, $depth, $begin, $perms_clause);
}
/**
* Returns an object reference to the hook object if any
*
* @param string Name of the function you want to call / hook key
* @return object Hook object, if any. Otherwise NULL.
* @author Kasper Skårhøj
*/
public function hookRequest($functionName) {
// Hook: menuConfig_preProcessModMenu
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['be_hooks'][$functionName]) {
$hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['be_hooks'][$functionName]);
if (method_exists($hookObj, $functionName)) {
$hookObj->pObj = $this;
return $hookObj;
}
}
}
}
<?php
namespace TYPO3\CMS\IndexedSearch\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
/**
* Backend module providing boring statistics of the index-tables.
*
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
*/
class ModuleController {
/**
* @var array
*/
public $MCONF = array();
/**
* @var array
*/
public $MOD_MENU = array();
/**
* @var array
*/
public $MOD_SETTINGS = array();
/**
* document template object
*
* @var \TYPO3\CMS\Backend\Template\DocumentTemplate
*/
public $doc;
/**
* @var array
*/
public $include_once = array();
/**
* @var string
*/
public $content;
/**
* Constructor
*/
public function __construct() {
$GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], TRUE);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('indexed_search', TRUE);
}
/**
* Initialization
*
* @return void
*/
public function init() {
$this->MCONF = $GLOBALS['MCONF'];
$this->menuConfig();
$this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
$this->doc->form = '<form action="" method="post">';
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->doc->setModuleTemplate(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('indexed_search') . '/mod/mod_template.html');
$this->doc->tableLayout = array(
'defRow' => array(
'0' => array('<td valign="top" nowrap>', '</td>'),
'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width=10 height=1></td><td valign="top" nowrap>', '</td>')
)
);
$indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class);
$indexer->initializeExternalParsers();
}
/**
* MENU-ITEMS:
* If array, then it's a selector box menu
* If empty string it's just a variable, that'll be saved.
* Values NOT in this array will not be saved in the settings-array for the module.
*
* @return void
*/
public function menuConfig() {
$this->MOD_MENU = array(
'function' => array(
'stat' => 'General statistics',
'typo3pages' => 'List: TYPO3 Pages',
'externalDocs' => 'List: External documents'
)
);
// cleanse settings
$this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $this->MCONF['name'], 'ses');
}
/**
* Main function to generate the content
*
* @return void
*/
public function main() {
$this->content = $this->doc->header('Indexing Engine Statistics');
$this->content .= $this->doc->spacer(5);
switch ($this->MOD_SETTINGS['function']) {
case 'stat':
$this->content .= $this->doc->section('Records', $this->doc->table($this->getRecordsNumbers()), 0, 1);
$this->content .= $this->doc->spacer(15);
$this->content .= $this->doc->section('index_phash TYPES', $this->doc->table($this->getPhashTypes()), 1);
$this->content .= $this->doc->spacer(15);
break;
case 'externalDocs':
$this->content .= $this->doc->section('External documents', $this->doc->table($this->getPhashExternalDocs()), 0, 1);
$this->content .= $this->doc->spacer(15);
break;
case 'typo3pages':
$this->content .= $this->doc->section('TYPO3 Pages', $this->doc->table($this->getPhashT3pages()), 0, 1);
$this->content .= $this->doc->spacer(15);
break;
}
$docHeaderButtons = $this->getButtons();
$markers = array(
'CSH' => $docHeaderButtons['csh'],
'FUNC_MENU' => BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
'CONTENT' => $this->content
);
$this->content = $this->doc->startPage('Indexing Engine Statistics');
$this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
$this->content .= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
}
/**
* Print content
*
* @return void
*/
public function printContent() {
echo $this->content;
}
/**
* Create the panel of buttons for submitting the form or otherwise perform operations.
*
* @return array all available buttons as an assoc. array
*/
protected function getButtons() {
$buttons = array(
'csh' => '',
'shortcut' => ''
);
// Shortcut
if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
$buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
}
return $buttons;
}
/***************************
*
* OTHER FUNCTIONS:
*
***************************/
/**
* @return [type] ...
*/
public function getRecordsNumbers() {
$tables = explode(',', 'index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext');
$recList = array();
foreach ($tables as $t) {
$recList[] = array(
$this->tableHead($t),
$GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $t)
);
}
return $recList;
}
/**
* [Describe function...]
*
* @param [type] $str: ...
* @return [type] ...
*/
public function tableHead($str) {
return '<strong>' . $str . ':&nbsp;&nbsp;&nbsp;</strong>';
}
/**
* [Describe function...]
*
* @return [type] ...
*/
public function getPhashStat() {
$recList = array();
// TYPO3 pages, unique
$items = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id<>0', 'phash_grouping,pcount,phash');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
$items[] = $row;
}
$recList[] = array($this->tableHead('TYPO3 pages'), count($items));
// TYPO3 pages:
$recList[] = array(
$this->tableHead('TYPO3 pages, raw'),
$GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_phash', 'data_page_id<>0')
);
// External files, unique
$items = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename<>\'\'', 'phash_grouping');
$row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
$recList[] = array($this->tableHead('External files'), $row[0]);
// External files
$recList[] = array(
$this->tableHead('External files, raw'),
$GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_phash', 'data_filename<>\'\'')
);
return $recList;
}
/**
* [Describe function...]
*
* @return [type] ...
*/
public function getPhashT3pages() {
$recList[] = array(
$this->tableHead('id/type'),
$this->tableHead('Title'),
$this->tableHead('Size'),
$this->tableHead('Words'),
$this->tableHead('mtime'),
$this->tableHead('Indexed'),
$this->tableHead('Updated'),
$this->tableHead('Parsetime'),
$this->tableHead('#sec/gr/full'),
$this->tableHead('#sub'),
$this->tableHead('Lang'),
$this->tableHead('cHash'),
$this->tableHead('phash')
);
// TYPO3 pages, unique
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'data_page_id<>0', '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', 'data_page_id');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$cHash = count(unserialize($row['cHashParams'])) ? $this->formatCHash(unserialize($row['cHashParams'])) : '';
$grListRec = $this->getGrlistRecord($row['phash']);
$recList[] = array(
$row['data_page_id'] . ($row['data_page_type'] ? '/' . $row['data_page_type'] : ''),
htmlentities(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['item_title'], 30)),
\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row['item_size']),
$this->getNumberOfWords($row['phash']),
BackendUtility::datetime($row['item_mtime']),
BackendUtility::datetime($row['crdate']),
$row['tstamp'] != $row['crdate'] ? BackendUtility::datetime($row['tstamp']) : '',
$row['parsetime'],
$this->getNumberOfSections($row['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row['phash']),
$row['pcount'] . '/' . $this->formatFeGroup($grListRec),
$row['sys_language_uid'],
$cHash,
$row['phash']
);
if ($row['pcount'] > 1) {
$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping=' . (int)$row['phash_grouping'] . ' AND phash<>' . (int)$row['phash']);
while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
$grListRec = $this->getGrlistRecord($row2['phash']);
$recList[] = array(
'',
'',
\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row2['item_size']),
$this->getNumberOfWords($row2['phash']),
BackendUtility::datetime($row2['item_mtime']),
BackendUtility::datetime($row2['crdate']),
$row2['tstamp'] != $row2['crdate'] ? BackendUtility::datetime($row2['tstamp']) : '',
$row2['parsetime'],
$this->getNumberOfSections($row2['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row2['phash']),
'-/' . $this->formatFeGroup($grListRec),
'',
'',
$row2['phash']
);
}
}
}
return $recList;
}
/**
* [Describe function...]
*
* @return [type] ...
*/
public function getPhashExternalDocs() {
$recList[] = array(
$this->tableHead('Filename'),
$this->tableHead('Size'),
$this->tableHead('Words'),
$this->tableHead('mtime'),
$this->tableHead('Indexed'),
$this->tableHead('Updated'),
$this->tableHead('Parsetime'),
$this->tableHead('#sec/gr/full'),
$this->tableHead('#sub'),
$this->tableHead('cHash'),
$this->tableHead('phash'),
$this->tableHead('Path')
);
// TYPO3 pages, unique
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'item_type<>\'0\'', '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', 'item_type');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$cHash = count(unserialize($row['cHashParams'])) ? $this->formatCHash(unserialize($row['cHashParams'])) : '';
$grListRec = $this->getGrlistRecord($row['phash']);
$recList[] = array(
htmlentities(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['item_title'], 30)),
\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row['item_size']),
$this->getNumberOfWords($row['phash']),
BackendUtility::datetime($row['item_mtime']),
BackendUtility::datetime($row['crdate']),
$row['tstamp'] != $row['crdate'] ? BackendUtility::datetime($row['tstamp']) : '',
$row['parsetime'],
$this->getNumberOfSections($row['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row['phash']),
$row['pcount'],
$cHash,
$row['phash'],
htmlentities(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['data_filename'], 100))
);
if ($row['pcount'] > 1) {
$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping=' . (int)$row['phash_grouping'] . ' AND phash<>' . (int)$row['phash']);
while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
$cHash = count(unserialize($row2['cHashParams'])) ? $this->formatCHash(unserialize($row2['cHashParams'])) : '';
$grListRec = $this->getGrlistRecord($row2['phash']);
$recList[] = array(
'',
'',
$this->getNumberOfWords($row2['phash']),
'',
BackendUtility::datetime($row2['crdate']),
$row2['tstamp'] != $row2['crdate'] ? BackendUtility::datetime($row2['tstamp']) : '',
$row2['parsetime'],
$this->getNumberOfSections($row2['phash']) . '/' . $grListRec[0]['pcount'] . '/' . $this->getNumberOfFulltext($row2['phash']),
'',
$cHash,
$row2['phash'],
''
);
}
}
}
return $recList;
}
/**
* [Describe function...]
*