| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Source view] [Print] [Project Stats]
OO AJAX Implementation for PHP SVN Rev: $Id: AJAX.php,v 1.1.2.1 2008/10/03 07:09:50 nicolasconnault Exp $
| Author: | Joshua Eichorn <josh@bluga.net> |
| Author: | Arpad Ray <arpad@php.net> |
| Author: | David Coallier <davidc@php.net> |
| Author: | Elizabeth Smith <auroraeosrose@gmail.com> |
| Copyright: | 2005-2008 Joshua Eichorn, Arpad Ray, David Coallier, Elizabeth Smith |
| License: | http://www.opensource.org/licenses/lgpl-license.php LGPL |
| Version: | Release: 0.5.6 |
| File Size: | 1076 lines (35 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
HTML_AJAX:: (26 methods):
registerClass()
_getMethodsToExport()
generateJavaScriptClient()
generateClassStub()
_generateMethodStub()
populatePayload()
handleRequest()
_getClientPayloadContentType()
_sendResponse()
_sendContentLength()
_sendHeaders()
_getSerializer()
_getClientPayload()
_getVar()
_getServer()
_exceptionHandler()
_errorHandler()
_iframeWrapper()
_iframeGrabProxy()
addAllowedClasses()
_validatePhpCallback()
registerPhpCallback()
packJavaScript()
setInterceptor()
_processInterceptor()
HTML_AJAX_Class_exists()
| registerClass(&$instance, $exportedName = false, $exportedMethods = false) X-Ref |
| Set a class to handle requests param: object &$instance An instance to export param: mixed $exportedName Name used for the javascript class, param: mixed $exportedMethods If false all functions without a _ prefix return: void |
| _getMethodsToExport($className) X-Ref |
| Get a list of methods in a class to export This function uses get_class_methods to get a list of callable methods, so if you're on PHP5 extending this class with a class you want to export should export its protected methods, while normally only its public methods would be exported. All methods starting with _ are removed from the export list. This covers PHP4 style private by naming as well as magic methods in either PHP4 or PHP5 param: string $className Name of the class return: array all methods of the class that are public |
| generateJavaScriptClient() X-Ref |
| Generate the client Javascript code return: string generated javascript client code |
| generateClassStub($name) X-Ref |
| Return the stub for a class param: string $name name of the class to generated the stub for, return: string javascript proxy stub code for a single class |
| _generateMethodStub($method) X-Ref |
| Returns a methods stub param: string $method the method name return: string the js code |
| populatePayload() X-Ref |
| Populates the current payload return: string the js code |
| handleRequest() X-Ref |
| 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: boolean true if an ajax call was handled, false otherwise |
| _getClientPayloadContentType() X-Ref |
| Determines the content type of the client payload return: string |
| _sendResponse($response) X-Ref |
| Send a reponse adding needed headers and serializing content Note: this method echo's output as well as setting headers to prevent caching Iframe Detection: if this has been detected as an iframe response, it has to be wrapped in different code and headers changed (quite a mess) param: mixed $response content to serialize and send return: void |
| _sendContentLength() X-Ref |
| Decide if we should send a Content-length header return: bool true if it's ok to send the header, false otherwise |
| _sendHeaders($array) X-Ref |
| Actually send a list of headers param: array $array list of headers to send return: void |
| _getSerializer($type) X-Ref |
| Get an instance of a serializer class param: string $type Last part of the class name return: HTML_AJAX_Serializer |
| _getClientPayload() X-Ref |
| Get payload in its submitted form, currently only supports raw post return: string raw post data |
| _getVar($var) X-Ref |
| stub for getting get vars - applies strip_tags param: string $var variable to get return: string filtered _GET value |
| _getServer($var) X-Ref |
| stub for getting server vars - applies strip_tags param: string $var variable to get return: string filtered _GET value |
| _exceptionHandler($ex) X-Ref |
| Exception handler, passes them to _errorHandler to do the actual work param: Exception $ex Exception to be handled return: void |
| _errorHandler($errno, $errstr, $errfile, $errline) X-Ref |
| Error handler that sends it errors to the client side param: int $errno Error number param: string $errstr Error string param: string $errfile Error file param: string $errline Error line return: void |
| _iframeWrapper($id, $data, $headers = array() X-Ref |
| Creates html to wrap serialized info for iframe xmlhttprequest fakeout param: string $id iframe instance id param: string $data data to pass param: string $headers headers to pass return: string html page with iframe passing code |
| _iframeGrabProxy() X-Ref |
| Handles a proxied grab request return: bool true to end the response, false to continue trying to handle it |
| addAllowedClasses($classes) X-Ref |
| Add a class or classes to those allowed to be unserialized param: mixed $classes the class or array of classes to add return: void |
| _validatePhpCallback($callback) X-Ref |
| Checks that the given callback is callable and allowed to be called param: callback $callback the callback to check return: bool true if the callback is valid, false otherwise |
| registerPhpCallback($callback) X-Ref |
| Register a callback so it may be called from JS param: callback $callback the callback to register return: void |
| packJavaScript($input) X-Ref |
| 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 /* param: string $input Javascript to pack return: string packed javascript |
| setInterceptor($instance) X-Ref |
| 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 param: Object $instance an instance of you interceptor class return: void |
| _processInterceptor($className,$methodName,$callback,$params) X-Ref |
| Attempt to intercept a call param: string $className Class Name param: string $methodName Method Name param: string $callback Not implemented param: array $params Array of parameters to pass to the interceptor return: array Updated params |
| HTML_AJAX_Class_exists($class, $autoload) X-Ref |
| PHP 4 compat function for interface/class exists param: string $class Class name param: bool $autoload Should the autoloader be called return: bool |
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |