mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 20:36:10 +01:00
BUGFIX: Respect additionalWhereClause and rootline
* Use constants instead of setup. * Grap configuration from path. * Add where clause.
This commit is contained in:
parent
8448618f60
commit
8e062d6e42
6 changed files with 55 additions and 22 deletions
0
Classes/Configuration/NoConfigurationException.php
Executable file → Normal file
0
Classes/Configuration/NoConfigurationException.php
Executable file → Normal file
0
Classes/Domain/Index/NoRecordFoundException.php
Executable file → Normal file
0
Classes/Domain/Index/NoRecordFoundException.php
Executable file → Normal file
|
@ -151,9 +151,9 @@ class TcaTableService
|
||||||
. ' AND pages.no_search = 0'
|
. ' AND pages.no_search = 0'
|
||||||
;
|
;
|
||||||
|
|
||||||
$userDefinedWhere = $this->configuration->getIfExists('indexer.tca.' . $this->tableName);
|
$userDefinedWhere = $this->configuration->getIfExists('indexer.tca.' . $this->tableName . '.additionalWhereClause');
|
||||||
if (is_string($userDefinedWhere)) {
|
if (is_string($userDefinedWhere)) {
|
||||||
$whereClause .= $userDefinedWhere;
|
$whereClause .= ' AND ' . $userDefinedWhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isBlacklistedRootLineConfigured()) {
|
if ($this->isBlacklistedRootLineConfigured()) {
|
||||||
|
@ -236,20 +236,26 @@ class TcaTableService
|
||||||
* Checks whether the given record was blacklisted by root line.
|
* Checks whether the given record was blacklisted by root line.
|
||||||
* This can be configured by typoscript as whole root lines can be black listed.
|
* This can be configured by typoscript as whole root lines can be black listed.
|
||||||
*
|
*
|
||||||
|
* NOTE: Does not support pages yet. We have to add a switch once we
|
||||||
|
* support them to use uid instead.
|
||||||
|
*
|
||||||
* @param array &$record
|
* @param array &$record
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isRecordBlacklistedByRootline(array &$record)
|
protected function isRecordBlacklistedByRootline(array &$record)
|
||||||
{
|
{
|
||||||
// NOTE: Does not support pages yet. We have to add a switch once we
|
// If no rootline exists, the record is on a unreachable page and therefore blacklisted.
|
||||||
// support them to use uid instead.
|
$rootline = BackendUtility::BEgetRootLine($record['pid']);
|
||||||
if (! $this->isBlackListedRootLineConfigured()) {
|
if (!isset($rootline[0])) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (BackendUtility::BEgetRootLine($record['uid']) as $pageInRootLine) {
|
// Check configured black list if present.
|
||||||
if (in_array($pageInRootLine['uid'], $this->getBlackListedRootLine())) {
|
if ($this->isBlackListedRootLineConfigured()) {
|
||||||
return true;
|
foreach ($rootline as $pageInRootLine) {
|
||||||
|
if (in_array($pageInRootLine['uid'], $this->getBlackListedRootLine())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
Configuration/TypoScript/constants.txt
Normal file → Executable file
29
Configuration/TypoScript/constants.txt
Normal file → Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
plugin {
|
||||||
|
tx_searchcore {
|
||||||
|
settings {
|
||||||
|
connections {
|
||||||
|
elasticsearch {
|
||||||
|
host = localhost
|
||||||
|
port = 9200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
indexer {
|
||||||
|
tca {
|
||||||
|
# Pages are not supported yet, see
|
||||||
|
# https://github.com/DanielSiepmann/search_core/issues/24 but
|
||||||
|
# should also be added, together with additionalWhereClause
|
||||||
|
# based on doktypes
|
||||||
|
allowedTables = tt_content
|
||||||
|
|
||||||
|
tt_content {
|
||||||
|
additionalWhereClause (
|
||||||
|
pages.doktype NOT IN (3, 199)
|
||||||
|
AND tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Configuration/TypoScript/setup.txt
Normal file → Executable file
12
Configuration/TypoScript/setup.txt
Normal file → Executable file
|
@ -3,21 +3,17 @@ plugin {
|
||||||
settings {
|
settings {
|
||||||
connections {
|
connections {
|
||||||
elasticsearch {
|
elasticsearch {
|
||||||
host = localhost
|
host = {$plugin.tx_searchcore.settings.connections.elasticsearch.host}
|
||||||
port = 9200
|
port = {$plugin.tx_searchcore.settings.connections.elasticsearch.port}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indexer {
|
indexer {
|
||||||
tca {
|
tca {
|
||||||
# Pages are not supported yet, see
|
allowedTables = {$plugin.tx_searchcore.settings.indexer.tca.allowedTables}
|
||||||
# https://github.com/DanielSiepmann/search_core/issues/24 but
|
|
||||||
# should also be added, together with additionalWhereClause
|
|
||||||
# based on doktypes
|
|
||||||
allowedTables = tt_content
|
|
||||||
|
|
||||||
tt_content {
|
tt_content {
|
||||||
additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
|
additionalWhereClause = {$plugin.tx_searchcore.settings.indexer.tca.tt_content.additionalWhereClause}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,16 @@ mode of TYPO3. Do so by placing the following line at the end::
|
||||||
|
|
||||||
We will use references inside the extension to make the above unnecessary in the future.
|
We will use references inside the extension to make the above unnecessary in the future.
|
||||||
|
|
||||||
Currently no constants are available, but this will change in the near future to make configuration
|
|
||||||
easier.
|
|
||||||
|
|
||||||
The structure is following TYPO3 Extbase conventions. All settings are placed inside of::
|
The structure is following TYPO3 Extbase conventions. All settings are placed inside of::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings
|
plugin.tx_searchcore.settings
|
||||||
|
|
||||||
Here is the example default configuration that's provided through static setup:
|
Here is the example default configuration that's provided through static include:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../Configuration/TypoScript/constants.txt
|
||||||
|
:language: typoscript
|
||||||
|
:linenos:
|
||||||
|
:caption: Static TypoScript Constants
|
||||||
|
|
||||||
.. literalinclude:: ../../Configuration/TypoScript/setup.txt
|
.. literalinclude:: ../../Configuration/TypoScript/setup.txt
|
||||||
:language: typoscript
|
:language: typoscript
|
||||||
|
@ -145,7 +147,7 @@ The following settings are available. For each setting its documented which inde
|
||||||
The page attribute *No Search* is also taken into account to prevent indexing records from only one
|
The page attribute *No Search* is also taken into account to prevent indexing records from only one
|
||||||
page without recursion.
|
page without recursion.
|
||||||
|
|
||||||
Contains a comma separated list of table names. Spaces are trimmed.
|
Contains a comma separated list of page uids. Spaces are trimmed.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue