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