Gentics Portal.Node PHP API
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
All
Classes
Namespaces
Functions
Variables
Pages
common
extensions
HeadersHelper.php
1
<?php
2
/**
3
* Gentics Portal.Node PHP
4
* Author & Copyright (c) by Gentics Software GmbH
5
* sales@gentics.com
6
* http://www.gentics.com
7
* Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8
* You must not use this software without a valid license agreement.
9
*
10
* Class for helping in work with headers
11
*/
12
class
HeadersHelper
13
{
14
15
/**
16
* Build content headers for file content.
17
*
18
* @param string $path file path
19
* @param string $content file content
20
*
21
* @return array headers
22
*/
23
public
static
function
forFile
($path, $content = null)
24
{
25
$headers = array();
26
$headers[] =
"Content-Type: "
. CFileHelper::getMimeTypeByExtension($path);
27
if
($content) {
28
$headers[] =
"Content-Length: "
. mb_strlen($content);
29
}
30
return
$headers;
31
}
32
33
/**
34
* Build cache headers for file
35
*
36
* @param int $seconds seconds to cache
37
*
38
* @return array headers
39
*/
40
public
static
function
cache
($seconds)
41
{
42
$headers = array();
43
$headers[] =
"Pragma: public"
;
44
$headers[] =
"Expires: "
. date(
"r"
, time() + $seconds);
45
$headers[] =
"Cache-Control: public"
;
46
47
return
$headers;
48
}
49
}
Generated on Thu Jun 20 2013 14:45:15 for Gentics Portal.Node PHP API by
1.8.1.2