LoadingFiles

Factory class
Source
LoadingFiles.php
Extends
Response

Properties

__arta__ = true

$obj->__arta__ = true

By default a data structure as "arta: {resources: {js:[], css:[], jsx: [],}, DEBUG: (true/false), BASE_URL: (string), fav: (URL), title: (string)}" is added to the response context. To exclude this data set this property to false.

__tpl

$obj->__tpl

Hook to the template engine object if a template engine is being used as the context of the response.

css = array

$obj->css = array()

A list of CSS URLs or CSS URL keys defined in the browser-dictionary. The keys will be replaced with their URL values and available/sent with the response context as "arta: {resources: {css: [],},}". e.g. you can iterate over the list in the template to include required CSS URLs for the page or load it dynamically in a page when sent in a JSON pack as AJAX, if you use "arta.js" all will be taken care of automatically. Widget and HTML renderer objects inject items to this property.

js = array

$obj->js = array()

A list of JS URLs or JS URL keys defined in the browser-dictionary. The keys will be replaced with their URL values and available/sent with the response context as "arta: {resources: {js: [],},}". e.g. you can iterate over the list in the template to include required JS URLs for the page or load it dynamically in a page when sent in a JSON pack as AJAX, if you use "arta.js" all will be taken care of automatically. Widget and HTML renderer objects inject items to this property.

jsx = array

$obj->jsx = array()

A list of JS source to be executed that would be available/sent with the response context as "arta: {resources: {jsx: [],},}". e.g. you can iterate over the list in the template and put the contents in a script tag or execute the source dynamically in a page when sent in a JSON pack as AJAX, if you use "arta.js" all will be taken care of automatically. Widget and HTML renderer objects inject items to this property.

Static Methods

getHttpStatusCodes

array|string|null LoadingFiles::getHttpStatusCodes(int | string code=null)

Get a list of all HTTP status codes, or get the full status by passing only the code.

Arguments

    code=null (int | string)
    Status code as int or string or with description

Returns

array|string|null
If argument is not passed then all status codes will be returned as {code: code-and-description,} if argument is passed and identifies a valid HTTP status code then the full HTTP status line will be returned

getHttpVersions

array|string LoadingFiles::getHttpVersions(float | string version=null)

Get a list of HTTP versions, or check if a passed value is valid or not.

Arguments

    version=null (float | string)
    HTTP version. e.g. 1.1 or "1.1" or "HTTP/1.1"

Returns

array|string
If argument is not passed then all HTTP versions will be returned as {version-float: version-string,} if argument is passed and identifies a valid HTTP version then a string such as "1.1" with only the HTTP version will be returned otherwise null will be returned

headerSent

bool LoadingFiles::headerSent()

Check if headers have been sent to the client.

Returns

bool
true=headers have been sent

set404

void LoadingFiles::set404()

Set 404 headers for the response.

Returns

void

Methods

__call

void $obj->aNotExistingMethod(string key, array arguments)

This can be used as a shortcut to add complex arrays to the response context. e.g. "$this->html('form', 'SOME DATA', 'list', 'SOME DATA',);" 'is equal to "$this->html = array('html' => array('form' => 'SOME DATA', 'list' => 'SOME DATA',));".

Since
Artaengine 1.2.0

Arguments

    key (string)
    Function name of contex key
    arguments (array)
    Contex key value key: {arg1: arg2, arg3: arg4,...}

Returns

void

__get

mixed __get(string key)

Get a response context var. Context vars can be accessed as properties and will be available in the response context e.g. templates, JSON, etc.

Arguments

    key (string)
    Var name

Returns

mixed
Var value

__isset

bool __isset(string key)

Check if a varable exists in the response context.

Arguments

    key (string)
    Context variable(key) name

Returns

bool
true=exists

__set

void __set(string key, mixed val)

Set a response context var. Context vars can be accessed as properties and will be available in the response context e.g. templates, JSON, etc.

Arguments

    key (string)
    Var name
    val (mixed)
    Var value

Returns

void

__unset

void __unset(string key)

Unset a response context variable.

Arguments

    key (string)
    Context variable(key) name

Returns

void

addCssFile

IResponse $obj->addCssFile([string] file)

Add a CSS file to the response context. The CSS list in the response context is available in the template or the data pack being sent to the client for on-demand CSS loading.

Arguments

    file ([string])
    CSS file URL or browser dictionary key to a CSS file URL

Returns

IResponse
For method chaining

addJsFile

IResponse $obj->addJsFile([string] file)

Add a JS file to the response context. The JS list in the response context is available in the template or the data pack being sent to the client for on-demand JS loading.

Arguments

    file ([string])
    JS file URL or browser dictionary key to a JS file URL

Returns

IResponse
For method chaining

addJsSource

IResponse $obj->addJsSource([string] sourceCode)

Add a JS source to the response context. The JS source list in the response context is available in the template or the data pack being sent to the client for execution.

Arguments

    sourceCode ([string])
    JS source code

Returns

IResponse
For method chaining

arta

array $obj->arta()

Get the Artaengine extra data which is be included to the response context. To exclude this data from the response context in a factory set "$this->__arta__ = false;".

Returns

array
{
    string title     : app-title (from app configs array or ini),
    string BASE_URL  : the BASE_URL,
    bool   DEBUG     : app DEBUG status (from app configs array or ini),
    string resources : {
        string fav : fav ico URL (from app configs array or ini),
        array  js  : [list-of-js-files-to-be-included-to-the-page],
        array  css : [list-of-css-files-to-be-included-to-the-page],
        string jsx : JavaScript source codes to be executed,
    }
}

authenticate

void $obj->authenticate(
    string realm='',
    string msgOnCancel=null,
    string simpleDigest=false
)

Send an "Authentication Required" message to the client browser causing it to pop up a Username/Password input window.

Arguments

    realm='' (string)
    Message to be shown in the popup
    msgOnCancel=null (string)
    If not null shows the message end exits if cancel is pressed
    simpleDigest=false (string)
    true=Simple digest authentication

Returns

void

bufferLen

int $obj->bufferLen()

Get the length of the output buffer.

Returns

int
Content length

clear

IResponse $obj->clear()

Clear all context vars.

Returns

IResponse
For method chaining

clearBuffer

IResponse $obj->clearBuffer()

Clear the contents of the output buffer.

Returns

IResponse
for method chaining

flush

IResponse $obj->flush()

Flush the contents of the output buffer.

Returns

IResponse
for method chaining

get

mixed $obj->get(string key)

Get a response context var. Context vars can be accessed as properties and will be available in the response context e.g. templates, JSON, etc.

Arguments

    key (string)
    Var name

Returns

mixed
Var value

getBuffer

string $obj->getBuffer()

Get the contents of the output buffer.

Returns

string
Buffer contents

getCssUrl

string $obj->getCssUrl(string key)

Get the URL for a CSS file by a browser dictionary key.

Arguments

    key (string)
    A browser dictionary key that is mappeed to a CSS file

Returns

string
URL

getJsUrl

string $obj->getJsUrl(string key)

Get the URL for a JS file by a browser dictionary key.

Arguments

    key (string)
    A browser dictionary key that is mappeed to a JS file

Returns

string
URL

getTemplate

string $obj->getTemplate(string template)

Render a template and return the contents.

Arguments

    template (string)
    Template filename or a template dictionary key

Returns

string
The template contents

has

bool $obj->has(string key)

Check if a variable exists in the response context.

Arguments

    key (string)
    Context variable(key) name

Returns

bool
true=exists

inspect

void|array $obj->inspect(bool print=true)

Dumps response variables.

Arguments

    print=true (bool)
    false=returns the data

Returns

void|array
If print=false returns an array of response vars

redirect

void $obj->redirect(string url=null)

Redirect to a URL.

Arguments

    url=null (string)
    The URL, null=redirect to base URL, if it's string is a path e.g. "/path" the redirect URL would be considered as "BASE_URL/path"

Returns

void

remove

void $obj->remove(string key)

Unset a response context variable.

Arguments

    key (string)
    Context variable(key) name

Returns

void

sendFile

void $obj->sendFile(string filePath, string asFilename=null, string fileType=null)

Send a file to be downloaded.

Arguments

    filePath (string)
    File path
    asFilename=null (string)
    Download file as this filename
    fileType=null (string)
    File type, null=it will be guessed

Returns

void

set

IResponse $obj->set(string key, mixed val)

Set a response context var. Context vars can be accessed as properties and will be available in the response context e.g. templates, JSON, etc.

Arguments

    key (string)
    Var name
    val (mixed)
    Var value

Returns

IResponse
For method chaining

setHttpStatus

IHeaders $obj->setHttpStatus(string | int code)

Set the response HTTP status code. Invalid status codes will be ignored.

Arguments

    code (string | int)
    An HTTP status code or an HTTP status code and description

Returns

IHeaders
For method chaining

setHttpVersion

IHeaders $obj->setHttpVersion(string version=1.1)

Set the HTTP version. Invalid values will be ignored.

Arguments

    version=1.1 (string)
    HTTP version

Returns

IHeaders
For method chaining

show

void $obj->show(string template)

Render a template and show the contents. Alias for "writeTemplate()".

Arguments

    template (string)
    Template filename or a template dictionary key

Returns

void

showFile

IResponse $obj->showFile(string filePath, string fileType=null)

Output file contents.

Arguments

    filePath (string)
    File path
    fileType=null (string)
    File type, null=it will be guessed

Returns

IResponse
For method chaining

write

IResponse $obj->write(string | array contents=null, string charset=utf-8)

Output text. If an array is passed the array dump will be sent.

Arguments

    contents=null (string | array)
    Data to output, null=write the response context values
    charset=utf-8 (string)
    Character-set, null=do not send any additional headers

Returns

IResponse
For method chaining

writeClose

IResponse $obj->writeClose(string | array contents=null, string encoding=utf-8)

Output text and immediately close the connection. If an array is passed the array dump will be sent.

Arguments

    contents=null (string | array)
    Data to output, null=write the response context values
    encoding=utf-8 (string)
    Character-encoding

Returns

IResponse
For method chaining

writeJson

IResponse $obj->writeJson(string | array data=null, string charset=utf-8)

Output JSON.

Arguments

    data=null (string | array)
    Data pack to send, null=send the response context values
    charset=utf-8 (string)
    Character-set, null=do not send any additional headers

Returns

IResponse
For method chaining

writeTemplate

void $obj->writeTemplate(string template)

Render a template and show the contents.

Arguments

    template (string)
    Template filename or a template dictionary key

Returns

void

writeX

IResponse $obj->writeX(string | array contents=null, string charset=utf-8)

Output text immediately without closing the connection. This is useful when a process takes time and you want to send messages meanwhile. If an array is passed the array dump will be sent.

Arguments

    contents=null (string | array)
    Data to output, null=write the response context values
    charset=utf-8 (string)
    Character-set, null=do not send any additional headers

Returns

IResponse
For method chaining