Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
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
/* @var $return MenuItems */
33
$return = $event->getValue();
34
35
$comment_count
=
$entity
->countComments();
36
$can_comment =
$entity
->canComment();
37
if
($can_comment ||
$comment_count
) {
38
$text
= $can_comment ?
elgg_echo
(
'comment:this'
) :
elgg_echo
(
'comments'
);
39
40
$options
= [
41
'name'
=>
'comment'
,
42
'icon'
=>
'comment'
,
43
'badge'
=>
$comment_count
?: null,
44
'text'
=>
$text
,
45
'title'
=>
$text
,
46
'href'
=>
$entity
->getURL() .
'#comments'
,
47
];
48
49
$item
= $event->getParam(
'item'
);
50
if
(
$item
instanceof \
ElggRiverItem
&& $can_comment) {
51
$options
[
'href'
] =
"#comments-add-{$entity->guid}-{$item->id}"
;
52
$options
[
'class'
] =
'elgg-toggle'
;
53
}
54
55
$return[] =
\ElggMenuItem::factory
(
$options
);
56
}
57
58
return
$return;
59
}
60
}
$item
if(!$items) $item
Definition:
delete.php:13
ElggComment
Definition:
ElggComment.php:11
elgg_echo
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition:
languages.php:17
ElggEntity
ElggMenuItem\factory
static factory(array $options)
Create an ElggMenuItem from an associative array.
Definition:
ElggMenuItem.php:130
Elgg\Menus\Social
Register menu items to the social menu.
Definition:
Social.php:13
$options
$options
Elgg admin footer.
Definition:
footer.php:6
$comment_count
if(!empty($item->annotation_id)||!$object instanceof ElggEntity||$object instanceof ElggComment) if(!$object->hasCapability('commentable')) $comment_count
Definition:
responses.php:34
MenuItems
Elgg
Definition:
ActionsService.php:3
$entity
$entity
Definition:
reset.php:8
Elgg\Menus
Definition:
AdminControlPanel.php:3
$text
$text
Definition:
button.php:32
ElggRiverItem
Definition:
ElggRiverItem.php:18
Elgg\Menus\Social\registerComments
static registerComments(\Elgg\Event $event)
Adds comment menu items to social menu.
Definition:
Social.php:22
Elgg\Event
Models an event passed to event handlers.
Definition:
Event.php:11
Generated on Wed Mar 29 2023 00:01:39 for Elgg by
1.8.11