Complex classes like TypoScriptConfiguration 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 TypoScriptConfiguration, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
63 | class TypoScriptConfiguration |
||
64 | { |
||
65 | /** |
||
66 | * @var \ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor|null |
||
67 | */ |
||
68 | protected $configurationAccess = null; |
||
69 | |||
70 | /** |
||
71 | * Holds the pageId in which context the configuration was parsed |
||
72 | * (normally $GLOBALS['TSFE']->id) |
||
73 | */ |
||
74 | protected $contextPageId = 0; |
||
75 | |||
76 | /** |
||
77 | * @var ContentObjectService |
||
78 | */ |
||
79 | protected $contentObjectService; |
||
80 | |||
81 | /** |
||
82 | * @param array $configuration |
||
83 | * @param int $contextPageId |
||
84 | * @param ContentObjectService $contentObjectService |
||
85 | */ |
||
86 | 248 | public function __construct(array $configuration, $contextPageId = 0, ContentObjectService $contentObjectService = null) |
|
92 | |||
93 | /** |
||
94 | * Checks if a value is 1, '1', 'true' |
||
95 | * @param mixed $value |
||
96 | * @return bool |
||
97 | */ |
||
98 | 236 | protected function getBool($value) |
|
102 | |||
103 | /** |
||
104 | * This method can be used to only retrieve array keys where the value is not an array. |
||
105 | * |
||
106 | * This can be very handy in the configuration when only keys should ne taken into account |
||
107 | * where the value is not a subconfiguration (typically an typoscript object path). |
||
108 | * |
||
109 | * @param $inputArray |
||
110 | * @return array |
||
111 | */ |
||
112 | 10 | protected function getOnlyArrayKeysWhereValueIsNotAnArray($inputArray) |
|
127 | |||
128 | /** |
||
129 | * Gets the value from a given TypoScript path. |
||
130 | * |
||
131 | * In the context of an frontend content element the path plugin.tx_solr is |
||
132 | * merged recursive with overrule with the content element specific typoscript |
||
133 | * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings |
||
134 | * (depends on the solr plugin). |
||
135 | * |
||
136 | * Example: plugin.tx_solr.search.targetPage |
||
137 | * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage'] |
||
138 | * |
||
139 | * @param string $path TypoScript path |
||
140 | * @return mixed The TypoScript object defined by the given path |
||
141 | * @throws InvalidArgumentException |
||
142 | */ |
||
143 | 273 | public function getValueByPath($path) |
|
144 | { |
||
145 | 273 | if (!is_string($path)) { |
|
146 | throw new InvalidArgumentException('Parameter $path is not a string', |
||
147 | 1325623321); |
||
148 | } |
||
149 | 273 | return $this->configurationAccess->get($path); |
|
150 | } |
||
151 | |||
152 | /** |
||
153 | * This method can be used to get a configuration value by path if it exists or return a |
||
154 | * default value when it does not exist. |
||
155 | * |
||
156 | * @param string $path |
||
157 | * @param mixed $defaultValue |
||
158 | * @return mixed |
||
159 | */ |
||
160 | 270 | public function getValueByPathOrDefaultValue($path, $defaultValue) |
|
161 | { |
||
162 | 270 | $value = $this->getValueByPath($path); |
|
163 | 270 | if (is_null($value)) { |
|
164 | 262 | return $defaultValue; |
|
165 | } |
||
166 | |||
167 | 140 | return $value; |
|
168 | } |
||
169 | |||
170 | /** |
||
171 | * Gets the parent TypoScript Object from a given TypoScript path. |
||
172 | * |
||
173 | * In the context of an frontend content element the path plugin.tx_solr is |
||
174 | * merged recursive with overrule with the content element specific typoscript |
||
175 | * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings |
||
176 | * (depends on the solr plugin). |
||
177 | * |
||
178 | * Example: plugin.tx_solr.index.queue.tt_news.fields.content |
||
179 | * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['index.']['queue.']['tt_news.']['fields.']['content.'] |
||
180 | * which is a SOLR_CONTENT cObj. |
||
181 | * |
||
182 | * @param string $path TypoScript path |
||
183 | * @return array The TypoScript object defined by the given path |
||
184 | * @throws InvalidArgumentException |
||
185 | */ |
||
186 | 158 | public function getObjectByPath($path) |
|
187 | { |
||
188 | 158 | if (substr($path, -1) !== '.') { |
|
189 | 1 | $path = rtrim($path, '.'); |
|
190 | 1 | $path = substr($path, 0, strrpos($path, '.') + 1); |
|
191 | } |
||
192 | |||
193 | 158 | if (!is_string($path)) { |
|
194 | throw new InvalidArgumentException('Parameter $path is not a string', 1325627243); |
||
195 | } |
||
196 | |||
197 | 158 | return $this->configurationAccess->get($path); |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * Gets the parent TypoScript Object from a given TypoScript path and if not present return |
||
202 | * the default value |
||
203 | * |
||
204 | * @see getObjectByPath |
||
205 | * @param string $path |
||
206 | * @param array $defaultValue |
||
207 | * @return array |
||
208 | */ |
||
209 | 153 | public function getObjectByPathOrDefault($path, array $defaultValue) |
|
210 | { |
||
211 | try { |
||
212 | 153 | $object = $this->getObjectByPath($path); |
|
213 | } catch (\InvalidArgumentException $e) { |
||
214 | return $defaultValue; |
||
215 | } |
||
216 | |||
217 | 153 | if (!is_array($object)) { |
|
218 | 40 | return $defaultValue; |
|
219 | } |
||
220 | |||
221 | 149 | return $object; |
|
222 | } |
||
223 | |||
224 | /** |
||
225 | * Checks whether a given TypoScript path is valid. |
||
226 | * |
||
227 | * @param string $path TypoScript path |
||
228 | * @return bool TRUE if the path resolves, FALSE otherwise |
||
229 | */ |
||
230 | public function isValidPath($path) |
||
231 | { |
||
232 | $isValidPath = false; |
||
233 | |||
234 | $pathValue = $this->getValueByPath($path); |
||
235 | if (!is_null($pathValue)) { |
||
236 | $isValidPath = true; |
||
237 | } |
||
238 | |||
239 | return $isValidPath; |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * Merges a configuration with another configuration a |
||
244 | * |
||
245 | * @param array $configurationToMerge |
||
246 | * @param bool $addKeys If set to FALSE, keys that are NOT found in $original will not be set. Thus only existing value can/will be overruled from overrule array. |
||
247 | * @param bool $includeEmptyValues If set, values from $overrule will overrule if they are empty or zero. |
||
248 | * @param bool $enableUnsetFeature If set, special values "__UNSET" can be used in the overrule array in order to unset array keys in the original array. |
||
249 | * @return TypoScriptConfiguration |
||
250 | */ |
||
251 | 31 | public function mergeSolrConfiguration(array $configurationToMerge, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
252 | { |
||
253 | 31 | $data = $this->configurationAccess->getData(); |
|
254 | 31 | ArrayUtility::mergeRecursiveWithOverrule( |
|
255 | 31 | $data['plugin.']['tx_solr.'], |
|
256 | $configurationToMerge, |
||
257 | $addKeys, |
||
258 | $includeEmptyValues, |
||
259 | $enableUnsetFeature |
||
260 | ); |
||
261 | |||
262 | 31 | $this->configurationAccess->setData($data); |
|
263 | |||
264 | 31 | return $this; |
|
265 | } |
||
266 | |||
267 | /** |
||
268 | * Returns true when ext_solr is enabled |
||
269 | * |
||
270 | * @param boolean $defaultIfEmpty |
||
271 | * @return boolean |
||
272 | */ |
||
273 | 3 | public function getEnabled($defaultIfEmpty = false) |
|
274 | { |
||
275 | 3 | $path = 'plugin.tx_solr.enabled'; |
|
276 | 3 | $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty); |
|
277 | 3 | return $this->getBool($result); |
|
278 | } |
||
279 | |||
280 | /** |
||
281 | * Returns the configured css file for a specific fileKey. |
||
282 | * |
||
283 | * plugin.tx_solr.cssFiles.<fileKey> |
||
284 | * |
||
285 | * @param string $fileKey |
||
286 | * @param string $defaultIfEmpty |
||
287 | * @return string |
||
288 | */ |
||
289 | public function getCssFileByFileKey($fileKey, $defaultIfEmpty = '') |
||
290 | { |
||
291 | $cssFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.cssFiles.' . $fileKey, $defaultIfEmpty); |
||
292 | return (string)$cssFileName; |
||
293 | } |
||
294 | |||
295 | /** |
||
296 | * Returns the configured additionalFields configured for the indexing. |
||
297 | * |
||
298 | * plugin.tx_solr.index.additionalFields. |
||
299 | * |
||
300 | * @param array $defaultIfEmpty |
||
301 | * @return array |
||
302 | */ |
||
303 | 3 | public function getIndexAdditionalFieldsConfiguration($defaultIfEmpty = []) |
|
304 | { |
||
305 | 3 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.additionalFields.', $defaultIfEmpty); |
|
306 | 3 | return $result; |
|
307 | } |
||
308 | |||
309 | /** |
||
310 | * Returns all solr fields names where a mapping is configured in index.additionalFields |
||
311 | * |
||
312 | * Returns all keys from |
||
313 | * plugin.tx_solr.index.additionalFields. |
||
314 | * |
||
315 | * @param array $defaultIfEmpty |
||
316 | * @return array |
||
317 | */ |
||
318 | 2 | public function getIndexMappedAdditionalFieldNames($defaultIfEmpty = []) |
|
319 | { |
||
320 | 2 | $mappingConfiguration = $this->getIndexAdditionalFieldsConfiguration(); |
|
321 | 2 | $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration); |
|
322 | 2 | return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames; |
|
323 | } |
||
324 | |||
325 | /** |
||
326 | * Returns the fieldProcessingInstructions configuration array |
||
327 | * |
||
328 | * plugin.tx_solr.index.fieldProcessingInstructions. |
||
329 | * |
||
330 | * @param array $defaultIfEmpty |
||
331 | * @return array |
||
332 | */ |
||
333 | 59 | public function getIndexFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = []) |
|
334 | { |
||
335 | 59 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.fieldProcessingInstructions.', $defaultIfEmpty); |
|
336 | 59 | return $result; |
|
337 | } |
||
338 | |||
339 | /** |
||
340 | * Retrieves the indexing configuration array for an indexing queue by configuration name. |
||
341 | * |
||
342 | * plugin.tx_solr.index.queue.<configurationName>. |
||
343 | * |
||
344 | * @param string $configurationName |
||
345 | * @param array $defaultIfEmpty |
||
346 | * @return array |
||
347 | */ |
||
348 | 6 | public function getIndexQueueConfigurationByName($configurationName, array $defaultIfEmpty = []) |
|
349 | { |
||
350 | 6 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.'; |
|
351 | 6 | $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty); |
|
352 | 6 | return $result; |
|
353 | } |
||
354 | |||
355 | /** |
||
356 | * Returns an array of all additionalPageIds by index configuration name. |
||
357 | * |
||
358 | * plugin.tx_solr.index.queue.pages.additionalPageIds |
||
359 | * |
||
360 | * @param string $configurationName |
||
361 | * @param array $defaultIfEmpty |
||
362 | * @return array |
||
363 | */ |
||
364 | 46 | public function getIndexQueueAdditionalPageIdsByConfigurationName($configurationName = 'pages', $defaultIfEmpty = []) |
|
365 | { |
||
366 | 46 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalPageIds'; |
|
367 | 46 | $result = $this->getValueByPathOrDefaultValue($path, ''); |
|
368 | 46 | if (trim($result) == '') { |
|
369 | 43 | return $defaultIfEmpty; |
|
370 | } |
||
371 | |||
372 | 3 | return GeneralUtility::trimExplode(',', $result); |
|
373 | } |
||
374 | |||
375 | /** |
||
376 | * Returns an array of all allowedPageTypes. |
||
377 | * |
||
378 | * plugin.tx_solr.index.queue.pages.allowedPageTypes |
||
379 | * |
||
380 | * @param string $configurationName The configuration name of the queue to use. |
||
381 | * @param array $defaultIfEmpty |
||
382 | * @return array |
||
383 | */ |
||
384 | 30 | public function getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName = 'pages', $defaultIfEmpty = []) |
|
385 | { |
||
386 | 30 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.allowedPageTypes'; |
|
387 | 30 | $result = $this->getValueByPathOrDefaultValue($path, ''); |
|
388 | 30 | if (trim($result) == '') { |
|
389 | return $defaultIfEmpty; |
||
390 | } |
||
391 | |||
392 | 30 | return GeneralUtility::trimExplode(',', $result); |
|
393 | } |
||
394 | |||
395 | /** |
||
396 | * Returns the configured excludeContentByClass patterns as array. |
||
397 | * |
||
398 | * plugin.tx_solr.index.queue.pages.excludeContentByClass |
||
399 | * |
||
400 | * @param array $defaultIfEmpty |
||
401 | * @return array |
||
402 | */ |
||
403 | 39 | public function getIndexQueuePagesExcludeContentByClassArray($defaultIfEmpty = []) |
|
404 | { |
||
405 | 39 | $path = 'plugin.tx_solr.index.queue.pages.excludeContentByClass'; |
|
406 | 39 | $result = $this->getValueByPathOrDefaultValue($path, ''); |
|
407 | |||
408 | 39 | if (trim($result) == '') { |
|
409 | 7 | return $defaultIfEmpty; |
|
410 | } |
||
411 | |||
412 | 32 | return GeneralUtility::trimExplode(',', $result); |
|
413 | } |
||
414 | |||
415 | /** |
||
416 | * Returns the configured database table for an indexing queue configuration or |
||
417 | * the configurationName itself that is used by convention as tableName when no |
||
418 | * other tablename is present. |
||
419 | * |
||
420 | * plugin.tx_solr.index.queue.<configurationName>.table or configurationName |
||
421 | * |
||
422 | * @param string $configurationName |
||
423 | * @return string |
||
424 | */ |
||
425 | 63 | public function getIndexQueueTableNameOrFallbackToConfigurationName($configurationName = '') |
|
426 | { |
||
427 | 63 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.table'; |
|
428 | 63 | $result = $this->getValueByPathOrDefaultValue($path, $configurationName); |
|
429 | 63 | return $result; |
|
430 | } |
||
431 | |||
432 | /** |
||
433 | * Returns the field configuration for a specific index queue. |
||
434 | * |
||
435 | * plugin.tx_solr.index.queue.<configurationName>.fields. |
||
436 | * |
||
437 | * @param string $configurationName |
||
438 | * @param array $defaultIfEmpty |
||
439 | * @return array |
||
440 | */ |
||
441 | 22 | public function getIndexQueueFieldsConfigurationByConfigurationName($configurationName = '', $defaultIfEmpty = []) |
|
442 | { |
||
443 | 22 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.fields.'; |
|
444 | 22 | $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty); |
|
445 | 22 | return $result; |
|
446 | } |
||
447 | |||
448 | /** |
||
449 | * Gets an array of tables configured for indexing by the Index Queue. Since the |
||
450 | * record monitor must watch these tables for manipulation. |
||
451 | * |
||
452 | * @return array Array of table names to be watched by the record monitor. |
||
453 | */ |
||
454 | 34 | public function getIndexQueueMonitoredTables() |
|
455 | { |
||
456 | 34 | $monitoredTables = []; |
|
457 | |||
458 | 34 | $indexingConfigurations = $this->getEnabledIndexQueueConfigurationNames(); |
|
459 | 34 | foreach ($indexingConfigurations as $indexingConfigurationName) { |
|
460 | 34 | $monitoredTable = $this->getIndexQueueTableNameOrFallbackToConfigurationName($indexingConfigurationName); |
|
461 | 34 | $monitoredTables[] = $monitoredTable; |
|
462 | 34 | if ($monitoredTable == 'pages') { |
|
463 | // when monitoring pages, also monitor creation of translations |
||
464 | 34 | $monitoredTables[] = 'pages_language_overlay'; |
|
465 | } |
||
466 | } |
||
467 | |||
468 | 34 | return array_values(array_unique($monitoredTables)); |
|
469 | } |
||
470 | |||
471 | /** |
||
472 | * This method can be used to check if a table is configured to be monitored by the record monitor. |
||
473 | * |
||
474 | * @param string $tableName |
||
475 | * @return bool |
||
476 | */ |
||
477 | 33 | public function getIndexQueueIsMonitoredTable($tableName) |
|
478 | { |
||
479 | 33 | return in_array($tableName, $this->getIndexQueueMonitoredTables(), true); |
|
480 | } |
||
481 | |||
482 | /** |
||
483 | * Returns the configured indexer class that should be used for a certain indexingConfiguration. |
||
484 | * By default "ApacheSolrForTypo3\Solr\IndexQueue\Indexer" will be returned. |
||
485 | * |
||
486 | * plugin.tx_solr.index.queue.<configurationName>.indexer |
||
487 | * |
||
488 | * @param string $configurationName |
||
489 | * @param string $defaultIfEmpty |
||
490 | * @return string |
||
491 | */ |
||
492 | 6 | public function getIndexQueueIndexerByConfigurationName($configurationName, $defaultIfEmpty = Indexer::class) |
|
493 | { |
||
494 | 6 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer'; |
|
495 | 6 | $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty); |
|
496 | 6 | return $result; |
|
497 | } |
||
498 | |||
499 | /** |
||
500 | * Returns the configuration of an indexer for a special indexingConfiguration. By default an empty |
||
501 | * array is returned. |
||
502 | * |
||
503 | * plugin.tx_solr.index.queue.<configurationName>.indexer. |
||
504 | * |
||
505 | * @param string $configurationName |
||
506 | * @param array $defaultIfEmpty |
||
507 | * @return array |
||
508 | */ |
||
509 | 6 | public function getIndexQueueIndexerConfigurationByConfigurationName($configurationName, $defaultIfEmpty = []) |
|
510 | { |
||
511 | 6 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer.'; |
|
512 | 6 | $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty); |
|
513 | 6 | return $result; |
|
514 | } |
||
515 | |||
516 | /** |
||
517 | * Returns all solr fields names where a mapping configuration is set for a certain index configuration |
||
518 | * |
||
519 | * Returns all keys from |
||
520 | * plugin.tx_solr.index.queue.<configurationName>.fields. |
||
521 | * |
||
522 | * @param string $configurationName |
||
523 | * @param array $defaultIfEmpty |
||
524 | * @return array |
||
525 | */ |
||
526 | 9 | public function getIndexQueueMappedFieldsByConfigurationName($configurationName = '', $defaultIfEmpty = []) |
|
527 | { |
||
528 | 9 | $mappingConfiguration = $this->getIndexQueueFieldsConfigurationByConfigurationName($configurationName); |
|
529 | 9 | $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration); |
|
530 | 9 | return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames; |
|
531 | } |
||
532 | |||
533 | /** |
||
534 | * This method is used to check if an index queue configuration is enabled or not |
||
535 | * |
||
536 | * plugin.tx_solr.index.queue.<configurationName> = 1 |
||
537 | * |
||
538 | * @param string $configurationName |
||
539 | * @param bool $defaultIfEmpty |
||
540 | * @return bool |
||
541 | */ |
||
542 | 58 | public function getIndexQueueConfigurationIsEnabled($configurationName, $defaultIfEmpty = false) |
|
543 | { |
||
544 | 58 | $path = 'plugin.tx_solr.index.queue.' . $configurationName; |
|
545 | 58 | $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty); |
|
546 | 58 | return $this->getBool($result); |
|
547 | } |
||
548 | |||
549 | /** |
||
550 | * Retrieves an array of enabled index queue configurations. |
||
551 | * |
||
552 | * plugin.tx_solr.index.queue.<configurationName> |
||
553 | * |
||
554 | * @param array $defaultIfEmpty |
||
555 | * @return array |
||
556 | */ |
||
557 | 65 | public function getEnabledIndexQueueConfigurationNames($defaultIfEmpty = []) |
|
558 | { |
||
559 | 65 | $tablesToIndex = []; |
|
560 | 65 | $path = 'plugin.tx_solr.index.queue.'; |
|
561 | 65 | $indexQueueConfiguration = $this->getObjectByPathOrDefault($path, []); |
|
562 | 65 | foreach ($indexQueueConfiguration as $configurationName => $indexingEnabled) { |
|
563 | 63 | if (substr($configurationName, -1) != '.' && $indexingEnabled) { |
|
564 | 63 | $tablesToIndex[] = $configurationName; |
|
565 | } |
||
566 | } |
||
567 | |||
568 | 65 | return count($tablesToIndex) == 0 ? $defaultIfEmpty : $tablesToIndex; |
|
569 | } |
||
570 | |||
571 | /** |
||
572 | * Retrieves an array of additional fields that will trigger an recursive update of pages |
||
573 | * when some of the fields on that page are modified. |
||
574 | * |
||
575 | * plugin.tx_solr.index.queue.recursiveUpdateFields |
||
576 | * |
||
577 | * @param string $configurationName |
||
578 | * @param array $defaultIfEmpty |
||
579 | * @return array |
||
580 | */ |
||
581 | 26 | public function getIndexQueueConfigurationRecursiveUpdateFields($configurationName, $defaultIfEmpty = []) |
|
582 | { |
||
583 | 26 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.recursiveUpdateFields'; |
|
584 | 26 | $recursiveUpdateFieldsString = $this->getValueByPathOrDefaultValue($path, ''); |
|
585 | 26 | if (trim($recursiveUpdateFieldsString) === '') { |
|
586 | 20 | return $defaultIfEmpty; |
|
587 | } |
||
588 | 7 | $recursiveUpdateFields = GeneralUtility::trimExplode(',', $recursiveUpdateFieldsString); |
|
589 | // For easier check later on we return an array by combining $recursiveUpdateFields |
||
590 | 7 | return array_combine($recursiveUpdateFields, $recursiveUpdateFields); |
|
591 | } |
||
592 | |||
593 | |||
594 | /** |
||
595 | * Retrieves and initialPagesAdditionalWhereClause where clause when configured or an empty string. |
||
596 | * |
||
597 | * plugin.tx_solr.index.queue.<configurationName>.initialPagesAdditionalWhereClause |
||
598 | * |
||
599 | * @param string $configurationName |
||
600 | * @return string |
||
601 | */ |
||
602 | 13 | public function getInitialPagesAdditionalWhereClause($configurationName) |
|
603 | { |
||
604 | 13 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialPagesAdditionalWhereClause'; |
|
605 | 13 | $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, ''); |
|
606 | |||
607 | 13 | if (trim($initialPagesAdditionalWhereClause) === '') { |
|
608 | 13 | return ''; |
|
609 | } |
||
610 | |||
611 | 1 | return ' AND ' . $initialPagesAdditionalWhereClause; |
|
612 | } |
||
613 | |||
614 | /** |
||
615 | * Retrieves and additional where clause when configured or an empty string. |
||
616 | * |
||
617 | * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause |
||
618 | * |
||
619 | * @param string $configurationName |
||
620 | * @return string |
||
621 | */ |
||
622 | 61 | public function getIndexQueueAdditionalWhereClauseByConfigurationName($configurationName) |
|
623 | { |
||
624 | 61 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause'; |
|
625 | 61 | $additionalWhere = $this->getValueByPathOrDefaultValue($path, ''); |
|
626 | |||
627 | 61 | if (trim($additionalWhere) === '') { |
|
628 | 16 | return ''; |
|
629 | } |
||
630 | |||
631 | 46 | return ' AND ' . $additionalWhere; |
|
632 | } |
||
633 | |||
634 | /** |
||
635 | * This method can be used to retrieve all index queue configuration names, where |
||
636 | * a certain table is used. It can be configured with the property "table" or is using the configuration |
||
637 | * key a fallback for the table name. |
||
638 | * |
||
639 | * plugin.tx_solr.index.queue.<configurationName>. |
||
640 | * |
||
641 | * @param string $tableName |
||
642 | * @param array $defaultIfEmpty |
||
643 | * @return array |
||
644 | */ |
||
645 | 1 | public function getIndexQueueConfigurationNamesByTableName($tableName, $defaultIfEmpty = []) |
|
646 | { |
||
647 | 1 | $path = 'plugin.tx_solr.index.queue.'; |
|
648 | 1 | $configuration = $this->getObjectByPathOrDefault($path, []); |
|
649 | 1 | $possibleConfigurations = []; |
|
650 | |||
651 | 1 | foreach ($configuration as $configurationName => $indexingEnabled) { |
|
652 | 1 | $isObject = substr($configurationName, -1) == '.'; |
|
653 | 1 | if ($isObject || !$indexingEnabled) { |
|
654 | 1 | continue; |
|
655 | } |
||
656 | |||
657 | // when the configuration name equals the tableName we have a fallback |
||
658 | 1 | $hasTableNameAsConfigurationName = $configurationName == $tableName; |
|
659 | 1 | $hasTableAssignedInQueueConfiguration = isset($configuration[$configurationName . '.']['table']) && |
|
660 | 1 | $configuration[$configurationName . '.']['table'] == $tableName; |
|
661 | 1 | if ($hasTableNameAsConfigurationName || $hasTableAssignedInQueueConfiguration) { |
|
662 | 1 | $possibleConfigurations[] = $configurationName; |
|
663 | } |
||
664 | } |
||
665 | |||
666 | 1 | return count($possibleConfigurations) > 0 ? $possibleConfigurations : $defaultIfEmpty; |
|
667 | } |
||
668 | |||
669 | /** |
||
670 | * This method is used to retrieve the className of a queue initializer for a certain indexing configuration |
||
671 | * of returns the default initializer class, when noting is configured. |
||
672 | * |
||
673 | * plugin.tx_solr.index.queue.<configurationName>.initialization |
||
674 | * |
||
675 | * @param string $configurationName |
||
676 | * @param string $defaultIfEmpty |
||
677 | * @return string |
||
678 | */ |
||
679 | 6 | public function getIndexQueueInitializerClassByConfigurationName($configurationName, $defaultIfEmpty = Record::class) |
|
680 | { |
||
681 | 6 | $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialization'; |
|
682 | 6 | $className = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty); |
|
683 | |||
684 | 6 | return $className; |
|
685 | } |
||
686 | |||
687 | /** |
||
688 | * Returns the configured javascript file for a specific fileKey. |
||
689 | * |
||
690 | * plugin.tx_solr.javascriptFiles.<fileKey> |
||
691 | * |
||
692 | * @param string $fileKey |
||
693 | * @param string $defaultIfEmpty |
||
694 | * @return string |
||
695 | */ |
||
696 | 1 | public function getJavaScriptFileByFileKey($fileKey, $defaultIfEmpty = '') |
|
697 | { |
||
698 | 1 | $javaScriptFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.' . $fileKey, $defaultIfEmpty); |
|
699 | 1 | return (string)$javaScriptFileName; |
|
700 | } |
||
701 | |||
702 | /** |
||
703 | * Returns the configuration where to load the javascript |
||
704 | * |
||
705 | * plugin.tx_solr.javascriptFiles.loadIn |
||
706 | * |
||
707 | * @param string $defaultIfEmpty |
||
708 | * @return string |
||
709 | */ |
||
710 | public function getJavaScriptLoadIn($defaultIfEmpty = 'footer') |
||
711 | { |
||
712 | $loadIn = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.loadIn', $defaultIfEmpty); |
||
713 | return (string)$loadIn; |
||
714 | } |
||
715 | |||
716 | /** |
||
717 | * Returns the _LOCAL_LANG configuration from the TypoScript. |
||
718 | * |
||
719 | * plugin.tx_solr._LOCAL_LANG. |
||
720 | * |
||
721 | * @param array $defaultIfEmpty |
||
722 | * @return array |
||
723 | */ |
||
724 | public function getLocalLangConfiguration(array $defaultIfEmpty = []) |
||
725 | { |
||
726 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr._LOCAL_LANG.', $defaultIfEmpty); |
||
727 | return $result; |
||
728 | } |
||
729 | |||
730 | /** |
||
731 | * When this is enabled the output of the devlog, will be printed as debug output. |
||
732 | * |
||
733 | * @param bool $defaultIfEmpty |
||
734 | * @return bool |
||
735 | */ |
||
736 | public function getLoggingDebugOutput($defaultIfEmpty = false) |
||
737 | { |
||
738 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.debugOutput', $defaultIfEmpty); |
||
739 | return $this->getBool($result); |
||
740 | } |
||
741 | |||
742 | /** |
||
743 | * Returns if query filters should be written to the log. |
||
744 | * |
||
745 | * plugin.tx_solr.logging.query.filters |
||
746 | * |
||
747 | * @param bool $defaultIfEmpty |
||
748 | * @return bool |
||
749 | */ |
||
750 | 38 | public function getLoggingQueryFilters($defaultIfEmpty = false) |
|
751 | { |
||
752 | 38 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.filters', $defaultIfEmpty); |
|
753 | 38 | return $this->getBool($result); |
|
754 | } |
||
755 | |||
756 | /** |
||
757 | * Returns if the querystring should be logged or not. |
||
758 | * |
||
759 | * plugin.tx_solr.logging.query.queryString |
||
760 | * |
||
761 | * @param bool $defaultIfEmpty |
||
762 | * @return bool |
||
763 | */ |
||
764 | 29 | public function getLoggingQueryQueryString($defaultIfEmpty = false) |
|
765 | { |
||
766 | 29 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.queryString', $defaultIfEmpty); |
|
767 | 29 | return $this->getBool($result); |
|
768 | } |
||
769 | |||
770 | /** |
||
771 | * Returns if the searchWords should be logged or not. |
||
772 | * |
||
773 | * plugin.tx_solr.logging.query.searchWords |
||
774 | * |
||
775 | * @param bool $defaultIfEmpty |
||
776 | * @return bool |
||
777 | */ |
||
778 | 25 | public function getLoggingQuerySearchWords($defaultIfEmpty = false) |
|
779 | { |
||
780 | 25 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.searchWords', $defaultIfEmpty); |
|
781 | 25 | return $this->getBool($result); |
|
782 | } |
||
783 | |||
784 | /** |
||
785 | * Returns if the rawGet requests should be logged or not. |
||
786 | * |
||
787 | * plugin.tx_solr.logging.query.rawGet |
||
788 | * |
||
789 | * @param bool $defaultIfEmpty |
||
790 | * @return bool |
||
791 | */ |
||
792 | 43 | public function getLoggingQueryRawGet($defaultIfEmpty = false) |
|
793 | { |
||
794 | 43 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawGet', $defaultIfEmpty); |
|
795 | 43 | return $this->getBool($result); |
|
796 | } |
||
797 | |||
798 | /** |
||
799 | * Returns if the rawPost requests should be logged or not. |
||
800 | * |
||
801 | * plugin.tx_solr.logging.query.rawPost |
||
802 | * |
||
803 | * @param bool $defaultIfEmpty |
||
804 | * @return bool |
||
805 | */ |
||
806 | 68 | public function getLoggingQueryRawPost($defaultIfEmpty = false) |
|
807 | { |
||
808 | 68 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawPost', $defaultIfEmpty); |
|
809 | 68 | return $this->getBool($result); |
|
810 | } |
||
811 | |||
812 | /** |
||
813 | * Returns if the rawDelete requests should be logged or not. |
||
814 | * |
||
815 | * plugin.tx_solr.logging.query.rawDelete |
||
816 | * |
||
817 | * @param bool $defaultIfEmpty |
||
818 | * @return bool |
||
819 | */ |
||
820 | 4 | public function getLoggingQueryRawDelete($defaultIfEmpty = false) |
|
821 | { |
||
822 | 4 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawDelete', $defaultIfEmpty); |
|
823 | 4 | return $this->getBool($result); |
|
824 | } |
||
825 | |||
826 | /** |
||
827 | * Returns if exceptions should be logged or not. |
||
828 | * |
||
829 | * plugin.tx_solr.logging.exceptions |
||
830 | * |
||
831 | * @param bool $defaultIfEmpty |
||
832 | * @return bool |
||
833 | */ |
||
834 | 3 | public function getLoggingExceptions($defaultIfEmpty = true) |
|
835 | { |
||
836 | 3 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.exceptions', $defaultIfEmpty); |
|
837 | 3 | return $this->getBool($result); |
|
838 | } |
||
839 | |||
840 | /** |
||
841 | * Returns if indexing operations should be logged or not. |
||
842 | * |
||
843 | * plugin.tx_solr.logging.indexing |
||
844 | * |
||
845 | * @param bool $defaultIfEmpty |
||
846 | * @return bool |
||
847 | */ |
||
848 | 15 | public function getLoggingIndexing($defaultIfEmpty = false) |
|
849 | { |
||
850 | 15 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing', $defaultIfEmpty); |
|
851 | 15 | return $this->getBool($result); |
|
852 | } |
||
853 | |||
854 | /** |
||
855 | * Returns if indexing queue operations should be logged or not. |
||
856 | * |
||
857 | * plugin.tx_solr.logging.indexing.queue |
||
858 | * |
||
859 | * @param bool $defaultIfEmpty |
||
860 | * @return bool |
||
861 | */ |
||
862 | 14 | public function getLoggingIndexingQueue($defaultIfEmpty = false) |
|
863 | { |
||
864 | 14 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.queue', $defaultIfEmpty); |
|
865 | 14 | return $this->getBool($result); |
|
866 | } |
||
867 | |||
868 | /** |
||
869 | * This method can be used to check if the logging during indexing should be done. |
||
870 | * It takes the specific configuration by indexQueueConfiguration into account or is using the |
||
871 | * fallback when the logging is enabled on queue or indexing level. |
||
872 | * |
||
873 | * plugin.tx_solr.logging.indexing.queue.<indexQueueConfiguration> |
||
874 | * |
||
875 | * @param string $indexQueueConfiguration |
||
876 | * @param bool $defaultIfEmpty |
||
877 | * @return bool |
||
878 | */ |
||
879 | 15 | public function getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack($indexQueueConfiguration, $defaultIfEmpty = false) |
|
880 | { |
||
881 | // when logging is globally enabled we do not need to check the specific configuration |
||
882 | 15 | if ($this->getLoggingIndexing()) { |
|
883 | 1 | return true; |
|
884 | } |
||
885 | |||
886 | // when the logging for indexing is enabled on queue level we also do not need to check the specific configuration |
||
887 | 14 | if ($this->getLoggingIndexingQueue()) { |
|
888 | return true; |
||
889 | } |
||
890 | |||
891 | 14 | $path = 'plugin.tx_solr.logging.indexing.queue.' . $indexQueueConfiguration; |
|
892 | 14 | $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty); |
|
893 | 14 | return $this->getBool($result); |
|
894 | } |
||
895 | |||
896 | /** |
||
897 | * Returns if a log message should be written when a page was indexed. |
||
898 | * |
||
899 | * plugin.tx_solr.logging.indexing.pageIndexed |
||
900 | * |
||
901 | * @param bool $defaultIfEmpty |
||
902 | * @return bool |
||
903 | */ |
||
904 | 8 | public function getLoggingIndexingPageIndexed($defaultIfEmpty = false) |
|
905 | { |
||
906 | 8 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.pageIndexed', $defaultIfEmpty); |
|
907 | 8 | return $this->getBool($result); |
|
908 | } |
||
909 | |||
910 | /** |
||
911 | * Returns if a log message should be written when the TYPO3 search markers are missing in the page. |
||
912 | * |
||
913 | * plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers |
||
914 | * |
||
915 | * @param bool $defaultIfEmpty |
||
916 | * @return bool |
||
917 | */ |
||
918 | 9 | public function getLoggingIndexingMissingTypo3SearchMarkers($defaultIfEmpty = true) |
|
919 | { |
||
920 | 9 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers', $defaultIfEmpty); |
|
921 | 9 | return $this->getBool($result); |
|
922 | } |
||
923 | |||
924 | /** |
||
925 | * Returns if the initialization of an indexqueue should be logged. |
||
926 | * |
||
927 | * plugin.tx_solr.logging.indexing.indexQueueInitialization |
||
928 | * |
||
929 | * @param bool $defaultIfEmpty |
||
930 | * @return bool |
||
931 | */ |
||
932 | 12 | public function getLoggingIndexingIndexQueueInitialization($defaultIfEmpty = false) |
|
933 | { |
||
934 | 12 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.indexQueueInitialization', $defaultIfEmpty); |
|
935 | 12 | return $this->getBool($result); |
|
936 | } |
||
937 | |||
938 | /** |
||
939 | * Indicates if the debug mode is enabled or not. |
||
940 | * |
||
941 | * plugin.tx_solr.enableDebugMode |
||
942 | * |
||
943 | * @param bool $defaultIfEmpty |
||
944 | * @return bool |
||
945 | */ |
||
946 | 25 | public function getEnabledDebugMode($defaultIfEmpty = false) |
|
947 | { |
||
948 | 25 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.enableDebugMode', $defaultIfEmpty); |
|
949 | 25 | return $this->getBool($result); |
|
950 | } |
||
951 | |||
952 | /** |
||
953 | * Returns true or false if something is configured below plugin.tx_solr.solr. |
||
954 | * |
||
955 | * plugin.tx_solr.solr. |
||
956 | * |
||
957 | * @param boolean $defaultIfEmpty |
||
958 | * @return boolean |
||
959 | */ |
||
960 | 3 | public function getSolrHasConnectionConfiguration($defaultIfEmpty = false) |
|
961 | { |
||
962 | 3 | $configuration = $this->getObjectByPathOrDefault('plugin.tx_solr.solr.', []); |
|
963 | 3 | return $configuration !== [] ? true : $defaultIfEmpty; |
|
964 | } |
||
965 | |||
966 | /** |
||
967 | * Returns the defaultTimeout used for requests to the Solr server |
||
968 | * |
||
969 | * plugin.tx_solr.solr.timeout |
||
970 | * |
||
971 | * @param float $defaultIfEmpty |
||
972 | * @return float |
||
973 | */ |
||
974 | 91 | public function getSolrTimeout($defaultIfEmpty = 0.0) |
|
975 | { |
||
976 | 91 | return (float)$this->getValueByPathOrDefaultValue('plugin.tx_solr.solr.timeout', $defaultIfEmpty); |
|
977 | } |
||
978 | |||
979 | /** |
||
980 | * Returns the scheme used for requests to the Solr server |
||
981 | * |
||
982 | * plugin.tx_solr.solr.scheme |
||
983 | * |
||
984 | * Applies stdWrap on the configured setting |
||
985 | * |
||
986 | * @param string $defaultIfEmpty |
||
987 | * @return string |
||
988 | */ |
||
989 | 4 | public function getSolrScheme($defaultIfEmpty = 'http') |
|
990 | { |
||
991 | 4 | $valuePath = 'plugin.tx_solr.solr.scheme'; |
|
992 | 4 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
993 | 4 | return $this->renderContentElementOfConfigured($valuePath, $value); |
|
994 | } |
||
995 | |||
996 | /** |
||
997 | * Returns the hostname used for requests to the Solr server |
||
998 | * |
||
999 | * plugin.tx_solr.solr.host |
||
1000 | * |
||
1001 | * Applies stdWrap on the configured setting |
||
1002 | * |
||
1003 | * @param string $defaultIfEmpty |
||
1004 | * @return string |
||
1005 | */ |
||
1006 | 7 | public function getSolrHost($defaultIfEmpty = 'localhost') |
|
1007 | { |
||
1008 | 7 | $valuePath = 'plugin.tx_solr.solr.host'; |
|
1009 | 7 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
1010 | 7 | return $this->renderContentElementOfConfigured($valuePath, $value); |
|
1011 | } |
||
1012 | |||
1013 | /** |
||
1014 | * Returns the port used for requests to the Solr server |
||
1015 | * |
||
1016 | * plugin.tx_solr.solr.port |
||
1017 | * |
||
1018 | * Applies stdWrap on the configured setting |
||
1019 | * |
||
1020 | * @param int $defaultIfEmpty |
||
1021 | * @return int |
||
1022 | */ |
||
1023 | 4 | public function getSolrPort($defaultIfEmpty = 8983) |
|
1024 | { |
||
1025 | 4 | $valuePath = 'plugin.tx_solr.solr.port'; |
|
1026 | 4 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
1027 | 4 | return $this->renderContentElementOfConfigured($valuePath, $value); |
|
1028 | } |
||
1029 | |||
1030 | /** |
||
1031 | * Returns the path used for requests to the Solr server |
||
1032 | * |
||
1033 | * plugin.tx_solr.solr.path |
||
1034 | * |
||
1035 | * Applies stdWrap on the configured setting |
||
1036 | * |
||
1037 | * @param string $defaultIfEmpty |
||
1038 | * @return string |
||
1039 | */ |
||
1040 | 7 | public function getSolrPath($defaultIfEmpty = '/solr/core_en/') |
|
1041 | { |
||
1042 | 7 | $valuePath = 'plugin.tx_solr.solr.path'; |
|
1043 | 7 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
1044 | 7 | $solrPath = $this->renderContentElementOfConfigured($valuePath, $value); |
|
1045 | |||
1046 | 7 | $solrPath = trim($solrPath, '/'); |
|
1047 | 7 | $solrPath = '/' . $solrPath . '/'; |
|
1048 | |||
1049 | 7 | return $solrPath; |
|
1050 | } |
||
1051 | |||
1052 | /** |
||
1053 | * Returns the username used for requests to the Solr server |
||
1054 | * |
||
1055 | * plugin.tx_solr.solr.username |
||
1056 | * |
||
1057 | * Applies stdWrap on the configured setting |
||
1058 | * |
||
1059 | * @param string $defaultIfEmpty |
||
1060 | * @return string |
||
1061 | */ |
||
1062 | 4 | public function getSolrUsername($defaultIfEmpty = '') |
|
1063 | { |
||
1064 | 4 | $valuePath = 'plugin.tx_solr.solr.username'; |
|
1065 | 4 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
1066 | 4 | return $this->renderContentElementOfConfigured($valuePath, $value); |
|
1067 | } |
||
1068 | |||
1069 | /** |
||
1070 | * Returns the password used for requests to the Solr server |
||
1071 | * |
||
1072 | * plugin.tx_solr.solr.password |
||
1073 | * |
||
1074 | * Applies stdWrap on the configured setting |
||
1075 | * |
||
1076 | * @param string $defaultIfEmpty |
||
1077 | * @return string |
||
1078 | */ |
||
1079 | 4 | public function getSolrPassword($defaultIfEmpty = '') |
|
1080 | { |
||
1081 | 4 | $valuePath = 'plugin.tx_solr.solr.password'; |
|
1082 | 4 | $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty); |
|
1083 | 4 | return $this->renderContentElementOfConfigured($valuePath, $value); |
|
1084 | } |
||
1085 | |||
1086 | /** |
||
1087 | * Retrieves the complete search configuration |
||
1088 | * |
||
1089 | * plugin.tx_solr.search. |
||
1090 | * |
||
1091 | * @param array $defaultIfEmpty |
||
1092 | * @return array |
||
1093 | */ |
||
1094 | 25 | public function getSearchConfiguration(array $defaultIfEmpty = []) |
|
1095 | { |
||
1096 | 25 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.', $defaultIfEmpty); |
|
1097 | 25 | return $result; |
|
1098 | } |
||
1099 | |||
1100 | /** |
||
1101 | * Indicates if elevation should be used or not |
||
1102 | * |
||
1103 | * plugin.tx_solr.search.elevation |
||
1104 | * |
||
1105 | * @param bool $defaultIfEmpty |
||
1106 | * @return bool |
||
1107 | */ |
||
1108 | 25 | public function getSearchElevation($defaultIfEmpty = false) |
|
1109 | { |
||
1110 | 25 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation', $defaultIfEmpty); |
|
1111 | 25 | return $this->getBool($result); |
|
1112 | } |
||
1113 | |||
1114 | /** |
||
1115 | * Indicates if elevated results should be marked |
||
1116 | * |
||
1117 | * plugin.tx_solr.search.elevation.markElevatedResults |
||
1118 | * |
||
1119 | * @param bool $defaultIfEmpty |
||
1120 | * @return bool |
||
1121 | */ |
||
1122 | 25 | public function getSearchElevationMarkElevatedResults($defaultIfEmpty = true) |
|
1123 | { |
||
1124 | 25 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.markElevatedResults', $defaultIfEmpty); |
|
1125 | 25 | return $this->getBool($result); |
|
1126 | } |
||
1127 | |||
1128 | /** |
||
1129 | * Indicates if elevation should be forced |
||
1130 | * |
||
1131 | *plugin.tx_solr.search.elevation.forceElevation |
||
1132 | * |
||
1133 | * @param bool $defaultIfEmpty |
||
1134 | * @return bool |
||
1135 | */ |
||
1136 | 25 | public function getSearchElevationForceElevation($defaultIfEmpty = true) |
|
1137 | { |
||
1138 | 25 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.forceElevation', $defaultIfEmpty); |
|
1139 | 25 | return $this->getBool($result); |
|
1140 | } |
||
1141 | |||
1142 | /** |
||
1143 | * Indicates if collapsing on a certain field should be used to build variants or not. |
||
1144 | * |
||
1145 | * plugin.tx_solr.search.variants |
||
1146 | * |
||
1147 | * @param bool $defaultIfEmpty |
||
1148 | * @return bool |
||
1149 | */ |
||
1150 | 123 | public function getSearchVariants($defaultIfEmpty = false) |
|
1151 | { |
||
1152 | 123 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants', $defaultIfEmpty); |
|
1153 | 123 | return $this->getBool($result); |
|
1154 | } |
||
1155 | |||
1156 | /** |
||
1157 | * Indicates if collapsing on a certain field should be used or not |
||
1158 | * |
||
1159 | * plugin.tx_solr.search.variants.variantField |
||
1160 | * |
||
1161 | * @param string $defaultIfEmpty |
||
1162 | * @return string |
||
1163 | */ |
||
1164 | 3 | public function getSearchVariantsField($defaultIfEmpty = 'variantId') |
|
1165 | { |
||
1166 | 3 | return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.variantField', $defaultIfEmpty); |
|
1167 | } |
||
1168 | |||
1169 | /** |
||
1170 | * Indicates if expanding of collapsed items it activated. |
||
1171 | * |
||
1172 | * plugin.tx_solr.search.variants.expand |
||
1173 | * |
||
1174 | * @param bool $defaultIfEmpty |
||
1175 | * @return bool |
||
1176 | */ |
||
1177 | 4 | public function getSearchVariantsExpand($defaultIfEmpty = false) |
|
1178 | { |
||
1179 | 4 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.expand', $defaultIfEmpty); |
|
1180 | 4 | return $this->getBool($result); |
|
1181 | } |
||
1182 | |||
1183 | /** |
||
1184 | * Retrieves the number of elements that should be expanded. |
||
1185 | * |
||
1186 | * plugin.tx_solr.search.variants.limit |
||
1187 | * |
||
1188 | * @param int $defaultIfEmpty |
||
1189 | * @return int |
||
1190 | */ |
||
1191 | 2 | public function getSearchVariantsLimit($defaultIfEmpty = 10) |
|
1192 | { |
||
1193 | 2 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.limit', $defaultIfEmpty); |
|
1194 | 2 | return (int)$result; |
|
1195 | } |
||
1196 | |||
1197 | /** |
||
1198 | * Indicates if frequent searches should be show or not. |
||
1199 | * |
||
1200 | * plugin.tx_solr.search.frequentSearches |
||
1201 | * |
||
1202 | * @param bool $defaultIfEmpty |
||
1203 | * @return bool |
||
1204 | */ |
||
1205 | public function getSearchFrequentSearches($defaultIfEmpty = false) |
||
1206 | { |
||
1207 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches', $defaultIfEmpty); |
||
1208 | return $this->getBool($result); |
||
1209 | } |
||
1210 | |||
1211 | /** |
||
1212 | * Returns the sub configuration of the frequentSearches |
||
1213 | * |
||
1214 | * plugin.tx_solr.search.frequentSearches. |
||
1215 | * |
||
1216 | * @param array $defaultIfEmpty |
||
1217 | * @return array |
||
1218 | */ |
||
1219 | 23 | public function getSearchFrequentSearchesConfiguration($defaultIfEmpty = []) |
|
1220 | { |
||
1221 | 23 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.frequentSearches.', $defaultIfEmpty); |
|
1222 | 23 | return $result; |
|
1223 | } |
||
1224 | |||
1225 | /** |
||
1226 | * Retrieves the minimum font size that should be used for the frequentSearches. |
||
1227 | * |
||
1228 | * plugin.tx_solr.search.frequentSearches.minSize |
||
1229 | * |
||
1230 | * @param int $defaultIfEmpty |
||
1231 | * @return int |
||
1232 | */ |
||
1233 | 23 | public function getSearchFrequentSearchesMinSize($defaultIfEmpty = 14) |
|
1234 | { |
||
1235 | 23 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.minSize', $defaultIfEmpty); |
|
1236 | 23 | return (int)$result; |
|
1237 | } |
||
1238 | |||
1239 | /** |
||
1240 | * Retrieves the maximum font size that should be used for the frequentSearches. |
||
1241 | * |
||
1242 | * plugin.tx_solr.search.frequentSearches.minSize |
||
1243 | * |
||
1244 | * @param int $defaultIfEmpty |
||
1245 | * @return int |
||
1246 | */ |
||
1247 | 23 | public function getSearchFrequentSearchesMaxSize($defaultIfEmpty = 32) |
|
1248 | { |
||
1249 | 23 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.maxSize', $defaultIfEmpty); |
|
1250 | 23 | return (int)$result; |
|
1251 | } |
||
1252 | |||
1253 | /** |
||
1254 | * Indicates if frequent searches should be show or not. |
||
1255 | * |
||
1256 | * plugin.tx_solr.search.frequentSearches.useLowercaseKeywords |
||
1257 | * |
||
1258 | * @param bool $defaultIfEmpty |
||
1259 | * @return bool |
||
1260 | */ |
||
1261 | 21 | public function getSearchFrequentSearchesUseLowercaseKeywords($defaultIfEmpty = false) |
|
1262 | { |
||
1263 | 21 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.useLowercaseKeywords', $defaultIfEmpty); |
|
1264 | 21 | return $this->getBool($result); |
|
1265 | } |
||
1266 | |||
1267 | /** |
||
1268 | * Returns the configuration if the search should be initialized with an empty query. |
||
1269 | * |
||
1270 | * plugin.tx_solr.search.initializeWithEmptyQuery |
||
1271 | * |
||
1272 | * @param bool $defaultIfEmpty |
||
1273 | * @return bool |
||
1274 | */ |
||
1275 | 29 | public function getSearchInitializeWithEmptyQuery($defaultIfEmpty = false) |
|
1276 | { |
||
1277 | 29 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithEmptyQuery', $defaultIfEmpty); |
|
1278 | 29 | return $this->getBool($result); |
|
1279 | } |
||
1280 | |||
1281 | /** |
||
1282 | * Returns the configured initial query |
||
1283 | * |
||
1284 | * plugin.tx_solr.search.initializeWithQuery |
||
1285 | * |
||
1286 | * @param string $defaultIfEmpty |
||
1287 | * @return string |
||
1288 | */ |
||
1289 | 29 | public function getSearchInitializeWithQuery($defaultIfEmpty = '') |
|
1290 | { |
||
1291 | 29 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithQuery', $defaultIfEmpty); |
|
1292 | 29 | return (string)$result; |
|
1293 | } |
||
1294 | |||
1295 | /** |
||
1296 | * Returns if the last searches should be displayed or not. |
||
1297 | * |
||
1298 | * plugin.tx_solr.search.lastSearches |
||
1299 | * |
||
1300 | * @param bool $defaultIfEmpty |
||
1301 | * @return bool |
||
1302 | */ |
||
1303 | public function getSearchLastSearches($defaultIfEmpty = false) |
||
1304 | { |
||
1305 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches', $defaultIfEmpty); |
||
1306 | return $this->getBool($result); |
||
1307 | } |
||
1308 | |||
1309 | /** |
||
1310 | * Returns the lastSearch mode. "user" for user specific |
||
1311 | * |
||
1312 | * plugin.tx_solr.search.lastSearches.mode |
||
1313 | * |
||
1314 | * @param string $defaultIfEmpty |
||
1315 | * @return string |
||
1316 | */ |
||
1317 | 28 | public function getSearchLastSearchesMode($defaultIfEmpty = 'user') |
|
1318 | { |
||
1319 | 28 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.mode', $defaultIfEmpty); |
|
1320 | 28 | return (string)$result; |
|
1321 | } |
||
1322 | |||
1323 | /** |
||
1324 | * Returns the lastSearch limit |
||
1325 | * |
||
1326 | * plugin.tx_solr.search.lastSearches.limit |
||
1327 | * |
||
1328 | * @param int $defaultIfEmpty |
||
1329 | * @return int |
||
1330 | */ |
||
1331 | 28 | public function getSearchLastSearchesLimit($defaultIfEmpty = 10) |
|
1332 | { |
||
1333 | 28 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.limit', $defaultIfEmpty); |
|
1334 | 28 | return (int)$result; |
|
1335 | } |
||
1336 | |||
1337 | /** |
||
1338 | * Returns the search results fieldProcessingInstructions configuration array |
||
1339 | * |
||
1340 | * plugin.tx_solr.search.results.fieldProcessingInstructions. |
||
1341 | * |
||
1342 | * @param array $defaultIfEmpty |
||
1343 | * @return array |
||
1344 | */ |
||
1345 | public function getSearchResultsFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = []) |
||
1346 | { |
||
1347 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldProcessingInstructions.', $defaultIfEmpty); |
||
1348 | return $result; |
||
1349 | } |
||
1350 | |||
1351 | /** |
||
1352 | * Returns the search results fieldRenderingInstructions configuration array |
||
1353 | * |
||
1354 | * plugin.tx_solr.search.results.fieldRenderingInstructions. |
||
1355 | * |
||
1356 | * @param array $defaultIfEmpty |
||
1357 | * @return array |
||
1358 | */ |
||
1359 | public function getSearchResultsFieldRenderingInstructionsConfiguration(array $defaultIfEmpty = []) |
||
1360 | { |
||
1361 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldRenderingInstructions.', $defaultIfEmpty); |
||
1362 | return $result; |
||
1363 | } |
||
1364 | |||
1365 | /** |
||
1366 | * Indicates if the results of an initial empty query should be shown or not. |
||
1367 | * |
||
1368 | * plugin.tx_solr.search.showResultsOfInitialEmptyQuery |
||
1369 | * |
||
1370 | * @param bool $defaultIfEmpty |
||
1371 | * @return bool |
||
1372 | */ |
||
1373 | 3 | public function getSearchShowResultsOfInitialEmptyQuery($defaultIfEmpty = false) |
|
1374 | { |
||
1375 | 3 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialEmptyQuery', $defaultIfEmpty); |
|
1376 | 3 | return $this->getBool($result); |
|
1377 | } |
||
1378 | |||
1379 | /** |
||
1380 | * Indicates if the results of an initial search query should be shown. |
||
1381 | * |
||
1382 | * plugin.tx_solr.search.showResultsOfInitialQuery |
||
1383 | * |
||
1384 | * @param bool $defaultIfEmpty |
||
1385 | * @return bool |
||
1386 | */ |
||
1387 | 2 | public function getSearchShowResultsOfInitialQuery($defaultIfEmpty = false) |
|
1388 | { |
||
1389 | 2 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialQuery', $defaultIfEmpty); |
|
1390 | 2 | return $this->getBool($result); |
|
1391 | } |
||
1392 | |||
1393 | /** |
||
1394 | * Indicates if sorting was enabled or not. |
||
1395 | * |
||
1396 | * plugin.tx_solr.search.sorting |
||
1397 | * |
||
1398 | * @param bool $defaultIfEmpty |
||
1399 | * @return bool |
||
1400 | */ |
||
1401 | 46 | public function getSearchSorting($defaultIfEmpty = false) |
|
1402 | { |
||
1403 | 46 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.sorting', $defaultIfEmpty); |
|
1404 | 46 | return $this->getBool($result); |
|
1405 | } |
||
1406 | |||
1407 | /** |
||
1408 | * Returns the sorting options configurations. |
||
1409 | * |
||
1410 | * plugin.tx_solr.search.sorting.options. |
||
1411 | * |
||
1412 | * @param array $defaultIfEmpty |
||
1413 | * @return array |
||
1414 | */ |
||
1415 | 23 | public function getSearchSortingOptionsConfiguration($defaultIfEmpty = []) |
|
1416 | { |
||
1417 | 23 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.sorting.options.', $defaultIfEmpty); |
|
1418 | 23 | return $result; |
|
1419 | } |
||
1420 | |||
1421 | /** |
||
1422 | * Retrieves the sorting default order for a sort option. |
||
1423 | * |
||
1424 | * plugin.tx_solr.search.sorting.options.<sortOptionName>.defaultOrder |
||
1425 | * |
||
1426 | * or |
||
1427 | * |
||
1428 | * plugin.tx_solr.search.sorting.defaultOrder |
||
1429 | * |
||
1430 | * |
||
1431 | * @param string $sortOptionName |
||
1432 | * @param string $defaultIfEmpty |
||
1433 | * @return string |
||
1434 | */ |
||
1435 | 23 | public function getSearchSortingDefaultOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = 'asc') |
|
1436 | { |
||
1437 | 23 | $sortOrderSpecificPath = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.defaultOrder'; |
|
1438 | 23 | $specificSortOrder = $this->getValueByPathOrDefaultValue($sortOrderSpecificPath, null); |
|
1439 | |||
1440 | // if we have a concrete setting, use it |
||
1441 | 23 | if ($specificSortOrder !== null) { |
|
1442 | return $specificSortOrder; |
||
1443 | } |
||
1444 | |||
1445 | // no specific setting, check common setting |
||
1446 | 23 | $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder'; |
|
1447 | 23 | $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty); |
|
1448 | 23 | return $commonATagParamOrDefaultValue; |
|
1449 | } |
||
1450 | |||
1451 | /** |
||
1452 | * Returns the configured fixedOrder, if nothing configured defaultIfEmpty will be returned. |
||
1453 | * |
||
1454 | * plugin.tx_solr.search.sorting.options.<sortOptionName>.fixedOrder |
||
1455 | * |
||
1456 | * @param string $sortOptionName |
||
1457 | * @param string $defaultIfEmpty |
||
1458 | * @return string |
||
1459 | */ |
||
1460 | public function getSearchSortingFixedOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = '') |
||
1461 | { |
||
1462 | $fixedOrder = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.fixedOrder'; |
||
1463 | return $this->getValueByPathOrDefaultValue($fixedOrder, $defaultIfEmpty); |
||
1464 | } |
||
1465 | |||
1466 | /** |
||
1467 | * Returns the trusted fields configured for the search that do not need to be escaped. |
||
1468 | * |
||
1469 | * @param array $defaultIfEmpty |
||
1470 | * @return array |
||
1471 | */ |
||
1472 | 2 | public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url']) |
|
1473 | { |
||
1474 | 2 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', ''); |
|
1475 | |||
1476 | 2 | if (trim($result) === '') { |
|
1477 | return $defaultIfEmpty; |
||
1478 | } |
||
1479 | |||
1480 | 2 | return GeneralUtility::trimExplode(',', $result); |
|
1481 | } |
||
1482 | |||
1483 | /** |
||
1484 | * Indicates if the plugin arguments should be kept in the search form for a second submission. |
||
1485 | * |
||
1486 | * plugin.tx_solr.search.keepExistingParametersForNewSearches |
||
1487 | * |
||
1488 | * @param bool $defaultIfEmpty |
||
1489 | * @return bool |
||
1490 | */ |
||
1491 | public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false) |
||
1492 | { |
||
1493 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty); |
||
1494 | return $this->getBool($result); |
||
1495 | } |
||
1496 | |||
1497 | /** |
||
1498 | * Returns if an empty query is allowed on the query level. |
||
1499 | * |
||
1500 | * plugin.tx_solr.search.query.allowEmptyQuery |
||
1501 | * |
||
1502 | * @param string $defaultIfEmpty |
||
1503 | * @return bool |
||
1504 | */ |
||
1505 | 24 | public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '') |
|
1506 | { |
||
1507 | 24 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty); |
|
1508 | 24 | return $this->getBool($result); |
|
1509 | } |
||
1510 | |||
1511 | /** |
||
1512 | * Returns the fieldProcessingInstructions configuration array |
||
1513 | * |
||
1514 | * plugin.tx_solr.search.query.filter. |
||
1515 | * |
||
1516 | * @param array $defaultIfEmpty |
||
1517 | * @return array |
||
1518 | */ |
||
1519 | 34 | public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = []) |
|
1520 | { |
||
1521 | 34 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty); |
|
1522 | 34 | return $result; |
|
1523 | } |
||
1524 | |||
1525 | /** |
||
1526 | * Can be used to overwrite the filterConfiguration. |
||
1527 | * |
||
1528 | * plugin.tx_solr.search.query.filter. |
||
1529 | * |
||
1530 | * @param array $configuration |
||
1531 | */ |
||
1532 | 1 | public function setSearchQueryFilterConfiguration(array $configuration) |
|
1533 | { |
||
1534 | 1 | $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration); |
|
1535 | 1 | } |
|
1536 | |||
1537 | /** |
||
1538 | * Removes the pageSections filter setting. |
||
1539 | * |
||
1540 | * @return void |
||
1541 | */ |
||
1542 | 2 | public function removeSearchQueryFilterForPageSections() |
|
1543 | { |
||
1544 | 2 | $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections'); |
|
1545 | 2 | } |
|
1546 | |||
1547 | /** |
||
1548 | * Returns the configured queryFields from TypoScript |
||
1549 | * |
||
1550 | * plugin.tx_solr.search.query.queryFields |
||
1551 | * |
||
1552 | * @param string $defaultIfEmpty |
||
1553 | * @return string |
||
1554 | */ |
||
1555 | 124 | public function getSearchQueryQueryFields($defaultIfEmpty = '') |
|
1556 | { |
||
1557 | 124 | return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.queryFields', $defaultIfEmpty); |
|
1558 | } |
||
1559 | |||
1560 | /** |
||
1561 | * Returns the configured returnFields as array. |
||
1562 | * |
||
1563 | * plugin.tx_solr.search.query.returnFields |
||
1564 | * |
||
1565 | * @param array $defaultIfEmpty |
||
1566 | * @return array |
||
1567 | */ |
||
1568 | 126 | public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = []) |
|
1569 | { |
||
1570 | 126 | $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields'); |
|
1571 | 126 | if (is_null($returnFields)) { |
|
1572 | 96 | return $defaultIfEmpty; |
|
1573 | } |
||
1574 | |||
1575 | 30 | return GeneralUtility::trimExplode(',', $returnFields); |
|
1576 | } |
||
1577 | |||
1578 | /** |
||
1579 | * Returns the configured target page for the search. |
||
1580 | * By default the contextPageId will be used |
||
1581 | * |
||
1582 | * plugin.tx_solr.search.targetPage |
||
1583 | * |
||
1584 | * @return int |
||
1585 | */ |
||
1586 | 129 | public function getSearchTargetPage() |
|
1596 | |||
1597 | /** |
||
1598 | * Retrieves the targetPage configuration. |
||
1599 | * |
||
1600 | * plugin.tx_solr.search.targetPage. |
||
1601 | * |
||
1602 | * @param array $defaultIfEmpty |
||
1603 | * @return array |
||
1604 | */ |
||
1605 | public function getSearchTargetPageConfiguration(array $defaultIfEmpty = []) |
||
1606 | { |
||
1607 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.targetPage.', $defaultIfEmpty); |
||
1608 | return $result; |
||
1609 | } |
||
1610 | |||
1611 | /** |
||
1612 | * Retrieves the pagebrowser configuration. |
||
1613 | * |
||
1614 | * plugin.tx_solr.search.results.pagebrowser. |
||
1615 | * |
||
1616 | * @param array $defaultIfEmpty |
||
1617 | * @return array |
||
1618 | */ |
||
1619 | public function getSearchResultsPageBrowserConfiguration(array $defaultIfEmpty = []) |
||
1620 | { |
||
1621 | $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.pagebrowser.', $defaultIfEmpty); |
||
1622 | return $result; |
||
1623 | } |
||
1624 | |||
1625 | /** |
||
1626 | * Returns the result highlighting fields. |
||
1627 | * |
||
1628 | * plugin.tx_solr.search.results.resultsHighlighting.highlightFields |
||
1629 | * |
||
1630 | * @param string $defaultIfEmpty |
||
1631 | * @return string |
||
1632 | */ |
||
1633 | 32 | public function getSearchResultsHighlightingFields($defaultIfEmpty = '') |
|
1637 | |||
1638 | /** |
||
1639 | * Returns the result highlighting fields as array. |
||
1640 | * |
||
1641 | * plugin.tx_solr.search.results.resultsHighlighting.highlightFields |
||
1642 | * |
||
1643 | * @param array $defaultIfEmpty |
||
1644 | * @return array |
||
1645 | */ |
||
1646 | public function getSearchResultsHighlightingFieldsAsArray($defaultIfEmpty = []) |
||
1647 | { |
||
1648 | $highlightingFields = $this->getSearchResultsHighlightingFields(''); |
||
1649 | |||
1650 | if ($highlightingFields === '') { |
||
1651 | return $defaultIfEmpty; |
||
1652 | } |
||
1653 | |||
1654 | return GeneralUtility::trimExplode(',', $highlightingFields, true); |
||
1655 | } |
||
1656 | |||
1657 | /** |
||
1658 | * Returns the fragmentSeparator for highlighted segments. |
||
1659 | * |
||
1660 | * plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator |
||
1661 | * |
||
1662 | * @param string $defaultIfEmpty |
||
1663 | * @return string |
||
1664 | */ |
||
1665 | 19 | public function getSearchResultsHighlightingFragmentSeparator($defaultIfEmpty = '[...]') |
|
1669 | |||
1670 | /** |
||
1671 | * Returns the number of results that should be shown per page. |
||
1672 | * |
||
1673 | * plugin.tx_solr.search.results.resultsPerPage |
||
1674 | * |
||
1675 | * @param int $defaultIfEmpty |
||
1676 | * @return int |
||
1677 | */ |
||
1678 | 25 | public function getSearchResultsPerPage($defaultIfEmpty = 10) |
|
1682 | |||
1683 | /** |
||
1684 | * Returns the available options for the per page switch. |
||
1685 | * |
||
1686 | * plugin.tx_solr.search.results.resultsPerPageSwitchOptions |
||
1687 | * |
||
1688 | * @param array $defaultIfEmpty |
||
1689 | * @return array |
||
1690 | */ |
||
1691 | 25 | public function getSearchResultsPerPageSwitchOptionsAsArray($defaultIfEmpty = []) |
|
1701 | |||
1702 | /** |
||
1703 | * Returns the configured wrap for the resultHighlighting. |
||
1704 | * |
||
1705 | * plugin.tx_solr.search.results.resultsHighlighting.wrap |
||
1706 | * |
||
1707 | * @param string $defaultIfEmpty |
||
1708 | * @return string |
||
1709 | */ |
||
1710 | 32 | public function getSearchResultsHighlightingWrap($defaultIfEmpty = '') |
|
1714 | |||
1715 | /** |
||
1716 | * Indicates if spellchecking is enabled or not. |
||
1717 | * |
||
1718 | * plugin.tx_solr.search.spellchecking |
||
1719 | * |
||
1720 | * @param bool $defaultIfEmpty |
||
1721 | * @return bool |
||
1722 | */ |
||
1723 | public function getSearchSpellchecking($defaultIfEmpty = false) |
||
1724 | { |
||
1725 | $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty); |
||
1726 | return $this->getBool($isFacetingEnabled); |
||
1727 | } |
||
1728 | |||
1729 | /** |
||
1730 | * Returns the wrap that should be used for spellchecking |
||
1731 | * |
||
1732 | * plugin.tx_solr.search.spellchecking.wrap |
||
1733 | * |
||
1734 | * @param string $defaultIfEmpty |
||
1735 | * @return string |
||
1736 | */ |
||
1737 | public function getSearchSpellcheckingWrap($defaultIfEmpty = '') |
||
1738 | { |
||
1739 | return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.wrap', $defaultIfEmpty); |
||
1740 | } |
||
1741 | |||
1742 | /** |
||
1743 | * Returns the numberOfSuggestionsToTry that should be used for the spellchecking. |
||
1744 | * |
||
1745 | * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry |
||
1746 | * |
||
1747 | * @param int $defaultIfEmpty |
||
1748 | * @return int |
||
1749 | */ |
||
1750 | 23 | public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 0) |
|
1754 | |||
1755 | /** |
||
1756 | * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found. |
||
1757 | * |
||
1758 | * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion |
||
1759 | * |
||
1760 | * @param bool $defaultIfEmpty |
||
1761 | * @return bool |
||
1762 | */ |
||
1763 | public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false) |
||
1764 | { |
||
1765 | $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty); |
||
1766 | return $this->getBool($result); |
||
1767 | } |
||
1768 | |||
1769 | /** |
||
1770 | * Indicates if faceting is enabled or not. |
||
1771 | * |
||
1772 | * plugin.tx_solr.search.faceting |
||
1773 | * |
||
1774 | * @param bool $defaultIfEmpty |
||
1775 | * @return bool |
||
1776 | */ |
||
1777 | public function getSearchFaceting($defaultIfEmpty = false) |
||
1778 | { |
||
1779 | $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty); |
||
1780 | return $this->getBool($isFacetingEnabled); |
||
1781 | } |
||
1782 | |||
1783 | /** |
||
1784 | * Retrieves the facetLinkATagParams for a facet by facet name. If nothing specific is configured |
||
1785 | * the global facetLinkATagParams with be returned. |
||
1786 | * |
||
1787 | * plugin.tx_solr.search.faceting.facets.<facetName>.facetLinkATagParams |
||
1788 | * |
||
1789 | * or |
||
1790 | * |
||
1791 | * plugin.tx_solr.search.faceting.facetLinkATagParams |
||
1792 | * |
||
1793 | * |
||
1794 | * @param string $facetName |
||
1795 | * @param string $defaultIfEmpty |
||
1796 | * @return string |
||
1797 | */ |
||
1798 | 1 | public function getSearchFacetingFacetLinkATagParamsByName($facetName = '', $defaultIfEmpty = '') |
|
1813 | |||
1814 | /** |
||
1815 | * Returns the test that should be used to remove a faceting link |
||
1816 | * |
||
1817 | * plugin.tx_solr.search.faceting.removeFacetLinkText |
||
1818 | * |
||
1819 | * @param string $defaultIfEmpty |
||
1820 | * @return string |
||
1821 | */ |
||
1822 | public function getSearchFacetingRemoveFacetLinkText($defaultIfEmpty = '@facetLabel: @facetText') |
||
1823 | { |
||
1824 | return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.removeFacetLinkText', $defaultIfEmpty); |
||
1825 | } |
||
1826 | |||
1827 | /** |
||
1828 | * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured |
||
1829 | * the global showEmptyFacets with be returned. |
||
1830 | * |
||
1831 | * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty |
||
1832 | * |
||
1833 | * or |
||
1834 | * |
||
1835 | * plugin.tx_solr.search.faceting.showEmptyFacets |
||
1836 | * |
||
1837 | * |
||
1838 | * @param string $facetName |
||
1839 | * @param bool $defaultIfEmpty |
||
1840 | * @return bool |
||
1841 | */ |
||
1842 | 48 | public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false) |
|
1857 | |||
1858 | /** |
||
1859 | * Returns the wrap for the faceting show all link |
||
1860 | * |
||
1861 | * plugin.tx_solr.search.faceting.showAllLink.wrap |
||
1862 | * |
||
1863 | * @param string $defaultIfEmpty |
||
1864 | * @return string |
||
1865 | */ |
||
1866 | public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '') |
||
1870 | |||
1871 | /** |
||
1872 | * Returns the link url parameters that should be added to a facet. |
||
1873 | * |
||
1874 | * plugin.tx_solr.search.faceting.facetLinkUrlParameters |
||
1875 | * |
||
1876 | * @param string $defaultIfEmpty |
||
1877 | * @return string |
||
1878 | */ |
||
1879 | 18 | public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '') |
|
1885 | |||
1886 | /** |
||
1887 | * Returns if the facetLinkUrlsParameters should be included in the reset link. |
||
1888 | * |
||
1889 | * plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl |
||
1890 | * |
||
1891 | * @param bool $defaultIfEmpty |
||
1892 | * @return bool |
||
1893 | */ |
||
1894 | 2 | public function getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl($defaultIfEmpty = true) |
|
1899 | |||
1900 | /** |
||
1901 | * Returns the link url parameters that should be added to a facet as array. |
||
1902 | * |
||
1903 | * plugin.tx_solr.search.faceting.facetLinkUrlParameters |
||
1904 | * |
||
1905 | * @param array $defaultIfEmpty |
||
1906 | * @return array |
||
1907 | */ |
||
1908 | 18 | public function getSearchFacetingFacetLinkUrlParametersAsArray($defaultIfEmpty = []) |
|
1917 | |||
1918 | /** |
||
1919 | * Return the configured minimumCount value for facets. |
||
1920 | * |
||
1921 | * plugin.tx_solr.search.faceting.minimumCount |
||
1922 | * |
||
1923 | * @param int $defaultIfEmpty |
||
1924 | * @return int |
||
1925 | */ |
||
1926 | 32 | public function getSearchFacetingMinimumCount($defaultIfEmpty = 1) |
|
1930 | |||
1931 | /** |
||
1932 | * Return the configured limit value for facets, used for displaying. |
||
1933 | * |
||
1934 | * plugin.tx_solr.search.faceting.limit |
||
1935 | * |
||
1936 | * @param int $defaultIfEmpty |
||
1937 | * @return int |
||
1938 | */ |
||
1939 | public function getSearchFacetingLimit($defaultIfEmpty = 10) |
||
1940 | { |
||
1941 | return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.limit', $defaultIfEmpty); |
||
1942 | } |
||
1943 | |||
1944 | /** |
||
1945 | * Return the configured limit value for facets, used for the response. |
||
1946 | * |
||
1947 | * plugin.tx_solr.search.faceting.facetLimit |
||
1948 | * |
||
1949 | * @param int $defaultIfEmpty |
||
1950 | * @return int |
||
1951 | */ |
||
1952 | 32 | public function getSearchFacetingFacetLimit($defaultIfEmpty = 100) |
|
1956 | |||
1957 | /** |
||
1958 | * Returns if the singleFacetMode is active or not. |
||
1959 | * |
||
1960 | * plugin.tx_solr.search.faceting.singleFacetMode |
||
1961 | * |
||
1962 | * @param bool $defaultIfEmpty |
||
1963 | * @return bool |
||
1964 | */ |
||
1965 | public function getSearchFacetingSingleFacetMode($defaultIfEmpty = false) |
||
1966 | { |
||
1967 | $singleFacetMode = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.singleFacetMode', $defaultIfEmpty); |
||
1968 | return $this->getBool($singleFacetMode); |
||
1969 | } |
||
1970 | |||
1971 | /** |
||
1972 | * Return the configured faceting sortBy value. |
||
1973 | * |
||
1974 | * plugin.tx_solr.search.faceting.sortBy |
||
1975 | * |
||
1976 | * @param string $defaultIfEmpty |
||
1977 | * @return string |
||
1978 | */ |
||
1979 | 32 | public function getSearchFacetingSortBy($defaultIfEmpty = '') |
|
1983 | |||
1984 | /** |
||
1985 | * Returns if a facets should be kept on selection. Global faceting setting |
||
1986 | * can also be configured on facet level by using |
||
1987 | * (plugin.tx_solr.search.faceting.facets.<fieldName>.keepAllOptionsOnSelection) |
||
1988 | * |
||
1989 | * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection |
||
1990 | * |
||
1991 | * @param bool $defaultIfEmpty |
||
1992 | * @return bool |
||
1993 | */ |
||
1994 | 28 | public function getSearchFacetingKeepAllFacetsOnSelection($defaultIfEmpty = false) |
|
1999 | |||
2000 | /** |
||
2001 | * Returns the configured faceting configuration. |
||
2002 | * |
||
2003 | * plugin.tx_solr.search.faceting.facets |
||
2004 | * |
||
2005 | * @param array $defaultIfEmpty |
||
2006 | * @return array |
||
2007 | */ |
||
2008 | 49 | public function getSearchFacetingFacets(array $defaultIfEmpty = []) |
|
2012 | |||
2013 | /** |
||
2014 | * Returns the configuration of a single facet by facet name. |
||
2015 | * |
||
2016 | * plugin.tx_solr.search.faceting.facets.<facetName> |
||
2017 | * |
||
2018 | * @param string $facetName |
||
2019 | * @param array $defaultIfEmpty |
||
2020 | * @return array |
||
2021 | */ |
||
2022 | 28 | public function getSearchFacetingFacetByName($facetName, $defaultIfEmpty = []) |
|
2026 | |||
2027 | /** |
||
2028 | * Indicates if statistics is enabled or not. |
||
2029 | * |
||
2030 | * plugin.tx_solr.statistics |
||
2031 | * |
||
2032 | * @param bool $defaultIfEmpty |
||
2033 | * @return bool |
||
2034 | */ |
||
2035 | 25 | public function getStatistics($defaultIfEmpty = false) |
|
2040 | |||
2041 | /** |
||
2042 | * Indicates to which length an ip should be anonymized in the statistics |
||
2043 | * |
||
2044 | * plugin.tx_solr.statistics.anonymizeIP |
||
2045 | * |
||
2046 | * @param int $defaultIfEmpty |
||
2047 | * @return int |
||
2048 | */ |
||
2049 | 21 | public function getStatisticsAnonymizeIP($defaultIfEmpty = 0) |
|
2054 | |||
2055 | /** |
||
2056 | * Indicates if additional debug Data should be added to the statistics |
||
2057 | * |
||
2058 | * plugin.tx_solr.statistics.addDebugData |
||
2059 | * |
||
2060 | * @param bool $defaultIfEmpty |
||
2061 | * @return bool |
||
2062 | */ |
||
2063 | 21 | public function getStatisticsAddDebugData($defaultIfEmpty = false) |
|
2068 | |||
2069 | /** |
||
2070 | * Indicates if suggestion is enabled or not. |
||
2071 | * |
||
2072 | * plugin.tx_solr.suggest |
||
2073 | * |
||
2074 | * @param bool $defaultIfEmpty |
||
2075 | * @return bool |
||
2076 | */ |
||
2077 | public function getSuggest($defaultIfEmpty = false) |
||
2078 | { |
||
2079 | $isSuggestionEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest', $defaultIfEmpty); |
||
2080 | return $this->getBool($isSuggestionEnabled); |
||
2081 | } |
||
2082 | |||
2083 | /** |
||
2084 | * Indicates if https should be used for the suggest form. |
||
2085 | * |
||
2086 | * plugin.tx_solr.suggest.forceHttps |
||
2087 | * |
||
2088 | * @param bool $defaultIfEmpty |
||
2089 | * @return bool |
||
2090 | */ |
||
2091 | public function getSuggestForceHttps($defaultIfEmpty = false) |
||
2092 | { |
||
2093 | $isHttpsForced = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.forceHttps', $defaultIfEmpty); |
||
2094 | return $this->getBool($isHttpsForced); |
||
2095 | } |
||
2096 | |||
2097 | /** |
||
2098 | * Returns the configured template for a specific template fileKey. |
||
2099 | * |
||
2100 | * plugin.tx_solr.search.templateFiles.<fileKey> |
||
2101 | * |
||
2102 | * @param string $fileKey |
||
2103 | * @param string $defaultIfEmpty |
||
2104 | * @return string |
||
2105 | */ |
||
2106 | public function getTemplateByFileKey($fileKey, $defaultIfEmpty = '') |
||
2107 | { |
||
2108 | $templateFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.templateFiles.' . $fileKey, $defaultIfEmpty); |
||
2109 | return (string)$templateFileName; |
||
2110 | } |
||
2111 | |||
2112 | /** |
||
2113 | * Returns the configuration of the crop view helper. |
||
2114 | * |
||
2115 | * plugin.tx_solr.viewHelpers.crop. |
||
2116 | * |
||
2117 | * @param array $defaultIfEmpty |
||
2118 | * @return array |
||
2119 | */ |
||
2120 | public function getViewHelpersCropConfiguration(array $defaultIfEmpty = []) |
||
2121 | { |
||
2122 | $cropViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.crop.', $defaultIfEmpty); |
||
2123 | return $cropViewHelperConfiguration; |
||
2124 | } |
||
2125 | |||
2126 | /** |
||
2127 | * Returns the configuration of the sorting view helper. |
||
2128 | * |
||
2129 | * plugin.tx_solr.viewHelpers.sortIndicator. |
||
2130 | * |
||
2131 | * @param array $defaultIfEmpty |
||
2132 | * @return array |
||
2133 | */ |
||
2134 | public function getViewHelpersSortIndicatorConfiguration(array $defaultIfEmpty = []) |
||
2135 | { |
||
2136 | $sortingViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.sortIndicator.', $defaultIfEmpty); |
||
2137 | return $sortingViewHelperConfiguration; |
||
2138 | } |
||
2139 | |||
2140 | /** |
||
2141 | * Controls whether ext-solr will send commits to solr. |
||
2142 | * Beware: If you disable this, you need to ensure |
||
2143 | * that some other mechanism will commit your changes |
||
2144 | * otherwise they will never be searchable. |
||
2145 | * A good way to achieve this is enabling the solr |
||
2146 | * daemons autoCommit feature. |
||
2147 | * |
||
2148 | * plugin.tx_solr.index.enableCommits |
||
2149 | * |
||
2150 | * @param bool $defaultIfEmpty |
||
2151 | * @return bool |
||
2152 | */ |
||
2153 | 16 | public function getEnableCommits($defaultIfEmpty = true) |
|
2154 | { |
||
2155 | 16 | $enableCommits = $this->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableCommits', $defaultIfEmpty); |
|
2156 | 16 | return $this->getBool($enableCommits); |
|
2157 | } |
||
2158 | |||
2159 | /* |
||
2160 | * Applies the stdWrap if it is configured for the path, otherwise the unprocessed value will be returned. |
||
2161 | * |
||
2162 | * @param string $valuePath |
||
2163 | * @param mixed $value |
||
2164 | * @return mixed |
||
2165 | */ |
||
2166 | 7 | protected function renderContentElementOfConfigured($valuePath, $value) |
|
2177 | } |
||
2178 |