
Public Member Functions | |
| __construct () | |
| Constructor. | |
| getRequest () | |
| Provides the request we're currently responding to. | |
| getHeaders () | |
| Provides all headers for this response. | |
| addHeader ($header) | |
| Adds a header to be sent with this response. | |
| getBody () | |
| Provides the HTTP body of the response. | |
| getEntryPoint () | |
| Gets the current EntryPoint. | |
| getEntryPointName () | |
| Provides the name of the EntryPoint generating this response. | |
| getTitle () | |
| Provides the content of the <title> title tag of the response. | |
| setTitle ($title) | |
| Sets the content of the <title> title tag of the response. | |
| getCookies () | |
| Provides the cookies that will be sent along with this response. | |
| addMultipleCss ($css) | |
| addCss ($css) | |
| getCssDeclarations () | |
| addMultipleJs ($js, $inHeader=false) | |
| addJs ($js, $inHeader=false) | |
| addDynamicFooterJs ($js) | |
| getJsDeclarations ($inHeader) | |
| displayingTemplate (spunQ_PreparedTemplate $preparedTemplate) | |
| Callback for pages to indicate they are being displayed. | |
| finishedDisplayingTemplate (spunQ_PreparedTemplate $page) | |
| Callback for pages to indicate they have finished displaying. | |
| changeUser (spunQ_User $newUser) | |
| Changes the currently active user. | |
| getLocale () | |
| Provides the locale of the response. | |
| setLocale ($newLocale) | |
| Sets the locale of the response. | |
| set304 () | |
| Will set this to the HTTP 304 response. | |
| padHtmlTo1k ($html) | |
| Pads a string to 1 kb in length. | |
| handleException (Exception $exception) | |
| Will react to an exception that occured during the processing of a page. | |
| getCurrentLanguage () | |
| Gets the currently set language object. | |
| showHeaderInformation () | |
| showFooterInformation () | |
| captureDynamicJs ($output) | |
| Output buffer callback that just appends a closing script tag. | |
| getHeadersString () | |
| getFootersString () | |
| headersSent () | |
| Whether the HTTP headers have alreaty been sent. | |
| sendHeaders () | |
| Attempts to send the HTTP headers of this response to the client. | |
| send () | |
| Calls the appropriate PHP functions for sending the response. | |
| deliveredAsHtml () | |
| Checks current headers for content-type other than 'text/html'. | |
| __sleep () | |
| addCookie ($name, $value="", $expire=NULL, $path="", $domain="", $secure=false, $httponly=true) | |
| Adds a cookie to the response. | |
| deleteCookie ($name) | |
| Deletes a previously set cookie. | |
| deleteAllCookies () | |
| Deletes all previously set cookies (useful for delivering images). | |
| setAutologin ($user=NULL, $expire= '+5 years', $domain="", $path="", $secure=false, $httponly=true) | |
| Sets autologin cookies that are recognized by spunQ3. | |
| disableAutologin () | |
| Disables autologin for this user. | |
Static Public Member Functions | |
| static | get () |
| Provides the last object of this class that was created. | |
| static | getDefaultLocale () |
| Getter for the default locale. | |
| static | create (spunQ_IHttpRequest $request, spunQ_HttpEntryPoint $entryPoint, array $variables) |
| Initializes this object in response to given request. | |
| static | get301 (spunQ_IHttpRequest $request, $url) |
| Will generate a response indicating permanent redirection to another URL. | |
| static | get302 (spunQ_IHttpRequest $request, $url) |
| Will generate a response indicating temporal redirection to another URL. | |
| static | get404 (spunQ_IHttpRequest $request) |
| Handles the case that a URL does not point to a valid resource. | |
| static | get403 (spunQ_IHttpRequest $request, spunQ_HttpEntryPoint $entryPoint) |
| Handles the case that the requestor does not have the required rights. | |
| static | get405 (spunQ_IHttpRequest $request, spunQ_HttpEntryPoint $entryPoint) |
| Handles the case that the request type was received. | |
| static | get503 (spunQ_IHttpRequest $request, spunQ_HttpEntryPoint $entryPoint) |
| Handles the case that the request type was received. | |
| static | get500 ($request, $entryPoint, Exception $exception) |
| Handles the case of an internal error during processing a request. | |
| static | createResponseForInitializationError ($request, Exception $exception) |
| static | createResponseForFatalError ($output) |
| static | handleFatalError ($output) |
Public Attributes | |
| const | INIT_FILE_CONFKEY = 'spunQ.html.init' |
| Configuration key for the init file. | |
Static Protected Member Functions | |
| static | getInitFile () |
| Returns the initialization file, if one was configured. | |
| static | createRedirectionResponse (spunQ_IHttpRequest $request, $url, $permanent=false) |
| Implementation of both get301() and get302(). | |
| static | createErrorResponse ($request, $entryPoint, $exception, $code, $message) |
| Sets a given error template. | |
Protected Attributes | |
| $request | |
| The request this response is for. | |
| $headers = array('Content-Type: text/html;charset=utf-8') | |
| Headers of this http response. | |
| $sentHeaders = array() | |
| Headers that have already been sent. | |
| $cookies = array() | |
| Cookies to send along with this response. | |
| $sentCookies = array() | |
| Cookies that have already been sent. | |
| $body = '' | |
| The body of this response. | |
| $entryPoint | |
| The current entrypoint. | |
| $entryPointName | |
| The current entrypoint name. | |
| $title = NULL | |
| The html title to insert in the headers. | |
| $locale = NULL | |
| The locale in which the response will be encoded. | |
| $headerAndFooterManager | |
| The header/footer manager to use. | |
| $jsCollector | |
| Javascript collector to use. | |
| $cssCollector | |
| Css collector to use. | |
| $language = NULL | |
| The language object of the response. | |
| $deliveredAsHtml = true | |
| Whether the response contains HTML. | |
Static Private Attributes | |
| static | $current = NULL |
| Holds the last object of this class that was created. | |
| static | $defaultLocale = NULL |
Definition at line 6 of file HttpResponse.class.php.
| spunQ_HttpResponse::addCookie | ( | $ | name, | |
| $ | value = "", |
|||
| $ | expire = NULL, |
|||
| $ | path = "", |
|||
| $ | domain = "", |
|||
| $ | secure = false, |
|||
| $ | httponly = true | |||
| ) |
Adds a cookie to the response.
All parameters - except the first - map directly to the members of spunQ_HttpResponseCookie.
| $name | The name of the cookie, or a spunQ_HttpResponseCookie object. | |
| $value | The value of the cookie. Providing an empty string here unsets the cookie instead. | |
| $expire | The time the cookie expires. Either NULL, a spunQ_DateTime object or a string that will be used to construct a spunQ_DateTime object. | |
| $path | The path on the server in which the cookie will be available on. | |
| $domain | The domain that the cookie is available. | |
| $secure | The cookie should only be transmitted over a secure connection if this is true. | |
| $httponly | The cookie shall be made accessible only through the HTTP protocol if this is true. |
$this Definition at line 818 of file HttpResponse.class.php.
| spunQ_HttpResponse::addHeader | ( | $ | header | ) |
Adds a header to be sent with this response.
Note that later headers will override previous headers with the same name. $header The header to add, formatted as specified by the HTTP protocol (i.e. 'Name: Value'), with the trailing CRLF being optional.
$this Definition at line 372 of file HttpResponse.class.php.
| spunQ_HttpResponse::captureDynamicJs | ( | $ | output | ) |
Output buffer callback that just appends a closing script tag.
| $output | The javascript code that was captured. |
Definition at line 651 of file HttpResponse.class.php.
| spunQ_HttpResponse::changeUser | ( | spunQ_User $ | newUser | ) |
Changes the currently active user.
Sets spunQ_User:setCurrent(), the user's locale as response locale and disables autologin, if it was enabled.
| $newUser | The new user of the application. |
$this Definition at line 516 of file HttpResponse.class.php.
| static spunQ_HttpResponse::create | ( | spunQ_IHttpRequest $ | request, | |
| spunQ_HttpEntryPoint $ | entryPoint, | |||
| array $ | variables | |||
| ) | [static] |
Initializes this object in response to given request.
Definition at line 53 of file HttpResponse.class.php.
| static spunQ_HttpResponse::createErrorResponse | ( | $ | request, | |
| $ | entryPoint, | |||
| $ | exception, | |||
| $ | code, | |||
| $ | message | |||
| ) | [static, protected] |
Sets a given error template.
| $code | The numeric http status code. This will be used to find the appropriate error template. | |
| $message | This string will be used to generate the response header. It is required, since http status codes have a human-readable part (example: 'Not Found' for 404). |
Definition at line 215 of file HttpResponse.class.php.
| static spunQ_HttpResponse::createRedirectionResponse | ( | spunQ_IHttpRequest $ | request, | |
| $ | url, | |||
| $ | permanent = false | |||
| ) | [static, protected] |
Implementation of both get301() and get302().
Definition at line 196 of file HttpResponse.class.php.
| spunQ_HttpResponse::deleteAllCookies | ( | ) |
Deletes all previously set cookies (useful for delivering images).
$this Definition at line 854 of file HttpResponse.class.php.
| spunQ_HttpResponse::deleteCookie | ( | $ | name | ) |
Deletes a previously set cookie.
| $name | The name of the cookie to remove. |
$this Definition at line 843 of file HttpResponse.class.php.
| spunQ_HttpResponse::deliveredAsHtml | ( | ) |
Checks current headers for content-type other than 'text/html'.
Definition at line 778 of file HttpResponse.class.php.
| spunQ_HttpResponse::disableAutologin | ( | ) |
Disables autologin for this user.
$this Definition at line 902 of file HttpResponse.class.php.
| spunQ_HttpResponse::displayingTemplate | ( | spunQ_PreparedTemplate $ | preparedTemplate | ) |
Callback for pages to indicate they are being displayed.
Will include all appropriate css and js files.
| $preparedTemplate | The prepared template that is being displayed. |
$this Definition at line 492 of file HttpResponse.class.php.
| spunQ_HttpResponse::finishedDisplayingTemplate | ( | spunQ_PreparedTemplate $ | page | ) |
Callback for pages to indicate they have finished displaying.
| $page | The page that is finished. |
$this Definition at line 504 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get | ( | ) | [static] |
Provides the last object of this class that was created.
Definition at line 24 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get301 | ( | spunQ_IHttpRequest $ | request, | |
| $ | url | |||
| ) | [static] |
Will generate a response indicating permanent redirection to another URL.
| $url | The URL to redirect to. |
Definition at line 103 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get302 | ( | spunQ_IHttpRequest $ | request, | |
| $ | url | |||
| ) | [static] |
Will generate a response indicating temporal redirection to another URL.
| $url | The URL to redirect to. |
Definition at line 113 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get403 | ( | spunQ_IHttpRequest $ | request, | |
| spunQ_HttpEntryPoint $ | entryPoint | |||
| ) | [static] |
Handles the case that the requestor does not have the required rights.
Will send according header information and display the 403 template.
Definition at line 131 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get404 | ( | spunQ_IHttpRequest $ | request | ) | [static] |
Handles the case that a URL does not point to a valid resource.
Will send according header information and display the 404 template.
Definition at line 122 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get405 | ( | spunQ_IHttpRequest $ | request, | |
| spunQ_HttpEntryPoint $ | entryPoint | |||
| ) | [static] |
Handles the case that the request type was received.
Will send according header information and display the 405 template.
Definition at line 140 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get500 | ( | $ | request, | |
| $ | entryPoint, | |||
| Exception $ | exception | |||
| ) | [static] |
Handles the case of an internal error during processing a request.
Will send according header information and display the 500 template.
Definition at line 158 of file HttpResponse.class.php.
| static spunQ_HttpResponse::get503 | ( | spunQ_IHttpRequest $ | request, | |
| spunQ_HttpEntryPoint $ | entryPoint | |||
| ) | [static] |
Handles the case that the request type was received.
Will send according header information and display the 503 template.
Definition at line 149 of file HttpResponse.class.php.
| spunQ_HttpResponse::getBody | ( | ) |
Provides the HTTP body of the response.
Definition at line 382 of file HttpResponse.class.php.
| spunQ_HttpResponse::getCookies | ( | ) |
Provides the cookies that will be sent along with this response.
Definition at line 428 of file HttpResponse.class.php.
| spunQ_HttpResponse::getCurrentLanguage | ( | ) |
Gets the currently set language object.
Definition at line 626 of file HttpResponse.class.php.
| static spunQ_HttpResponse::getDefaultLocale | ( | ) | [static] |
Getter for the default locale.
This locale will be used if no explicit locale definition is found for the request.
Definition at line 36 of file HttpResponse.class.php.
| spunQ_HttpResponse::getEntryPoint | ( | ) |
Gets the current EntryPoint.
Definition at line 390 of file HttpResponse.class.php.
| spunQ_HttpResponse::getEntryPointName | ( | ) |
Provides the name of the EntryPoint generating this response.
Same as $response->getEntryPoint()->getName().
Definition at line 402 of file HttpResponse.class.php.
| spunQ_HttpResponse::getHeaders | ( | ) |
Provides all headers for this response.
Definition at line 359 of file HttpResponse.class.php.
| static spunQ_HttpResponse::getInitFile | ( | ) | [static, protected] |
Returns the initialization file, if one was configured.
This file will be included just before the entry point is invoked. The configuration key is as defined by the constant INIT_FILE_CONFKEY.
Definition at line 188 of file HttpResponse.class.php.
| spunQ_HttpResponse::getLocale | ( | ) |
Provides the locale of the response.
Corresponds to the locale of the request, defaulting to getDefaultLocale().
Definition at line 532 of file HttpResponse.class.php.
| spunQ_HttpResponse::getRequest | ( | ) |
Provides the request we're currently responding to.
Definition at line 351 of file HttpResponse.class.php.
| spunQ_HttpResponse::getTitle | ( | ) |
Provides the content of the <title> title tag of the response.
Will be inserted into the headers section of the response.
Definition at line 411 of file HttpResponse.class.php.
| spunQ_HttpResponse::handleException | ( | Exception $ | exception | ) |
Will react to an exception that occured during the processing of a page.
Will basically log the exception and call handle500().
| $exception | The exception. |
Definition at line 609 of file HttpResponse.class.php.
| spunQ_HttpResponse::headersSent | ( | ) |
Whether the HTTP headers have alreaty been sent.
Definition at line 685 of file HttpResponse.class.php.
| spunQ_HttpResponse::padHtmlTo1k | ( | $ | html | ) |
Pads a string to 1 kb in length.
Some versions of IE do not display custom error messages if they do not exceed 1 kb in size. This function is used as a callback to ob_start(). Needs to be public because its called out of context of spunQ_HttpResponse.
| $html | The string to pad. |
Definition at line 599 of file HttpResponse.class.php.
| spunQ_HttpResponse::send | ( | ) |
Calls the appropriate PHP functions for sending the response.
Sends the headers (sendHeaders()), followed by the body, possibly adjusting to content encoding.
$this Definition at line 749 of file HttpResponse.class.php.
| spunQ_HttpResponse::sendHeaders | ( | ) |
Attempts to send the HTTP headers of this response to the client.
Will not do anything if all headers have been sent and will generate a warning if headers have already been sent.
Note that cookies are sent via headers, too!
Definition at line 696 of file HttpResponse.class.php.
| spunQ_HttpResponse::set304 | ( | ) |
Will set this to the HTTP 304 response.
304 means that the page was not mofied since the last visit of the user.
Definition at line 574 of file HttpResponse.class.php.
| spunQ_HttpResponse::setAutologin | ( | $ | user = NULL, |
|
| $ | expire = '+5 years', |
|||
| $ | domain = "", |
|||
| $ | path = "", |
|||
| $ | secure = false, |
|||
| $ | httponly = true | |||
| ) |
Sets autologin cookies that are recognized by spunQ3.
Use this function to keep users logged in across sessions.
| $expire | The time the cookie expires. Either a spunQ_DateTime object or a string that will be used to construct a spunQ_DateTime object. | |
| $domain | The domain that the cookie is available. | |
| $path | The path on the server in which the cookie will be available on. | |
| $secure | The cookie should only be transmitted over a secure connection if this is true. | |
| $httponly | The cookie shall be made accessible only through the HTTP protocol if this is true. |
$this Definition at line 876 of file HttpResponse.class.php.
| spunQ_HttpResponse::setLocale | ( | $ | newLocale | ) |
Sets the locale of the response.
This will cause links to be generated for the new locale and the translations of the new locale to be used. User-code might query the locale, too.
| $newLocale | Either a numeric value, which will be considered the id of a locale, or the rfcName of a spunQ_Locale, or a spunQ_Locale object. |
$this Definition at line 553 of file HttpResponse.class.php.
| spunQ_HttpResponse::setTitle | ( | $ | title | ) |
Sets the content of the <title> title tag of the response.
$this Definition at line 419 of file HttpResponse.class.php.
spunQ_HttpResponse::$body = '' [protected] |
spunQ_HttpResponse::$cookies = array() [protected] |
Cookies to send along with this response.
Definition at line 259 of file HttpResponse.class.php.
spunQ_HttpResponse::$cssCollector [protected] |
Css collector to use.
Definition at line 317 of file HttpResponse.class.php.
spunQ_HttpResponse::$current = NULL [static, private] |
Holds the last object of this class that was created.
Definition at line 18 of file HttpResponse.class.php.
spunQ_HttpResponse::$deliveredAsHtml = true [protected] |
Whether the response contains HTML.
Will be set to NULL if new headers are added to the response and re-generated in deliveredAsHtml().
Definition at line 333 of file HttpResponse.class.php.
spunQ_HttpResponse::$entryPointName [protected] |
spunQ_HttpResponse::$headerAndFooterManager [protected] |
The header/footer manager to use.
Defaults to spunQ_BufferingHeaderAndFooterManager
Definition at line 305 of file HttpResponse.class.php.
spunQ_HttpResponse::$headers = array('Content-Type: text/html;charset=utf-8') [protected] |
Headers of this http response.
Definition at line 244 of file HttpResponse.class.php.
spunQ_HttpResponse::$jsCollector [protected] |
Javascript collector to use.
Definition at line 311 of file HttpResponse.class.php.
spunQ_HttpResponse::$language = NULL [protected] |
The language object of the response.
Definition at line 324 of file HttpResponse.class.php.
spunQ_HttpResponse::$locale = NULL [protected] |
The locale in which the response will be encoded.
Definition at line 298 of file HttpResponse.class.php.
spunQ_HttpResponse::$request [protected] |
The request this response is for.
Definition at line 238 of file HttpResponse.class.php.
spunQ_HttpResponse::$sentCookies = array() [protected] |
Cookies that have already been sent.
Contains cookies present in the $cookies array that have already been sent using PHP's setcookie() function. Required to verify that all cookies have been sent successfully.
Definition at line 268 of file HttpResponse.class.php.
spunQ_HttpResponse::$sentHeaders = array() [protected] |
Headers that have already been sent.
Contains headers present in the $headers array that have already been sent using PHP's header() function. Required to verify that all headers have been sent successfully.
Definition at line 253 of file HttpResponse.class.php.
spunQ_HttpResponse::$title = NULL [protected] |
The html title to insert in the headers.
Definition at line 292 of file HttpResponse.class.php.
| const spunQ_HttpResponse::INIT_FILE_CONFKEY = 'spunQ.html.init' |
Configuration key for the init file.
Definition at line 12 of file HttpResponse.class.php.
1.5.9