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

Class: xajax

Source Location: /pem-includes/xajax/xajax_core/xajax.inc.php

Class Overview


The xajax class uses a modular plug-in system to facilitate the processing


Variables

Methods


Child classes:

legacyXajax
The xajax class uses a modular plug-in system to facilitate the processing

Class Details

[line 68]
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, and it handles the output of response objects (see xajaxResponse). Many different flags and settings can be adjusted to alter the behavior of the xajax class as well as the client-side Javascript.




[ Top ]


Class Variables

$aCallableObjects =

[line 85]



Tags:

var:  Objects with methods that can be called via xajax.call()
access:  protected

Type:   array


[ Top ]

$aEventCallbacks =

[line 89]



Tags:

var:  Array of callbacks for xajax events
access:  protected

Type:   array


[ Top ]

$aFunctions =

[line 81]



Tags:

var:  Array of PHP functions that will be callable through Javascript wrappers. Format is key=function name, value is assoc. array: "callback"=function or object/class method callback, "include"=PHP file to include (optional)
access:  protected

Type:   array


[ Top ]

$bAllowAllResponseTypes =

[line 154]



Tags:

var:  Allow xajax to send a response back to the client whether or not it is an xajaxResponse (default false)
access:  protected

Type:   boolean


[ Top ]

$bAllowBlankResponse =

[line 149]



Tags:

var:  Allow xajax to send a blank response back to the client (default false)
access:  protected

Type:   boolean


[ Top ]

$bCleanBuffer =

[line 129]



Tags:

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

Type:   boolean


[ Top ]

$bDebug =

[line 101]



Tags:

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

Type:   boolean


[ Top ]

$bDecodeUTF8Input =

[line 137]



Tags:

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

Type:   boolean


[ Top ]

$bErrorHandler =

[line 121]



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 113]



Tags:

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

Type:   boolean


[ Top ]

$bOutputEntities =

[line 141]



Tags:

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

Type:   boolean


[ Top ]

$bStatusMessages =

[line 109]



Tags:

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

Type:   boolean


[ Top ]

$bUseUncompressedScripts =

[line 105]



Tags:

var:  Use the uncompressed versions of the Javascript
access:  protected

Type:   boolean


[ Top ]

$bWaitCursor =

[line 117]



Tags:

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

Type:   boolean


[ Top ]

$iTimeout =

[line 145]



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 ]

$sEncoding =

[line 133]



Tags:

var:  String containing the character encoding used
access:  protected

Type:   string


[ Top ]

$sLogFile =

[line 125]



Tags:

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

Type:   string


[ Top ]

$sRequestURI =

[line 93]



Tags:

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

Type:   string


[ Top ]

$sWrapperPrefix =

[line 97]



Tags:

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

Type:   string


[ Top ]



Class Methods


constructor xajax [line 163]

xajax xajax( [string $sRequestURI = ''])

Sets up the xajax object and the plugin system



Parameters:

string   $sRequestURI   optional request URI; defaults to the current browser URI

[ Top ]

method autoCompressJavascript [line 683]

void autoCompressJavascript( [string $sJsFullFilename = NULL], [ $bAlways = false])

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.
   $bAlways  

[ Top ]

method canProcessRequest [line 522]

boolean canProcessRequest( )

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. (executes request processor plugin)




[ Top ]

method getCharEncoding [line 401]

string getCharEncoding( )

Returns the character encoding for the HTTP output



[ Top ]

method getFlag [line 284]

boolean getFlag( $name)

Returns the value of the flag



Parameters:

   $name  

[ Top ]

method getGlobalResponse [line 216]

xajaxResponse &getGlobalResponse( )

Returns an xajaxResponse object set up with this xajax object's encoding and entity settings. Use this for singleton-pattern response development.



[ Top ]

method getJavascript [line 622]

string getJavascript( [string $sJsURI = ''], [array $aJsFiles = array()])

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

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.
array   $aJsFiles   an array of arrays. Each sub-array should contain two script elements: the relative folder/file pair of the Javascript engine component (e.g. "xajax_js/xajax_debug.js"), and the name of the component (e.g. "xajax.debug"). Optional

[ Top ]

method getJavascriptConfig [line 638]

string getJavascriptConfig( )

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

(executes Javascript include plugin)




[ Top ]

method getJavascriptInclude [line 666]

string getJavascriptInclude( [string $sJsURI = ''], [array $aJsFiles = array()])

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).

(executes Javascript include plugin)




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.
array   $aJsFiles   an array of arrays. Each sub-array should contain two script elements: the relative folder/file pair of the Javascript engine component (e.g. "xajax_js/xajax_debug.js"), and the name of the component (e.g. "xajax.debug"). Optional

[ Top ]

method getLogFile [line 376]

string getLogFile( )

Returns the log file to use for error output (or "" if no log file is to be used)



[ Top ]

method getRegisteredCallableObjects [line 500]

array getRegisteredCallableObjects( )

Returns an associative array of callable objects



[ Top ]

method getRegisteredEvents [line 510]

array getRegisteredEvents( )

Returns an associative array of event definitions



[ Top ]

method getRegisteredFunctions [line 490]

array getRegisteredFunctions( )

Returns an associative array of registered function definitions



[ Top ]

method getRequestMode [line 535]

mixed getRequestMode( )

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



[ Top ]

method getRequestURI [line 333]

string getRequestURI( )

Returns the current request URI



[ Top ]

method getTimeout [line 311]

integer getTimeout( )

Returns the xajax Javascript timeout



Tags:

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


[ Top ]

method getVersion [line 230]

string getVersion( )

Returns the current xajax version.



[ Top ]

method getWrapperPrefix [line 354]

string getWrapperPrefix( )

Returns the Javascript wrapper prefix



[ Top ]

method printJavascript [line 587]

void printJavascript( [string $sJsURI = ""], [array $aJsFiles = array()])

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. (executes Javascript include plugin)

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.
array   $aJsFiles   an array of arrays. Each sub-array should contain two script elements: the relative folder/file pair of the Javascript engine component (e.g. "xajax_js/xajax_debug.js"), and the name of the component (e.g. "xajax.debug"). Optional

[ Top ]

method processRequest [line 550]

void processRequest( )

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 response 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. (executes request processor plugin)




[ Top ]

method registerCallableObject [line 451]

void registerCallableObject( &$oObject)

Registers an object whose methods will be searched for a match to the incoming request function name. If more than one callable object is registered, the first object that contains a method having the same name as the incoming function will be called.



Parameters:

   &$oObject  

[ Top ]

method registerEvent [line 475]

void registerEvent( mixed $mCallback, string $sEventName)

Registers a callback with an xajax event. Available events are:

  • beforeProcessing -- triggered before the request is processed
  • afterProcessing -- triggered after the request is processed
  • onMissingFunction -- triggered if no function/method could be found
  • onProcessingError -- triggered if there were an error during the request processing




Parameters:

mixed   $mCallback   standard PHP function or object callback
string   $sEventName   name of the event

[ Top ]

method registerFunction [line 425]

void registerFunction( mixed $mFunction, [string $sIncludeFile = null])

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
string   $sIncludeFile   a PHP file to include before the function is called (optional)

[ Top ]

method setCharEncoding [line 391]

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 268]

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
  • allowBlankResponse: false
  • allowAllResponseTypes: false




Parameters:

string   $name   name of flag
boolean   $value  

[ Top ]

method setFlags [line 241]

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 365]

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 323]

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 301]

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 344]

void setWrapperPrefix( string $sPrefix)

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



Parameters:

string   $sPrefix  

[ Top ]


Documentation generated on Tue, 21 Aug 2007 14:49:55 -0500 by phpDocumentor 1.4.0a2