Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
vk.php
1<?php
2
4
8
9class Vk extends OpenGraph
10{
11 public function handle(HtmlDocument $document)
12 {
13 $uri = $document->getUri();
14 if(mb_strpos($uri->getPath(), '/video') !== 0)
15 {
16 return;
17 }
18
19 parent::handle($document);
20
21 if(!empty($document->getExtraField('VIDEO')))
22 {
23 $ogVideo = $document->getExtraField('VIDEO');
24 $uri = new Uri($ogVideo);
25 $query = $uri->getQuery();
26 if(!empty($query))
27 {
28 parse_str($query, $params);
29 if(isset($params['oid']) && isset($params['id']) && isset($params['hash']))
30 {
31 $embedUri = new Uri('https://vk.com/video_ext.php');
32 $embedUri->addParams(array('oid' => $params['oid'], 'id' => $params['id'], 'hash' => $params['hash']));
33 if($document->getExtraField('VIDEO_WIDTH') && $document->getExtraField('VIDEO_WIDTH') < UrlPreview::IFRAME_MAX_WIDTH)
34 {
35 $width = $document->getExtraField('VIDEO_WIDTH');
36 }
37 else
38 {
40 }
41 if($document->getExtraField('VIDEO_HEIGHT') && $document->getExtraField('VIDEO_HEIGHT') < UrlPreview::IFRAME_MAX_HEIGHT)
42 {
43 $height = $document->getExtraField('VIDEO_HEIGHT');
44 }
45 else
46 {
48 }
49 $iframe = '<iframe src="'.$embedUri->getLocator().'" allowfullscreen="" width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>';
50 $document->setEmbed($iframe);
51 $document->setExtraField('PROVIDER_NAME', 'VK');
52 }
53 }
54 }
55 }
56}
setExtraField($fieldName, $fieldValue)
handle(HtmlDocument $document)
Definition vk.php:11