AjaxCore

AjaxCore 1.1.2
http://ajaxcore.sourceforge.net/

AjaxCore is a PHP framework that aims the ease development of rich
AJAX applications, using Prototype's JavaScript standard library.

Copyright 2007 Mauro Niewolski (niewolski@users.sourceforge.net)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 

Public Method Summary

void

AjaxCore([ boolean $lastbind ])

AjaxCore()
void

setJSCode(string $id, string $before, string $after)

setJSCode
void

setDebug(bool $debug)

setDebug
void

getJSCode()

getJSCode
string

bind(string $id, string $event, string $bindto, [ string $params ])

bind
string

onLoad(string $bindto, [ string $params, string $request, integer $timerms ])

onLoad
string

bindTimer(string $id, string $event, string $bindto, string $timername, string $timerms, [ string $params ])

bindTimer
string

bindPeriodicalTimer(string $id, string $event, string $bindto, string $timername, string $timerms, [ string $params ])

bindPeriodicalTimer
string

phpArrayToJS(array $array)

phpArrayToJS
void

startTimer(string $id)

startTimer
void

stopTimer(string $id)

stopTimer

Private Method Summary

void

setUpdating(string $code)

setUpdating
void

setCurrentFile(string $file)

setCurrentFile
void

setPlaceHolder(string $placeHolder)

setPlaceHolder
void

setMethod(string $method)

setMethod
void

setCache(bool $cache)

setCache
void

parseCache()

parseCache
void

lookForAction()

lookForAction
void

initialize()

intialize
array

getRequest()

getRequest
string

escapeJS(string $string)

escapeJS (borrowed from Smarty)
void

alert(string $message, boolean $die)

alert
string

arrayToString(array $array)

arrayToString
string

htmlDisable(string $element)

htmlDisable
string

htmlEnable(string $element)

htmlEnable
string

htmlInner(string $element, string $value)

htmlInner

Public Method Details

AjaxCore

public void AjaxCore( [ boolean $lastbind ] )

  AjaxCore()
Class constructor.

Parameter
boolean $lastbind = >>false<<
it's the name of the last JavaScript event triggered.
Returns void


setJSCode

public void setJSCode( string $id, string $before, string $after )

  setJSCode
Sets specific JavaScript code to execute before and after the AJAX request is made.

Parameter
string $id
HTML object id
string $before
JavaScript code to execute before the AJAX request is being made.
string $after
JavaScript code to execute before the AJAX request is being made.
Returns void


setDebug

public void setDebug( bool $debug )

  setDebug
Set whether it should print JavaScript error when occurrs.

Parameter
bool $debug
boolean value.
Returns void


getJSCode

public void getJSCode( )

  getJSCode
Returns string header JavaScript code for main placeHolder.

Returns void


bind

public string bind( string $id, string $event, string $bindto, [ string $params ] )

  bind
Does the bind between an Html object and PHP function, request will be made when appropiate JavaScript event is triggered.

Parameter
string $id
Html ID object
string $event
JavaScript event that will cause AJAX request ( onfocus onblur onmouseover onmouseout onmousedown onmouseup onsubmit onclick onload onchange onkeypress onkeydown onkeyup )
string $bindto
PHP function that handles the AJAX request
string $params = >>""<<
ID of the Html elements that needs to be send within the request, static values (not html elements ) should be sent as _XXX=YYY , whether XXX represents variable name, and YYY value.
Returns string

JavaScript code to handle the binding.


onLoad

public string onLoad( string $bindto, [ string $params, string $request, integer $timerms ] )

  onLoad
Does a request to a PHP function, request will be made when onLoad JavaScript event occurs.

Parameter
string $bindto
PHP function that handles the AJAX request
string $params = >>""<<
ID of the Html elements that needs to be send within the request, static values (not html elements ) should be sent as _XXX=YYY , whether XXX represents variable name, and YYY value.
string $request = >>"bind"<<
type of request, bind, bindTimer, bindPeriodicalTimer
integer $timerms = >>300<<
timer expiration time in milliseconds (only for timer requests)
Returns string

JavaScript code to handle the binding.


bindTimer

public string bindTimer( string $id, string $event, string $bindto, string $timername, string $timerms, [ string $params ] )

  bindTimer
Does the bind between an Html object and PHP function, request will be made when onLoad JavaScript event occurs and timer expires.

Parameter
string $id
Html ID object
string $event
JavaScript event that will cause AJAX request ( onfocus onblur onmouseover onmouseout onmousedown onmouseup onsubmit onclick onload onchange onkeypress onkeydown onkeyup )
string $bindto
PHP function that handles the AJAX request
string $timername
ID of the Html elements that needs to be send within the request, static values (not html elements ) should be sent as _XXX=YYY , whether XXX represents variable name, and YYY value.
string $timerms
name of the timer
string $params = >>""<<
expiration time in milliseconds
Returns string

JavaScript code to handle the binding.


bindPeriodicalTimer

public string bindPeriodicalTimer( string $id, string $event, string $bindto, string $timername, string $timerms, [ string $params ] )

  bindPeriodicalTimer
Does the bind between an Html object and PHP function, request will be made when onLoad JavaScript event occurs and will keep repeating when timer expires.

Parameter
string $id
Html ID object
string $event
JavaScript event that will cause AJAX request ( onfocus onblur onmouseover onmouseout onmousedown onmouseup onsubmit onclick onload onchange onkeypress onkeydown onkeyup )
string $bindto
PHP function that handles the AJAX request
string $timername
ID of the Html elements that needs to be send within the request, static values (not html elements ) should be sent as _XXX=YYY , whether XXX represents variable name, and YYY value.
string $timerms
name of the timer
string $params = >>""<<
expiration time in milliseconds
Returns string

JavaScript code to handle the binding.


phpArrayToJS

public string phpArrayToJS( array $array )

  phpArrayToJS
Converts an array from php to JavaScript.

Parameter
array $array
php array
Returns string

JavaScript array


startTimer

public void startTimer( string $id )

  startTimer
Restarts a timer

Parameter
string $id
is the timer id
Returns void


stopTimer

public void stopTimer( string $id )

  stopTimer
Stops a timer

Parameter
string $id
is the timer id
Returns void


Private Method Details

setUpdating

private void setUpdating( string $code )

  setUpdating
Sets an HTML code while the AJAX request is being made.

Parameter
string $code
HTML code to show while making the request.
Returns void


setCurrentFile

private void setCurrentFile( string $file )

  setCurrentFile
Sets filename of the extended class that inherits of AjaxCore.

Parameter
string $file
filename of the extended class.
Returns void


setPlaceHolder

private void setPlaceHolder( string $placeHolder )

  setPlaceHolder
Sets the <Div> id that will be used as placeholder.

Parameter
string $placeHolder
<Div id=""> used to return Html results.
Returns void


setMethod

private void setMethod( string $method )

  setMethod
Sets whether the method should be Get or Post.

Parameter
string $method
Get or Post.
Returns void


setCache

private void setCache( bool $cache )

  setCache
Sets whether should use cache or not.

Parameter
bool $cache
boolean value
Returns void


parseCache

private void parseCache( )

  parseCache
Parses the current cache.

Returns void


lookForAction

private void lookForAction( )

  lookForAction
Determines what PHP function should be called upon each AJAX request

Returns void


initialize

private void initialize( )

  intialize
Method that is called just before any PHP function, useful to initialize databases and so on.

Returns void


getRequest

private array getRequest( )

  getRequest
Returns Get or Post array.

Returns array

request


escapeJS

private string escapeJS( string $string )

  escapeJS (borrowed from Smarty)
Escape the string to JavaScript

Parameter
string $string
String unscaped
Returns string

escaped string

Links
Author(s)

alert

private void alert( string $message, boolean $die )

  alert
Return JavaScript Alert Message

Parameter
string $message
message to alert
boolean $die
Warning: documentation is missing.
Returns void


arrayToString

private string arrayToString( array $array )

  arrayToString
Returns a sentence form an array

Parameter
array $array
of sentences
Returns string

string with sentences


htmlDisable

private string htmlDisable( string $element )

  htmlDisable
Disables an html element

Parameter
string $element
is the ID of the element
Returns string

sentence to disable element


htmlEnable

private string htmlEnable( string $element )

  htmlEnable
Enables an html element

Parameter
string $element
is the ID of the element
Returns string

sentence to disable element


htmlInner

private string htmlInner( string $element, string $value )

  htmlInner
Enables an html element

Parameter
string $element
is the ID of the element
string $value
is the text to put in
Returns string

sentence to disable element


AjaxCore 2007