Elgg  Version 1.11
comment.php
Go to the documentation of this file.
1 <?php
9 $full_view = elgg_extract('full_view', $vars, true);
10 
11 $comment = $vars['entity'];
12 
13 $entity = get_entity($comment->container_guid);
14 $commenter = get_user($comment->owner_guid);
15 if (!$entity || !$commenter) {
16  return true;
17 }
18 
20 
22 $commenter_link = "<a href=\"{$commenter->getURL()}\">$commenter->name</a>";
23 
24 $entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
25 $entity_link = "<a href=\"{$entity->getURL()}\">$entity_title</a>";
26 
27 if ($full_view) {
28  $anchor = "<a name=\"comment-{$comment->getGUID()}\"></a>";
29 
30  $menu = elgg_view_menu('entity', array(
31  'entity' => $comment,
32  'handler' => 'comment',
33  'sort_by' => 'priority',
34  'class' => 'elgg-menu-hz float-alt',
35  ));
36 
37  if (elgg_in_context('activity')) {
38 
39  $comment_text = '<div class="elgg-output elgg-inner" data-role="comment-text">';
40  $comment_text .= elgg_view('output/text', array(
41  'value' => elgg_get_excerpt($comment->description),
42  ));
43  $comment_text .= '</div>';
44  } else {
45  $comment_text = elgg_view('output/longtext', array(
46  'value' => $comment->description,
47  'class' => 'elgg-inner',
48  'data-role' => 'comment-text',
49  ));
50  }
51  $body = <<<HTML
52 $anchor
53 <div class="mbn">
54  $menu
56  <span class="elgg-subtext">
58  </span>
60 </div>
61 HTML;
62 
64 
65 } else {
66  // brief view
67 
68  $excerpt = elgg_get_excerpt($comment->description, 80);
69  $posted = elgg_echo('generic_comment:on', array($commenter_link, $entity_link));
70 
71  $body = <<<HTML
72 <span class="elgg-subtext">
73  $posted ($friendlytime): $excerpt
74 </span>
75 HTML;
76 
78 }
$comment_text
Definition: save.php:11
$commenter_link
Definition: comment.php:22
$commenter_icon
Definition: comment.php:21
$full_view
Elgg comment view.
Definition: comment.php:9
$commenter
Definition: comment.php:14
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
fieldset div
Definition: admin.php:470
$entity
Definition: comment.php:13
elgg_view_menu($menu_name, array $vars=array())
Render a menu.
Definition: views.php:692
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_friendly_time($time)
Displays a UNIX timestamp in a friendly way.
Definition: views.php:1146
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
elgg_view_image_block($image, $body, $vars=array())
Wrapper function for the image block display pattern.
Definition: views.php:1196
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:250
elgg echo
Translates a string.
Definition: languages.js:43
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
ui datepicker td span
Definition: admin.php:634
$posted
Definition: comment.php:69
$entity_title
Definition: comment.php:24
$entity_link
Definition: comment.php:25
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:72
$body
Definition: comment.php:71
$menu
Definition: default.php:19
$comment
Definition: comment.php:11
elgg_view_entity_icon(\ElggEntity $entity, $size= 'medium', $vars=array())
View the icon of an entity.
Definition: views.php:865
if(!$entity||!$commenter) $friendlytime
Definition: comment.php:19
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:382
if(file_exists($welcome)) $vars
Definition: upgrade.php:93