|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Controller\Backend\Web\Info; |
|
4
|
|
|
|
|
5
|
|
|
/*************************************************************** |
|
6
|
|
|
* Copyright notice |
|
7
|
|
|
* |
|
8
|
|
|
* (c) 2017 Rafael Kähm <[email protected]> |
|
9
|
|
|
* All rights reserved |
|
10
|
|
|
* |
|
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
|
12
|
|
|
* free software; you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU General Public License as published by |
|
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
|
15
|
|
|
* (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* The GNU General Public License can be found at |
|
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
|
19
|
|
|
* |
|
20
|
|
|
* This script is distributed in the hope that it will be useful, |
|
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
* GNU General Public License for more details. |
|
24
|
|
|
* |
|
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
26
|
|
|
***************************************************************/ |
|
27
|
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ApacheSolrDocument\Repository; |
|
29
|
|
|
use TYPO3\CMS\Backend\Module\AbstractFunctionModule; |
|
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
31
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Administration module controller |
|
35
|
|
|
*/ |
|
36
|
|
|
class IndexInspectorController extends AbstractFunctionModule |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Page ID in page context |
|
41
|
|
|
* |
|
42
|
|
|
* @var int |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $pageId = 0; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var Repository |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $apacheSolrDocumentRepository; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Initializes properties |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->apacheSolrDocumentRepository = GeneralUtility::makeInstance(Repository::class); |
|
57
|
|
|
$this->pageId = (int)GeneralUtility::_GP('id'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Lists all avalable apacha solr documents from page |
|
62
|
|
|
* |
|
63
|
|
|
* @return string|void |
|
64
|
|
|
*/ |
|
65
|
|
|
public function main() |
|
66
|
|
|
{ |
|
67
|
|
|
$documents = $this->apacheSolrDocumentRepository->findByPageIdAndByLanguageId($this->pageId, 0); |
|
68
|
|
|
$documentsByType = []; |
|
69
|
|
|
foreach ($documents as $document) { |
|
70
|
|
|
$documentsByType[$document->type][] = $document; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$path = GeneralUtility::getFileAbsFileName('EXT:solr/Resources/Private/Templates/Backend/Web/Info/IndexInspector.html'); |
|
74
|
|
|
$view = GeneralUtility::makeInstance(StandaloneView::class); |
|
75
|
|
|
$view->getRequest()->setControllerExtensionName('solr'); |
|
76
|
|
|
$view->setTemplatePathAndFilename($path); |
|
77
|
|
|
$view->assignMultiple([ |
|
78
|
|
|
'pageId' => $this->pageId, |
|
79
|
|
|
'documentsByType' => $documentsByType |
|
80
|
|
|
]); |
|
81
|
|
|
|
|
82
|
|
|
return $view->render(); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|