[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZClusterFileHandler class 4 // 5 // Created on: <07-Mar-2006 16:14:02 vs> 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 ezclusterfilehandler.php 30 */ 31 32 class eZClusterFileHandler 33 { 34 /** 35 * \public 36 * \static 37 * \return filehandler 38 */ 39 function instance( $filename = false ) 40 { 41 // Determine handler to use and cache its name in a global variable. 42 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler_class'] ) ) 43 { 44 require_once ( 'lib/ezutils/classes/ezini.php' ); 45 $fileINI = eZINI::instance( 'file.ini' ); 46 $handlerName = 'ezfs'; 47 if ( $fileINI->hasVariable( 'ClusteringSettings', 'FileHandler' ) ) 48 $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' ); 49 50 // Create list of directories used to search cluster file handlers for. 51 $searchPathArray = eZClusterFileHandler::searchPathArray(); 52 53 // Find chosen handler. 54 $handlerClass = $handlerName . 'filehandler'; 55 foreach ( $searchPathArray as $searchPath ) 56 { 57 $includeFileName = $searchPath . '/' . $handlerClass . '.php'; 58 if ( is_readable( $includeFileName ) ) 59 { 60 include_once( $includeFileName ); 61 $GLOBALS['eZClusterFileHandler_chosen_handler_class'] = $handlerClass; 62 break; 63 } 64 } 65 66 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler_class'] ) ) 67 { 68 eZDebug::writeError( "Cannot find cluster file handler '$handlerName'." ); 69 return null; 70 } 71 } 72 73 // Instantiate the handler. 74 if ( $filename !== false ) 75 { 76 // return new FileHandler based on INI setting. 77 $handlerClass = $GLOBALS['eZClusterFileHandler_chosen_handler_class']; 78 return new $handlerClass( $filename ); 79 } 80 else 81 { 82 // return Filehandler from GLOBALS based on ini setting. 83 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler'] ) ) 84 { 85 $handlerClass = $GLOBALS['eZClusterFileHandler_chosen_handler_class']; 86 $handler = new $handlerClass; 87 $GLOBALS['eZClusterFileHandler_chosen_handler'] = $handler; 88 } 89 else 90 $handler = $GLOBALS['eZClusterFileHandler_chosen_handler']; 91 92 return $handler; 93 } 94 } 95 96 /** 97 * \public 98 * \static 99 * \return list of directories used to search cluster file handlers for. 100 */ 101 function searchPathArray() 102 { 103 if ( !isset( $GLOBALS['eZClusterFileHandler_search_path_array'] ) ) 104 { 105 $fileINI = eZINI::instance( 'file.ini' ); 106 $searchPathArray = array( 'kernel/classes/clusterfilehandlers' ); 107 if ( $fileINI->hasVariable( 'ClusteringSettings', 'ExtensionDirectories' ) ) 108 { 109 $extensionDirectories = $fileINI->variable( 'ClusteringSettings', 'ExtensionDirectories' ); 110 require_once ( 'lib/ezutils/classes/ezextension.php' ); 111 $baseDirectory = eZExtension::baseDirectory(); 112 foreach ( $extensionDirectories as $extensionDirectory ) 113 { 114 $customSearchPath = $baseDirectory . '/' . $extensionDirectory . '/clusterfilehandlers'; 115 if ( file_exists( $customSearchPath ) ) 116 $searchPathArray[] = $customSearchPath; 117 } 118 } 119 120 $GLOBALS['eZClusterFileHandler_search_path_array'] = $searchPathArray; 121 } 122 123 return $GLOBALS['eZClusterFileHandler_search_path_array']; 124 } 125 } 126 127 ?>
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 |