autoload.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. define('ELFINDER_PHP_ROOT_PATH', dirname(__FILE__));
  3. function elFinderAutoloader($name) {
  4. $map = array(
  5. 'elFinder' => ELFINDER_PHP_ROOT_PATH . '/elFinder.class.php',
  6. 'elFinderConnector' => ELFINDER_PHP_ROOT_PATH . '/elFinderConnector.class.php',
  7. 'elFinderEditor' => ELFINDER_PHP_ROOT_PATH . '/editors/editor.php',
  8. 'elFinderLibGdBmp' => ELFINDER_PHP_ROOT_PATH . '/libs/GdBmp.php',
  9. 'elFinderPlugin' => ELFINDER_PHP_ROOT_PATH . '/elFinderPlugin.php',
  10. 'elFinderPluginAutoResize' => ELFINDER_PHP_ROOT_PATH . '/plugins/AutoResize/plugin.php',
  11. 'elFinderPluginAutoRotate' => ELFINDER_PHP_ROOT_PATH . '/plugins/AutoRotate/plugin.php',
  12. 'elFinderPluginNormalizer' => ELFINDER_PHP_ROOT_PATH . '/plugins/Normalizer/plugin.php',
  13. 'elFinderPluginSanitizer' => ELFINDER_PHP_ROOT_PATH . '/plugins/Sanitizer/plugin.php',
  14. 'elFinderPluginWatermark' => ELFINDER_PHP_ROOT_PATH . '/plugins/Watermark/plugin.php',
  15. 'elFinderSession' => ELFINDER_PHP_ROOT_PATH . '/elFinderSession.php',
  16. 'elFinderSessionInterface' => ELFINDER_PHP_ROOT_PATH . '/elFinderSessionInterface.php',
  17. 'elFinderVolumeDriver' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeDriver.class.php',
  18. 'elFinderVolumeDropbox2' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeDropbox2.class.php',
  19. 'elFinderVolumeFTP' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeFTP.class.php',
  20. 'elFinderVolumeFlysystemGoogleDriveCache' => ELFINDER_PHP_ROOT_PATH . '/elFinderFlysystemGoogleDriveNetmount.php',
  21. 'elFinderVolumeFlysystemGoogleDriveNetmount' => ELFINDER_PHP_ROOT_PATH . '/elFinderFlysystemGoogleDriveNetmount.php',
  22. 'elFinderVolumeGoogleDrive' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeGoogleDrive.class.php',
  23. 'elFinderVolumeGroup' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeGroup.class.php',
  24. 'elFinderVolumeLocalFileSystem' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeLocalFileSystem.class.php',
  25. 'elFinderVolumeMySQL' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeMySQL.class.php',
  26. 'elFinderVolumeTrash' => ELFINDER_PHP_ROOT_PATH . '/elFinderVolumeTrash.class.php',
  27. );
  28. if (isset($map[$name])) {
  29. return include_once($map[$name]);
  30. }
  31. $prefix = substr($name, 0, 14);
  32. if (substr($prefix, 0, 8) === 'elFinder') {
  33. if ($prefix === 'elFinderVolume') {
  34. $file = ELFINDER_PHP_ROOT_PATH . '/' . $name . '.class.php';
  35. return (is_file($file) && include_once($file));
  36. } else if ($prefix === 'elFinderPlugin') {
  37. $file = ELFINDER_PHP_ROOT_PATH . '/plugins/' . substr($name, 14) . '/plugin.php';
  38. return (is_file($file) && include_once($file));
  39. } else if ($prefix === 'elFinderEditor') {
  40. $file = ELFINDER_PHP_ROOT_PATH . '/editors/' . substr($name, 14) . '/editor.php';
  41. return (is_file($file) && include_once($file));
  42. }
  43. }
  44. return false;
  45. }
  46. if (version_compare(PHP_VERSION, '5.3', '<')) {
  47. spl_autoload_register('elFinderAutoloader');
  48. } else {
  49. spl_autoload_register('elFinderAutoloader', true, true);
  50. }