Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
file.php
1
<?php
2
3
namespace
Bitrix\Main\Engine\Response
;
4
5
6
use
Bitrix\Main
;
7
8
class
File
extends
Main\HttpResponse
9
{
10
protected
$path
;
14
protected
$name
;
18
protected
$contentType
;
19
protected
$showInline
=
false
;
20
protected
$cacheTime
= 0;
21
22
public
function
__construct
($path, $name =
null
, $contentType =
'application/octet-stream'
)
23
{
24
parent::__construct();
25
26
$this->
setPath
(
$path
);
27
$this->
setContentType
(
$contentType
);
28
29
if
(
$name
===
null
)
30
{
31
$name
= bx_basename(
$path
);
32
}
33
34
$this->
setName
(
$name
);
35
}
36
40
public
function
getPath
()
41
{
42
return
$this->path;
43
}
44
50
public
function
setPath
($path)
51
{
52
$this->path =
$path
;
53
54
return
$this;
55
}
56
60
public
function
getName
()
61
{
62
return
$this->name;
63
}
64
70
public
function
setName
($name)
71
{
72
$this->name =
$name
;
73
74
return
$this;
75
}
76
80
public
function
getContentType
()
81
{
82
return
$this->contentType;
83
}
84
90
public
function
setContentType
($contentType)
91
{
92
$this->contentType =
$contentType
;
93
94
return
$this;
95
}
96
100
public
function
isShowInline
()
101
{
102
return
$this->showInline;
103
}
104
110
public
function
showInline
($enabled)
111
{
112
$this->
showInline
= (bool)$enabled;
113
114
return
$this;
115
}
116
120
public
function
getCacheTime
()
121
{
122
return
$this->cacheTime;
123
}
124
130
public
function
setCacheTime
($cacheTime)
131
{
132
$this->cacheTime = (int)
$cacheTime
;
133
134
return
$this;
135
}
136
137
protected
function
prepareOptions
()
138
{
139
return
[
140
'force_download'
=> !$this->
isShowInline
(),
141
'cache_time'
=> $this->
getCacheTime
(),
142
'attachment_name'
=> $this->
getName
(),
143
'content_type'
=> $this->
getContentType
(),
144
'fast_download'
=>
false
,
145
];
146
}
147
148
protected
function
prepareFile
()
149
{
150
$path
= new \Bitrix\Main\IO\File($this->
getPath
());
151
152
return \CFile::makeFileArray(
$path
->getPhysicalPath());
153
}
154
155
public
function
send
()
156
{
157
\CFile::viewByUser($this->
prepareFile
(), $this->
prepareOptions
());
158
}
159
}
Bitrix\Main\Engine\Response\File
Definition
file.php:9
Bitrix\Main\Engine\Response\File\$path
$path
Definition
file.php:10
Bitrix\Main\Engine\Response\File\showInline
showInline($enabled)
Definition
file.php:110
Bitrix\Main\Engine\Response\File\$showInline
$showInline
Definition
file.php:19
Bitrix\Main\Engine\Response\File\send
send()
Definition
file.php:155
Bitrix\Main\Engine\Response\File\$cacheTime
$cacheTime
Definition
file.php:20
Bitrix\Main\Engine\Response\File\prepareFile
prepareFile()
Definition
file.php:148
Bitrix\Main\Engine\Response\File\setName
setName($name)
Definition
file.php:70
Bitrix\Main\Engine\Response\File\getPath
getPath()
Definition
file.php:40
Bitrix\Main\Engine\Response\File\getName
getName()
Definition
file.php:60
Bitrix\Main\Engine\Response\File\__construct
__construct($path, $name=null, $contentType='application/octet-stream')
Definition
file.php:22
Bitrix\Main\Engine\Response\File\setPath
setPath($path)
Definition
file.php:50
Bitrix\Main\Engine\Response\File\prepareOptions
prepareOptions()
Definition
file.php:137
Bitrix\Main\Engine\Response\File\setContentType
setContentType($contentType)
Definition
file.php:90
Bitrix\Main\Engine\Response\File\setCacheTime
setCacheTime($cacheTime)
Definition
file.php:130
Bitrix\Main\Engine\Response\File\isShowInline
isShowInline()
Definition
file.php:100
Bitrix\Main\Engine\Response\File\getContentType
getContentType()
Definition
file.php:80
Bitrix\Main\Engine\Response\File\$name
$name
Definition
file.php:14
Bitrix\Main\Engine\Response\File\$contentType
$contentType
Definition
file.php:18
Bitrix\Main\Engine\Response\File\getCacheTime
getCacheTime()
Definition
file.php:120
Bitrix\Main\HttpResponse
Definition
httpresponse.php:8
Bitrix\Main\Engine\Response
Definition
ajaxjson.php:3
Bitrix\Main
modules
main
lib
engine
response
file.php
Создано системой
1.10.0