Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 89efac...d8afc6 )
by
unknown
03:51
created

SearchController   F

Complexity

Total Complexity 80

Size/Duplication

Total Lines 475
Duplicated Lines 0 %

Importance

Changes 8
Bugs 2 Features 1
Metric Value
eloc 209
c 8
b 2
f 1
dl 0
loc 475
rs 2
wmc 80

9 Methods

Rating   Name   Duplication   Size   Complexity  
A injectMetadataRepository() 0 3 1
A injectCollectionRepository() 0 3 1
A searchAction() 0 7 1
F mainAction() 0 92 19
A addFacetsMenu() 0 14 4
F makeFacetsMenuArray() 0 192 42
A getFacetsMenuEntry() 0 28 3
A translateValue() 0 16 5
A addExtendedSearch() 0 22 4

How to fix   Complexity   

Complex Class

Complex classes like SearchController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use SearchController, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Helper;
15
use Kitodo\Dlf\Common\Indexer;
16
use Kitodo\Dlf\Common\Solr;
17
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
18
use TYPO3\CMS\Core\Core\Environment;
19
use TYPO3\CMS\Core\Information\Typo3Version;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
22
use Kitodo\Dlf\Domain\Repository\MetadataRepository;
23
24
/**
25
 * Controller class for the plugin 'Search'.
26
 *
27
 * @author Sebastian Meyer <[email protected]>
28
 * @author Henrik Lochmann <[email protected]>
29
 * @author Frank Ulrich Weber <[email protected]>
30
 * @author Alexander Bigga <[email protected]>
31
 * @package TYPO3
32
 * @subpackage dlf
33
 * @access public
34
 */
35
class SearchController extends AbstractController
36
{
37
    /**
38
     * @var CollectionRepository
39
     */
40
    protected $collectionRepository;
41
42
    /**
43
     * @param CollectionRepository $collectionRepository
44
     */
45
    public function injectCollectionRepository(CollectionRepository $collectionRepository)
46
    {
47
        $this->collectionRepository = $collectionRepository;
48
    }
49
50
    /**
51
     * @var MetadataRepository
52
     */
53
    protected $metadataRepository;
54
55
    /**
56
     * @param MetadataRepository $metadataRepository
57
     */
58
    public function injectMetadataRepository(MetadataRepository $metadataRepository)
59
    {
60
        $this->metadataRepository = $metadataRepository;
61
    }
62
63
    /**
64
     * @var array $this->searchParams: The current search parameter
65
     * @access protected
66
     */
67
    protected $searchParams;
68
69
    /**
70
     * Search Action
71
     *
72
     * @return void
73
     */
74
    public function searchAction()
75
    {
76
        // if search was triggered, get search parameters from POST variables
77
        $this->searchParams = $this->getParametersSafely('searchParameter');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getParametersSafely('searchParameter') can also be of type string. However, the property $searchParams is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
78
79
        // output is done by main action
80
        $this->forward('main', null, null, ['searchParameter' => $this->searchParams]);
81
    }
82
83
    /**
84
     * Main action
85
     *
86
     * This shows the search form and optional the facets and extended search form.
87
     *
88
     * @return void
89
     */
90
    public function mainAction()
91
    {
92
        $listViewSearch = false;
93
        // Quit without doing anything if required variables are not set.
94
        if (empty($this->settings['solrcore'])) {
95
            $this->logger->warning('Incomplete plugin configuration');
96
            return;
97
        }
98
99
        // if search was triggered, get search parameters from POST variables
100
        $this->searchParams = $this->getParametersSafely('searchParameter');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getParametersSafely('searchParameter') can also be of type string. However, the property $searchParams is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
101
        // if search was triggered by the ListView plugin, get the parameters from GET variables
102
        $listRequestData = GeneralUtility::_GPmerged('tx_dlf_listview');
103
104
        if (isset($listRequestData['searchParameter']) && is_array($listRequestData['searchParameter'])) {
105
            $this->searchParams = array_merge($this->searchParams ? : [], $listRequestData['searchParameter']);
0 ignored issues
show
Bug introduced by
It seems like $this->searchParams ?: array() can also be of type string; however, parameter $arrays of array_merge() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

105
            $this->searchParams = array_merge(/** @scrutinizer ignore-type */ $this->searchParams ? : [], $listRequestData['searchParameter']);
Loading history...
106
            $listViewSearch = true;
107
            $GLOBALS['TSFE']->fe_user->setKey('ses', 'search', $this->searchParams);
108
        }
109
110
        // sanitize date search input
111
        if(empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
112
            $this->searchParams['dateFrom'] = '*';
113
        }
114
        if(empty($this->searchParams['dateTo']) && !empty($this->searchParams['dateFrom'])) {
115
            $this->searchParams['dateTo'] = 'NOW';
116
        }
117
        if($this->searchParams['dateFrom'] > $this->searchParams['dateTo']) {
118
            $tmpDate = $this->searchParams['dateFrom'];
119
            $this->searchParams['dateFrom'] = $this->searchParams['dateTo'];
120
            $this->searchParams['dateTo'] = $tmpDate;
121
        }
122
123
        // Pagination of Results: Pass the currentPage to the fluid template to calculate current index of search result.
124
        $widgetPage = $this->getParametersSafely('@widget_0');
125
        if (empty($widgetPage)) {
126
            $widgetPage = ['currentPage' => 1];
127
        }
128
129
        // If a targetPid is given, the results will be shown by ListView on the target page.
130
        if (!empty($this->settings['targetPid']) && !empty($this->searchParams) && !$listViewSearch) {
131
            $this->redirect('main', 'ListView', null,
132
                [
133
                    'searchParameter' => $this->searchParams,
134
                    'widgetPage' => $widgetPage
135
                ], $this->settings['targetPid']
136
            );
137
        }
138
139
        // If no search has been executed, no variables habe to be prepared. An empty form will be shown.
140
        if (is_array($this->searchParams) && !empty($this->searchParams)) {
141
            // get all sortable metadata records
142
            $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
0 ignored issues
show
Bug introduced by
The method findByIsSortable() does not exist on Kitodo\Dlf\Domain\Repository\MetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

142
            /** @scrutinizer ignore-call */ 
143
            $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
Loading history...
143
144
            // get all metadata records to be shown in results
145
            $listedMetadata = $this->metadataRepository->findByIsListed(true);
0 ignored issues
show
Bug introduced by
The method findByIsListed() does not exist on Kitodo\Dlf\Domain\Repository\MetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
            /** @scrutinizer ignore-call */ 
146
            $listedMetadata = $this->metadataRepository->findByIsListed(true);
Loading history...
146
147
            $solrResults = [];
148
            $numResults = 0;
149
            // Do not execute the Solr search if used together with ListView plugin.
150
            if (!$listViewSearch) {
151
                $solrResults = $this->documentRepository->findSolrByCollection(null, $this->settings, $this->searchParams, $listedMetadata);
152
                $numResults = $solrResults->getNumFound();
153
            }
154
155
            $this->view->assign('documents', $solrResults);
156
            $this->view->assign('numResults', $numResults);
157
            $this->view->assign('widgetPage', $widgetPage);
158
            $this->view->assign('lastSearch', $this->searchParams);
159
            $this->view->assign('listedMetadata', $listedMetadata);
160
            $this->view->assign('sortableMetadata', $sortableMetadata);
161
162
            // Add the facets menu
163
            $this->addFacetsMenu();
164
165
        }
166
167
        // Get additional fields for extended search.
168
        $this->addExtendedSearch();
169
170
        // Add the current document if present to fluid. This way, we can limit further searches to this document.
171
        if (isset($this->requestData['id'])) {
172
            $currentDocument = $this->documentRepository->findByUid($this->requestData['id']);
173
            $this->view->assign('currentDocument', $currentDocument);
174
        }
175
176
        // Add uHash parameter to suggest parameter to make a basic protection of this form.
177
        if ($this->settings['suggest']) {
178
            $this->view->assign('uHash', GeneralUtility::hmac((string) (new Typo3Version()) . Environment::getExtensionsPath(), 'SearchSuggest'));
179
        }
180
181
        $this->view->assign('viewData', $this->viewData);
182
    }
183
184
    /**
185
     * Adds the facets menu to the search form
186
     *
187
     * @access protected
188
     *
189
     * @return string HTML output of facets menu
190
     */
191
    protected function addFacetsMenu()
192
    {
193
        // Quit without doing anything if no facets are configured.
194
        if (empty($this->settings['facets']) && empty($this->settings['facetCollections'])) {
195
            return '';
196
        }
197
198
        // Get facets from plugin configuration.
199
        $facets = [];
200
        foreach (GeneralUtility::trimExplode(',', $this->settings['facets'], true) as $facet) {
201
            $facets[$facet . '_faceting'] = Helper::translate($facet, 'tx_dlf_metadata', $this->settings['storagePid']);
202
        }
203
204
        $this->view->assign('facetsMenu', $this->makeFacetsMenuArray($facets));
205
    }
206
207
    /**
208
     * This builds a menu array for HMENU
209
     *
210
     * @access public
211
     *
212
     * @param string $content: The PlugIn content
213
     * @param array $conf: The PlugIn configuration
214
     *
215
     * @return array HMENU array
216
     */
217
    public function makeFacetsMenuArray($facets)
218
    {
219
        $menuArray = [];
220
        // Set default value for facet search.
221
        $search = [
222
            'query' => '*:*',
223
            'params' => [
224
                'component' => [
225
                    'facetset' => [
226
                        'facet' => []
227
                    ]
228
                ]
229
            ]
230
        ];
231
232
        // Set needed parameters for facet search.
233
        if (empty($search['params']['filterquery'])) {
234
            $search['params']['filterquery'] = [];
235
        }
236
237
        $fields = Solr::getFields();
238
239
        // Set search query.
240
        $searchParams = $this->searchParams;
241
        if (
242
            (!empty($searchParams['fulltext']))
243
            || preg_match('/' . $fields['fulltext'] . ':\((.*)\)/', trim($searchParams['query']), $matches)
244
        ) {
245
            // If the query already is a fulltext query e.g using the facets
246
            $searchParams['query'] = empty($matches[1]) ? $searchParams['query'] : $matches[1];
247
            // Search in fulltext field if applicable. Query must not be empty!
248
            if (!empty($this->searchParams['query'])) {
249
                $search['query'] = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($searchParams['query'])) . ')';
250
            }
251
        } else {
252
            // Retain given search field if valid.
253
            if (!empty($searchParams['query'])) {
254
                $search['query'] = Solr::escapeQueryKeepField(trim($searchParams['query']), $this->settings['storagePid']);
255
            }
256
        }
257
258
        // if collections are given, we prepare the collection query string
259
        // extract collections from collection parameter
260
        $collection = null;
261
        if ($this->searchParams['collection']) {
262
            foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) {
263
                $collection[] = $this->collectionRepository->findByUid($collectionEntry);
0 ignored issues
show
Bug introduced by
$collectionEntry of type string is incompatible with the type integer expected by parameter $uid of TYPO3\CMS\Extbase\Persis...Repository::findByUid(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

263
                $collection[] = $this->collectionRepository->findByUid(/** @scrutinizer ignore-type */ $collectionEntry);
Loading history...
264
            }
265
            
266
        }
267
        if ($collection) {
0 ignored issues
show
introduced by
$collection is of type null, thus it always evaluated to false.
Loading history...
268
            $collectionsQueryString = '';
269
            $virtualCollectionsQueryString = '';
270
            foreach ($collection as $collectionEntry) {
271
                // check for virtual collections query string
272
                if($collectionEntry->getIndexSearch()) {
273
                    $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collectionEntry->getIndexSearch() . ')' : ' OR ('. $collectionEntry->getIndexSearch() . ')' ;
274
                }
275
                else {
276
                    $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collectionEntry->getIndexName() . '"' : ' OR "' . $collectionEntry->getIndexName() . '"';
277
                }
278
            }
279
            
280
            // distinguish between simple collection browsing and actual searching within the collection(s)
281
            if(!empty($collectionsQueryString)) {
282
                if(empty($searchParams['query'])) {
283
                    $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)';
284
                } else {
285
                    $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))';
286
                }
287
            }
288
289
            // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separatly
290
            if(!empty($virtualCollectionsQueryString)) {
291
                $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')';
292
            }
293
294
            // combine both querystrings into a single filterquery via OR if both are given, otherwise pass either of those
295
            $search['params']['filterquery'][]['query'] = implode(" OR ", array_filter([$collectionsQueryString, $virtualCollectionsQueryString]));
296
        }
297
298
        // add filter query for date search
299
        if (!empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
300
            // combine dateFrom and dateTo into filterquery as range search
301
            $search['params']['filterquery'][]['query'] = '{!join from=' . $fields['uid'] . ' to=' . $fields['uid'] . '}' . $fields['date'] . ':[' . $this->searchParams['dateFrom'] . ' TO ' . $this->searchParams['dateTo'] . ']';
302
        }
303
304
        // Add extended search query.
305
        if (
306
            !empty($searchParams['extQuery'])
307
            && is_array($searchParams['extQuery'])
308
        ) {
309
            // If the search query is already set by the simple search field, we have to reset it.
310
            $search['query'] = '';
311
            $allowedOperators = ['AND', 'OR', 'NOT'];
312
            $numberOfExtQueries = count($searchParams['extQuery']);
313
            for ($i = 0; $i < $numberOfExtQueries; $i++) {
314
                if (!empty($searchParams['extQuery'][$i])) {
315
                    if (
316
                        in_array($searchParams['extOperator'][$i], $allowedOperators)
317
                    ) {
318
                        if (!empty($search['query'])) {
319
                            $search['query'] .= ' ' . $searchParams['extOperator'][$i] . ' ';
320
                        }
321
                        $search['query'] .= Indexer::getIndexFieldName($searchParams['extField'][$i], $this->settings['storagePid']) . ':(' . Solr::escapeQuery($searchParams['extQuery'][$i]) . ')';
322
                    }
323
                }
324
            }
325
        }
326
327
        if (isset($this->searchParams['fq']) && is_array($this->searchParams['fq'])) {
328
            foreach ($this->searchParams['fq'] as $fq) {
329
                $search['params']['filterquery'][]['query'] = $fq;
330
            }
331
        }
332
333
        // Get applicable facets.
334
        $solr = Solr::getInstance($this->settings['solrcore']);
335
        if (!$solr->ready) {
336
            $this->logger->error('Apache Solr not available');
337
            return [];
338
        }
339
340
        foreach (array_keys($facets) as $field) {
341
            $search['params']['component']['facetset']['facet'][] = [
342
                'type' => 'field',
343
                'mincount' => '1',
344
                'key' => $field,
345
                'field' => $field,
346
                'limit' => $this->settings['limitFacets'],
347
                'sort' => isset($this->settings['sortingFacets']) ? $this->settings['sortingFacets'] : 'count'
348
            ];
349
        }
350
351
        // Set additional query parameters.
352
        $search['params']['start'] = 0;
353
        $search['params']['rows'] = 0;
354
        // Set query.
355
        $search['params']['query'] = $search['query'];
356
        // Perform search.
357
        $selectQuery = $solr->service->createSelect($search['params']);
358
        $results = $solr->service->select($selectQuery);
359
        $facet = $results->getFacetSet();
360
361
        $facetCollectionArray = [];
362
363
        // replace everything expect numbers and comma
364
        $facetCollections = preg_replace('/[^\d,]/', '', $this->settings['facetCollections']);
365
366
        if (!empty($facetCollections)) {
367
            $collections = $this->collectionRepository->findCollectionsBySettings(['collections' => $facetCollections]);
368
369
            /** @var Collection $collection */
370
            foreach ($collections as $collection) {
371
                $facetCollectionArray[] = $collection->getIndexName();
372
            }
373
        }
374
375
        // Process results.
376
        if ($facet) {
377
            foreach ($facet as $field => $values) {
378
                $entryArray = [];
379
                $entryArray['field'] = substr($field, 0, strpos($field, '_faceting'));
380
                $entryArray['count'] = 0;
381
                $entryArray['_OVERRIDE_HREF'] = '';
382
                $entryArray['ITEM_STATE'] = 'NO';
383
                // Count number of facet values.
384
                $i = 0;
385
                foreach ($values as $value => $count) {
386
                    if ($count > 0) {
387
                        // check if facet collection configuration exists
388
                        if (!empty($this->settings['facetCollections'])) {
389
                            if ($field == "collection_faceting" && !in_array($value, $facetCollectionArray)) {
390
                                continue;
391
                            }
392
                        }
393
                        $entryArray['count']++;
394
                        if ($entryArray['ITEM_STATE'] == 'NO') {
395
                            $entryArray['ITEM_STATE'] = 'IFSUB';
396
                        }
397
                        $entryArray['_SUB_MENU'][] = $this->getFacetsMenuEntry($field, $value, $count, $search, $entryArray['ITEM_STATE']);
398
                        if (++$i == $this->settings['limit']) {
399
                            break;
400
                        }
401
                    } else {
402
                        break;
403
                    }
404
                }
405
                $menuArray[] = $entryArray;
406
            }
407
        }
408
        return $menuArray;
409
    }
410
411
    /**
412
     * Creates an array for a HMENU entry of a facet value.
413
     *
414
     * @access protected
415
     *
416
     * @param string $field: The facet's index_name
417
     * @param string $value: The facet's value
418
     * @param int $count: Number of hits for this facet
419
     * @param array $search: The parameters of the current search query
420
     * @param string &$state: The state of the parent item
421
     *
422
     * @return array The array for the facet's menu entry
423
     */
424
    protected function getFacetsMenuEntry($field, $value, $count, $search, &$state)
425
    {
426
        $entryArray = [];
427
        $entryArray['title'] = $this->translateValue($field, $value);
428
        $entryArray['count'] = $count;
429
        $entryArray['doNotLinkIt'] = 0;
430
        // Check if facet is already selected.
431
        $queryColumn = array_column($search['params']['filterquery'], 'query');
432
        $index = array_search($field . ':("' . Solr::escapeQuery($value) . '")', $queryColumn);
433
        if ($index !== false) {
434
            // Facet is selected, thus remove it from filter.
435
            unset($queryColumn[$index]);
436
            $queryColumn = array_values($queryColumn);
437
            $entryArray['ITEM_STATE'] = 'CUR';
438
            $state = 'ACTIFSUB';
439
            // Reset facets
440
            if ($this->settings['resetFacets']) {
441
                $entryArray['resetFacet'] = true;
442
                $entryArray['queryColumn'] = $queryColumn;
443
            }
444
        } else {
445
            // Facet is not selected, thus add it to filter.
446
            $queryColumn[] = $field . ':("' . Solr::escapeQuery($value) . '")';
447
            $entryArray['ITEM_STATE'] = 'NO';
448
        }
449
        $entryArray['queryColumn'] = $queryColumn;
450
451
        return $entryArray;
452
    }
453
454
    /**
455
     * Translates value depending on the index name.
456
     *
457
     * @param string $field: The facet's index_name
458
     * @param string $value: The facet's value
459
     *
460
     * @return string
461
     */
462
    private function translateValue($field, $value) {
463
        switch ($field) {
464
            case 'owner_faceting':
465
                // Translate name of holding library.
466
                return htmlspecialchars(Helper::translate($value, 'tx_dlf_libraries', $this->settings['storagePid']));
467
            case 'type_faceting':
468
                // Translate document type.
469
                return htmlspecialchars(Helper::translate($value, 'tx_dlf_structures', $this->settings['storagePid']));
470
            case 'collection_faceting':
471
                // Translate name of collection.
472
                return htmlspecialchars(Helper::translate($value, 'tx_dlf_collections', $this->settings['storagePid']));
473
            case 'language_faceting':
474
                // Translate ISO 639 language code.
475
                return htmlspecialchars(Helper::getLanguageName($value));
476
            default:
477
                return htmlspecialchars($value);
478
        }
479
    }
480
481
    /**
482
     * Returns the extended search form and adds the JS files necessary for extended search.
483
     *
484
     * @access protected
485
     *
486
     * @return string The extended search form or an empty string
487
     */
488
    protected function addExtendedSearch()
489
    {
490
        // Quit without doing anything if no fields for extended search are selected.
491
        if (
492
            empty($this->settings['extendedSlotCount'])
493
            || empty($this->settings['extendedFields'])
494
        ) {
495
            return '';
496
        }
497
498
        // Get field selector options.
499
        $searchFields = GeneralUtility::trimExplode(',', $this->settings['extendedFields'], true);
500
501
        $slotCountArray = [];
502
        for ($i = 0; $i < $this->settings['extendedSlotCount']; $i++) {
503
            $slotCountArray[] = $i;
504
        }
505
506
        $this->view->assign('extendedSlotCount', $slotCountArray);
507
        $this->view->assign('extendedFields', $this->settings['extendedFields']);
508
        $this->view->assign('operators', ['AND', 'OR', 'NOT']);
509
        $this->view->assign('searchFields', $searchFields);
510
    }
511
}
512