1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- /**
- * Created by PhpStorm.
- * User: phperstar
- * Date: 2020/8/11
- * Time: 10:40 AM
- */
- namespace Util\PHPExcel;
- class Settings
- {
- /** Available Zip library classes */
- const PCLZIP = 'PHPExcel_Shared_ZipArchive';
- const ZIPARCHIVE = 'ZipArchive';
- /**
- * Name of the class used for Zip file management
- * e.g.
- * ZipArchive
- *
- * @var string
- */
- private static $zipClass = self::ZIPARCHIVE;
- /**
- * Default options for libxml loader
- *
- * @var int
- */
- private static $libXmlLoaderOptions = null;
- /**
- * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
- *
- * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
- * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
- * @return boolean Success or failure
- */
- public static function setZipClass($zipClass)
- {
- if (($zipClass === self::PCLZIP) ||
- ($zipClass === self::ZIPARCHIVE)) {
- self::$zipClass = $zipClass;
- return true;
- }
- return false;
- }
- /**
- * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
- * or Zip file management
- *
- * @return string Name of the Zip handler Class that PHPExcel is configured to use
- * for Zip file management
- * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
- */
- public static function getZipClass()
- {
- return self::$zipClass;
- }
- /**
- * Get defined options for libxml loader.
- * Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
- *
- * @return int Default options for libxml loader
- */
- public static function getLibXmlLoaderOptions()
- {
- if (is_null(self::$libXmlLoaderOptions) && defined('LIBXML_DTDLOAD')) {
- self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
- } elseif (is_null(self::$libXmlLoaderOptions)) {
- self::$libXmlLoaderOptions = true;
- }
- if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
- @libxml_disable_entity_loader((bool) self::$libXmlLoaderOptions);
- }
- return self::$libXmlLoaderOptions;
- }
- /**
- * Set options for libxml loader
- *
- * @param int $options Options for libxml loader
- */
- public static function setLibXmlLoaderOptions($options = null)
- {
- if (is_null($options) && defined('LIBXML_DTDLOAD')) {
- $options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
- }
- if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
- @libxml_disable_entity_loader((bool) $options);
- }
- self::$libXmlLoaderOptions = $options;
- }
- }
|