00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00046 include_once( 'lib/ezutils/classes/ezphpcreator.php' );
00047
eZExpiryHandler
00049 {
eZExpiryHandler()
00054 {
00055 $this->Timestamps = array();
00056 $this->IsModified = false;
00057 $this->restore();
00058 }
00059
restore()
00064 {
00065 $cacheDirectory = eZSys::cacheDirectory();
00066 $creator = new eZPHPCreator( $cacheDirectory, 'expiry.php' );
00067 if ( $creator->canRestore() )
00068 {
00069 $values = $creator->restore( array( 'timestamps' => 'Timestamps' ) );
00070 $this->Timestamps = $values['timestamps'];
00071 $this->IsModified = false;
00072 }
00073 }
00074
store()
00079 {
00080 $cacheDirectory = eZSys::cacheDirectory();
00081 $creator = new eZPHPCreator( $cacheDirectory, 'expiry.php' );
00082
00083 $creator->addComment( "Array of expiry timestamps for various system parts\nCan be set to current date to force a total expiry" );
00084 $creator->addVariable( 'Timestamps', $this->Timestamps );
00085
00086 $creator->store();
00087 $this->IsModified = false;
00088 }
00089
setTimestamp( $name, $value )
00094 {
00095 $this->Timestamps[$name] = $value;
00096 $this->IsModified = true;
00097 }
00098
hasTimestamp( $name )
00103 {
00104 return isset( $this->Timestamps[$name] );
00105 }
00106
timestamp( $name )
00111 {
00112 if ( !isset( $this->Timestamps[$name] ) )
00113 {
00114 eZExpiryHandler::timestamp' );
00115 return false;
00116 }
00117 return $this->Timestamps[$name];
00118 }
00119
instance()
00125 {
00126 $expiryInstance =& $GLOBALS['eZExpiryHandlerInstance'];
00127 if ( !isset( $expiryInstance ) )
00128 {
00129 $eZExpiryHandler();
00130 }
00131 return $expiryInstance;
00132 }
00133
isModified()
00138 {
00139 return $this->IsModified;
00140 }
00141
Timestamps;
00144 var $IsModified;
00145 }
00146
00150 function eZExpiryHandlerShutdownHandler()
00151 {
00152 $expiryInstance =& $GLOBALS['eZExpiryHandlerInstance'];
00153 if ( isset( $expiryInstance ) and
00154 get_class( $expiryInstance ) == 'ezexpiryhandler' )
00155 {
00156 $instance =& eZExpiryHandler::instance();
00157 if ( $instance->isModified() )
00158 {
00159 $instance->store();
00160 }
00161 }
00162 }
00163
00164 register_shutdown_function( 'eZExpiryHandlerShutdownHandler' );
00165
00166 ?>