芝麻web文件管理V1.00
编辑当前文件:/var/www/italafricacentrale.com/wp-content/plugins/mapsvg/php/Autoloader.php
*/ class Autoloader { /** * File extension as a string. Defaults to ".php". */ protected static $fileExt = '.php'; /** * The top level directory where recursion will begin. Defaults to the current * directory. */ protected static $pathTop = __DIR__; /** * A placeholder to hold the file iterator so that directory traversal is only * performed once. */ protected static $fileIterator = null; /** * Autoload function for registration with spl_autoload_register * * Looks recursively through project directory and loads class files based on * filename match. * * @param string $className */ public static function loader( $className ) { if(strpos($className, "Options")){ $che = 1; } if(strpos($className, "MapSVG") === false){ return; } $exclude = array('Vendor'); $filter = function ($file, $key, $iterator) use ($exclude) { if ($iterator->hasChildren() && !in_array($file->getFilename(), $exclude)) { return true; } return $file->isFile(); }; $innerIterator = new \RecursiveDirectoryIterator( static::$pathTop, \RecursiveDirectoryIterator::SKIP_DOTS ); if ( is_null( static::$fileIterator ) ) { static::$fileIterator = new \RecursiveIteratorIterator( new \RecursiveCallbackFilterIterator($innerIterator, $filter), \RecursiveIteratorIterator::SELF_FIRST, \RecursiveIteratorIterator::CATCH_GET_CHILD ); } // if ( is_null( static::$fileIterator ) ) { // static::$fileIterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( static::$pathTop, \RecursiveDirectoryIterator::SKIP_DOTS ), \RecursiveIteratorIterator::SELF_FIRST, \RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied" // ); // } $filename = str_replace(__NAMESPACE__."\\","",$className . static::$fileExt); foreach ( static::$fileIterator as $file ) { if ( strtolower( $file->getFilename() ) === strtolower( $filename ) ) { if ( $file->isReadable() ) { include_once $file->getPathname(); } break; } } } /** * Sets the $fileExt property * * @param string $fileExt The file extension used for class files. Default is "php". */ public static function setFileExt($fileExt) { static::$fileExt = $fileExt; } /** * Sets the $path property * * @param string $path The path representing the top level where recursion should * begin. Defaults to the current directory. */ public static function setPath($path) { static::$pathTop = $path; } } Autoloader::setFileExt('.php'); spl_autoload_register('\MapSVG\Autoloader::loader'); // EOF