1 | <?php |
||
15 | class SimpleHeaders |
||
16 | { |
||
17 | const DIPOSITION_INLINE = 'inline'; |
||
18 | const DIPOSITION_ATTACHEMENT = 'attachement'; |
||
19 | |||
20 | /** |
||
21 | * Supported disposition types. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $disposition_types = ['inline', 'attachement']; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $default_params = [ |
||
31 | 'content-type' => null, |
||
32 | 'content-type-charset' => null, |
||
33 | 'content-disposition-filename' => null, |
||
34 | 'content-disposition-type' => null, |
||
35 | 'content-length' => null |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $params; |
||
42 | |||
43 | 8 | public function __construct() |
|
47 | |||
48 | /** |
||
49 | * @param string $content_type |
||
50 | * @param string $charset |
||
51 | * |
||
52 | * @return SimpleHeaders |
||
53 | */ |
||
54 | 6 | public function setContentType($content_type, $charset = null) |
|
63 | |||
64 | 7 | public function getContentType() |
|
68 | |||
69 | /** |
||
70 | * Set the content disposition filename and type. |
||
71 | * |
||
72 | * @param string $filename filename when downloading |
||
73 | * @param string $content_disposition_type by default attachment |
||
74 | * |
||
75 | * @return SimpleHeaders |
||
76 | */ |
||
77 | 1 | public function setFilename($filename, $content_disposition_type = 'attachement') |
|
84 | |||
85 | /** |
||
86 | * Return the content disposition filename. |
||
87 | * |
||
88 | * @return string|null |
||
89 | */ |
||
90 | 1 | public function getFilename() |
|
94 | |||
95 | /** |
||
96 | * Set the content type charset. |
||
97 | * |
||
98 | * @throws Exception\RuntimeException |
||
99 | * |
||
100 | * @param string $charset |
||
101 | * |
||
102 | * @return SimpleHeaders |
||
103 | */ |
||
104 | 7 | public function setCharset($charset) |
|
113 | |||
114 | /** |
||
115 | * @return string |
||
116 | */ |
||
117 | 6 | public function getCharset() |
|
121 | |||
122 | /** |
||
123 | * Set the preferred content disposition type 'attachement' or 'inline'. |
||
124 | * |
||
125 | * @throws Exception\InvalidArgumentException |
||
126 | * |
||
127 | * @param string $content_disposition_type |
||
128 | * |
||
129 | * @return SimpleHeaders |
||
130 | */ |
||
131 | 3 | public function setContentDispositionType($content_disposition_type) |
|
142 | |||
143 | /** |
||
144 | * Return the content disposition type. |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | 2 | public function getContentDispositionType() |
|
152 | |||
153 | /** |
||
154 | * @param int $length |
||
155 | * |
||
156 | * @return SimpleHeaders |
||
157 | */ |
||
158 | 1 | public function setContentLength($length) |
|
164 | |||
165 | /** |
||
166 | * @return int |
||
167 | */ |
||
168 | 1 | public function getContentLength() |
|
172 | |||
173 | 1 | public function getHeaderLines() |
|
198 | |||
199 | /** |
||
200 | * Output the headers (php). |
||
201 | * |
||
202 | * @param bool $replace tells to replace eventual headers |
||
203 | */ |
||
204 | public function outputHeaders($replace = true) |
||
211 | } |
||
212 |