API DOCS

DOCS & TUTORIALS » API DOCS » xajax_core » xajax.inc.php » xajax

Class: xajax



The xajax class uses a modular plug-in system to facilitate the processing
of special Ajax requests made by a PHP page. It generates Javascript that
the page must include in order to make requests. It handles the output
of response commands (see <xajaxResponse>). Many flags and settings can be
adjusted to effect the behavior of the xajax class as well as the client-side
javascript.

variables

functions

xajax

function xajax($sRequestURI=null, $sLanguage=null)

Constructs a xajax instance and initializes the plugin system.


getGlobalResponse

function &getGlobalResponse()

Returns the object preconfigured with the encoding
and entity settings from this instance of . This is used
for singleton-pattern response development.


getVersion

function getVersion()

register

function register($sType, $mArg)

Call this function to register request handlers, including functions,
callable objects and events. New plugins can be added that support
additional registration methods and request processors.



configure

function configure($sName, $mValue)

Call this function to set options that will effect the processing of
xajax requests. Configuration settings can be specific to the xajax
core, request processor plugins and response plugins.



configureMany

function configureMany($aOptions)
Set an array of configuration options.


getConfiguration

function getConfiguration($sName)

Get the current value of a configuration setting that was previously set
via configure> or configureMany>


processRequest

function processRequest()

If this is a xajax request (see canProcessRequest>), call the
requested PHP function, build the response and send it back to the
browser.

This is the main server side engine for xajax. It handles all the
incoming requests, including the firing of events and handling of the
response. If your RequestURI is the same as your web page, then this
function should be called before ANY headers or HTML is output from
your script.

This function may exit, if a request is processed. See bAllowExit>

printJavascript

function printJavascript($sJsURI="", $aJsFiles=array()
Prints the xajax Javascript header and wrapper code into your page.
This should be used to print the javascript code between the HEAD
and /HEAD tags at the top of the page.

The javascript code output by this function is dependent on the plugins
that are included and the functions that are registered.


getJavascript

function getJavascript($sJsURI='', $aJsFiles=array()
See printJavascript> for more information.

autoCompressJavascript

function autoCompressJavascript($sJsFullFilename=NULL, $bAlways=false)

Creates a new xajax_core, xajax_debug, etc... file out of the
_uncompressed file with a similar name. This strips out the
comments and extraneous whitespace so the file is as small as
possible without modifying the function of the code.


setCharEncoding

function setCharEncoding($sEncoding)

Sets the character encoding that will be used for the HTTP output.
Typically, you will not need to use this method since the default
character encoding can be configured using the constant
.


getCharEncoding

function getCharEncoding()

Returns the current character encoding. See also setCharEncoding>
and


setFlags

function setFlags($flags)

Sets a series of flags. See also, setFlag>.


setFlag

function setFlag($name, $value)

Sets a single flag (boolean true or false).

Available flags are as follows (flag, default value):
- debug, false
- verbose, false
- statusMessages, false
- waitCursor, true
- scriptDeferral, false
- exitAllowed, true
- errorHandler, false
- cleanBuffer, false
- decodeUTF8Input, false
- outputEntities, false
- allowBlankResponse, false
- allowAllResponseTypes, false
- generateStubs, true


getFlag

function getFlag($name)

Returns the current value of the flag. See also setFlag>.


setRequestURI

function setRequestURI($sRequestURI)
Sets the URI to which requests will be sent.


getRequestURI

function getRequestURI()

setDefaultMode

function setDefaultMode($sDefaultMode)

Sets the default mode for requests from the browser.


getDefaultMode

function getDefaultMode()

Get the default request mode that will be used by the browser
for submitting requests to the server. See also setDefaultMode>


setDefaultMethod

function setDefaultMethod($sMethod)

Sets the default method for making xajax requests.


getDefaultMethod

function getDefaultMethod()

Gets the default method for making xajax requests.


setWrapperPrefix

function setWrapperPrefix($sPrefix)

Sets the prefix that will be prepended to the javascript wrapper
functions. This allows a little flexibility in setting the naming
for the wrapper functions.


getWrapperPrefix

function getWrapperPrefix()

Gets the current javascript wrapper prefix. See also, setWrapperPrefix>


setLogFile

function setLogFile($sFilename)

Specifies a log file that will be written to by xajax during a
request. This is only used by the error handling system at this
point. If you do not invoke this method or you pass in an empty
string, then no log file will be written to.


getLogFile

function getLogFile()

Returns the current log file path. See also setLogFile>.


registerFunction

function registerFunction($mFunction, $sIncludeFile=null)

Registers a PHP function or method with the xajax request processor. This
makes the function available to the browser via an asynchronous
(or synchronous) javascript call.


registerCallableObject

function registerCallableObject(&$oObject)

Registers an object whose methods will be searched for a match to the
incoming request. If more than one callable object is registered, the
first on that contains the requested method will be used.


registerEvent

function registerEvent($sEventName, $mCallback)

Assigns a callback function with the specified xajax event. Events
are triggered during the processing of a request.

List: Available events:
- beforeProcessing: triggered before the request is processed.
- afterProcessing: triggered after the request is processed.
- invalidRequest: triggered if no matching function/method is found.


 



XAJAX on SourceForge.net
Support this project Valid XHTML 1.0 Transitional