Elgg  Version master
default.php
Go to the documentation of this file.
1 <?php
2 
3 $entity = elgg_extract('entity', $vars);
4 if (!$entity instanceof \ElggUser) {
5  return;
6 }
7 
8 $input_name = elgg_extract('input_name', $vars);
9 
10 // reset the viewtype so we can render html views
12 elgg_set_viewtype('default');
13 
15  'use_link' => false,
16  'href' => false,
17  'use_hover' => false,
18 ]);
19 
20 $label = elgg_view_image_block($icon, $entity->getDisplayName(), ['class' => 'elgg-autocomplete-item']);
21 
22 $data = $entity->toObject();
23 $data->label = $label;
24 $data->value = $entity->username;
25 $data->icon = $icon;
26 
28  $data->html = elgg_view('input/autocomplete/item', $vars);
29 }
30 
31 echo json_encode($data);
32 
33 // restore viewtype
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:898
$data
Definition: default.php:21
elgg_get_viewtype()
Return the current view type.
Definition: views.php:73
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_view_entity_icon(\ElggEntity $entity, string $size= 'medium', array $vars=[])
View the icon of an entity.
Definition: views.php:542
if(!$entity instanceof ElggEntity) $input_name
Definition: default.php:14
elgg_set_viewtype(string $viewtype= '')
Manually set the viewtype.
Definition: views.php:60
$viewtype
Definition: default.php:11
if(!array_key_exists($size, $icon_sizes)) $vars['size']
Definition: default.php:25
$entity
Generic icon view.
Definition: default.php:13
$label
Definition: default.php:19
if($user->isBanned()) elseif($user->isValidated()===false) $icon
Definition: default.php:46