Autoloader.php 3.0 KB

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