Subversion Repositories php-qbpwcf

Rev

Rev 3 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
11
    it under the terms of the GNU General Public License as published by
Line 28... Line 28...
28
跟open document有關的類別.
28
跟open document有關的類別.
29
備註:
29
備註:
30
無.
30
無.
31
*/
31
*/
32
class od{
32
class od{
33
	
33
 
34
	/*
34
	/*
35
	#函式說明:
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
46
	*/
47
	public function __call($method,$arguments){
47
	public function __call($method,$arguments){
48
		
48
 
49
		#取得當前執行的函式
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
50
		$result["function"]=__FUNCTION__;
51
		
51
 
52
		#設置執行不正常
52
		#設置執行不正常
53
		$result["status"]="false";
53
		$result["status"]="false";
54
		
54
 
55
		#設置執行錯誤
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		
57
 
58
		#設置所丟入的參數
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
59
		$result["error"][]=$arguments;
60
		
60
 
61
		#回傳結果
61
		#回傳結果
62
		return $result;
62
		return $result;
63
		
63
 
64
		}#function __call end
64
		}#function __call end
65
		
65
 
66
	/*
66
	/*
67
	#函式說明:
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 75... Line 75...
75
	#$arguments,陣列,為呼叫方法時所用的參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
78
	*/
79
	public static function __callStatic($method,$arguments){
79
	public static function __callStatic($method,$arguments){
80
		
80
 
81
		#取得當前執行的函式
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
82
		$result["function"]=__FUNCTION__;
83
		
83
 
84
		#設置執行不正常
84
		#設置執行不正常
85
		$result["status"]="false";
85
		$result["status"]="false";
86
		
86
 
87
		#設置執行錯誤
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
		
89
 
90
		#設置所丟入的參數
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
91
		$result["error"][]=$arguments;
92
		
92
 
93
		#回傳結果
93
		#回傳結果
94
		return $result;
94
		return $result;
95
		
95
 
96
		}#function __callStatic end	
96
		}#function __callStatic end
97
	
97
 
98
	/*
98
	/*
99
	#函式說明:
99
	#函式說明:
100
	#匯入phpodt函式庫的函式
100
	#匯入phpodt函式庫的函式
101
	#回傳結果:
101
	#回傳結果:
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 106... Line 106...
106
	#無
106
	#無
107
	#可省略參數:
107
	#可省略參數:
108
	#無
108
	#無
109
	*/
109
	*/
110
	function importOdtLib(){
110
	function importOdtLib(){
111
		
111
 
112
		#取得當前執行的函式
112
		#取得當前執行的函式
113
		$result["function"]=__FUNCTION__;
113
		$result["function"]=__FUNCTION__;
114
		
114
 
115
		#設定 phpodt lib 的路徑
115
		#設定 phpodt lib 的路徑
116
		$phpOdtLibPath="lib/phpodt-0.3.3/phpodt.php";
116
		$phpOdtLibPath="lib/phpodt-0.3.3/phpodt.php";
117
		
117
 
118
		#檢查要匯入的套件是否存在
118
		#檢查要匯入的套件是否存在
119
		#涵式說明:檢查多個檔案與資料夾是否存在.
119
		#涵式說明:檢查多個檔案與資料夾是否存在.
120
		#回傳的結果:
120
		#回傳的結果:
121
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
121
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
122
		#$result["error"],錯誤訊息陣列.
122
		#$result["error"],錯誤訊息陣列.
Line 140... Line 140...
140
		#http://php.net/manual/en/control-structures.foreach.php
140
		#http://php.net/manual/en/control-structures.foreach.php
141
		#備註:
141
		#備註:
142
		#函數file_exists檢查的路徑為檔案系統的路徑
142
		#函數file_exists檢查的路徑為檔案系統的路徑
143
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
143
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
144
		unset($conf["fileAccess::checkMultiFileExist"]);
144
		unset($conf["fileAccess::checkMultiFileExist"]);
145
		
145
 
146
		#如果檢查檔案是否存在失敗
146
		#如果檢查檔案是否存在失敗
147
		if($checkMultiFileExist["status"]=="false"){
147
		if($checkMultiFileExist["status"]=="false"){
148
			
148
 
149
			#設置錯誤訊息
149
			#設置錯誤訊息
150
			$result["error"]=$checkMultiFileExist;
150
			$result["error"]=$checkMultiFileExist;
151
		
151
 
152
			#設置執行不正常
152
			#設置執行不正常
153
			$result["status"]="false";
153
			$result["status"]="false";
154
			
154
 
155
			#回傳結果
155
			#回傳結果
156
			return $result;
156
			return $result;
157
			
157
 
158
			}#if end
158
			}#if end
159
			
159
 
160
		#如果檔案不存在
160
		#如果檔案不存在
161
		if($checkMultiFileExist["allExist"]=="false"){
161
		if($checkMultiFileExist["allExist"]=="false"){
162
			
162
 
163
			#設置錯誤訊息
163
			#設置錯誤訊息
164
			$result["error"]=$checkMultiFileExist;
164
			$result["error"]=$checkMultiFileExist;
165
		
165
 
166
			#設置執行不正常
166
			#設置執行不正常
167
			$result["status"]="false";
167
			$result["status"]="false";
168
			
168
 
169
			#回傳結果
169
			#回傳結果
170
			return $result;
170
			return $result;
171
			
171
 
172
			}#if end		
172
			}#if end
173
		
173
 
174
		#匯入 phpodt 套件
174
		#匯入 phpodt 套件
175
		include($phpOdtLibPath);
175
		include($phpOdtLibPath);
176
		
176
 
177
		#設置執行正常
177
		#設置執行正常
178
		$result["status"]="true";			
178
		$result["status"]="true";
179
		
179
 
180
		#回傳結果
180
		#回傳結果
181
		return $result;
181
		return $result;
182
					
182
 
183
		}#function importOdtLib end
183
		}#function importOdtLib end
184
		
184
 
185
	/*
185
	/*
186
	#函式說明:
186
	#函式說明:
187
	#展示建立odt檔案的功能,會產生名稱為"od::demoOdt.odt"的檔案
187
	#展示建立odt檔案的功能,會產生名稱為"od::demoOdt.odt"的檔案
188
	#回傳結果:
188
	#回傳結果:
189
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
189
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 193... Line 193...
193
	#必填參數:
193
	#必填參數:
194
	#無
194
	#無
195
	#可省略參數:
195
	#可省略參數:
196
	#無
196
	#無
197
	#參考資料:
197
	#參考資料:
198
	#http://php-odt.sourceforge.net/ 
198
	#http://php-odt.sourceforge.net/
199
	*/
199
	*/
200
	function demoOdt(){
200
	function demoOdt(){
201
		
201
 
202
		#取得當前執行的函式
202
		#取得當前執行的函式
203
		$result["function"]=__FUNCTION__;	
203
		$result["function"]=__FUNCTION__;
204
			
204
 
205
		/*
205
		/*
206
		#函式說明:
206
		#函式說明:
207
		#匯入phpodt函式庫的函式
207
		#匯入phpodt函式庫的函式
208
		#回傳結果:
208
		#回傳結果:
209
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
209
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 213... Line 213...
213
		#無
213
		#無
214
		#可省略參數:
214
		#可省略參數:
215
		#無
215
		#無
216
		*/
216
		*/
217
		$importLib=od::importOdtLib();
217
		$importLib=od::importOdtLib();
218
		
218
 
219
		#如果匯入 phpodt 函式庫失敗
219
		#如果匯入 phpodt 函式庫失敗
220
		if($importLib["status"]=="false"){
220
		if($importLib["status"]=="false"){
221
			
221
 
222
			#設置錯誤訊息
222
			#設置錯誤訊息
223
			$result["error"]=$importLib;
223
			$result["error"]=$importLib;
224
		
224
 
225
			#設置執行不正常
225
			#設置執行不正常
226
			$result["status"]="false";
226
			$result["status"]="false";
227
			
227
 
228
			#回傳結果
228
			#回傳結果
229
			return $result;
229
			return $result;
230
			
230
 
231
			}#if end
231
			}#if end
232
		
232
 
233
		#DEMO
233
		#DEMO
234
		$odt=\ODT::getInstance();
234
		$odt=\ODT::getInstance();
235
		$p=new \Paragraph();
235
		$p=new \Paragraph();
236
		$p->addText('Hello World!!');
236
		$p->addText('Hello World!!');
237
		$odt->output('odT/demoOdt.odt');
237
		$odt->output('odT/demoOdt.odt');
238
		
238
 
239
		#取得檔案位置
239
		#取得檔案位置
240
		$result["content"]="odT/demoOdt.odt";
240
		$result["content"]="odT/demoOdt.odt";
241
		
241
 
242
		#設置執行正常
242
		#設置執行正常
243
		$result["status"]="true";
243
		$result["status"]="true";
244
		
244
 
245
		#回傳結果
245
		#回傳結果
246
		return $result;
246
		return $result;
247
		
247
 
248
		}#function demoOdt
248
		}#function demoOdt
249
	
249
 
250
	/*
250
	/*
251
	#函式說明:
251
	#函式說明:
252
	#匯入phpods函式庫的函式
252
	#匯入phpods函式庫的函式
253
	#回傳結果:
253
	#回傳結果:
254
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
254
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 258... Line 258...
258
	#無
258
	#無
259
	#可省略參數:
259
	#可省略參數:
260
	#無
260
	#無
261
	*/
261
	*/
262
	function importOdsLib(){
262
	function importOdsLib(){
263
		
263
 
264
		#取得當前執行的函式
264
		#取得當前執行的函式
265
		$result["function"]=__FUNCTION__;
265
		$result["function"]=__FUNCTION__;
266
		
266
 
267
		#設定 phpods lib 的路徑
267
		#設定 phpods lib 的路徑
268
		$phpOdsLibPath="lib/ods-php-0.1rc1/ods.php";
268
		$phpOdsLibPath="lib/ods-php-0.1rc1/ods.php";
269
		
269
 
270
		#檢查要匯入的套件是否存在
270
		#檢查要匯入的套件是否存在
271
		#涵式說明:檢查多個檔案與資料夾是否存在.
271
		#涵式說明:檢查多個檔案與資料夾是否存在.
272
		#回傳的結果:
272
		#回傳的結果:
273
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
273
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
274
		#$result["error"],錯誤訊息陣列.
274
		#$result["error"],錯誤訊息陣列.
Line 292... Line 292...
292
		#http://php.net/manual/en/control-structures.foreach.php
292
		#http://php.net/manual/en/control-structures.foreach.php
293
		#備註:
293
		#備註:
294
		#函數file_exists檢查的路徑為檔案系統的路徑
294
		#函數file_exists檢查的路徑為檔案系統的路徑
295
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
295
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
296
		unset($conf["fileAccess::checkMultiFileExist"]);
296
		unset($conf["fileAccess::checkMultiFileExist"]);
297
		
297
 
298
		#如果檢查檔案是否存在失敗
298
		#如果檢查檔案是否存在失敗
299
		if($checkMultiFileExist["status"]=="false"){
299
		if($checkMultiFileExist["status"]=="false"){
300
			
300
 
301
			#設置錯誤訊息
301
			#設置錯誤訊息
302
			$result["error"]=$checkMultiFileExist;
302
			$result["error"]=$checkMultiFileExist;
303
		
303
 
304
			#設置執行不正常
304
			#設置執行不正常
305
			$result["status"]="false";
305
			$result["status"]="false";
306
			
306
 
307
			#回傳結果
307
			#回傳結果
308
			return $result;
308
			return $result;
309
			
309
 
310
			}#if end
310
			}#if end
311
			
311
 
312
		#如果檔案不存在
312
		#如果檔案不存在
313
		if($checkMultiFileExist["allExist"]=="false"){
313
		if($checkMultiFileExist["allExist"]=="false"){
314
			
314
 
315
			#設置錯誤訊息
315
			#設置錯誤訊息
316
			$result["error"]=$checkMultiFileExist;
316
			$result["error"]=$checkMultiFileExist;
317
		
317
 
318
			#設置執行不正常
318
			#設置執行不正常
319
			$result["status"]="false";
319
			$result["status"]="false";
320
			
320
 
321
			#回傳結果
321
			#回傳結果
322
			return $result;
322
			return $result;
323
			
323
 
324
			}#if end		
324
			}#if end
325
		
325
 
326
		#匯入 phpodt 套件
326
		#匯入 phpodt 套件
327
		include($phpOdsLibPath);
327
		include($phpOdsLibPath);
328
		
328
 
329
		#設置執行正常
329
		#設置執行正常
330
		$result["status"]="true";			
330
		$result["status"]="true";
331
		
331
 
332
		#回傳結果
332
		#回傳結果
333
		return $result;
333
		return $result;
334
					
334
 
335
		}#function importOdsLib end	
335
		}#function importOdsLib end
336
		
336
 
337
	/*
337
	/*
338
	#函式說明:
338
	#函式說明:
339
	#展示建立ods檔案的功能,會出現檔案名稱為'od::demoOdf.ods'的檔案.
339
	#展示建立ods檔案的功能,會出現檔案名稱為'od::demoOdf.ods'的檔案.
340
	#回傳結果:
340
	#回傳結果:
341
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
341
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 348... Line 348...
348
	#無
348
	#無
349
	#參考資料:
349
	#參考資料:
350
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
350
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
351
	*/
351
	*/
352
	function demoOds(){
352
	function demoOds(){
353
		
353
 
354
		/*
354
		/*
355
		#函式說明:
355
		#函式說明:
356
		#匯入phpods函式庫的函式
356
		#匯入phpods函式庫的函式
357
		#回傳結果:
357
		#回傳結果:
358
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
358
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 364... Line 364...
364
		#無
364
		#無
365
		*/
365
		*/
366
		$importOdsLib=od::importOdsLib();
366
		$importOdsLib=od::importOdsLib();
367
 
367
 
368
		#如果載入 php ods lib 失敗
368
		#如果載入 php ods lib 失敗
369
		if($importOdsLib["status"]=="false"){				
369
		if($importOdsLib["status"]=="false"){
370
			
370
 
371
			#設置錯誤訊息
371
			#設置錯誤訊息
372
			$result["error"]=$importLib;
372
			$result["error"]=$importLib;
373
		
373
 
374
			#設置執行不正常
374
			#設置執行不正常
375
			$result["status"]="false";
375
			$result["status"]="false";
376
			
376
 
377
			#回傳結果
377
			#回傳結果
378
			return $result;			
378
			return $result;
379
			
379
 
380
			}#if end
380
			}#if end
381
		
381
 
382
		#create a new ods file
382
		#create a new ods file
383
		$object=\newOds(); 
383
		$object=\newOds();
384
		
384
 
385
		#add a cell to sheet 0, row 0, cell 0, with value 1 and type float
385
		#add a cell to sheet 0, row 0, cell 0, with value 1 and type float
386
		$object->addCell(0,0,0,1,'float');
386
		$object->addCell(0,0,0,1,'float');
387
		 
387
 
388
		#add a cell to sheet 0, row 0, cell 1, with value 1 and type float
388
		#add a cell to sheet 0, row 0, cell 1, with value 1 and type float
389
		$object->addCell(0,0,1,2,'float'); 
389
		$object->addCell(0,0,1,2,'float');
390
		
390
 
391
		#add a cell to sheet 0, row 1, cell 0, with value 1 and type float
391
		#add a cell to sheet 0, row 1, cell 0, with value 1 and type float
392
		$object->addCell(0,1,0,1,'float'); 
392
		$object->addCell(0,1,0,1,'float');
393
		
393
 
394
		#add a cell to sheet 0, row 1, cell 1, with value 1 and type float
394
		#add a cell to sheet 0, row 1, cell 1, with value 1 and type float
395
		$object->addCell(0,1,1,2,'float');
395
		$object->addCell(0,1,1,2,'float');
396
		
396
 
397
		#save the object to a ods file
397
		#save the object to a ods file
398
		saveOds($object,'odT/demoOdf.ods'); 
398
		saveOds($object,'odT/demoOdf.ods');
399
		
399
 
400
		#取得檔案路徑
400
		#取得檔案路徑
401
		$result["content"]="odT/demoOdf.ods";
401
		$result["content"]="odT/demoOdf.ods";
402
		
402
 
403
		#設置執行正常
403
		#設置執行正常
404
		$result["status"]="true";
404
		$result["status"]="true";
405
		
405
 
406
		#回傳結果
406
		#回傳結果
407
		return $result;
407
		return $result;
408
		
408
 
409
		}#function demoOds end
409
		}#function demoOds end
410
		
410
 
411
	/*
411
	/*
412
	#函式說明:
412
	#函式說明:
413
	#建立ods檔案
413
	#建立ods檔案
414
	#回傳結果:
414
	#回傳結果:
415
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
415
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 427... Line 427...
427
	#無
427
	#無
428
	#參考資料:
428
	#參考資料:
429
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
429
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
430
	*/
430
	*/
431
	function createOds(&$conf){
431
	function createOds(&$conf){
432
		
432
 
433
		#初始化要回傳的結果
433
		#初始化要回傳的結果
434
		$result=array();
434
		$result=array();
435
		
435
 
436
		#取得當前執行的函數
436
		#取得當前執行的函數
437
		$result["function"]=__FUNCTION__;
437
		$result["function"]=__FUNCTION__;
438
 
438
 
439
		#如果 $conf 不為陣列
439
		#如果 $conf 不為陣列
440
		if(gettype($conf)!="array"){
440
		if(gettype($conf)!="array"){
441
			
441
 
442
			#設置執行失敗
442
			#設置執行失敗
443
			$result["status"]="false";
443
			$result["status"]="false";
444
			
444
 
445
			#設置執行錯誤訊息
445
			#設置執行錯誤訊息
446
			$result["error"][]="\$conf變數須為陣列形態";
446
			$result["error"][]="\$conf變數須為陣列形態";
447
 
447
 
448
			#如果傳入的參數為 null
448
			#如果傳入的參數為 null
449
			if($conf==null){
449
			if($conf==null){
450
				
450
 
451
				#設置執行錯誤訊息
451
				#設置執行錯誤訊息
452
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
452
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
453
				
453
 
454
				}#if end
454
				}#if end
455
 
455
 
456
			#回傳結果
456
			#回傳結果
457
			return $result;
457
			return $result;
458
			
458
 
459
			}#if end
459
			}#if end
460
			
460
 
461
		#檢查參數
461
		#檢查參數
462
		#函式說明:
462
		#函式說明:
463
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
463
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
464
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
464
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
465
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
465
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 474... Line 474...
474
		#必填寫的參數:
474
		#必填寫的參數:
475
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
475
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
476
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
476
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
477
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
477
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
478
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePathAndName","content","fileArgu");
478
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePathAndName","content","fileArgu");
479
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
479
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
480
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
480
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
481
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
481
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
482
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
482
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
483
		#可以省略的參數:
483
		#可以省略的參數:
484
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
484
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
485
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
485
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
486
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
486
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
487
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("alt","class");
487
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("alt","class");
488
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
488
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
489
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
489
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
490
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
490
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
491
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("","");
491
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("","");
492
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
492
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
493
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
493
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
Line 496... Line 496...
496
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
496
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
497
		unset($conf["variableCheck::checkArguments"]);
497
		unset($conf["variableCheck::checkArguments"]);
498
 
498
 
499
		#如果檢查失敗
499
		#如果檢查失敗
500
		if($checkResult["status"]=="false"){
500
		if($checkResult["status"]=="false"){
501
			
501
 
502
			#設置錯誤狀態
502
			#設置錯誤狀態
503
			$result["status"]="false";
503
			$result["status"]="false";
504
			
504
 
505
			#設置錯誤提示
505
			#設置錯誤提示
506
			$result["error"]=$checkResult;
506
			$result["error"]=$checkResult;
507
			
507
 
508
			#回傳結果
508
			#回傳結果
509
			return $result;
509
			return $result;
510
			
510
 
511
			}#if end
511
			}#if end
512
 
512
 
513
		#如果檢查不通過
513
		#如果檢查不通過
514
		if($checkResult["passed"]=="false"){
514
		if($checkResult["passed"]=="false"){
515
			
515
 
516
			#設置錯誤狀態
516
			#設置錯誤狀態
517
			$result["status"]="false";
517
			$result["status"]="false";
518
			
518
 
519
			#設置錯誤提示
519
			#設置錯誤提示
520
			$result["error"]=$checkResult;
520
			$result["error"]=$checkResult;
521
			
521
 
522
			#回傳結果
522
			#回傳結果
523
			return $result;
523
			return $result;
524
			
524
 
525
			}#if end
525
			}#if end
526
		
526
 
527
		/*
527
		/*
528
		#函式說明:
528
		#函式說明:
529
		#匯入phpods函式庫的函式
529
		#匯入phpods函式庫的函式
530
		#回傳結果:
530
		#回傳結果:
531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 535... Line 535...
535
		#無
535
		#無
536
		#可省略參數:
536
		#可省略參數:
537
		#無
537
		#無
538
		*/
538
		*/
539
		$importOdsLib=od::importOdsLib();
539
		$importOdsLib=od::importOdsLib();
540
		
540
 
541
		#create a new ods file
541
		#create a new ods file
542
		$object=\newOds(); 
542
		$object=\newOds();
543
		
543
 
544
		#針對每個分頁
544
		#針對每個分頁
545
		foreach($conf["content"] as $tabName=>$tabContent){
545
		foreach($conf["content"] as $tabName=>$tabContent){
546
			
546
 
547
			#如果 $tabContent 不為陣列或元素數量為0
547
			#如果 $tabContent 不為陣列或元素數量為0
548
			if(gettype($tabContent)!="array" || count($tabContent)==0){
548
			if(gettype($tabContent)!="array" || count($tabContent)==0){
549
				
549
 
550
				#結束foreach end
550
				#結束foreach end
551
				break;
551
				break;
552
				
552
 
553
				}#if end
553
				}#if end
554
			
554
 
555
			#針對每個列
555
			#針對每個列
556
			foreach($tabContent as $rowName=>$rowContent){
556
			foreach($tabContent as $rowName=>$rowContent){
557
				
557
 
558
				#如果 $rowContent 不為陣列或元素數量為0
558
				#如果 $rowContent 不為陣列或元素數量為0
559
				if(gettype($rowContent)!="array" || count($rowContent)==0){
559
				if(gettype($rowContent)!="array" || count($rowContent)==0){
560
					
560
 
561
					#結束foreach end
561
					#結束foreach end
562
					break;
562
					break;
563
					
563
 
564
					}#if end
564
					}#if end
565
				
565
 
566
				#針對每個行
566
				#針對每個行
567
				foreach($rowContent as $colName=>$colContent){
567
				foreach($rowContent as $colName=>$colContent){
568
					
568
 
569
					#如果 $colContent 不為陣列或元素數量為0
569
					#如果 $colContent 不為陣列或元素數量為0
570
					if(gettype($colContent)!="array" || count($colContent)==0){
570
					if(gettype($colContent)!="array" || count($colContent)==0){
571
						
571
 
572
						#結束foreach end
572
						#結束foreach end
573
						break;
573
						break;
574
						
574
 
575
						}#if end
575
						}#if end
576
					
576
 
577
					#針對每個欄位的內容
577
					#針對每個欄位的內容
578
					for($i=0;$i<2;$i++){
578
					for($i=0;$i<2;$i++){
579
						
579
 
580
						#如果內容元素不存在
580
						#如果內容元素不存在
581
						if(!isset($colContent[$i])){
581
						if(!isset($colContent[$i])){
582
							
582
 
583
							#如果是數值
583
							#如果是數值
584
							if($i==0){
584
							if($i==0){
585
								
585
 
586
								#設為空字串
586
								#設為空字串
587
								$colContent[$i]="";
587
								$colContent[$i]="";
588
								
588
 
589
								}#if end
589
								}#if end
590
							
590
 
591
							#反之如果是形態
591
							#反之如果是形態
592
							else if($i==1){
592
							else if($i==1){
593
								
593
 
594
								#設為字串
594
								#設為字串
595
								$colContent[$i]="string";
595
								$colContent[$i]="string";
596
								
596
 
597
								}#if end
597
								}#if end
598
							
598
 
599
							}#if end
599
							}#if end
600
							
600
 
601
						}#for end
601
						}#for end
602
						
602
 
603
					#add a cell to sheet $tabName, row $rowName, cell $colName, with value $colContent[0] and type $colContent[1]
603
					#add a cell to sheet $tabName, row $rowName, cell $colName, with value $colContent[0] and type $colContent[1]
604
					$object->addCell($tabName,$rowName,$colName,$colContent[0],$colContent[1]);
604
					$object->addCell($tabName,$rowName,$colName,$colContent[0],$colContent[1]);
605
					
605
 
606
					}#foreach end
606
					}#foreach end
607
				
607
 
608
				}#foreache end
608
				}#foreache end
609
			
609
 
610
			}#foreach end
610
			}#foreach end
611
		
611
 
612
		#確保路徑
612
		#確保路徑
613
		#涵式說明:
613
		#涵式說明:
614
		#確保路徑存在.
614
		#確保路徑存在.
615
		#回傳的結果:
615
		#回傳的結果:
616
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
616
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
617
		#$result["error"],錯誤訊息陣列.
617
		#$result["error"],錯誤訊息陣列.
618
		#$resutl["function"],當前執行的涵式名稱.
618
		#$resutl["function"],當前執行的涵式名稱.
619
		#必填的參數:
619
		#必填的參數:
620
		#$conf["path"],要檢查的路徑
620
		#$conf["path"],要檢查的路徑
621
		$conf["fileAccess::validatePath"]["path"]=$conf["filePathAndName"];		
621
		$conf["fileAccess::validatePath"]["path"]=$conf["filePathAndName"];
622
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
622
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
623
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
623
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
624
		#可省略參數:
624
		#可省略參數:
625
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
625
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
626
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
626
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
627
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
627
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
628
		#$conf["dirPermission"]="";
628
		#$conf["dirPermission"]="";
629
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
629
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
630
		unset($conf["fileAccess::validatePath"]);
630
		unset($conf["fileAccess::validatePath"]);
631
		
631
 
632
		#如果確保路徑失敗
632
		#如果確保路徑失敗
633
		if($validatePath["status"]=="false"){
633
		if($validatePath["status"]=="false"){
634
			
634
 
635
			#設置錯誤狀態
635
			#設置錯誤狀態
636
			$result["status"]="false";
636
			$result["status"]="false";
637
			
637
 
638
			#設置錯誤提示
638
			#設置錯誤提示
639
			$result["error"]=$validatePath;
639
			$result["error"]=$validatePath;
640
			
640
 
641
			#回傳結果
641
			#回傳結果
642
			return $result;
642
			return $result;
643
			
643
 
644
			}#if end
644
			}#if end
645
		
645
 
646
		#save the object to a ods file
646
		#save the object to a ods file
647
		saveOds($object,$conf["filePathAndName"].".ods"); 
647
		saveOds($object,$conf["filePathAndName"].".ods");
648
		
648
 
649
		#取得ods檔案的路徑
649
		#取得ods檔案的路徑
650
		$result["content"]=$conf["filePathAndName"].".ods";
650
		$result["content"]=$conf["filePathAndName"].".ods";
651
		
651
 
652
		#設置執行正常
652
		#設置執行正常
653
		$result["status"]="true";
653
		$result["status"]="true";
654
		
654
 
655
		#回傳結果
655
		#回傳結果
656
		return $result;
656
		return $result;
657
		
657
 
658
		}#function createOds end
658
		}#function createOds end
659
	
659
 
660
	/*
660
	/*
661
	#函式說明:
661
	#函式說明:
662
	#建立odt檔案
662
	#建立odt檔案
663
	#回傳結果:
663
	#回傳結果:
664
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
664
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 676... Line 676...
676
	#無
676
	#無
677
	#參考資料:
677
	#參考資料:
678
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
678
	#https://sourceforge.net/projects/ods-php/?source=typ_redirect
679
	*/
679
	*/
680
	function createOdt(&$conf){
680
	function createOdt(&$conf){
681
		
681
 
682
		#初始化要回傳的結果
682
		#初始化要回傳的結果
683
		$result=array();
683
		$result=array();
684
 
684
 
685
		#取得當前執行的函數名稱
685
		#取得當前執行的函數名稱
686
		$result["function"]=__FUNCTION__;
686
		$result["function"]=__FUNCTION__;
687
 
687
 
688
		#如果沒有參數
688
		#如果沒有參數
689
		if(func_num_args()==0){
689
		if(func_num_args()==0){
690
			
690
 
691
			#設置執行失敗
691
			#設置執行失敗
692
			$result["status"]="false";
692
			$result["status"]="false";
693
			
693
 
694
			#設置執行錯誤訊息
694
			#設置執行錯誤訊息
695
			$result["error"]="函數".$result["function"]."需要參數";
695
			$result["error"]="函數".$result["function"]."需要參數";
696
			
696
 
697
			#回傳結果
697
			#回傳結果
698
			return $result;
698
			return $result;
699
			
699
 
700
			}#if end
700
			}#if end
701
			
701
 
702
		#取得參數
702
		#取得參數
703
		$result["argu"]=$conf;
703
		$result["argu"]=$conf;
704
 
704
 
705
		#如果 $conf 不為陣列
705
		#如果 $conf 不為陣列
706
		if(gettype($conf)!="array"){
706
		if(gettype($conf)!="array"){
707
			
707
 
708
			#設置執行失敗
708
			#設置執行失敗
709
			$result["status"]="false";
709
			$result["status"]="false";
710
			
710
 
711
			#設置執行錯誤訊息
711
			#設置執行錯誤訊息
712
			$result["error"][]="\$conf變數須為陣列形態";
712
			$result["error"][]="\$conf變數須為陣列形態";
713
			
713
 
714
			#如果傳入的參數為 null
714
			#如果傳入的參數為 null
715
			if($conf==null){
715
			if($conf==null){
716
				
716
 
717
				#設置執行錯誤訊息
717
				#設置執行錯誤訊息
718
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
718
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
719
				
719
 
720
				}#if end
720
				}#if end
721
 
721
 
722
			#回傳結果
722
			#回傳結果
723
			return $result;
723
			return $result;
724
			
724
 
725
			}#if end
725
			}#if end
726
			
726
 
727
		#檢查參數
727
		#檢查參數
728
		#函式說明:
728
		#函式說明:
729
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
729
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
730
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
730
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
731
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
731
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 756... Line 756...
756
		#$conf["canBeEmpty"]=array();
756
		#$conf["canBeEmpty"]=array();
757
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
757
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
758
		#$conf["skipableVariableCanNotBeEmpty"]=array();
758
		#$conf["skipableVariableCanNotBeEmpty"]=array();
759
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
759
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
760
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liId");
760
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liId");
761
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
761
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
762
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
762
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
763
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
763
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
764
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"liName\"]");
764
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"liName\"]");
765
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
765
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
766
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet","liId");
766
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet","liId");
767
		#參考資料來源:
767
		#參考資料來源:
768
		#array_keys=>http://php.net/manual/en/function.array-keys.php
768
		#array_keys=>http://php.net/manual/en/function.array-keys.php
769
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
769
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
770
		unset($conf["variableCheck::checkArguments"]);
770
		unset($conf["variableCheck::checkArguments"]);
771
		
771
 
772
		#如果檢查參數失敗
772
		#如果檢查參數失敗
773
		if($checkArguments["status"]=="false"){
773
		if($checkArguments["status"]=="false"){
774
			
774
 
775
			#設置執行失敗
775
			#設置執行失敗
776
			$result["status"]="false";
776
			$result["status"]="false";
777
			
777
 
778
			#設置執行錯誤訊息
778
			#設置執行錯誤訊息
779
			$result["error"]=$checkArguments;
779
			$result["error"]=$checkArguments;
780
			
780
 
781
			#回傳結果
781
			#回傳結果
782
			return $result;
782
			return $result;
783
			
783
 
784
			}#if end
784
			}#if end
785
			
785
 
786
		#如果檢查參數不通過
786
		#如果檢查參數不通過
787
		if($checkArguments["passed"]=="false"){
787
		if($checkArguments["passed"]=="false"){
788
			
788
 
789
			#設置執行失敗
789
			#設置執行失敗
790
			$result["status"]="false";
790
			$result["status"]="false";
791
			
791
 
792
			#設置執行錯誤訊息
792
			#設置執行錯誤訊息
793
			$result["error"]=$checkArguments;
793
			$result["error"]=$checkArguments;
794
			
794
 
795
			#回傳結果
795
			#回傳結果
796
			return $result;
796
			return $result;
797
			
797
 
798
			}#if end	
798
			}#if end
799
		
799
 
800
		#函式說明:
800
		#函式說明:
801
		#匯入phpodt函式庫的函式
801
		#匯入phpodt函式庫的函式
802
		#回傳結果:
802
		#回傳結果:
803
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
803
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
804
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
804
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 806... Line 806...
806
		#必填參數:
806
		#必填參數:
807
		#無
807
		#無
808
		#可省略參數:
808
		#可省略參數:
809
		#無
809
		#無
810
		$importLib=od::importOdtLib();
810
		$importLib=od::importOdtLib();
811
		
811
 
812
		#如果匯入 phpodt 函式庫失敗
812
		#如果匯入 phpodt 函式庫失敗
813
		if($importLib["status"]=="false"){
813
		if($importLib["status"]=="false"){
814
			
814
 
815
			#設置錯誤訊息
815
			#設置錯誤訊息
816
			$result["error"]=$importLib;
816
			$result["error"]=$importLib;
817
		
817
 
818
			#設置執行不正常
818
			#設置執行不正常
819
			$result["status"]="false";
819
			$result["status"]="false";
820
			
820
 
821
			#回傳結果
821
			#回傳結果
822
			return $result;
822
			return $result;
823
			
823
 
824
			}#if end
824
			}#if end
825
		
825
 
826
		#建立實體
826
		#建立實體
827
		$odt=\ODT::getInstance();
827
		$odt=\ODT::getInstance();
828
		
828
 
829
		#針對 $conf["content"] 的每個元素
829
		#針對 $conf["content"] 的每個元素
830
		foreach($conf["content"] as $pKey=>$pVal){
830
		foreach($conf["content"] as $pKey=>$pVal){
831
			
831
 
832
			#新增段落
832
			#新增段落
833
			$pKey=new \Paragraph();
833
			$pKey=new \Paragraph();
834
			
834
 
835
			#設置內容
835
			#設置內容
836
			$pKey->addText($pVal);
836
			$pKey->addText($pVal);
837
			
837
 
838
			}#foreach end
838
			}#foreach end
839
		
839
 
840
		#輸出置檔案
840
		#輸出置檔案
841
		$odt->output($conf["filePathAndName"].".odt");
841
		$odt->output($conf["filePathAndName"].".odt");
842
		
842
 
843
		#取得檔案位置
843
		#取得檔案位置
844
		$result["content"]=$conf["filePathAndName"].".odt";
844
		$result["content"]=$conf["filePathAndName"].".odt";
845
		
845
 
846
		#設置執行正常
846
		#設置執行正常
847
		$result["status"]="true";
847
		$result["status"]="true";
848
		
848
 
849
		#回傳結果
849
		#回傳結果
850
		return $result;
850
		return $result;
851
		
851
 
852
		}#function createOdt end
852
		}#function createOdt end
853
	
853
 
854
	}#class od end
854
	}#class od end
855
	
855
 
856
?>
856
?>