Elgg
Version 7.1
engine
classes
Elgg
Menus
Social.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Menus
;
4
5
use
Elgg\Menu\MenuItems
;
6
13
class
Social
{
14
22
public
static
function
registerComments
(\
Elgg
\
Event
$event) {
23
$entity
= $event->getEntityParam();
24
if
(!
$entity
instanceof \
ElggEntity
||
$entity
instanceof \
ElggComment
) {
25
return
;
26
}
27
28
if
(!
$entity
->hasCapability(
'commentable'
)) {
29
return
;
30
}
31
32
if
(
$entity
->isDeleted()) {
33
return
;
34
}
35
36
/* @var $return MenuItems */
37
$return = $event->getValue();
38
39
$comment_count
=
$entity
->countComments();
40
$can_comment =
$entity
->canComment();
41
if
($can_comment ||
$comment_count
) {
42
$text
= $can_comment ?
elgg_echo
(
'comment:this'
) :
elgg_echo
(
'comments'
);
43
44
$options
= [
45
'name'
=>
'comment'
,
46
'icon'
=>
'comment'
,
47
'badge'
=>
$comment_count
?:
null
,
48
'text'
=>
$text
,
49
'title'
=>
$text
,
50
'href'
=>
$entity
->getURL() .
'#comments'
,
51
];
52
53
$item
= $event->getParam(
'item'
);
54
if
(
$item
instanceof \
ElggRiverItem
&& $can_comment) {
55
$options
[
'href'
] =
"#comments-add-{$entity->guid}-{$item->id}"
;
56
$options
[
'class'
] =
'elgg-toggle'
;
57
}
58
59
$return[] =
\ElggMenuItem::factory
(
$options
);
60
}
61
62
return
$return;
63
}
64
}
$entity
$entity
Definition:
reset.php:8
$comment_count
$comment_count
Definition:
save.php:78
$item
if(! $items) $item
Definition:
delete.php:13
$text
$text
Definition:
button.php:26
ElggComment
Definition:
ElggComment.php:11
ElggEntity
Definition:
ElggEntity.php:52
ElggMenuItem\factory
static factory(array $options)
Create an ElggMenuItem from an associative array.
Definition:
ElggMenuItem.php:130
ElggRiverItem
Definition:
ElggRiverItem.php:18
Elgg\Event
Models an event passed to event handlers.
Definition:
Event.php:11
Elgg\Menu\MenuItems
A collection of menu items.
Definition:
MenuItems.php:10
Elgg\Menus\Social
Register menu items to the social menu.
Definition:
Social.php:13
Elgg\Menus\Social\registerComments
static registerComments(\Elgg\Event $event)
Adds comment menu items to social menu.
Definition:
Social.php:22
$options
if(count($css_vars)< 2) $options
Definition:
color_scheme.php:22
elgg_echo
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition:
languages.php:17
Elgg\Menus
Definition:
AdminControlPanel.php:3
Elgg
Definition:
ActionsService.php:3
Generated on Wed Sep 23 2026 00:00:19 for Elgg by
1.9.1