mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 10:16:10 +01:00
Merge remote-tracking branch 'origin/develop' into feature/112-prevent-issue-with-non-uids
This commit is contained in:
commit
8fe42789ba
10 changed files with 62 additions and 14 deletions
|
@ -20,13 +20,11 @@ namespace Codappix\SearchCore\Configuration;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container of all configurations for extension.
|
* Container of all configurations for extension.
|
||||||
* Always inject this to have a single place for configuration and parsing only once.
|
* Always inject this to have a single place for configuration.
|
||||||
*/
|
*/
|
||||||
interface ConfigurationContainerInterface extends Singleton
|
interface ConfigurationContainerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the option defined by section and key.
|
* Returns the option defined by section and key.
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||||
use Codappix\SearchCore\Connection\ConnectionInterface;
|
use Codappix\SearchCore\Connection\ConnectionInterface;
|
||||||
use Codappix\SearchCore\Domain\Index\TcaIndexer;
|
use Codappix\SearchCore\Domain\Index\TcaIndexer;
|
||||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService;
|
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService;
|
||||||
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific indexer for Pages, will basically add content of page.
|
* Specific indexer for Pages, will basically add content of page.
|
||||||
|
@ -109,7 +110,7 @@ class PagesIndexer extends TcaIndexer
|
||||||
$images,
|
$images,
|
||||||
$this->getContentElementImages($contentElement['uid'])
|
$this->getContentElementImages($contentElement['uid'])
|
||||||
);
|
);
|
||||||
$content[] = $contentElement['bodytext'];
|
$content[] = $this->getContentFromContentElement($contentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -142,4 +143,22 @@ class PagesIndexer extends TcaIndexer
|
||||||
|
|
||||||
return $imageRelationUids;
|
return $imageRelationUids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getContentFromContentElement(array $contentElement) : string
|
||||||
|
{
|
||||||
|
$content = '';
|
||||||
|
|
||||||
|
$fieldsWithContent = GeneralUtility::trimExplode(
|
||||||
|
',',
|
||||||
|
$this->configuration->get('indexing.' . $this->identifier . '.contentFields'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
foreach ($fieldsWithContent as $fieldWithContent) {
|
||||||
|
if (isset($contentElement[$fieldWithContent]) && trim($contentElement[$fieldWithContent])) {
|
||||||
|
$content .= trim($contentElement[$fieldWithContent]) . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,13 @@ plugin {
|
||||||
|
|
||||||
indexing {
|
indexing {
|
||||||
tt_content {
|
tt_content {
|
||||||
additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login') AND tt_content.bodytext != ''
|
additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login') AND (tt_content.bodytext != '' OR tt_content.header != '')
|
||||||
}
|
}
|
||||||
|
|
||||||
pages {
|
pages {
|
||||||
additionalWhereClause = pages.doktype NOT IN (3, 199, 6, 254, 255)
|
additionalWhereClause = pages.doktype NOT IN (3, 199, 6, 254, 255)
|
||||||
abstractFields = abstract, description, bodytext
|
abstractFields = abstract, description, bodytext
|
||||||
|
contentFields = header, bodytext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ plugin {
|
||||||
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
||||||
additionalWhereClause = {$plugin.tx_searchcore.settings.indexing.pages.additionalWhereClause}
|
additionalWhereClause = {$plugin.tx_searchcore.settings.indexing.pages.additionalWhereClause}
|
||||||
abstractFields = {$plugin.tx_searchcore.settings.indexing.pages.abstractFields}
|
abstractFields = {$plugin.tx_searchcore.settings.indexing.pages.abstractFields}
|
||||||
|
contentFields = {$plugin.tx_searchcore.settings.indexing.pages.contentFields}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ Changelog
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
:glob:
|
:glob:
|
||||||
|
|
||||||
|
changelog/20180415-134-make-conent-fields-configurable
|
||||||
changelog/20180409-25-provide-sys-language-uid
|
changelog/20180409-25-provide-sys-language-uid
|
||||||
changelog/20180408-131-respect-page-cache-clear
|
changelog/20180408-131-respect-page-cache-clear
|
||||||
changelog/20180408-introduce-php70-type-hints
|
changelog/20180408-introduce-php70-type-hints
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
FEATURE 134 "Enable indexing of tt_content records of CType Header"
|
||||||
|
===================================================================
|
||||||
|
|
||||||
|
Before, only ``bodytext`` was used to generate content while indexing pages.
|
||||||
|
|
||||||
|
As there are content elements like ``header`` where this field is empty, but content is still
|
||||||
|
available, it's now possible to configure the fields.
|
||||||
|
This makes it also possible to configure further custom content elements with new columns.
|
||||||
|
|
||||||
|
A new TypoScript option is now available, and ``header`` is added by default, see
|
||||||
|
:ref:`contentFields`.
|
||||||
|
|
||||||
|
See :issue:`134`.
|
|
@ -86,6 +86,23 @@ Default::
|
||||||
|
|
||||||
abstract, description, bodytext
|
abstract, description, bodytext
|
||||||
|
|
||||||
|
.. _contentFields:
|
||||||
|
|
||||||
|
contentFields
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Used by: :ref:`PagesIndexer`.
|
||||||
|
|
||||||
|
Define which fields should be used to provide the auto generated field "content".
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
plugin.tx_searchcore.settings.indexing.pages.contentFields := addToList(table_caption)
|
||||||
|
|
||||||
|
Default::
|
||||||
|
|
||||||
|
header, bodytext
|
||||||
|
|
||||||
.. _mapping:
|
.. _mapping:
|
||||||
|
|
||||||
mapping
|
mapping
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -41,16 +41,11 @@ unitTests:
|
||||||
.Build/bin/phpunit --colors --debug -v \
|
.Build/bin/phpunit --colors --debug -v \
|
||||||
-c Tests/Unit/UnitTests.xml
|
-c Tests/Unit/UnitTests.xml
|
||||||
|
|
||||||
uploadCodeCoverage: uploadCodeCoverageToScrutinizer uploadCodeCoverageToCodacy
|
uploadCodeCoverage: uploadCodeCoverageToScrutinizer
|
||||||
|
|
||||||
uploadCodeCoverageToScrutinizer:
|
uploadCodeCoverageToScrutinizer:
|
||||||
wget https://scrutinizer-ci.com/ocular.phar && \
|
wget https://scrutinizer-ci.com/ocular.phar && \
|
||||||
php ocular.phar code-coverage:upload --format=php-clover .Build/report/functional/clover/coverage
|
php ocular.phar code-coverage:upload --format=php-clover .Build/report/functional/clover/coverage
|
||||||
|
|
||||||
uploadCodeCoverageToCodacy:
|
|
||||||
composer require -vv --dev codacy/coverage && \
|
|
||||||
git checkout composer.json && \
|
|
||||||
php .Build/bin/codacycoverage clover .Build/report/functional/clover/coverage
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf .Build composer.lock
|
rm -rf .Build composer.lock
|
||||||
|
|
|
@ -14,7 +14,7 @@ plugin {
|
||||||
|
|
||||||
additionalWhereClause (
|
additionalWhereClause (
|
||||||
tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login')
|
tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login')
|
||||||
AND tt_content.bodytext != ''
|
AND (tt_content.bodytext != '' OR tt_content.header != '')
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping {
|
mapping {
|
||||||
|
@ -27,6 +27,7 @@ plugin {
|
||||||
pages {
|
pages {
|
||||||
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
||||||
abstractFields = abstract, description, bodytext
|
abstractFields = abstract, description, bodytext
|
||||||
|
contentFields = header, bodytext
|
||||||
|
|
||||||
mapping {
|
mapping {
|
||||||
CType {
|
CType {
|
||||||
|
|
|
@ -50,7 +50,9 @@ class PagesIndexerTest extends AbstractFunctionalTestCase
|
||||||
$this->callback(function ($documents) {
|
$this->callback(function ($documents) {
|
||||||
return count($documents) === 2
|
return count($documents) === 2
|
||||||
&& isset($documents[0]['content']) && $documents[0]['content'] ===
|
&& isset($documents[0]['content']) && $documents[0]['content'] ===
|
||||||
'this is the content of header content element that should get indexed Some text in paragraph'
|
'indexed content element' .
|
||||||
|
' this is the content of header content element that should get indexed' .
|
||||||
|
' Indexed without html tags Some text in paragraph'
|
||||||
&& isset($documents[0]['search_abstract']) && $documents[0]['search_abstract'] ===
|
&& isset($documents[0]['search_abstract']) && $documents[0]['search_abstract'] ===
|
||||||
'Used as abstract as no abstract is defined.'
|
'Used as abstract as no abstract is defined.'
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in a new issue