Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
vk.php
1
<?php
2
3
namespace
Bitrix\Main\UrlPreview\Parser
;
4
5
use
Bitrix\Main\UrlPreview\HtmlDocument
;
6
use
Bitrix\Main\Web\Uri
;
7
use
Bitrix\Main\UrlPreview\UrlPreview
;
8
9
class
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
{
39
$width =
UrlPreview::IFRAME_MAX_WIDTH
;
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
{
47
$height =
UrlPreview::IFRAME_MAX_HEIGHT
;
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
}
Bitrix\Main\UrlPreview\HtmlDocument
Definition
htmldocument.php:13
Bitrix\Main\UrlPreview\HtmlDocument\getUri
getUri()
Definition
htmldocument.php:61
Bitrix\Main\UrlPreview\HtmlDocument\getExtraField
getExtraField($fieldName)
Definition
htmldocument.php:246
Bitrix\Main\UrlPreview\HtmlDocument\setExtraField
setExtraField($fieldName, $fieldValue)
Definition
htmldocument.php:209
Bitrix\Main\UrlPreview\HtmlDocument\setEmbed
setEmbed($embed)
Definition
htmldocument.php:192
Bitrix\Main\UrlPreview\Parser\OpenGraph
Definition
opengraph.php:9
Bitrix\Main\UrlPreview\Parser\Vk
Definition
vk.php:10
Bitrix\Main\UrlPreview\Parser\Vk\handle
handle(HtmlDocument $document)
Definition
vk.php:11
Bitrix\Main\UrlPreview\UrlPreview
Definition
urlpreview.php:18
Bitrix\Main\UrlPreview\UrlPreview\IFRAME_MAX_HEIGHT
const IFRAME_MAX_HEIGHT
Definition
urlpreview.php:29
Bitrix\Main\UrlPreview\UrlPreview\IFRAME_MAX_WIDTH
const IFRAME_MAX_WIDTH
Definition
urlpreview.php:28
Bitrix\Main\Web\Uri
Definition
uri.php:17
Bitrix\Main\UrlPreview\Parser
Definition
applemaps.php:2
modules
main
lib
urlpreview
parser
vk.php
Создано системой
1.10.0