1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
archiveentry.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Zip\Nginx;
3
4
use \Bitrix\Main\Text\Encoding;
5
use \Bitrix\Main\Config\Option;
6
use \Bitrix\Landing\File;
7
use \Bitrix\Landing\Manager;
8
9
class
ArchiveEntry
10
{
15
protected
$name
;
16
21
protected
$path
;
22
27
protected
$fileId
;
28
33
protected
$size
;
34
38
protected
function
__construct
()
39
{
40
$this->fileId = 0;
41
}
42
48
public
static
function
createFromFilePath
($filePath)
49
{
50
$fileArray = \CFile::MakeFileArray($filePath);
51
52
if
($fileArray)
53
{
54
return
self::createFromFile
([
55
'ID'
=> 0,
56
'ORIGINAL_NAME'
=> $fileArray[
'name'
],
57
'FILE_SIZE'
=> $fileArray[
'size'
],
58
'SRC'
=> substr(
59
$fileArray[
'tmp_name'
],
60
strlen(
Manager::getDocRoot
())
61
),
62
]);
63
}
64
65
return
null
;
66
}
67
73
public
static
function
createFromFileId
(
$fileId
)
74
{
75
$fileArray =
File::getFileArray
(
$fileId
);
76
77
if
(
78
!$fileArray ||
79
empty($fileArray[
'SRC'
])
80
)
81
{
82
return
null
;
83
}
84
85
return
self::createFromFile
($fileArray);
86
}
87
93
protected
static
function
createFromFile
(
array
$fileArray)
94
{
95
$zipEntry =
new
static
;
96
$zipEntry->name = $fileArray[
'ORIGINAL_NAME'
];
97
$zipEntry->fileId = $fileArray[
'ID'
];
98
$zipEntry->size = $fileArray[
'FILE_SIZE'
];
99
100
$fromClouds =
false
;
101
$filename
= $fileArray[
'SRC'
];
102
103
if
(isset($fileArray[
'HANDLER_ID'
]) && !empty($fileArray[
'HANDLER_ID'
]))
104
{
105
$fromClouds =
true
;
106
}
107
108
unset($fileArray);
109
110
if
($fromClouds)
111
{
112
$filename
= preg_replace(
'~^(http[s]?)(\://)~i'
,
'\\1.'
,
$filename
);
113
$cloudUploadPath = Option::get(
114
'main'
,
115
'bx_cloud_upload'
,
116
'/upload/bx_cloud_upload/'
117
);
118
$zipEntry->path = $cloudUploadPath .
$filename
;
119
unset($cloudUploadPath);
120
}
121
else
122
{
123
$zipEntry->path =
self::encodeUrn
(
124
Encoding::convertEncoding(
$filename
,
LANG_CHARSET
,
'UTF-8'
)
125
);
126
}
127
unset(
$filename
);
128
129
return
$zipEntry;
130
}
131
137
protected
function
encodeUrn
(
$uri
)
138
{
139
$result
=
''
;
140
$parts = preg_split(
141
"#(://|:\\d+/|/|\\?|=|&)#"
,
$uri
, -1, PREG_SPLIT_DELIM_CAPTURE
142
);
143
144
foreach
($parts as
$i
=> $part)
145
{
146
$part =
Manager::getApplication
()->convertCharset(
147
$part,
148
LANG_CHARSET
,
149
'UTF-8'
150
);
151
$result
.= (
$i
% 2)
152
? $part
153
: rawurlencode($part);
154
}
155
unset($parts,
$i
, $part);
156
157
return
$result
;
158
}
159
164
public
function
__toString
()
165
{
166
$name
= Encoding::convertEncoding(
167
$this->name,
168
LANG_CHARSET
,
169
'UTF-8'
170
);
171
return
"- {$this->size} {$this->path} /upload/{$this->fileId}/{$name}"
;
172
}
173
}
Bitrix\Landing\File\getFileArray
static getFileArray($fileId)
Определения
file.php:580
Bitrix\Landing\Manager\getDocRoot
static getDocRoot()
Определения
manager.php:180
Bitrix\Landing\Manager\getApplication
static getApplication()
Определения
manager.php:71
Bitrix\Landing\Zip\Nginx\ArchiveEntry
Определения
archiveentry.php:10
Bitrix\Landing\Zip\Nginx\ArchiveEntry\__construct
__construct()
Определения
archiveentry.php:38
Bitrix\Landing\Zip\Nginx\ArchiveEntry\$path
$path
Определения
archiveentry.php:21
Bitrix\Landing\Zip\Nginx\ArchiveEntry\encodeUrn
encodeUrn($uri)
Определения
archiveentry.php:137
Bitrix\Landing\Zip\Nginx\ArchiveEntry\$fileId
$fileId
Определения
archiveentry.php:27
Bitrix\Landing\Zip\Nginx\ArchiveEntry\createFromFileId
static createFromFileId($fileId)
Определения
archiveentry.php:73
Bitrix\Landing\Zip\Nginx\ArchiveEntry\__toString
__toString()
Определения
archiveentry.php:164
Bitrix\Landing\Zip\Nginx\ArchiveEntry\$name
$name
Определения
archiveentry.php:15
Bitrix\Landing\Zip\Nginx\ArchiveEntry\createFromFile
static createFromFile(array $fileArray)
Определения
archiveentry.php:93
Bitrix\Landing\Zip\Nginx\ArchiveEntry\createFromFilePath
static createFromFilePath($filePath)
Определения
archiveentry.php:48
Bitrix\Landing\Zip\Nginx\ArchiveEntry\$size
$size
Определения
archiveentry.php:33
$filename
$filename
Определения
file_edit.php:47
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$uri
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения
urlrewrite.php:61
LANG_CHARSET
const LANG_CHARSET
Определения
include.php:65
$i
$i
Определения
factura.php:643
bitrix
modules
landing
lib
zip
nginx
archiveentry.php
Создано системой
1.14.0