xajax
[ class tree: xajax ] [ index: xajax ] [ all elements ]

Class: xajax

Source Location: /vendors/xajax/xajax.inc.php

Class Overview


The xajax class generates the xajax javascript for your page including the Javascript wrappers for the PHP functions that you want to call from your page.


Variables

Methods



Class Details

[line 75]
The xajax class generates the xajax javascript for your page including the Javascript wrappers for the PHP functions that you want to call from your page.

It also handles processing and executing the command messages in the XML responses sent back to your page from your PHP functions.




[ Top ]


Class Variables

$aFunctionIncludeFiles =

[line 95]



Tags:

var:  Array of Include Files for any external functions (key=function name)
access:  protected

Type:   array


[ Top ]

$aFunctionRequestTypes =

[line 91]



Tags:

var:  Array of RequestTypes to be used with each function (key=function name)
access:  protected

Type:   array


[ Top ]

$aFunctions =

[line 83]



Tags:

var:  Array of PHP functions that will be callable through javascript wrappers
access:  protected

Type:   array


[ Top ]

$aObjArray =

[line 155]



Tags:

var:  Array for parsing complex objects
access:  protected

Type:   array


[ Top ]

$aObjects =

[line 87]



Tags:

var:  Array of object callbacks that will allow Javascript to call PHP methods (key=function name)
access:  protected

Type:   array


[ Top ]

$bCleanBuffer =

[line 139]



Tags:

var:  Clean all output buffers before outputting response (default false)
access:  protected

Type:   boolean


[ Top ]

$bDebug =

[line 115]



Tags:

var:  Show debug messages (default false)
access:  protected

Type:   boolean


[ Top ]

$bDecodeUTF8Input =

[line 147]



Tags:

var:  Decode input request args from UTF-8 (default false)
access:  protected

Type:   boolean


[ Top ]

$bErrorHandler =

[line 131]



Tags:

var:  Use an special xajax error handler so the errors are sent to the browser properly (default false)
access:  protected

Type:   boolean


[ Top ]

$bExitAllowed =

[line 123]



Tags:

var:  Allow xajax to exit after processing a request (default true)
access:  protected

Type:   boolean


[ Top ]

$bOutputEntities =

[line 151]



Tags:

var:  Convert special characters to HTML entities (default false)
access:  protected

Type:   boolean


[ Top ]

$bStatusMessages =

[line 119]



Tags:

var:  Show messages in the client browser's status bar (default false)
access:  protected

Type:   boolean


[ Top ]

$bWaitCursor =

[line 127]



Tags:

var:  Use wait cursor in browser (default true)
access:  protected

Type:   boolean


[ Top ]

$iPos =

[line 159]



Tags:

var:  Position in $aObjArray
access:  protected

Type:   integer


[ Top ]

$iTimeout =

[line 163]



Tags:

var:  The number of milliseconds to wait before checking if xajax is loaded in the client, or 0 to disable (default 6000)
access:  protected

Type:   integer


[ Top ]

$sCatchAllFunction =

[line 99]



Tags:

var:  Name of the PHP function to call if no callable function was found
access:  protected

Type:   string


[ Top ]

$sEncoding =

[line 143]



Tags:

var:  String containing the character encoding used
access:  protected

Type:   string


[ Top ]

$sLogFile =

[line 135]



Tags:

var:  Specify what, if any, file xajax should log errors to (and more information in a future release)
access:  protected

Type:   string


[ Top ]

$sPreFunction =

[line 103]



Tags:

var:  Name of the PHP function to call before any other function
access:  protected

Type:   string


[ Top ]

$sRequestURI =

[line 107]



Tags:

var:  The URI for making requests to the xajax object
access:  protected

Type:   string


[ Top ]

$sWrapperPrefix =

[line 111]



Tags:

var:  The prefix to prepend to the javascript wraper function name
access:  protected

Type:   string


[ Top ]



Class Methods


constructor xajax [line 176]

xajax xajax( [string $sRequestURI = ""], [string $sWrapperPrefix = "xajax_"], [string $sEncoding = XAJAX_DEFAULT_CHAR_ENCODING], [boolean $bDebug = false])

Constructor. You can set some extra xajax options right away or use individual methods later to set options.



Parameters:

string   $sRequestURI   defaults to the current browser URI
string   $sWrapperPrefix   defaults to "xajax_";
string   $sEncoding   defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
boolean   $bDebug   defaults to false

[ Top ]

method autoCompressJavascript [line 918]

void autoCompressJavascript( [string $sJsFullFilename = NULL])

This method can be used to create a new xajax.js file out of the xajax_uncompressed.js file (which will only happen if xajax.js doesn't already exist on the filesystem).



Parameters:

string   $sJsFullFilename   an optional argument containing the full server file path of xajax.js.

[ Top ]

method canProcessRequests [line 593]

boolean canProcessRequests( )

Returns true if xajax can process the request, false if otherwise.

You can use this to determine if xajax needs to process the request or not.




[ Top ]

method cleanBufferOff [line 417]

void cleanBufferOff( )

Turns off xajax's output buffer cleaning.



[ Top ]

method cleanBufferOn [line 410]

void cleanBufferOn( )

Causes xajax to clean out all output buffers before outputting a response (default behavior).



[ Top ]

method debugOff [line 322]

void debugOff( )

Disables debug messages for xajax (default behavior).



[ Top ]

method debugOn [line 314]

void debugOn( )

Enables debug messages for xajax.



[ Top ]

method decodeUTF8InputOff [line 450]

void decodeUTF8InputOff( )

Turns off decoding the input request args from UTF-8 (default behavior).



[ Top ]

method decodeUTF8InputOn [line 442]

void decodeUTF8InputOn( )

Causes xajax to decode the input request args from UTF-8 to the current encoding if possible. Either the iconv or mb_string extension must be present for optimal functionality.



[ Top ]

method errorHandlerOff [line 390]

void errorHandlerOff( )

Turns off xajax's error handling system (default behavior).



[ Top ]

method errorHandlerOn [line 382]

void errorHandlerOn( )

Turns on xajax's error handling system so that PHP errors that occur during a request are trapped and pushed to the browser in the form of a Javascript alert.



[ Top ]

method exitAllowedOff [line 372]

void exitAllowedOff( )

Disables xajax's default behavior of exiting immediately after processing a request and sending the response back to the browser.



[ Top ]

method exitAllowedOn [line 363]

void exitAllowedOn( )

Enables xajax to exit immediately after processing a request and sending the response back to the browser (default behavior).



[ Top ]

method getFlag [line 255]

boolean getFlag( $name)

Returns the value of the flag



Parameters:

   $name  

[ Top ]

method getJavascript [line 844]

string getJavascript( [string $sJsURI = ""], [string $sJsFile = NULL])

Returns the xajax Javascript code that should be added to your HTML page between the <head> </head> tags.

Usage:

  1.   < ?php $xajaxJSHead $xajax->getJavascript()? >
  2.     <head>
  3.         ...
  4.         < ?php echo $xajaxJSHead? >




Parameters:

string   $sJsURI   the relative address of the folder where xajax has been installed. For instance, if your PHP file is "http://www.myserver.com/myfolder/mypage.php" and xajax was installed in "http://www.myserver.com/anotherfolder", then $sJsURI should be set to "../anotherfolder". Defaults to assuming xajax is in the same folder as your PHP file.
string   $sJsFile   the relative folder/file pair of the xajax Javascript engine located within the xajax installation folder. Defaults to xajax_js/xajax.js.

[ Top ]

method getJavascriptConfig [line 858]

string getJavascriptConfig( )

Returns a string containing inline Javascript that sets up the xajax runtime (typically called internally by xajax from get/printJavascript).



[ Top ]

method getJavascriptInclude [line 894]

string getJavascriptInclude( [string $sJsURI = ""], [string $sJsFile = NULL])

Returns a string containing a Javascript include of the xajax.js file along with a check to see if the file loaded after six seconds (typically called internally by xajax from get/printJavascript).



Parameters:

string   $sJsURI   the relative address of the folder where xajax has been installed. For instance, if your PHP file is "http://www.myserver.com/myfolder/mypage.php" and xajax was installed in "http://www.myserver.com/anotherfolder", then $sJsURI should be set to "../anotherfolder". Defaults to assuming xajax is in the same folder as your PHP file.
string   $sJsFile   the relative folder/file pair of the xajax Javascript engine located within the xajax installation folder. Defaults to xajax_js/xajax.js.

[ Top ]

method getRequestMode [line 605]

mixed getRequestMode( )

Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if there is none.



[ Top ]

method getTimeout [line 282]

integer getTimeout( )

Returns the xajax Javascript timeout



Tags:

return:  the number of milliseconds (or 0 if disabled)


[ Top ]

method getVersion [line 203]

string getVersion( )

Returns the current xajax version.



[ Top ]

method outputEntitiesOff [line 468]

void outputEntitiesOff( )

Tells the response object to output special characters intact. (default behavior).



[ Top ]

method outputEntitiesOn [line 459]

void outputEntitiesOn( )

Tells the response object to convert special characters to HTML entities automatically (only works if the mb_string extension is available).



[ Top ]

method printJavascript [line 815]

void printJavascript( [string $sJsURI = ""], [string $sJsFile = NULL])

Prints the xajax Javascript header and wrapper code into your page by printing the output of the getJavascript() method. It should only be called between the
 
tags in your HTML page.

Remember, if you only want to obtain the result of this function, use xajax::getJavascript() instead.

Usage:

  1.   <head>
  2.         ...
  3.         < ?php $xajax->printJavascript()? >




Parameters:

string   $sJsURI   the relative address of the folder where xajax has been installed. For instance, if your PHP file is "http://www.myserver.com/myfolder/mypage.php" and xajax was installed in "http://www.myserver.com/anotherfolder", then $sJsURI should be set to "../anotherfolder". Defaults to assuming xajax is in the same folder as your PHP file.
string   $sJsFile   the relative folder/file pair of the xajax Javascript engine located within the xajax installation folder. Defaults to xajax_js/xajax.js.

[ Top ]

method processRequest [line 616]

void processRequest( )



[ Top ]

method processRequests [line 629]

void processRequests( )

This is the main communications engine of xajax. The engine handles all

incoming xajax requests, calls the apporiate PHP functions (or class/object methods) and passes the XML responses back to the Javascript response handler. If your RequestURI is the same as your Web page then this function should be called before any headers or HTML has been sent.




[ Top ]

method registerCatchAllFunction [line 549]

void registerCatchAllFunction( string $mFunction)

Registers a PHP function to be called when xajax cannot find the

function being called via Javascript. Because this is technically impossible when using "wrapped" functions, the catch-all feature is only useful when you're directly using the xajax.call() Javascript method. Use the catch-all feature when you want more dynamic ability to intercept unknown calls and handle them in a custom way.

Usage: $xajax->registerCatchAllFunction("myCatchAllFunction");




Parameters:

string   $mFunction   contains the function name or an object callback array (see registerFunction for more info on object callback arrays)

[ Top ]

method registerExternalFunction [line 523]

void registerExternalFunction( string $mFunction, string $sIncludeFile, [mixed $sRequestType = XAJAX_POST])

Registers a PHP function to be callable through xajax which is located in some other file. If the function is requested the external file will be included to define the function before the function is called.

Usage: $xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);




Parameters:

string   $mFunction   contains the function name or an object callback array (see registerFunction for more info on object callback arrays)
string   $sIncludeFile   contains the path and filename of the include file
mixed   $sRequestType   the RequestType (XAJAX_GET/XAJAX_POST) that should be used for this function. Defaults to XAJAX_POST.

[ Top ]

method registerFunction [line 492]

void registerFunction( mixed $mFunction, [mixed $sRequestType = XAJAX_POST])

Registers a PHP function or method to be callable through xajax in your

Javascript. If you want to register a function, pass in the name of that function. If you want to register a static class method, pass in an array like so: array("myFunctionName", "myClass", "myMethod") For an object instance method, use an object variable for the second array element (and in PHP 4 make sure you put an & before the variable to pass the object by reference). Note: the function name is what you call via Javascript, so it can be anything as long as it doesn't conflict with any other registered function name.

Usage: $xajax->registerFunction("myFunction"); or: $xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));




Parameters:

mixed   $mFunction   contains the function name or an object callback array
mixed   $sRequestType   request type (XAJAX_GET/XAJAX_POST) that should be used for this function. Defaults to XAJAX_POST.

[ Top ]

method registerPreFunction [line 575]

void registerPreFunction( string $mFunction)

Registers a PHP function to be called before xajax calls the requested

function. xajax will automatically add the request function's response to the pre-function's response to create a single response. Another feature is the ability to return not just a response, but an array with the first element being false (a boolean) and the second being the response. In this case, the pre-function's response will be returned to the browser without xajax calling the requested function.

Usage: $xajax->registerPreFunction("myPreFunction");




Parameters:

string   $mFunction   contains the function name or an object callback array (see registerFunction for more info on object callback arrays)

[ Top ]

method setCharEncoding [line 432]

void setCharEncoding( string $sEncoding)

Sets the character encoding for the HTTP output based on

$sEncoding, which is a string containing the character encoding to use. You don't need to use this method normally, since the character encoding for the response gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING constant. Usage: $xajax->setCharEncoding("utf-8");




Parameters:

string   $sEncoding   the encoding type to use (utf-8, iso-8859-1, etc.)

[ Top ]

method setFlag [line 239]

void setFlag( string $name, boolean $value)

Sets a flag (boolean true or false). Available flags with their defaults are as follows:

  • debug: false
  • statusMessages: false
  • waitCursor: true
  • exitAllowed: true
  • errorHandler: false
  • cleanBuffer: false
  • decodeUTF8Input: false
  • outputEntities: false




Parameters:

string   $name   name of flag
boolean   $value  

[ Top ]

method setFlags [line 214]

void setFlags( array $flags)

Sets multiple flags based on the supplied associative array (see xajax::setFlag() for flag names)



Parameters:

array   $flags  

[ Top ]

method setLogFile [line 401]

void setLogFile( $sFilename)

Specifies a log file that will be written to by xajax during a request (used only by the error handling system at present). If you don't invoke this method, or you pass in "", then no log file will be written to.

Usage: $xajax->setLogFile("/xajax_logs/errors.log");




Parameters:

   $sFilename  

[ Top ]

method setRequestURI [line 294]

void setRequestURI( string $sRequestURI)

Sets the URI to which requests will be made.

Usage: $xajax->setRequestURI("http://www.xajaxproject.org");




Parameters:

string   $sRequestURI   the URI (can be absolute or relative) of the PHP script that will be accessed when an xajax request occurs

[ Top ]

method setTimeout [line 272]

void setTimeout( integer $iTimeout)

Sets the timeout before xajax notifies the client that xajax has not been loaded Usage: $xajax->setTimeout(6000);



Parameters:

integer   $iTimeout   the number of milliseconds, or 0 to disable

[ Top ]

method setWrapperPrefix [line 306]

void setWrapperPrefix( string $sPrefix)

Sets the prefix that will be appended to the Javascript wrapper functions (default is "xajax_").



Parameters:

string   $sPrefix  

[ Top ]

method statusMessagesOff [line 338]

void statusMessagesOff( )

Disables messages in the browser's status bar for xajax (default behavior).



[ Top ]

method statusMessagesOn [line 330]

void statusMessagesOn( )

Enables messages in the browser's status bar for xajax.



[ Top ]

method waitCursorOff [line 354]

void waitCursorOff( )

Disables the wait cursor to be displayed in the browser.



[ Top ]

method waitCursorOn [line 346]

void waitCursorOn( )

Enables the wait cursor to be displayed in the browser (default behavior).



[ Top ]


Documentation generated on Mon, 05 Sep 2011 20:34:55 -0500 by phpDocumentor 1.4.3