xajaxResponse. inc.phpContains the response class. Summary | Contains the response class. | | Please see copyright.inc.php for a detailed description, copyright and license information. | | Collect commands to be sent back to the browser in response to a xajax request. | | | | Stores the commands that will be sent to the browser in the response. | | The name of the encoding method you wish to use when dealing with special characters. | | Convert special characters to the HTML equivellent. | | A reference to the global plugin manager. | | | | Create and initialize a xajaxResponse object. | | Overrides the default character encoding (or the one specified in the constructor) to the specified character encoding. | | Convert special characters to their HTML equivellent automatically (only works if the mb_string extension is available). | | Provides access to registered response plugins. | | Magic function for PHP 5. | | Response command that prompts user with [ok] [cancel] style message box. | | Response command indicating that the specified value should be assigned to the given element’s attribute. | | Response command that indicates the specified data should be appended to the given element’s property. | | Response command to prepend the specified value onto the given element’s property. | | Replace a specified value with another value within the given element’s property. | | Response command used to clear the specified property of the given element. | | Response command used to assign a value to a member of a javascript object (or element) that is specified by the context member of the request. | | Response command used to append a value onto the specified member of the javascript context object (or element) specified by the context member of the request. | | Response command used to prepend the speicified data to the given member of the current javascript object specified by context in the current request. | | Response command used to clear the value of the property specified in the sAttribute parameter. | | Response command that is used to display an alert message to the user. | | Response command that causes the browser to navigate to the specified URL. | | Response command that is used to execute a portion of javascript on the browser. | | Response command that indicates that the specified javascript function should be called with the given (optional) parameters. | | Response command used to remove an element from the document. | | Response command used to create a new element on the browser. | | Response command used to insert a new element just prior to the specified element. | | Response command used to insert a new element after the specified one. | | Response command used to create an input element on the browser. | | Response command used to insert a new input element preceeding the specified element. | | Response command used to insert a new input element after the specified element. | | Response command used to set an event handler on the browser. | | Response command used to install an event handler on the specified element. | | Response command used to remove an event handler from an element. | | Response command used to construct a javascript function on the browser. | | Response command used to construct a wrapper function around and existing javascript function on the browser. | | Response command used to load a javascript file on the browser. | | Response command used to include a javascript file on the browser if it has not already been loaded. | | Response command used to remove a SCRIPT reference to a javascript file on the browser. | | Response command used to include a LINK reference to the specified CSS file on the browser. | | Response command used to remove a LINK reference to a CSS file on the browser. | | Response command instructing xajax to pause while the CSS files are loaded. | | Response command instructing xajax to delay execution of the response commands until a specified condition is met. | | Response command which instructs xajax to pause execution of the response commands, returning control to the browser so it can perform other commands asynchronously. | | Stores a value that will be passed back as part of the response. | | Returns the current content type that will be used for the response packet. | | | | Prints the output, generated from the commands added to the response, that will be sent to the browser. | | Used internally to generate the response headers. | | | | | | Adds a response command that is generated by a plugin. | | Add a response command to the array of commands that will be sent to the browser. | | Used internally to print XML start tag. | | Used internally to generate the command output. | | Prints an XML representation of the command. | | Prints an XML representation of a php array suitable for inclusion in the response to the browser. | | Escape the specified data if necessary, so special characters in the command data does not interfere with the structure of the response. | | Recursively serializes a data structure in an array so that it can be sent to the browser. |
xajax response classPlease see copyright.inc.php for a detailed description, copyright and license information.
xajaxResponseCollect commands to be sent back to the browser in response to a xajax request. Commands are encoded and packaged in a format that is acceptable to the response handler from the javascript library running on the client side. Common commands includeElements are identified by the value of the HTML id attribute. If you do not see your updates occuring on the browser side, ensure that you are using the correct id in your response. Summary | | | Stores the commands that will be sent to the browser in the response. | | The name of the encoding method you wish to use when dealing with special characters. | | Convert special characters to the HTML equivellent. | | A reference to the global plugin manager. | | | | Create and initialize a xajaxResponse object. | | Overrides the default character encoding (or the one specified in the constructor) to the specified character encoding. | | Convert special characters to their HTML equivellent automatically (only works if the mb_string extension is available). | | Provides access to registered response plugins. | | Magic function for PHP 5. | | Response command that prompts user with [ok] [cancel] style message box. | | Response command indicating that the specified value should be assigned to the given element’s attribute. | | Response command that indicates the specified data should be appended to the given element’s property. | | Response command to prepend the specified value onto the given element’s property. | | Replace a specified value with another value within the given element’s property. | | Response command used to clear the specified property of the given element. | | Response command used to assign a value to a member of a javascript object (or element) that is specified by the context member of the request. | | Response command used to append a value onto the specified member of the javascript context object (or element) specified by the context member of the request. | | Response command used to prepend the speicified data to the given member of the current javascript object specified by context in the current request. | | Response command used to clear the value of the property specified in the sAttribute parameter. | | Response command that is used to display an alert message to the user. | | Response command that causes the browser to navigate to the specified URL. | | Response command that is used to execute a portion of javascript on the browser. | | Response command that indicates that the specified javascript function should be called with the given (optional) parameters. | | Response command used to remove an element from the document. | | Response command used to create a new element on the browser. | | Response command used to insert a new element just prior to the specified element. | | Response command used to insert a new element after the specified one. | | Response command used to create an input element on the browser. | | Response command used to insert a new input element preceeding the specified element. | | Response command used to insert a new input element after the specified element. | | Response command used to set an event handler on the browser. | | Response command used to install an event handler on the specified element. | | Response command used to remove an event handler from an element. | | Response command used to construct a javascript function on the browser. | | Response command used to construct a wrapper function around and existing javascript function on the browser. | | Response command used to load a javascript file on the browser. | | Response command used to include a javascript file on the browser if it has not already been loaded. | | Response command used to remove a SCRIPT reference to a javascript file on the browser. | | Response command used to include a LINK reference to the specified CSS file on the browser. | | Response command used to remove a LINK reference to a CSS file on the browser. | | Response command instructing xajax to pause while the CSS files are loaded. | | Response command instructing xajax to delay execution of the response commands until a specified condition is met. | | Response command which instructs xajax to pause execution of the response commands, returning control to the browser so it can perform other commands asynchronously. | | Stores a value that will be passed back as part of the response. | | Returns the current content type that will be used for the response packet. | | | | Prints the output, generated from the commands added to the response, that will be sent to the browser. | | Used internally to generate the response headers. | | | | | | Adds a response command that is generated by a plugin. | | Add a response command to the array of commands that will be sent to the browser. | | Used internally to print XML start tag. | | Used internally to generate the command output. | | Prints an XML representation of the command. | | Prints an XML representation of a php array suitable for inclusion in the response to the browser. | | Escape the specified data if necessary, so special characters in the command data does not interfere with the structure of the response. | | Recursively serializes a data structure in an array so that it can be sent to the browser. |
aCommandsStores the commands that will be sent to the browser in the response.
sCharacterEncodingThe name of the encoding method you wish to use when dealing with special characters. See <xajax->setEncoding> for more information.
bOutputEntitiesConvert special characters to the HTML equivellent. See also <xajax->bOutputEntities> and xajax->setFlag.
objPluginManagerA reference to the global plugin manager.
xajaxResponseCreate and initialize a xajaxResponse object.
setCharacterEncodingfunction setCharacterEncoding( | $sCharacterEncoding | ) |
|
Overrides the default character encoding (or the one specified in the constructor) to the specified character encoding. sCharacterEncoding | (string): The encoding method to use for this response. |
See also, <xajaxResponse->xajaxResponse>() Returnsobject | The xajaxResponse object. |
setOutputEntitiesfunction setOutputEntities( | $bOutputEntities | ) |
|
Convert special characters to their HTML equivellent automatically (only works if the mb_string extension is available). bOption | (boolean): Convert special characters |
Returnsobject | The xajaxResponse object. |
pluginProvides access to registered response plugins. If you are using PHP 4 or 5, pass the plugin name as the first argument, the plugin method name as the second argument and subsequent arguments (if any) to be passed along to the plugin. Optionally, if you use PHP 5, you can pass just the plugin name as the first argument and the plugin object will be returned. You can then access the methods of the plugin directly. sName | (string): Name of the plugin. | sFunction | (string, optional): The name of the method to call. | arg1...argn | (mixed, optional): Additional arguments to pass on to the plugin function. |
Returnsobject | The plugin specified by sName. |
__getfunction &__get( | $sPluginName | ) |
|
Magic function for PHP 5. Used to permit plugins to be called as if they where native members of the xajaxResponse instance. sPluginName | (string): The name of the plugin. |
Returnsobject | The plugin specified by sPluginName. |
confirmCommandsfunction confirmCommands( | $iCmdNumber, | | $sMessage | ) |
|
Response command that prompts user with [ok] [cancel] style message box. If the user clicks cancel, the specified number of response commands following this one, will be skipped. iCmdNumber | (integer): The number of commands to skip upon cancel. | sMessage | (string): The message to display to the user. |
Returnsobject | The xajaxResponse object. |
assignfunction assign( | $sTarget, | | $sAttribute, | | $sData | ) |
|
Response command indicating that the specified value should be assigned to the given element’s attribute. sTarget | (string): The id of the html element on the browser. | sAttribute | (string): The property to be assigned. | sData | (string): The value to be assigned to the property. |
ReturnsExample$objResponse->assign(“contentDiv”, “innerHTML”, “Some Text”);
appendfunction append( | $sTarget, | | $sAttribute, | | $sData | ) |
|
Response command that indicates the specified data should be appended to the given element’s property. sTarget | (string): The id of the element to be updated. | sAttribute | (string): The name of the property to be appended to. | sData | (string): The data to be appended to the property. |
Returns
prependfunction prepend( | $sTarget, | | $sAttribute, | | $sData | ) |
|
Response command to prepend the specified value onto the given element’s property. sTarget | (string): The id of the element to be updated. | sAttribute | (string): The property to be updated. | sData | (string): The value to be prepended. |
Returns
replacefunction replace( | $sTarget, | | $sAttribute, | | $sSearch, | | $sData | ) |
|
Replace a specified value with another value within the given element’s property. sTarget | (string): The id of the element to update. | sAttribute | (string): The property to be updated. | sSearch | (string): The needle to search for. | sData | (string): The data to use in place of the needle. |
clearfunction clear( | $sTarget, | | $sAttribute | ) |
|
Response command used to clear the specified property of the given element. sTarget | (string): The id of the element to be updated. | sAttribute | (string): The property to be clared. |
Returns
contextAssignfunction contextAssign( | $sAttribute, | | $sData | ) |
|
Response command used to assign a value to a member of a javascript object (or element) that is specified by the context member of the request. The object is referenced using the ‘this’ keyword in the sAttribute parameter. sAttribute | (string): The property to be updated. | sData | (string): The value to assign. |
Returns
contextAppendfunction contextAppend( | $sAttribute, | | $sData | ) |
|
Response command used to append a value onto the specified member of the javascript context object (or element) specified by the context member of the request. The object is referenced using the ‘this’ keyword in the sAttribute parameter. sAttribute | (string): The member to be appended to. | sData | (string): The value to append. |
Returns
contextPrependfunction contextPrepend( | $sAttribute, | | $sData | ) |
|
Response command used to prepend the speicified data to the given member of the current javascript object specified by context in the current request. The object is access via the ‘this’ keyword in the sAttribute parameter. sAttribute | (string): The member to be updated. | sData | (string): The value to be prepended. |
Returns
contextClearfunction contextClear( | $sAttribute | ) |
|
Response command used to clear the value of the property specified in the sAttribute parameter. The member is access via the ‘this’ keyword and can be used to update a javascript object specified by context in the request parameters. sAttribute | (string): The member to be cleared. |
Returns
alertResponse command that is used to display an alert message to the user. sMsg | (string): The message to be displayed. |
Returns
redirectfunction redirect( | $sURL, | | | $iDelay | = | ) |
|
Response command that causes the browser to navigate to the specified URL. sURL | (string): The relative or fully qualified URL. | iDelay | (integer, optional): Number of seconds to delay before the redirect occurs. |
Returns
scriptResponse command that is used to execute a portion of javascript on the browser. The script runs in it’s own context, so variables declared locally, using the ‘var’ keyword, will no longer be available after the call. To construct a variable that will be accessable globally, even after the script has executed, leave off the ‘var’ keyword. sJS | (string): The script to execute. |
Returns
callResponse command that indicates that the specified javascript function should be called with the given (optional) parameters. arg1 | (string): The name of the function to call. | arg2 .. argn | arguments to be passed to the function. |
Returns
removefunction remove( | $sTarget | ) |
|
Response command used to remove an element from the document. sTarget | (string): The id of the element to be removed. |
Returns
createfunction create( | $sParent, | | | | $sTag, | | | | $sId, | | | | $sType | = | null | ) |
|
Response command used to create a new element on the browser. sParent | (string): The id of the parent element. | sTag | (string): The tag name to be used for the new element. | sId | (string): The id to assign to the new element. | sType | (string, optional): The type of tag, deprecated, use xajaxResponse->createInput instead. |
Returns
insertfunction insert( | $sBefore, | | $sTag, | | $sId | ) |
|
Response command used to insert a new element just prior to the specified element. sBefore | (string): The element used as a reference point for the insertion. | sTag | (string): The tag to be used for the new element. | sId | (string): The id to be used for the new element. |
Returns
insertAfterfunction insertAfter( | $sAfter, | | $sTag, | | $sId | ) |
|
Response command used to insert a new element after the specified one. sAfter | (string): The id of the element that will be used as a reference for the insertion. | sTag | (string): The tag name to be used for the new element. | sId | (string): The id to be used for the new element. |
Returns
createInputfunction createInput( | $sParent, | | $sType, | | $sName, | | $sId | ) |
|
Response command used to create an input element on the browser. sParent | (string): The id of the parent element. | sType | (string): The type of the new input element. | sName | (string): The name of the new input element. | sId | (string): The id of the new element. |
Returns
insertInputfunction insertInput( | $sBefore, | | $sType, | | $sName, | | $sId | ) |
|
Response command used to insert a new input element preceeding the specified element. sBefore | (string): The id of the element to be used as the reference point for the insertion. | sType | (string): The type of the new input element. | sName | (string): The name of the new input element. | sId | (string): The id of the new input element. |
Returns
insertInputAfterfunction insertInputAfter( | $sAfter, | | $sType, | | $sName, | | $sId | ) |
|
Response command used to insert a new input element after the specified element. sAfter | (string): The id of the element that is to be used as the insertion point for the new element. | sType | (string): The type of the new input element. | sName | (string): The name of the new input element. | sId | (string): The id of the new input element. |
Returns
setEventfunction setEvent( | $sTarget, | | $sEvent, | | $sScript | ) |
|
Response command used to set an event handler on the browser. sTarget | (string): The id of the element that contains the event. | sEvent | (string): The name of the event. | sScript | (string): The javascript to execute when the event is fired. |
Returns
addHandlerfunction addHandler( | $sTarget, | | $sEvent, | | $sHandler | ) |
|
Response command used to install an event handler on the specified element. sTarget | (string): The id of the element. | sEvent | (string): The name of the event to add the handler to. | sHandler | (string): The javascript function to call when the event is fired. |
You can add more than one event handler to an element’s event using this method. Returns
removeHandlerfunction removeHandler( | $sTarget, | | $sEvent, | | $sHandler | ) |
|
Response command used to remove an event handler from an element. sTarget | (string): The id of the element. | sEvent | (string): The name of the event. | sHandler | (string): The javascript function that is called when the event is fired. |
Returns
setFunctionfunction setFunction( | $sFunction, | | $sArgs, | | $sScript | ) |
|
Response command used to construct a javascript function on the browser. sFunction | (string): The name of the function to construct. | sArgs | (string): Comma separated list of parameter names. | sScript | (string): The javascript code that will become the body of the function. |
Returns
wrapFunctionfunction wrapFunction( | $sFunction, | | $sArgs, | | $aScripts, | | $sReturnValueVariable | ) |
|
Response command used to construct a wrapper function around and existing javascript function on the browser. sFunction | (string): The name of the existing function to wrap. | sArgs | (string): The comma separated list of parameters for the function. | aScripts | (array): An array of javascript code snippets that will be used to build the body of the function. The first piece of code specified in the array will occur before the call to the original function, the second will occur after the original function is called. | sReturnValueVariable | (string): The name of the variable that will retain the return value from the call to the original function. |
Returns
includeScriptfunction includeScript( | $sFileName | ) |
|
Response command used to load a javascript file on the browser. sFileName | (string): The relative or fully qualified URI of the javascript file. |
Returns
includeScriptOncefunction includeScriptOnce( | $sFileName | ) |
|
Response command used to include a javascript file on the browser if it has not already been loaded. sFileName | (string): The relative for fully qualified URI of the javascript file. |
Returns
removeScriptfunction removeScript( | $sFileName, | | | | $sUnload | = | '' | ) |
|
Response command used to remove a SCRIPT reference to a javascript file on the browser. Optionally, you can call a javascript function just prior to the file being unloaded (for cleanup). sFileName | (string): The relative or fully qualified URI of the javascript file. | sUnload | (string): Name of a javascript function to call prior to unlaoding the file. |
Returns
includeCSSfunction includeCSS( | $sFileName | ) |
|
Response command used to include a LINK reference to the specified CSS file on the browser. This will cause the browser to load and apply the style sheet. sFileName | (string): The relative or fully qualified URI of the css file. |
Returns
removeCSSfunction removeCSS( | $sFileName | ) |
|
Response command used to remove a LINK reference to a CSS file on the browser. This causes the browser to unload the style sheet, effectively removing the style changes it caused. sFileName | (string): The relative or fully qualified URI of the css file. |
Returns
waitForCSSfunction waitForCSS( | $iTimeout | = | 600 | ) |
|
Response command instructing xajax to pause while the CSS files are loaded. The browser is not typically a multi-threading application, with regards to javascript code. Therefore, the CSS files included or removed with xajaxResponse->includeCSS and xajaxResponse->removeCSS respectively, will not be loaded or removed until the browser regains control from the script. This command returns control back to the browser and pauses the execution of the response until the CSS files, included previously, are loaded. iTimeout | (integer): The number of 1/10ths of a second to pause before timing out and continuing with the execution of the response commands. |
Returns
waitForfunction waitFor( | $script, | | $tenths | ) |
|
Response command instructing xajax to delay execution of the response commands until a specified condition is met. Note, this returns control to the browser, so that other script operations can execute. xajax will continue to monitor the specified condition and, when it evaulates to true, will continue processing response commands. script | (string): A piece of javascript code that evaulates to true or false. | tenths | (integer): The number of 1/10ths of a second to wait before timing out and continuing with the execution of the response commands. |
Returns
sleepResponse command which instructs xajax to pause execution of the response commands, returning control to the browser so it can perform other commands asynchronously. After the specified delay, xajax will continue execution of the response commands. tenths | (integer): The number of 1/10ths of a second to sleep. |
Returns
setReturnValuefunction setReturnValue( | $value | ) |
|
Stores a value that will be passed back as part of the response. When making synchronous requests, the calling javascript can obtain this value immediately as the return value of the xajax.call function. Returns
getContentTypefunction getContentType() |
Returns the current content type that will be used for the response packet. (typically: “text/xml”) Returns
printOutputPrints the output, generated from the commands added to the response, that will be sent to the browser. Returnsstring | The textual representation of the response commands. |
_sendHeadersUsed internally to generate the response headers.
getCommandCountfunction getCommandCount() |
Returnsinteger | The number of commands in the response. |
loadCommandsfunction loadCommands( | $mCommands, | | | | $bBefore | = | false | ) |
|
Merges the response commands from the specified xajaxResponse object with the response commands in this xajaxResponse object. mCommands | (object): xajaxResponse object. | bBefore | (boolean): Add the new commands to the beginning of the list. |
addPluginCommandfunction addPluginCommand( | $objPlugin, | | $aAttributes, | | $mData | ) |
|
Adds a response command that is generated by a plugin. objPlugin | (object): A reference to a plugin object. | aAttributes | (array): Array containing the attributes for this response command. | mData | (mixed): The data to be sent with this command. |
Returns
addCommandfunction addCommand( | $aAttributes, | | $mData | ) |
|
Add a response command to the array of commands that will be sent to the browser. aAttributes | (array): Associative array of attributes that will describe the command. | mData | (mixed): The data to be associated with this command. |
Returns
_printHeader_XMLfunction _printHeader_XML() |
Used internally to print XML start tag.
_printResponse_XMLfunction _printResponse_XML() |
Used internally to generate the command output.
_printCommand_XMLfunction _printCommand_XML( | & | $aAttributes | ) |
|
Prints an XML representation of the command. aAttributes | (array): Associative array of attributes for this command. |
_printArray_XMLfunction _printArray_XML( | & | $mArray | ) |
|
Prints an XML representation of a php array suitable for inclusion in the response to the browser. Arrays sent via this method will be converted into a javascript array on the browser. mArray | (array): Array to be converted. |
_printEscapedString_XMLfunction _printEscapedString_XML( | & | $sData | ) |
|
Escape the specified data if necessary, so special characters in the command data does not interfere with the structure of the response. This could be overridden to allow for transport encodings other than XML. sData | (string): The data to be escaped. |
Returns
_encodeArrayfunction _encodeArray( | & | $mData | ) |
|
Recursively serializes a data structure in an array so that it can be sent to the browser. This can be thought of as the opposite of <xajaxRequestProcessorPlugin->_parseObjXml>. mData | (mixed): The data to be evaluated. |
Returnsmixed | The object constructed from the data. |
|