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

Class: HTML_AJAX_Server

Source Location: /HTML_AJAX-0.5.7/AJAX/Server.php

Class Overview


Class for creating an external AJAX server


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2005 Joshua Eichorn

Variables

Methods


Child classes:

GuestbookServer
Class for creating an external AJAX server
LoginServer
Class for creating an external AJAX server
Class for creating an external AJAX server
ReviewServer
Class for creating an external AJAX server

Inherited Variables

Inherited Methods


Class Details

[line 40]
Class for creating an external AJAX server

Can be used in 2 different modes, registerClass mode where you create an instance of the server and add the classes that will be registered and then run handle request

Or you can extend it and add init{className} methods for each class you want to export

Client js generation is exposed through 2 _GET params client and stub Setting the _GET param client to `all` will give you all the js classes needed Setting the _GET param stub to `all` will give you stubs of all registered classes, you can also set it too just 1 class



[ Top ]


Class Variables

$ajax =

[line 53]

HTML_AJAX instance

Type:   HTML_AJAX


[ Top ]

$cacheOptions = array(
        'httpCacheClient'       => true, 
        'ClientCacheRule'       => 'file',
        'ClientCacheExpects'    => 'files',
        'httpCacheStub'         => true, 
        'StubCacheRule'         => 'api', 
        'StubCacheExpects'      => 'classes', 
        )

[line 88]

An array of options that tell the server howto Cache output

The rules are functions that make etag hash used to see if the client needs to download updated content If you extend this class you can make your own rule function the naming convention is _cacheRule{RuleName}

  1.  array(
  2.   'httpCacheClient' => true,   // send 304 headers for responses to ?client=* requests
  3.   'ClientCacheRule' => 'File'// create a hash from file names and modified times, options: file|content
  4.   'ClientCacheExpects'=> 'files'// what type of content to send to the hash function, options: files|classes|content
  5.   'httpCacheStub'   => true,   // send 304 headers for responses to ?stub=* requests
  6.   'StubCacheRule'   => 'Api',  // create a hash from the exposed api, options: api|content
  7.   'StubCacheExpects'=> 'classes'// what type of content to send to the hash function, options: files|classes|content
  8.  )

  • Access: public

Type:   array


[ Top ]

$clientJsLocation =  false

[line 66]

Location on filesystem of client javascript library
  • Var: if false the default pear data dir location is used

Type:   false|string


[ Top ]

$compression = array(
        'enabled'       => false,
        'type'          => 'gzip'
    )

[line 110]

Compression Options

  1.  array(
  2.   'enabled'   => false,   // enable compression
  3.   'type'      => 'gzip'   // the type of compression to do, options: gzip
  4.  )

  • Access: public

Type:   array


[ Top ]

$initMethods =  false

[line 60]

Set to true if your extending the server to add init{className methods}
  • Access: public

Type:   boolean


[ Top ]

$javascriptLibraries = array(
        'all'           =>  'HTML_AJAX.js',
        'html_ajax'     =>  'HTML_AJAX.js',
        'html_ajax_lite'=>  'HTML_AJAX_lite.js',
        'json'          =>  'serializer/JSON.js',
        'request'       =>  'Request.js',
        'main'          =>  array('Compat.js','Main.js','clientPool.js'),'httpclient'=>'HttpClient.js','dispatcher'=>'Dispatcher.js','util'=>'util.js','loading'=>'Loading.js','phpserializer'=>'serializer/phpSerializer.js','urlserializer'=>'serializer/UrlSerializer.js','haserializer'=>'serializer/haSerializer.js','clientpool'=>'clientPool.js','iframe'=>'IframeXHR.js','alias'=>'Alias.js','queues'=>'Queue.js','behavior'=>array('behavior/behavior.js','behavior/cssQuery-p.js'),// rules to help you use a minimal library set
'standard'=>array('Compat.js','clientPool.js','util.js','Main.js','HttpClient.js','Request.js','serializer/JSON.js','Loading.js','serializer/UrlSerializer.js','Alias.js','behavior/behavior.js','behavior/cssQuery-p.js'),'jsonrpc'=>array('Compat.js','util.js','Main.js','clientPool.js','HttpClient.js','Request.js','serializer/JSON.js'),'proxyobjects'=>array('Compat.js','util.js','Main.js','clientPool.js','Request.js','serializer/JSON.js','Dispatcher.js'),// BC rules
'priorityqueue'=>'Queue.js','orderedqueue'=>'Queue.js',)

[line 123]

Javascript library names and there path

the return of $this->clientJsLocation(), is prepended before running readfile on them

  • Access: public

Type:   array


[ Top ]

$javascriptLibraryPaths = array()

[line 161]

Custom paths to use for javascript libraries, if not set clientJsLocation is used to find the system path
  • See: registerJsLibrary
  • Access: public

Type:   array


[ Top ]

$options =  true

[line 47]

Client options array if set to true the code looks at _GET

Type:   bool|array


[ Top ]

$_initLookup = array()

[line 168]

Array of className => init methods to call, generated from constructor from initClassName methods
  • Access: protected

Type:   mixed


[ Top ]



Method Detail

HTML_AJAX_Server (Constructor)   [line 176]

HTML_AJAX_Server HTML_AJAX_Server( [string $serverUrl = false])

Constructor creates the HTML_AJAX instance

Parameters:

string   $serverUrl   —  (Optional) the url the client should be making a request too

[ Top ]

clientJsLocation   [line 495]

string clientJsLocation( )

Get the location of the client js To override the default pear datadir location set $this->clientJsLocation

[ Top ]

generateClient   [line 312]

void generateClient( )

Generate client js
  • Todo: this is going to need tests to cover all the options

[ Top ]

handleRequest   [line 214]

boolean handleRequest( )

Handle a client request, either generating a client or having HTML_AJAX handle the request
  • Return: true if request was handled, false otherwise

[ Top ]

registerClass   [line 237]

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

Register method passthrough to HTML_AJAX
  • See: HTML_AJAX::registerClass for docs

Parameters:

   &$instance   — 
   $exportedName   — 
   $exportedMethods   — 

[ Top ]

registerInitObject   [line 274]

void registerInitObject( &$instance, object $instance)

Register init methods from an external class

Parameters:

object   $instance   —  an external class with initClassName methods
   &$instance   — 

[ Top ]

registerJSLibrary   [line 260]

void registerJSLibrary( string $libraryName, string|array $fileName, [string|false $path = false])

Register a new js client library

Parameters:

string   $libraryName   —  name you'll reference the library as
string|array   $fileName   —  actual filename with no path, for example customLib.js
string|false   $path   —  Optional, if not set the result from jsClientLocation is used

[ Top ]

registerPhpCallback   [line 290]

void registerPhpCallback( $callback)

Register a callback to be exported to the client

This function uses the PHP callback pseudo-type


Parameters:

   $callback   — 

[ Top ]

setClientJsLocation   [line 516]

void setClientJsLocation( string $location)

Set the location of the client js
  • Access: public

Parameters:

string   $location   —  Location

[ Top ]

setJavascriptLibraryPath   [line 529]

void setJavascriptLibraryPath( string $library, string $path)

Set the path to a Javascript libraries
  • Access: public

Parameters:

string   $library   —  Library name
string   $path   —  Path

[ Top ]

setJavascriptLibraryPaths   [line 541]

void setJavascriptLibraryPaths( array $paths)

Set the path to more than one Javascript libraries at once
  • Access: public

Parameters:

array   $paths   —  Paths

[ Top ]

setSerializer   [line 247]

void setSerializer( $type)

Change default serialization - important for exporting classes

I wanted this for the xml serializer :)


Parameters:

   $type   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:59:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.