Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
background.php
1<?php
2namespace Bitrix\Im\Call;
3
6
8{
9 private static $path = '/bitrix/js/im/images/background';
10
11 public static function get()
12 {
13 return array_merge(
14 self::getImageFiles(),
15 self::getVideoFiles(),
16 self::getIntranetFiles()
17 );
18 }
19
20 private static function getImageFiles()
21 {
22 $result = [
23 [
24 'id' => 'apartment',
25 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_APARTMENT'),
26 ],
27 [
28 'id' => 'night-office',
29 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_NIGHT_OFFICE'),
30 ],
31 [
32 'id' => 'basement',
33 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_BASEMENT'),
34 ],
35 [
36 'id' => 'tent',
37 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_TENT'),
38 ],
39 [
40 'id' => 'summer-park',
41 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_SUMMER_PARK'),
42 ],
43 [
44 'id' => 'winter-forest',
45 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_WINTER_FOREST'),
46 ],
47 [
48 'id' => 'botanical-garden',
49 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_BOTANICAL_GARDEN'),
50 ],
51 [
52 'id' => 'stadium',
53 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_STADIUM'),
54 ],
55 [
56 'id' => 'safari',
57 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_SAFARI'),
58 ],
59 [
60 'id' => 'subway',
61 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_SUBWAY'),
62 ],
63 [
64 'id' => 'escalator',
65 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_ESCALATOR'),
66 ],
67 [
68 'id' => 'space-station',
69 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_SPACE_STATION'),
70 ],
71 [
72 'id' => 'moon',
73 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_MOON'),
74 ],
75 [
76 'id' => 'fireworks',
77 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_HOLIDAY'),
78 ],
79 [
80 'id' => 'hyperspace',
81 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_HYPERSPACE'),
82 ],
83 [
84 'id' => 'attractions',
85 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_ATTRACTIONS'),
86 ],
87 [
88 'id' => 'street',
89 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_STREET'),
90 ],
91 [
92 'id' => 'cathedral',
93 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_CATHEDRAL'),
94 ],
95 [
96 'id' => 'abandoned-building',
97 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_ABANDONED_BUILDING'),
98 ],
99 [
100 'id' => 'business-quarter',
101 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_BUSINESS_QUARTER'),
102 ],
103 [
104 'id' => 'under-water',
105 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_UNDER_WATER'),
106 ],
107 [
108 'id' => 'autumn-wall',
109 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_AUTUMN_WALL'),
110 ],
111 [
112 'id' => 'wooden-wall',
113 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_WOODEN_WALL'),
114 ],
115 [
116 'id' => 'bright-wall',
117 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_BRIGHT_WALL'),
118 ],
119 [
120 'id' => 'neon-space',
121 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_NEON_SPACE'),
122 ],
123 [
124 'id' => 'skeletons',
125 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_SKELETONS'),
126 ],
127 [
128 'id' => 'halloween',
129 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_HALLOWEEN'),
130 ],
131 [
132 'id' => 'christmas-tree',
133 'title' => Loc::getMessage('IM_CALL_BG_IMAGE_CHRISTMAS_TREE'),
134 ],
135 ];
136
137 foreach ($result as &$value)
138 {
139 $value['preview'] = static::$path."/{$value['id']}-preview.jpg";
140 $value['background'] = static::$path."/{$value['id']}.jpg";
141 $value['isVideo'] = false;
142 $value['isSupported'] = true;
143 }
144
145 return $result;
146 }
147
148 private static function getVideoFiles()
149 {
150 $result = [
151 [
152 'id' => 'star-sky',
153 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_STAR_SKY'),
154 ],
155 [
156 'id' => 'waves',
157 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_WAVES'),
158 ],
159 [
160 'id' => 'jellyfishes',
161 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_JELLYFISHES'),
162 ],
163 [
164 'id' => 'sunset',
165 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_SUNSET'),
166 ],
167 [
168 'id' => 'rain',
169 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_RAIN'),
170 ],
171 [
172 'id' => 'rain-drops',
173 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_RAIN_DROPS'),
174 ],
175 [
176 'id' => 'grass',
177 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_GRASS'),
178 ],
179 [
180 'id' => 'stones',
181 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_STONES'),
182 ],
183 [
184 'id' => 'waterfall',
185 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_WATERFALL'),
186 ],
187 [
188 'id' => 'shining',
189 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_SHINING'),
190 ],
191 [
192 'id' => 'beach',
193 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_BEACH'),
194 ],
195 [
196 'id' => 'river',
197 'title' => Loc::getMessage('IM_CALL_BG_VIDEO_RIVER'),
198 ],
199 ];
200
201 foreach ($result as &$value)
202 {
203 $value['preview'] = "/bitrix/js/im/images/background/video/{$value['id']}-preview.jpg";
204 $value['background'] = "/bitrix/js/im/images/background/video/{$value['id']}.mp4";
205 $value['isVideo'] = true;
206 $value['isSupported'] = true;
207 $value['id'] .= ':video';
208 }
209
210 return $result;
211 }
212
213 private static function getIntranetFiles()
214 {
215 $result = [];
216
217 if (!\Bitrix\Main\Loader::includeModule('intranet'))
218 {
219 return $result;
220 }
221
222 $themePicker = new \Bitrix\Intranet\Integration\Templates\Bitrix24\ThemePicker('bitrix24');
223 $list = $themePicker->getList();
224
225 foreach ($list as $element)
226 {
227 if (mb_strpos($element['id'], 'pattern') !== false)
228 {
229 continue;
230 }
231
232 if (mb_strpos($element['id'], 'video') !== false)
233 {
234 continue;
235 }
236
237 if (!$element['prefetchImages'][0])
238 {
239 continue;
240 }
241
242 $result[] = [
243 'id' => $element['id'],
244 'title' => $element['title'],
245 'preview' => $element['previewImage'],
246 'background' => $element['prefetchImages'][0],
247 'isVideo' => false,
248 'isSupported' => true
249 ];
250 }
251
252 return $result;
253 }
254
255 public static function getCustom()
256 {
257 $result = [];
258
259 if (!\CIMDisk::Enabled())
260 {
261 return $result;
262 }
263
264 $folderModel = self::getUploadFolder();
265 if (!$folderModel)
266 {
267 return $result;
268 }
269
270 $securityContext = new \Bitrix\Disk\Security\DiskSecurityContext(Common::getUserId());
271
272 $parameters = [
273 'filter' => [
274 'PARENT_ID' => $folderModel->getId(),
275 'STORAGE_ID' => $folderModel->getStorageId()
276 ],
277 'order' => ['UPDATE_TIME' => 'DESC']
278 ];
279 $parameters = \Bitrix\Disk\Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ID', 'CREATED_BY'));
280
281 $fileCollection = \Bitrix\Disk\File::getModelList($parameters);
282
283 foreach ($fileCollection as $fileModel)
284 {
285 if ($fileModel->getTypeFile() == \Bitrix\Disk\TypeFile::IMAGE)
286 {
287 $supported = in_array(mb_strtolower($fileModel->getExtension()), ['png', 'jpg', 'jpeg'], true);
288 }
289 else if ($fileModel->getTypeFile() == \Bitrix\Disk\TypeFile::VIDEO)
290 {
291 $supported = in_array(mb_strtolower($fileModel->getExtension()), ['mp4', 'mov', 'avi'], true);
292 }
293 else
294 {
295 $supported = false;
296 }
297
298 $result[] = [
299 'id' => (int)$fileModel->getId(),
300 'title' => $fileModel->getName(),
301 'preview' => $supported? \CIMDisk::GetPublicPath(\CIMDisk::PATH_TYPE_PREVIEW, $fileModel, false): '',
302 'background' => $supported? \CIMDisk::GetPublicPath(\CIMDisk::PATH_TYPE_SHOW, $fileModel, false): '',
303 'isVideo' => $fileModel->getTypeFile() == \Bitrix\Disk\TypeFile::VIDEO,
304 'isSupported' => $supported,
305 ];
306 }
307
308 return $result;
309 }
310
311 public static function getUploadFolder($userId = null)
312 {
313 $folderModel = \CIMDisk::GetBackgroundFolderModel($userId);
314 if (!$folderModel)
315 {
316 return null;
317 }
318
319 return $folderModel;
320 }
321
322 public static function getLimitForJs()
323 {
324 $result = [];
325
326 $image = \Bitrix\Im\Limit::getTypeCallBackground();
327 $result[] = [
328 'id' => $image['ID'],
329 'active' => $image['ACTIVE'],
330 'articleCode' => $image['ARTICLE_CODE'],
331 ];
332
333 $blur = \Bitrix\Im\Limit::getTypeCallBlurBackground();
334 $result[] = [
335 'id' => $blur['ID'],
336 'active' => $blur['ACTIVE'],
337 'articleCode' => $blur['ARTICLE_CODE'],
338 ];
339
340 return $result;
341 }
342}
343
static getUploadFolder($userId=null)
static getUserId($userId=null)
Definition common.php:74
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29