Elgg  Version master
byline.php
Go to the documentation of this file.
1 <?php
14 $entity = elgg_extract('entity', $vars);
15 if (!$entity instanceof \ElggEntity) {
16  return;
17 }
18 
19 $show_links = elgg_extract('show_links', $vars, true);
20 
22 if (!isset($byline_str)) {
23  $parts = [];
24 
25  $owner = elgg_extract('byline_owner_entity', $vars, $entity->getOwnerEntity());
26  if ($owner instanceof \ElggEntity) {
27  if ($show_links && !$owner->isDeleted()) {
28  $owner_text = elgg_view_entity_url($owner);
29  } else {
30  $owner_text = $owner->getDisplayName();
31  }
32 
33  $parts[] = elgg_echo('byline', [$owner_text]);
34  }
35 
36  $container_entity = elgg_extract('byline_container_entity', $vars, $entity->getContainerEntity());
37  if ($container_entity instanceof \ElggGroup && $container_entity->guid !== elgg_get_page_owner_guid()) {
38  if ($show_links && !$container_entity->isDeleted()) {
39  $group_text = elgg_view_entity_url($container_entity);
40  } else {
41  $group_text = $container_entity->getDisplayName();
42  }
43 
44  $parts[] = elgg_echo('byline:ingroup', [$group_text]);
45  }
46 
47  $byline_str = implode(' ', $parts);
48 }
49 
51  return;
52 }
53 
54 echo elgg_view('trash/elements/imprint/element', [
55  'content' => $byline_str,
56  'class' => 'elgg-listing-byline',
57 ]);
$owner
Definition: upload.php:7
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_get_page_owner_guid()
Elgg page owner library.
Definition: pageowner.php:12
$byline_str
Definition: byline.php:19
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
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
$entity
Displays information about the author and container of the post.
Definition: byline.php:14
$vars
Definition: theme.php:5
if(!$annotation instanceof ElggAnnotation) $show_links
Definition: byline.php:17
elgg_view_entity_url(\ElggEntity $entity, array $options=[])
Helper function for outputting a link to an entity.
Definition: views.php:1444