2 namespace TYPO3\CMS\IndexedSearch\Controller;
90 parent::initializeView($view);
93 $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
95 $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
105 'controller' =>
'Administration',
107 'label' => $this->
getLanguageService()->sL(
'LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.general')
110 'controller' =>
'Administration',
112 'label' => $this->
getLanguageService()->sL(
'LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.pages')
114 'externalDocuments' => [
115 'controller' =>
'Administration',
116 'action' =>
'externalDocuments',
117 'label' => $this->
getLanguageService()->sL(
'LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.externalDocuments')
120 'controller' =>
'Administration',
121 'action' =>
'statistic',
122 'label' => $this->
getLanguageService()->sL(
'LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.statistic')
125 $uriBuilder = $this->objectManager->get(UriBuilder::class);
128 $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
129 $menu->setIdentifier(
'IndexedSearchModuleMenu');
131 foreach ($menuItems as $menuItemConfig) {
132 $isActive = $this->request->getControllerActionName() === $menuItemConfig[
'action'];
133 $menuItem = $menu->makeMenuItem()
134 ->setTitle($menuItemConfig[
'label'])
135 ->setHref($this->
getHref($menuItemConfig[
'controller'], $menuItemConfig[
'action']))
136 ->setActive($isActive);
137 $menu->addMenuItem($menuItem);
140 $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
151 $this->indexerConfig = unserialize(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXT'][
'extConf'][
'indexed_search']);
152 $this->enableMetaphoneSearch = (bool)$this->indexerConfig[
'enableMetaphoneSearch'];
155 parent::initializeAction();
170 if (is_array($vars) && isset($vars[
'action']) && method_exists($this, $vars[
'action'] .
'Action')) {
171 $action = $vars[
'action'];
174 case 'saveStopwordsKeywords':
175 $action =
'statisticDetails';
177 case 'deleteIndexedItem':
178 $action =
'statistic';
182 $beUser->uc[
'indexed_search'][
'action'] = $action;
183 $beUser->uc[
'indexed_search'][
'arguments'] = $request->getArguments();
185 }
elseif (isset($beUser->uc[
'indexed_search'][
'action'])) {
186 if ($request instanceof WebRequest) {
187 $request->setControllerActionName($beUser->uc[
'indexed_search'][
'action']);
189 if (isset($beUser->uc[
'indexed_search'][
'arguments'])) {
190 $request->setArguments($beUser->uc[
'indexed_search'][
'arguments']);
194 parent::processRequest($request, $response);
213 $this->view->assignMultiple(array(
214 'records' => $this->administrationRepository->getRecordsNumbers(),
215 'phash' => $this->administrationRepository->getPageHashTypes()
218 if ($this->pageUid) {
219 $last24hours =
' AND tstamp > ' . (
$GLOBALS[
'EXEC_TIME'] - 24 * 60 * 60);
220 $last30days =
' AND tstamp > ' . (
$GLOBALS[
'EXEC_TIME'] - 30 * 24 * 60 * 60);
222 $this->view->assignMultiple(array(
223 'pageUid' => $this->pageUid,
224 'all' => $this->administrationRepository->getGeneralSearchStatistic(
'', $this->pageUid),
225 'last24hours' => $this->administrationRepository->getGeneralSearchStatistic($last24hours, $this->pageUid),
226 'last30days' => $this->administrationRepository->getGeneralSearchStatistic($last30days, $this->pageUid),
238 $this->view->assign(
'records', $this->administrationRepository->getPageStatistic());
248 $this->view->assign(
'records', $this->administrationRepository->getExternalDocumentsStatistic());
260 $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon(
'actions-view-go-up',
Icon::SIZE_SMALL);
261 $backButton = $this->view->getModuleTemplate()->getDocHeaderComponent()
262 ->getButtonBar()->makeLinkButton()
263 ->setTitle($this->
getLanguageService()->sL(
'LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.back'))
265 ->setHref($this->
getHref(
'Administration',
'statistic'));
266 $this->view->getModuleTemplate()->getDocHeaderComponent()
267 ->getButtonBar()->addButton($backButton);
269 $pageHash = (int)$pageHash;
271 $pageHashRow = $db->exec_SELECTgetSingleRow(
'*',
'index_phash',
'phash = ' . (
int)$pageHash);
273 if (!is_array($pageHashRow)) {
277 $debugRow = $db->exec_SELECTgetRows(
'*',
'index_debug',
'phash = ' . (
int)$pageHash);
278 $debugInfo = array();
280 if (is_array($debugRow)) {
281 $debugInfo = unserialize($debugRow[0][
'debuginfo']);
282 $lexer = $debugInfo[
'lexer'];
283 unset($debugInfo[
'lexer']);
287 $wordRecords = $db->exec_SELECTgetRows(
288 'index_words.*, index_rel.*',
289 'index_rel, index_words',
290 'index_rel.phash = ' . (
int)$pageHash .
' AND index_words.wid = index_rel.wid',
292 'index_words.baseword'
294 foreach ($wordRecords as $id => $row) {
295 if (isset($keywords[$row[
'baseword']])) {
296 $wordRecords[$id][
'is_keyword'] =
true;
299 $metaphoneRows = $metaphone = array();
300 if ($this->enableMetaphoneSearch && is_array($wordRecords)) {
302 foreach ($wordRecords as $row) {
303 $metaphoneRows[$row[
'metaphone']][] = $row[
'baseword'];
306 foreach ($metaphoneRows as $hash => $words) {
307 if (count($words) > 1) {
308 $metaphone[] = array(
309 'metaphone' => $this->indexer->metaphone($words[0], 1), $hash,
316 $this->view->assignMultiple(array(
317 'phash' => $pageHash,
318 'phashRow' => $pageHashRow,
319 'words' => $wordRecords,
320 'sections' => $db->exec_SELECTgetRows(
323 'index_section.phash = ' . (
int)$pageHash
325 'topCount' => $db->exec_SELECTgetRows(
326 'index_words.baseword, index_words.metaphone, index_rel.*',
327 'index_rel, index_words',
328 'index_rel.phash = ' . (
int)$pageHash .
' AND index_words.wid = index_rel.wid
329 AND index_words.is_stopword=0',
331 'index_rel.count DESC',
334 'topFrequency' => $db->exec_SELECTgetRows(
335 'index_words.baseword, index_words.metaphone, index_rel.*',
336 'index_rel, index_words',
337 'index_rel.phash = ' . (
int)$pageHash .
' AND index_words.wid = index_rel.wid
338 AND index_words.is_stopword=0',
340 'index_rel.freq DESC',
343 'debug' => $debugInfo,
345 'metaphone' => $metaphone,
346 'page' => $pageRecord,
347 'keywords' => $keywords
363 if (is_array($stopwords) && !empty($stopwords)) {
364 $this->administrationRepository->saveStopWords($stopwords);
366 if (is_array($keywords) && !empty($keywords)) {
367 $this->administrationRepository->saveKeywords($keywords, $pageId);
371 $this->
redirect(
'statisticDetails', null, null, array(
'pageHash' => $pageHash));
384 'index_phash.*, index_section.*, index_rel.*',
385 'index_rel, index_section, index_phash',
386 'index_rel.wid = ' . (
int)$id .
' AND index_rel.phash = index_section.phash' .
' AND index_section.phash = index_phash.phash',
388 'index_rel.freq DESC'
391 $this->view->assignMultiple(array(
404 public function statisticAction($depth = 1, $mode =
'overview')
406 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'indexed_search'][
'external_parsers'])) {
407 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'indexed_search'][
'external_parsers'] as $extension => $_objRef) {
410 if ($fileContentParser->softInit($extension)) {
411 $this->external_parsers[$extension] = $fileContentParser;
417 $allLines = $this->administrationRepository->getTree($this->pageUid, $depth, $mode);
419 $this->view->assignMultiple(array(
420 'levelTranslations' => explode(
'|', $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.enterSearchLevels')),
422 'pageUid' => $this->pageUid,
439 $this->administrationRepository->removeIndexedPhashRow($id, $this->pageUid, $depth);
440 $this->
redirect(
'statistic', null, null, array(
'depth' => $depth,
'mode' => $mode));
452 protected function getHref($controller, $action, $parameters = [])
454 $uriBuilder = $this->objectManager->get(UriBuilder::class);
456 return $uriBuilder->reset()->uriFor($action, $parameters, $controller);