[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** PHPExcel root directory */ 4 if (!defined('PHPEXCEL_ROOT')) { 5 /** 6 * @ignore 7 */ 8 define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); 9 require (PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); 10 } 11 12 /** 13 * PHPExcel_Settings 14 * 15 * Copyright (c) 2006 - 2015 PHPExcel 16 * 17 * This library is free software; you can redistribute it and/or 18 * modify it under the terms of the GNU Lesser General Public 19 * License as published by the Free Software Foundation; either 20 * version 2.1 of the License, or (at your option) any later version. 21 * 22 * This library is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 * Lesser General Public License for more details. 26 * 27 * You should have received a copy of the GNU Lesser General Public 28 * License along with this library; if not, write to the Free Software 29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 30 * 31 * @category PHPExcel 32 * @package PHPExcel_Settings 33 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) 34 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 35 * @version ##VERSION##, ##DATE## 36 */ 37 class PHPExcel_Settings 38 { 39 /** constants */ 40 /** Available Zip library classes */ 41 const PCLZIP = 'PHPExcel_Shared_ZipArchive'; 42 const ZIPARCHIVE = 'ZipArchive'; 43 44 /** Optional Chart Rendering libraries */ 45 const CHART_RENDERER_JPGRAPH = 'jpgraph'; 46 47 /** Optional PDF Rendering libraries */ 48 const PDF_RENDERER_TCPDF = 'tcPDF'; 49 const PDF_RENDERER_DOMPDF = 'DomPDF'; 50 const PDF_RENDERER_MPDF = 'mPDF'; 51 52 53 private static $chartRenderers = array( 54 self::CHART_RENDERER_JPGRAPH, 55 ); 56 57 private static $pdfRenderers = array( 58 self::PDF_RENDERER_TCPDF, 59 self::PDF_RENDERER_DOMPDF, 60 self::PDF_RENDERER_MPDF, 61 ); 62 63 64 /** 65 * Name of the class used for Zip file management 66 * e.g. 67 * ZipArchive 68 * 69 * @var string 70 */ 71 private static $zipClass = self::ZIPARCHIVE; 72 73 74 /** 75 * Name of the external Library used for rendering charts 76 * e.g. 77 * jpgraph 78 * 79 * @var string 80 */ 81 private static $chartRendererName; 82 83 /** 84 * Directory Path to the external Library used for rendering charts 85 * 86 * @var string 87 */ 88 private static $chartRendererPath; 89 90 91 /** 92 * Name of the external Library used for rendering PDF files 93 * e.g. 94 * mPDF 95 * 96 * @var string 97 */ 98 private static $pdfRendererName; 99 100 /** 101 * Directory Path to the external Library used for rendering PDF files 102 * 103 * @var string 104 */ 105 private static $pdfRendererPath; 106 107 /** 108 * Default options for libxml loader 109 * 110 * @var int 111 */ 112 private static $libXmlLoaderOptions = null; 113 114 /** 115 * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) 116 * 117 * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management 118 * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive 119 * @return boolean Success or failure 120 */ 121 public static function setZipClass($zipClass) 122 { 123 if (($zipClass === self::PCLZIP) || 124 ($zipClass === self::ZIPARCHIVE)) { 125 self::$zipClass = $zipClass; 126 return true; 127 } 128 return false; 129 } 130 131 132 /** 133 * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) 134 * or Zip file management 135 * 136 * @return string Name of the Zip handler Class that PHPExcel is configured to use 137 * for Zip file management 138 * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive 139 */ 140 public static function getZipClass() 141 { 142 return self::$zipClass; 143 } 144 145 146 /** 147 * Return the name of the method that is currently configured for cell cacheing 148 * 149 * @return string Name of the cacheing method 150 */ 151 public static function getCacheStorageMethod() 152 { 153 return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); 154 } 155 156 157 /** 158 * Return the name of the class that is currently being used for cell cacheing 159 * 160 * @return string Name of the class currently being used for cacheing 161 */ 162 public static function getCacheStorageClass() 163 { 164 return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); 165 } 166 167 168 /** 169 * Set the method that should be used for cell cacheing 170 * 171 * @param string $method Name of the cacheing method 172 * @param array $arguments Optional configuration arguments for the cacheing method 173 * @return boolean Success or failure 174 */ 175 public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array()) 176 { 177 return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); 178 } 179 180 181 /** 182 * Set the locale code to use for formula translations and any special formatting 183 * 184 * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") 185 * @return boolean Success or failure 186 */ 187 public static function setLocale($locale = 'en_us') 188 { 189 return PHPExcel_Calculation::getInstance()->setLocale($locale); 190 } 191 192 193 /** 194 * Set details of the external library that PHPExcel should use for rendering charts 195 * 196 * @param string $libraryName Internal reference name of the library 197 * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH 198 * @param string $libraryBaseDir Directory path to the library's base folder 199 * 200 * @return boolean Success or failure 201 */ 202 public static function setChartRenderer($libraryName, $libraryBaseDir) 203 { 204 if (!self::setChartRendererName($libraryName)) { 205 return false; 206 } 207 return self::setChartRendererPath($libraryBaseDir); 208 } 209 210 211 /** 212 * Identify to PHPExcel the external library to use for rendering charts 213 * 214 * @param string $libraryName Internal reference name of the library 215 * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH 216 * 217 * @return boolean Success or failure 218 */ 219 public static function setChartRendererName($libraryName) 220 { 221 if (!in_array($libraryName, self::$chartRenderers)) { 222 return false; 223 } 224 self::$chartRendererName = $libraryName; 225 226 return true; 227 } 228 229 230 /** 231 * Tell PHPExcel where to find the external library to use for rendering charts 232 * 233 * @param string $libraryBaseDir Directory path to the library's base folder 234 * @return boolean Success or failure 235 */ 236 public static function setChartRendererPath($libraryBaseDir) 237 { 238 if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { 239 return false; 240 } 241 self::$chartRendererPath = $libraryBaseDir; 242 243 return true; 244 } 245 246 247 /** 248 * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) 249 * 250 * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is 251 * currently configured to use 252 * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH 253 */ 254 public static function getChartRendererName() 255 { 256 return self::$chartRendererName; 257 } 258 259 260 /** 261 * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use 262 * 263 * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is 264 * currently configured to use 265 */ 266 public static function getChartRendererPath() 267 { 268 return self::$chartRendererPath; 269 } 270 271 272 /** 273 * Set details of the external library that PHPExcel should use for rendering PDF files 274 * 275 * @param string $libraryName Internal reference name of the library 276 * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, 277 * PHPExcel_Settings::PDF_RENDERER_DOMPDF 278 * or PHPExcel_Settings::PDF_RENDERER_MPDF 279 * @param string $libraryBaseDir Directory path to the library's base folder 280 * 281 * @return boolean Success or failure 282 */ 283 public static function setPdfRenderer($libraryName, $libraryBaseDir) 284 { 285 if (!self::setPdfRendererName($libraryName)) { 286 return false; 287 } 288 return self::setPdfRendererPath($libraryBaseDir); 289 } 290 291 292 /** 293 * Identify to PHPExcel the external library to use for rendering PDF files 294 * 295 * @param string $libraryName Internal reference name of the library 296 * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, 297 * PHPExcel_Settings::PDF_RENDERER_DOMPDF 298 * or PHPExcel_Settings::PDF_RENDERER_MPDF 299 * 300 * @return boolean Success or failure 301 */ 302 public static function setPdfRendererName($libraryName) 303 { 304 if (!in_array($libraryName, self::$pdfRenderers)) { 305 return false; 306 } 307 self::$pdfRendererName = $libraryName; 308 309 return true; 310 } 311 312 313 /** 314 * Tell PHPExcel where to find the external library to use for rendering PDF files 315 * 316 * @param string $libraryBaseDir Directory path to the library's base folder 317 * @return boolean Success or failure 318 */ 319 public static function setPdfRendererPath($libraryBaseDir) 320 { 321 if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { 322 return false; 323 } 324 self::$pdfRendererPath = $libraryBaseDir; 325 326 return true; 327 } 328 329 330 /** 331 * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) 332 * 333 * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is 334 * currently configured to use 335 * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, 336 * PHPExcel_Settings::PDF_RENDERER_DOMPDF 337 * or PHPExcel_Settings::PDF_RENDERER_MPDF 338 */ 339 public static function getPdfRendererName() 340 { 341 return self::$pdfRendererName; 342 } 343 344 /** 345 * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use 346 * 347 * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is 348 * currently configured to use 349 */ 350 public static function getPdfRendererPath() 351 { 352 return self::$pdfRendererPath; 353 } 354 355 /** 356 * Set default options for libxml loader 357 * 358 * @param int $options Default options for libxml loader 359 */ 360 public static function setLibXmlLoaderOptions($options = null) 361 { 362 if (is_null($options) && defined(LIBXML_DTDLOAD)) { 363 $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; 364 } 365 if (version_compare(PHP_VERSION, '5.2.11') >= 0) { 366 @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); 367 } 368 self::$libXmlLoaderOptions = $options; 369 } 370 371 /** 372 * Get default options for libxml loader. 373 * Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly. 374 * 375 * @return int Default options for libxml loader 376 */ 377 public static function getLibXmlLoaderOptions() 378 { 379 if (is_null(self::$libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) { 380 self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); 381 } 382 if (version_compare(PHP_VERSION, '5.2.11') >= 0) { 383 @libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); 384 } 385 return self::$libXmlLoaderOptions; 386 } 387 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |