Elgg  Version 3.0
item.php
Go to the documentation of this file.
1 <?php
9 $entity = elgg_extract('entity', $vars);
10 if (!$entity instanceof ElggEntity) {
11  return;
12 }
13 
14 $type = $entity->getType();
15 $subtype = $entity->getSubtype();
16 
17 $views = [
18  "input/autocomplete/{$type}/{$subtype}",
19  "input/autocomplete/{$type}/default",
20  "input/autocomplete/default",
21 ];
22 foreach ($views as $view) {
23  if (elgg_view_exists($view)) {
24  echo elgg_view($view, $vars);
25  return;
26  }
27 }
28 
29 elgg_log("No autocomplete item view could be found for {$entity->guid}", 'WARNING');
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
$subtype
Definition: item.php:15
$entity
Item view for generating HTML of an entity in an input/autocomplete (or input/userpicker) ...
Definition: item.php:9
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:786
if(!$entity instanceof ElggEntity) $type
Definition: item.php:14
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$vars['type']
Definition: save.php:11
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$views
Definition: item.php:17