ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMailLuceneQueryParser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
24 private array $fields = [];
25
26 public function parse(): void
27 {
28 if (!empty($this->getFields())) {
29 $queried_fields = [];
30 $token_operator = ' OR ';
31 if (ilSearchSettings::getInstance()->getDefaultOperator() === ilSearchSettings::OPERATOR_AND) {
32 $token_operator = ' AND ';
33 }
34
35 // ILIAS 10: each filter field has now its own query string
36 foreach ($this->getFields() as $field => $query_string) {
37 if (empty($query_string)) {
38 continue;
39 }
40
41 $field_query = '';
42 $tokens = array_map(trim(...), explode(' ', $query_string));
43 foreach ($tokens as $token) {
44 if ($field_query !== '') {
45 $field_query .= $token_operator;
46 }
47 $field_query .= '(' . $field . ':' . $token . ')';
48 }
49
50 $queried_fields[] = '(' . $field_query . ')';
51 }
52
53 if ($queried_fields !== []) {
54 $this->parsed_query = implode(' OR ', $queried_fields);
55 return;
56 }
57 }
58
59 parent::parse();
60 }
61
68 public function setFields(array $fields): void
69 {
70 $this->fields = $fields;
71 }
72
78 public function getFields(): array
79 {
80 return $this->fields;
81 }
82}
getFields()
Get the fields to query for ILIAS 10 the values are not boolean, but different query strings for the ...
setFields(array $fields)
Set the fields to query for ILIAS 10: the values are not boolean, but different query strings for the...
$token
Definition: xapitoken.php:70