[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZExecution class 4 // 5 // Created on: <29-Nov-2002 11:24:42 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezexecution.php 30 */ 31 32 /*! 33 \class eZExecution ezexecution.php 34 \brief Handles proper script execution, fatal error detection and handling. 35 36 By registering a fatal error handler it's possible for the PHP script to 37 catch fatal errors, such as "Call to a member function on a non-object". 38 39 By registering a cleanup handler it's possible to make sure the script can 40 end properly. 41 */ 42 43 class eZExecution 44 { 45 /*! 46 Constructor 47 */ 48 function eZExecution() 49 { 50 } 51 52 /*! 53 Sets the clean exit flag to on, 54 this notifies the exit handler that everything finished properly. 55 */ 56 function setCleanExit() 57 { 58 $GLOBALS['eZExecutionCleanExit'] = true; 59 } 60 61 /*! 62 Calls the cleanup handlers to make sure that the script is ready to exit. 63 */ 64 function cleanup() 65 { 66 $handlers =& eZExecution::cleanupHandlers(); 67 foreach ( $handlers as $handler ) 68 { 69 if ( function_exists( $handler ) ) 70 $handler(); 71 } 72 } 73 74 /*! 75 Adds a cleanup handler to the end of the list, 76 \a $handler must contain the name of the function to call. 77 The function is called at the end of the script execution to 78 do some cleanups. 79 */ 80 function addCleanupHandler( $handler ) 81 { 82 $handlers =& eZExecution::cleanupHandlers(); 83 $handlers[] = $handler; 84 } 85 86 /*! 87 \return An array with cleanup handlers. 88 */ 89 function &cleanupHandlers() 90 { 91 $handlers =& $GLOBALS['eZExecutionCleanupHandlers']; 92 if ( !isset( $handlers ) ) 93 $handlers = array(); 94 return $handlers; 95 } 96 97 /*! 98 Adds a fatal error handler to the end of the list, 99 \a $handler must contain the name of the function to call. 100 The handler will be called whenever a fatal error occurs, 101 which usually happens when the script did not finish. 102 */ 103 function addFatalErrorHandler( $handler ) 104 { 105 $handlers =& eZExecution::fatalErrorHandlers(); 106 $handlers[] = $handler; 107 } 108 109 /*! 110 \return An array with fatal error handlers. 111 */ 112 function &fatalErrorHandlers() 113 { 114 $handlers =& $GLOBALS['eZExecutionFatalErrorHandlers']; 115 if ( !isset( $handlers ) ) 116 $handlers = array(); 117 return $handlers; 118 } 119 120 /*! 121 \return true if the request finished properly. 122 */ 123 function isCleanExit() 124 { 125 return $GLOBALS['eZExecutionCleanExit']; 126 } 127 128 /*! 129 Sets the clean exit flag and exits the page. 130 Use this if you want premature exits instead of the \c exit function. 131 */ 132 function cleanExit() 133 { 134 eZExecution::cleanup(); 135 eZExecution::setCleanExit(); 136 exit; 137 } 138 139 } 140 141 142 /*! 143 Exit handler which called after the script is done, if it detects 144 that eZ publish did not exit cleanly it will issue an error message 145 and display the debug. 146 */ 147 function eZExecutionUncleanShutdownHandler() 148 { 149 if ( eZExecution::isCleanExit() ) 150 return; 151 eZExecution::cleanup(); 152 $handlers =& eZExecution::fatalErrorHandlers(); 153 foreach ( $handlers as $handler ) 154 { 155 if ( function_exists( $handler ) ) 156 $handler(); 157 } 158 } 159 160 register_shutdown_function( 'eZExecutionUncleanShutdownHandler' ); 161 162 $GLOBALS['eZExecutionCleanExit'] = false; 163 164 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |