0.5 Documentation






0.5 Documentation

Contents

[edit] Inital Setup

[edit] require()

Initialize the xajax script.

require('xajax_core/xajax.inc.php')

[edit] xajax()

Sets up the xajax object and the plugin system

$xajax = new xajax($sRequestURI)
  • string $sRequestURI: optional request URI; defaults to the current browser URI


[edit] registerFunction()

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.

$xajax->registerFunction($mFunction,$sIncludeFile=null)
  • mixed $mFunction: contains the function name or an object callback array string
  • string $sIncludeFile: optional; an external PHP file to include before the function is called

[edit] xajax.inc.php

[edit] getVersion()

Returns the current xajax version.

$xajax->getVersion()


[edit] setFlag()

Sets a flag (boolean true or false).

Defaults

  • debug: false
  • statusMessages: false
  • waitCursor: true
  • exitAllowed: true
  • errorHandler: false
  • cleanBuffer: false
  • decodeUTF8Input: false
  • outputEntities: false
  • allowBlankResponse: false
$xajax->setFlag($name,$value)
  • string $name: name of flag
  • boolean $value: if true set flag


[edit] getFlag()

Returns the value of the flag boolean, returns true or false for that flag

$xajax->getFlag($name)
  • string $name: name of flag


[edit] setTimeout()

Sets the timeout before xajax notifies the client that xajax has not been loaded

$xajax->setTimeout($iTimeout)
  • integer $iTimeout: the number of milliseconds, or 0 to disable


[edit] getTimeout()

Returns the xajax Javascript timeout

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

$xajax->getTimeout()


[edit] setWrapperPrefix()

Sets the prefix that will be appended to the Javascript wrapper

$xajax->setWrapperPrefix($sPrefix)
  • string $sPrefix: name of the wrapper, (default is "xajax_").


[edit] getWrapperPrefix()

Returns the Javascript wrapper prefix

$xajax->getWrapperPrefix()


[edit] setLogFile()

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.

$xajax->setLogFile($sFilename)
  • string $sFilename: name of the log file.


[edit] getLogFile()

Returns the log file to use for error output

returns a string or "" if no log is being used.

$xajax->getLogFile()


[edit] setCharEncoding()

Sets the character encoding for the HTTP output

$xajax->setCharEncoding($sEncoding)
  • string $sEncoding: the encoding type to use (utf-8, iso-8859-1, etc.)


[edit] getCharEncoding()

Returns the character encoding for the HTTP output

$xajax->getCharEncoding()


[edit] registerEvent()

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
$xajax->registerEvent($mCallback$sEventName)
  • mixed $mCallback: standard PHP function or object callback
  • string $sEventName: name of the event

[edit] 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)
$xajax->canProcessRequest()


[edit] getRequestMode()

Returns the current request mode

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

$xajax->getRequestMode()


[edit] 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)

$xajax->processRequest()


[edit] printJavascript()

Prints the xajax Javascript header and wrapper code.

It should only be called between the
<head> </head>
tags in your HTML page. Remember, if you only want to obtain the result of this function, use {@link xajax::getJavascript()} instead. (executes Javascript include plugin)
$xajax->printJavascript($sJsURI=""$sJsFile=NULL)
  • 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.


[edit] getJavascript()

Returns the xajax Javascript code

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

$xajax->getJavascript($sJsURI=""$sJsFile=NULL)
  • 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.


[edit] 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)

$xajax->getJavascriptConfig()


[edit] getJavascriptInclude()

Returns a string containing a Javascript include of the xajax.js file

a check to see if the file loaded after x seconds. typically called internally by xajax from get/printJavascript. (executes Javascript include plugin)

$xajax->getJavascriptInclude($sJsURI=""$sJsFile=NULL)
  • 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.


[edit] autoCompressJavascript()

create a new xajax.js file out of the xajax_uncompressed.js file

Will only happen if xajax.js doesn't already exist on the filesystem

$xajax->autoCompressJavascript($sJsFullFilename=NULL)
  • string $sJsFullFilename: an optional argument containing the full server file path of xajax.js.


[edit] _detectURI()

Returns the current URL based upon the SERVER vars.

returns a string

$xajax->_detectURI()


[edit] xajaxResponse.inc.php

[edit] assign()

Adds an assign command message to the response. Replaces data from the element specified.

$objResponse->assign($sTarget,$sAttribute,$sData)
  • string $sTarget: contains the id of an HTML element
  • string $sAttribute: the part of the element you wish to modify. innerHTML,value etc..
  • string $sData: the data you want to set the attribute to


[edit] append()

Adds an append command message to the response. Adds data after the element specified.

$objResponse->append($sTarget,$sAttribute,$sData)
  • string $sTarget: contains the id of an HTML element
  • string $sAttribute: the part of the element you wish to modify. innerHTML,value etc..
  • string $sData: the data you want to append to the end of the attribute


[edit] prepend()

Adds an prepend command message to the response. Adds data before the element specified.

$objResponse->prepend($sTarget,$sAttribute,$sData)
  • string $sTarget: contains the id of an HTML element
  • string $sAttribute: the part of the element you wish to modify. innerHTML,value etc..
  • string $sData: the data you want to prepend to the end of the attribute


[edit] replace()

Adds a replace command message to the response. Replaces the string specified in the element specified.

$objResponse->replace($sTarget,$sAttribute,$sSearch,$sData)
  • string $sTarget: contains the id of an HTML element
  • string $sAttribute: the part of the element you wish to modify. innerHTML,value etc..
  • string $sSearch: the string to search for
  • string $sData: the string to replace the search string when found in the attribute


[edit] clear()

Adds a clear command message to the response. Clears the element specified.

$objResponse->clear($sTarget,$sAttribute)
  • string $sTarget: contains the id of an HTML element
  • string $sAttribute: the part of the element you wish to modify. innerHTML,value etc..


[edit] alert()

Adds an alert command message to the response.

$objResponse->alert($sMsg)
  • string $sMsg: the text to be displayed in the Javascript alert box


[edit] redirect()

Redirects to another url

$objResponse->redirect($sURL$iDelay=0)
  • string $sURL: the URL to redirect the client browser to
  • string $iDelay: the delay


[edit] script()

Adds a Javascript command message to the response.

$objResponse->script($sJS)
  • string $sJS: contains Javascript code to be executed


[edit] call()

Adds a Javascript function call command message to the response.

$objResponse->call($sFunc,$args)
  • string $sFunc: the name of a Javascript function
  • mixed $args: optional arguments to pass to the Javascript function


[edit] remove()

Adds a remove element command message to the response.

$objResponse->remove($sTarget)
  • string $sTarget: contains the id of an HTML element to be removed


[edit] create()

Adds a create element command message to the response.

$objResponse->create($sParent$sTag$sId$sType="")
  • string $sParent: contains the id of an HTML element to to which the new element will be appended.
  • string $sTag: the tag to be added
  • string $sId: the id to be assigned to the new element
  • string $sType: deprecated, use the CreateInput() method instead. This is optional.


[edit] insert()

Adds a insert element command message to the response.

$objResponse->insert($sBefore$sTag$sId)
  • string $sBefore: contains the id of the child before which the new element will be inserted
  • string $sTag: the tag to be added
  • string $sId: the id to be assigned to the new element

[edit] insertAfter()

Adds a insert element command message to the response.

$objResponse->insertAfter($sAfter$sTag$sId)
  • string $sAfter: contains the id of the child after which the new element will be inserted
  • string $sTag: the tag to be added
  • string $sId: the id to be assigned to the new element

[edit] createInput()

Adds a create input command message to the response.

$objResponse->createInput($sParent$sType$sName$sId)
  • string $sParent: string contains the id of an HTML element to which the new input will be appended
  • string $sType: the type of input to be created (text, radio, checkbox,etc.)
  • string $sName: the name to be assigned to the new input and the variable name when it is submitted
  • string $sId: the id to be assigned to the new input


[edit] insertInput()

Adds an insert input command message to the response.

$objResponse->insertInput($sBefore$sType$sName$sId)
  • string $sParent: contains the id of the child before which the new element will be inserted
  • string $sType: the type of input to be created (text, radio, checkbox,etc.)
  • string $sName: the name to be assigned to the new input and the variable name when it is submitted
  • string $sId: the id to be assigned to the new input


[edit] insertInputAfter()

Adds an insert input command message to the response.

$objResponse->insertInputAfter($sBefore$sType$sName$sId)
  • string $sBefore: contains the id of the child after which the new element will be inserted
  • string $sType: the type of input to be created (text, radio, checkbox,etc.)
  • string $sName: the name to be assigned to the new input and the variable name when it is submitted
  • string $sId: the id to be assigned to the new input

[edit] addEvent()

Adds an event command message to the response.

$objResponse->addEvent($sTarget,$sEvent,$sScript)
  • string $sTarget: contains the id of an HTML element
  • string $sEvent: the event you wish to set ("onclick", "onmouseover", etc.)
  • string $sScript: the Javascript string you want the event to invoke


[edit] addHandler()

Adds a handler command message to the response.

$objResponse->addHandler($sTarget,$sEvent,$sHandler)
  • string $sTarget: contains the id of an HTML element
  • string $sEvent: the event you wish to set ("onclick", "onmouseover", etc.)
  • string $sHandler: the name of a Javascript function that will handle the event. Multiple handlers can be added for the same event

[edit] removeHandler()

Adds a remove handler command message to the response.

$objResponse->removeHandler($sTarget,$sEvent,$sHandler)
  • string $sTarget: contains the id of an HTML element
  • string $sEvent: the event you wish to set ("onclick", "onmouseover", etc.)
  • string $sHandler: the name of a Javascript handler function that you want to remove

[edit] includeScript()

Adds an include script command message to the response.

$objResponse->includeScript($sFileName)
  • string $sFileName: URL of the Javascript file to include


[edit] includeScriptOnce()

Adds an include script once command message to the response.

$objResponse->includeScriptOnce($sFileName)
  • string $sFileName: URL of the Javascript file to include

[edit] removeScript()

Adds a remove script command message to the response.

$objResponse->removeScript($sFileName$sUnload);
  • string $sFileName: URL of the Javascript file to remove
  • string $sUnload:(STRING) script to run before removing reference if it exists (can be used to call an unload function)

[edit] includeCSS()

Adds an include CSS command message to the response.

$objResponse->includeCSS($sFileName)
  • string $sFileName: URL of the CSS file to include


[edit] removeCSS()

Adds a remove CSS command message to the response.

$objResponse->removeCSS($sFileName)
  • string $sFileName: URL of the CSS file to remove


[edit] waitForCSS()

Waits for the CSS files to finish loading before concluding the xajax request.

$objResponse->waitForCSS()


[edit] getContentType()

Returns the content type of the response (typically "text/xml").

$objResponse->getContentType()


[edit] getOutput()

Returns the output of the response suitable for sending to a Web browser (i. e., XML or JSON)

$objResponse->getOutput()


[edit] getCommandCount()

Returns the number of commands current in the response

$objResponse->getCommandCount()


[edit] loadCommands()

Adds the commands of the provided response to this response object

$objResponse2->loadCommands($objResponse1); return $objResponse2;

$objResponse->($mCommands$bBefore=false)
  • mixed$mCommands:the response object to add to the end of this response object, or an array of response commands
  • boolean$bBefore: True to add to the front of, false to add to the back of the array