5 use Doctrine\DBAL\Query\Expression\CompositeExpression;
 
   14 use Elgg\Traits\Database\LegacyQueryOptionsAdapter;
 
   24     use LegacyQueryOptionsAdapter;
 
   67         if (empty($query_parts) || empty(array_filter(
$fields))) {
 
   76             throw new DomainException(
"'{$entity_type}' is not a valid entity type");
 
   80         if (!empty($entity_subtype) && is_string($entity_subtype)) {
 
   86         if ($this->events->hasHandler(
'search:results', $search_type)) {
 
   87             $results = $this->events->triggerResults(
'search:results', $search_type, 
$options);
 
  112         $options[
'search_type'] = $search_type;
 
  120         $options[
'_elgg_search_service_normalize_options'] = 
true;
 
  157         $query = htmlspecialchars(
$query, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, 
'UTF-8', 
false);
 
  160         $words = preg_split(
'/\s+/', 
$query);
 
  161         $words = array_map(
function ($e) {
 
  165         $query = implode(
' ', $words);
 
  176         $options[
'query_parts'] = array_unique(array_filter($parts));
 
  198         $clean_field_property_types = 
function ($new_fields) use ($default_fields) {
 
  199             $property_types = array_keys($default_fields);
 
  200             foreach ($property_types as $property_type) {
 
  201                 if (empty($new_fields[$property_type])) {
 
  202                     $new_fields[$property_type] = [];
 
  204                     $new_fields[$property_type] = array_unique($new_fields[$property_type]);
 
  211         $merge_fields = 
function ($new_fields) use (&
$fields, $clean_field_property_types) {
 
  212             if (empty($new_fields) || !is_array($new_fields)) {
 
  216             $new_fields = $clean_field_property_types($new_fields);
 
  222         $normalized_options = $this->normalizeTypeSubtypeOptions(
$options);
 
  224         $type_subtype_pairs = 
elgg_extract(
'type_subtype_pairs', $normalized_options);
 
  225         if (!empty($type_subtype_pairs)) {
 
  226             foreach ($type_subtype_pairs as $entity_type => $entity_subtypes) {
 
  227                 $result = $this->events->triggerResults(
'search:fields', $entity_type, 
$options, $default_fields);
 
  234                 foreach ($entity_subtypes as $entity_subtype) {
 
  235                     $result = $this->events->triggerResults(
'search:fields', 
"{$entity_type}:{$entity_subtype}", 
$options, $default_fields);
 
  254             foreach (
$fields as $property_type => $property_type_fields) {
 
  255                 if (empty(
$options[
'fields'][$property_type])) {
 
  256                     $options[
'fields'][$property_type] = [];
 
  260                 $allowed = array_intersect($property_type_fields, (array) 
$options[
'fields'][$property_type]);
 
  261                 $options[
'fields'][$property_type] = array_values(array_unique($allowed));
 
  287         $populate_where = 
function ($where, $part) use ($partial_match) {
 
  288             $where->values = $partial_match ? 
"%{$part}%" : $part;
 
  289             $where->comparison = 
'LIKE';
 
  292                 $where->case_sensitive = 
false;
 
  298                 $attribute_ands = [];
 
  299                 foreach ($query_parts as $part) {
 
  301                     $populate_where($where, $part);
 
  302                     $attribute_ands[] = $where->prepare(
$qb, $alias);
 
  305                 $ors[] = 
$qb->merge($attribute_ands, 
'AND');
 
  311             $md_alias = 
$qb->joinMetadataTable($alias, 
'guid', 
$metadata, 
'left');
 
  312             foreach ($query_parts as $part) {
 
  314                 $populate_where($where, $part);
 
  315                 $metadata_ands[] = $where->prepare(
$qb, $md_alias);
 
  318             $ors[] = 
$qb->merge($metadata_ands, 
'AND');
 
  321         if (!empty($annotations)) {
 
  322             $annotations_ands = [];
 
  323             $an_alias = 
$qb->joinAnnotationTable($alias, 
'guid', $annotations, 
'left');
 
  324             foreach ($query_parts as $part) {
 
  326                 $populate_where($where, $part);
 
  327                 $annotations_ands[] = $where->prepare(
$qb, $an_alias);
 
  330             $ors[] = 
$qb->merge($annotations_ands, 
'AND');
 
  333         return $qb->merge($ors, 
'OR');
 
$fields
Save the configuration of the security.txt contents.
$attributes
Elgg AJAX loader.
Builds queries for matching annotations against their properties.
Builds queries for matching entities by their attributes.
static factory(array $attributes)
Build a new AttributeWhereClause.
Database abstraction query builder.
Exception thrown if a value does not adhere to a defined valid data domain.
normalizeSearchFields(array $options=[])
Normalizes an array of search fields.
normalizeOptions(array $options=[])
Normalize options.
normalizeQuery(array $options=[])
Normalize query parts.
search(array $options=[])
Returns search results as an array of entities, as a batch, or a count, depending on parameters given...
buildSearchWhereQuery(QueryBuilder $qb, $alias, $fields, $query_parts, $partial_match=true)
Builds search clause.
__construct(protected Config $config, protected EventsService $events, protected Database $db)
Constructor.
prepareSearchOptions(array $options=[])
Prepare ege* options.
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
$config
Advanced site settings, debugging section.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.