1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
FileInfo.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\UI\FileUploader;
4
5
use Bitrix\Main\Type\Dictionary;
6
7
class
FileInfo
extends
FileData
implements \JsonSerializable
8
{
9
protected
$id
;
10
protected
int
$fileId
= 0;
11
protected
bool
$treatImageAsFile
=
false
;
12
protected
?
string
$downloadUrl
=
null
;
13
protected
?
string
$previewUrl
=
null
;
14
protected
int
$previewWidth
= 0;
15
protected
int
$previewHeight
= 0;
16
protected
?
Dictionary
$customData
=
null
;
17
protected
?
Dictionary
$viewerAttrs
=
null
;
18
25
public
function
__construct
(
$id
,
string
$name
,
string
$contentType
,
int
$size
)
26
{
27
parent::__construct(
$name
,
$contentType
,
$size
);
28
$this->
id
=
$id
;
29
}
30
31
public
static
function
createFromBFile
(
int
$id
): ?
FileInfo
32
{
33
$file = \CFile::getFileArray(
$id
);
34
if
(!is_array($file))
35
{
36
return
null
;
37
}
38
39
$fileName
= !empty($file[
'ORIGINAL_NAME'
]) ? $file[
'ORIGINAL_NAME'
] : $file[
'FILE_NAME'
];
40
$fileInfo =
new
static
(
$id
,
$fileName
, $file[
'CONTENT_TYPE'
], (int)$file[
'FILE_SIZE'
]);
41
$fileInfo->setWidth($file[
'WIDTH'
]);
42
$fileInfo->setHeight($file[
'HEIGHT'
]);
43
$fileInfo->setFileId(
$id
);
44
45
return
$fileInfo;
46
}
47
48
public
static
function
createFromTempFile
(
string
$tempFileId): ?
FileInfo
49
{
50
[$guid, $signature] = explode(
'.'
, $tempFileId);
51
52
$tempFile =
TempFileTable::getList
([
53
'filter'
=> [
54
'=GUID'
=> $guid,
55
'=UPLOADED'
=>
true
,
56
],
57
])->fetchObject();
58
59
if
(!$tempFile)
60
{
61
return
null
;
62
}
63
64
$fileInfo =
new
static
($tempFileId, $tempFile->getFilename(), $tempFile->getMimetype(), $tempFile->getSize());
65
$fileInfo->setWidth($tempFile->getWidth());
66
$fileInfo->setHeight($tempFile->getHeight());
67
$fileInfo->setFileId($tempFile->getFileId());
68
69
return
$fileInfo;
70
}
71
75
public
function
getId
()
76
{
77
return
$this->id
;
78
}
79
80
public
function
setId
(
$id
): void
81
{
82
if
(is_int(
$id
) || is_string(
$id
))
83
{
84
$this->
id
=
$id
;
85
}
86
}
87
88
public
function
getFileId
(): int
89
{
90
return
$this->fileId
;
91
}
92
93
public
function
setFileId
(
int
$fileId
): void
94
{
95
$this->fileId =
$fileId
;
96
}
97
98
public
function
shouldTreatImageAsFile
(): bool
99
{
100
return
$this->treatImageAsFile
;
101
}
102
103
public
function
setTreatImageAsFile
(
bool
$flag): void
104
{
105
$this->treatImageAsFile = $flag;
106
}
107
108
public
function
getDownloadUrl
(): ?string
109
{
110
return
$this->downloadUrl
;
111
}
112
113
public
function
setDownloadUrl
(
string
$downloadUrl
): void
114
{
115
$this->downloadUrl =
$downloadUrl
;
116
}
117
118
public
function
getPreviewUrl
(): ?string
119
{
120
return
$this->previewUrl
;
121
}
122
123
public
function
setPreviewUrl
(
string
$previewUrl
,
int
$previewWidth
,
int
$previewHeight
): void
124
{
125
$this->previewUrl =
$previewUrl
;
126
$this->previewWidth =
$previewWidth
;
127
$this->previewHeight =
$previewHeight
;
128
}
129
130
public
function
getPreviewWidth
(): int
131
{
132
return
$this->previewWidth
;
133
}
134
135
public
function
getPreviewHeight
(): int
136
{
137
return
$this->previewHeight
;
138
}
139
140
public
function
setCustomData
(
array
$customData
): self
141
{
142
$this->
getCustomData
()->setValues($customData);
143
144
return
$this;
145
}
146
150
public
function
getCustomData
():
Dictionary
151
{
152
if
($this->customData ===
null
)
153
{
154
$this->customData =
new
Dictionary
();
155
}
156
157
return
$this->customData
;
158
}
159
160
public
function
setViewerAttrs
(
array
$viewerAttrs
): self
161
{
162
$this->
getViewerAttrs
()->setValues($viewerAttrs);
163
164
return
$this;
165
}
166
167
public
function
getViewerAttrs
():
Dictionary
168
{
169
if
($this->viewerAttrs ===
null
)
170
{
171
$this->viewerAttrs =
new
Dictionary
();
172
}
173
174
return
$this->viewerAttrs
;
175
}
176
177
public
function
jsonSerialize
():
array
178
{
179
return
[
180
'serverFileId'
=> $this->
getId
(),
181
'serverId'
=> $this->
getId
(),
// compatibility
182
'type'
=> $this->
getContentType
(),
183
'name'
=> $this->
getName
(),
184
'size'
=> $this->
getSize
(),
185
'width'
=> $this->
getWidth
(),
186
'height'
=> $this->
getHeight
(),
187
'isImage'
=> $this->
isImage
(),
188
'isVideo'
=> $this->
isVideo
(),
189
'treatImageAsFile'
=> $this->
isImage
() && $this->
shouldTreatImageAsFile
(),
190
'downloadUrl'
=> $this->
getDownloadUrl
(),
191
'serverPreviewUrl'
=> $this->
getPreviewUrl
(),
192
'serverPreviewWidth'
=> $this->
getPreviewWidth
(),
193
'serverPreviewHeight'
=> $this->
getPreviewHeight
(),
194
'customData'
=> $this->customData !==
null
? $this->
getCustomData
()->getValues() : [],
195
'viewerAttrs'
=> $this->viewerAttrs !==
null
? $this->
getViewerAttrs
()->getValues() : [],
196
];
197
}
198
}
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\Type\Dictionary
Определения
dictionary.php:6
Bitrix\UI\FileUploader\FileData
Определения
FileData.php:6
Bitrix\UI\FileUploader\FileData\$contentType
string $contentType
Определения
FileData.php:8
Bitrix\UI\FileUploader\FileData\isImage
isImage()
Определения
FileData.php:66
Bitrix\UI\FileUploader\FileData\getName
getName()
Определения
FileData.php:20
Bitrix\UI\FileUploader\FileData\$size
int $size
Определения
FileData.php:9
Bitrix\UI\FileUploader\FileData\$name
string $name
Определения
FileData.php:7
Bitrix\UI\FileUploader\FileData\getSize
getSize()
Определения
FileData.php:35
Bitrix\UI\FileUploader\FileData\isVideo
isVideo()
Определения
FileData.php:71
Bitrix\UI\FileUploader\FileData\getHeight
getHeight()
Определения
FileData.php:53
Bitrix\UI\FileUploader\FileData\getContentType
getContentType()
Определения
FileData.php:30
Bitrix\UI\FileUploader\FileData\getWidth
getWidth()
Определения
FileData.php:40
Bitrix\UI\FileUploader\FileInfo
Определения
FileInfo.php:8
Bitrix\UI\FileUploader\FileInfo\$previewWidth
int $previewWidth
Определения
FileInfo.php:14
Bitrix\UI\FileUploader\FileInfo\$customData
Dictionary $customData
Определения
FileInfo.php:16
Bitrix\UI\FileUploader\FileInfo\setDownloadUrl
setDownloadUrl(string $downloadUrl)
Определения
FileInfo.php:113
Bitrix\UI\FileUploader\FileInfo\getId
getId()
Определения
FileInfo.php:75
Bitrix\UI\FileUploader\FileInfo\getDownloadUrl
getDownloadUrl()
Определения
FileInfo.php:108
Bitrix\UI\FileUploader\FileInfo\getViewerAttrs
getViewerAttrs()
Определения
FileInfo.php:167
Bitrix\UI\FileUploader\FileInfo\getPreviewWidth
getPreviewWidth()
Определения
FileInfo.php:130
Bitrix\UI\FileUploader\FileInfo\__construct
__construct($id, string $name, string $contentType, int $size)
Определения
FileInfo.php:25
Bitrix\UI\FileUploader\FileInfo\createFromTempFile
static createFromTempFile(string $tempFileId)
Определения
FileInfo.php:48
Bitrix\UI\FileUploader\FileInfo\createFromBFile
static createFromBFile(int $id)
Определения
FileInfo.php:31
Bitrix\UI\FileUploader\FileInfo\setViewerAttrs
setViewerAttrs(array $viewerAttrs)
Определения
FileInfo.php:160
Bitrix\UI\FileUploader\FileInfo\$downloadUrl
string $downloadUrl
Определения
FileInfo.php:12
Bitrix\UI\FileUploader\FileInfo\shouldTreatImageAsFile
shouldTreatImageAsFile()
Определения
FileInfo.php:98
Bitrix\UI\FileUploader\FileInfo\setTreatImageAsFile
setTreatImageAsFile(bool $flag)
Определения
FileInfo.php:103
Bitrix\UI\FileUploader\FileInfo\setId
setId($id)
Определения
FileInfo.php:80
Bitrix\UI\FileUploader\FileInfo\getPreviewHeight
getPreviewHeight()
Определения
FileInfo.php:135
Bitrix\UI\FileUploader\FileInfo\$previewUrl
string $previewUrl
Определения
FileInfo.php:13
Bitrix\UI\FileUploader\FileInfo\$viewerAttrs
Dictionary $viewerAttrs
Определения
FileInfo.php:17
Bitrix\UI\FileUploader\FileInfo\$treatImageAsFile
bool $treatImageAsFile
Определения
FileInfo.php:11
Bitrix\UI\FileUploader\FileInfo\$fileId
int $fileId
Определения
FileInfo.php:10
Bitrix\UI\FileUploader\FileInfo\$previewHeight
int $previewHeight
Определения
FileInfo.php:15
Bitrix\UI\FileUploader\FileInfo\setCustomData
setCustomData(array $customData)
Определения
FileInfo.php:140
Bitrix\UI\FileUploader\FileInfo\setFileId
setFileId(int $fileId)
Определения
FileInfo.php:93
Bitrix\UI\FileUploader\FileInfo\getPreviewUrl
getPreviewUrl()
Определения
FileInfo.php:118
Bitrix\UI\FileUploader\FileInfo\jsonSerialize
jsonSerialize()
Определения
FileInfo.php:177
Bitrix\UI\FileUploader\FileInfo\getCustomData
getCustomData()
Определения
FileInfo.php:150
Bitrix\UI\FileUploader\FileInfo\setPreviewUrl
setPreviewUrl(string $previewUrl, int $previewWidth, int $previewHeight)
Определения
FileInfo.php:123
Bitrix\UI\FileUploader\FileInfo\$id
$id
Определения
FileInfo.php:9
Bitrix\UI\FileUploader\FileInfo\getFileId
getFileId()
Определения
FileInfo.php:88
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$fileName
$fileName
Определения
quickway.php:305
bitrix
modules
ui
lib
FileUploader
FileInfo.php
Создано системой
1.14.0