Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
urlmetadata.php
1
<?php
2
3
namespace
Bitrix\Main\UrlPreview
;
4
5
use
Bitrix\Main
;
6
use
Bitrix\Main\Entity
;
7
use
Bitrix\Main\Text\Emoji
;
8
use
Bitrix\Main\ORM\Event
;
9
26
class
UrlMetadataTable
extends
Entity\DataManager
27
{
28
const
TYPE_STATIC
=
'S'
;
29
const
TYPE_DYNAMIC
=
'D'
;
30
const
TYPE_TEMPORARY
=
'T'
;
31
const
TYPE_FILE
=
'F'
;
32
38
public
static
function
getTableName
()
39
{
40
return
'b_urlpreview_metadata'
;
41
}
42
48
public
static
function
getMap
()
49
{
50
return
array(
51
'ID'
=>
new
Entity
\
IntegerField
(
'ID'
, array(
52
'primary'
=>
true
,
53
'autocomplete'
=>
true
,
54
)),
55
'URL'
=>
new
Entity
\
StringField
(
'URL'
, array(
56
'required'
=>
true
,
57
)),
58
'TYPE'
=>
new
Entity
\
StringField
(
'TYPE'
, array(
59
'required'
=>
true
,
60
)),
61
'TITLE'
=>
new
Entity
\
StringField
(
'TITLE'
, [
62
'save_data_modification'
=> [Emoji::class,
'getSaveModificator'
],
63
'fetch_data_modification'
=> [Emoji::class,
'getFetchModificator'
],
64
]),
65
'DESCRIPTION'
=>
new
Entity
\
TextField
(
'DESCRIPTION'
, [
66
'save_data_modification'
=> [Emoji::class,
'getSaveModificator'
],
67
'fetch_data_modification'
=> [Emoji::class,
'getFetchModificator'
],
68
]),
69
'IMAGE_ID'
=>
new
Entity
\
IntegerField
(
'IMAGE_ID'
),
70
'IMAGE'
=>
new
Entity
\
StringField
(
'IMAGE'
),
71
'EMBED'
=>
new
Entity
\
TextField
(
'EMBED'
, [
72
'save_data_modification'
=> [Emoji::class,
'getSaveModificator'
],
73
'fetch_data_modification'
=> [Emoji::class,
'getFetchModificator'
],
74
]),
75
'EXTRA'
=>
new
Entity
\
TextField
(
'EXTRA'
, array(
76
'serialized'
=>
true
,
77
)),
78
'DATE_INSERT'
=>
new
Entity
\
DatetimeField
(
'DATE_INSERT'
, array(
79
'default_value'
=>
new
Main\
Type
\
DateTime
(),
80
)),
81
'DATE_EXPIRE'
=>
new
Entity
\
DatetimeField
(
'DATE_EXPIRE'
)
82
);
83
}
84
92
public
static
function
getByUrl
($url)
93
{
94
$parameters = [
95
'select'
=> [
'*'
],
96
'filter'
=> [
97
'=URL'
=> $url,
98
],
99
'order'
=> [
100
'ID'
=>
'desc'
101
],
102
'limit'
=> 1
103
];
104
105
return
static::getList($parameters)->fetch();
106
}
107
108
public
static
function
onUpdate
(
Event
$event)
109
{
110
$parameters = $event->
getParameters
();
111
112
if
(!empty($parameters[
'fields'
]))
113
{
114
if
(array_key_exists(
'IMAGE_ID'
, $parameters[
'fields'
]))
115
{
116
$currentValues = static::getList([
117
'select'
=> [
'IMAGE_ID'
],
118
'filter'
=> [
'=ID'
=> $parameters[
'id'
]],
119
])->fetch();
120
121
if
($currentValues[
'IMAGE_ID'
] > 0 && $currentValues[
'IMAGE_ID'
] != $parameters[
'fields'
][
'IMAGE_ID'
])
122
{
123
\CFile::Delete($currentValues[
'IMAGE_ID'
]);
124
}
125
}
126
}
127
}
128
129
public
static
function
onDelete
(
Event
$event)
130
{
131
$parameters = $event->
getParameters
();
132
133
$currentValues = static::getList([
134
'select'
=> [
'IMAGE_ID'
],
135
'filter'
=> [
'=ID'
=> $parameters[
'id'
]],
136
])->fetch();
137
138
if
($currentValues[
'IMAGE_ID'
] > 0)
139
{
140
\CFile::Delete($currentValues[
'IMAGE_ID'
]);
141
}
142
}
143
}
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Event\getParameters
getParameters()
Definition
event.php:66
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\TextField
Definition
textfield.php:20
Bitrix\Main\Text\Emoji
Definition
emoji.php:10
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\UrlPreview\UrlMetadataTable
Definition
urlmetadata.php:27
Bitrix\Main\UrlPreview\UrlMetadataTable\getMap
static getMap()
Definition
urlmetadata.php:48
Bitrix\Main\UrlPreview\UrlMetadataTable\onDelete
static onDelete(Event $event)
Definition
urlmetadata.php:129
Bitrix\Main\UrlPreview\UrlMetadataTable\TYPE_TEMPORARY
const TYPE_TEMPORARY
Definition
urlmetadata.php:30
Bitrix\Main\UrlPreview\UrlMetadataTable\TYPE_STATIC
const TYPE_STATIC
Definition
urlmetadata.php:28
Bitrix\Main\UrlPreview\UrlMetadataTable\TYPE_FILE
const TYPE_FILE
Definition
urlmetadata.php:31
Bitrix\Main\UrlPreview\UrlMetadataTable\TYPE_DYNAMIC
const TYPE_DYNAMIC
Definition
urlmetadata.php:29
Bitrix\Main\UrlPreview\UrlMetadataTable\onUpdate
static onUpdate(Event $event)
Definition
urlmetadata.php:108
Bitrix\Main\UrlPreview\UrlMetadataTable\getTableName
static getTableName()
Definition
urlmetadata.php:38
Bitrix\Main\UrlPreview\UrlMetadataTable\getByUrl
static getByUrl($url)
Definition
urlmetadata.php:92
Bitrix\Main\Type
Definition
collection.php:2
Bitrix\Main\UrlPreview
Definition
htmldocument.php:3
Bitrix\Main
modules
main
lib
urlpreview
urlmetadata.php
Создано системой
1.10.0