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


Source Location: /HTML_AJAX-0.5.8/HTML/AJAX.php

Class Overview

OO AJAX Implementation for PHP



  • Release: 0.5.8


  • 2005-2008 Joshua Eichorn, Arpad Ray, David Coallier, Elizabeth Smith



Inherited Variables

Inherited Methods

Class Details

[line 43]
OO AJAX Implementation for PHP

[ Top ]

Class Variables

$contentTypeMap = array(
            'JSON'  => 'application/json',
            'XML'   => 'application/xml',
            'Null'  => 'text/plain',
            'Error' => 'application/error',
            'PHP'   => 'application/php-serialized',
            'Urlencoded' => 'application/x-www-form-urlencoded'

[line 93]

Content-type map

Used in to automatically choose serializers as needed

Type:   mixed

[ Top ]

$debug =

[line 108]

This is the debug variable that we will be passing the HTML_AJAX_Debug instance to.

Type:   mixed

[ Top ]

$debugEnabled =  false

[line 114]

This is to tell if debug is enabled or not. If so, then debug is called, instantiated then saves the file and such.

Type:   mixed

[ Top ]

$debugSession =  false

[line 122]

This puts the error into a session variable is set to true.

set to false by default.

  • Access: public

Type:   mixed

[ Top ]

$jsonLooseType =  true

[line 86]

Option to use loose typing for JSON encoding
  • Access: public

Type:   bool

[ Top ]

$packJavaScript =  false

[line 154]

Automatically pack all generated JavaScript making it smaller

If your using output compression this might not make sense

Type:   mixed

[ Top ]

$php4CompatCase =  false

[line 147]

Make Generated code compatible with php4 by lowercasing all class/method names before exporting to JavaScript.

If you have code that works on php4 but not on php5 then setting this flag can fix the problem. The recommended solution is too specify the class and method names when registering the class letting you have function case in php4 as well

  • Access: public

Type:   boolean

[ Top ]

$sendContentLength =  true

[line 133]

Boolean telling if the Content-Length header should be sent.

If your using a gzip handler on an output buffer, or run into any compatability problems, try disabling this.

  • Access: public

Type:   boolean

[ Top ]

$serializer =  'JSON'

[line 73]

What encoding your going to use for serializing data from php being sent to javascript.
  • Var: JSON|PHP|Null

Type:   string

[ Top ]

$serverUrl =  false

[line 65]

Set the server url in the generated stubs to this value

If set to false, serverUrl will not be set

Type:   false|string

[ Top ]

$unserializer =  'JSON'

[line 79]

What encoding your going to use for unserializing data sent from javascript
  • Var: JSON|PHP|Null

Type:   string

[ Top ]

Method Detail

addAllowedClasses   [line 890]

void addAllowedClasses( mixed $classes)

Add a class or classes to those allowed to be unserialized
  • Access: public


mixed   $classes   —  the class or array of classes to add

[ Top ]

generateClassStub   [line 284]

string generateClassStub( string $name)

Return the stub for a class
  • Return: javascript proxy stub code for a single class


string   $name   —  name of the class to generated the stub for, note that this is the exported name not the php class name

[ Top ]

generateJavaScriptClient   [line 265]

string generateJavaScriptClient( )

Generate the client Javascript code
  • Return: generated javascript client code

[ Top ]

handleRequest   [line 376]

boolean handleRequest( )

Handle a ajax request if needed

The current check is if GET variables c (class) and m (method) are set, more options may be available in the future

  • Return: true if an ajax call was handled, false otherwise

[ Top ]

packJavaScript   [line 944]

string packJavaScript( string $input)

Make JavaScript code smaller

Currently just strips whitespace and comments, needs to remain fast Strips comments only if they are not preceeded by code Strips /*-style comments only if they span over more than one line Since strings cannot span over multiple lines, it cannot be defeated by a string containing /*

  • Return: packed javascript
  • Access: public


string   $input   —  Javascript to pack

[ Top ]

registerClass   [line 207]

void registerClass( object &$instance, [mixed $exportedName = false], [mixed $exportedMethods = false])

Set a class to handle requests


object   &$instance   —  An instance to export
mixed   $exportedName   —  Name used for the javascript class, if false the name of the php class is used
mixed   $exportedMethods   —  If false all functions without a _ prefix are exported, if an array only the methods listed in the array are exported

[ Top ]

registerPhpCallback   [line 925]

void registerPhpCallback( callback $callback)

Register a callback so it may be called from JS
  • Access: public


callback   $callback   —  the callback to register

[ Top ]

setInterceptor   [line 1020]

void setInterceptor( Object $instance)

Set an interceptor class

An interceptor class runs during the process of handling a request, it allows you to run security checks globally. It also allows you to rewrite parameters

You can throw errors and exceptions in your intercptor methods and they will be passed to javascript

You can add interceptors are 3 levels For a particular class/method, this is done by add a method to you class named ClassName_MethodName($params) For a particular class, method ClassName($methodName,$params) Globally, method intercept($className,$methodName,$params)

Only one match is done, using the most specific interceptor

All methods have to return $params, if you want to empty all of the parameters return an empty array

  • Todo: handle php callbacks
  • Access: public


Object   $instance   —  an instance of you interceptor class

[ Top ]

Documentation generated on Thu, 02 Feb 2017 22:30:02 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.