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 class eZClusterFileHandler
00035 {
00036
00037
00038
00039
00040
00041 function instance( $filename = false )
00042 {
00043
00044 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler_class'] ) )
00045 {
00046 require_once( 'lib/ezutils/classes/ezini.php' );
00047 $fileINI = eZINI::instance( 'file.ini' );
00048 $handlerName = 'ezfs';
00049 if ( $fileINI->hasVariable( 'ClusteringSettings', 'FileHandler' ) )
00050 $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
00051
00052
00053 $searchPathArray = eZClusterFileHandler::searchPathArray();
00054
00055
00056 $handlerClass = $handlerName . 'filehandler';
00057 foreach ( $searchPathArray as $searchPath )
00058 {
00059 $includeFileName = $searchPath . '/' . $handlerClass . '.php';
00060 if ( is_readable( $includeFileName ) )
00061 {
00062 include_once( $includeFileName );
00063 $GLOBALS['eZClusterFileHandler_chosen_handler_class'] = $handlerClass;
00064 break;
00065 }
00066 }
00067
00068 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler_class'] ) )
00069 {
00070 eZDebug::writeError( "Cannot find cluster file handler '$handlerName'." );
00071 return null;
00072 }
00073 }
00074
00075
00076 if ( $filename !== false )
00077 {
00078
00079 $handlerClass = $GLOBALS['eZClusterFileHandler_chosen_handler_class'];
00080 return new $handlerClass( $filename );
00081 }
00082 else
00083 {
00084
00085 if ( !isset( $GLOBALS['eZClusterFileHandler_chosen_handler'] ) )
00086 {
00087 $handlerClass = $GLOBALS['eZClusterFileHandler_chosen_handler_class'];
00088 $handler = new $handlerClass;
00089 $GLOBALS['eZClusterFileHandler_chosen_handler'] = $handler;
00090 }
00091 else
00092 $handler = $GLOBALS['eZClusterFileHandler_chosen_handler'];
00093
00094 return $handler;
00095 }
00096 }
00097
00098
00099
00100
00101
00102
00103 function searchPathArray()
00104 {
00105 if ( !isset( $GLOBALS['eZClusterFileHandler_search_path_array'] ) )
00106 {
00107 $fileINI = eZINI::instance( 'file.ini' );
00108 $searchPathArray = array( 'kernel/classes/clusterfilehandlers' );
00109 if ( $fileINI->hasVariable( 'ClusteringSettings', 'ExtensionDirectories' ) )
00110 {
00111 $extensionDirectories = $fileINI->variable( 'ClusteringSettings', 'ExtensionDirectories' );
00112 require_once( 'lib/ezutils/classes/ezextension.php' );
00113 $baseDirectory = eZExtension::baseDirectory();
00114 foreach ( $extensionDirectories as $extensionDirectory )
00115 {
00116 $customSearchPath = $baseDirectory . '/' . $extensionDirectory . '/clusterfilehandlers';
00117 if ( file_exists( $customSearchPath ) )
00118 $searchPathArray[] = $customSearchPath;
00119 }
00120 }
00121
00122 $GLOBALS['eZClusterFileHandler_search_path_array'] = $searchPathArray;
00123 }
00124
00125 return $GLOBALS['eZClusterFileHandler_search_path_array'];
00126 }
00127 }
00128
00129 ?>