cvs: pear /HTML_AJAX AJAX.php package.php package.xml /HTML_AJAX/AJAX JSON.php Server.php /HTML_AJAX/AJAX/Serializer Error.php JSON.php Null.php
/HTML_AJAX/docs/examples auto_server.php

From: Date: Fri, 19 Aug 2005 19:30:52 +0000
Subject: cvs: pear /HTML_AJAX AJAX.php package.php package.xml /HTML_AJAX/AJAX JSON.php Server.php /HTML_AJAX/AJAX/Serializer Error.php JSON.php Null.php
/HTML_AJAX/docs/examples auto_server.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-34164@lists.php.net to get a copy of this message
davidc Fri Aug 19 15:30:52 2005 EDT Modified files: /pear/HTML_AJAX AJAX.php package.php package.xml /pear/HTML_AJAX/AJAX JSON.php Server.php /pear/HTML_AJAX/AJAX/Serializer Error.php JSON.php Null.php /pear/HTML_AJAX/docs/examples auto_server.php Log: Changes by joshua, revert serializer

http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX.php?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/AJAX.php diff -u pear/HTML_AJAX/AJAX.php:1.2 pear/HTML_AJAX/AJAX.php:1.3 --- pear/HTML_AJAX/AJAX.php:1.2 Thu Aug 18 22:57:10 2005 +++ pear/HTML_AJAX/AJAX.php Fri Aug 19 15:30:51 2005 @@ -1,5 +1,5 @@ <?php -// $Id: AJAX.php,v 1.2 2005/08/19 02:57:10 davidc Exp $ +// $Id: AJAX.php,v 1.3 2005/08/19 19:30:51 davidc Exp $ /** * OO AJAX Implementation for PHP * @@ -16,6 +16,13 @@ * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: @package_version@ */ + +/** + * This is a quick hack, loading serializers as needed doesn't work in php5 + */ +require_once "HTML/AJAX/Serializer/JSON.php"; +require_once "HTML/AJAX/Serializer/Null.php"; +require_once "HTML/AJAX/Serializer/Error.php"; /** * OO AJAX Implementation for PHP @@ -31,8 +38,7 @@ * @todo pass server side warnings to the client as exceptions or something like that * @todo Add some sort of debugging console */ -class HTML_AJAX -{ +class HTML_AJAX { /** * An array holding the instances were exporting * @@ -199,10 +205,9 @@ function handleRequest() { if (isset($_GET['c']) && isset($_GET['m'])) { - set_error_handler(array(&$this,'_errorHandler')); - $class = $_GET['c']; + $class = $_GET['c']; $method = $_GET['m']; if (!isset($this->_exportedInstances[$class])) { http://cvs.php.net/diff.php/pear/HTML_AJAX/package.php?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/package.php diff -u pear/HTML_AJAX/package.php:1.2 pear/HTML_AJAX/package.php:1.3 --- pear/HTML_AJAX/package.php:1.2 Thu Aug 18 23:28:46 2005 +++ pear/HTML_AJAX/package.php Fri Aug 19 15:30:51 2005 @@ -13,7 +13,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: package.php,v 1.2 2005/08/19 03:28:46 davidc Exp $ + * @version CVS: $Id: package.php,v 1.3 2005/08/19 19:30:51 davidc Exp $ * @link http://pear.php.net/package/PEAR_PackageFileManager * @since File available since Release 0.1.0 */ @@ -21,8 +21,9 @@ $version = '0.1.4'; $notes = <<<EOT -Made sure that the files are PEAR CS Compliant, -Update comments to PEAR coding standards +PEAR CS fixes +Support for generating multiple stubs in a single request stub=test,test2 +304 Http Cache support for Client and Stub generation, this is on by default, caching rules are configurable see docblocks for more info EOT; $description =<<<EOT @@ -37,7 +38,7 @@ $result = $package->setOptions(array( 'package' => 'HTML_AJAX', - 'summary' => 'Provides PHP and JavaScript library for AJAX', + 'summary' => 'PHP and JavaScript AJAX library', 'description' => $description, 'version' => $version, 'state' => 'alpha', @@ -46,8 +47,8 @@ 'filelistgenerator' => 'file', // other option is 'file' 'notes' => $notes, 'changelogoldtonew' => false, - 'packagedirectory' => '', 'baseinstalldir' => 'HTML', // if your package is like "Packagename" use '' + 'packagedirectory' => '', 'simpleoutput' => true )); @@ -61,6 +62,7 @@ $package->addMaintainer('jeichorn','lead','Joshua Eichorn','josh@bluga.net'); $package->addMaintainer('davidc','lead','David Coallier','davidc@php.net'); + // dependencies can be added at will here $package->addDependency('PEAR', '1.3.5', 'ge', 'pkg', false); $package->addDependency('php', '4.3.0', 'ge', 'php', false); http://cvs.php.net/diff.php/pear/HTML_AJAX/package.xml?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/package.xml diff -u pear/HTML_AJAX/package.xml:1.1 pear/HTML_AJAX/package.xml:1.2 --- pear/HTML_AJAX/package.xml:1.1 Thu Aug 18 09:09:49 2005 +++ pear/HTML_AJAX/package.xml Fri Aug 19 15:30:51 2005 @@ -2,7 +2,7 @@ <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0" packagerversion="1.4.0a12"> <name>HTML_AJAX</name> - <summary>Provides PHP and JavaScript library for AJAX</summary> + <summary>PHP and JavaScript AJAX library</summary> <description>Provides PHP and JavaScript libraries for performing AJAX (Communication from JavaScript to your browser without reloading the page) Offers OO proxies in JavaScript of registered PHP or proxyless operation @@ -16,13 +16,20 @@ <email>josh@bluga.net</email> <role>lead</role> </maintainer> + <maintainer> + <user>davidc</user> + <name>David Coallier</name> + <email>davidc@php.net</email> + <role>lead</role> + </maintainer> </maintainers> <release> - <version>0.1.3</version> - <date>2005-08-01</date> + <version>0.1.4</version> + <date>2005-08-17</date> <license>PHP License</license> <state>alpha</state> - <notes>Update comments to PEAR coding standards + <notes>PEAR CS fixes +Support for generating multiple stubs in a single request stub=test,test2 </notes> <deps> <dep type="pkg" rel="ge" version="1.3.5" optional="no">PEAR</dep> @@ -77,6 +84,9 @@ <file role="doc" name="test.class.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> + <file role="doc" name="test2.class.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> <file role="doc" name="test_speed.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> @@ -112,6 +122,15 @@ </release> <changelog> <release> + <version>0.1.4</version> + <date>2005-08-17</date> + <license>PHP License</license> + <state>alpha</state> + <notes>PEAR CS fixes +Support for generating multiple stubs in a single request stub=test,test2 + </notes> + </release> + <release> <version>0.1.3</version> <date>2005-08-01</date> <license>PHP License</license> http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX/JSON.php?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/AJAX/JSON.php diff -u pear/HTML_AJAX/AJAX/JSON.php:1.1 pear/HTML_AJAX/AJAX/JSON.php:1.2 --- pear/HTML_AJAX/AJAX/JSON.php:1.1 Thu Aug 18 09:17:10 2005 +++ pear/HTML_AJAX/AJAX/JSON.php Fri Aug 19 15:30:52 2005 @@ -18,7 +18,7 @@ // | Brett Stimmerman, brettstimmerman[at]gmail[dot]com | // +----------------------------------------------------------------------+ // - // $Id: JSON.php,v 1.1 2005/08/18 13:17:10 davidc Exp $ + // $Id: JSON.php,v 1.2 2005/08/19 19:30:52 davidc Exp $ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ define('HTML_AJAX_JSON_SLICE', 1); http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX/Server.php?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/AJAX/Server.php diff -u pear/HTML_AJAX/AJAX/Server.php:1.2 pear/HTML_AJAX/AJAX/Server.php:1.3 --- pear/HTML_AJAX/AJAX/Server.php:1.2 Thu Aug 18 22:54:40 2005 +++ pear/HTML_AJAX/AJAX/Server.php Fri Aug 19 15:30:52 2005 @@ -40,64 +40,112 @@ * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName - * @todo Decide if a syntax is needed to generate 2 stubs at once + * @todo extend options and generateClient fileList building to support , seperated lists of libs */ class HTML_AJAX_Server { - /** - * Client options array if set to true the code looks at _GET - * @var bool|array - */ - var $options = true; - - /** - * HTML_AJAX instance - * @var HTML_AJAX - */ - var $ajax; + /** + * Client options array if set to true the code looks at _GET + * @var bool|array + */ + var $options = true; + + /** + * HTML_AJAX instance + * @var HTML_AJAX + */ + var $ajax; - /** - * Set to true if your extending the server to add init{className methods} + /** + * Set to true if your extending the server to add init{className methods} * @var boolean - */ - var $initMethods = false; + * @access public + */ + var $initMethods = false; /** * Location on filesystem of client javascript library - * var false|string if false the default pear data dir location is used + * @var false|string if false the default pear data dir location is used */ var $clientJsLocation = false; - /** - * Constructor creates the HTML_AJAX instance + /** + * 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} + * + * <code> + * array( + * 'httpCacheClient' => true, // send 304 headers for responses to ?client=* requests + * 'ClientCacheRule' => 'File', // create a hash from file names and modified times, options: file|content + * 'ClientCacheExpects'=> 'files', // what type of content to send to the hash function, options: files|classes|content + * 'httpCacheStub' => true, // send 304 headers for responses to ?stub=* requests + * 'StubCacheRule' => 'Api', // create a hash from the exposed api, options: api|content + * 'StubCacheExpects'=> 'classes', // what type of content to send to the hash function, options: files|classes|content + * ) + * </code> + * + * @var array + * @access public + */ + var $cacheOptions = array( + 'httpCacheClient' => true, + 'ClientCacheRule' => 'file', + 'ClientCacheExpects' => 'files', + 'httpCacheStub' => true, + 'StubCacheRule' => 'api', + 'StubCacheExpects' => 'classes', + ); + + /** + * Javascript library names and there path + * + * the return of $this->clientJsLocation(), is appended before running readfile on them + * + * @access public + * @var array + */ + var $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' + ); + + /** + * Constructor creates the HTML_AJAX instance * * @todo: verify that PHP_SELF always does what we want - */ - function HTML_AJAX_Server() + */ + function HTML_AJAX_Server() { - $this->ajax =& new HTML_AJAX(); + $this->ajax =& new HTML_AJAX(); $this->ajax->serverUrl = $_SERVER['PHP_SELF']; - } + } - /** - * Handle a client request, either generating a client or having HTML_AJAX handle the request + /** + * Handle a client request, either generating a client or having HTML_AJAX handle the request * * @return string generated client or ajax response - */ - function handleRequest() + */ + function handleRequest() { - if ($this->options == true) { - $this->_loadOptions(); - } - - if (!isset($_GET['c'])) { - return $this->generateClient(); - } else { - $this->_init($_GET['c']); - return $this->ajax->handleRequest(); - } - } + if ($this->options == true) { + $this->_loadOptions(); + } + if (!isset($_GET['c'])) { + return $this->generateClient(); + } else { + $this->_init($this->_cleanIdentifier($_GET['c'])); + return $this->ajax->handleRequest(); + } + } /** * Register method passthrough to HTML_AJAX @@ -109,139 +157,325 @@ $this->ajax->registerClass($instance,$exportedName,$exportedMethods); } - /** - * Generate client js - * - * @todo Add Http_Cache type functionality so the client will cache the js - */ - function generateClient() + /** + * Generate client js + * + * @todo this is going to need tests to cover all the options + */ + function generateClient() { header('Content-Type: text/javascript'); + ob_start(); - if ($this->options['stub'] === 'all') { - if ($this->initMethods) { - $this->_initAll(); - } - echo $this->ajax->generateJavaScriptClient($this->options['stub']); - } else { - if ($this->options['stub'] !== false) { - $this->_init($this->options['stub']); - echo $this->ajax->generateClassStub($this->options['stub']); + // create a list list of js files were going to need to output + $fileList = array(); + $library = strtolower($this->options['client']); + + if (isset($this->javascriptLibraries[$library])) { + $fileList[] = $this->clientJsLocation().$this->javascriptLibraries[$library]; + } + + // do needed class init if were running an init server + $classList = $this->options['stub']; + if ($this->initMethods) { + if (isset($this->options['stub'][0]) && $this->options['stub'][0] === 'all') { + $this->_initAll(); + } else { + foreach($this->options['stub'] as $stub) { + $this->_init($stub); + } } - } + } + if (isset($this->options['stub'][0]) && $this->options['stub'][0] === 'all') { + $classList = array_keys($this->ajax->_exportedInstances); + } - $library = strtolower($this->options['client']); - switch($library) { - case 'all': - case 'html_ajax': - $this->_readFile($this->clientJsLocation()."HTML_AJAX.js"); - break; - case 'json': - $this->_readFile($this->clientJsLocation()."JSON.js"); - break; - case 'request': - $this->_readFile($this->clientJsLocation()."Request.js"); - break; - case 'main': - $this->_readFile($this->clientJsLocation()."Main.js"); - break; - case 'httpclient': - $this->_readFile($this->clientJsLocation()."HttpClient.js"); - break; - case 'dispatcher': - $this->_readFile($this->clientJsLocation()."Dispatcher.js"); - break; - case false: - break; - default: - echo "alert('Unknown javascript library: $library');"; - break; - } + // if were doing stub and client we have to wait for both ETags before we can compare with the client + $combinedOutput = false; + if ($classList != false && count($classList) > 0 && count($fileList) > 0) { + $combinedOutput = true; + } + + + if ($classList != false && count($classList) > 0) { + + // were setup enough to make a stubETag if the input it wants is a class list + if ($this->cacheOptions['httpCacheStub'] && $this->cacheOptions['StubCacheExpects'] == 'classes') { + $stubETag = $this->_callCacheRule('Stub',$classList); + } + + // if were not in combined output compare etags, if method returns true were done + if (!$combinedOutput && isset($stubETag)) { + if ($this->_compareEtags($stubETag)) { + ob_end_clean(); + return; + } + } + + // output the stubs for all the classes in our list + foreach($classList as $class) { + echo $this->ajax->generateClassStub($class); + } + + // if were cacheing and the rule expects content make a tag and check it, if the check is true were done + if ($this->cacheOptions['httpCacheStub'] && $this->cacheOptions['StubCacheExpects'] == 'content') { + $stubETag = $this->_callCacheRule('Stub',ob_get_contents()); + } + + // if were not in combined output compare etags, if method returns true were done + if (!$combinedOutput && isset($stubETag)) { + if ($this->_compareEtags($stubETag)) { + ob_end_clean(); + return; + } + } + } + + if (count($fileList) > 0) { + // if were caching and need a file list build our jsETag + if ($this->cacheOptions['httpCacheClient'] && $this->cacheOptions['ClientCacheExpects'] === 'files') { + $jsETag = $this->_callCacheRule('Client',$fileList); + + } + + // if were not in combined output compare etags, if method returns true were done + if (!$combinedOutput && isset($jsETag)) { + if ($this->_compareEtags($jsETag)) { + ob_end_clean(); + return; + } + } + + // output the needed client js files + foreach($fileList as $file) { + $this->_readFile($file); + } + + // if were caching and need content build the etag + if ($this->cacheOptions['httpCacheClient'] && $this->cacheOptions['ClientCacheExpects'] === 'content') { + $jsETag = $this->_callCacheRule('Client',ob_get_contents()); + } + + // if were not in combined output compare etags, if method returns true were done + if (!$combinedOutput && isset($jsETag)) { + if ($this->_compareEtags($jsETag)) { + ob_end_clean(); + return; + } + } + // were in combined output, merge the 2 ETags and compare + else if (isset($jsETag) && isset($stubETag)) { + if ($this->_compareEtags(md5($stubETag.$jsETag))) { + ob_end_clean(); + return; + } + } + } - } + + // were outputting content, add our length header and send the output + $length = ob_get_length(); + if ($length > 0) { + header('Content-Length: '.$length); + } + ob_end_flush(); + } /** * Run readfile on input with basic error checking * * @param string $file file to read * @access private + * @todo is addslashes enough encoding for js? */ function _readFile($file) { if (file_exists($file)) { readfile($file); } else { + $file = addslashes($file); echo "alert('Unable to find javascript file: $file');"; } } - /** - * Get the location of the client js + /** + * Get the location of the client js * To override the default pear datadir location set $this->clientJsLocation - * - * @return string - */ - function clientJsLocation() + * + * @return string + */ + function clientJsLocation() { if (!$this->clientJsLocation) { return '@data-dir@'.DIRECTORY_SEPARATOR.'HTML_AJAX'.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR; } else { return $this->clientJsLocationRoot; } - } + } - /** - * Load options from _GET - * - * @access private - * @todo Is this preg_replace a good enough security check? - */ - function _loadOptions() + /** + * Load options from _GET + * + * @access private + */ + function _loadOptions() { $this->options = array('client'=>false,'stub'=>false); - if (isset($_GET['client'])) { - $this->options['client'] = $_GET['client']; - } - if (isset($_GET['stub'])) { - $stub = trim(preg_replace('/[^A-Za-z_0-9]/','',$_GET['stub'])); - if (!empty($stub)) { - $this->options['stub'] = $stub; - } else { - $this->options['stub'] = false; - } - } - } - - /** - * Run every init method on the class - * - * @access private - */ - function _initAll() - { - $methods = get_class_methods(get_class($this)); - - foreach($methods as $method) { - if (substr($method,0,4) == 'init') { - $this->$method(); - } - } - } - - /** - * Init one class - * - * @param string $className - * @access private - * @todo error handling if the method doesn't exist - */ - function _init($className) - { - $m = "init$className"; - if (is_callable(array(&$this,$m))) { - $this->$m(); - } - } + if (isset($_GET['client'])) { + $this->options['client'] = $this->_cleanIdentifier($_GET['client']); + } + if (isset($_GET['stub'])) { + if (strstr($_GET['stub'],',')) { + $stubs = explode(',',$_GET['stub']); + } else { + $stubs = array($_GET['stub']); + } + $stub = array(); + foreach($stubs as $val) { + $cleanVal = $this->_cleanIdentifier($val); + if (!empty($cleanVal)) { + $stub[] = $cleanVal; + } + } + + if (count($stub) > 0) { + $this->options['stub'] = $stub; + } else { + $this->options['stub'] = false; + } + } + } + + /** + * Clean an identifier like a class name making it safe to use + * + * @param string $input + * @return string + * @access private + */ + function _cleanIdentifier($input) { + return trim(preg_replace('/[^A-Za-z_0-9]/','',$input)); + } + + /** + * Run every init method on the class + * + * @access private + */ + function _initAll() + { + $methods = get_class_methods(get_class($this)); + + foreach($methods as $method) { + if (substr($method,0,4) == 'init') { + $this->$method(); + } + } + } + + /** + * Init one class + * + * @param string $className + * @access private + * @todo error handling if the method doesn't exist + */ + function _init($className) + { + $m = "init$className"; + if (is_callable(array(&$this,$m))) { + $this->$m(); + } + } + + /** + * Generate a hash from a list of files + * + * @param array $files file list + * @return string a hash that can be used as an etag + * @access private + */ + function _cacheRuleFile($files) { + $signature = ""; + foreach($files as $file) { + if (file_exists($file)) { + $signature .= $file.filemtime($file); + } + } + return md5($signature); + } + + /** + * Generate a hash from the api of registered classes + * + * @param array $classes class list + * @return string a hash that can be used as an etag + * @access private + */ + function _cacheRuleApi($classes) { + $signature = ""; + foreach($classes as $class) { + if (isset($this->ajax->_exportedInstances[$class])) { + $signature .= $class.implode(',',$this->ajax->_exportedInstances[$class]['exportedMethods']); + } + } + return md5($signature); + } + + /** + * Generate a hash from the raw content + * + * @param array $content + * @return string a hash that can be used as an etag + * @access private + */ + function _cacheRuleContent($content) { + return md5($content); + } + + /** + * Send cache control headers + * @access private + */ + function _sendCacheHeaders($etag,$notModified) { + header('Cache-Control: must-revalidate'); + header('ETag: '.$etag); + if ($notModified) { + header('HTTP/1.0 304 Not Modified'); + } + } + + /** + * Compare eTags + * + * @param string $serverETag server eTag + * @return boolean + * @access private + */ + function _compareEtags($serverETag) { + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { + if (strcmp($_SERVER['HTTP_IF_NONE_MATCH'],$serverETag) == 0) { + $this->_sendCacheHeaders($serverETag,true); + return true; + } + } + $this->_sendCacheHeaders($serverETag,false); + return false; + } + + /** + * Call a cache rule and return its retusn + * + * @param string $rule Stub|Client + * @param mixed $payload + * @return boolean + * @access private + * @todo decide if error checking is needed + */ + function _callCacheRule($rule,$payload) { + $method = '_cacheRule'.$this->cacheOptions[$rule.'CacheRule']; + return call_user_func(array(&$this,$method),$payload); + } } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ ?> http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX/Serializer/Error.php?r1=1.3&r2=1.4&ty=u Index: pear/HTML_AJAX/AJAX/Serializer/Error.php diff -u pear/HTML_AJAX/AJAX/Serializer/Error.php:1.3 pear/HTML_AJAX/AJAX/Serializer/Error.php:1.4 --- pear/HTML_AJAX/AJAX/Serializer/Error.php:1.3 Thu Aug 18 22:34:58 2005 +++ pear/HTML_AJAX/AJAX/Serializer/Error.php Fri Aug 19 15:30:52 2005 @@ -1,6 +1,6 @@ <?php require_once 'HTML/AJAX/Serializer/JSON.php'; -// $Id: Error.php,v 1.3 2005/08/19 02:34:58 davidc Exp $ +// $Id /** * Error Serializer, for now just uses JSON * http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX/Serializer/JSON.php?r1=1.3&r2=1.4&ty=u Index: pear/HTML_AJAX/AJAX/Serializer/JSON.php diff -u pear/HTML_AJAX/AJAX/Serializer/JSON.php:1.3 pear/HTML_AJAX/AJAX/Serializer/JSON.php:1.4 --- pear/HTML_AJAX/AJAX/Serializer/JSON.php:1.3 Thu Aug 18 22:31:44 2005 +++ pear/HTML_AJAX/AJAX/Serializer/JSON.php Fri Aug 19 15:30:52 2005 @@ -1,6 +1,6 @@ <?php require_once 'HTML/AJAX/JSON.php'; -// $Id: JSON.php,v 1.3 2005/08/19 02:31:44 davidc Exp $ +// $Id: JSON.php,v 1.4 2005/08/19 19:30:52 davidc Exp $ /** * JSON Serializer * @@ -29,7 +29,7 @@ } function serialize($input) - { + { return $this->_json->encode($input); } http://cvs.php.net/diff.php/pear/HTML_AJAX/AJAX/Serializer/Null.php?r1=1.2&r2=1.3&ty=u Index: pear/HTML_AJAX/AJAX/Serializer/Null.php diff -u pear/HTML_AJAX/AJAX/Serializer/Null.php:1.2 pear/HTML_AJAX/AJAX/Serializer/Null.php:1.3 --- pear/HTML_AJAX/AJAX/Serializer/Null.php:1.2 Thu Aug 18 22:34:58 2005 +++ pear/HTML_AJAX/AJAX/Serializer/Null.php Fri Aug 19 15:30:52 2005 @@ -1,5 +1,5 @@ <?php -// $Id: Null.php,v 1.2 2005/08/19 02:34:58 davidc Exp $ +// $Id: Null.php,v 1.3 2005/08/19 19:30:52 davidc Exp $ /** * Null Serializer * http://cvs.php.net/diff.php/pear/HTML_AJAX/docs/examples/auto_server.php?r1=1.1&r2=1.2&ty=u Index: pear/HTML_AJAX/docs/examples/auto_server.php diff -u pear/HTML_AJAX/docs/examples/auto_server.php:1.1 pear/HTML_AJAX/docs/examples/auto_server.php:1.2 --- pear/HTML_AJAX/docs/examples/auto_server.php:1.1 Thu Aug 18 09:46:08 2005 +++ pear/HTML_AJAX/docs/examples/auto_server.php Fri Aug 19 15:30:52 2005 @@ -1,6 +1,6 @@ <?php /** - * Advanced ussage of HTML_AJAX_Server + * Advanced usage of HTML_AJAX_Server * Allows for a single server to manage exporting a large number of classes without high overhead per call * Also gives a single place to handle setup tasks especially useful if session setup is required * @@ -30,6 +30,12 @@ include 'test.class.php'; $this->registerClass(new test()); } + + // init method for the test class, includes needed files an registers it for ajax + function initTest2() { + include 'test2.class.php'; + $this->registerClass(new test2()); + } }
« previous php.pear.cvs (#34164) next »