No Description

Autoloader.php 3.1KB

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