|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct ($spec) | |
| getContent () | |
| getHeaders () | |
| sendHeaders () | |
| sendAll () | |
| encode ($compressionLevel=null) | |
Static Public Member Functions | |
| static | getAcceptedEncoding ($allowCompress=true, $allowDeflate=true) |
| static | output ($content, $compressionLevel=null) |
Static Public Attributes | |
| static | $encodeToIe6 = false |
| static | $compressionLevel = 6 |
Static Protected Member Functions | |
| static | _isBuggyIe () |
Protected Attributes | |
| $_content = '' | |
| $_headers = array() | |
| $_encodeMethod = array('', '') | |
Definition at line 46 of file Encoder.php.
| __construct | ( | $ | spec | ) |
Get an HTTP Encoder object
| array | $spec | options |
'content': (string required) content to be encoded
'type': (string) if set, the Content-Type header will have this value.
'method: (string) only set this if you are forcing a particular encoding method. If not set, the best method will be chosen by getAcceptedEncoding() The available methods are 'gzip', 'deflate', 'compress', and '' (no encoding)
Definition at line 91 of file Encoder.php.

| static _isBuggyIe | ( | ) | [static, protected] |
Is the browser an IE version earlier than 6 SP2?
Definition at line 312 of file Encoder.php.
| encode | ( | $ | compressionLevel = null | ) |
Encode (compress) the content
If the encode method is '' (none) or compression level is 0, or the 'zlib' extension isn't loaded, we return false.
Then the appropriate gz_* function is called to compress the content. If this fails, false is returned.
The header "Vary: Accept-Encoding" is added. If encoding is successful, the Content-Length header is updated, and Content-Encoding is also added.
| int | $compressionLevel | given to zlib functions. If not given, the class default will be used. |
Definition at line 254 of file Encoder.php.
| static getAcceptedEncoding | ( | $ | allowCompress = true, |
| $ | allowDeflate = true |
||
| ) | [static] |
Determine the client's best encoding method from the HTTP Accept-Encoding header.
If no Accept-Encoding header is set, or the browser is IE before v6 SP2, this will return ('', ''), the "identity" encoding.
A syntax-aware scan is done of the Accept-Encoding, so the method must be non 0. The methods are favored in order of gzip, deflate, then compress. Deflate is always smallest and generally faster, but is rarely sent by servers, so client support could be buggier.
| bool | $allowCompress | allow the older compress encoding |
| bool | $allowDeflate | allow the more recent deflate encoding |
Definition at line 193 of file Encoder.php.

| getContent | ( | ) |
Get content in current form
Call after encode() for encoded content.
return string
Definition at line 114 of file Encoder.php.
| getHeaders | ( | ) |
Get array of output headers to be sent
E.g. array( 'Content-Length' => '615' ,'Content-Encoding' => 'x-gzip' ,'Vary' => 'Accept-Encoding' )
Definition at line 133 of file Encoder.php.
| static output | ( | $ | content, |
| $ | compressionLevel = null |
||
| ) | [static] |
Encode and send appropriate headers and content
This is a convenience method for common use of the class
| string | $content | |
| int | $compressionLevel | given to zlib functions. If not given, the class default will be used. |
Definition at line 294 of file Encoder.php.
| sendAll | ( | ) |
Send output headers and content
A shortcut for sendHeaders() and echo getContent()
You must call this before headers are sent and it probably cannot be used in conjunction with zlib output buffering / mod_gzip. Errors are not handled purposefully.
Definition at line 167 of file Encoder.php.

| sendHeaders | ( | ) |
Send output headers
You must call this before headers are sent and it probably cannot be used in conjunction with zlib output buffering / mod_gzip. Errors are not handled purposefully.
Definition at line 149 of file Encoder.php.

$_content = '' [protected] |
Definition at line 305 of file Encoder.php.
$_encodeMethod = array('', '') [protected] |
Definition at line 307 of file Encoder.php.
$_headers = array() [protected] |
Definition at line 306 of file Encoder.php.
$compressionLevel = 6 [static] |
Definition at line 72 of file Encoder.php.
$encodeToIe6 = false [static] |
Definition at line 62 of file Encoder.php.