Elgg  Version 1.11
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 true;
14 }
15 
16 $item = $vars['item'];
17 /* @var ElggRiverItem $item */
18 $object = $item->getObjectEntity();
19 $target = $item->getTargetEntity();
20 
21 // annotations and comments do not have responses
22 if ($item->annotation_id != 0 || !$object || elgg_instanceof($target, 'object', 'comment')) {
23  return true;
24 }
25 
26 $comment_count = $object->countComments();
27 
28 if ($comment_count) {
30  'type' => 'object',
31  'subtype' => 'comment',
32  'container_guid' => $object->getGUID(),
33  'limit' => 3,
34  'order_by' => 'e.time_created desc',
35  'distinct' => false,
36  ));
37 
38  // why is this reversing it? because we're asking for the 3 latest
39  // comments by sorting desc and limiting by 3, but we want to display
40  // these comments with the latest at the bottom.
41  $comments = array_reverse($comments);
42 
43  echo elgg_view_entity_list($comments, array('list_class' => 'elgg-river-comments'));
44 
45  if ($comment_count > count($comments)) {
46  $url = $object->getURL();
47  $params = array(
48  'href' => $url,
49  'text' => elgg_echo('river:comments:all', array($comment_count)),
50  'is_trusted' => true,
51  );
52  $link = elgg_view('output/url', $params);
53  echo "<div class=\"elgg-river-more\">$link</div>";
54  }
55 }
56 
57 // inline comment form
58 $form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden');
59 $body_vars = array('entity' => $object, 'inline' => true);
60 echo elgg_view_form('comment/save', $form_vars, $body_vars);
if($comment_count) $form_vars
Definition: responses.php:58
$comments
if($item->annotation_id!=0||!$object||elgg_instanceof($target, 'object', 'comment')) $comment_count
Definition: responses.php:26
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
$url
Definition: exceptions.php:24
$params
Definition: login.php:72
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:922
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:59
elgg echo
Translates a string.
Definition: languages.js:43
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:490
if($responses) $item
Definition: responses.php:16
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$object
Definition: responses.php:18
$target
Definition: responses.php:19
$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:984
elgg_view_form($action, $form_vars=array(), $body_vars=array())
Definition: views.php:1313
if(file_exists($welcome)) $vars
Definition: upgrade.php:93