Elgg  Version 2.3
responses.php
Go to the documentation of this file.
1 <?php
9 // allow river views to override the response content
10 $responses = elgg_extract('responses', $vars, false);
11 if ($responses) {
13  return;
14 }
15 
16 $item = $vars['item'];
17 /* @var ElggRiverItem $item */
18 $object = $item->getObjectEntity();
19 
20 // annotations and comments do not have responses
21 if ($item->annotation_id != 0 || !$object || $object instanceof ElggComment) {
22  return;
23 }
24 
25 $comment_count = $object->countComments();
26 
27 if ($comment_count) {
29  'type' => 'object',
30  'subtype' => 'comment',
31  'container_guid' => $object->getGUID(),
32  'limit' => 3,
33  'order_by' => 'e.time_created desc',
34  'distinct' => false,
35  ));
36 
37  // why is this reversing it? because we're asking for the 3 latest
38  // comments by sorting desc and limiting by 3, but we want to display
39  // these comments with the latest at the bottom.
40  $comments = array_reverse($comments);
41 
42  // make sure the comments know that this is viewed from the activity/river
43  elgg_push_context('activity');
44 
45  echo elgg_view_entity_list($comments, array('list_class' => 'elgg-river-comments'));
46 
47  // restore context
49 
50  if ($comment_count > count($comments)) {
51  $url = $object->getURL();
52  $params = array(
53  'href' => $url,
54  'text' => elgg_echo('river:comments:all', array($comment_count)),
55  'is_trusted' => true,
56  );
57  $link = elgg_view('output/url', $params);
58  echo "<div class=\"elgg-river-more\">$link</div>";
59  }
60 }
61 
62 if (!$object->canComment()) {
63  return;
64 }
65 
66 // inline comment form
67 $form_vars = array('id' => "comments-add-{$object->guid}-{$item->id}", 'class' => 'hidden');
68 $body_vars = array('entity' => $object, 'inline' => true);
69 echo elgg_view_form('comment/save', $form_vars, $body_vars);
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_form($action, $form_vars=array(), $body_vars=array())
Definition: views.php:1345
$comments
$link
Definition: container.php:14
$url
Definition: exceptions.php:24
$vars['entity']
$params
Definition: login.php:72
if($comment_count) if(!$object->canComment()) $form_vars
Definition: responses.php:67
$body_vars
Definition: responses.php:68
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:225
elgg echo
Translates a string.
Definition: languages.js:48
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:326
if($responses) $item
Definition: responses.php:16
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
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:1375
$object
Definition: responses.php:18
elgg_view_entity_list($entities, array $vars=array())
Returns a rendered list of entities with pagination.
Definition: views.php:1048
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:215
if($item->annotation_id!=0||!$object||$object instanceof ElggComment) $comment_count
Definition: responses.php:25
$responses
River item footer.
Definition: responses.php:10