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

Class: HTML_AJAX_Server

Source Location: /HTML_AJAX-0.2.4/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:

Class for creating an external AJAX server

Inherited Variables

Inherited Methods


Class Details

[line 38]
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 51]

HTML_AJAX instance

Type:   HTML_AJAX


[ Top ]

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

[line 86]

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 64]

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

Type:   false|string


[ Top ]

$initMethods =  false

[line 58]

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'          =>  'JSON.js',
        'request'       =>  'Request.js',
        'main'          =>  'Main.js',
        'httpclient'    =>  'HttpClient.js',
        'dispatcher'    =>  'Dispatcher.js',
        'util'          =>  'util.js',
        'loading'       =>  'Loading.js',
        'phpserializer' =>  'serialize.js',
        'behavior'      =>  array('behavior.js','cssQuery-p.js'))

[line 103]

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 125]

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 45]

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

Type:   bool|array


[ Top ]

$_initLookup = array()

[line 132]

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 140]

HTML_AJAX_Server HTML_AJAX_Server( )

Constructor creates the HTML_AJAX instance

[ Top ]

clientJsLocation   [line 383]

string clientJsLocation( )

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

[ Top ]

generateClient   [line 216]

void generateClient( )

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

[ Top ]

handleRequest   [line 158]

string handleRequest( )

Handle a client request, either generating a client or having HTML_AJAX handle the request
  • Return: generated client or ajax response

[ Top ]

registerClass   [line 176]

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 202]

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 188]

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 ]


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