Elgg
Version 4.3
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
\
Hook
$hook) {
23
$entity
= $hook->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 = $hook->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
= $hook->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\Menus\Social\registerComments
static registerComments(\Elgg\Hook $hook)
Adds comment menu items to social menu.
Definition:
Social.php:22
ElggEntity
elgg_echo
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition:
languages.php:18
Elgg\Menus\Social
Register menu items to the social menu.
Definition:
Social.php:13
$options
$options
Elgg admin footer.
Definition:
footer.php:6
ElggMenuItem\factory
static factory($options)
Create an ElggMenuItem from an associative array.
Definition:
ElggMenuItem.php:134
Elgg\Hook
Models an event passed to hook handlers.
Definition:
Hook.php:11
$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
Generated on Sat Feb 4 2023 00:00:23 for Elgg by
1.8.11