Elgg  Version 1.9
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 $object = $item->getObjectEntity();
18 $target = $item->getTargetEntity();
19 
20 // annotations and comments do not have responses
21 if ($item->annotation_id != 0 || !$object || elgg_instanceof($target, 'object', 'comment')) {
22  return true;
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  ));
35 
36  // why is this reversing it? because we're asking for the 3 latest
37  // comments by sorting desc and limiting by 3, but we want to display
38  // these comments with the latest at the bottom.
39  $comments = array_reverse($comments);
40 
41 ?>
42  <span class="elgg-river-comments-tab"><?php echo elgg_echo('comments'); ?></span>
43 
44 <?php
45 
46  echo elgg_view_entity_list($comments, array('list_class' => 'elgg-river-comments'));
47 
48  if ($comment_count > count($comments)) {
49  $num_more_comments = $comment_count - count($comments);
50  $url = $object->getURL();
51  $params = array(
52  'href' => $url,
53  'text' => elgg_echo('river:comments:more', array($num_more_comments)),
54  'is_trusted' => true,
55  );
56  $link = elgg_view('output/url', $params);
57  echo "<div class=\"elgg-river-more\">$link</div>";
58  }
59 }
60 
61 // inline comment form
62 $form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden');
63 $body_vars = array('entity' => $object, 'inline' => true);
64 echo elgg_view_form('comment/save', $form_vars, $body_vars);
if($comment_count) $form_vars
Definition: responses.php:62
$comments
elgg_view_entity_list($entities, $vars=array(), $offset=0, $limit=10, $full_view=true, $list_type_toggle=true, $pagination=true)
Returns a rendered list of entities with pagination.
Definition: views.php:969
if($item->annotation_id!=0||!$object||elgg_instanceof($target, 'object', 'comment')) $comment_count
Definition: responses.php:25
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:1464
$url
Definition: exceptions.php:24
$params
Definition: login.php:72
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an ElggEntity and optionally for type and subtype.
Definition: entities.php:1886
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:63
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:777
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
ui datepicker td span
Definition: admin.php:610
$object
Definition: responses.php:17
$target
Definition: responses.php:18
$responses
River item footer.
Definition: responses.php:10
elgg_view_form($action, $form_vars=array(), $body_vars=array())
Definition: views.php:1280
if(file_exists($welcome)) $vars
Definition: upgrade.php:93