1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Класс UrlPreview

Открытые статические члены

static getMetadataByUrl ($url, $addIfNew=true, $reuseExistingMetadata=true)
static showView ($userField, $userFieldParams, &$cacheTag, $edit=false)
static showEdit ($userField, $userFieldParams)
static isUrlCached ($url)
static getMetadataAndHtmlByUrl ($url, $addIfNew=true, $reuseExistingMetadata=true)
static getMetadataAndHtmlByIds (array $ids, $checkAccess=true, $userId=0)
static getMetadataByIds (array $ids)
static reserveIdForUrl ($url)
static resolveTemporaryMetadata ($id, $checkAccess=true, $userId=0)
static getDynamicPreview ($url, $checkAccess=true, $userId=0)
static getImAttach ($url, $checkAccess=true, $userId=0)
static getImRich ($url, $checkAccess=true, $userId=0)
static checkDynamicPreviewAccess ($url, $userId=0)
static setMetadataImage ($id, $imageUrl)
static isEnabled ()
static sign ($id)
static getCurrentUserId ()
static isIpAddressPrivate ($ipAddress)
static isHostTrusted (Uri $uri)
static fetchVideoMetaData ($url)
static getInnerFrameUrl ($id, $provider='')

Поля данных

const SIGN_SALT = 'url_preview'
const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 (Bitrix link preview)'
const MAX_DESCRIPTION = 500
const MAX_FILE_SIZE = 1048576
const FILE_RANGE = 1023
const IFRAME_MAX_WIDTH = 640
const IFRAME_MAX_HEIGHT = 340

Защищенные статические члены

static refreshMetadata (array &$metadata)
static getUrlInfoFromExternal ($url, $method, $checkAccess=true, $userId=0)
static fetchUrlMetadata ($url)
static isUrlLocal (Uri $uri)
static getRemoteUrlMetadata (Uri $uri)
static getTempPath (string $fileName)
static downloadFile (string $url, ?string &$fileName=null, ?int $range=null)
static saveImage (string $tempPath, ?string $fileName)
static fetchImageMetadata (string $imageUrl, array &$metadata)
static normalizeUrl ($url)
static getOptionSaveImages ()
static validateRemoteMetadata (array $metadata)
static unfoldShortLink ($shortUrl)
static getFileMetadata (HttpClient $client)

Статические защищенные данные

static $trustedHosts

Подробное описание

См. определение в файле urlpreview.php строка 17

Методы

◆ checkDynamicPreviewAccess()

checkDynamicPreviewAccess ( $url,
$userId = 0 )
static

Returns true if current user has read access to the content behind internal url.

Аргументы
string$urlURL of the internal document. @params int $userId. ID of the users to check access. If userId == 0, will check access for current user.
Возвращает
bool True if current user has read access to the main entity of the document, or false otherwise.

См. определение в файле urlpreview.php строка 501

◆ downloadFile()

downloadFile ( string $url,
?string & $fileName = null,
?int $range = null )
staticprotected

См. определение в файле urlpreview.php строка 774

◆ fetchImageMetadata()

fetchImageMetadata ( string $imageUrl,
array & $metadata )
staticprotected

См. определение в файле urlpreview.php строка 844

◆ fetchUrlMetadata()

fetchUrlMetadata ( $url)
staticprotected
Аргументы
string$urlURL of the document.
Возвращает
array|false Fetched metadata or false if metadata was not found, or was invalid.

См. определение в файле urlpreview.php строка 626

◆ fetchVideoMetaData()

fetchVideoMetaData ( $url)
static

Returns video metaData for $url if its host is trusted.

Аргументы
string$url
Возвращает
array|false

См. определение в файле urlpreview.php строка 1040

◆ getCurrentUserId()

getCurrentUserId ( )
static

Returns id of currently logged user.

Возвращает
int User's id.

См. определение в файле urlpreview.php строка 934

◆ getDynamicPreview()

getDynamicPreview ( $url,
$checkAccess = true,
$userId = 0 )
static

Returns HTML code for the dynamic (internal url) preview.

Аргументы
string$urlURL of the internal document.
bool$checkAccessShould method check current user's access to the entity, or not. @params int $userId. ID of the users to check access. If userId == 0, will check access for current user.
Возвращает
string|false HTML code of the preview, or false if case of any errors (including access denied)/

См. определение в файле urlpreview.php строка 441

◆ getFileMetadata()

getFileMetadata ( HttpClient $client)
staticprotected

Returns metadata for downloadable file.

Аргументы
HttpClient$client
Возвращает
array|bool Metadata record if mime type and filename were detected, or false otherwise.

См. определение в файле urlpreview.php строка 966

◆ getImAttach()

getImAttach ( $url,
$checkAccess = true,
$userId = 0 )
static

Returns attach for the IM message with the requested internal entity content.

Аргументы
string$urlURL of the internal document.
bool$checkAccessShould method check current user's access to the entity, or not. @params int $userId. ID of the users to check access. If userId == 0, will check access for current user.
Возвращает
\CIMMessageParamAttach | false

См. определение в файле urlpreview.php строка 479

◆ getImRich()

getImRich ( $url,
$checkAccess = true,
$userId = 0 )
static
Аргументы
$url
bool$checkAccess
int$userId
Возвращает
\Bitrix\Im\V2\Entity\Url\RichData | false

См. определение в файле urlpreview.php строка 490

◆ getInnerFrameUrl()

getInnerFrameUrl ( $id,
$provider = '' )
static

Returns inner frame url to embed third parties html video players.

Аргументы
int$id
string$provider
Возвращает
bool|string

См. определение в файле urlpreview.php строка 1088

◆ getMetadataAndHtmlByIds()

getMetadataAndHtmlByIds ( array $ids,
$checkAccess = true,
$userId = 0 )
static

Returns stored metadata for array of IDs

Аргументы
array$idsArray of record's IDs.
bool$checkAccessShould method check current user's access to the internal entities, or not. @params int $userId. ID of the users to check access. If == 0, will check access for current user.
Возвращает
array|false Array with provided IDs as the keys.

См. определение в файле urlpreview.php строка 265

◆ getMetadataAndHtmlByUrl()

getMetadataAndHtmlByUrl ( $url,
$addIfNew = true,
$reuseExistingMetadata = true )
static

If url is remote - returns metadata for this url. If url is local - checks current user access to the entity behind the url, and returns html preview for this entity.

Аргументы
string$urlDocument's URL.
bool$addIfNewShould method fetch and store metadata for the document, if it is not found in database. @params bool $reuseExistingMetadata Allow reading of the cached metadata.
Возвращает
array|false Metadata for the document, or false if metadata could not be fetched/parsed.

См. определение в файле urlpreview.php строка 232

◆ getMetadataByIds()

getMetadataByIds ( array $ids)
static

См. определение в файле urlpreview.php строка 308

◆ getMetadataByUrl()

getMetadataByUrl ( $url,
$addIfNew = true,
$reuseExistingMetadata = true )
static

Returns associated metadata for the specified URL

Аргументы
string$urlURL.
bool$addIfNewShould metadata be fetched and saved, if not found in database.
bool$reuseExistingMetadataAllow reading of the cached metadata.
Возвращает
array|false Metadata for the URL if found, or false otherwise.

См. определение в файле urlpreview.php строка 55

◆ getOptionSaveImages()

getOptionSaveImages ( )
staticprotected

Returns value of the option for saving images locally.

Возвращает
bool True if images should be saved locally.

См. определение в файле urlpreview.php строка 909

◆ getRemoteUrlMetadata()

getRemoteUrlMetadata ( Uri $uri)
staticprotected
Аргументы
Uri$uriAbsolute URL to get metadata for.
Возвращает
array|false

См. определение в файле urlpreview.php строка 687

◆ getTempPath()

getTempPath ( string $fileName)
staticprotected

См. определение в файле urlpreview.php строка 766

◆ getUrlInfoFromExternal()

getUrlInfoFromExternal ( $url,
$method,
$checkAccess = true,
$userId = 0 )
staticprotected

См. определение в файле urlpreview.php строка 591

◆ isEnabled()

isEnabled ( )
static

Checks if UrlPreview is enabled in module option

Возвращает
bool True if UrlPreview is enabled in module options.

См. определение в файле urlpreview.php строка 569

◆ isHostTrusted()

isHostTrusted ( Uri $uri)
static

Returns true if host of $uri is in $trustedHosts list.

Аргументы
Uri$uri
Возвращает
bool

См. определение в файле urlpreview.php строка 1022

◆ isIpAddressPrivate()

isIpAddressPrivate ( $ipAddress)
static
Аргументы
string$ipAddress
Возвращает
bool

См. определение в файле urlpreview.php строка 1011

◆ isUrlCached()

isUrlCached ( $url)
static

Checks if metadata for the provided url is already fetched and cached.

Аргументы
string$urlDocument's URL.
Возвращает
bool True if metadata for the url is located in database, false otherwise.

См. определение в файле urlpreview.php строка 212

◆ isUrlLocal()

isUrlLocal ( Uri $uri)
staticprotected

Returns true if given URL is local

Аргументы
Uri$uriAbsolute URL to be checked.
Возвращает
bool

См. определение в файле urlpreview.php строка 672

◆ normalizeUrl()

normalizeUrl ( $url)
staticprotected

If provided url does not contain scheme part, tries to add it

Аргументы
string$urlURL to be fixed.
Возвращает
string Fixed URL.

См. определение в файле urlpreview.php строка 880

◆ refreshMetadata()

refreshMetadata ( array & $metadata)
staticprotected

См. определение в файле urlpreview.php строка 412

◆ reserveIdForUrl()

reserveIdForUrl ( $url)
static

Creates temporary record for url

Аргументы
string$urlURL for which temporary record should be created.
Возвращает
int Temporary record's id.

См. определение в файле urlpreview.php строка 349

◆ resolveTemporaryMetadata()

resolveTemporaryMetadata ( $id,
$checkAccess = true,
$userId = 0 )
static

Fetches and stores metadata for temporary record, created by UrlPreview::reserveIdForUrl. If metadata could not be fetched, deletes record.

Аргументы
int$idMetadata record's id.
bool$checkAccessShould method check current user's access to the entity, or not. @params int $userId. ID of the users to check access. If == 0, will check access for current user.
Возвращает
array|false Metadata if fetched, false otherwise.

См. определение в файле urlpreview.php строка 375

◆ saveImage()

saveImage ( string $tempPath,
?string $fileName )
staticprotected
Аргументы
string$tempPath
string | null$fileName
Возвращает
integer Saved file identifier

См. определение в файле urlpreview.php строка 821

◆ setMetadataImage()

setMetadataImage ( $id,
$imageUrl )
static

Sets main image url for the metadata with given id.

Аргументы
int$idID of the metadata to set image url.
string$imageUrlUrl of the image.
Возвращает
bool Returns true in case of successful update, or false otherwise.
Исключения
ArgumentException

См. определение в файле urlpreview.php строка 531

◆ showEdit()

showEdit ( $userField,
$userFieldParams )
static

Returns html code for url preview edit form

Аргументы
array$userFieldUserfield's value.
array$userFieldParamsUserfield's parameters.
Возвращает
string HTML code for the preview.

См. определение в файле urlpreview.php строка 201

◆ showView()

showView ( $userField,
$userFieldParams,
& $cacheTag,
$edit = false )
static

Returns html code for url preview

Аргументы
array$userFieldUserfield's value.
array$userFieldParamsUserfield's parameters.
string$cacheTagCache tag for returned preview (out param).
bool$editShow method build preview for editing the userfield.
Возвращает
string HTML code for the preview.

См. определение в файле urlpreview.php строка 117

◆ sign()

sign ( $id)
static

Signs value using UrlPreview salt

Аргументы
string$idUnsigned value.
Возвращает
string Signed value.
Исключения

Bitrix\Main\ArgumentTypeException

См. определение в файле urlpreview.php строка 585

◆ unfoldShortLink()

unfoldShortLink ( $shortUrl)
staticprotected

Unfolds internal short url. If url is not classified as a short link, returns input $url.

Аргументы
string$shortUrlShort URL.
Возвращает
string Full URL.

См. определение в файле urlpreview.php строка 944

◆ validateRemoteMetadata()

validateRemoteMetadata ( array $metadata)
staticprotected

Checks if metadata is complete.

Аргументы
array$metadataHTML document metadata.
Возвращает
bool True if metadata is complete, false otherwise.

См. определение в файле urlpreview.php строка 924

Поля

◆ $trustedHosts

$trustedHosts
staticprotected
Инициализатор
= [
'youtube.com' => 'youtube.com',
'youtu.be' => 'youtu.be',
'youtube-nocookie.com' => 'youtube-nocookie.com',
'www.youtube-nocookie.com' => 'www.youtube-nocookie.com',
'vimeo.com' => 'vimeo.com',
'player.vimeo.com' => 'player.vimeo.com',
'rutube.ru' => 'rutube.ru',
'www.rutube.ru' => 'www.rutube.ru',
'facebook.com' => 'facebook.com',
'fb.watch' => 'fb.watch',
'vk.com' => 'vk.com',
'vk.ru' => 'vk.ru',
'instagram.com' => 'instagram.com',
]

См. определение в файле urlpreview.php строка 31

◆ FILE_RANGE

const FILE_RANGE = 1023

См. определение в файле urlpreview.php строка 26

◆ IFRAME_MAX_HEIGHT

const IFRAME_MAX_HEIGHT = 340

См. определение в файле urlpreview.php строка 29

◆ IFRAME_MAX_WIDTH

const IFRAME_MAX_WIDTH = 640

См. определение в файле urlpreview.php строка 28

◆ MAX_DESCRIPTION

const MAX_DESCRIPTION = 500

См. определение в файле urlpreview.php строка 22

◆ MAX_FILE_SIZE

const MAX_FILE_SIZE = 1048576

См. определение в файле urlpreview.php строка 24

◆ SIGN_SALT

const SIGN_SALT = 'url_preview'

См. определение в файле urlpreview.php строка 19

◆ USER_AGENT

const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 (Bitrix link preview)'

См. определение в файле urlpreview.php строка 20


Объявления и описания членов класса находятся в файле: