Autoloader.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. PHPExcel_Autoloader::register();
  3. // As we always try to run the autoloader before anything else, we can use it to do a few
  4. // simple checks and initialisations
  5. //PHPExcel_Shared_ZipStreamWrapper::register();
  6. // check mbstring.func_overload
  7. if (ini_get('mbstring.func_overload') & 2) {
  8. throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
  9. }
  10. PHPExcel_Shared_String::buildCharacterSets();
  11. /**
  12. * PHPExcel
  13. *
  14. * Copyright (c) 2006 - 2015 PHPExcel
  15. *
  16. * This library is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU Lesser General Public
  18. * License as published by the Free Software Foundation; either
  19. * version 2.1 of the License, or (at your option) any later version.
  20. *
  21. * This library is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  24. * Lesser General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Lesser General Public
  27. * License along with this library; if not, write to the Free Software
  28. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel
  32. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  34. * @version ##VERSION##, ##DATE##
  35. */
  36. class PHPExcel_Autoloader
  37. {
  38. /**
  39. * Register the Autoloader with SPL
  40. *
  41. */
  42. public static function register()
  43. {
  44. if (function_exists('__autoload')) {
  45. // Register any existing autoloader function with SPL, so we don't get any clashes
  46. spl_autoload_register('__autoload');
  47. }
  48. // Register ourselves with SPL
  49. if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
  50. return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
  51. } else {
  52. return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
  53. }
  54. }
  55. /**
  56. * Autoload a class identified by name
  57. *
  58. * @param string $pClassName Name of the object to load
  59. */
  60. public static function load($pClassName)
  61. {
  62. if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
  63. // Either already loaded, or not a PHPExcel class request
  64. return false;
  65. }
  66. $pClassFilePath = PHPEXCEL_ROOT .
  67. str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
  68. '.php';
  69. if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
  70. // Can't load
  71. return false;
  72. }
  73. require($pClassFilePath);
  74. }
  75. }