Elgg  Version master
comment.php
Go to the documentation of this file.
1 <?php
9 $full_view = elgg_extract('full_view', $vars, true);
10 
12 if (!$comment instanceof \ElggComment) {
13  return;
14 }
15 
16 $entity = $comment->getContainerEntity();
17 $commenter = $comment->getOwnerEntity();
18 if (!$entity instanceof \ElggEntity || !$commenter instanceof \ElggEntity) {
19  return;
20 }
21 
22 if ($comment->canEdit()) {
23  elgg_import_esm('elgg/comments');
24 }
25 
27  'icon_entity' => $commenter,
28  'time_href' => $comment->getURL(),
29  'access' => false,
30  'title' => false,
31  'tag_name' => 'article',
32  'imprint' => elgg_extract('imprint', $vars, []),
33  'class' => elgg_extract_class($vars),
34 ];
36 
37 if ($comment->isCreatedByContentOwner()) {
38  $params['class'][] = 'elgg-comment-by-owner';
39 
40  $params['imprint'][] = [
41  'icon_name' => 'user-edit',
42  'content' => elgg_echo('generic_comment:by_owner'),
43  ];
44 }
45 
46 if ($full_view) {
47  $params['show_summary'] = true;
48 
49  $body = elgg_view('output/longtext', [
50  'value' => $comment->description,
51  ]);
52 
53  if (elgg_extract('show_add_form', $vars, true) && $comment->canComment()) {
54  $body .= elgg_view('output/url', [
55  'text' => elgg_echo('generic_comments:add'),
56  'href' => "#elgg-form-comment-save-{$comment->guid}",
57  'data-load-comment' => $comment->guid,
58  'class' => ['elgg-subtext', 'elgg-toggle-comment'],
59  ]);
60  }
61 
62  $params['content'] = $body;
63 
64  if (!empty(elgg()->thread_preloader->getChildren($comment->guid))) {
65  $params['class'][] = 'with-children';
66  }
67 
68  echo elgg_view('object/elements/full', $params);
69 } else {
70  $params['content'] = elgg_get_excerpt((string) $comment->description);
71 
72  echo elgg_view('object/elements/summary', $params);
73 }
elgg
Definition: install.js:27
elgg_get_excerpt(string $text, int $num_chars=250)
Returns an excerpt.
Definition: output.php:83
$full_view
Elgg comment view.
Definition: comment.php:9
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$commenter
Definition: comment.php:17
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_import_esm(string $name)
Helper functions for external files like css/js.
$body
Definition: useradd.php:55
if(!$entity instanceof\ElggEntity||!$commenter instanceof\ElggEntity) if($comment->canEdit()) $params
Definition: comment.php:26
$vars
Definition: theme.php:5
if(!$comment instanceof\ElggComment) $entity
Definition: comment.php:16
elgg_extract_class(array $array, array|string $existing=[], string $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:277
$comment
Definition: comment.php:11