Autoloader.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. $functions = spl_autoload_functions();
  44. foreach ( $functions as $function)
  45. spl_autoload_unregister($function);
  46. $functions = array_merge(array(array('PHPExcel_Autoloader','Load')),$functions);
  47. foreach ( $functions as $function)
  48. $x = spl_autoload_register($function);
  49. return $x;
  50. }
  51. /* public static function register()
  52. {
  53. if (function_exists('__autoload')) {
  54. // Register any existing autoloader function with SPL, so we don't get any clashes
  55. spl_autoload_register('__autoload');
  56. }
  57. // Register ourselves with SPL
  58. if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
  59. return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
  60. } else {
  61. return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
  62. }
  63. }*/
  64. /**
  65. * Autoload a class identified by name
  66. *
  67. * @param string $pClassName Name of the object to load
  68. */
  69. public static function load($pClassName)
  70. {
  71. if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
  72. // Either already loaded, or not a PHPExcel class request
  73. return false;
  74. }
  75. $pClassFilePath = PHPEXCEL_ROOT .
  76. str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
  77. '.php';
  78. if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
  79. // Can't load
  80. return false;
  81. }
  82. require($pClassFilePath);
  83. }
  84. }