Autoloader.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 1.8.0, 2014-03-02
  26. */
  27. spl_autoload_unregister(array('YiiBase','autoload'));
  28. PHPExcel_Autoloader::Register();
  29. // As we always try to run the autoloader before anything else, we can use it to do a few
  30. // simple checks and initialisations
  31. //PHPExcel_Shared_ZipStreamWrapper::register();
  32. // check mbstring.func_overload
  33. if (ini_get('mbstring.func_overload') & 2) {
  34. throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
  35. }
  36. PHPExcel_Shared_String::buildCharacterSets();
  37. spl_autoload_register(array('YiiBase','autoload'));
  38. /**
  39. * PHPExcel_Autoloader
  40. *
  41. * @category PHPExcel
  42. * @package PHPExcel
  43. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  44. */
  45. class PHPExcel_Autoloader
  46. {
  47. /**
  48. * Register the Autoloader with SPL
  49. *
  50. */
  51. public static function Register() {
  52. if (function_exists('__autoload')) {
  53. // Register any existing autoloader function with SPL, so we don't get any clashes
  54. spl_autoload_register('__autoload');
  55. }
  56. // Register ourselves with SPL
  57. return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
  58. } // function Register()
  59. /**
  60. * Autoload a class identified by name
  61. *
  62. * @param string $pClassName Name of the object to load
  63. */
  64. public static function Load($pClassName){
  65. if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
  66. // Either already loaded, or not a PHPExcel class request
  67. return FALSE;
  68. }
  69. $pClassFilePath = PHPEXCEL_ROOT .
  70. str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
  71. '.php';
  72. if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
  73. // Can't load
  74. return FALSE;
  75. }
  76. require($pClassFilePath);
  77. } // function Load()
  78. }