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