Elgg  Version 1.12
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  echo elgg_view_entity_list($comments, array('list_class' => 'elgg-river-comments'));
43 
44  if ($comment_count > count($comments)) {
45  $url = $object->getURL();
46  $params = array(
47  'href' => $url,
48  'text' => elgg_echo('river:comments:all', array($comment_count)),
49  'is_trusted' => true,
50  );
51  $link = elgg_view('output/url', $params);
52  echo "<div class=\"elgg-river-more\">$link</div>";
53  }
54 }
55 
56 // inline comment form
57 $form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden');
58 $body_vars = array('entity' => $object, 'inline' => true);
59 echo elgg_view_form('comment/save', $form_vars, $body_vars);
if($comment_count) $form_vars
Definition: responses.php:57
$comments
$url
Definition: exceptions.php:24
$params
Definition: login.php:72
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$body_vars
Definition: responses.php:58
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:494
if($responses) $item
Definition: responses.php:16
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:340
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:1271
$object
Definition: responses.php:18
if($item->annotation_id!=0||!$object||$object instanceof ElggComment) $comment_count
Definition: responses.php:25
$responses
River item footer.
Definition: responses.php:10
elgg_view_entity_list($entities, $vars=array(), $offset=0, $limit=null, $full_view=true, $list_type_toggle=true, $pagination=true)
Returns a rendered list of entities with pagination.
Definition: views.php:970
elgg_view_form($action, $form_vars=array(), $body_vars=array())
Definition: views.php:1298
if(file_exists($welcome)) $vars
Definition: upgrade.php:93