TYPO3 API  SVNRelease
Public Member Functions | Protected Member Functions | Protected Attributes
TYPO3AJAX Class Reference

List of all members.

Public Member Functions

 __construct ($ajaxId)
 getAjaxID ()
 setContent ($content)
 addContent ($key, $content)
 getContent ($key= '')
 setContentFormat ($format)
 setJavascriptCallbackWrap ($javascriptCallbackWrap)
 setError ($errorMsg= '')
 isError ()
 render ()

Protected Member Functions

 renderAsError ()
 renderAsPlain ()
 renderAsXML ()
 renderAsJSON ()
 renderAsJavascript ()

Protected Attributes

 $ajaxId = null
 $errorMessage = null
 $isError = false
 $content = array()
 $contentFormat = 'plain'
 $charset = 'utf-8'
 $requestCharset = 'utf-8'
 $javascriptCallbackWrap

Detailed Description

Definition at line 36 of file class.typo3ajax.php.


Constructor & Destructor Documentation

TYPO3AJAX::__construct ( ajaxId)

sets the charset and the ID for the AJAX call due some charset limitations in Javascript (prototype uses encodeURIcomponent, which converts all data to utf-8), we need to detect if the encoding of the request differs from the backend encoding (e.g. forceCharset), and then convert all incoming data (_GET and _POST) in the expected backend encoding.

Parameters:
stringthe AJAX id
Returns:
void

Definition at line 62 of file class.typo3ajax.php.

References $ajaxId, $charset, and $GLOBALS.


Member Function Documentation

TYPO3AJAX::addContent ( key,
content 
)

adds new content

Parameters:
stringthe new content key where the content should be added in the content array
stringthe new content to add
Returns:
mixed the old content; if the old content didn't exist before, false is returned

Definition at line 119 of file class.typo3ajax.php.

References $content.

Referenced by AjaxLogin\getChallenge(), AjaxLogin\isTimedOut(), AjaxLogin\login(), AjaxLogin\logout(), tx_t3editor_TSrefLoader\processAjaxRequest(), TYPO3_tcefile\processAjaxRequest(), AjaxLogin\refreshLogin(), and AjaxLogin\refreshTokens().

TYPO3AJAX::getAjaxID ( )

returns the ID for the AJAX call

Returns:
string the AJAX id

Definition at line 91 of file class.typo3ajax.php.

Referenced by tx_t3editor_codecompletion\processAjaxRequest(), and tx_t3editor_TSrefLoader\processAjaxRequest().

TYPO3AJAX::getContent ( key = '')

returns the content for the ajax call

Returns:
mixed the content for a specific key or the whole content

Definition at line 140 of file class.typo3ajax.php.

TYPO3AJAX::isError ( )

checks whether an error occured during the execution or not

Returns:
boolean whether this AJAX call had errors

Definition at line 186 of file class.typo3ajax.php.

Referenced by render(), and setError().

TYPO3AJAX::render ( )

renders the AJAX call based on the $contentFormat variable and exits the request

Returns:
void

Definition at line 196 of file class.typo3ajax.php.

References isError(), renderAsError(), renderAsJavascript(), renderAsJSON(), renderAsPlain(), and renderAsXML().

TYPO3AJAX::renderAsError ( ) [protected]

renders the AJAX call in XML error style to handle with JS the "responseXML" of the transport object will be filled with the error message then

Returns:
void

Definition at line 226 of file class.typo3ajax.php.

References t3lib_utility_Http\HTTP_STATUS_500.

Referenced by render().

TYPO3AJAX::renderAsJavascript ( ) [protected]

Renders the AJAX call as inline JSON inside a script tag. This is useful when an iframe is used as the AJAX transport.

Returns:
void

Definition at line 296 of file class.typo3ajax.php.

References $content, and $GLOBALS.

Referenced by render().

TYPO3AJAX::renderAsJSON ( ) [protected]

renders the AJAX call with JSON evaluated headers note that you need to have requestHeaders: {Accept: 'application/json'}, in your AJAX options of your AJAX request object in JS

the content will be available

  • in the second parameter of the onSuccess / onComplete callback (except when contentFormat = 'jsonbody')
  • and in the xhr.responseText as a string (except when contentFormat = 'jsonhead') you can evaluate this in JS with xhr.responseText.evalJSON();
Returns:
void

Definition at line 272 of file class.typo3ajax.php.

References $content, and $GLOBALS.

Referenced by render().

TYPO3AJAX::renderAsPlain ( ) [protected]

renders the AJAX call with text/html headers the content will be available in the "responseText" value of the transport object

Returns:
void

Definition at line 240 of file class.typo3ajax.php.

Referenced by render().

TYPO3AJAX::renderAsXML ( ) [protected]

renders the AJAX call with text/xml headers the content will be available in the "responseXML" value of the transport object

Returns:
void

Definition at line 253 of file class.typo3ajax.php.

Referenced by render().

TYPO3AJAX::setContent ( content)

overwrites the existing content with the first parameter

Parameters:
arraythe new content
Returns:
mixed the old content as array; if the new content was not an array, false is returned

Definition at line 102 of file class.typo3ajax.php.

References $content.

Referenced by t3lib_extjs_ExtDirectApi\getAPI(), tx_t3editor\getPlugins(), tx_t3editor_codecompletion\processAjaxRequest(), tx_t3editor_TSrefLoader\processAjaxRequest(), and t3lib_extjs_ExtDirectRouter\route().

TYPO3AJAX::setContentFormat ( format)

sets the content format for the ajax call

Parameters:
stringcan be one of 'plain' (default), 'xml', 'json', 'javascript', 'jsonbody' or 'jsonhead'
Returns:
void

Definition at line 151 of file class.typo3ajax.php.

References t3lib_div\inArray().

Referenced by AjaxLogin\getChallenge(), tx_t3editor\getPlugins(), AjaxLogin\isTimedOut(), AjaxLogin\login(), AjaxLogin\logout(), tx_t3editor_codecompletion\processAjaxRequest(), tx_t3editor_TSrefLoader\processAjaxRequest(), TYPO3_tcefile\processAjaxRequest(), AjaxLogin\refreshLogin(), AjaxLogin\refreshTokens(), and t3lib_extjs_ExtDirectRouter\route().

TYPO3AJAX::setError ( errorMsg = '')

sets an error message and the error flag

Parameters:
stringthe error message
Returns:
void

Definition at line 175 of file class.typo3ajax.php.

References isError().

Referenced by TYPO3_tcefile\processAjaxRequest().

TYPO3AJAX::setJavascriptCallbackWrap ( javascriptCallbackWrap)

Specifies the wrap to be used if contentFormat is "javascript". The wrap used by default stores the results in a variable "response" and adds <script>-Tags around it.

Parameters:
string$javascriptCallbackWrapthe javascript callback wrap to be used
Returns:
void

Definition at line 165 of file class.typo3ajax.php.

References $javascriptCallbackWrap.


Member Data Documentation

TYPO3AJAX::$ajaxId = null [protected]

Definition at line 37 of file class.typo3ajax.php.

Referenced by __construct().

TYPO3AJAX::$charset = 'utf-8' [protected]

Definition at line 42 of file class.typo3ajax.php.

Referenced by __construct().

TYPO3AJAX::$content = array() [protected]

Definition at line 40 of file class.typo3ajax.php.

Referenced by addContent(), renderAsJavascript(), renderAsJSON(), and setContent().

TYPO3AJAX::$contentFormat = 'plain' [protected]

Definition at line 41 of file class.typo3ajax.php.

TYPO3AJAX::$errorMessage = null [protected]

Definition at line 38 of file class.typo3ajax.php.

TYPO3AJAX::$isError = false [protected]

Definition at line 39 of file class.typo3ajax.php.

TYPO3AJAX::$javascriptCallbackWrap [protected]
Initial value:
 '
        <script type="text/javascript">
            /*<![CDATA[*/
            response = |;
            /*]]>*/
        </script>
    '

Definition at line 44 of file class.typo3ajax.php.

Referenced by setJavascriptCallbackWrap().

TYPO3AJAX::$requestCharset = 'utf-8' [protected]

Definition at line 43 of file class.typo3ajax.php.


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