ezexpiryhandler.php

Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZExpiryHandler class
00004 //
00005 // Created on: <28-Feb-2003 16:52:53 amos>
00006 //
00007 // Copyright (C) 1999-2003 Exponential. All rights reserved.
00008 //
00009 // This source file is part of the Exponential (tm) Open Source Content
00010 // Management System.
00011 //
00012 // This file may be distributed and/or modified under the terms of the
00013 // "GNU General Public License" version 2 as published by the Free
00014 // Software Foundation and appearing in the file LICENSE.GPL included in
00015 // the packaging of this file.
00016 //
00017 // Licencees holding valid "Exponential professional licences" may use this
00018 // file in accordance with the "Exponential professional licence" Agreement
00019 // provided with the Software.
00020 //
00021 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
00022 // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00023 // PURPOSE.
00024 //
00025 // The "Exponential professional licence" is available at
00026 // http://ez.no/products/licences/professional/. For pricing of this licence
00027 // please contact us via e-mail to licence@ez.no. Further contact
00028 // information is available at http://ez.no/home/contact/.
00029 //
00030 // The "GNU General Public License" (GPL) is available at
00031 // http://www.gnu.org/copyleft/gpl.html.
00032 //
00033 // Contact licence@ez.no if any conditions of this licencing isn't clear to
00034 // you.
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 ?>
 

Exponential