PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/PHPExcel/Settings.php

https://bitbucket.org/nfredricks/wp-employee-time
PHP | 332 lines | 101 code | 55 blank | 176 comment | 10 complexity | e6f7434f39bfdf51116f27296b87b945 MD5 | raw file
  1<?php
  2/**
  3 * PHPExcel
  4 *
  5 * Copyright (c) 2006 - 2012 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_Settings
 23 * @copyright  Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
 24 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
 25 * @version    1.7.8, 2012-10-12
 26 */
 27
 28/** PHPExcel root directory */
 29if (!defined('PHPEXCEL_ROOT')) {
 30	/**
 31	 * @ignore
 32	 */
 33	define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
 34	require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
 35}
 36
 37
 38class PHPExcel_Settings
 39{
 40	/**	constants */
 41	/**	Available Zip library classes */
 42	const PCLZIP		= 'PHPExcel_Shared_ZipArchive';
 43	const ZIPARCHIVE	= 'ZipArchive';
 44
 45	/**	Optional Chart Rendering libraries */
 46    const CHART_RENDERER_JPGRAPH	= 'jpgraph';
 47
 48	/**	Optional PDF Rendering libraries */
 49    const PDF_RENDERER_TCPDF		= 'tcPDF';
 50    const PDF_RENDERER_DOMPDF		= 'DomPDF';
 51    const PDF_RENDERER_MPDF			= 'mPDF';
 52
 53
 54	private static $_chartRenderers = array(
 55		self::CHART_RENDERER_JPGRAPH,
 56	);
 57
 58	private static $_pdfRenderers = array(
 59		self::PDF_RENDERER_TCPDF,
 60		self::PDF_RENDERER_DOMPDF,
 61		self::PDF_RENDERER_MPDF,
 62	);
 63
 64
 65	/**
 66	 * Name of the class used for Zip file management
 67	 *		e.g.
 68	 *			ZipArchive
 69	 *
 70	 * @var string
 71	 */
 72	private static $_zipClass	= self::ZIPARCHIVE;
 73
 74
 75	/**
 76	 * Name of the external Library used for rendering charts
 77	 *		e.g.
 78	 *			jpgraph
 79	 *
 80	 * @var string
 81	 */
 82	private static $_chartRendererName = NULL;
 83
 84	/**
 85	 * Directory Path to the external Library used for rendering charts
 86	 *
 87	 * @var string
 88	 */
 89	private static $_chartRendererPath = NULL;
 90
 91
 92	/**
 93	 * Name of the external Library used for rendering PDF files
 94	 *		e.g.
 95	 *			mPDF
 96	 *
 97	 * @var string
 98	 */
 99	private static $_pdfRendererName = NULL;
100
101	/**
102	 * Directory Path to the external Library used for rendering PDF files
103	 *
104	 * @var string
105	 */
106	private static $_pdfRendererPath = NULL;
107
108
109	/**
110	 * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
111	 *
112	 * @param	 string	$zipClass			The Zip handler class that PHPExcel should use for Zip file management
113	 *											e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
114	 * @return	 boolean					Success or failure
115	 */
116	public static function setZipClass($zipClass) {
117		if (($zipClass === self::PCLZIP) ||
118			($zipClass === self::ZIPARCHIVE)) {
119			self::$_zipClass = $zipClass;
120			return TRUE;
121		}
122		return FALSE;
123	}	//	function setZipClass()
124
125
126	/**
127	 * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
128	 *		for Zip file management
129	 *
130	 * @return	 string						Name of the Zip handler Class that PHPExcel is configured to use
131	 *											for Zip file management
132	 *												e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
133	 */
134	public static function getZipClass() {
135		return self::$_zipClass;
136	}	//	function getZipClass()
137
138
139	/**
140	 * Return the name of the method that is currently configured for cell cacheing
141	 *
142	 * @return	string				Name of the cacheing method
143	 */
144	public static function getCacheStorageMethod() {
145		return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
146	}	//	function getCacheStorageMethod()
147
148
149	/**
150	 * Return the name of the class that is currently being used for cell cacheing
151	 *
152	 * @return	string				Name of the class currently being used for cacheing
153	 */
154	public static function getCacheStorageClass() {
155		return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
156	}	//	function getCacheStorageClass()
157
158
159	/**
160	 * Set the method that should be used for cell cacheing
161	 *
162	 * @param	string	$method		Name of the cacheing method
163	 * @param	array	$arguments	Optional configuration arguments for the cacheing method
164	 * @return	boolean				Success or failure
165	 */
166	public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
167												 $arguments = array()) {
168		return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
169	}	//	function setCacheStorageMethod()
170
171
172	/**
173	 * Set the locale code to use for formula translations and any special formatting
174	 *
175	 * @param	string	$locale		The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
176	 * @return	boolean				Success or failure
177	 */
178	public static function setLocale($locale='en_us') {
179		return PHPExcel_Calculation::getInstance()->setLocale($locale);
180	}	//	function setLocale()
181
182
183	/**
184	 * Set details of the external library that PHPExcel should use for rendering charts
185	 *
186	 * @param	 string	$libraryName		Internal reference name of the library
187	 *											e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
188	 * @param	 string	$libraryBaseDir		Directory path to the library's base folder
189	 * @return	 boolean					Success or failure
190	 */
191	public static function setChartRenderer($libraryName, $libraryBaseDir) {
192		if (!self::setChartRendererName($libraryName))
193			return FALSE;
194		return self::setChartRendererPath($libraryBaseDir);
195	}	//	function setChartRenderer()
196
197
198	/**
199	 * Identify to PHPExcel the external library to use for rendering charts
200	 *
201	 * @param	 string	$libraryName		Internal reference name of the library
202	 *											e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
203	 * @return	 boolean					Success or failure
204	 */
205	public static function setChartRendererName($libraryName) {
206		if (!in_array($libraryName,self::$_chartRenderers)) {
207			return FALSE;
208		}
209
210		self::$_chartRendererName = $libraryName;
211
212		return TRUE;
213	}	//	function setChartRendererName()
214
215
216	/**
217	 * Tell PHPExcel where to find the external library to use for rendering charts
218	 *
219	 * @param	 string	$libraryBaseDir		Directory path to the library's base folder
220	 * @return	 boolean					Success or failure
221	 */
222	public static function setChartRendererPath($libraryBaseDir) {
223		if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
224			return FALSE;
225		}
226		self::$_chartRendererPath = $libraryBaseDir;
227
228		return TRUE;
229	}	//	function setChartRendererPath()
230
231
232	/**
233	 * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
234	 *
235	 * @return	 string|NULL				Internal reference name of the Chart Rendering Library that PHPExcel is
236	 *											currently configured to use
237	 *												e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
238	 */
239	public static function getChartRendererName() {
240		return self::$_chartRendererName;
241	}	//	function getChartRendererName()
242
243
244	/**
245	 * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
246	 *
247	 * @return	 string|NULL				Directory Path to the Chart Rendering Library that PHPExcel is
248	 *											currently configured to use
249	 */
250	public static function getChartRendererPath() {
251		return self::$_chartRendererPath;
252	}	//	function getChartRendererPath()
253
254
255	/**
256	 * Set details of the external library that PHPExcel should use for rendering PDF files
257	 *
258	 * @param	 string	$libraryName		Internal reference name of the library
259	 *											e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
260	 *												 PHPExcel_Settings::PDF_RENDERER_DOMPDF
261	 *											  or PHPExcel_Settings::PDF_RENDERER_MPDF
262	 * @param	 string	$libraryBaseDir		Directory path to the library's base folder
263	 * @return	 boolean					Success or failure
264	 */
265	public static function setPdfRenderer($libraryName, $libraryBaseDir) {
266		if (!self::setPdfRendererName($libraryName))
267			return FALSE;
268		return self::setPdfRendererPath($libraryBaseDir);
269	}	//	function setPdfRenderer()
270
271
272	/**
273	 * Identify to PHPExcel the external library to 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	 * @return	 boolean					Success or failure
280	 */
281	public static function setPdfRendererName($libraryName) {
282		if (!in_array($libraryName,self::$_pdfRenderers)) {
283			return FALSE;
284		}
285
286		self::$_pdfRendererName = $libraryName;
287
288		return TRUE;
289	}	//	function setPdfRendererName()
290
291
292	/**
293	 * Tell PHPExcel where to find the external library to use for rendering PDF files
294	 *
295	 * @param	 string	$libraryBaseDir		Directory path to the library's base folder
296	 * @return	 boolean					Success or failure
297	 */
298	public static function setPdfRendererPath($libraryBaseDir) {
299		if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
300			return FALSE;
301		}
302		self::$_pdfRendererPath = $libraryBaseDir;
303
304		return TRUE;
305	}	//	function setPdfRendererPath()
306
307
308	/**
309	 * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
310	 *
311	 * @return	 string|NULL				Internal reference name of the PDF Rendering Library that PHPExcel is
312	 *											currently configured to use
313	 *												e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
314	 *													 PHPExcel_Settings::PDF_RENDERER_DOMPDF
315	 *												  or PHPExcel_Settings::PDF_RENDERER_MPDF
316	 */
317	public static function getPdfRendererName() {
318		return self::$_pdfRendererName;
319	}	//	function getPdfRendererName()
320
321
322	/**
323	 * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
324	 *
325	 * @return	 string|NULL				Directory Path to the PDF Rendering Library that PHPExcel is
326	 *											currently configured to use
327	 */
328	public static function getPdfRendererPath() {
329		return self::$_pdfRendererPath;
330	}	//	function getPdfRendererPath()
331
332}