Elgg  Version 3.0
comment.php
Go to the documentation of this file.
1 <?php
10 $full_view = elgg_extract('full_view', $vars, true);
11 
13 if (!$comment instanceof \ElggComment) {
14  return;
15 }
16 
17 $entity = get_entity($comment->container_guid);
18 $commenter = get_user($comment->owner_guid);
19 if (!$entity || !$commenter) {
20  return;
21 }
22 
23 if ($comment->canEdit()) {
24  elgg_require_js('elgg/comments');
25 }
26 
27 if ($full_view) {
28  if (elgg_extract('show_excerpt', $vars)) {
29  $body = elgg_view('output/longtext', [
30  'value' => elgg_get_excerpt($comment->description),
31  ]);
32  } else {
33  $body = elgg_view('output/longtext', [
34  'value' => $comment->description,
35  ]);
36  }
37 
38  $params = [
39  'icon_entity' => $commenter,
40  'time_href' => $comment->getURL(),
41  'access' => false,
42  'title' => false,
43  'content' => $body,
44  ];
45  $params = $params + $vars;
46  echo elgg_view('object/elements/summary', $params);
47 } else {
48  // brief view
49  $commenter_icon = elgg_view_entity_icon($commenter, 'small');
50 
52 
53  $commenter_link = elgg_view('output/url', [
54  'href' => $commenter->getURL(),
55  'text' => $commenter->getDisplayName(),
56  ]);
57 
58  $entity_link = elgg_view('output/url', [
59  'href' => $entity->getURL(),
60  'text' => $entity->getDisplayName() ?: elgg_echo('untitled'),
61  ]);
62 
63  $excerpt = elgg_get_excerpt($comment->description, 80);
64  $posted = elgg_echo('generic_comment:on', [$commenter_link, $entity_link]);
65 
67  'class' => 'elgg-subtext',
68  ], "$posted ($friendlytime): $excerpt");
69 
70  echo elgg_view_image_block($commenter_icon, $body);
71 }
$commenter_link
Definition: comment.php:53
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:40
$full_view
Elgg comment view.
Definition: comment.php:10
$commenter
Definition: comment.php:18
$excerpt
Definition: comment.php:63
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_entity_icon(\ElggEntity $entity, $size= 'medium', $vars=[])
View the icon of an entity.
Definition: views.php:899
elgg_view_image_block($image, $body, $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:1177
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:168
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
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
$posted
Definition: comment.php:64
getDisplayName()
{}
Definition: ElggObject.php:38
$entity_link
Definition: comment.php:58
$vars['type']
Definition: save.php:11
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:74
$body
Definition: comment.php:66
if(!$comment instanceof\ElggComment) $entity
Definition: comment.php:17
$comment
Definition: comment.php:12
$friendlytime
Definition: comment.php:51
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
elgg_view_friendly_time($time)
Displays a UNIX timestamp in a friendly way.
Definition: views.php:1120
getURL()
Gets the URL for this entity.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87