Elgg  Version 3.0
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) {
28  $owner_text = elgg_view('output/url', [
29  'href' => $owner->getURL(),
30  'text' => $owner->getDisplayName(),
31  'is_trusted' => true,
32  ]);
33  } else {
34  $owner_text = $owner->getDisplayName();
35  }
36 
37  $parts[] = elgg_echo('byline', [$owner_text]);
38  }
39 
40  $container_entity = elgg_extract('byline_container_entity', $vars, $entity->getContainerEntity());
41  if ($container_entity instanceof ElggGroup && $container_entity->guid !== elgg_get_page_owner_guid()) {
42  if ($show_links) {
43  $group_text = elgg_view('output/url', [
44  'href' => $container_entity->getURL(),
45  'text' => $container_entity->getDisplayName(),
46  'is_trusted' => true,
47  ]);
48  } else {
49  $group_text = $container_entity->getDisplayName();
50  }
51 
52  $parts[] = elgg_echo('byline:ingroup', [$group_text]);
53  }
54 
55  $byline_str = implode(' ', $parts);
56 }
57 
59  return;
60 }
61 
62 echo elgg_view('object/elements/imprint/element', [
63  'content' => $byline_str,
64  'class' => 'elgg-listing-byline',
65 ]);
$entity
Displays information about the author and container of the post.
Definition: byline.php:14
$byline_str
Definition: byline.php:21
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:206
$owner
Definition: crop.php:7
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
elgg_get_page_owner_guid($guid=0)
Gets the guid of the entity that owns the current page.
Definition: pageowner.php:22
if(!$entity instanceof ElggEntity) $show_links
Definition: byline.php:19