cvs: pear /Cache Application.php Cache.php DB.php Function.php Graphics.php Output.php package.xml /Cache/Container file.php msession.php
| From: | Sebastian Bergmann | Date: | Mon, 20 May 2002 17:34:27 +0000 |
| Subject: | cvs: pear /Cache Application.php Cache.php DB.php Function.php Graphics.php Output.php package.xml /Cache/Container file.php msession.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3974@lists.php.net to get a copy of this message | ||
sebastian Mon May 20 13:34:27 2002 EDT
Modified files:
/pear/Cache Application.php Cache.php DB.php Function.php
Graphics.php Output.php package.xml
/pear/Cache/Container file.php msession.php
Log:
Prepare release.
Index: pear/Cache/Application.php diff -u pear/Cache/Application.php:1.1 pear/Cache/Application.php:1.2 --- pear/Cache/Application.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Application.php Mon May 20 13:34:26 2002 @@ -1,178 +1,178 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Richard Heyes <richard@phpguru.org> | -// +----------------------------------------------------------------------+ -// -// $Id: Application.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ - -require_once('Cache.php'); - -// Application level variables -// -// Purpose -// Variables that are persisent across all user sessions, -// not just a specific user ala normal sessions. -// -// Usage: -// -// Example 1: -// -// $app =& new Cache_Application(); -// $_APP =& $app->getData(); -// -// In this case the $_APP variable is akin to the $_SESSION variable. -// If you add/remove stuff, it will be reflected in the next request -// (of any user). -// -// Example 2: -// -// $foo = 'Some data'; -// $bar = 'Some other data'; -// -// $app =& new Cache_Application(); -// $app->register('foo'); -// $app->register('bar', $bar); -// -// $foo = 'Different data'; -// -// In this case the variables are registered with the register() function. -// This is akin to session_register(). -// -// As with session_register(), the contents of the variable at the *end* of the -// request is registered and not at the point of registration. Therefore in this -// example, for the $foo variable, the string 'Different data' is stored and not -// 'Some data'. The exception to this rule is if you use the second argument to -// register() as in the second call to it above. This will cause the data supplied -// in the second argument to be stored and not the contents at the end of the request. -// -// Note: If you use this method with register_globals turned on, the variables will be -// automatically globalled upon startup, (ie. when you create the object). -// -// Note: If you register a variable that is not set when the script finishes, it will -// registered as NULL. -// -// -// *** You are strongly recommended to use only one method of the two above. *** -// -// (In fact if you use the register() function with register_globals Off, you have to -// use the $_APP method to get at the data). - -class Cache_Application extends Cache { - - var $data; - var $id; - var $group; - var $registered_vars; - - /** - * Constructor - * - * @param string Name of container class - * @param array Array with container class options - */ - function Cache_Application($container = 'file', $container_options = array('cache_dir' => '/tmp/', 'filename_prefix' => 'cache_'), $id = 'application_var', $group = 'application_cache') - { - $this->id = $id; - $this->group = $group; - $this->registered_vars = array(); - - $this->Cache($container, $container_options); - $this->data = $this->isCached($this->id, $this->group) ? unserialize($this->get($this->id, $this->group)) : array(); - - // If register_globals on, global all registered variables - if (ini_get('register_globals') AND is_array($this->data)) { - foreach ($this->data as $key => $value) { - global $$key; - $$key = $value; - } - } - } - - /** - * Destructor - * - * Gets values of all registered variables and stores them. Then calls save() to - * write data away. - */ - function _Cache_Application() - { - // Get contents of all registered variables - if (is_array($this->registered_vars) AND !empty($this->registered_vars)) { - foreach ($this->registered_vars as $varname) { - global $$varname; - $this->data[$varname] = $$varname; - } - } - - // Save the data - $this->save($this->id, serialize($this->data), 0, $this->group); - } - - /** - * register() - * - * Registers a variable to be stored. - * - * @param string Name of variable to register - * @param mixed Optional data to store - */ - function register($varname, $data = null) - { - if (isset($data)) { - $this->data[$varname] = $data; - } else { - $this->registered_vars[] = $varname; - } - } - - /** - * unregister() - * - * Unregisters a variable from being stored. - * - * @param string Name of variable to unregister - */ - function unregister($varname) - { - if (isset($this->data[$varname])) { - unset($this->data[$varname]); - } - } - - /** - * clear() - * - * Removes all stored data - */ - function clear() - { - $this->data = array(); - } - - /** - * getData() - * - * Use this to get a reference to the data to manipulate - * in calling script. Eg. $_APP =& $obj->getData(); - * - * @return mixed A reference to the data - */ - function &getData() - { - return $this->data; - } -} +<?php +// +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Richard Heyes <richard@phpguru.org> | +// +----------------------------------------------------------------------+ +// +// $Id: Application.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ + +require_once 'Cache/Cache.php'; + +// Application level variables +// +// Purpose +// Variables that are persisent across all user sessions, +// not just a specific user ala normal sessions. +// +// Usage: +// +// Example 1: +// +// $app =& new Cache_Application(); +// $_APP =& $app->getData(); +// +// In this case the $_APP variable is akin to the $_SESSION variable. +// If you add/remove stuff, it will be reflected in the next request +// (of any user). +// +// Example 2: +// +// $foo = 'Some data'; +// $bar = 'Some other data'; +// +// $app =& new Cache_Application(); +// $app->register('foo'); +// $app->register('bar', $bar); +// +// $foo = 'Different data'; +// +// In this case the variables are registered with the register() function. +// This is akin to session_register(). +// +// As with session_register(), the contents of the variable at the *end* of the +// request is registered and not at the point of registration. Therefore in this +// example, for the $foo variable, the string 'Different data' is stored and not +// 'Some data'. The exception to this rule is if you use the second argument to +// register() as in the second call to it above. This will cause the data supplied +// in the second argument to be stored and not the contents at the end of the request. +// +// Note: If you use this method with register_globals turned on, the variables will be +// automatically globalled upon startup, (ie. when you create the object). +// +// Note: If you register a variable that is not set when the script finishes, it will +// registered as NULL. +// +// +// *** You are strongly recommended to use only one method of the two above. *** +// +// (In fact if you use the register() function with register_globals Off, you have to +// use the $_APP method to get at the data). + +class Cache_Application extends Cache { + + var $data; + var $id; + var $group; + var $registered_vars; + + /** + * Constructor + * + * @param string Name of container class + * @param array Array with container class options + */ + function Cache_Application($container = 'file', $container_options = array('cache_dir' => '/tmp/', 'filename_prefix' => 'cache_'), $id = 'application_var', $group = 'application_cache') + { + $this->id = $id; + $this->group = $group; + $this->registered_vars = array(); + + $this->Cache($container, $container_options); + $this->data = $this->isCached($this->id, $this->group) ? unserialize($this->get($this->id, $this->group)) : array(); + + // If register_globals on, global all registered variables + if (ini_get('register_globals') AND is_array($this->data)) { + foreach ($this->data as $key => $value) { + global $$key; + $$key = $value; + } + } + } + + /** + * Destructor + * + * Gets values of all registered variables and stores them. Then calls save() to + * write data away. + */ + function _Cache_Application() + { + // Get contents of all registered variables + if (is_array($this->registered_vars) AND !empty($this->registered_vars)) { + foreach ($this->registered_vars as $varname) { + global $$varname; + $this->data[$varname] = $$varname; + } + } + + // Save the data + $this->save($this->id, serialize($this->data), 0, $this->group); + } + + /** + * register() + * + * Registers a variable to be stored. + * + * @param string Name of variable to register + * @param mixed Optional data to store + */ + function register($varname, $data = null) + { + if (isset($data)) { + $this->data[$varname] = $data; + } else { + $this->registered_vars[] = $varname; + } + } + + /** + * unregister() + * + * Unregisters a variable from being stored. + * + * @param string Name of variable to unregister + */ + function unregister($varname) + { + if (isset($this->data[$varname])) { + unset($this->data[$varname]); + } + } + + /** + * clear() + * + * Removes all stored data + */ + function clear() + { + $this->data = array(); + } + + /** + * getData() + * + * Use this to get a reference to the data to manipulate + * in calling script. Eg. $_APP =& $obj->getData(); + * + * @return mixed A reference to the data + */ + function &getData() + { + return $this->data; + } +} ?> Index: pear/Cache/Cache.php diff -u pear/Cache/Cache.php:1.1 pear/Cache/Cache.php:1.2 --- pear/Cache/Cache.php:1.1 Sun Jan 20 11:09:46 2002 +++ pear/Cache/Cache.php Mon May 20 13:34:26 2002 @@ -16,10 +16,10 @@ // | Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: Cache.php,v 1.1 2002/01/20 16:09:46 sebastian Exp $ +// $Id: Cache.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once('PEAR.php'); -require_once('Cache/Error.php'); +require_once 'PEAR.php'; +require_once 'Cache/Error.php'; /** * Cache is a base class for cache implementations. @@ -59,7 +59,7 @@ * bad circumstances (especially with the file container) * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: Cache.php,v 1.1 2002/01/20 16:09:46 sebastian Exp $ +* @version $Id: Cache.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ * @package Cache * @access public */ Index: pear/Cache/DB.php diff -u pear/Cache/DB.php:1.1 pear/Cache/DB.php:1.2 --- pear/Cache/DB.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/DB.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: DB.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; require_once 'DB.php'; /** @@ -27,7 +27,7 @@ * @module Cache_DB * @modulegroup Cache_DB * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class Cache_DB extends Cache { @@ -229,7 +229,7 @@ * @module Cache_DB * @modulegroup Cache_DB * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class Cache_DB_Result { Index: pear/Cache/Function.php diff -u pear/Cache/Function.php:1.1 pear/Cache/Function.php:1.2 --- pear/Cache/Function.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Function.php Mon May 20 13:34:26 2002 @@ -45,7 +45,7 @@ * @module Function_Cache * @modulegroup Function_Cache * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ @@ -65,9 +65,9 @@ // | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: Function.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: Function.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; class Cache_Function extends Cache { var $expires; Index: pear/Cache/Graphics.php diff -u pear/Cache/Graphics.php:1.1 pear/Cache/Graphics.php:1.2 --- pear/Cache/Graphics.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Graphics.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: Graphics.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: Graphics.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; /** * Graphics disk cache. @@ -66,7 +66,7 @@ * the output buffer. Modify it if required! * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: Graphics.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +* @version $Id: Graphics.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ * @package Cache */ class Cache_Graphics extends Cache { Index: pear/Cache/Output.php diff -u pear/Cache/Output.php:1.2 pear/Cache/Output.php:1.3 --- pear/Cache/Output.php:1.2 Wed Mar 27 16:11:21 2002 +++ pear/Cache/Output.php Mon May 20 13:34:26 2002 @@ -17,9 +17,9 @@ // | Vinai Kopp <kopp@netzarbeiter.de> | // +----------------------------------------------------------------------+ // -// $Id: Output.php,v 1.2 2002/03/27 21:11:21 chregu Exp $ +// $Id: Output.php,v 1.3 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; /** * Class to cache the output of a script using the output buffering functions Index: pear/Cache/package.xml diff -u pear/Cache/package.xml:1.8 pear/Cache/package.xml:1.9 --- pear/Cache/package.xml:1.8 Sun May 19 21:24:08 2002 +++ pear/Cache/package.xml Mon May 20 13:34:26 2002 @@ -1,56 +1,78 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> - <name>Cache</name> - <summary>Framework for caching of arbitrary data.</summary> - <description> - With the PEAR Cache you can cache the result of certain function - calls, as well as the output of a whole script run or share data - between applications. - </description> + <name>Cache</name> + <summary>Framework for caching of arbitrary data.</summary> + <description> +With the PEAR Cache you can cache the result of certain function +calls, as well as the output of a whole script run or share data +between applications. + </description> <maintainers> <maintainer> <user>chregu</user> + <role>lead</role> <name>Christian Stocker</name> <email>chregu@php.net</email> </maintainer> + <maintainer> + <user>sebastian</user> + <role>developer</role> + <name>Sebastian Bergmann</name> + <email>sb@sebastian-bergmann.de</email> + </maintainer> + <maintainer> + <user>uw</user> + <role>developer</role> + <name>Ulf Wendel</name> + <email>ulf.wendel@phpdoc.de</email> + </maintainer> </maintainers> - <license>PHP License</license> - <release> - <version>1.2</version> - <date>2002-01-20</date> - <state>stable</state> - <notes> - This is the initial independent PEAR release. - </notes> - <filelist> - <dir name="/"> - <file role="php" name="Cache.php"/> - <file role="php" baseinstalldir="Cache" name="Application.php"/> - <file role="php" baseinstalldir="Cache" name="Container.php"/> - <file role="php" baseinstalldir="Cache" name="DB.php"/> - <file role="php" baseinstalldir="Cache" name="Error.php"/> - <file role="php" baseinstalldir="Cache" name="Function.php"/> - <file role="php" baseinstalldir="Cache" name="Graphics.php"/> - <file role="php" baseinstalldir="Cache" name="Output.php"/> - <file role="php" baseinstalldir="Cache" name="OutputCompression.php"/> - <dir name="Container" baseinstalldir="Cache"> - <file role="php" name="db.php"/> - <file role="php" name="dbx.php"/> - <file role="php" name="file.php"/> - <file role="php" name="msession.php"/> - <file role="php" name="phplib.php"/> - <file role="php" name="shm.php"/> - </dir> - </dir> - </filelist> - </release> - <changelog> + <license>PHP License</license> <release> - <version>1.1</version> - <date>2001-03-27</date> - <notes> - Stable Code, SHM implementation missing - </notes> + <version>1.3</version> + <date>2002-05-20</date> + <state>stable</state> + <notes> +Fixed packaging. + </notes> + <filelist> + <dir name="/" baseinstalldir="Cache"> + <dir name="Container"> + <file role="php" name="db.php" /> + <file role="php" name="dbx.php" /> + <file role="php" name="file.php" /> + <file role="php" name="msession.php" /> + <file role="php" name="phplib.php" /> + <file role="php" name="shm.php" /> + </dir> + + <file role="php" name="Application.php" /> + <file role="php" name="Cache.php" /> + <file role="php" name="Container.php" /> + <file role="php" name="DB.php" /> + <file role="php" name="Error.php" /> + <file role="php" name="Function.php" /> + <file role="php" name="Graphics.php" /> + <file role="php" name="Output.php" /> + <file role="php" name="OutputCompression.php" /> + </dir> + </filelist> </release> - </changelog> + <changelog> + <release> + <version>1.2</version> + <date>2002-01-20</date> + <state>stable</state> + <notes> +This is the initial independent PEAR release. + </notes> + </release> + <release> + <version>1.1</version> + <date>2001-03-27</date> + <notes> +Stable Code, SHM implementation missing. + </notes> + </release> + </changelog> </package> Index: pear/Cache/Container/file.php diff -u pear/Cache/Container/file.php:1.4 pear/Cache/Container/file.php:1.5 --- pear/Cache/Container/file.php:1.4 Sun Feb 24 21:34:28 2002 +++ pear/Cache/Container/file.php Mon May 20 13:34:26 2002 @@ -16,15 +16,15 @@ // | Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: file.php,v 1.4 2002/02/25 02:34:28 chregu Exp $ +// $Id: file.php,v 1.5 2002/05/20 17:34:26 sebastian Exp $ -require_once('Cache/Container.php'); +require_once 'Cache/Container.php'; /** * Stores cache contents in a file. * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: file.php,v 1.4 2002/02/25 02:34:28 chregu Exp $ +* @version $Id: file.php,v 1.5 2002/05/20 17:34:26 sebastian Exp $ */ class Cache_Container_file extends Cache_Container { Index: pear/Cache/Container/msession.php diff -u pear/Cache/Container/msession.php:1.1 pear/Cache/Container/msession.php:1.2 --- pear/Cache/Container/msession.php:1.1 Sun Jan 20 11:06:23 2002 +++ pear/Cache/Container/msession.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: msession.php,v 1.1 2002/01/20 16:06:23 sebastian Exp $ +// $Id: msession.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once('Cache/Container.php'); +require_once 'Cache/Container.php'; /** * Stores cache contents in msessions. @@ -25,7 +25,7 @@ * WARNING: experimental, untested * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: msession.php,v 1.1 2002/01/20 16:06:23 sebastian Exp $ +* @version $Id: msession.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ */ class Cache_Container_msession extends Cache_Container {
Index: pear/Cache/Application.php diff -u pear/Cache/Application.php:1.1 pear/Cache/Application.php:1.2 --- pear/Cache/Application.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Application.php Mon May 20 13:34:26 2002 @@ -1,178 +1,178 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Richard Heyes <richard@phpguru.org> | -// +----------------------------------------------------------------------+ -// -// $Id: Application.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ - -require_once('Cache.php'); - -// Application level variables -// -// Purpose -// Variables that are persisent across all user sessions, -// not just a specific user ala normal sessions. -// -// Usage: -// -// Example 1: -// -// $app =& new Cache_Application(); -// $_APP =& $app->getData(); -// -// In this case the $_APP variable is akin to the $_SESSION variable. -// If you add/remove stuff, it will be reflected in the next request -// (of any user). -// -// Example 2: -// -// $foo = 'Some data'; -// $bar = 'Some other data'; -// -// $app =& new Cache_Application(); -// $app->register('foo'); -// $app->register('bar', $bar); -// -// $foo = 'Different data'; -// -// In this case the variables are registered with the register() function. -// This is akin to session_register(). -// -// As with session_register(), the contents of the variable at the *end* of the -// request is registered and not at the point of registration. Therefore in this -// example, for the $foo variable, the string 'Different data' is stored and not -// 'Some data'. The exception to this rule is if you use the second argument to -// register() as in the second call to it above. This will cause the data supplied -// in the second argument to be stored and not the contents at the end of the request. -// -// Note: If you use this method with register_globals turned on, the variables will be -// automatically globalled upon startup, (ie. when you create the object). -// -// Note: If you register a variable that is not set when the script finishes, it will -// registered as NULL. -// -// -// *** You are strongly recommended to use only one method of the two above. *** -// -// (In fact if you use the register() function with register_globals Off, you have to -// use the $_APP method to get at the data). - -class Cache_Application extends Cache { - - var $data; - var $id; - var $group; - var $registered_vars; - - /** - * Constructor - * - * @param string Name of container class - * @param array Array with container class options - */ - function Cache_Application($container = 'file', $container_options = array('cache_dir' => '/tmp/', 'filename_prefix' => 'cache_'), $id = 'application_var', $group = 'application_cache') - { - $this->id = $id; - $this->group = $group; - $this->registered_vars = array(); - - $this->Cache($container, $container_options); - $this->data = $this->isCached($this->id, $this->group) ? unserialize($this->get($this->id, $this->group)) : array(); - - // If register_globals on, global all registered variables - if (ini_get('register_globals') AND is_array($this->data)) { - foreach ($this->data as $key => $value) { - global $$key; - $$key = $value; - } - } - } - - /** - * Destructor - * - * Gets values of all registered variables and stores them. Then calls save() to - * write data away. - */ - function _Cache_Application() - { - // Get contents of all registered variables - if (is_array($this->registered_vars) AND !empty($this->registered_vars)) { - foreach ($this->registered_vars as $varname) { - global $$varname; - $this->data[$varname] = $$varname; - } - } - - // Save the data - $this->save($this->id, serialize($this->data), 0, $this->group); - } - - /** - * register() - * - * Registers a variable to be stored. - * - * @param string Name of variable to register - * @param mixed Optional data to store - */ - function register($varname, $data = null) - { - if (isset($data)) { - $this->data[$varname] = $data; - } else { - $this->registered_vars[] = $varname; - } - } - - /** - * unregister() - * - * Unregisters a variable from being stored. - * - * @param string Name of variable to unregister - */ - function unregister($varname) - { - if (isset($this->data[$varname])) { - unset($this->data[$varname]); - } - } - - /** - * clear() - * - * Removes all stored data - */ - function clear() - { - $this->data = array(); - } - - /** - * getData() - * - * Use this to get a reference to the data to manipulate - * in calling script. Eg. $_APP =& $obj->getData(); - * - * @return mixed A reference to the data - */ - function &getData() - { - return $this->data; - } -} +<?php +// +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Richard Heyes <richard@phpguru.org> | +// +----------------------------------------------------------------------+ +// +// $Id: Application.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ + +require_once 'Cache/Cache.php'; + +// Application level variables +// +// Purpose +// Variables that are persisent across all user sessions, +// not just a specific user ala normal sessions. +// +// Usage: +// +// Example 1: +// +// $app =& new Cache_Application(); +// $_APP =& $app->getData(); +// +// In this case the $_APP variable is akin to the $_SESSION variable. +// If you add/remove stuff, it will be reflected in the next request +// (of any user). +// +// Example 2: +// +// $foo = 'Some data'; +// $bar = 'Some other data'; +// +// $app =& new Cache_Application(); +// $app->register('foo'); +// $app->register('bar', $bar); +// +// $foo = 'Different data'; +// +// In this case the variables are registered with the register() function. +// This is akin to session_register(). +// +// As with session_register(), the contents of the variable at the *end* of the +// request is registered and not at the point of registration. Therefore in this +// example, for the $foo variable, the string 'Different data' is stored and not +// 'Some data'. The exception to this rule is if you use the second argument to +// register() as in the second call to it above. This will cause the data supplied +// in the second argument to be stored and not the contents at the end of the request. +// +// Note: If you use this method with register_globals turned on, the variables will be +// automatically globalled upon startup, (ie. when you create the object). +// +// Note: If you register a variable that is not set when the script finishes, it will +// registered as NULL. +// +// +// *** You are strongly recommended to use only one method of the two above. *** +// +// (In fact if you use the register() function with register_globals Off, you have to +// use the $_APP method to get at the data). + +class Cache_Application extends Cache { + + var $data; + var $id; + var $group; + var $registered_vars; + + /** + * Constructor + * + * @param string Name of container class + * @param array Array with container class options + */ + function Cache_Application($container = 'file', $container_options = array('cache_dir' => '/tmp/', 'filename_prefix' => 'cache_'), $id = 'application_var', $group = 'application_cache') + { + $this->id = $id; + $this->group = $group; + $this->registered_vars = array(); + + $this->Cache($container, $container_options); + $this->data = $this->isCached($this->id, $this->group) ? unserialize($this->get($this->id, $this->group)) : array(); + + // If register_globals on, global all registered variables + if (ini_get('register_globals') AND is_array($this->data)) { + foreach ($this->data as $key => $value) { + global $$key; + $$key = $value; + } + } + } + + /** + * Destructor + * + * Gets values of all registered variables and stores them. Then calls save() to + * write data away. + */ + function _Cache_Application() + { + // Get contents of all registered variables + if (is_array($this->registered_vars) AND !empty($this->registered_vars)) { + foreach ($this->registered_vars as $varname) { + global $$varname; + $this->data[$varname] = $$varname; + } + } + + // Save the data + $this->save($this->id, serialize($this->data), 0, $this->group); + } + + /** + * register() + * + * Registers a variable to be stored. + * + * @param string Name of variable to register + * @param mixed Optional data to store + */ + function register($varname, $data = null) + { + if (isset($data)) { + $this->data[$varname] = $data; + } else { + $this->registered_vars[] = $varname; + } + } + + /** + * unregister() + * + * Unregisters a variable from being stored. + * + * @param string Name of variable to unregister + */ + function unregister($varname) + { + if (isset($this->data[$varname])) { + unset($this->data[$varname]); + } + } + + /** + * clear() + * + * Removes all stored data + */ + function clear() + { + $this->data = array(); + } + + /** + * getData() + * + * Use this to get a reference to the data to manipulate + * in calling script. Eg. $_APP =& $obj->getData(); + * + * @return mixed A reference to the data + */ + function &getData() + { + return $this->data; + } +} ?> Index: pear/Cache/Cache.php diff -u pear/Cache/Cache.php:1.1 pear/Cache/Cache.php:1.2 --- pear/Cache/Cache.php:1.1 Sun Jan 20 11:09:46 2002 +++ pear/Cache/Cache.php Mon May 20 13:34:26 2002 @@ -16,10 +16,10 @@ // | Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: Cache.php,v 1.1 2002/01/20 16:09:46 sebastian Exp $ +// $Id: Cache.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once('PEAR.php'); -require_once('Cache/Error.php'); +require_once 'PEAR.php'; +require_once 'Cache/Error.php'; /** * Cache is a base class for cache implementations. @@ -59,7 +59,7 @@ * bad circumstances (especially with the file container) * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: Cache.php,v 1.1 2002/01/20 16:09:46 sebastian Exp $ +* @version $Id: Cache.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ * @package Cache * @access public */ Index: pear/Cache/DB.php diff -u pear/Cache/DB.php:1.1 pear/Cache/DB.php:1.2 --- pear/Cache/DB.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/DB.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: DB.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; require_once 'DB.php'; /** @@ -27,7 +27,7 @@ * @module Cache_DB * @modulegroup Cache_DB * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class Cache_DB extends Cache { @@ -229,7 +229,7 @@ * @module Cache_DB * @modulegroup Cache_DB * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class Cache_DB_Result { Index: pear/Cache/Function.php diff -u pear/Cache/Function.php:1.1 pear/Cache/Function.php:1.2 --- pear/Cache/Function.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Function.php Mon May 20 13:34:26 2002 @@ -45,7 +45,7 @@ * @module Function_Cache * @modulegroup Function_Cache * @package Cache -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ @@ -65,9 +65,9 @@ // | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: Function.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: Function.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; class Cache_Function extends Cache { var $expires; Index: pear/Cache/Graphics.php diff -u pear/Cache/Graphics.php:1.1 pear/Cache/Graphics.php:1.2 --- pear/Cache/Graphics.php:1.1 Sun Jan 20 11:06:22 2002 +++ pear/Cache/Graphics.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: Graphics.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +// $Id: Graphics.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; /** * Graphics disk cache. @@ -66,7 +66,7 @@ * the output buffer. Modify it if required! * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: Graphics.php,v 1.1 2002/01/20 16:06:22 sebastian Exp $ +* @version $Id: Graphics.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ * @package Cache */ class Cache_Graphics extends Cache { Index: pear/Cache/Output.php diff -u pear/Cache/Output.php:1.2 pear/Cache/Output.php:1.3 --- pear/Cache/Output.php:1.2 Wed Mar 27 16:11:21 2002 +++ pear/Cache/Output.php Mon May 20 13:34:26 2002 @@ -17,9 +17,9 @@ // | Vinai Kopp <kopp@netzarbeiter.de> | // +----------------------------------------------------------------------+ // -// $Id: Output.php,v 1.2 2002/03/27 21:11:21 chregu Exp $ +// $Id: Output.php,v 1.3 2002/05/20 17:34:26 sebastian Exp $ -require_once 'Cache.php'; +require_once 'Cache/Cache.php'; /** * Class to cache the output of a script using the output buffering functions Index: pear/Cache/package.xml diff -u pear/Cache/package.xml:1.8 pear/Cache/package.xml:1.9 --- pear/Cache/package.xml:1.8 Sun May 19 21:24:08 2002 +++ pear/Cache/package.xml Mon May 20 13:34:26 2002 @@ -1,56 +1,78 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> - <name>Cache</name> - <summary>Framework for caching of arbitrary data.</summary> - <description> - With the PEAR Cache you can cache the result of certain function - calls, as well as the output of a whole script run or share data - between applications. - </description> + <name>Cache</name> + <summary>Framework for caching of arbitrary data.</summary> + <description> +With the PEAR Cache you can cache the result of certain function +calls, as well as the output of a whole script run or share data +between applications. + </description> <maintainers> <maintainer> <user>chregu</user> + <role>lead</role> <name>Christian Stocker</name> <email>chregu@php.net</email> </maintainer> + <maintainer> + <user>sebastian</user> + <role>developer</role> + <name>Sebastian Bergmann</name> + <email>sb@sebastian-bergmann.de</email> + </maintainer> + <maintainer> + <user>uw</user> + <role>developer</role> + <name>Ulf Wendel</name> + <email>ulf.wendel@phpdoc.de</email> + </maintainer> </maintainers> - <license>PHP License</license> - <release> - <version>1.2</version> - <date>2002-01-20</date> - <state>stable</state> - <notes> - This is the initial independent PEAR release. - </notes> - <filelist> - <dir name="/"> - <file role="php" name="Cache.php"/> - <file role="php" baseinstalldir="Cache" name="Application.php"/> - <file role="php" baseinstalldir="Cache" name="Container.php"/> - <file role="php" baseinstalldir="Cache" name="DB.php"/> - <file role="php" baseinstalldir="Cache" name="Error.php"/> - <file role="php" baseinstalldir="Cache" name="Function.php"/> - <file role="php" baseinstalldir="Cache" name="Graphics.php"/> - <file role="php" baseinstalldir="Cache" name="Output.php"/> - <file role="php" baseinstalldir="Cache" name="OutputCompression.php"/> - <dir name="Container" baseinstalldir="Cache"> - <file role="php" name="db.php"/> - <file role="php" name="dbx.php"/> - <file role="php" name="file.php"/> - <file role="php" name="msession.php"/> - <file role="php" name="phplib.php"/> - <file role="php" name="shm.php"/> - </dir> - </dir> - </filelist> - </release> - <changelog> + <license>PHP License</license> <release> - <version>1.1</version> - <date>2001-03-27</date> - <notes> - Stable Code, SHM implementation missing - </notes> + <version>1.3</version> + <date>2002-05-20</date> + <state>stable</state> + <notes> +Fixed packaging. + </notes> + <filelist> + <dir name="/" baseinstalldir="Cache"> + <dir name="Container"> + <file role="php" name="db.php" /> + <file role="php" name="dbx.php" /> + <file role="php" name="file.php" /> + <file role="php" name="msession.php" /> + <file role="php" name="phplib.php" /> + <file role="php" name="shm.php" /> + </dir> + + <file role="php" name="Application.php" /> + <file role="php" name="Cache.php" /> + <file role="php" name="Container.php" /> + <file role="php" name="DB.php" /> + <file role="php" name="Error.php" /> + <file role="php" name="Function.php" /> + <file role="php" name="Graphics.php" /> + <file role="php" name="Output.php" /> + <file role="php" name="OutputCompression.php" /> + </dir> + </filelist> </release> - </changelog> + <changelog> + <release> + <version>1.2</version> + <date>2002-01-20</date> + <state>stable</state> + <notes> +This is the initial independent PEAR release. + </notes> + </release> + <release> + <version>1.1</version> + <date>2001-03-27</date> + <notes> +Stable Code, SHM implementation missing. + </notes> + </release> + </changelog> </package> Index: pear/Cache/Container/file.php diff -u pear/Cache/Container/file.php:1.4 pear/Cache/Container/file.php:1.5 --- pear/Cache/Container/file.php:1.4 Sun Feb 24 21:34:28 2002 +++ pear/Cache/Container/file.php Mon May 20 13:34:26 2002 @@ -16,15 +16,15 @@ // | Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: file.php,v 1.4 2002/02/25 02:34:28 chregu Exp $ +// $Id: file.php,v 1.5 2002/05/20 17:34:26 sebastian Exp $ -require_once('Cache/Container.php'); +require_once 'Cache/Container.php'; /** * Stores cache contents in a file. * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: file.php,v 1.4 2002/02/25 02:34:28 chregu Exp $ +* @version $Id: file.php,v 1.5 2002/05/20 17:34:26 sebastian Exp $ */ class Cache_Container_file extends Cache_Container { Index: pear/Cache/Container/msession.php diff -u pear/Cache/Container/msession.php:1.1 pear/Cache/Container/msession.php:1.2 --- pear/Cache/Container/msession.php:1.1 Sun Jan 20 11:06:23 2002 +++ pear/Cache/Container/msession.php Mon May 20 13:34:26 2002 @@ -15,9 +15,9 @@ // | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: msession.php,v 1.1 2002/01/20 16:06:23 sebastian Exp $ +// $Id: msession.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ -require_once('Cache/Container.php'); +require_once 'Cache/Container.php'; /** * Stores cache contents in msessions. @@ -25,7 +25,7 @@ * WARNING: experimental, untested * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id: msession.php,v 1.1 2002/01/20 16:06:23 sebastian Exp $ +* @version $Id: msession.php,v 1.2 2002/05/20 17:34:26 sebastian Exp $ */ class Cache_Container_msession extends Cache_Container {