Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Static Public Member Functions | List of all members
HeadersHelper Class Reference

Static Public Member Functions

static forFile ($path, $content=null)
static expires ($seconds)
static cache ($seconds=null)

Detailed Description

Gentics Portal.Node PHP Author & Copyright (c) by Gentics Software GmbH sales.nosp@m.@gen.nosp@m.tics..nosp@m.com http://www.gentics.com Licenses can be found in the LICENSE.txt file in the root-folder of this installation You must not use this software without a valid license agreement.

Class for helping in work with headers

Definition at line 12 of file HeadersHelper.php.

Member Function Documentation

static HeadersHelper::cache (   $seconds = null)
static

Build cache control header for file

Parameters
string$filename
int$secondshow long the file should be cached in browser
Returns
array headers

Definition at line 59 of file HeadersHelper.php.

Referenced by RendererController\actionStatic().

{
$headers = array();
$cache_string = "Cache-Control: public";
if(isset($seconds) && is_numeric($seconds) && $seconds > 0) {
$cache_string = "Cache-Control: max-age=".$seconds.", public";
}
$headers[] = $cache_string;
return $headers;
}
static HeadersHelper::expires (   $seconds)
static

Build expires headers for file

Parameters
int$secondsseconds before content expires
Returns
array headers

Definition at line 42 of file HeadersHelper.php.

Referenced by RendererController\actionStatic().

{
$headers = array();
$headers[] = "Pragma: public";
$headers[] = "Expires: " . date("r", time() + $seconds);
return $headers;
}
static HeadersHelper::forFile (   $path,
  $content = null 
)
static

Build content headers for file content.

Parameters
string$pathfile path
string$contentfile content
Returns
array headers

Definition at line 23 of file HeadersHelper.php.

Referenced by RendererController\actionStatic().

{
$headers = array();
$headers[] = "Content-Type: " . CFileHelper::getMimeTypeByExtension($path);
if ($content) {
$headers[] = "Content-Length: " . mb_strlen($content);
$contentPath = Yii::app()->getModule('contentSource')->getContentSource()->contentFile($path);
$headers[] = "Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($contentPath)) . " GMT";
}
return $headers;
}

The documentation for this class was generated from the following file: