Autoloader.php 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * autoload library
  4. */
  5. PHPExcel_Autoloader::Register();
  6. class PHPExcel_Autoloader {
  7. /**
  8. * Register the Autoloader with SPL
  9. */
  10. public static function Register() {
  11. if (function_exists('__autoload')) {
  12. spl_autoload_register('__autoload');
  13. }
  14. return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
  15. }
  16. /**
  17. * Autoload a class identified by name
  18. *
  19. * @param string $pClassName Name of the object to load
  20. * @return string
  21. */
  22. public static function Load($pClassName) {
  23. if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
  24. return false;
  25. }
  26. $pClassFilePath = PHPEXCEL_ROOT . str_replace('_', DIRECTORY_SEPARATOR, $pClassName) . '.php';
  27. if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
  28. return false;
  29. }
  30. require $pClassFilePath;
  31. }
  32. }