Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
photogalleryalbum.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Livefeed
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Iblock\SectionTable
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Socialnetwork\LogTable
;
10
11
Loc::loadMessages
(__FILE__);
12
13
final
class
PhotogalleryAlbum
extends
Provider
14
{
15
public
const
PROVIDER_ID
=
'PHOTO_ALBUM'
;
16
public
const
CONTENT_TYPE_ID
=
'PHOTO_ALBUM'
;
17
18
public
static
function
getId
(): string
19
{
20
return
static::PROVIDER_ID;
21
}
22
23
public
function
getEventId
(): array
24
{
25
return
[
'photo'
];
26
}
27
28
public
function
getType
(): string
29
{
30
return
Provider::TYPE_POST
;
31
}
32
33
public
function
getCommentProvider
():
Provider
34
{
35
return
new
LogComment
();
36
}
37
38
public
function
initSourceFields
()
39
{
40
static
$cache = [];
41
42
$sectionId =
$this->entityId
;
43
44
if
($sectionId <= 0)
45
{
46
return
;
47
}
48
49
$albumFields = [];
50
51
if
(isset($cache[$sectionId]))
52
{
53
$albumFields = $cache[$sectionId];
54
}
55
elseif (Loader::includeModule(
'iblock'
))
56
{
57
$res = SectionTable::getList([
58
'filter'
=> [
59
'=ID'
=> $sectionId
60
],
61
'select'
=> [
'ID'
,
'NAME'
]
62
]);
63
if
($sectionFields = $res->fetch())
64
{
65
$logId
=
false
;
66
67
$res =
LogTable::getList
([
68
'filter'
=> [
69
'SOURCE_ID'
=> $sectionId,
70
'@EVENT_ID'
=> $this->
getEventId
(),
71
],
72
'select'
=> [
'ID'
,
'URL'
]
73
]);
74
if
($logEntryFields = $res->fetch())
75
{
76
$logId
= (int)$logEntryFields[
'ID'
];
77
}
78
79
if
(
$logId
)
80
{
81
$res = \CSocNetLog::getList(
82
[],
83
[
84
'=ID'
=>
$logId
85
],
86
false
,
87
false
,
88
[
'ID'
,
'EVENT_ID'
,
'URL'
],
89
[
90
"CHECK_RIGHTS"
=>
"Y"
,
91
"USE_FOLLOW"
=>
"N"
,
92
"USE_SUBSCRIBE"
=>
"N"
93
]
94
);
95
if
($logFields = $res->fetch())
96
{
97
$albumFields = array_merge($sectionFields, [
98
'LOG_ID'
=> $logFields[
'ID'
],
99
'LOG_EVENT_ID'
=> $logFields[
'EVENT_ID'
],
100
'URL'
=> $logFields[
'URL'
]
101
]);
102
}
103
}
104
}
105
106
$cache[$sectionId] = $albumFields;
107
}
108
109
if
(empty($albumFields))
110
{
111
return
;
112
}
113
114
$this->
setLogId
($albumFields[
'LOG_ID'
]);
115
$this->
setSourceFields
($albumFields);
116
117
$title = $albumFields[
'NAME'
];
118
$this->
setSourceDescription
($title);
119
$this->
setSourceTitle
($title);
120
}
121
122
public
function
getPinnedTitle
(): string
123
{
124
$result =
''
;
125
126
if
(empty($this->sourceFields))
127
{
128
$this->
initSourceFields
();
129
}
130
131
$albumFields = $this->
getSourceFields
();
132
if
(empty($albumFields))
133
{
134
return
$result;
135
}
136
137
return
(
string
)
Loc::getMessage
(
'SONET_LIVEFEED_PHOTOGALLERY_ALBUM_PINNED_TITLE'
, [
138
'#TITLE#'
=> $albumFields[
'NAME'
]
139
]);
140
}
141
142
public
function
getPinnedDescription
(): string
143
{
144
return
''
;
145
}
146
147
public
static
function
canRead
($params): bool
148
{
149
return
true
;
150
}
151
152
protected
function
getPermissions
(array $post): string
153
{
154
return
self::PERMISSION_READ
;
155
}
156
157
public
function
getLiveFeedUrl
()
158
{
159
$pathToPhoto =
''
;
160
161
if
(
162
($message = $this->
getSourceFields
())
163
&& !empty($message)
164
)
165
{
166
$pathToPhoto = str_replace(
167
"#GROUPS_PATH#"
,
168
Option::get(
'socialnetwork'
,
'workgroups_page'
,
'/workgroups/'
, $this->
getSiteId
()),
169
$message[
'URL'
]
170
);
171
}
172
173
return
$pathToPhoto;
174
}
175
176
}
Bitrix\Iblock\SectionTable
Definition
sectiontable.php:61
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Socialnetwork\Livefeed\LogComment
Definition
logcomment.php:9
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum
Definition
photogalleryalbum.php:14
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\initSourceFields
initSourceFields()
Definition
photogalleryalbum.php:38
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getCommentProvider
getCommentProvider()
Definition
photogalleryalbum.php:33
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\CONTENT_TYPE_ID
const CONTENT_TYPE_ID
Definition
photogalleryalbum.php:16
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getPinnedTitle
getPinnedTitle()
Definition
photogalleryalbum.php:122
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getPermissions
getPermissions(array $post)
Definition
photogalleryalbum.php:152
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getType
getType()
Definition
photogalleryalbum.php:28
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getLiveFeedUrl
getLiveFeedUrl()
Definition
photogalleryalbum.php:157
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getEventId
getEventId()
Definition
photogalleryalbum.php:23
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\canRead
static canRead($params)
Definition
photogalleryalbum.php:147
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getId
static getId()
Definition
photogalleryalbum.php:18
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\PROVIDER_ID
const PROVIDER_ID
Definition
photogalleryalbum.php:15
Bitrix\Socialnetwork\Livefeed\PhotogalleryAlbum\getPinnedDescription
getPinnedDescription()
Definition
photogalleryalbum.php:142
Bitrix\Socialnetwork\Livefeed\Provider
Definition
provider.php:22
Bitrix\Socialnetwork\Livefeed\Provider\setLogId
setLogId($logId)
Definition
provider.php:612
Bitrix\Socialnetwork\Livefeed\Provider\$logId
$logId
Definition
provider.php:54
Bitrix\Socialnetwork\Livefeed\Provider\setSourceFields
setSourceFields(array $fields)
Definition
provider.php:627
Bitrix\Socialnetwork\Livefeed\Provider\setSourceTitle
setSourceTitle($title)
Definition
provider.php:665
Bitrix\Socialnetwork\Livefeed\Provider\getSiteId
getSiteId()
Definition
provider.php:94
Bitrix\Socialnetwork\Livefeed\Provider\PERMISSION_READ
const PERMISSION_READ
Definition
provider.php:47
Bitrix\Socialnetwork\Livefeed\Provider\getSourceFields
getSourceFields()
Definition
provider.php:637
Bitrix\Socialnetwork\Livefeed\Provider\TYPE_POST
const TYPE_POST
Definition
provider.php:25
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDescription
setSourceDescription($description)
Definition
provider.php:642
Bitrix\Socialnetwork\Livefeed\Provider\$entityId
$entityId
Definition
provider.php:52
Bitrix\Socialnetwork\LogTable
Definition
log.php:36
Bitrix\Socialnetwork\Livefeed
Definition
bitrix24newuser.php:3
modules
socialnetwork
lib
livefeed
photogalleryalbum.php
Создано системой
1.10.0