Main xajax class and setup file.
xajax. | Main xajax class and setup file. |
xajax class | Please see copyright.inc.php for a detailed description, copyright and license information. |
Standard Definitions | |
Variables | |
XAJAX_DEFAULT_CHAR_ENCODING | Default character encoding used by both the xajax and xajaxResponse classes. |
XAJAX_PROCESSING_EVENT | String: XAJAX_PROCESSING_EVENT_BEFORE String: XAJAX_PROCESSING_EVENT_AFTER String: XAJAX_PROCESSING_EVENT_INVALID |
xajax | The xajax class uses a modular plug-in system to facilitate the processing of special Ajax requests made by a PHP page. |
Variables | |
aSettings | This array is used to store all the configuration settings that are set during the run of the script. |
bErrorHandler | This is a configuration setting that the main xajax object tracks. |
aProcessingEvents | Stores the processing event handlers that have been assigned during this run of the script. |
bExitAllowed | A configuration option that is tracked by the main <xajax>object. |
bCleanBuffer | A configuration option that is tracked by the main xajax object. |
sLogFile | A configuration setting tracked by the main xajax object. |
sCoreIncludeOutput | This is populated with any errors or warnings produced while including the xajax core components. |
objPluginManager | This stores a reference to the global xajaxPluginManager |
objArgumentManager | Stores a reference to the global xajaxArgumentManager |
objResponseManager | Stores a reference to the global xajaxResponseManager |
objLanguageManager | Stores a reference to the global xajaxLanguageManager |
Functions | |
xajax | Constructs a xajax instance and initializes the plugin system. |
__sleep | |
__wakeup | |
getGlobalResponse | Returns the xajaxResponse object preconfigured with the encoding and entity settings from this instance of xajax. |
getVersion | |
register | Call this function to register request handlers, including functions, callable objects and events. |
configure | Call this function to set options that will effect the processing of xajax requests. |
configureMany | Set an array of configuration options. |
getConfiguration | Get the current value of a configuration setting that was previously set via xajax->configure or xajax->configureMany |
canProcessRequest | Determines if a call is a xajax request or a page load request. |
processRequest | If this is a xajax request (see <xajax->canProcessRequest>), call the requested PHP function, build the response and send it back to the browser. |
printJavascript | Prints the xajax Javascript header and wrapper code into your page. |
getJavascript | See xajax->printJavascript for more information. |
autoCompressJavascript | Creates a new xajax_core, xajax_debug, etc... |
_detectURI | Returns the current requests URL based upon the SERVER vars. |
setCharEncoding | Sets the character encoding that will be used for the HTTP output. |
getCharEncoding | Returns the current character encoding. |
setFlags | Sets a series of flags. |
setFlag | Sets a single flag (boolean true or false). |
getFlag | Returns the current value of the flag. |
setRequestURI | Sets the URI to which requests will be sent. |
getRequestURI | |
setDefaultMode | Sets the default mode for requests from the browser. |
getDefaultMode | Get the default request mode that will be used by the browser for submitting requests to the server. |
setDefaultMethod | |
getDefaultMethod | Gets the default method for making xajax requests. |
setWrapperPrefix | Sets the prefix that will be prepended to the javascript wrapper functions. |
getWrapperPrefix | Gets the current javascript wrapper prefix. |
setLogFile | Specifies a log file that will be written to by xajax during a request. |
getLogFile | Returns the current log file path. |
registerFunction | Registers a PHP function or method with the xajax request processor. |
registerCallableObject | Registers an object whose methods will be searched for a match to the incoming request. |
registerEvent | Assigns a callback function with the specified xajax event. |
Available events: | |
Global functions |
Please see copyright.inc.php for a detailed description, copyright and license information.
Variables | |
XAJAX_DEFAULT_CHAR_ENCODING | Default character encoding used by both the xajax and xajaxResponse classes. |
XAJAX_PROCESSING_EVENT | String: XAJAX_PROCESSING_EVENT_BEFORE String: XAJAX_PROCESSING_EVENT_AFTER String: XAJAX_PROCESSING_EVENT_INVALID |
if ( !defined ('XAJAX_DEFAULT_CHAR_ENCODING') ) define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8')
Default character encoding used by both the xajax and xajaxResponse classes.
if ( !defined ('XAJAX_PROCESSING_EVENT') ) define ('XAJAX_PROCESSING_EVENT', 'xajax processing event')
String: XAJAX_PROCESSING_EVENT_BEFORE String: XAJAX_PROCESSING_EVENT_AFTER String: XAJAX_PROCESSING_EVENT_INVALID
Identifiers used to register processing events. Processing events are essentially hooks into the xajax core that can be used to add functionality into the request processing sequence.
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 | |
aSettings | This array is used to store all the configuration settings that are set during the run of the script. |
bErrorHandler | This is a configuration setting that the main xajax object tracks. |
aProcessingEvents | Stores the processing event handlers that have been assigned during this run of the script. |
bExitAllowed | A configuration option that is tracked by the main <xajax>object. |
bCleanBuffer | A configuration option that is tracked by the main xajax object. |
sLogFile | A configuration setting tracked by the main xajax object. |
sCoreIncludeOutput | This is populated with any errors or warnings produced while including the xajax core components. |
objPluginManager | This stores a reference to the global xajaxPluginManager |
objArgumentManager | Stores a reference to the global xajaxArgumentManager |
objResponseManager | Stores a reference to the global xajaxResponseManager |
objLanguageManager | Stores a reference to the global xajaxLanguageManager |
Functions | |
xajax | Constructs a xajax instance and initializes the plugin system. |
__sleep | |
__wakeup | |
getGlobalResponse | Returns the xajaxResponse object preconfigured with the encoding and entity settings from this instance of xajax. |
getVersion | |
register | Call this function to register request handlers, including functions, callable objects and events. |
configure | Call this function to set options that will effect the processing of xajax requests. |
configureMany | Set an array of configuration options. |
getConfiguration | Get the current value of a configuration setting that was previously set via xajax->configure or xajax->configureMany |
canProcessRequest | Determines if a call is a xajax request or a page load request. |
processRequest | If this is a xajax request (see <xajax->canProcessRequest>), call the requested PHP function, build the response and send it back to the browser. |
printJavascript | Prints the xajax Javascript header and wrapper code into your page. |
getJavascript | See xajax->printJavascript for more information. |
autoCompressJavascript | Creates a new xajax_core, xajax_debug, etc... |
_detectURI | Returns the current requests URL based upon the SERVER vars. |
setCharEncoding | Sets the character encoding that will be used for the HTTP output. |
getCharEncoding | Returns the current character encoding. |
setFlags | Sets a series of flags. |
setFlag | Sets a single flag (boolean true or false). |
getFlag | Returns the current value of the flag. |
setRequestURI | Sets the URI to which requests will be sent. |
getRequestURI | |
setDefaultMode | Sets the default mode for requests from the browser. |
getDefaultMode | Get the default request mode that will be used by the browser for submitting requests to the server. |
setDefaultMethod | |
getDefaultMethod | Gets the default method for making xajax requests. |
setWrapperPrefix | Sets the prefix that will be prepended to the javascript wrapper functions. |
getWrapperPrefix | Gets the current javascript wrapper prefix. |
setLogFile | Specifies a log file that will be written to by xajax during a request. |
getLogFile | Returns the current log file path. |
registerFunction | Registers a PHP function or method with the xajax request processor. |
registerCallableObject | Registers an object whose methods will be searched for a match to the incoming request. |
registerEvent | Assigns a callback function with the specified xajax event. |
Available events: |
var $aSettings
This array is used to store all the configuration settings that are set during the run of the script. This provides a single data store for the settings in case we need to return the value of a configuration option for some reason.
It is advised that individual plugins store a local copy of the settings they wish to track, however, settings are available via a reference to the xajax object using xajax->getConfiguration.
var $bExitAllowed
A configuration option that is tracked by the main <xajax>object. Setting this to true allows xajax to exit immediatly after processing a xajax request. If this is set to false, xajax will allow the remaining code and HTML to be sent as part of the response. Typically this would result in an error, however, a response processor on the client side could be designed to handle this condition.
var $bCleanBuffer
A configuration option that is tracked by the main xajax object. Setting this to true allows xajax to clear out any pending output buffers so that the xajaxResponse is (virtually) the only output when handling a request.
var $objPluginManager
This stores a reference to the global xajaxPluginManager
var $objArgumentManager
Stores a reference to the global xajaxArgumentManager
var $objResponseManager
Stores a reference to the global xajaxResponseManager
var $objLanguageManager
Stores a reference to the global xajaxLanguageManager
function &getGlobalResponse()
Returns the xajaxResponse object preconfigured with the encoding and entity settings from this instance of xajax. This is used for singleton-pattern response development.
<xajaxResponse> | A xajaxResponse object which can be used to return response commands. See also the xajaxResponseManager class. |
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.
$sType | (string): Type of request handler being registered; standard options include: XAJAX_FUNCTION: a function declared at global scope. XAJAX_CALLABLE_OBJECT: an object who’s methods are to be registered. XAJAX_EVENT: an event which will cause zero or more event handlers to be called. XAJAX_EVENT_HANDLER: register an event handler function. |
$sFunction || $objObject || $sEvent | (mixed): when registering a function, this is the name of the function when registering a callable object, this is the object being registered when registering an event or event handler, this is the name of the event |
$sIncludeFile || $aCallOptions || $sEventHandler when registering a function, this is the (optional) include file. when registering a callable object, this is an (optional) array of call options for the functions being registered. when registering an event handler, this is the name of the function.
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.
javascript URI | (string): The path to the folder that contains the xajax javascript files. |
errorHandler | (boolean): true to enable the xajax error handler, see xajax->bErrorHandler |
exitAllowed | (boolean): true to allow xajax to exit after processing a request. See xajax->bExitAllowed for more information. |
function getConfiguration( $sName )
Get the current value of a configuration setting that was previously set via xajax->configure or xajax->configureMany
$mValue | (mixed): The value of the setting if set, null otherwise. |
function processRequest()
If this is a xajax request (see <xajax->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 <xajax->bAllowExit>
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.
$sJsURI | (string, optional, deprecated): the path to the xajax javascript file(s) This option is deprecated and will be removed in future versions; instead please use xajax->configure with the option name ‘javascript URI’ |
$aJsFiles | (array, optional, deprecated): an array of xajax javascript files that will be loaded via SCRIPT tags. This option is deprecated and will be removed in future versions; please use xajax->configure with the option name ‘javascript files’ instead. |
function getJavascript( $sJsURI = '', $aJsFiles = array() )
See xajax->printJavascript for more information.
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.
sJsFullFilename | (string): The relative path and name of the file to be compressed. |
bAlways | (boolean): Compress the file, even if it already exists. |
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 XAJAX_DEFAULT_CHAR_ENCODING.
sEncoding | (string): The encoding to use. |
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getCharEncoding()
Returns the current character encoding. See also xajax->setCharEncoding and XAJAX_DEFAULT_CHAR_ENCODING
string | The character encoding. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
function setFlags( $flags )
Sets a series of flags. See also, xajax->setFlag.
flags | (array): An associative array containing the name of the flag and the value to set. |
deprecated | This function will be removed in future versions. Please use xajax->configureMany instead. |
function setFlag( $name, $value )
Sets a single flag (boolean true or false).
name | (string): The name of the flag to set. |
value | (boolean): The value to set. |
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getFlag( $name )
Returns the current value of the flag. See also xajax->setFlag.
name | (string): The name of the flag. |
boolean | The value currently associated with the flag. |
deprecated | This function will be removed in future versions. Instead, use xajax->getConfiguration. |
function setRequestURI( $sRequestURI )
Sets the URI to which requests will be sent.
sRequestURI | (string): The URI |
Note: Usage
$xajax->setRequestURI(“http://www.xajaxproject.org”);
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getRequestURI()
string | The current request URI that will be configured on the client side. This is the default URI for all requests made from the current page. See xajax->setRequestURI. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
function setDefaultMode( $sDefaultMode )
Sets the default mode for requests from the browser.
sDefaultMode | (string): The mode to set as the default. |
$xajax->setDefaultMode(“synchronous”);
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getDefaultMode()
Get the default request mode that will be used by the browser for submitting requests to the server. See also xajax->setDefaultMode
string | The default mode to be used by the browser for each request. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
function setDefaultMethod( $sMethod )
sMethod | (string): The name of the method. |
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getDefaultMethod()
Gets the default method for making xajax requests.
string | The current method configured. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
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.
sPrefix | (string): The prefix to be used. |
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getWrapperPrefix()
Gets the current javascript wrapper prefix. See also, xajax->setWrapperPrefix
string | The current wrapper prefix. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
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.
sFilename | (string): The full or reletive path to the log file. |
deprecated | This function will be removed in future versions. Please use xajax->configure instead. |
function getLogFile()
Returns the current log file path. See also xajax->setLogFile.
string | The log file path. |
deprecated | This function will be removed in future versions. Please use xajax->getConfiguration instead. |
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.
mFunction | (string or array): The string containing the function name or an array containing the following: |
sIncludeFile | (string, optional): The server path to the PHP file to include when calling this function. This will enable xajax to load only the include file that is needed for this function call, thus reducing server load. |
deprecated | This function will be removed in future versions. Please use xajax->register instead. |
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.
oObject | (object, by reference): The object whose methods will be registered. |
deprecated | This function will be removed in future versions. Please use xajax->register instead. |
mCallback | (function): The function or object callback to be assigned. |
sEventName | (string): The name of the event. |
deprecated | This function will be removed in future versions. Please use xajax->register instead. |
Default character encoding used by both the xajax and xajaxResponse classes.
if ( !defined ('XAJAX_DEFAULT_CHAR_ENCODING') ) define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8')
String: XAJAX_PROCESSING_EVENT_BEFORE String: XAJAX_PROCESSING_EVENT_AFTER String: XAJAX_PROCESSING_EVENT_INVALID
if ( !defined ('XAJAX_PROCESSING_EVENT') ) define ('XAJAX_PROCESSING_EVENT', 'xajax processing event')
This array is used to store all the configuration settings that are set during the run of the script.
var $aSettings
This is a configuration setting that the main xajax object tracks.
var $bErrorHandler
Stores the processing event handlers that have been assigned during this run of the script.
var $aProcessingEvents
A configuration option that is tracked by the main <xajax>object.
var $bExitAllowed
A configuration option that is tracked by the main xajax object.
var $bCleanBuffer
Constructs a xajax instance and initializes the plugin system.
function xajax( $sRequestURI = null, $sLanguage = null )
A configuration setting tracked by the main xajax object.
var $sLogFile
This is populated with any errors or warnings produced while including the xajax core components.
var $sCoreIncludeOutput
This stores a reference to the global xajaxPluginManager
var $objPluginManager
Stores a reference to the global xajaxArgumentManager
var $objArgumentManager
Stores a reference to the global xajaxResponseManager
var $objResponseManager
Stores a reference to the global xajaxLanguageManager
var $objLanguageManager
function __sleep()
function __wakeup()
Returns the xajaxResponse object preconfigured with the encoding and entity settings from this instance of xajax.
function &getGlobalResponse()
function getVersion()
Call this function to register request handlers, including functions, callable objects and events.
function register( $sType, $mArg )
Call this function to set options that will effect the processing of xajax requests.
function configure( $sName, $mValue )
Set an array of configuration options.
function configureMany( $aOptions )
Get the current value of a configuration setting that was previously set via xajax->configure or xajax->configureMany
function getConfiguration( $sName )
Determines if a call is a xajax request or a page load request.
function canProcessRequest()
If this is a xajax request (see <xajax->canProcessRequest>), call the requested PHP function, build the response and send it back to the browser.
function processRequest()
Prints the xajax Javascript header and wrapper code into your page.
function printJavascript( $sJsURI = "", $aJsFiles = array() )
See xajax->printJavascript for more information.
function getJavascript( $sJsURI = '', $aJsFiles = array() )
Creates a new xajax_core, xajax_debug, etc...
function autoCompressJavascript( $sJsFullFilename = NULL, $bAlways = false )
Returns the current requests URL based upon the SERVER vars.
function _detectURI()
Sets the character encoding that will be used for the HTTP output.
function setCharEncoding( $sEncoding )
Returns the current character encoding.
function getCharEncoding()
Sets a series of flags.
function setFlags( $flags )
Sets a single flag (boolean true or false).
function setFlag( $name, $value )
Returns the current value of the flag.
function getFlag( $name )
Sets the URI to which requests will be sent.
function setRequestURI( $sRequestURI )
function getRequestURI()
Sets the default mode for requests from the browser.
function setDefaultMode( $sDefaultMode )
Get the default request mode that will be used by the browser for submitting requests to the server.
function getDefaultMode()
function setDefaultMethod( $sMethod )
Gets the default method for making xajax requests.
function getDefaultMethod()
Sets the prefix that will be prepended to the javascript wrapper functions.
function setWrapperPrefix( $sPrefix )
Gets the current javascript wrapper prefix.
function getWrapperPrefix()
Specifies a log file that will be written to by xajax during a request.
function setLogFile( $sFilename )
Returns the current log file path.
function getLogFile()
Registers a PHP function or method with the xajax request processor.
function registerFunction( $mFunction, $sIncludeFile = null )
Registers an object whose methods will be searched for a match to the incoming request.
function registerCallableObject( & $oObject )