Phpfox_Ajax

Description

Handles AJAX Requests and returns data outputed

by the specified call which connects to a modules ajax component. Many of the methods within this class returns the classes own object thus allow calls like:

  1.  $this->hide('#foo')->show('#bar')->html('Test Content')->call('init();');

  • author: Raymond Benc
  • version: $Id: ajax.class.php 1687 2010-07-22 03:13:27Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/ajax/ajax.class.php (line 22)


	
			
Variable Summary
 static array $_aCalls
 static array $_aParams
 static bool $_bShowErrors
 static string $_sErrorHolder
 array $_aJquery
 array $_aRequest
 object $_oReq
Method Summary
 static void alert (string $sMessage, [string $sTitle = null], [int $iWidth = 300], [int $iHeight = 150])
 static void debug (string $sMsg)
 Phpfox_Ajax __construct ()
 object Return append (string $sId, string $sContent, [string $sExtra = ''])
 object Return call (string $sCall)
 void error (bool $bShowErrors)
 void errorSet (string $sDiv)
 mixed get (string $sVar, [mixed $mDef = null])
 array getAll ()
 string getContent ([bool $bClean = true])
 string getData ()
 object Return html (string $sId, string $sContent, [string $sExtra = ''])
 mixed isUser ()
 object Return prepend (string $sId, string $sContent, [string $sExtra = ''])
 bool process ()
 void set (mixed $mVar, [mixed $mDef = ''])
 void setMessage (string $sMessage)
 object Template template ()
 string _ajaxSafe (string $sStr)
 void __call (string $sMethod, array $aArguments)
Variables
static array $_aCalls = array() (line 30)

Stores all the AJAX calls.

  • access: private
static array $_aParams = array() (line 38)

Holds all the $_POST data when sending information via AJAX.

  • access: private
static bool $_bShowErrors = true (line 49)

During an AJAX call you can use "Phpfox_Error::set();" to set error messages and

by default the AJAX class will pick up on these errors and return the error message to the user. However, in some cases you may not want to use the default error reporting routine and create your own and by setting this to false will disable to error reporting routine.

  • access: private
static string $_sErrorHolder = null (line 56)

This is the HTML div ID that holds error messages

  • access: private
array $_aJquery = array(
'addClass',
'removeClass',
'val',
'focus',
'show',
'remove',
'hide',
'slideDown',
'slideUp',
'submit',
'attr',
'height',
'width',
'after',
'before',
'fadeOut'
)
(line 64)

These are jQuery functions we support, which can be called via this class

  • access: private
  • example: example not found
array $_aRequest = array() (line 96)

Holds the default 'phpfox' parameters being passed by the post request.

  • access: private
object $_oReq = null (line 88)

Holds the Request object

  • access: private
Methods
static alert (line 468)

At times you may want to notify your users and instead of using the default JavaScript alert() we provide a AJAX popup version that works well with the sites theme.

  • access: public
void alert (string $sMessage, [string $sTitle = null], [int $iWidth = 300], [int $iHeight = 150])
  • string $sMessage: Message to pass to your users
  • string $sTitle: Title of the alert box
  • int $iWidth: Width of the alert box
  • int $iHeight: Height of the alert box
static debug (line 454)

Set debug information which can be picked up with Firebug.

  • access: public
void debug (string $sMsg)
  • string $sMsg: Debug information you want to pass to Firebug
Constructor __construct (line 102)

Class Constructor

  • access: public
Phpfox_Ajax __construct ()
append (line 272)

jQuery has support for append() and we use that method, however we add a little extra protection with our routine.

  • return: the AJAX object
  • access: public
  • example: example not found
object Return append (string $sId, string $sContent, [string $sExtra = ''])
  • string $sId: HTML id for the element
  • string $sContent: Content to append
  • string $sExtra: Optional jQuery functions you may want to execute
call (line 292)

Used to call any JavaScript back to the browser once the AJAX routine is complete.

  • return: the AJAX object
  • access: public
  • example: example not found
object Return call (string $sCall)
  • string $sCall: JavaScript that you plan to execute back to the browser
error (line 331)

Controlls if you want to use our default error system or create your own.

  • access: public
void error (bool $bShowErrors)
  • bool $bShowErrors: True by default and will use our error system | False to create your own.
errorSet (line 341)

We have our own default error div with a specific ID, however you can use this with this function.

  • access: public
void errorSet (string $sDiv)
  • string $sDiv: ID of the HTML element
get (line 182)

Used to get $_POST requests send via an AJAX request

  • return: Returns the value if the $_POST data, which is usually either a string or array
  • access: public
mixed get (string $sVar, [mixed $mDef = null])
  • string $sVar: Name of the post param
  • mixed $mDef: You can pass a default value incase the $_POST data was not sent
getAll (line 192)

Get all the $_POST params sent over via an AJAX request

  • return: Array of all the $_POST params
  • access: public
array getAll ()
getContent (line 307)

Our product is designed to automatically echo data from components such as blocks and controllers and within an AJAX call we need to get that from the output buffer so we could possible place it within a specific HTML element.

  • return: Returns the output thus allowing you to use it in any way you want.
  • access: public
string getContent ([bool $bClean = true])
  • bool $bClean: Set to true if we should attempt to clean out the content depending on how you plan to return it.
getData (line 351)

This is the final output to the browser once the AJAX request is complete.

  • return: Data to return back to the browser. It must be JavaScript code.
  • access: public
string getData ()
html (line 227)

jQuery has support for innerHTML and we use that method, however we add a little extra protection with our routine.

  • return: the AJAX object
  • access: public
  • example: example not found
object Return html (string $sId, string $sContent, [string $sExtra = ''])
  • string $sId: HTML id for the element
  • string $sContent: Content to place inside the HTML element
  • string $sExtra: Optional jQuery functions you may want to execute
isUser (line 431)

Quick function that can be used to identify if a user is logged it or not and if not they will not be able to use the specific feature and display a login form.

  • return: Returns true if they are logged in or simply exisits the script and returns JavaScript to display the login form.
  • access: public
mixed isUser ()
prepend (line 249)

jQuery has support for prepend() and we use that method, however we add a little extra protection with our routine.

  • return: the AJAX object
  • access: public
  • example: example not found
object Return prepend (string $sId, string $sContent, [string $sExtra = ''])
  • string $sId: HTML id for the element
  • string $sContent: Content to prepend
  • string $sExtra: Optional jQuery functions you may want to execute
process (line 115)

Process the AJAX request

  • return: If we can load the component we return true, false on failure
  • access: public
bool process ()
set (line 204)

Manually set $_POST information if it was not sent via an AJAX request

  • access: public
  • example: example not found
void set (mixed $mVar, [mixed $mDef = ''])
  • mixed $mVar: It can be a string, which will hold the param var or an array of values
  • mixed $mDef: This is the default value of the param you are creating
setMessage (line 523)

Sets a public message on the site for the user to see and closes the AJAX popup box for you.

  • access: public
void setMessage (string $sMessage)
  • string $sMessage: Message you want to display to the user.
template (line 535)

Extend template

  • return: object
  • access: protected
  • example: example not found
  • example: example not found
object Template template ()
_ajaxSafe (line 546)

Safe AJAX Code

  • return: Safe string
  • access: private
string _ajaxSafe (string $sStr)
  • string $sStr: String to replace
__call (line 488)

Emulate jQuery calls.

  • access: public
void __call (string $sMethod, array $aArguments)
  • string $sMethod: jQuery method we are trying to call.
  • array $aArguments: Array of option arguments being passed to jQuery.

Documentation generated on Tue, 28 Sep 2010 10:36:36 +0200 by phpDocumentor 1.4.0a2