Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
photogalleryalbum.php
1<?php
2
4
10
11Loc::loadMessages(__FILE__);
12
13final 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 {
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 {
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}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())