Checks if the types of the passed arguments in a function/method call are compatible.
1 | <?php |
||
2 | /** |
||
3 | * River item footer |
||
4 | * |
||
5 | * @uses $vars['item'] ElggRiverItem |
||
6 | * @uses $vars['responses'] Alternate override for this item |
||
7 | */ |
||
8 | |||
9 | // allow river views to override the response content |
||
10 | $responses = elgg_extract('responses', $vars); |
||
11 | if (isset($responses)) { |
||
12 | echo $responses; |
||
13 | return; |
||
14 | } |
||
15 | |||
16 | $item = elgg_extract('item', $vars); |
||
17 | if (!$item instanceof ElggRiverItem) { |
||
18 | return; |
||
19 | } |
||
20 | |||
21 | $object = $item->getObjectEntity(); |
||
22 | |||
23 | // annotations and comments do not have responses |
||
24 | if (!empty($item->annotation_id) || !$object instanceof ElggEntity || $object instanceof ElggComment) { |
||
25 | return; |
||
26 | } |
||
27 | |||
28 | $comment_count = $object->countComments(); |
||
29 | |||
30 | if ($comment_count) { |
||
31 | $comments = elgg_get_entities([ |
||
32 | 'type' => 'object', |
||
33 | 'subtype' => 'comment', |
||
34 | 'container_guid' => $object->getGUID(), |
||
35 | 'limit' => 3, |
||
36 | 'order_by' => 'e.time_created desc', |
||
37 | 'distinct' => false, |
||
38 | ]); |
||
39 | |||
40 | // why is this reversing it? because we're asking for the 3 latest |
||
41 | // comments by sorting desc and limiting by 3, but we want to display |
||
42 | // these comments with the latest at the bottom. |
||
43 | $comments = array_reverse($comments); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
44 | |||
45 | echo elgg_view_entity_list($comments, [ |
||
46 | 'list_class' => 'elgg-river-comments', |
||
47 | 'show_excerpt' => true, |
||
48 | ]); |
||
49 | |||
50 | if ($comment_count > count($comments)) { |
||
51 | echo elgg_format_element('div', ['class' => 'elgg-river-more'], elgg_view('output/url', [ |
||
52 | 'href' => $object->getURL(), |
||
53 | 'text' => elgg_echo('river:comments:all', [$comment_count]), |
||
54 | 'is_trusted' => true, |
||
55 | ])); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | if (!$object->canComment()) { |
||
60 | return; |
||
61 | } |
||
62 | |||
63 | // inline comment form |
||
64 | $form_vars = ['id' => "comments-add-{$object->guid}-{$item->id}", 'class' => 'hidden']; |
||
65 | $body_vars = ['entity' => $object, 'inline' => true]; |
||
66 | echo elgg_view_form('comment/save', $form_vars, $body_vars); |
||
67 |