| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 239 |
liveuser |
6 |
Copyright (C) 2014~2026 MIN ZHI, CHEN
|
| 3 |
liveuser |
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
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
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
#宣告指派命名空間
|
|
|
26 |
namespace qbpwcf;
|
|
|
27 |
|
|
|
28 |
#建立跟表格有關的類別
|
|
|
29 |
class table{
|
|
|
30 |
|
|
|
31 |
/*
|
|
|
32 |
#函式說明:
|
|
|
33 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
34 |
#回傳結果:
|
|
|
35 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
36 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
37 |
#$result["function"],當前執行的函式名稱.
|
|
|
38 |
#必填參數:
|
|
|
39 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
40 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
41 |
#可省略參數:
|
|
|
42 |
#無.
|
|
|
43 |
#參考資料:
|
|
|
44 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
45 |
#備註:
|
|
|
46 |
#無.
|
|
|
47 |
*/
|
|
|
48 |
public function __call($method,$arguments){
|
|
|
49 |
|
|
|
50 |
#取得當前執行的函式
|
|
|
51 |
$result["function"]=__FUNCTION__;
|
|
|
52 |
|
|
|
53 |
#設置執行不正常
|
|
|
54 |
$result["status"]="false";
|
|
|
55 |
|
|
|
56 |
#設置執行錯誤
|
|
|
57 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
58 |
|
|
|
59 |
#設置所丟入的參數
|
|
|
60 |
$result["error"][]=$arguments;
|
|
|
61 |
|
|
|
62 |
#回傳結果
|
|
|
63 |
return $result;
|
|
|
64 |
|
|
|
65 |
}#function __call end
|
|
|
66 |
|
|
|
67 |
/*
|
|
|
68 |
#函式說明:
|
|
|
69 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
70 |
#回傳結果:
|
|
|
71 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
72 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
73 |
#$result["function"],當前執行的函式名稱.
|
|
|
74 |
#必填參數:
|
|
|
75 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
76 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
77 |
#可省略參數:
|
|
|
78 |
#無.
|
|
|
79 |
#參考資料:
|
|
|
80 |
#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
81 |
#備註:
|
|
|
82 |
#無.
|
|
|
83 |
*/
|
|
|
84 |
public static function __callStatic($method,$arguments){
|
|
|
85 |
|
|
|
86 |
#取得當前執行的函式
|
|
|
87 |
$result["function"]=__FUNCTION__;
|
|
|
88 |
|
|
|
89 |
#設置執行不正常
|
|
|
90 |
$result["status"]="false";
|
|
|
91 |
|
|
|
92 |
#設置執行錯誤
|
|
|
93 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
94 |
|
|
|
95 |
#設置所丟入的參數
|
|
|
96 |
$result["error"][]=$arguments;
|
|
|
97 |
|
|
|
98 |
#回傳結果
|
|
|
99 |
return $result;
|
|
|
100 |
|
|
|
101 |
}#function __callStatic end
|
|
|
102 |
|
|
|
103 |
/*
|
|
|
104 |
#函式說明:
|
|
|
105 |
#表格開始,可以設定表格的厚度和位置
|
|
|
106 |
#回傳結果:
|
|
|
107 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
108 |
#$result["content"],表格開始的語法
|
|
|
109 |
#$result["function"],當前執行的函數
|
|
|
110 |
#$result["error"],涵式錯誤訊息
|
|
|
111 |
#必填參數:
|
|
|
112 |
#$conf["class"],字串,爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
113 |
$conf["class"]="";
|
|
|
114 |
#可省略參數:
|
|
|
115 |
#無.
|
|
|
116 |
#參考資料:
|
|
|
117 |
#無.
|
|
|
118 |
#備註:
|
|
|
119 |
#無.
|
|
|
120 |
*/
|
|
|
121 |
public static function start(&$conf){
|
|
|
122 |
|
|
|
123 |
#初始化要回傳的內容
|
|
|
124 |
$result=array();
|
|
|
125 |
|
|
|
126 |
#設置當前執行的函數
|
|
|
127 |
$result["function"]=__FUNCTION__;
|
|
|
128 |
|
|
|
129 |
#初始化表格開始的語法
|
|
|
130 |
$result["content"]="";
|
|
|
131 |
|
|
|
132 |
#如果 $conf 不為陣列
|
|
|
133 |
if(gettype($conf)!="array"){
|
|
|
134 |
|
|
|
135 |
#設置執行失敗
|
|
|
136 |
$result["status"]="false";
|
|
|
137 |
|
|
|
138 |
#設置執行錯誤訊息
|
|
|
139 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
140 |
|
|
|
141 |
#如果傳入的參數為 null
|
|
|
142 |
if($conf==null){
|
|
|
143 |
|
|
|
144 |
#設置執行錯誤訊息
|
|
|
145 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
146 |
|
|
|
147 |
}#if end
|
|
|
148 |
|
|
|
149 |
#回傳結果
|
|
|
150 |
return $result;
|
|
|
151 |
|
|
|
152 |
}#if end
|
|
|
153 |
|
|
|
154 |
#檢查參數
|
|
|
155 |
#函式說明:
|
|
|
156 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
157 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
158 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
159 |
#$result["function"],當前執行的函式名稱.
|
|
|
160 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
161 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
162 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
163 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
164 |
#必填參數:
|
|
|
165 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
166 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
167 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
168 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("class");
|
|
|
169 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
170 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
171 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
172 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
173 |
#可省略參數:
|
|
|
174 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
175 |
$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
176 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
177 |
#$conf["skipableVariableName"]=array();
|
|
|
178 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
179 |
#$conf["skipableVariableType"]=array();
|
|
|
180 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
181 |
#$conf["skipableVarDefaultValue"]=array("");
|
|
|
182 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
183 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
184 |
|
|
|
185 |
#如果檢查失敗
|
|
|
186 |
if($checkResult["status"]=="false"){
|
|
|
187 |
|
|
|
188 |
#設置執行不正常
|
|
|
189 |
$result["status"]="false";
|
|
|
190 |
|
|
|
191 |
#程式停止執行
|
|
|
192 |
$result["error"]=$checkResult;
|
|
|
193 |
|
|
|
194 |
#回傳結果
|
|
|
195 |
return $result;
|
|
|
196 |
|
|
|
197 |
}#if end
|
|
|
198 |
|
|
|
199 |
#如果檢查不通過
|
|
|
200 |
if($checkResult["passed"]=="false"){
|
|
|
201 |
|
|
|
202 |
#設置執行不正常
|
|
|
203 |
$result["status"]="false";
|
|
|
204 |
|
|
|
205 |
#程式停止執行
|
|
|
206 |
$result["error"]=$checkResult;
|
|
|
207 |
|
|
|
208 |
#回傳結果
|
|
|
209 |
return $result;
|
|
|
210 |
|
|
|
211 |
}#if end
|
|
|
212 |
|
|
|
213 |
#判斷 $conf["class"] 的內容
|
|
|
214 |
switch($conf["class"]){
|
|
|
215 |
|
|
|
216 |
#如果為 "__withBorder"
|
|
|
217 |
case "__withBorder":
|
|
|
218 |
|
|
|
219 |
#建立表格預設的 css 樣式 "__defaultTbaleCsssStyle"
|
|
|
220 |
#函式說明:
|
|
|
221 |
#創建 css 樣式
|
|
|
222 |
#必填參數:
|
|
|
223 |
$conf_createCssStyle["cssStyleName"]="__withBorderTableCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
224 |
$conf_createCssStyle["attributes"]=array("table-layout","word-break","width","border","border-color","border-style","margin-right","margin-left","font-size");#為屬性名稱,須為陣列值
|
|
|
225 |
$conf_createCssStyle["content"]=array("fixed","break-all","100%","1px","#000000","solid","auto","auto","30px");#為屬性值,須為陣列值
|
|
|
226 |
$css["createCssStyle"]=css::createCssStyle($conf_createCssStyle);
|
|
|
227 |
unset($conf_createCssStyle);
|
|
|
228 |
|
|
|
229 |
#如果建立css樣式失敗
|
|
|
230 |
if($css["createCssStyle"]["status"]=="false"){
|
|
|
231 |
|
|
|
232 |
#設置執行不正常
|
|
|
233 |
$result["status"]="false";
|
|
|
234 |
|
|
|
235 |
#程式停止執行
|
|
|
236 |
$result["error"]=$css["createCssStyle"];
|
|
|
237 |
|
|
|
238 |
#回傳結果
|
|
|
239 |
return $result;
|
|
|
240 |
|
|
|
241 |
}#if end
|
|
|
242 |
|
|
|
243 |
#取得css樣式的設定字串
|
|
|
244 |
$result["content"]=$result["content"].$css["createCssStyle"]["content"];
|
|
|
245 |
|
|
|
246 |
#則套用預設的css樣式
|
|
|
247 |
$conf["class"]=" class = __withBorderTableCssStyle ";
|
|
|
248 |
|
|
|
249 |
#跳出 switch
|
|
|
250 |
break;
|
|
|
251 |
|
|
|
252 |
#如果為 "__withoutBorder"
|
|
|
253 |
case "__withoutBorder":
|
|
|
254 |
|
|
|
255 |
#建立表格預設的 css 樣式 "__withoutBorderTableCssStyle"
|
|
|
256 |
#函式說明:
|
|
|
257 |
#創建 css 樣式
|
|
|
258 |
#必填參數:
|
|
|
259 |
$conf_createCssStyle["cssStyleName"]="__withoutBorderTableCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
260 |
$conf_createCssStyle["attributes"]=array("table-layout","word-break","width","border","border-color","border-style","margin-right","margin-left","font-size");#為屬性名稱,須為陣列值
|
|
|
261 |
$conf_createCssStyle["content"]=array("fixed","break-all","97%","0px","#000000","solid","auto","auto","30px");#為屬性值,須為陣列值
|
|
|
262 |
$css["createCssStyle"]=css::createCssStyle($conf_createCssStyle);
|
|
|
263 |
unset($conf_createCssStyle);
|
|
|
264 |
|
|
|
265 |
#如果建立css樣式失敗
|
|
|
266 |
if($css["createCssStyle"]["status"]=="false"){
|
|
|
267 |
|
|
|
268 |
#設置執行不正常
|
|
|
269 |
$result["status"]="false";
|
|
|
270 |
|
|
|
271 |
#程式停止執行
|
|
|
272 |
$result["error"]=$css["createCssStyle"];
|
|
|
273 |
|
|
|
274 |
#回傳結果
|
|
|
275 |
return $result;
|
|
|
276 |
|
|
|
277 |
}#if end
|
|
|
278 |
|
|
|
279 |
#取得css樣式的設定字串
|
|
|
280 |
$result["content"]=$result["content"].$css["createCssStyle"]["content"];
|
|
|
281 |
|
|
|
282 |
#則套用預設的css樣式
|
|
|
283 |
$conf["class"]=" class = __withoutBorderTableCssStyle ";
|
|
|
284 |
|
|
|
285 |
#跳出 switch
|
|
|
286 |
break;
|
|
|
287 |
|
|
|
288 |
#如果為 ""
|
|
|
289 |
case "":
|
|
|
290 |
|
|
|
291 |
#則不設定要套用的css類別樣式
|
|
|
292 |
$conf["class"]="";
|
|
|
293 |
|
|
|
294 |
#跳出 switch
|
|
|
295 |
break;
|
|
|
296 |
|
|
|
297 |
#如果不是以上內容
|
|
|
298 |
default:
|
|
|
299 |
|
|
|
300 |
#套用其指定的樣式
|
|
|
301 |
$conf["class"]="class = ".$conf["class"];
|
|
|
302 |
|
|
|
303 |
#跳出 switch
|
|
|
304 |
break;
|
|
|
305 |
|
|
|
306 |
}#switch end
|
|
|
307 |
|
|
|
308 |
#放置表格的開頭語
|
|
|
309 |
$result["content"]=$result["content"]."<table ".$conf["class"]." ><tbody>";
|
|
|
310 |
|
|
|
311 |
#設置執行正常
|
|
|
312 |
$result["status"]="true";
|
|
|
313 |
|
|
|
314 |
#回傳結果
|
|
|
315 |
return $result;
|
|
|
316 |
|
|
|
317 |
}#function end
|
|
|
318 |
|
|
|
319 |
/*
|
|
|
320 |
#函式說明:
|
|
|
321 |
#表格結束
|
|
|
322 |
#回傳結果:
|
|
|
323 |
#$result,表格結束的語法
|
|
|
324 |
#必填參數:
|
|
|
325 |
#無.
|
|
|
326 |
#可省略參數:
|
|
|
327 |
#無.
|
|
|
328 |
#參考資料:
|
|
|
329 |
#無.
|
|
|
330 |
#備註:
|
|
|
331 |
#無.
|
|
|
332 |
*/
|
|
|
333 |
public static function end(){
|
|
|
334 |
|
|
|
335 |
return "</tbody></table>";
|
|
|
336 |
|
|
|
337 |
}#function end
|
|
|
338 |
|
|
|
339 |
/*
|
|
|
340 |
#函式說明:
|
|
|
341 |
#列開始
|
|
|
342 |
#回傳結果:
|
|
|
343 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
344 |
#$result["error"],涵式錯誤訊息陣列.
|
|
|
345 |
#$result["content"],列開始的語法.
|
|
|
346 |
#$result["function"],當前執行的函式名稱.
|
|
|
347 |
#必填參數:
|
|
|
348 |
#$conf["class"],字串,爲tr的css樣式,若為""則為不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
349 |
$conf["class"]="__noBorder";
|
|
|
350 |
#可省略參數:
|
|
|
351 |
#$conf["trTitle"],字串,該列要有什麼的提示字串.
|
|
|
352 |
#$conf["trTitle"]="";
|
|
|
353 |
#參考資料:
|
|
|
354 |
#無.
|
|
|
355 |
#備註:
|
|
|
356 |
#無.
|
|
|
357 |
*/
|
|
|
358 |
public static function trStart(&$conf){
|
|
|
359 |
|
|
|
360 |
#初始化要回傳的變數
|
|
|
361 |
$result=array();
|
|
|
362 |
|
|
|
363 |
#初始化要回傳的變數
|
|
|
364 |
$result["content"]="";
|
|
|
365 |
|
|
|
366 |
#初始化當前執行的函數名稱
|
|
|
367 |
$result["funciton"]=__FUNCTION__;
|
|
|
368 |
|
|
|
369 |
#如果 $conf 不為陣列
|
|
|
370 |
if(gettype($conf)!="array"){
|
|
|
371 |
|
|
|
372 |
#設置執行失敗
|
|
|
373 |
$result["status"]="false";
|
|
|
374 |
|
|
|
375 |
#設置執行錯誤訊息
|
|
|
376 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
377 |
|
|
|
378 |
#如果傳入的參數為 null
|
|
|
379 |
if($conf==null){
|
|
|
380 |
|
|
|
381 |
#設置執行錯誤訊息
|
|
|
382 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
383 |
|
|
|
384 |
}#if end
|
|
|
385 |
|
|
|
386 |
#回傳結果
|
|
|
387 |
return $result;
|
|
|
388 |
|
|
|
389 |
}#if end
|
|
|
390 |
|
|
|
391 |
#檢查參數
|
|
|
392 |
#函式說明:
|
|
|
393 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
394 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
395 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
396 |
#$result["function"],當前執行的函式名稱.
|
|
|
397 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
398 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
399 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
400 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
401 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
402 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
403 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
404 |
#必填參數:
|
|
|
405 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
406 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
407 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
408 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("class");
|
|
|
409 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
410 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
411 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
412 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
413 |
#可省略參數:
|
|
|
414 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
415 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
416 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
417 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("trTitle");
|
|
|
418 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
419 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
|
|
|
420 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
421 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
|
|
|
422 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
423 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
424 |
#參考資料來源:
|
|
|
425 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
426 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
427 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
428 |
|
|
|
429 |
#如果檢查失敗
|
|
|
430 |
if($checkResult["status"]=="false"){
|
|
|
431 |
|
|
|
432 |
#設置執行不正常
|
|
|
433 |
$result["status"]="false";
|
|
|
434 |
|
|
|
435 |
#設置錯誤訊息
|
|
|
436 |
$result["error"]=$checkResult;
|
|
|
437 |
|
|
|
438 |
#回傳結果
|
|
|
439 |
return $result;
|
|
|
440 |
|
|
|
441 |
}#if end
|
|
|
442 |
|
|
|
443 |
#如果檢查不通過
|
|
|
444 |
if($checkResult["passed"]=="false"){
|
|
|
445 |
|
|
|
446 |
#設置執行不正常
|
|
|
447 |
$result["status"]="false";
|
|
|
448 |
|
|
|
449 |
#設置錯誤訊息
|
|
|
450 |
$result["error"]=$checkResult;
|
|
|
451 |
|
|
|
452 |
#回傳結果
|
|
|
453 |
return $result;
|
|
|
454 |
|
|
|
455 |
}#if end
|
|
|
456 |
|
|
|
457 |
#判斷 $conf["class"] 的內容
|
|
|
458 |
switch($conf["class"]){
|
|
|
459 |
|
|
|
460 |
#如果為 "__withBorder"
|
|
|
461 |
case "__withBorder":
|
|
|
462 |
|
|
|
463 |
#建立表格預設的 css 樣式 "__defaultTbaleCsssStyle"
|
|
|
464 |
#函式說明:
|
|
|
465 |
#創建 css 樣式
|
|
|
466 |
#必填參數:
|
|
|
467 |
$conf_createCssStyle["cssStyleName"]="__withBorderTrCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
468 |
$conf_createCssStyle["attributes"]=array("table-layout","word-break","width","border","border-color","border-style");#為屬性名稱,須為陣列值
|
|
|
469 |
$conf_createCssStyle["content"]=array("fixed","break-all","100%","1px","#000000","solid");#為屬性值,須為陣列值
|
|
|
470 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
471 |
unset($conf_createCssStyle);
|
|
|
472 |
|
|
|
473 |
#如果建立css樣式失敗
|
|
|
474 |
if($css["status"]=="false"){
|
|
|
475 |
|
|
|
476 |
#設置執行失敗
|
|
|
477 |
$result["status"]="false";
|
|
|
478 |
|
|
|
479 |
#設置執行錯誤訊息
|
|
|
480 |
$result["error"]=$css;
|
|
|
481 |
|
|
|
482 |
#回傳結果
|
|
|
483 |
return $result;
|
|
|
484 |
|
|
|
485 |
}#if end
|
|
|
486 |
|
|
|
487 |
#取得css樣式的設定字串
|
|
|
488 |
$result["content"]=$result["content"].$css["content"];
|
|
|
489 |
|
|
|
490 |
#則套用預設的css樣式
|
|
|
491 |
$conf["class"]=" class = __withBorderTrCssStyle ";
|
|
|
492 |
|
|
|
493 |
#跳出 switch
|
|
|
494 |
break;
|
|
|
495 |
|
|
|
496 |
#如果為 "__withoutBorder"
|
|
|
497 |
case "__withoutBorder":
|
|
|
498 |
|
|
|
499 |
#建立表格預設的 css 樣式 "__defaultTbaleCssStyle"
|
|
|
500 |
#函式說明:
|
|
|
501 |
#創建 css 樣式
|
|
|
502 |
#必填參數:
|
|
|
503 |
$conf_createCssStyle["cssStyleName"]="__withoutBorderTrCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
504 |
$conf_createCssStyle["attributes"]=array("table-layout","word-break","width","border","border-color","border-style");#為屬性名稱,須為陣列值
|
|
|
505 |
$conf_createCssStyle["content"]=array("fixed","break-all","100%","0px","#000000","solid");#為屬性值,須為陣列值
|
|
|
506 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
507 |
unset($conf_createCssStyle);
|
|
|
508 |
|
|
|
509 |
#如果建立css樣式失敗
|
|
|
510 |
if($css["status"]=="false"){
|
|
|
511 |
|
|
|
512 |
#設置執行失敗
|
|
|
513 |
$result["status"]="false";
|
|
|
514 |
|
|
|
515 |
#設置執行錯誤訊息
|
|
|
516 |
$result["error"]=$css;
|
|
|
517 |
|
|
|
518 |
#回傳結果
|
|
|
519 |
return $result;
|
|
|
520 |
|
|
|
521 |
}#if end
|
|
|
522 |
|
|
|
523 |
#取得css樣式的設定字串
|
|
|
524 |
$result["content"]=$result["content"].$css["content"];
|
|
|
525 |
|
|
|
526 |
#則套用預設的css樣式
|
|
|
527 |
$conf["class"]=" class = __withoutBorderTrCssStyle ";
|
|
|
528 |
|
|
|
529 |
#跳出 switch
|
|
|
530 |
break;
|
|
|
531 |
|
|
|
532 |
#如果為 ""
|
|
|
533 |
case "":
|
|
|
534 |
|
|
|
535 |
#則不設定要套用的css類別樣式
|
|
|
536 |
$conf["class"]="";
|
|
|
537 |
|
|
|
538 |
#跳出 switch
|
|
|
539 |
break;
|
|
|
540 |
|
|
|
541 |
#如果不是以上內容
|
|
|
542 |
default:
|
|
|
543 |
|
|
|
544 |
#套用其指定的樣式
|
|
|
545 |
$conf["class"]="class = ".$conf["class"];
|
|
|
546 |
|
|
|
547 |
#跳出 switch
|
|
|
548 |
break;
|
|
|
549 |
|
|
|
550 |
}#switch end
|
|
|
551 |
|
|
|
552 |
#如果 $conf["trTitle"] 有設定
|
|
|
553 |
if(isset($conf["trTitle"])){
|
|
|
554 |
|
|
|
555 |
#設置提示字串
|
|
|
556 |
$conf["trTitle"]="title=\"".$conf["trTitle"]."\"";
|
|
|
557 |
|
|
|
558 |
}#if end
|
|
|
559 |
|
|
|
560 |
#提示字串設為 ""
|
|
|
561 |
else{
|
|
|
562 |
|
|
|
563 |
$conf["trTitle"]="";
|
|
|
564 |
|
|
|
565 |
}#else end
|
|
|
566 |
|
|
|
567 |
#建立 tr 標籤與指派css樣式
|
|
|
568 |
$result["content"]=$result["content"]." <tr ".$conf["class"]." ".$conf["trTitle"]."> ";
|
|
|
569 |
|
|
|
570 |
#執行到這邊代表執行正常
|
|
|
571 |
$result["status"]="true";
|
|
|
572 |
|
|
|
573 |
#回傳結果
|
|
|
574 |
return $result;
|
|
|
575 |
|
|
|
576 |
}#function trStart end
|
|
|
577 |
|
|
|
578 |
/*
|
|
|
579 |
#函式說明:
|
|
|
580 |
#列結束
|
|
|
581 |
#回傳結果:
|
|
|
582 |
#$result,列結束的語法
|
|
|
583 |
#必填參數:
|
|
|
584 |
#無.
|
|
|
585 |
#可省略參數:
|
|
|
586 |
#無.
|
|
|
587 |
#參考資料:
|
|
|
588 |
#無.
|
|
|
589 |
#備註:
|
|
|
590 |
#無.
|
|
|
591 |
*/
|
|
|
592 |
public static function trEnd(){
|
|
|
593 |
|
|
|
594 |
return "</tr>";
|
|
|
595 |
|
|
|
596 |
}#function trEnd end
|
|
|
597 |
|
|
|
598 |
/*
|
|
|
599 |
#函式說明:
|
|
|
600 |
#行開始
|
|
|
601 |
#回傳結果:
|
|
|
602 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
603 |
#$result["error"],涵式錯誤訊息陣列.
|
|
|
604 |
#$result["content"],行開始的語法.
|
|
|
605 |
#$result["function"],當前執行的函式名稱.
|
|
|
606 |
#必填參數:
|
|
|
607 |
#$conf["class"],字串,該 td 要套用套用的 css 樣式,若為""則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式.
|
|
|
608 |
$conf["class"]="__withoutBorder";
|
|
|
609 |
#可省略參數:
|
|
|
610 |
#$conf["colspan"],整數字串,為欄位合併的數量.
|
|
|
611 |
#$conf["colspan"]="2";
|
|
|
612 |
#$conf["rowspan"],整數字串,為列合併的數量.
|
|
|
613 |
#$conf["rowspan"]="2";
|
|
|
614 |
#參考資料:
|
|
|
615 |
#無.
|
|
|
616 |
#備註:
|
|
|
617 |
#無.
|
|
|
618 |
*/
|
|
|
619 |
public static function tdStart(&$conf){
|
|
|
620 |
|
|
|
621 |
#初始化要回傳的變數
|
|
|
622 |
$result=array();
|
|
|
623 |
|
|
|
624 |
#初始化要回傳的變數
|
|
|
625 |
$result["content"]="";
|
|
|
626 |
|
|
|
627 |
#初始化當前執行的函數名稱
|
|
|
628 |
$result["funciton"]=__FUNCTION__;
|
|
|
629 |
|
|
|
630 |
#如果 $conf 不為陣列
|
|
|
631 |
if(gettype($conf)!="array"){
|
|
|
632 |
|
|
|
633 |
#設置執行失敗
|
|
|
634 |
$result["status"]="false";
|
|
|
635 |
|
|
|
636 |
#設置執行錯誤訊息
|
|
|
637 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
638 |
|
|
|
639 |
#如果傳入的參數為 null
|
|
|
640 |
if($conf==null){
|
|
|
641 |
|
|
|
642 |
#設置執行錯誤訊息
|
|
|
643 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
644 |
|
|
|
645 |
}#if end
|
|
|
646 |
|
|
|
647 |
#回傳結果
|
|
|
648 |
return $result;
|
|
|
649 |
|
|
|
650 |
}#if end
|
|
|
651 |
|
|
|
652 |
#檢查參數
|
|
|
653 |
#函式說明:
|
|
|
654 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
655 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
656 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
657 |
#$result["function"],當前執行的函式名稱.
|
|
|
658 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
659 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
660 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
661 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
662 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
663 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
664 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
665 |
#必填參數:
|
|
|
666 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
667 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
668 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
669 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("class");
|
|
|
670 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
671 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
672 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
673 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
674 |
#可省略參數:
|
|
|
675 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
676 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
677 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
678 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("colspan","rowspan");
|
|
|
679 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
680 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
681 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
682 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null);
|
|
|
683 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
684 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
685 |
#參考資料來源:
|
|
|
686 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
687 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
688 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
689 |
|
|
|
690 |
#如果檢查失敗
|
|
|
691 |
if($checkResult["status"]=="false"){
|
|
|
692 |
|
|
|
693 |
#設置執行不正常
|
|
|
694 |
$result["status"]="false";
|
|
|
695 |
|
|
|
696 |
#設置錯誤訊息
|
|
|
697 |
$result["error"]=$checkResult;
|
|
|
698 |
|
|
|
699 |
#回傳結果
|
|
|
700 |
return $result;
|
|
|
701 |
|
|
|
702 |
}#if end
|
|
|
703 |
|
|
|
704 |
#如果檢查不通過
|
|
|
705 |
if($checkResult["passed"]=="false"){
|
|
|
706 |
|
|
|
707 |
#設置執行不正常
|
|
|
708 |
$result["status"]="false";
|
|
|
709 |
|
|
|
710 |
#設置錯誤訊息
|
|
|
711 |
$result["error"]=$checkResult;
|
|
|
712 |
|
|
|
713 |
#回傳結果
|
|
|
714 |
return $result;
|
|
|
715 |
|
|
|
716 |
}#if end
|
|
|
717 |
|
|
|
718 |
#如果沒有設定樣式
|
|
|
719 |
if(!isset($conf["class"])){
|
|
|
720 |
|
|
|
721 |
#回傳錯誤訊息
|
|
|
722 |
return "\$conf[\"class\"]參數未設置";
|
|
|
723 |
|
|
|
724 |
}#if end
|
|
|
725 |
|
|
|
726 |
#判斷 $conf["class"] 的內容
|
|
|
727 |
switch($conf["class"]){
|
|
|
728 |
|
|
|
729 |
#如果為 "__withBorder"
|
|
|
730 |
case "__withBorder":
|
|
|
731 |
|
|
|
732 |
#建立表格預設的 css 樣式 "__defaultTbaleCssStyle"
|
|
|
733 |
#函式說明:
|
|
|
734 |
#創建 css 樣式
|
|
|
735 |
#必填參數:
|
|
|
736 |
$conf_createCssStyle["cssStyleName"]="__withBorderTdCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
737 |
$conf_createCssStyle["attributes"]=array("text-align","table-layout","word-break","width","border","border-color","border-style","margin");#為屬性名稱,須為陣列值
|
|
|
738 |
$conf_createCssStyle["content"]=array("center","fixed","break-all","100%","1px","#000000","solid","0px");#為屬性值,須為陣列值
|
|
|
739 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
740 |
unset($conf_createCssStyle);
|
|
|
741 |
|
|
|
742 |
#如果建立css樣式失敗
|
|
|
743 |
if($css["status"]=="false"){
|
|
|
744 |
|
|
|
745 |
#設置執行失敗
|
|
|
746 |
$result["status"]="false";
|
|
|
747 |
|
|
|
748 |
#設置執行錯誤訊息
|
|
|
749 |
$result["error"]=$css;
|
|
|
750 |
|
|
|
751 |
#回傳結果
|
|
|
752 |
return $result;
|
|
|
753 |
|
|
|
754 |
}#if end
|
|
|
755 |
|
|
|
756 |
#取得css樣式的設定字串
|
|
|
757 |
$result["content"]=$result["content"].$css["content"];
|
|
|
758 |
|
|
|
759 |
#則套用預設的css樣式
|
|
|
760 |
$conf["class"]=" class = __withBorderTdCssStyle ";
|
|
|
761 |
|
|
|
762 |
#跳出 switch
|
|
|
763 |
break;
|
|
|
764 |
|
|
|
765 |
#如果為 "__withoutBorder"
|
|
|
766 |
case "__withoutBorder":
|
|
|
767 |
|
|
|
768 |
#建立表格預設的 css 樣式 "__defaultTbaleCssStyle"
|
|
|
769 |
#函式說明:
|
|
|
770 |
#創建 css 樣式
|
|
|
771 |
#必填參數:
|
|
|
772 |
$conf_createCssStyle["cssStyleName"]="__withoutBorderTdCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
773 |
$conf_createCssStyle["attributes"]=array("text-align","table-layout","word-break","width","border","border-color","border-style");#為屬性名稱,須為陣列值
|
|
|
774 |
$conf_createCssStyle["content"]=array("center","fixed","break-all","100%","0px","#000000","solid");#為屬性值,須為陣列值
|
|
|
775 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
776 |
unset($conf_createCssStyle);
|
|
|
777 |
|
|
|
778 |
#如果建立css樣式失敗
|
|
|
779 |
if($css["status"]=="false"){
|
|
|
780 |
|
|
|
781 |
#設置執行失敗
|
|
|
782 |
$result["status"]="false";
|
|
|
783 |
|
|
|
784 |
#設置執行錯誤訊息
|
|
|
785 |
$result["error"]=$css;
|
|
|
786 |
|
|
|
787 |
#回傳結果
|
|
|
788 |
return $result;
|
|
|
789 |
|
|
|
790 |
}#if end
|
|
|
791 |
|
|
|
792 |
#取得css樣式的設定字串
|
|
|
793 |
$result["content"]=$result["content"].$css["content"];
|
|
|
794 |
|
|
|
795 |
#則套用預設的css樣式
|
|
|
796 |
$conf["class"]=" class = __withoutBorderTdCssStyle ";
|
|
|
797 |
|
|
|
798 |
#跳出 switch
|
|
|
799 |
break;
|
|
|
800 |
|
|
|
801 |
#如果為 ""
|
|
|
802 |
case "":
|
|
|
803 |
|
|
|
804 |
#則不設定要套用的css類別樣式
|
|
|
805 |
$conf["class"]="";
|
|
|
806 |
|
|
|
807 |
#跳出 switch
|
|
|
808 |
break;
|
|
|
809 |
|
|
|
810 |
#如果不是以上內容
|
|
|
811 |
default:
|
|
|
812 |
|
|
|
813 |
#套用其指定的樣式
|
|
|
814 |
$conf["class"]="class = ".$conf["class"];
|
|
|
815 |
|
|
|
816 |
#跳出 switch
|
|
|
817 |
break;
|
|
|
818 |
|
|
|
819 |
}#switch end
|
|
|
820 |
|
|
|
821 |
#如果 $conf["colspan"] 有設定
|
|
|
822 |
if(isset($conf["colspan"])){
|
|
|
823 |
|
|
|
824 |
#設定要合併的欄位數量
|
|
|
825 |
$conf["colspan"]=" colspan = ".$conf["colspan"];
|
|
|
826 |
|
|
|
827 |
}#if end
|
|
|
828 |
|
|
|
829 |
#欄位合併的參數如果沒有設定
|
|
|
830 |
if(!isset($conf["colspan"])){
|
|
|
831 |
|
|
|
832 |
#則設定為""
|
|
|
833 |
$conf["colspan"]="";
|
|
|
834 |
|
|
|
835 |
}#if end
|
|
|
836 |
|
|
|
837 |
#如果 $conf["rowspan"] 有設定
|
|
|
838 |
if(isset($conf["rowspan"])){
|
|
|
839 |
|
|
|
840 |
#設定要合併的列數量
|
|
|
841 |
$conf["rowspan"]=" rowspan = ".$conf["rowspan"];
|
|
|
842 |
|
|
|
843 |
}#if end
|
|
|
844 |
|
|
|
845 |
#列合併的參數如果沒有設定
|
|
|
846 |
if(!isset($conf["rowspan"])){
|
|
|
847 |
|
|
|
848 |
#則設定為""
|
|
|
849 |
$conf["rowspan"]="";
|
|
|
850 |
|
|
|
851 |
}#if end
|
|
|
852 |
|
|
|
853 |
#建立 td 標籤與指派css樣式
|
|
|
854 |
$result["content"]=$result["content"]." <td ".$conf["class"]." ".$conf["colspan"]." ".$conf["rowspan"]." > ";
|
|
|
855 |
|
|
|
856 |
#執行到這邊代表正常
|
|
|
857 |
$result["status"]="true";
|
|
|
858 |
|
|
|
859 |
#回傳結果
|
|
|
860 |
return $result;
|
|
|
861 |
|
|
|
862 |
}#function tdStart end
|
|
|
863 |
|
|
|
864 |
/*
|
|
|
865 |
#函式說明:
|
|
|
866 |
#行結束
|
|
|
867 |
#回傳結果:
|
|
|
868 |
#$result,行結束的語法.
|
|
|
869 |
#必填參數:
|
|
|
870 |
#無.
|
|
|
871 |
#可省略參數:
|
|
|
872 |
#無.
|
|
|
873 |
#參考資料:
|
|
|
874 |
#無.
|
|
|
875 |
#備註:
|
|
|
876 |
#無.
|
|
|
877 |
*/
|
|
|
878 |
public static function tdEnd(){
|
|
|
879 |
|
|
|
880 |
return "</td>";
|
|
|
881 |
|
|
|
882 |
}#function tdEnd end
|
|
|
883 |
|
|
|
884 |
/*
|
|
|
885 |
#函式說明:
|
|
|
886 |
#建立列的元素,以及指定裏面要放什麼內容
|
|
|
887 |
#回傳結果:
|
|
|
888 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
889 |
#$result["error"],錯誤訊息陣列.
|
|
|
890 |
#$result["function"],當前執行的函數名稱.
|
|
|
891 |
#$result["argu"],使用的參數.
|
|
|
892 |
#$result["content"],建立列元素的語法.
|
|
|
893 |
#必填參數:
|
|
|
894 |
#$conf["trClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式.
|
|
|
895 |
$conf["tdClass"]="__withoutBorder";
|
|
|
896 |
#$conf["tdContent"],字串陣列,列裏面要放的元素是?如果要空一欄則可以輸array(" ").
|
|
|
897 |
$conf["tdContent"]=array();
|
|
|
898 |
#可省略參數:
|
|
|
899 |
#$conf["tableStartClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式.
|
|
|
900 |
#$conf["tableStartClass"]="__withoutBorder";
|
|
|
901 |
#$conf["tableStart"],字串,爲是否要表格開始,"true"表示"是".
|
|
|
902 |
#$conf["tableStart"]="true";
|
|
|
903 |
#$conf["tableEnd"],字串,爲是否要表格結束,"true"表示"是".
|
|
|
904 |
#$conf["tableEnd"]="true";
|
|
|
905 |
#$conf["trTitle"],字串,該列是否要設定提示字串.
|
|
|
906 |
#$conf["trTitle"]="";
|
|
|
907 |
#$conf["formStart"],字串,是否要有表單的開始.
|
|
|
908 |
#$conf["formStart"]="true";
|
|
|
909 |
#$conf["formName"],字串,該表單的名稱.
|
|
|
910 |
#$conf["formName"]="";
|
|
|
911 |
#$conf["formAction"],字串,表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置.
|
|
|
912 |
#$conf["formAction"]="";
|
|
|
913 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
914 |
#$conf["formTarget"]="_self";
|
|
|
915 |
#$conf["formEnd"],字串,是否要有表單的結束.
|
|
|
916 |
#$conf["formEnd"]="true";
|
|
|
917 |
#參考資料:
|
|
|
918 |
#無.
|
|
|
919 |
#備註:
|
|
|
920 |
#無.
|
|
|
921 |
*/
|
|
|
922 |
public static function printRow(&$conf){
|
|
|
923 |
|
|
|
924 |
#設置要回傳的變數
|
|
|
925 |
$result=array();
|
|
|
926 |
|
|
|
927 |
#設置要回傳的語法
|
|
|
928 |
$result["content"]="";
|
|
|
929 |
|
|
|
930 |
#取得當前執行的函數名稱
|
|
|
931 |
$result["function"]=__FUNCTION__;
|
|
|
932 |
|
|
|
933 |
#取得使用的參數
|
|
|
934 |
$result["argu"]=$conf;
|
|
|
935 |
|
|
|
936 |
#如果 $conf 不為陣列
|
|
|
937 |
if(gettype($conf)!="array"){
|
|
|
938 |
|
|
|
939 |
#設置執行失敗
|
|
|
940 |
$result["status"]="false";
|
|
|
941 |
|
|
|
942 |
#設置執行錯誤訊息
|
|
|
943 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
944 |
|
|
|
945 |
#如果傳入的參數為 null
|
|
|
946 |
if($conf==null){
|
|
|
947 |
|
|
|
948 |
#設置執行錯誤訊息
|
|
|
949 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
950 |
|
|
|
951 |
}#if end
|
|
|
952 |
|
|
|
953 |
#回傳結果
|
|
|
954 |
return $result;
|
|
|
955 |
|
|
|
956 |
}#if end
|
|
|
957 |
|
|
|
958 |
#檢查參數
|
|
|
959 |
#函式說明:
|
|
|
960 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
961 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
962 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
963 |
#$result["function"],當前執行的函式名稱.
|
|
|
964 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
965 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
966 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
967 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
968 |
#必填參數:
|
|
|
969 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
970 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
971 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
972 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("trClass","tdClass","tdContent");
|
|
|
973 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
974 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array");
|
|
|
975 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
976 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
977 |
#可省略參數:
|
|
|
978 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
979 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
980 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
981 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("tableStartClass","tableStart","tableEnd","trTitle","formStart","formName","formAction","formTarget","formEnd");
|
|
|
982 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
983 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string");
|
|
|
984 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
985 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array();
|
|
|
986 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
987 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
|
|
|
988 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
989 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
990 |
|
|
|
991 |
#如果檢查失敗
|
|
|
992 |
if($checkResult["status"]=="false"){
|
|
|
993 |
|
|
|
994 |
#設置執行失敗
|
|
|
995 |
$result["status"]="false";
|
|
|
996 |
|
|
|
997 |
#設置執行錯誤
|
|
|
998 |
$result["error"]=$checkResult;
|
|
|
999 |
|
|
|
1000 |
#回傳結果
|
|
|
1001 |
return $result;
|
|
|
1002 |
|
|
|
1003 |
}#if end
|
|
|
1004 |
|
|
|
1005 |
#如果檢查不通過
|
|
|
1006 |
if($checkResult["passed"]=="false"){
|
|
|
1007 |
|
|
|
1008 |
#設置執行失敗
|
|
|
1009 |
$result["status"]="false";
|
|
|
1010 |
|
|
|
1011 |
#設置執行錯誤
|
|
|
1012 |
$result["error"]=$checkResult;
|
|
|
1013 |
|
|
|
1014 |
#回傳結果
|
|
|
1015 |
return $result;
|
|
|
1016 |
|
|
|
1017 |
}#if end
|
|
|
1018 |
|
|
|
1019 |
#如果 $conf["formStart"] 有設置
|
|
|
1020 |
if(isset($conf["formStart"])){
|
|
|
1021 |
|
|
|
1022 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
1023 |
if($conf["formStart"]=="true"){
|
|
|
1024 |
|
|
|
1025 |
#如果 $conf$conf["formAction"] 沒有設置
|
|
|
1026 |
if(!isset($conf["formAction"])){
|
|
|
1027 |
|
|
|
1028 |
#設置執行錯誤
|
|
|
1029 |
$result["error"]="\$conf[\"formAction\"]沒有設置!";
|
|
|
1030 |
|
|
|
1031 |
#設置執行失敗
|
|
|
1032 |
$result["status"]="false";
|
|
|
1033 |
|
|
|
1034 |
#回傳錯誤訊息
|
|
|
1035 |
return $result;
|
|
|
1036 |
|
|
|
1037 |
}#if end
|
|
|
1038 |
|
|
|
1039 |
#設置表單開始
|
|
|
1040 |
#函式說明:
|
|
|
1041 |
#表單開始
|
|
|
1042 |
#回傳結果:
|
|
|
1043 |
#$result,表單開始的語法
|
|
|
1044 |
#必填參數:
|
|
|
1045 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
1046 |
#可省略參數:
|
|
|
1047 |
#$conf["form"]["start"]["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
1048 |
#$conf["form"]["start"]["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
1049 |
#$conf["form"]["start"]["tableClass"]="";#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1050 |
|
|
|
1051 |
#如果有設置 $conf["formName"]
|
|
|
1052 |
if(isset($conf["formName"])){
|
|
|
1053 |
|
|
|
1054 |
#函式說明:
|
|
|
1055 |
#處理字串避免網頁出錯
|
|
|
1056 |
#回傳結果:
|
|
|
1057 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1058 |
#$result["function"],當前執行的函數.
|
|
|
1059 |
#$result["content"],爲處理好的字串.
|
|
|
1060 |
#$result["error"],錯誤訊息陣列.
|
| 226 |
liveuser |
1061 |
#$result["argu"],使用的參數.
|
| 3 |
liveuser |
1062 |
#必填參數:
|
|
|
1063 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
1064 |
#可省略參數:
|
|
|
1065 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array(" ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
1066 |
#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
|
|
|
1067 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
1068 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
1069 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
1070 |
unset($conf["stringProcess::correctCharacter"]);
|
| 226 |
liveuser |
1071 |
|
| 3 |
liveuser |
1072 |
#如果處理失敗
|
|
|
1073 |
if($correctCharacter["status"]==="false"){
|
|
|
1074 |
|
|
|
1075 |
#設置執行失敗
|
|
|
1076 |
$result["status"]="false";
|
|
|
1077 |
|
|
|
1078 |
#設置執行錯誤
|
|
|
1079 |
$result["error"]=$correctCharacter;
|
|
|
1080 |
|
|
|
1081 |
#回傳結果
|
|
|
1082 |
return $result;
|
|
|
1083 |
|
| 226 |
liveuser |
1084 |
}#if end
|
|
|
1085 |
|
| 3 |
liveuser |
1086 |
#則設定其參數
|
|
|
1087 |
$conf["form"]["start"]["name"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
1088 |
|
|
|
1089 |
}#if end
|
|
|
1090 |
|
|
|
1091 |
#如果有設置 $conf["formTarget"]
|
|
|
1092 |
if(isset($conf["formTarget"])){
|
|
|
1093 |
|
|
|
1094 |
#則設定其參數
|
|
|
1095 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
1096 |
|
|
|
1097 |
}#if end
|
|
|
1098 |
|
|
|
1099 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
1100 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
1101 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100%
|
|
|
1102 |
|
|
|
1103 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
1104 |
unset($conf["form"]["start"]);
|
|
|
1105 |
|
|
|
1106 |
#如果建議建立表單開始失敗
|
|
|
1107 |
if($formStart["status"]=="false"){
|
|
|
1108 |
|
|
|
1109 |
#設置執行錯誤
|
|
|
1110 |
$result["error"]=$formStart;
|
|
|
1111 |
|
|
|
1112 |
#設置執行失敗
|
|
|
1113 |
$result["status"]="false";
|
|
|
1114 |
|
|
|
1115 |
#回傳錯誤訊息
|
|
|
1116 |
return $result;
|
|
|
1117 |
|
|
|
1118 |
}#if end
|
|
|
1119 |
|
|
|
1120 |
#串接表單開始
|
|
|
1121 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
1122 |
|
|
|
1123 |
}#if end
|
|
|
1124 |
|
|
|
1125 |
}#if end
|
|
|
1126 |
|
|
|
1127 |
#如果 $conf["tableStart"] 存在
|
|
|
1128 |
if(isset($conf["tableStart"])){
|
|
|
1129 |
|
|
|
1130 |
#如果 $conf["tableStart"] 等於 true
|
|
|
1131 |
if($conf["tableStart"]=="true"){
|
|
|
1132 |
|
|
|
1133 |
#如果表格開始的樣式沒有指定
|
|
|
1134 |
if(!isset($conf["tableStartClass"])){
|
|
|
1135 |
|
|
|
1136 |
#則將其參數設為空值
|
|
|
1137 |
$conf["table"]["start"]["class"]="";
|
|
|
1138 |
|
|
|
1139 |
}#if end
|
|
|
1140 |
|
|
|
1141 |
#反之
|
|
|
1142 |
else{
|
|
|
1143 |
|
|
|
1144 |
#套件指定的css樣式
|
|
|
1145 |
$conf["table"]["start"]["class"]=$conf["tableStartClass"];
|
|
|
1146 |
|
|
|
1147 |
}#else end
|
|
|
1148 |
|
|
|
1149 |
#函式說明:
|
|
|
1150 |
#表格開始,可以設定表格的厚度和位置
|
|
|
1151 |
#回傳結果:
|
|
|
1152 |
#$result,表格開始的語法
|
|
|
1153 |
#必填參數:
|
|
|
1154 |
#$conf["table"]["start"]["class"]="";#爲表格的css樣式
|
|
|
1155 |
$tableStart=table::start($conf["table"]["start"]);
|
|
|
1156 |
unset($conf["table"]["start"]);
|
|
|
1157 |
|
|
|
1158 |
#如果表格開始失敗
|
|
|
1159 |
if($tableStart["status"]=="false"){
|
|
|
1160 |
|
|
|
1161 |
#設置執行錯誤
|
|
|
1162 |
$result["error"]=$tableStart;
|
|
|
1163 |
|
|
|
1164 |
#設置執行失敗
|
|
|
1165 |
$result["status"]="false";
|
|
|
1166 |
|
|
|
1167 |
#回傳錯誤訊息
|
|
|
1168 |
return $result;
|
|
|
1169 |
|
|
|
1170 |
}#if end
|
|
|
1171 |
|
|
|
1172 |
#串接表格開始
|
|
|
1173 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
1174 |
|
|
|
1175 |
}#if end
|
|
|
1176 |
|
|
|
1177 |
}#if end
|
|
|
1178 |
|
|
|
1179 |
#函式說明:
|
|
|
1180 |
#列開始
|
|
|
1181 |
#回傳結果:
|
|
|
1182 |
#$result,列開始的語法
|
|
|
1183 |
#必填參數:
|
|
|
1184 |
$conf["table::trStart"]["class"]=$conf["trClass"];#爲tr的css樣式,若為""則為不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1185 |
#可省略參數:
|
|
|
1186 |
|
|
|
1187 |
#如果 $conf["trTitle"] 有設定
|
|
|
1188 |
if(isset($conf["trTitle"])){
|
|
|
1189 |
|
|
|
1190 |
#設置提示字串的內容
|
|
|
1191 |
$conf["table::trStart"]["trTitle"]=$conf["trTitle"];#該列要有什麼的提示字串
|
|
|
1192 |
|
|
|
1193 |
}#if end
|
|
|
1194 |
|
|
|
1195 |
$trStart=table::trStart($conf["table::trStart"]);
|
|
|
1196 |
unset($conf["table::trStart"]);
|
|
|
1197 |
|
|
|
1198 |
#如果列開始失敗
|
|
|
1199 |
if($trStart["status"]=="false"){
|
|
|
1200 |
|
|
|
1201 |
#設置執行錯誤
|
|
|
1202 |
$result["error"]=$trStart;
|
|
|
1203 |
|
|
|
1204 |
#設置執行失敗
|
|
|
1205 |
$result["status"]="false";
|
|
|
1206 |
|
|
|
1207 |
#回傳錯誤訊息
|
|
|
1208 |
return $result;
|
|
|
1209 |
|
|
|
1210 |
}#if end
|
|
|
1211 |
|
|
|
1212 |
#串接列的開始
|
|
|
1213 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
1214 |
|
|
|
1215 |
#透過foreach來建立列裏面的內容
|
|
|
1216 |
foreach($conf["tdContent"] as $key => $value){
|
|
|
1217 |
|
|
|
1218 |
#函式說明:
|
|
|
1219 |
#行開始
|
|
|
1220 |
#必填參數:
|
|
|
1221 |
$conf_tdStart["class"]=$conf["tdClass"];#該 td 要套用套用的 css 樣式
|
|
|
1222 |
$tdStart=table::tdStart($conf_tdStart);
|
|
|
1223 |
unset($conf_tdStart);
|
|
|
1224 |
|
|
|
1225 |
#如果欄開始失敗
|
|
|
1226 |
if($tdStart["status"]=="false"){
|
|
|
1227 |
|
|
|
1228 |
#設置執行錯誤
|
|
|
1229 |
$result["error"]=$tdStart;
|
|
|
1230 |
|
|
|
1231 |
#設置執行失敗
|
|
|
1232 |
$result["status"]="false";
|
|
|
1233 |
|
|
|
1234 |
#回傳錯誤訊息
|
|
|
1235 |
return $result;
|
|
|
1236 |
|
|
|
1237 |
}#if end
|
|
|
1238 |
|
|
|
1239 |
#串接欄開始
|
|
|
1240 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
1241 |
|
|
|
1242 |
#放置內容
|
|
|
1243 |
$result["content"]=$result["content"].$value;
|
|
|
1244 |
|
|
|
1245 |
#函式說明:
|
|
|
1246 |
#行結束
|
|
|
1247 |
$result["content"]=$result["content"].table::tdEnd();
|
|
|
1248 |
|
|
|
1249 |
}#foreach end
|
|
|
1250 |
|
|
|
1251 |
#函式說明:
|
|
|
1252 |
#列結束
|
|
|
1253 |
$result["content"]=$result["content"].table::trEnd();
|
|
|
1254 |
|
|
|
1255 |
#如果 $conf["tableEnd"] 存在
|
|
|
1256 |
if(isset($conf["tableEnd"])){
|
|
|
1257 |
|
|
|
1258 |
#如果 $conf["tableIEnd"] 等於 true
|
|
|
1259 |
if($conf["tableEnd"]=="true"){
|
|
|
1260 |
|
|
|
1261 |
#函式說明:
|
|
|
1262 |
#表格結束
|
|
|
1263 |
$result["content"]=$result["content"].table::end();
|
|
|
1264 |
|
|
|
1265 |
}#if end
|
|
|
1266 |
|
|
|
1267 |
}#if end
|
|
|
1268 |
|
|
|
1269 |
#如果 $conf["formEnd"] 有設置
|
|
|
1270 |
if(isset($conf["formEnd"])){
|
|
|
1271 |
|
|
|
1272 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
1273 |
if($conf["formEnd"]=="true"){
|
|
|
1274 |
|
|
|
1275 |
#設置表單結束
|
|
|
1276 |
#函式說明:
|
|
|
1277 |
#表單結束
|
|
|
1278 |
#回傳結果:
|
|
|
1279 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
1280 |
#$result["error"],錯誤訊息陣列.
|
|
|
1281 |
#$resutl["function"],當前執行的涵式名稱.
|
|
|
1282 |
#$result["content"],表單結束的語法.
|
|
|
1283 |
#必填參數:
|
|
|
1284 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
1285 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
1286 |
unset($conf["form"]["end"]);
|
|
|
1287 |
|
|
|
1288 |
#如果表單結束失敗
|
|
|
1289 |
if($formEnd["status"]=="false"){
|
|
|
1290 |
|
|
|
1291 |
#設置執行錯誤
|
|
|
1292 |
$result["error"]=$formEnd;
|
|
|
1293 |
|
|
|
1294 |
#設置執行失敗
|
|
|
1295 |
$result["status"]="false";
|
|
|
1296 |
|
|
|
1297 |
#回傳錯誤訊息
|
|
|
1298 |
return $result;
|
|
|
1299 |
|
|
|
1300 |
}#if end
|
|
|
1301 |
|
|
|
1302 |
#串接表單結束
|
|
|
1303 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
1304 |
|
|
|
1305 |
}#if end
|
|
|
1306 |
|
|
|
1307 |
}#if end
|
|
|
1308 |
|
|
|
1309 |
#執行到這邊代表執行成功
|
|
|
1310 |
$result["status"]="true";
|
|
|
1311 |
|
|
|
1312 |
#回傳結果
|
|
|
1313 |
return $result;
|
|
|
1314 |
|
|
|
1315 |
}#function printRow end
|
|
|
1316 |
|
|
|
1317 |
/*
|
|
|
1318 |
#函式說明:
|
|
|
1319 |
#建立欄的元素,以及指定裏面要放什麼內容
|
|
|
1320 |
#回傳結果:
|
|
|
1321 |
#$result["content"],建立欄元素的語法
|
|
|
1322 |
#$result["status"],"true"代表執行成功;"false"代表執行失敗。
|
|
|
1323 |
#$result["error"],錯誤訊息陣列
|
|
|
1324 |
#$result["function"],當前執行的函數名稱.
|
|
|
1325 |
#必填參數:
|
|
|
1326 |
#$conf["trClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式.
|
|
|
1327 |
$conf["tdClass"]="__withoutBorder";
|
|
|
1328 |
#$conf["tdContent"],字串陣列,列裏面要放的元素是?如果要空一列則可以輸array(" "),如果要放置表單元素,請用<p> </p>或<br> </br>來連接表單元素合成一個元素.
|
|
|
1329 |
$conf["tdContent"]=array();
|
|
|
1330 |
#可省略參數:
|
|
|
1331 |
#$conf["formData"],字串,$conf["tdContent"]裡面要放的元素是否含有表單,"true"代表有,"false"代表沒有,預設為"false".
|
|
|
1332 |
#$conf["formData"]="false";
|
|
|
1333 |
#$conf["tableStartClass"],字串,列的樣式,預設為"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
1334 |
#$conf["tableStartClass"]="__withoutBorder";
|
|
|
1335 |
#$conf["tableStart"],字串,爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
1336 |
#$conf["tableStart"]="true";
|
|
|
1337 |
#$conf["tableEnd"],字串,爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
1338 |
#$conf["tableEnd"]="true";
|
|
|
1339 |
#$conf["formStart"],字串,是否要有表單的開始,預設為"false".
|
|
|
1340 |
#$conf["formStart"]="true";
|
|
|
1341 |
#$conf["formName"],字串,該表單的名稱.
|
|
|
1342 |
#$conf["formName"]="";
|
|
|
1343 |
#$conf["formAction"],字串,表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置.
|
|
|
1344 |
#$conf["formAction"]="";
|
|
|
1345 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
1346 |
#$conf["formTarget"]="_self";
|
|
|
1347 |
#$conf["formEnd"],字串,是否要有表單的結束,預設為"false".
|
|
|
1348 |
#$conf["formEnd"]="true";
|
|
|
1349 |
#$conf["spaceBlockAferPerElement"],字串,是否每個欄元素(除了最後一個元素)後面都要空一列。"true"代表要空一列.預設是不空一列.
|
|
|
1350 |
#$conf["spaceBlockAferPerElement"]="true";
|
|
|
1351 |
#參考資料:
|
|
|
1352 |
#無.
|
|
|
1353 |
#備註:
|
|
|
1354 |
#無.
|
|
|
1355 |
*/
|
|
|
1356 |
public static function printColumn(&$conf){
|
|
|
1357 |
|
|
|
1358 |
#設置要回傳的變數
|
|
|
1359 |
$result=array();
|
|
|
1360 |
|
|
|
1361 |
#設置要回傳的語法
|
|
|
1362 |
$result["content"]="";
|
|
|
1363 |
|
|
|
1364 |
#取得當前執行的函數名稱
|
|
|
1365 |
$result["function"]=__FUNCTION__;
|
|
|
1366 |
|
|
|
1367 |
#如果 $conf 不為陣列
|
|
|
1368 |
if(gettype($conf)!="array"){
|
|
|
1369 |
|
|
|
1370 |
#設置執行失敗
|
|
|
1371 |
$result["status"]="false";
|
|
|
1372 |
|
|
|
1373 |
#設置執行錯誤訊息
|
|
|
1374 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1375 |
|
|
|
1376 |
#如果傳入的參數為 null
|
|
|
1377 |
if($conf==null){
|
|
|
1378 |
|
|
|
1379 |
#設置執行錯誤訊息
|
|
|
1380 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1381 |
|
|
|
1382 |
}#if end
|
|
|
1383 |
|
|
|
1384 |
#回傳結果
|
|
|
1385 |
return $result;
|
|
|
1386 |
|
|
|
1387 |
}#if end
|
|
|
1388 |
|
|
|
1389 |
#檢查參數
|
|
|
1390 |
#函式說明:
|
|
|
1391 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1392 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1393 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1394 |
#$result["function"],當前執行的函式名稱.
|
|
|
1395 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1396 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1397 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1398 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1399 |
#必填參數:
|
|
|
1400 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1401 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
1402 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1403 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("trClass","tdClass","tdContent");
|
|
|
1404 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1405 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array");
|
|
|
1406 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1407 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
1408 |
#可省略參數:
|
|
|
1409 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
1410 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
1411 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1412 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array(
|
|
|
1413 |
"tableStartClass",
|
|
|
1414 |
"tableStart",
|
|
|
1415 |
"tableEnd",
|
|
|
1416 |
"formStart",
|
|
|
1417 |
"formName",
|
|
|
1418 |
"formAction",
|
|
|
1419 |
"formTarget",
|
|
|
1420 |
"formEnd",
|
|
|
1421 |
"spaceBlockAferPerElement",
|
|
|
1422 |
"formData"
|
|
|
1423 |
);
|
|
|
1424 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1425 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array(
|
|
|
1426 |
"string",
|
|
|
1427 |
"string",
|
|
|
1428 |
"string",
|
|
|
1429 |
"string",
|
|
|
1430 |
"string",
|
|
|
1431 |
"string",
|
|
|
1432 |
"string",
|
|
|
1433 |
"string",
|
|
|
1434 |
"string",
|
|
|
1435 |
"string");
|
|
|
1436 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1437 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(
|
|
|
1438 |
"__withoutBorder",
|
|
|
1439 |
"false",
|
|
|
1440 |
"false",
|
|
|
1441 |
"false",
|
|
|
1442 |
null,
|
|
|
1443 |
null,
|
|
|
1444 |
"_self",
|
|
|
1445 |
"false",
|
|
|
1446 |
"false",
|
|
|
1447 |
"false");
|
|
|
1448 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1449 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
|
|
|
1450 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1451 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1452 |
|
|
|
1453 |
#如果檢查失敗
|
|
|
1454 |
if($checkResult["status"]=="false"){
|
|
|
1455 |
|
|
|
1456 |
#設置執行失敗
|
|
|
1457 |
$result["status"]="false";
|
|
|
1458 |
|
|
|
1459 |
#設置執行錯誤
|
|
|
1460 |
$result["error"]=$checkResult;
|
|
|
1461 |
|
|
|
1462 |
#回傳結果
|
|
|
1463 |
return $result;
|
|
|
1464 |
|
|
|
1465 |
}#if end
|
|
|
1466 |
|
|
|
1467 |
#如果檢查不通過
|
|
|
1468 |
if($checkResult["passed"]=="false"){
|
|
|
1469 |
|
|
|
1470 |
#設置執行失敗
|
|
|
1471 |
$result["status"]="false";
|
|
|
1472 |
|
|
|
1473 |
#設置執行錯誤
|
|
|
1474 |
$result["error"]=$checkResult;
|
|
|
1475 |
|
|
|
1476 |
#回傳結果
|
|
|
1477 |
return $result;
|
|
|
1478 |
|
|
|
1479 |
}#if end
|
|
|
1480 |
|
|
|
1481 |
#如果要放置的欄元素內容含有表單資料
|
|
|
1482 |
if($conf["formData"]=="true"){
|
|
|
1483 |
|
|
|
1484 |
#把表格的表單開始與結束取消
|
|
|
1485 |
$conf["formStart"]="false";
|
|
|
1486 |
$conf["formEnd"]="false";
|
|
|
1487 |
|
|
|
1488 |
}#if end
|
|
|
1489 |
|
|
|
1490 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
1491 |
if($conf["formStart"]=="true"){
|
|
|
1492 |
|
|
|
1493 |
#函式說明:
|
|
|
1494 |
#表單開始
|
|
|
1495 |
#回傳結果:
|
|
|
1496 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
1497 |
#$result["error"],錯誤訊息陣列.
|
|
|
1498 |
#$resutl["function"],當前執行的涵式名稱.
|
|
|
1499 |
#$result["content"],表單開始的語法.
|
|
|
1500 |
#必填參數:
|
|
|
1501 |
$conf["form::start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
1502 |
#可省略參數:
|
|
|
1503 |
#$conf["legend"]="";#顯示表單的標題
|
|
|
1504 |
|
|
|
1505 |
#如果 $conf["formName"] 有設置
|
|
|
1506 |
if(isset($conf["formName"])){
|
|
|
1507 |
|
|
|
1508 |
$conf["form::start"]["name"]=$conf["formName"];#爲該表單的名稱,id也跟$conf["name"]一樣.
|
|
|
1509 |
|
|
|
1510 |
}#if end
|
|
|
1511 |
|
|
|
1512 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
1513 |
|
|
|
1514 |
#如果 $conf["formTarget"] 有設置
|
|
|
1515 |
if(isset($conf["formTarget"])){
|
|
|
1516 |
|
|
|
1517 |
$conf["form::start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
1518 |
|
|
|
1519 |
}#if end
|
|
|
1520 |
|
|
|
1521 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是,"false"為否,預設為"false".
|
|
|
1522 |
#$conf["tableClass"]="";#表格要套用的css樣式,預設爲"__withoutBorder"無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1523 |
#$conf["showFieldsetBorder"]="false";#是否要顯示表單區域的框線,預設為"false"不顯示,"true"代表要顯示.
|
|
|
1524 |
#參考資料來源:
|
|
|
1525 |
#http://www.w3schools.com/html/html_forms.asp
|
|
|
1526 |
#http://www.w3schools.com/tags/tag_fieldset.asp
|
|
|
1527 |
$start=form::start($conf["form::start"]);
|
|
|
1528 |
unset($conf["form::start"]);
|
|
|
1529 |
|
|
|
1530 |
#如果表單開始失敗
|
|
|
1531 |
if($start["status"]=="false"){
|
|
|
1532 |
|
|
|
1533 |
#設置錯誤訊息
|
|
|
1534 |
$result["status"]="false";
|
|
|
1535 |
|
|
|
1536 |
#設置錯誤提示
|
|
|
1537 |
$result["error"]=$start;
|
|
|
1538 |
|
|
|
1539 |
#回傳結果
|
|
|
1540 |
return $result;
|
|
|
1541 |
|
|
|
1542 |
}#if end
|
|
|
1543 |
|
|
|
1544 |
#串接表單開始的語法
|
|
|
1545 |
$result["content"]=$result["content"].$start["content"];
|
|
|
1546 |
|
|
|
1547 |
}#if end
|
|
|
1548 |
|
|
|
1549 |
#如果 $conf["tableStart"] 為 "true"
|
|
|
1550 |
if($conf["tableStart"]=="true"){
|
|
|
1551 |
|
|
|
1552 |
#函式說明:
|
|
|
1553 |
#表格開始,可以設定表格的厚度和位置
|
|
|
1554 |
#回傳結果:
|
|
|
1555 |
#$result,表格開始的語法
|
|
|
1556 |
#必填參數:
|
|
|
1557 |
$conf["table"]["start"]["class"]=$conf["tableStartClass"];#爲表格的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1558 |
$tableStart=table::start($conf["table"]["start"]);
|
|
|
1559 |
unset($conf["table"]);
|
|
|
1560 |
|
|
|
1561 |
#如果表格建立失敗
|
|
|
1562 |
if($tableStart["status"]=="false"){
|
|
|
1563 |
|
|
|
1564 |
#設置錯誤訊息
|
|
|
1565 |
$result["status"]="false";
|
|
|
1566 |
|
|
|
1567 |
#設置錯誤提示
|
|
|
1568 |
$result["error"]=$tableStart;
|
|
|
1569 |
|
|
|
1570 |
#回傳結果
|
|
|
1571 |
return $result;
|
|
|
1572 |
|
|
|
1573 |
}#if end
|
|
|
1574 |
|
|
|
1575 |
#串接表格開始
|
|
|
1576 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
1577 |
|
|
|
1578 |
}#if end
|
|
|
1579 |
|
|
|
1580 |
#如果 $conf["spaceBlockAferPerElement"] 等於 "true"
|
|
|
1581 |
if($conf["spaceBlockAferPerElement"]=="true"){
|
|
|
1582 |
|
|
|
1583 |
#函式說明:
|
|
|
1584 |
#將一陣列每個元素間插入一個特定的元素
|
|
|
1585 |
#回傳結果:
|
|
|
1586 |
#$result["status"],執行是否成功,"true"為執行成功;"false"為執行失敗
|
|
|
1587 |
#$result["error"],錯誤訊息陣列.
|
|
|
1588 |
#$result["content"],插入完元素的新陣列.
|
|
|
1589 |
#必填的參數:
|
|
|
1590 |
#$conf["inputArray"],字串變數,要處理的陣列變數.
|
|
|
1591 |
$conf["arrays"]["insertElementBetweenElements"]["inputArray"]=$conf["tdContent"];
|
|
|
1592 |
#$conf["insertElement"],字串,要加入的元素.
|
|
|
1593 |
$conf["arrays"]["insertElementBetweenElements"]["insertElement"]=" ";
|
|
|
1594 |
#可省略參數:
|
|
|
1595 |
#無
|
|
|
1596 |
$newArray=arrays::insertElementBetweenElements($conf["arrays"]["insertElementBetweenElements"]);
|
|
|
1597 |
unset($conf["arrays"]["insertElementBetweenElements"]);
|
|
|
1598 |
|
|
|
1599 |
#如果 $newArray["status"] 等於 "false"
|
|
|
1600 |
if($newArray["status"]=="false"){
|
|
|
1601 |
|
|
|
1602 |
#設置錯誤訊息
|
|
|
1603 |
$result["status"]="false";
|
|
|
1604 |
|
|
|
1605 |
#設置錯誤提示
|
|
|
1606 |
$result["error"]=$newArray;
|
|
|
1607 |
|
|
|
1608 |
#回傳結果
|
|
|
1609 |
return $result;
|
|
|
1610 |
|
|
|
1611 |
}#if end
|
|
|
1612 |
|
|
|
1613 |
#置換原始的 $conf["spaceBlockAferPerElement"] 陣列
|
|
|
1614 |
$conf["tdContent"]=$newArray["content"];
|
|
|
1615 |
|
|
|
1616 |
}#if end
|
|
|
1617 |
|
|
|
1618 |
#函式說明:
|
|
|
1619 |
#列開始
|
|
|
1620 |
#回傳結果:
|
|
|
1621 |
#$result,列開始的語法
|
|
|
1622 |
#必填參數:
|
|
|
1623 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1624 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
1625 |
unset($conf["table"]["trStart"]);
|
|
|
1626 |
|
|
|
1627 |
#如果列開始失敗
|
|
|
1628 |
if($trStart["status"]=="false"){
|
|
|
1629 |
|
|
|
1630 |
#設置錯誤訊息
|
|
|
1631 |
$result["status"]="false";
|
|
|
1632 |
|
|
|
1633 |
#設置錯誤提示
|
|
|
1634 |
$result["error"]=$trStart;
|
|
|
1635 |
|
|
|
1636 |
#回傳結果
|
|
|
1637 |
return $result;
|
|
|
1638 |
|
|
|
1639 |
}#if end
|
|
|
1640 |
|
|
|
1641 |
#串接列開始
|
|
|
1642 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
1643 |
|
|
|
1644 |
#函式說明:
|
|
|
1645 |
#行開始
|
|
|
1646 |
#回傳結果:
|
|
|
1647 |
#$result,行開始的語法
|
|
|
1648 |
#必填參數:
|
|
|
1649 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];#該 td 要套用套用的 css 樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1650 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
1651 |
unset($conf["table"]["tdStart"]);
|
|
|
1652 |
|
|
|
1653 |
#如果欄位的開始失敗
|
|
|
1654 |
if($tdStart["status"]=="false"){
|
|
|
1655 |
|
|
|
1656 |
#設置錯誤訊息
|
|
|
1657 |
$result["status"]="false";
|
|
|
1658 |
|
|
|
1659 |
#設置錯誤提示
|
|
|
1660 |
$result["error"]=$tdStart;
|
|
|
1661 |
|
|
|
1662 |
#回傳結果
|
|
|
1663 |
return $result;
|
|
|
1664 |
|
|
|
1665 |
}#if end
|
|
|
1666 |
|
|
|
1667 |
#傳接欄位的開始
|
|
|
1668 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
1669 |
|
|
|
1670 |
#針對欄上的每個數值
|
|
|
1671 |
for($i=0;$i<count($conf["tdContent"]);$i++){
|
|
|
1672 |
|
|
|
1673 |
#串接欄位的內容
|
|
|
1674 |
$result["content"]=$result["content"].$conf["tdContent"][$i];
|
|
|
1675 |
|
|
|
1676 |
#如果不是最後一個元素
|
|
|
1677 |
if($i!=count($conf["tdContent"])-1){
|
|
|
1678 |
|
|
|
1679 |
#加上跳列
|
|
|
1680 |
$result["content"]=$result["content"]."<br>";
|
|
|
1681 |
|
|
|
1682 |
}#if end
|
|
|
1683 |
|
|
|
1684 |
}#foreach end
|
|
|
1685 |
|
|
|
1686 |
#函式說明:
|
|
|
1687 |
#欄位的結束
|
|
|
1688 |
#回傳結果:
|
|
|
1689 |
#$result,行結束的語法
|
|
|
1690 |
$result["content"]=$result["content"].table::tdEnd();
|
|
|
1691 |
|
|
|
1692 |
#函式說明:
|
|
|
1693 |
#列結束
|
|
|
1694 |
#回傳結果:
|
|
|
1695 |
#$result,列結束的語法
|
|
|
1696 |
$result["content"]=$result["content"].table::trEnd();
|
|
|
1697 |
|
|
|
1698 |
#如果有設定表格結束
|
|
|
1699 |
if(isset($conf["tableEnd"])){
|
|
|
1700 |
|
|
|
1701 |
#如果 $conf["tableEnd"] 為 "true"
|
|
|
1702 |
if($conf["tableEnd"]=="true"){
|
|
|
1703 |
|
|
|
1704 |
#函式說明:
|
|
|
1705 |
#表格結束
|
|
|
1706 |
#回傳結果:
|
|
|
1707 |
#表格結束的語法
|
|
|
1708 |
$result["content"]=$result["content"].table::end();
|
|
|
1709 |
|
|
|
1710 |
}#if end
|
|
|
1711 |
|
|
|
1712 |
}#if end
|
|
|
1713 |
|
|
|
1714 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
1715 |
if($conf["formEnd"]=="true" ){
|
|
|
1716 |
|
|
|
1717 |
#函式說明:
|
|
|
1718 |
#表單結束
|
|
|
1719 |
#回傳結果:
|
|
|
1720 |
#$result,表單結束的語法
|
|
|
1721 |
#必填參數:
|
|
|
1722 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
1723 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
1724 |
unset($conf["form"]["end"]);
|
|
|
1725 |
|
|
|
1726 |
#如果表單結束失敗
|
|
|
1727 |
if($formEnd["status"]=="false"){
|
|
|
1728 |
|
|
|
1729 |
#設置錯誤訊息
|
|
|
1730 |
$result["status"]="false";
|
|
|
1731 |
|
|
|
1732 |
#設置錯誤提示
|
|
|
1733 |
$result["error"]=$formEnd;
|
|
|
1734 |
|
|
|
1735 |
#回傳結果
|
|
|
1736 |
return $result;
|
|
|
1737 |
|
|
|
1738 |
}#if end
|
|
|
1739 |
|
|
|
1740 |
#串接表單結束
|
|
|
1741 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
1742 |
|
|
|
1743 |
}#if end
|
|
|
1744 |
|
|
|
1745 |
#設置執行成功訊息
|
|
|
1746 |
$result["status"]="true";
|
|
|
1747 |
|
|
|
1748 |
#回傳結果
|
|
|
1749 |
return $result;
|
|
|
1750 |
|
|
|
1751 |
}#function printColumn end
|
|
|
1752 |
|
|
|
1753 |
/*
|
|
|
1754 |
#函式說明:
|
|
|
1755 |
#表格形式的空一列
|
|
|
1756 |
#回傳結果:
|
|
|
1757 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
1758 |
#$result["error"],錯誤訊息陣列.
|
|
|
1759 |
#$result["function"],當前執行的函數名稱.
|
|
|
1760 |
#$result["content"],表格形式空一列的語法.
|
|
|
1761 |
#必填參數:
|
|
|
1762 |
#$conf["default"],字串,是否採用預設值,"true"爲是;"false"爲否.
|
|
|
1763 |
$conf["default"]="true";
|
|
|
1764 |
#可省略參數:
|
|
|
1765 |
#$conf["bgcolor"],字串,該空一列的空間底色要用設麼顏色,預設是不指定。如果該涵式是介於<table>與</table>之間,則其設定才會生效。
|
|
|
1766 |
#$conf["bgcolor"]="whilte";
|
|
|
1767 |
#$conf["tableStart"],字串,爲是否要表格開始,"true"表示"是".
|
|
|
1768 |
#$conf["tableStart"]="true";
|
|
|
1769 |
#$conf["tableClass"],字串,爲tr的css樣式類別名稱,預設為"__spaceTrTdRowDefauleTableCssStyle".
|
|
|
1770 |
#$conf["tableClass"]="true";
|
|
|
1771 |
#$conf["tableEnd"],字串,爲是否要表格結束,"true"表示"是".
|
|
|
1772 |
#$conf["tableEnd"]="true";
|
|
|
1773 |
#參考資料:
|
|
|
1774 |
#無.
|
|
|
1775 |
#備註:
|
|
|
1776 |
#無.
|
|
|
1777 |
*/
|
|
|
1778 |
public static function spaceTrTdRow(&$conf){
|
|
|
1779 |
|
|
|
1780 |
#設置要回傳的變數
|
|
|
1781 |
$result=array();
|
|
|
1782 |
|
|
|
1783 |
#設置要回傳的語法
|
|
|
1784 |
$result["content"]="";
|
|
|
1785 |
|
|
|
1786 |
#取得當前執行的函數名稱
|
|
|
1787 |
$result["function"]=__FUNCTION__;
|
|
|
1788 |
|
|
|
1789 |
#如果 $conf 不為陣列
|
|
|
1790 |
if(gettype($conf)!="array"){
|
|
|
1791 |
|
|
|
1792 |
#設置執行失敗
|
|
|
1793 |
$result["status"]="false";
|
|
|
1794 |
|
|
|
1795 |
#設置執行錯誤訊息
|
|
|
1796 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1797 |
|
|
|
1798 |
#如果傳入的參數為 null
|
|
|
1799 |
if($conf==null){
|
|
|
1800 |
|
|
|
1801 |
#設置執行錯誤訊息
|
|
|
1802 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1803 |
|
|
|
1804 |
}#if end
|
|
|
1805 |
|
|
|
1806 |
#回傳結果
|
|
|
1807 |
return $result;
|
|
|
1808 |
|
|
|
1809 |
}#if end
|
|
|
1810 |
|
|
|
1811 |
#檢查參數
|
|
|
1812 |
#函式說明:
|
|
|
1813 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1814 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1815 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1816 |
#$result["function"],當前執行的函式名稱.
|
|
|
1817 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1818 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1819 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1820 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1821 |
#必填參數:
|
|
|
1822 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1823 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
1824 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1825 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("default");
|
|
|
1826 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1827 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
1828 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1829 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
1830 |
#可省略參數:
|
|
|
1831 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
1832 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
1833 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1834 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("bgcolor","tableStart","tableClass","tableEnd");
|
|
|
1835 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1836 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
|
|
|
1837 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1838 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"__spaceTrTdRowDefauleTableCssStyle",null);
|
|
|
1839 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1840 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
|
|
|
1841 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1842 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1843 |
|
|
|
1844 |
#如果檢查失敗
|
|
|
1845 |
if($checkResult["status"]=="false"){
|
|
|
1846 |
|
|
|
1847 |
#設置執行失敗
|
|
|
1848 |
$result["status"]="false";
|
|
|
1849 |
|
|
|
1850 |
#設置執行錯誤
|
|
|
1851 |
$result["error"]=$checkResult;
|
|
|
1852 |
|
|
|
1853 |
#回傳結果
|
|
|
1854 |
return $result;
|
|
|
1855 |
|
|
|
1856 |
}#if end
|
|
|
1857 |
|
|
|
1858 |
#如果檢查不通過
|
|
|
1859 |
if($checkResult["passed"]=="false"){
|
|
|
1860 |
|
|
|
1861 |
#設置執行失敗
|
|
|
1862 |
$result["status"]="false";
|
|
|
1863 |
|
|
|
1864 |
#設置執行錯誤
|
|
|
1865 |
$result["error"]=$checkResult;
|
|
|
1866 |
|
|
|
1867 |
#回傳結果
|
|
|
1868 |
return $result;
|
|
|
1869 |
|
|
|
1870 |
}#if end
|
|
|
1871 |
|
|
|
1872 |
#建立預設的表格css樣式
|
|
|
1873 |
#函式說明:
|
|
|
1874 |
#創建 css 樣式
|
|
|
1875 |
#必填參數:
|
|
|
1876 |
$conf_createCssStyle["cssStyleName"]="__spaceTrTdRowDefauleTableCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
1877 |
$conf_createCssStyle["attributes"]=array("word-break","table-layout","margin-left","margin-right","border","border-width");#為屬性名稱,須為陣列值
|
|
|
1878 |
$conf_createCssStyle["content"]=array("break-all","fixed","auto","auto","0px","100%");#為屬性值,須為陣列值
|
|
|
1879 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
1880 |
unset($conf_createCssStyle);
|
|
|
1881 |
|
|
|
1882 |
#串接css樣式
|
|
|
1883 |
$result["content"]=$result["content"].$css["content"];
|
|
|
1884 |
|
|
|
1885 |
#判斷變數 $conf["default"]
|
|
|
1886 |
switch($conf["default"]){
|
|
|
1887 |
|
|
|
1888 |
#如果其值爲 true
|
|
|
1889 |
case "true":
|
|
|
1890 |
|
|
|
1891 |
#空一列
|
|
|
1892 |
$result["content"]=$result["content"]."<tr><td> </td></tr>";
|
|
|
1893 |
|
|
|
1894 |
#結束
|
|
|
1895 |
break;
|
|
|
1896 |
|
|
|
1897 |
#如果其值爲 false
|
|
|
1898 |
case "false":
|
|
|
1899 |
|
|
|
1900 |
#如果 $conf["tableStart"] 存在
|
|
|
1901 |
if(isset($conf["tableStart"])){
|
|
|
1902 |
|
|
|
1903 |
#如果 $conf["tableStart"] 爲 "true"
|
|
|
1904 |
if($conf["tableStart"]=="true"){
|
|
|
1905 |
|
|
|
1906 |
#如果 $conf["tableClass"] 存在
|
|
|
1907 |
if(isset($conf["tableClass"])){
|
|
|
1908 |
|
|
|
1909 |
#則設定其要套用的css樣式
|
|
|
1910 |
$conf_tableStart["class"]=$conf["tableClass"];
|
|
|
1911 |
|
|
|
1912 |
}#if end
|
|
|
1913 |
|
|
|
1914 |
#回傳結果:
|
|
|
1915 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1916 |
#$result["content"],表格開始的語法
|
|
|
1917 |
#$result["function"],當前執行的函數
|
|
|
1918 |
#$result["error"],涵式錯誤訊息
|
|
|
1919 |
#必填參數:
|
|
|
1920 |
#$conf["class"]="";#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
1921 |
$result["content"]=$result["content"].table::start($conf_tableStart)["content"];
|
|
|
1922 |
unset($conf_tableStart);
|
|
|
1923 |
|
|
|
1924 |
}#if end
|
|
|
1925 |
|
|
|
1926 |
}#if end
|
|
|
1927 |
|
|
|
1928 |
#如果有設定背景顏色
|
|
|
1929 |
if(isset($conf["bgcolor"])){
|
|
|
1930 |
|
|
|
1931 |
#套用顏色設定值
|
|
|
1932 |
$bgColor="bgcolor=".$conf["bgcolor"];
|
|
|
1933 |
|
|
|
1934 |
}#if end
|
|
|
1935 |
|
|
|
1936 |
#如果沒有設定背景顏色
|
|
|
1937 |
else{
|
|
|
1938 |
|
|
|
1939 |
#將其設定值設爲空
|
|
|
1940 |
$bgColor="";
|
|
|
1941 |
|
|
|
1942 |
}#else end
|
|
|
1943 |
|
|
|
1944 |
#空一列
|
|
|
1945 |
$result["content"]=$result["content"]."<tr><td ".$bgColor." > </td></tr>";
|
|
|
1946 |
|
|
|
1947 |
#如果 $conf["tableEnd"] 存在
|
|
|
1948 |
if(isset($conf["tableEnd"])){
|
|
|
1949 |
|
|
|
1950 |
#如果 $conf["tableEnd"] 爲 "true"
|
|
|
1951 |
if($conf["tableEnd"]=="true"){
|
|
|
1952 |
|
|
|
1953 |
#放置表格的結尾
|
|
|
1954 |
$result["content"]=$result["content"].table::end();
|
|
|
1955 |
|
|
|
1956 |
}#if end
|
|
|
1957 |
|
|
|
1958 |
}#if end
|
|
|
1959 |
|
|
|
1960 |
#結束
|
|
|
1961 |
break;
|
|
|
1962 |
|
|
|
1963 |
}#switch end
|
|
|
1964 |
|
|
|
1965 |
#設置執行正常
|
|
|
1966 |
$result["status"]="true";
|
|
|
1967 |
|
|
|
1968 |
#回傳結果
|
|
|
1969 |
return $result;
|
|
|
1970 |
|
|
|
1971 |
}#function end
|
|
|
1972 |
|
|
|
1973 |
/*
|
|
|
1974 |
#函式說明:
|
|
|
1975 |
#表格形式的文字描述:
|
|
|
1976 |
#回傳結果:
|
|
|
1977 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
1978 |
#$result["error"],涵式錯誤訊息陣列.
|
|
|
1979 |
#$result["content"],表格形式文字描述的語法.
|
|
|
1980 |
#$result["function"],當前執行的函式名稱.
|
|
|
1981 |
#必填參數:
|
|
|
1982 |
#$conf["outputString"],字串,要印出來的文字.
|
|
|
1983 |
$conf["outputString"]="";
|
|
|
1984 |
#可省略參數:
|
|
|
1985 |
#$conf["tableStart"],字串,是否要表格開始<table>,"true"代表是.
|
|
|
1986 |
#$conf["tableStart"]="true";
|
|
|
1987 |
#$conf["tableClass"],字串,為表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder"
|
|
|
1988 |
#$conf["tableClass"]="__withoutBorder";
|
|
|
1989 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始.
|
|
|
1990 |
#$conf["trStart"]="true";
|
|
|
1991 |
#$conf["trClass"],字串,爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder"
|
|
|
1992 |
#$conf["trClass"]="__withoutBorder";
|
|
|
1993 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始.
|
|
|
1994 |
#$conf["tdStart"]="true";
|
|
|
1995 |
#$conf["tdClass"],字串,該 td 要套用套用的 css 樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder"
|
|
|
1996 |
#$conf["tdClass"]="__withoutBorder";
|
|
|
1997 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是".也可以看成列裏面的元素結束.
|
|
|
1998 |
#$conf["tdEnd"]="true";
|
|
|
1999 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束.
|
|
|
2000 |
#$conf["trEnd"]="true";
|
|
|
2001 |
#$conf["tableEnd"],字串,是否要表格結束</table>,"true"代表是.
|
|
|
2002 |
#$conf["tableEnd"]="true";
|
|
|
2003 |
#參考資料:
|
|
|
2004 |
#無.
|
|
|
2005 |
#備註:
|
|
|
2006 |
#無.
|
|
|
2007 |
*/
|
|
|
2008 |
public static function text(&$conf){
|
|
|
2009 |
|
|
|
2010 |
#初始化要回傳的內容
|
|
|
2011 |
$result=array();
|
|
|
2012 |
|
|
|
2013 |
#設置當前執行的函數
|
|
|
2014 |
$result["function"]=__FUNCTION__;
|
|
|
2015 |
|
|
|
2016 |
#初始化表格開始的語法
|
|
|
2017 |
$result["content"]="";
|
|
|
2018 |
|
|
|
2019 |
#如果 $conf 不為陣列
|
|
|
2020 |
if(gettype($conf)!="array"){
|
|
|
2021 |
|
|
|
2022 |
#設置執行失敗
|
|
|
2023 |
$result["status"]="false";
|
|
|
2024 |
|
|
|
2025 |
#設置執行錯誤訊息
|
|
|
2026 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2027 |
|
|
|
2028 |
#如果傳入的參數為 null
|
|
|
2029 |
if($conf==null){
|
|
|
2030 |
|
|
|
2031 |
#設置執行錯誤訊息
|
|
|
2032 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
2033 |
|
|
|
2034 |
}#if end
|
|
|
2035 |
|
|
|
2036 |
#回傳結果
|
|
|
2037 |
return $result;
|
|
|
2038 |
|
|
|
2039 |
}#if end
|
|
|
2040 |
|
|
|
2041 |
#檢查參數
|
|
|
2042 |
#函式說明:
|
|
|
2043 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
2044 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2045 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
2046 |
#$result["function"],當前執行的函式名稱.
|
|
|
2047 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
2048 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
2049 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
2050 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
2051 |
#必填參數:
|
|
|
2052 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
2053 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
2054 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
2055 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("outputString");
|
|
|
2056 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
2057 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
2058 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
2059 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
2060 |
#可省略參數:
|
|
|
2061 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
2062 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
2063 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
2064 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("tableStart","tableClass","trStart","trClass","tdStart","tdClass","tdEnd","trEnd","tableEnd");
|
|
|
2065 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
2066 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string");
|
|
|
2067 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
2068 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("false","__withoutBorder","false","__withoutBorder","false","__withoutBorder","false","false","false");
|
|
|
2069 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
2070 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
2071 |
|
|
|
2072 |
#如果檢查失敗
|
|
|
2073 |
if($checkResult["status"]=="false"){
|
|
|
2074 |
|
|
|
2075 |
#設置執行不正常
|
|
|
2076 |
$result["status"]="false";
|
|
|
2077 |
|
|
|
2078 |
#程式停止執行
|
|
|
2079 |
$result["error"]=$checkResult;
|
|
|
2080 |
|
|
|
2081 |
#回傳結果
|
|
|
2082 |
return $result;
|
|
|
2083 |
|
|
|
2084 |
}#if end
|
|
|
2085 |
|
|
|
2086 |
#如果檢查不通過
|
|
|
2087 |
if($checkResult["passed"]=="false"){
|
|
|
2088 |
|
|
|
2089 |
#設置執行不正常
|
|
|
2090 |
$result["status"]="false";
|
|
|
2091 |
|
|
|
2092 |
#程式停止執行
|
|
|
2093 |
$result["error"]=$checkResult;
|
|
|
2094 |
|
|
|
2095 |
#回傳結果
|
|
|
2096 |
return $result;
|
|
|
2097 |
|
|
|
2098 |
}#if end
|
|
|
2099 |
|
|
|
2100 |
#如果 $conf["tableStart"] 為 "true"
|
|
|
2101 |
if($conf["tableStart"]=="true"){
|
|
|
2102 |
|
|
|
2103 |
#函式說明:
|
|
|
2104 |
#表格開始,可以設定表格的厚度和位置
|
|
|
2105 |
#回傳結果:
|
|
|
2106 |
#$result,表格開始的語法
|
|
|
2107 |
#必填參數:
|
|
|
2108 |
#套用樣式
|
|
|
2109 |
$conf["table"]["start"]["class"]=$conf["tableClass"];#爲表格的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2110 |
$tableStart=table::start($conf["table"]["start"]);
|
|
|
2111 |
unset($conf["table"]);
|
|
|
2112 |
|
|
|
2113 |
#如果表格開始失敗
|
|
|
2114 |
if($tableStart["status"]=="false"){
|
|
|
2115 |
|
|
|
2116 |
#設置執行不正常
|
|
|
2117 |
$result["status"]="false";
|
|
|
2118 |
|
|
|
2119 |
#程式停止執行
|
|
|
2120 |
$result["error"]=$tableStart;
|
|
|
2121 |
|
|
|
2122 |
#回傳結果
|
|
|
2123 |
return $result;
|
|
|
2124 |
|
|
|
2125 |
}#if end
|
|
|
2126 |
|
|
|
2127 |
#串接表格開始的語法
|
|
|
2128 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
2129 |
|
|
|
2130 |
}#if end
|
|
|
2131 |
|
|
|
2132 |
#如果 $conf["trStart"] 爲 "true"
|
|
|
2133 |
if($conf["trStart"]=="true"){
|
|
|
2134 |
|
|
|
2135 |
#函式說明:
|
|
|
2136 |
#列開始
|
|
|
2137 |
#回傳結果:
|
|
|
2138 |
#$result,列開始的語法
|
|
|
2139 |
#必填參數:
|
|
|
2140 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2141 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
2142 |
unset($conf["table"]);
|
|
|
2143 |
|
|
|
2144 |
#如果列開始失敗
|
|
|
2145 |
if($trStart["status"]=="false"){
|
|
|
2146 |
|
|
|
2147 |
#設置執行不正常
|
|
|
2148 |
$result["status"]="false";
|
|
|
2149 |
|
|
|
2150 |
#程式停止執行
|
|
|
2151 |
$result["error"]=$trStart;
|
|
|
2152 |
|
|
|
2153 |
#回傳結果
|
|
|
2154 |
return $result;
|
|
|
2155 |
|
|
|
2156 |
}#if end
|
|
|
2157 |
|
|
|
2158 |
#串接列開始
|
|
|
2159 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
2160 |
|
|
|
2161 |
}#if end
|
|
|
2162 |
|
|
|
2163 |
#如果 $conf["tdStart"] 爲 "true"
|
|
|
2164 |
if($conf["tdStart"]=="true"){
|
|
|
2165 |
|
|
|
2166 |
#函式說明:
|
|
|
2167 |
#行開始
|
|
|
2168 |
#回傳結果:
|
|
|
2169 |
#$result,列開始的語法
|
|
|
2170 |
#必填參數:
|
|
|
2171 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2172 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
2173 |
unset($conf["table"]["tdStart"]);
|
|
|
2174 |
|
|
|
2175 |
#如果欄開始失敗
|
|
|
2176 |
if($tdStart["status"]=="false"){
|
|
|
2177 |
|
|
|
2178 |
#設置執行不正常
|
|
|
2179 |
$result["status"]="false";
|
|
|
2180 |
|
|
|
2181 |
#程式停止執行
|
|
|
2182 |
$result["error"]=$tdStart;
|
|
|
2183 |
|
|
|
2184 |
#回傳結果
|
|
|
2185 |
return $result;
|
|
|
2186 |
|
|
|
2187 |
}#if end
|
|
|
2188 |
|
|
|
2189 |
#串接欄
|
|
|
2190 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
2191 |
|
|
|
2192 |
}#if end
|
|
|
2193 |
|
|
|
2194 |
#串接提示文字
|
|
|
2195 |
$result["content"]=$result["content"].$conf["outputString"];
|
|
|
2196 |
|
|
|
2197 |
#如果其值爲 true
|
|
|
2198 |
if($conf["tdEnd"]=="true"){
|
|
|
2199 |
|
|
|
2200 |
#串接欄結束
|
|
|
2201 |
$result["content"]=$result["content"]."</td>";
|
|
|
2202 |
|
|
|
2203 |
}#if end
|
|
|
2204 |
|
|
|
2205 |
#如果 $conf["trtdEnd"] 爲 "true"
|
|
|
2206 |
if($conf["trEnd"]=="true"){
|
|
|
2207 |
|
|
|
2208 |
#串接列結束
|
|
|
2209 |
$result["content"]=$result["content"]."</tr>";
|
|
|
2210 |
|
|
|
2211 |
}#if end
|
|
|
2212 |
|
|
|
2213 |
#如果 $conf["tableEnd"] 等於 "true"
|
|
|
2214 |
if($conf["tableEnd"]=="true"){
|
|
|
2215 |
|
|
|
2216 |
#設置表格結束的語法
|
|
|
2217 |
#函式說明:
|
|
|
2218 |
#表格結束
|
|
|
2219 |
#回傳結果:
|
|
|
2220 |
#表格結束的語法
|
|
|
2221 |
$result["content"]=$result["content"].table::end();
|
|
|
2222 |
|
|
|
2223 |
}#if end
|
|
|
2224 |
|
|
|
2225 |
#設置執行正常
|
|
|
2226 |
$result["status"]="true";
|
|
|
2227 |
|
|
|
2228 |
#回傳結果
|
|
|
2229 |
return $result;
|
|
|
2230 |
|
|
|
2231 |
}#function text end
|
|
|
2232 |
|
|
|
2233 |
/*
|
|
|
2234 |
#函式說明:
|
|
|
2235 |
#依據類別的名稱、裡面的函式存限制、函式名稱、函式參數、函式回傳型態來建立類別圖表格
|
|
|
2236 |
#回傳結果:
|
|
|
2237 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2238 |
#$result["error"],錯誤訊息.
|
|
|
2239 |
#$result["function"],當前執行的函數名稱.
|
|
|
2240 |
#$result["classDiagramTable"],類別圖的網頁code
|
|
|
2241 |
#必填參數:
|
|
|
2242 |
#$conf["className"],字串,類別的名稱.
|
|
|
2243 |
$conf["className"]="";
|
|
|
2244 |
#$conf["functionOpenAccessType"],字串陣列,函式存取的限制,每個元素代表一個函式的設定,"+"代表開放存取.
|
|
|
2245 |
#$conf["functionOpenAccessType"]=array();
|
|
|
2246 |
#$conf["functionName"],字串陣列,各函式的名稱,每個元素代表一個函式的名稱.
|
|
|
2247 |
#$conf["functionName"]=array();
|
|
|
2248 |
#$conf["functionArgv"],字串陣列,各函式的傳入參數型態,每個元素代表一個函式的入參數型態,""代表沒有傳入參數.
|
|
|
2249 |
#$conf["functionArgv"]=array();
|
|
|
2250 |
#$conf["functionReturnType"],字串陣列,各函式回傳的型態,每個元素代表一個函式回傳的型態,"void"代表沒有回傳變數.
|
|
|
2251 |
#$conf["functionReturnType"]=array();
|
|
|
2252 |
#可省略參數:
|
|
|
2253 |
#無.
|
|
|
2254 |
#參考資料:
|
|
|
2255 |
#無.
|
|
|
2256 |
#備註:
|
|
|
2257 |
#無.
|
|
|
2258 |
*/
|
|
|
2259 |
public static function classDiagramTable(&$conf){
|
|
|
2260 |
|
|
|
2261 |
#初始化要回傳的內容
|
|
|
2262 |
$result=array();
|
|
|
2263 |
|
|
|
2264 |
#取得當前函數的名稱
|
|
|
2265 |
$result["function"]=__FUNCTION__;
|
|
|
2266 |
|
|
|
2267 |
#如果 $conf 不為陣列
|
|
|
2268 |
if(gettype($conf)!="array"){
|
|
|
2269 |
|
|
|
2270 |
#設置執行失敗
|
|
|
2271 |
$result["status"]="false";
|
|
|
2272 |
|
|
|
2273 |
#設置執行錯誤訊息
|
|
|
2274 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2275 |
|
|
|
2276 |
#如果傳入的參數為 null
|
|
|
2277 |
if($conf==null){
|
|
|
2278 |
|
|
|
2279 |
#設置執行錯誤訊息
|
|
|
2280 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
2281 |
|
|
|
2282 |
}#if end
|
|
|
2283 |
|
|
|
2284 |
#回傳結果
|
|
|
2285 |
return $result;
|
|
|
2286 |
|
|
|
2287 |
}#if end
|
|
|
2288 |
|
|
|
2289 |
#初始化類別圖表格產生的html程式
|
|
|
2290 |
$result["classDiagramTable"]="";
|
|
|
2291 |
|
|
|
2292 |
#參數檢查
|
|
|
2293 |
#檢查參數
|
|
|
2294 |
#函式說明:
|
|
|
2295 |
#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
|
|
|
2296 |
#回傳結果:
|
|
|
2297 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
2298 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
2299 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
2300 |
#必填參數:
|
|
|
2301 |
$conf["variableCheck"]["isexistMuti"]["varInput"]=$conf;#要檢查的陣列變數
|
|
|
2302 |
$conf["variableCheck"]["isexistMuti"]["variableCheck"]=array("className","functionOpenAccessType","functionName","functionArgv","functionReturnType");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
|
|
|
2303 |
#可省略參數:
|
|
|
2304 |
$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","array","array","array","array");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
|
|
|
2305 |
$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="true";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
|
|
|
2306 |
$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
|
|
|
2307 |
unset($conf["variableCheck"]["isexistMuti"]);
|
|
|
2308 |
|
|
|
2309 |
#如果 $checkResult["status"] 為 "fasle"
|
|
|
2310 |
if($checkResult["status"]==="false"){
|
|
|
2311 |
|
|
|
2312 |
#設置執行錯誤的識別
|
|
|
2313 |
$result["status"]="false";
|
|
|
2314 |
|
|
|
2315 |
#設置執行錯誤的訊息
|
|
|
2316 |
$result["error"]=$checkResult;
|
|
|
2317 |
|
|
|
2318 |
#回傳結果
|
|
|
2319 |
return $result;
|
|
|
2320 |
|
|
|
2321 |
}#if end
|
|
|
2322 |
|
|
|
2323 |
#如果 $checkResult["passed"] 為 "fasle"
|
|
|
2324 |
if($checkResult["passed"]==="false"){
|
|
|
2325 |
|
|
|
2326 |
#設置執行錯誤的識別
|
|
|
2327 |
$result["status"]="false";
|
|
|
2328 |
|
|
|
2329 |
#設置執行錯誤的訊息
|
|
|
2330 |
$result["error"]=$checkResult;
|
|
|
2331 |
|
|
|
2332 |
#回傳結果
|
|
|
2333 |
return $result;
|
|
|
2334 |
|
|
|
2335 |
}#if end
|
|
|
2336 |
|
|
|
2337 |
#建立類別名圖表格的css樣式
|
|
|
2338 |
#函式說明:
|
|
|
2339 |
#創建 css 樣式
|
|
|
2340 |
#回傳結果:
|
|
|
2341 |
#$result["css"],css設定內容
|
|
|
2342 |
#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
2343 |
#必填參數:
|
|
|
2344 |
$conf["css"]["createCssStyle"]["cssStyleName"]="classDiagramClassNameCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
2345 |
$conf["css"]["createCssStyle"]["attributes"]=array("border","border-style","border-color","text-align");#為屬性名稱,須為陣列值
|
|
|
2346 |
$conf["css"]["createCssStyle"]["content"]=array("1px","solid","#000000","center");#為屬性值,須為陣列值
|
|
|
2347 |
$css=css::createCssStyle($conf["css"]["createCssStyle"]);
|
|
|
2348 |
unset($conf["css"]["createCssStyle"]);
|
|
|
2349 |
$result["classDiagramTable"]=$result["classDiagramTable"].$css["content"];
|
|
|
2350 |
|
|
|
2351 |
#建立類別名圖表格的css樣式
|
|
|
2352 |
#函式說明:
|
|
|
2353 |
#創建 css 樣式
|
|
|
2354 |
#回傳結果:
|
|
|
2355 |
#$result["css"],css設定內容
|
|
|
2356 |
#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
2357 |
#必填參數:
|
|
|
2358 |
$conf["css"]["createCssStyle"]["cssStyleName"]="classDiagramCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
2359 |
$conf["css"]["createCssStyle"]["attributes"]=array("border","border-style","border-color");#為屬性名稱,須為陣列值
|
|
|
2360 |
$conf["css"]["createCssStyle"]["content"]=array("1px","solid","#000000");#為屬性值,須為陣列值
|
|
|
2361 |
$css=css::createCssStyle($conf["css"]["createCssStyle"]);
|
|
|
2362 |
unset($conf["css"]["createCssStyle"]);
|
|
|
2363 |
$result["classDiagramTable"]=$result["classDiagramTable"].$css["content"];
|
|
|
2364 |
|
|
|
2365 |
#類別圖的表格開始
|
|
|
2366 |
#函式說明:
|
|
|
2367 |
#表格開始,可以設定表格的厚度和位置
|
|
|
2368 |
#回傳結果:
|
|
|
2369 |
#$result,表格開始的語法
|
|
|
2370 |
#必填參數:
|
|
|
2371 |
$conf["table"]["start"]["class"]="classDiagramCssStyle";#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2372 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::start($conf["table"]["start"])["content"];
|
|
|
2373 |
unset($conf["table"]["start"]);
|
|
|
2374 |
|
|
|
2375 |
#列的開始
|
|
|
2376 |
#函式說明:
|
|
|
2377 |
#列開始
|
|
|
2378 |
#回傳結果:
|
|
|
2379 |
#$result,列開始的語法
|
|
|
2380 |
#必填參數:
|
|
|
2381 |
$conf["table"]["trStart"]["class"]="classDiagramCssStyle";#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2382 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::trStart($conf["table"]["trStart"])["content"];
|
|
|
2383 |
unset($conf["table"]["trStart"]);
|
|
|
2384 |
|
|
|
2385 |
#欄開始的語法
|
|
|
2386 |
#函式說明:
|
|
|
2387 |
#行開始
|
|
|
2388 |
#回傳結果:
|
|
|
2389 |
#$result,行開始的語法
|
|
|
2390 |
#必填參數:
|
|
|
2391 |
$conf["table"]["tdStart"]["class"]="classDiagramClassNameCssStyle";#該 td 要套用套用的 css 樣式,若為""則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2392 |
#可省略參數:
|
|
|
2393 |
$conf["table"]["tdStart"]["colspan"]="2";#為欄位合併的數量
|
|
|
2394 |
#$conf["table"]["tdStart"]["rowspan"]="2";#為列合併的數量
|
|
|
2395 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdStart($conf["table"]["tdStart"])["content"];
|
|
|
2396 |
unset($conf["table"]["tdStart"]);
|
|
|
2397 |
|
|
|
2398 |
#放置類別名稱
|
|
|
2399 |
$result["classDiagramTable"]=$result["classDiagramTable"].$conf["className"];
|
|
|
2400 |
|
|
|
2401 |
#欄結束的語法
|
|
|
2402 |
#函式說明:
|
|
|
2403 |
#行結束
|
|
|
2404 |
#回傳結果:
|
|
|
2405 |
#$result,行結束的語法
|
|
|
2406 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdEnd();
|
|
|
2407 |
|
|
|
2408 |
#列結束的語法
|
|
|
2409 |
#函式說明:
|
|
|
2410 |
#列結束
|
|
|
2411 |
#回傳結果:
|
|
|
2412 |
#$result,列結束的語法
|
|
|
2413 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::trEnd();
|
|
|
2414 |
|
|
|
2415 |
#debug
|
|
|
2416 |
#var_dump($conf["functionName"]);
|
|
|
2417 |
#exit;
|
|
|
2418 |
|
|
|
2419 |
#針對每個函式
|
|
|
2420 |
for($i=0;$i<count($conf["functionName"]);$i++){
|
|
|
2421 |
|
|
|
2422 |
#列的開始
|
|
|
2423 |
#函式說明:
|
|
|
2424 |
#列開始
|
|
|
2425 |
#回傳結果:
|
|
|
2426 |
#$result,列開始的語法
|
|
|
2427 |
#必填參數:
|
|
|
2428 |
$conf["table"]["trStart"]["class"]="classDiagramCssStyle";#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2429 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::trStart($conf["table"]["trStart"])["content"];
|
|
|
2430 |
unset($conf["table"]["trStart"]);
|
|
|
2431 |
|
|
|
2432 |
#欄開始的語法
|
|
|
2433 |
#函式說明:
|
|
|
2434 |
#行開始
|
|
|
2435 |
#回傳結果:
|
|
|
2436 |
#$result,行開始的語法
|
|
|
2437 |
#必填參數:
|
|
|
2438 |
$conf["table"]["tdStart"]["class"]="classDiagramCssStyle";#該 td 要套用套用的 css 樣式,若為""則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2439 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdStart($conf["table"]["tdStart"])["content"];
|
|
|
2440 |
unset($conf["table"]["tdStart"]);
|
|
|
2441 |
|
|
|
2442 |
#若無指定 public or private
|
|
|
2443 |
if(!isset($conf["functionOpenAccessType"][$i])){
|
|
|
2444 |
|
|
|
2445 |
#預設為public
|
|
|
2446 |
$conf["functionOpenAccessType"][$i]="public";
|
|
|
2447 |
|
|
|
2448 |
}#if end
|
|
|
2449 |
|
|
|
2450 |
#如果存在
|
|
|
2451 |
if(isset($conf["functionOpenAccessType"][$i])){
|
|
|
2452 |
|
|
|
2453 |
#放置函式存取限制
|
|
|
2454 |
$result["classDiagramTable"]=$result["classDiagramTable"].$conf["functionOpenAccessType"][$i];
|
|
|
2455 |
|
|
|
2456 |
}#if end
|
|
|
2457 |
|
|
|
2458 |
#欄結束的語法
|
|
|
2459 |
#函式說明:
|
|
|
2460 |
#行結束
|
|
|
2461 |
#回傳結果:
|
|
|
2462 |
#$result,行結束的語法
|
|
|
2463 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdEnd();
|
|
|
2464 |
|
|
|
2465 |
#欄開始的語法
|
|
|
2466 |
#函式說明:
|
|
|
2467 |
#行開始
|
|
|
2468 |
#回傳結果:
|
|
|
2469 |
#$result,行開始的語法
|
|
|
2470 |
#必填參數:
|
|
|
2471 |
$conf["table"]["tdStart"]["class"]="classDiagramCssStyle";#該 td 要套用套用的 css 樣式,若為""則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2472 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdStart($conf["table"]["tdStart"])["content"];
|
|
|
2473 |
unset($conf["table"]["tdStart"]);
|
|
|
2474 |
|
|
|
2475 |
#放置函式名稱、參數型態、回傳型態
|
|
|
2476 |
$result["classDiagramTable"]=$result["classDiagramTable"].$conf["functionName"][$i]["content"]."(".$conf["functionArgv"][$i]."):".$conf["functionReturnType"][$i];
|
|
|
2477 |
|
|
|
2478 |
#欄結束的語法
|
|
|
2479 |
#函式說明:
|
|
|
2480 |
#行結束
|
|
|
2481 |
#回傳結果:
|
|
|
2482 |
#$result,行結束的語法
|
|
|
2483 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::tdEnd();
|
|
|
2484 |
|
|
|
2485 |
#列結束的語法
|
|
|
2486 |
#函式說明:
|
|
|
2487 |
#列結束
|
|
|
2488 |
#回傳結果:
|
|
|
2489 |
#$result,列結束的語法
|
|
|
2490 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::trEnd();
|
|
|
2491 |
|
|
|
2492 |
}#for end
|
|
|
2493 |
|
|
|
2494 |
#類別圖的表格結束
|
|
|
2495 |
#函式說明:
|
|
|
2496 |
#表格結束
|
|
|
2497 |
#回傳結果:
|
|
|
2498 |
#表格結束的語法
|
|
|
2499 |
$result["classDiagramTable"]=$result["classDiagramTable"].table::end();
|
|
|
2500 |
|
|
|
2501 |
#執行到這邊代表執行成功
|
|
|
2502 |
|
|
|
2503 |
#設置執行成功的識別
|
|
|
2504 |
$result["status"]="true";
|
|
|
2505 |
|
|
|
2506 |
#回傳結果
|
|
|
2507 |
return $result;
|
|
|
2508 |
|
|
|
2509 |
}#function classDiagramTable end
|
|
|
2510 |
|
|
|
2511 |
/*
|
|
|
2512 |
#函式說明:
|
|
|
2513 |
#建立div表格
|
|
|
2514 |
#回傳結果:
|
|
|
2515 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2516 |
#$result["error"],錯誤訊息.
|
|
|
2517 |
#$result["function"],當前執行的函數名稱.
|
|
|
2518 |
#$result["content"],表格的html內容.
|
|
|
2519 |
#必填參數:
|
|
|
2520 |
#無.
|
|
|
2521 |
#可省略參數:
|
|
|
2522 |
#$conf["defaulBorderStyleName"],字串,預設的表格框線css類別樣式名稱,預設為"__qbpwcf_border",樣式為{border:1px solid;}
|
|
|
2523 |
#$conf["defaulBorderStyleName"]="__qbpwcf_border";
|
|
|
2524 |
#$conf["id.table"],字串,table的id.
|
|
|
2525 |
#$conf["id.table"]="tableId";
|
|
|
2526 |
#$conf["class.table"],陣列,最外層div要套用的css類別樣式
|
|
|
2527 |
#$conf["class.table"]=array();
|
|
|
2528 |
#$conf["class.table.head"],陣列,表格標題最外層div要套用的css類別樣式
|
|
|
2529 |
#$conf["class.table.head"]=array();
|
|
|
2530 |
#$conf["class.table.head.th"],陣列,<th>要套用的css類別樣式
|
|
|
2531 |
#$conf["class.table.head.th"]=array();
|
|
|
2532 |
#$conf["class.table.head.th.td"],陣列,標題欄位內容標籤<td>要套用的css類別樣式
|
|
|
2533 |
#$conf["class.table.head.th.td"]=array();
|
|
|
2534 |
#$conf["class.table.body"],陣列,表格內容最外圍div要套用的css類別樣式
|
|
|
2535 |
#$conf["class.table.body"]=array();
|
|
|
2536 |
#$conf["class.table.body.tr"],陣列,<tr>要套用的css類別樣式
|
|
|
2537 |
#$conf["class.table.body.tr"]=array();
|
|
|
2538 |
#$conf["class.table.body.tr.td"],陣列,內容欄位標籤<td>要套用的css類別樣式
|
|
|
2539 |
#$conf["class.table.body.tr.td"]=array();
|
|
|
2540 |
#$conf["titleRow"],陣列,表格內個欄位的標題內容.
|
|
|
2541 |
#$conf["titleRow"]=array();
|
|
|
2542 |
#$conf["titleId"],字串,抬頭的id.
|
|
|
2543 |
#$conf["titleId"]="titleId";
|
|
|
2544 |
#$conf["content"],二維陣列,每一列各欄位的內容.
|
|
|
2545 |
#$conf["content"]=array(array());
|
|
|
2546 |
#參考資料:
|
|
|
2547 |
#無.
|
|
|
2548 |
#備註:
|
|
|
2549 |
#無.
|
|
|
2550 |
*/
|
|
|
2551 |
public static function div(&$conf){
|
|
|
2552 |
|
|
|
2553 |
#初始化要回傳的變數
|
|
|
2554 |
$result=array();
|
|
|
2555 |
|
|
|
2556 |
#記錄當前執行的函數名稱
|
|
|
2557 |
$result["function"]=__FUNCTION__;
|
|
|
2558 |
|
|
|
2559 |
#初始化表格的html語法
|
|
|
2560 |
$result["content"]="";
|
|
|
2561 |
|
|
|
2562 |
#如果 $conf 不為陣列
|
|
|
2563 |
if(gettype($conf)!="array"){
|
|
|
2564 |
|
|
|
2565 |
#設置執行失敗
|
|
|
2566 |
$result["status"]="false";
|
|
|
2567 |
|
|
|
2568 |
#設置執行錯誤訊息
|
|
|
2569 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2570 |
|
|
|
2571 |
#如果傳入的參數為 null
|
|
|
2572 |
if($conf==null){
|
|
|
2573 |
|
|
|
2574 |
#設置執行錯誤訊息
|
|
|
2575 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
2576 |
|
|
|
2577 |
}#if end
|
|
|
2578 |
|
|
|
2579 |
#回傳結果
|
|
|
2580 |
return $result;
|
|
|
2581 |
|
|
|
2582 |
}#if end
|
|
|
2583 |
|
|
|
2584 |
#如果沒有指定預設的框線css類別樣式名稱
|
|
|
2585 |
if(!isset($conf["defaulBorderStyleName"])){
|
|
|
2586 |
|
|
|
2587 |
#預設為 "__qbpwcf_border"
|
|
|
2588 |
$conf["defaulBorderStyleName"]="__qbpwcf_border";
|
|
|
2589 |
|
|
|
2590 |
}#if end
|
|
|
2591 |
|
|
|
2592 |
#檢查參數
|
|
|
2593 |
#函式說明:
|
|
|
2594 |
#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
|
|
|
2595 |
#回傳結果:
|
|
|
2596 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2597 |
#$result["error"],錯誤訊息陣列.
|
|
|
2598 |
#$result["function"],當前執行的函式名稱.
|
|
|
2599 |
#$result["passed"],參數是否都通過檢查,"true",代表有通過檢查,"false"代表沒有通過檢查。
|
|
|
2600 |
#必填參數:
|
|
|
2601 |
#$conf["checkedVar"],陣列,要檢查的變數陣列名稱為?
|
|
|
2602 |
$conf["variableCheck::checkSkipableVarType"]["checkedVar"]=$conf;
|
|
|
2603 |
#$conf["sikpableVarNameArray"],字串陣列,要檢查型態是否設定正確的變數名稱陣列.
|
|
|
2604 |
$conf["variableCheck::checkSkipableVarType"]["sikpableVarNameArray"]=array("titleId","id.table","defaulBorderStyleName","class.table","class.table.head","class.table.head.th","class.table.head.th.td","class.table.body","class.table.body.tr","class.table.body.tr.td","titleRow","content");
|
|
|
2605 |
#$argu,要直接存取的陣列變數名稱,變數前面加上「&」,如果要在別的函式裡面使用本函式,請記得將變動過結果($argu)給使用該函式的設定變數(通常是$conf=$argu).
|
|
|
2606 |
$argu=&$conf;
|
|
|
2607 |
#可省略參數:
|
|
|
2608 |
#$conf["skipableVarTypeArray"],字串陣列,要檢查的每個變數,其型態應該要為何,null代表不指定變數形態.
|
|
|
2609 |
$conf["variableCheck::checkSkipableVarType"]["skipableVarTypeArray"]=array("string","string","string","array","array","array","array","array","array","array","array");
|
|
|
2610 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.
|
|
|
2611 |
$conf["variableCheck::checkSkipableVarType"]["skipableVarDefaultValue"]=array("","","__border",array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),array($conf["defaulBorderStyleName"]),null,null);
|
|
|
2612 |
$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["variableCheck::checkSkipableVarType"],$argu);
|
|
|
2613 |
unset($conf["variableCheck::checkSkipableVarType"]);
|
|
|
2614 |
$conf=$argu;
|
|
|
2615 |
|
|
|
2616 |
#如果檢查可省略參數失敗
|
|
|
2617 |
if($checkSkipableVarType["status"]=="false"){
|
|
|
2618 |
|
|
|
2619 |
#設置執行錯誤識別
|
|
|
2620 |
$result["status"]="false";
|
|
|
2621 |
|
|
|
2622 |
#設置錯誤訊息
|
|
|
2623 |
$result["error"]=$checkSkipableVarType;
|
|
|
2624 |
|
|
|
2625 |
#回傳結果
|
|
|
2626 |
return $result;
|
|
|
2627 |
|
|
|
2628 |
}#if end
|
|
|
2629 |
|
|
|
2630 |
#初始化設定要套用class屬性的 $class 變數
|
|
|
2631 |
$class="";
|
| 226 |
liveuser |
2632 |
|
| 3 |
liveuser |
2633 |
#如果有設置 $conf["class.table"]
|
|
|
2634 |
if(isset($conf["class.table"])){
|
|
|
2635 |
|
|
|
2636 |
#如果其元素數量大於0
|
|
|
2637 |
if(count($conf["class.table"])>0){
|
|
|
2638 |
|
|
|
2639 |
#class屬性的開始
|
|
|
2640 |
$class="class=\"";
|
|
|
2641 |
|
|
|
2642 |
#針對每個要套用的 class
|
|
|
2643 |
foreach($conf["class.table"] as $className){
|
|
|
2644 |
|
|
|
2645 |
#如果不是第一個 class
|
|
|
2646 |
if($class!=="class=\""){
|
| 226 |
liveuser |
2647 |
|
| 3 |
liveuser |
2648 |
#加上" "
|
|
|
2649 |
$class=$class." ";
|
| 226 |
liveuser |
2650 |
|
| 3 |
liveuser |
2651 |
}#if end
|
|
|
2652 |
|
|
|
2653 |
#設定套用之
|
|
|
2654 |
$class=$class.$className;
|
|
|
2655 |
|
|
|
2656 |
}#foreach end
|
|
|
2657 |
|
|
|
2658 |
#class屬性的結束
|
|
|
2659 |
$class=$class."\"";
|
|
|
2660 |
|
|
|
2661 |
}#if end
|
|
|
2662 |
|
|
|
2663 |
}#if end
|
| 226 |
liveuser |
2664 |
|
| 3 |
liveuser |
2665 |
#反之
|
|
|
2666 |
else{
|
|
|
2667 |
#設置預設的樣式
|
|
|
2668 |
$class="class='__qbpwcf_border'";
|
| 226 |
liveuser |
2669 |
|
| 3 |
liveuser |
2670 |
}#else
|
|
|
2671 |
|
|
|
2672 |
#如果 $conf["id.table"] 不等於 ""
|
|
|
2673 |
if($conf["id.table"]!==""){
|
| 226 |
liveuser |
2674 |
|
| 3 |
liveuser |
2675 |
#設置table的id
|
|
|
2676 |
$conf["id.table"]="id=\"".$conf["id.table"]."\"";
|
| 226 |
liveuser |
2677 |
|
| 3 |
liveuser |
2678 |
}#if end
|
|
|
2679 |
|
|
|
2680 |
#將div轉換成table的語法
|
|
|
2681 |
$result["content"]=$result["content"]."<div style=\"display:table;margin:auto;\" ".$class." ".$conf["id.table"]." >";
|
|
|
2682 |
|
|
|
2683 |
#如果 $conf["titleRow"] 存在
|
|
|
2684 |
if(isset($conf["titleRow"])){
|
|
|
2685 |
|
|
|
2686 |
#初始化要套用的<thead>類別樣式
|
|
|
2687 |
$table_head="";
|
|
|
2688 |
|
|
|
2689 |
#如果 $conf["class.table.head"] 存在
|
|
|
2690 |
if(isset($conf["class.table.head"])){
|
|
|
2691 |
|
|
|
2692 |
#class屬性的開始
|
|
|
2693 |
$table_head="class=\"";
|
|
|
2694 |
|
|
|
2695 |
#針對每個要套用的 class
|
|
|
2696 |
foreach($conf["class.table.head"] as $className){
|
|
|
2697 |
|
|
|
2698 |
#設定套用之
|
|
|
2699 |
$table_head=$table_head." ".$className;
|
|
|
2700 |
|
|
|
2701 |
}#foreach end
|
|
|
2702 |
|
|
|
2703 |
#class屬性的結束
|
|
|
2704 |
$table_head=$table_head."\"";
|
|
|
2705 |
|
|
|
2706 |
}#if end
|
| 226 |
liveuser |
2707 |
|
| 3 |
liveuser |
2708 |
#反之
|
|
|
2709 |
else{
|
|
|
2710 |
#設置預設的樣式
|
|
|
2711 |
$table_head="class='__qbpwcf_border'";
|
|
|
2712 |
|
| 226 |
liveuser |
2713 |
}#else
|
|
|
2714 |
|
| 3 |
liveuser |
2715 |
#初始化要套用的<th>類別樣式
|
|
|
2716 |
$table_th="";
|
|
|
2717 |
|
|
|
2718 |
#如果有設置 $conf["class.table.head.th"]
|
|
|
2719 |
if(isset($conf["class.table.head.th"])){
|
|
|
2720 |
|
|
|
2721 |
#class屬性的開始
|
|
|
2722 |
$table_th="class=\"";
|
|
|
2723 |
|
|
|
2724 |
#針對每個要套用的 class
|
|
|
2725 |
foreach($conf["class.table.head.th"] as $className){
|
|
|
2726 |
|
|
|
2727 |
#設定套用之
|
|
|
2728 |
$table_th=$table_th." ".$className;
|
|
|
2729 |
|
|
|
2730 |
}#foreach end
|
|
|
2731 |
|
|
|
2732 |
#class屬性的結束
|
|
|
2733 |
$table_th=$table_th."\"";
|
|
|
2734 |
|
|
|
2735 |
}#if end
|
| 226 |
liveuser |
2736 |
|
| 3 |
liveuser |
2737 |
#反之
|
|
|
2738 |
else{
|
|
|
2739 |
#設置預設的樣式
|
|
|
2740 |
$table_th="class='__qbpwcf_border'";
|
|
|
2741 |
|
| 226 |
liveuser |
2742 |
}#else
|
|
|
2743 |
|
| 3 |
liveuser |
2744 |
#初始化要套用在<th>裡面<td>的css類別樣式
|
|
|
2745 |
$table_th_td="";
|
|
|
2746 |
|
|
|
2747 |
#如果有設置 $conf["class.table.head.th.td"]
|
|
|
2748 |
if(isset($conf["class.table.head.th.td"])){
|
|
|
2749 |
|
|
|
2750 |
#class屬性的開始
|
|
|
2751 |
$table_th_td="class=\"";
|
|
|
2752 |
|
|
|
2753 |
#針對每個要套用的 class
|
|
|
2754 |
foreach($conf["class.table.head.th.td"] as $className){
|
|
|
2755 |
|
|
|
2756 |
#設定套用之
|
|
|
2757 |
$table_th_td=$table_th_td." ".$className;
|
|
|
2758 |
|
|
|
2759 |
}#foreach end
|
|
|
2760 |
|
|
|
2761 |
#class屬性的結束
|
|
|
2762 |
$table_th_td=$table_th_td."\"";
|
|
|
2763 |
|
|
|
2764 |
}#if end
|
|
|
2765 |
|
|
|
2766 |
#反之
|
|
|
2767 |
else{
|
|
|
2768 |
#設置預設的樣式
|
|
|
2769 |
$table_th_td="class='__qbpwcf_border'";
|
|
|
2770 |
|
| 226 |
liveuser |
2771 |
}#else
|
|
|
2772 |
|
| 3 |
liveuser |
2773 |
#如果標題列id有設置
|
|
|
2774 |
if(isset($conf["titleId"])){
|
| 226 |
liveuser |
2775 |
|
| 3 |
liveuser |
2776 |
#設置標題的id
|
|
|
2777 |
$conf["titleId"]="id=\"".$conf["titleId"]."\"";
|
| 226 |
liveuser |
2778 |
|
| 3 |
liveuser |
2779 |
}#if end
|
| 226 |
liveuser |
2780 |
|
|
|
2781 |
#反之
|
| 3 |
liveuser |
2782 |
else{
|
|
|
2783 |
#不設置id
|
|
|
2784 |
$conf["titleId"]="";
|
| 226 |
liveuser |
2785 |
|
| 3 |
liveuser |
2786 |
}#else end
|
|
|
2787 |
|
|
|
2788 |
#表格標題的開始
|
|
|
2789 |
$result["content"]=$result["content"]."<div ".$conf["titleId"]." style=\"display:table-header-group\" $table_head ><div style=\"display:table-row\" ".$table_th." >";
|
|
|
2790 |
|
|
|
2791 |
#針對每個標題欄位
|
|
|
2792 |
foreach($conf["titleRow"] as $key=>$value){
|
|
|
2793 |
|
|
|
2794 |
#放置其內容
|
|
|
2795 |
$result["content"]=$result["content"]."<div style=\"display:table-cell\" ".$table_th_td." >".$value."</div>";
|
|
|
2796 |
|
|
|
2797 |
}#foreach end
|
|
|
2798 |
|
|
|
2799 |
#表格標題的結束
|
|
|
2800 |
$result["content"]=$result["content"]."</div></div>";
|
|
|
2801 |
|
|
|
2802 |
}#if end
|
|
|
2803 |
|
|
|
2804 |
#初始化要套用的<tbody>類別樣式
|
|
|
2805 |
$table_body="";
|
|
|
2806 |
|
|
|
2807 |
#如果 $conf["class.table.body"] 存在
|
|
|
2808 |
if(isset($conf["class.table.body"])){
|
|
|
2809 |
|
|
|
2810 |
#class屬性的開始
|
|
|
2811 |
$table_body="class=\"";
|
|
|
2812 |
|
|
|
2813 |
#針對每個要套用的 class
|
|
|
2814 |
foreach($conf["class.table.body"] as $className){
|
|
|
2815 |
|
|
|
2816 |
#設定套用之
|
|
|
2817 |
$table_body=$table_body." ".$className;
|
|
|
2818 |
|
|
|
2819 |
}#foreach end
|
|
|
2820 |
|
|
|
2821 |
#class屬性的結束
|
|
|
2822 |
$table_body=$table_body."\"";
|
|
|
2823 |
|
|
|
2824 |
}#if end
|
| 226 |
liveuser |
2825 |
|
| 3 |
liveuser |
2826 |
#反之
|
|
|
2827 |
else{
|
|
|
2828 |
#設置預設的樣式
|
|
|
2829 |
$table_body="class='__qbpwcf_border'";
|
|
|
2830 |
|
| 226 |
liveuser |
2831 |
}#else
|
|
|
2832 |
|
| 3 |
liveuser |
2833 |
#初始化要套用的<tbody>中<tr>的css類別樣式
|
|
|
2834 |
$table_body_tr="";
|
|
|
2835 |
|
|
|
2836 |
#如果 $conf["class.table.body.tr"] 存在
|
|
|
2837 |
if(isset($conf["class.table.body.tr"])){
|
|
|
2838 |
|
|
|
2839 |
#class屬性的開始
|
|
|
2840 |
$table_body_tr="class=\"";
|
|
|
2841 |
|
|
|
2842 |
#針對每個要套用的 class
|
|
|
2843 |
foreach($conf["class.table.body.tr"] as $className){
|
|
|
2844 |
|
|
|
2845 |
#設定套用之
|
|
|
2846 |
$table_body_tr=$table_body_tr." ".$className;
|
|
|
2847 |
|
|
|
2848 |
}#foreach end
|
|
|
2849 |
|
|
|
2850 |
#class屬性的結束
|
|
|
2851 |
$table_body_tr=$table_body_tr."\"";
|
|
|
2852 |
|
|
|
2853 |
}#if end
|
| 226 |
liveuser |
2854 |
|
| 3 |
liveuser |
2855 |
#反之
|
|
|
2856 |
else{
|
|
|
2857 |
#設置預設的樣式
|
|
|
2858 |
$table_body_tr="class='__qbpwcf_border'";
|
|
|
2859 |
|
| 226 |
liveuser |
2860 |
}#else
|
|
|
2861 |
|
| 3 |
liveuser |
2862 |
#初始化要套用的<tbody>中<tr>中<td>的css類別樣式
|
|
|
2863 |
$table_body_tr_td="";
|
|
|
2864 |
|
|
|
2865 |
#如果 $conf["class.table.body.tr.td"] 存在
|
|
|
2866 |
if(isset($conf["class.table.body.tr.td"])){
|
|
|
2867 |
|
|
|
2868 |
#class屬性的開始
|
|
|
2869 |
$table_body_tr_td="class=\"";
|
|
|
2870 |
|
|
|
2871 |
#針對每個要套用的 class
|
|
|
2872 |
foreach($conf["class.table.body.tr.td"] as $className){
|
|
|
2873 |
|
|
|
2874 |
#設定套用之
|
|
|
2875 |
$table_body_tr_td=$table_body_tr_td." ".$className;
|
|
|
2876 |
|
|
|
2877 |
}#foreach end
|
|
|
2878 |
|
|
|
2879 |
#class屬性的結束
|
|
|
2880 |
$table_body_tr_td=$table_body_tr_td."\"";
|
|
|
2881 |
|
|
|
2882 |
}#if end
|
| 226 |
liveuser |
2883 |
|
| 3 |
liveuser |
2884 |
#反之
|
|
|
2885 |
else{
|
|
|
2886 |
#設置預設的樣式
|
|
|
2887 |
$table_body_tr_td="class='__qbpwcf_border'";
|
|
|
2888 |
|
| 226 |
liveuser |
2889 |
}#else
|
|
|
2890 |
|
| 3 |
liveuser |
2891 |
#如果 $conf["content"] 存在
|
|
|
2892 |
if(isset($conf["content"])){
|
|
|
2893 |
|
|
|
2894 |
#表格內容的開始
|
|
|
2895 |
$result["content"]=$result["content"]."<div style=\"display:table-row-group\" ".$table_body." >";
|
|
|
2896 |
|
|
|
2897 |
#針對每列
|
|
|
2898 |
foreach($conf["content"] as $row){
|
|
|
2899 |
|
|
|
2900 |
#表格內容欄的開始
|
|
|
2901 |
$result["content"]=$result["content"]."<div style=\"display:table-row\" ".$table_body_tr." >";
|
|
|
2902 |
|
|
|
2903 |
#針對每個欄位
|
|
|
2904 |
foreach($row as $key=>$value){
|
|
|
2905 |
|
|
|
2906 |
#放置其內容
|
|
|
2907 |
$result["content"]=$result["content"]."<div style=\"display:table-cell\" ".$table_body_tr_td." >".$value."</div>";
|
|
|
2908 |
|
|
|
2909 |
}#foreach end
|
|
|
2910 |
|
|
|
2911 |
#表格內容欄的結束
|
|
|
2912 |
$result["content"]=$result["content"]."</div>";
|
|
|
2913 |
|
|
|
2914 |
}#foreach end
|
|
|
2915 |
|
|
|
2916 |
#表格內容的結束
|
|
|
2917 |
$result["content"]=$result["content"]."</div></div>";
|
|
|
2918 |
|
|
|
2919 |
}#if end
|
|
|
2920 |
|
|
|
2921 |
#div表格結束
|
|
|
2922 |
$result["content"]=$result["content"]."</div>";
|
|
|
2923 |
|
|
|
2924 |
#設定執行正常
|
|
|
2925 |
$result["status"]="true";
|
|
|
2926 |
|
|
|
2927 |
#回傳結果
|
|
|
2928 |
return $result;
|
|
|
2929 |
|
|
|
2930 |
}#function div end
|
|
|
2931 |
|
|
|
2932 |
/*
|
|
|
2933 |
#函式說明:
|
| 207 |
liveuser |
2934 |
#建立div表格,並具備翻頁功能,從ajax取得新資料,傳遞的參數為post變數的pageNumber,代表要檢閱第幾頁的資料.
|
| 3 |
liveuser |
2935 |
#回傳結果:
|
|
|
2936 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2937 |
#$result["error"],錯誤訊息.
|
|
|
2938 |
#$result["function"],當前執行的函數名稱.
|
|
|
2939 |
#$result["content"],表格的html內容.
|
| 200 |
liveuser |
2940 |
#$result["argu"],使用的參數.
|
|
|
2941 |
#$result["argued"],參數檢查後使用的參數.
|
| 3 |
liveuser |
2942 |
#必填參數:
|
|
|
2943 |
#$conf["dataUrl"],字串,取得資料的url.
|
|
|
2944 |
$conf["dataUrl"]="";
|
|
|
2945 |
#可省略參數:
|
|
|
2946 |
#$conf["defaulBorderStyleName"],字串,預設的表格框線css類別樣式名稱,預設為"__qbpwcf_border",樣式為{border:1px solid;}
|
|
|
2947 |
#$conf["defaulBorderStyleName"]="__qbpwcf_border";
|
|
|
2948 |
#$conf["id.table"],字串,table的id.
|
|
|
2949 |
#$conf["id.table"]="tableId";
|
|
|
2950 |
#$conf["class.table"],陣列,最外層div要套用的css類別樣式
|
|
|
2951 |
#$conf["class.table"]=array();
|
|
|
2952 |
#$conf["class.table.head"],陣列,表格標題最外層div要套用的css類別樣式
|
|
|
2953 |
#$conf["class.table.head"]=array();
|
|
|
2954 |
#$conf["class.table.head.th"],陣列,<th>要套用的css類別樣式
|
|
|
2955 |
#$conf["class.table.head.th"]=array();
|
|
|
2956 |
#$conf["class.table.head.th.td"],陣列,標題欄位內容標籤<td>要套用的css類別樣式
|
|
|
2957 |
#$conf["class.table.head.th.td"]=array();
|
|
|
2958 |
#$conf["class.table.body"],陣列,表格內容最外圍div要套用的css類別樣式
|
|
|
2959 |
#$conf["class.table.body"]=array();
|
|
|
2960 |
#$conf["class.table.body.tr"],陣列,<tr>要套用的css類別樣式
|
|
|
2961 |
#$conf["class.table.body.tr"]=array();
|
|
|
2962 |
#$conf["class.table.body.tr.odd"],陣列,奇數<tr>要套用的css類別樣式.
|
|
|
2963 |
#$conf["class.table.body.tr.odd"]=array();
|
|
|
2964 |
#$conf["class.table.body.tr.even"],陣列,偶數<tr>要套用的css類別樣式.
|
|
|
2965 |
#$conf["class.table.body.tr.even"]=array();
|
|
|
2966 |
#$conf["class.table.body.tr.td"],陣列,內容欄位標籤<td>要套用的css類別樣式
|
|
|
2967 |
#$conf["class.table.body.tr.td"]=array();
|
|
|
2968 |
#$conf["titleRow"],字串陣列,表格內個欄位的標題內容.
|
|
|
2969 |
#$conf["titleRow"]=array();
|
|
|
2970 |
#$conf["titleId"],字串,抬頭的id.
|
|
|
2971 |
#$conf["titleId"]="titleId";
|
|
|
2972 |
#參考資料:
|
|
|
2973 |
#https://www.w3.org/Style/css2-updates/css2/tables.html
|
|
|
2974 |
#備註:
|
|
|
2975 |
#無.
|
|
|
2976 |
*/
|
|
|
2977 |
public static function divAjax(&$conf){
|
| 226 |
liveuser |
2978 |
|
| 3 |
liveuser |
2979 |
#初始化要回傳的變數
|
|
|
2980 |
$result=array();
|
|
|
2981 |
|
|
|
2982 |
#記錄當前執行的函數名稱
|
|
|
2983 |
$result["function"]=__FUNCTION__;
|
|
|
2984 |
|
|
|
2985 |
#初始化表格的html語法
|
|
|
2986 |
$result["content"]="";
|
|
|
2987 |
|
|
|
2988 |
#如果 $conf 不為陣列
|
|
|
2989 |
if(gettype($conf)!="array"){
|
|
|
2990 |
|
|
|
2991 |
#設置執行失敗
|
|
|
2992 |
$result["status"]="false";
|
|
|
2993 |
|
|
|
2994 |
#設置執行錯誤訊息
|
|
|
2995 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2996 |
|
|
|
2997 |
#如果傳入的參數為 null
|
|
|
2998 |
if($conf==null){
|
|
|
2999 |
|
|
|
3000 |
#設置執行錯誤訊息
|
|
|
3001 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
3002 |
|
|
|
3003 |
}#if end
|
|
|
3004 |
|
|
|
3005 |
#回傳結果
|
|
|
3006 |
return $result;
|
|
|
3007 |
|
|
|
3008 |
}#if end
|
| 226 |
liveuser |
3009 |
|
| 3 |
liveuser |
3010 |
#取得使用的參數
|
|
|
3011 |
$result["argu"]=$conf;
|
| 226 |
liveuser |
3012 |
|
| 3 |
liveuser |
3013 |
#參數清單
|
|
|
3014 |
$argu=array();
|
|
|
3015 |
$argu[]="defaulBorderStyleName";
|
|
|
3016 |
$argu[]="id.table";
|
|
|
3017 |
$argu[]="class.table";
|
|
|
3018 |
$argu[]="class.table.head";
|
|
|
3019 |
$argu[]="class.table.head.th";
|
|
|
3020 |
$argu[]="class.table.head.th.td";
|
|
|
3021 |
$argu[]="class.table.body";
|
|
|
3022 |
$argu[]="class.table.body.tr";
|
|
|
3023 |
$argu[]="class.table.body.tr.odd";
|
|
|
3024 |
$argu[]="class.table.body.tr.even";
|
|
|
3025 |
$argu[]="lass.table.body.tr.td";
|
|
|
3026 |
$argu[]="titleRow";
|
|
|
3027 |
$argu[]="titleId";
|
| 226 |
liveuser |
3028 |
|
| 3 |
liveuser |
3029 |
#可省略參數若有設置,不能為空值.
|
|
|
3030 |
$skipableVariableCanNotBeEmpty=$argu;
|
| 226 |
liveuser |
3031 |
|
| 3 |
liveuser |
3032 |
#可省略的參數名稱
|
|
|
3033 |
$skipableVariableName=$argu;
|
| 226 |
liveuser |
3034 |
|
| 3 |
liveuser |
3035 |
#可省略變數的形態
|
|
|
3036 |
$skipableVariableType=array();
|
|
|
3037 |
$skipableVariableType[]="string";
|
|
|
3038 |
$skipableVariableType[]="string";
|
|
|
3039 |
$skipableVariableType[]="array";
|
|
|
3040 |
$skipableVariableType[]="array";
|
|
|
3041 |
$skipableVariableType[]="array";
|
|
|
3042 |
$skipableVariableType[]="array";
|
|
|
3043 |
$skipableVariableType[]="array";
|
|
|
3044 |
$skipableVariableType[]="array";
|
|
|
3045 |
$skipableVariableType[]="array";
|
|
|
3046 |
$skipableVariableType[]="array";
|
|
|
3047 |
$skipableVariableType[]="array";
|
|
|
3048 |
$skipableVariableType[]="array";
|
|
|
3049 |
$skipableVariableType[]="string";
|
| 226 |
liveuser |
3050 |
|
| 3 |
liveuser |
3051 |
#可省略變數的預設值
|
|
|
3052 |
$skipableVarDefaultValue=array();
|
|
|
3053 |
$skipableVarDefaultValue[]="__qbpwcf_border";
|
|
|
3054 |
$skipableVarDefaultValue[]="tableId";
|
|
|
3055 |
$skipableVarDefaultValue[]=null;
|
|
|
3056 |
$skipableVarDefaultValue[]=array("__qbpwcf_border","__qbpwcf_bold","__qbpwcf_alignCenter");
|
|
|
3057 |
$skipableVarDefaultValue[]=null;
|
|
|
3058 |
$skipableVarDefaultValue[]=null;
|
|
|
3059 |
$skipableVarDefaultValue[]=null;
|
|
|
3060 |
$skipableVarDefaultValue[]=null;
|
|
|
3061 |
$skipableVarDefaultValue[]=array("__qbpwcf_odd");
|
|
|
3062 |
$skipableVarDefaultValue[]=array("__qbpwcf_even");
|
|
|
3063 |
$skipableVarDefaultValue[]=null;
|
|
|
3064 |
$skipableVarDefaultValue[]=null;
|
|
|
3065 |
$skipableVarDefaultValue[]=null;
|
| 226 |
liveuser |
3066 |
|
| 3 |
liveuser |
3067 |
#檢查參數
|
|
|
3068 |
#函式說明:
|
|
|
3069 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
3070 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3071 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
3072 |
#$result["function"],當前執行的函式名稱.
|
|
|
3073 |
#$result["argu"],設置給予的參數.
|
|
|
3074 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
3075 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
3076 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
3077 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
3078 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
3079 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
3080 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
3081 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
3082 |
#必填參數:
|
|
|
3083 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
3084 |
$conf["variable::checkArguments"]["varInput"]=&$conf;
|
|
|
3085 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
3086 |
$conf["variable::checkArguments"]["referenceVarKey"]="variable::checkArguments";
|
|
|
3087 |
#可以省略的參數:
|
|
|
3088 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
3089 |
$conf["variable::checkArguments"]["mustBeFilledVariableName"]=array("dataUrl");
|
|
|
3090 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
3091 |
$conf["variable::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
3092 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
3093 |
$conf["variable::checkArguments"]["canBeEmptyString"]="false";
|
|
|
3094 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
3095 |
#$conf["canNotBeEmpty"]=array();
|
|
|
3096 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
3097 |
#$conf["canBeEmpty"]=array();
|
|
|
3098 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
3099 |
$conf["variable::checkArguments"]["skipableVariableCanNotBeEmpty"]=$skipableVariableCanNotBeEmpty;
|
|
|
3100 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
3101 |
$conf["variable::checkArguments"]["skipableVariableName"]=$skipableVariableName;
|
|
|
3102 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
3103 |
$conf["variable::checkArguments"]["skipableVariableType"]=$skipableVariableType;
|
|
|
3104 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
3105 |
$conf["variable::checkArguments"]["skipableVarDefaultValue"]=$skipableVarDefaultValue;
|
|
|
3106 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
3107 |
$conf["variable::checkArguments"]["disallowAllSkipableVarIsEmpty"]="false";
|
|
|
3108 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
3109 |
$conf["variable::checkArguments"]["disallowAllSkipableVarIsEmptyArray"]="false";
|
|
|
3110 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
3111 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
3112 |
#參考資料來源:
|
|
|
3113 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
3114 |
$checkArguments=variableCheck::checkArguments($conf["variable::checkArguments"]);
|
|
|
3115 |
unset($conf["variable::checkArguments"]);
|
| 226 |
liveuser |
3116 |
|
| 3 |
liveuser |
3117 |
#如果檢查參數失敗
|
|
|
3118 |
if($checkArguments["status"]==="false"){
|
|
|
3119 |
|
|
|
3120 |
#設置執行錯誤識別
|
|
|
3121 |
$result["status"]="false";
|
|
|
3122 |
|
|
|
3123 |
#設置錯誤訊息
|
|
|
3124 |
$result["error"]=$checkArguments;
|
|
|
3125 |
|
|
|
3126 |
#回傳結果
|
|
|
3127 |
return $result;
|
|
|
3128 |
|
|
|
3129 |
}#if end
|
| 226 |
liveuser |
3130 |
|
| 3 |
liveuser |
3131 |
#如果檢查參數不通過
|
|
|
3132 |
if($checkArguments["passed"]==="false"){
|
|
|
3133 |
|
|
|
3134 |
#設置執行錯誤識別
|
|
|
3135 |
$result["status"]="false";
|
|
|
3136 |
|
|
|
3137 |
#設置錯誤訊息
|
|
|
3138 |
$result["error"]=$checkArguments;
|
|
|
3139 |
|
|
|
3140 |
#回傳結果
|
|
|
3141 |
return $result;
|
|
|
3142 |
|
|
|
3143 |
}#if end
|
| 226 |
liveuser |
3144 |
|
| 3 |
liveuser |
3145 |
#取得參數檢查後使用的參數
|
|
|
3146 |
$result["argued"]=$conf;
|
| 226 |
liveuser |
3147 |
|
| 3 |
liveuser |
3148 |
#初始化設定要套用class屬性的 $class 變數
|
|
|
3149 |
$class="";
|
| 226 |
liveuser |
3150 |
|
| 3 |
liveuser |
3151 |
#如果有設置 $conf["class.table"]
|
|
|
3152 |
if(isset($conf["class.table"])){
|
|
|
3153 |
|
|
|
3154 |
#如果其元素數量大於0
|
|
|
3155 |
if(count($conf["class.table"])>0){
|
|
|
3156 |
|
|
|
3157 |
#class屬性的開始
|
|
|
3158 |
$class="class=\"";
|
|
|
3159 |
|
|
|
3160 |
#針對每個要套用的 class
|
|
|
3161 |
foreach($conf["class.table"] as $className){
|
|
|
3162 |
|
|
|
3163 |
#如果不是第一個 class
|
|
|
3164 |
if($class!=="class=\""){
|
| 226 |
liveuser |
3165 |
|
| 3 |
liveuser |
3166 |
#加上" "
|
|
|
3167 |
$class=$class." ";
|
| 226 |
liveuser |
3168 |
|
| 3 |
liveuser |
3169 |
}#if end
|
|
|
3170 |
|
|
|
3171 |
#設定套用之
|
|
|
3172 |
$class=$class.$className;
|
|
|
3173 |
|
|
|
3174 |
}#foreach end
|
|
|
3175 |
|
|
|
3176 |
#class屬性的結束
|
|
|
3177 |
$class=$class."\"";
|
|
|
3178 |
|
|
|
3179 |
}#if end
|
|
|
3180 |
|
|
|
3181 |
}#if end
|
| 226 |
liveuser |
3182 |
|
| 3 |
liveuser |
3183 |
#反之
|
|
|
3184 |
else{
|
|
|
3185 |
#設置預設的樣式
|
|
|
3186 |
$class="class='__qbpwcf_border'";
|
| 226 |
liveuser |
3187 |
|
| 3 |
liveuser |
3188 |
}#else
|
|
|
3189 |
|
|
|
3190 |
#如果 $conf["id.table"] 不等於 ""
|
|
|
3191 |
if($conf["id.table"]!==""){
|
| 226 |
liveuser |
3192 |
|
| 3 |
liveuser |
3193 |
#設置table的id
|
|
|
3194 |
$conf["id.table"]="id=\"".$conf["id.table"]."\"";
|
| 226 |
liveuser |
3195 |
|
| 3 |
liveuser |
3196 |
}#if end
|
|
|
3197 |
|
|
|
3198 |
#將div轉換成table的語法
|
|
|
3199 |
$result["content"]=$result["content"]."<div style=\"display:table;margin:auto;width:90%;border-left:1px solid;border-right:1px solid;\" ".$class." ".$conf["id.table"]." >";
|
|
|
3200 |
|
|
|
3201 |
#如果 $conf["titleRow"] 存在
|
|
|
3202 |
if(isset($conf["titleRow"])){
|
|
|
3203 |
|
|
|
3204 |
#初始化要套用的<thead>類別樣式
|
|
|
3205 |
$table_head="";
|
|
|
3206 |
|
|
|
3207 |
#如果 $conf["class.table.head"] 存在
|
|
|
3208 |
if(isset($conf["class.table.head"])){
|
|
|
3209 |
|
|
|
3210 |
#class屬性的開始
|
|
|
3211 |
$table_head="class=\"";
|
|
|
3212 |
|
|
|
3213 |
#針對每個要套用的 class
|
|
|
3214 |
foreach($conf["class.table.head"] as $className){
|
|
|
3215 |
|
|
|
3216 |
#設定套用之
|
|
|
3217 |
$table_head=$table_head." ".$className;
|
|
|
3218 |
|
|
|
3219 |
}#foreach end
|
|
|
3220 |
|
|
|
3221 |
#class屬性的結束
|
|
|
3222 |
$table_head=$table_head."\"";
|
|
|
3223 |
|
|
|
3224 |
}#if end
|
| 226 |
liveuser |
3225 |
|
| 3 |
liveuser |
3226 |
#反之
|
|
|
3227 |
else{
|
|
|
3228 |
#設置預設的樣式
|
|
|
3229 |
$table_head="class='__qbpwcf_border'";
|
| 226 |
liveuser |
3230 |
|
| 207 |
liveuser |
3231 |
}#else end
|
| 3 |
liveuser |
3232 |
|
|
|
3233 |
#初始化要套用的<th>類別樣式
|
|
|
3234 |
$table_th="";
|
|
|
3235 |
|
|
|
3236 |
#如果有設置 $conf["class.table.head.th"]
|
|
|
3237 |
if(isset($conf["class.table.head.th"])){
|
|
|
3238 |
|
|
|
3239 |
#class屬性的開始
|
|
|
3240 |
$table_th="class=\"";
|
|
|
3241 |
|
|
|
3242 |
#針對每個要套用的 class
|
|
|
3243 |
foreach($conf["class.table.head.th"] as $className){
|
|
|
3244 |
|
|
|
3245 |
#設定套用之
|
|
|
3246 |
$table_th=$table_th." ".$className;
|
|
|
3247 |
|
|
|
3248 |
}#foreach end
|
|
|
3249 |
|
|
|
3250 |
#class屬性的結束
|
|
|
3251 |
$table_th=$table_th."\"";
|
|
|
3252 |
|
|
|
3253 |
}#if end
|
| 226 |
liveuser |
3254 |
|
| 3 |
liveuser |
3255 |
#反之
|
|
|
3256 |
else{
|
|
|
3257 |
#設置預設的樣式
|
|
|
3258 |
$table_th="class='__qbpwcf_border'";
|
|
|
3259 |
|
| 226 |
liveuser |
3260 |
}#else
|
|
|
3261 |
|
| 3 |
liveuser |
3262 |
#初始化要套用在<th>裡面<td>的css類別樣式
|
|
|
3263 |
$table_th_td="";
|
|
|
3264 |
|
|
|
3265 |
#如果有設置 $conf["class.table.head.th.td"]
|
|
|
3266 |
if(isset($conf["class.table.head.th.td"])){
|
|
|
3267 |
|
|
|
3268 |
#class屬性的開始
|
|
|
3269 |
$table_th_td="class=\"";
|
|
|
3270 |
|
|
|
3271 |
#針對每個要套用的 class
|
|
|
3272 |
foreach($conf["class.table.head.th.td"] as $className){
|
|
|
3273 |
|
|
|
3274 |
#設定套用之
|
|
|
3275 |
$table_th_td=$table_th_td." ".$className;
|
|
|
3276 |
|
|
|
3277 |
}#foreach end
|
|
|
3278 |
|
|
|
3279 |
#class屬性的結束
|
|
|
3280 |
$table_th_td=$table_th_td."\"";
|
|
|
3281 |
|
|
|
3282 |
}#if end
|
|
|
3283 |
|
|
|
3284 |
#反之
|
|
|
3285 |
else{
|
| 226 |
liveuser |
3286 |
|
| 3 |
liveuser |
3287 |
#設置預設的樣式
|
|
|
3288 |
$table_th_td="class='__qbpwcf_border'";
|
|
|
3289 |
|
| 226 |
liveuser |
3290 |
}#else
|
|
|
3291 |
|
| 3 |
liveuser |
3292 |
#如果標題列id有設置
|
|
|
3293 |
if(isset($conf["titleId"])){
|
| 226 |
liveuser |
3294 |
|
| 3 |
liveuser |
3295 |
#設置標題的id
|
|
|
3296 |
$conf["titleId"]="id=\"".$conf["titleId"]."\"";
|
| 226 |
liveuser |
3297 |
|
| 3 |
liveuser |
3298 |
}#if end
|
| 226 |
liveuser |
3299 |
|
|
|
3300 |
#反之
|
| 3 |
liveuser |
3301 |
else{
|
| 226 |
liveuser |
3302 |
|
| 3 |
liveuser |
3303 |
#預設的ID為資料表id+"_title"
|
|
|
3304 |
$conf["titleId"]="id=\"".$result["argued"]["id.table"]."_title\"";
|
| 226 |
liveuser |
3305 |
|
| 3 |
liveuser |
3306 |
}#else end
|
|
|
3307 |
|
|
|
3308 |
#表格標題的開始
|
|
|
3309 |
$result["content"]=$result["content"]."<div ".$conf["titleId"]." style=\"display:table-header-group\" $table_head ><div style=\"display:table-row\" ".$table_th." >";
|
|
|
3310 |
|
|
|
3311 |
#針對每個標題欄位
|
|
|
3312 |
foreach($conf["titleRow"] as $key=>$value){
|
|
|
3313 |
|
|
|
3314 |
#放置其內容
|
|
|
3315 |
$result["content"]=$result["content"]."<div style=\"display:table-cell\" ".$table_th_td." >".$value."</div>";
|
|
|
3316 |
|
|
|
3317 |
}#foreach end
|
|
|
3318 |
|
|
|
3319 |
#表格標題的結束
|
|
|
3320 |
$result["content"]=$result["content"]."</div></div>";
|
|
|
3321 |
|
|
|
3322 |
}#if end
|
|
|
3323 |
|
|
|
3324 |
#初始化要套用的<tbody>類別樣式
|
|
|
3325 |
$table_body="";
|
|
|
3326 |
|
|
|
3327 |
#如果 $conf["class.table.body"] 存在
|
|
|
3328 |
if(isset($conf["class.table.body"])){
|
|
|
3329 |
|
|
|
3330 |
#class屬性的開始
|
|
|
3331 |
$table_body="class=\"";
|
|
|
3332 |
|
|
|
3333 |
#針對每個要套用的 class
|
|
|
3334 |
foreach($conf["class.table.body"] as $className){
|
|
|
3335 |
|
|
|
3336 |
#設定套用之
|
|
|
3337 |
$table_body=$table_body." ".$className;
|
|
|
3338 |
|
|
|
3339 |
}#foreach end
|
|
|
3340 |
|
|
|
3341 |
#class屬性的結束
|
|
|
3342 |
$table_body=$table_body."\"";
|
|
|
3343 |
|
|
|
3344 |
}#if end
|
| 226 |
liveuser |
3345 |
|
| 3 |
liveuser |
3346 |
#反之
|
|
|
3347 |
else{
|
| 226 |
liveuser |
3348 |
|
| 3 |
liveuser |
3349 |
#設置預設的樣式
|
|
|
3350 |
$table_body="class=\"__qbpwcf_border\"";
|
|
|
3351 |
|
| 226 |
liveuser |
3352 |
}#else
|
|
|
3353 |
|
| 3 |
liveuser |
3354 |
#初始化要套用的<tbody>中<tr>的css類別樣式
|
|
|
3355 |
$table_body_tr="";
|
|
|
3356 |
|
|
|
3357 |
#如果 $conf["class.table.body.tr"] 存在
|
|
|
3358 |
if(isset($conf["class.table.body.tr"])){
|
|
|
3359 |
|
|
|
3360 |
#class屬性的開始
|
|
|
3361 |
$table_body_tr="class=\"";
|
|
|
3362 |
|
|
|
3363 |
#針對每個要套用的 class
|
|
|
3364 |
foreach($conf["class.table.body.tr"] as $className){
|
|
|
3365 |
|
|
|
3366 |
#設定套用之
|
|
|
3367 |
$table_body_tr=$table_body_tr." ".$className;
|
|
|
3368 |
|
|
|
3369 |
}#foreach end
|
|
|
3370 |
|
|
|
3371 |
#class屬性的結束
|
|
|
3372 |
$table_body_tr=$table_body_tr."\"";
|
|
|
3373 |
|
|
|
3374 |
}#if end
|
| 226 |
liveuser |
3375 |
|
| 3 |
liveuser |
3376 |
#反之
|
|
|
3377 |
else{
|
| 226 |
liveuser |
3378 |
|
| 3 |
liveuser |
3379 |
#設置預設的樣式
|
|
|
3380 |
$table_body_tr="class=\"__qbpwcf_border\"";
|
| 226 |
liveuser |
3381 |
|
|
|
3382 |
}#else
|
|
|
3383 |
|
| 3 |
liveuser |
3384 |
#初始化要套用的<tbody>中奇數<tr>的css類別樣式
|
|
|
3385 |
$table_body_tr_odd="";
|
|
|
3386 |
|
|
|
3387 |
#如果 $conf["class.table.body.tr.odd"] 存在
|
|
|
3388 |
if(isset($result["argued"]["class.table.body.tr.odd"])){
|
|
|
3389 |
|
|
|
3390 |
#class屬性的開始
|
|
|
3391 |
$table_body_tr_odd="";
|
|
|
3392 |
|
|
|
3393 |
#針對每個要套用的 class
|
|
|
3394 |
foreach($result["argued"]["class.table.body.tr.odd"] as $className){
|
|
|
3395 |
|
|
|
3396 |
#設定套用之
|
|
|
3397 |
$table_body_tr_odd=$table_body_tr_odd." ".$className;
|
|
|
3398 |
|
|
|
3399 |
}#foreach end
|
|
|
3400 |
|
|
|
3401 |
}#if end
|
| 226 |
liveuser |
3402 |
|
| 3 |
liveuser |
3403 |
#初始化要套用的<tbody>中偶數<tr>的css類別樣式
|
|
|
3404 |
$table_body_tr_even="";
|
|
|
3405 |
|
|
|
3406 |
#如果 $conf["class.table.body.tr.even"] 存在
|
|
|
3407 |
if(isset($result["argued"]["class.table.body.tr.even"])){
|
| 226 |
liveuser |
3408 |
|
| 3 |
liveuser |
3409 |
#針對每個要套用的 class
|
|
|
3410 |
foreach($result["argued"]["class.table.body.tr.even"] as $className){
|
|
|
3411 |
|
|
|
3412 |
#設定套用之
|
|
|
3413 |
$table_body_tr_even=$table_body_tr_even." ".$className;
|
|
|
3414 |
|
|
|
3415 |
}#foreach end
|
| 226 |
liveuser |
3416 |
|
| 3 |
liveuser |
3417 |
}#if end
|
|
|
3418 |
|
|
|
3419 |
#初始化要套用的<tbody>中<tr>中<td>的css類別樣式
|
|
|
3420 |
$table_body_tr_td="";
|
|
|
3421 |
|
|
|
3422 |
#如果 $conf["class.table.body.tr.td"] 存在
|
|
|
3423 |
if(isset($conf["class.table.body.tr.td"])){
|
|
|
3424 |
|
|
|
3425 |
#class屬性的開始
|
|
|
3426 |
$table_body_tr_td="class=\"";
|
|
|
3427 |
|
|
|
3428 |
#針對每個要套用的 class
|
|
|
3429 |
foreach($conf["class.table.body.tr.td"] as $className){
|
|
|
3430 |
|
|
|
3431 |
#設定套用之
|
|
|
3432 |
$table_body_tr_td=$table_body_tr_td." ".$className;
|
|
|
3433 |
|
|
|
3434 |
}#foreach end
|
|
|
3435 |
|
|
|
3436 |
#class屬性的結束
|
|
|
3437 |
$table_body_tr_td=$table_body_tr_td."\"";
|
|
|
3438 |
|
|
|
3439 |
}#if end
|
| 226 |
liveuser |
3440 |
|
| 3 |
liveuser |
3441 |
#反之
|
|
|
3442 |
else{
|
| 226 |
liveuser |
3443 |
|
| 3 |
liveuser |
3444 |
#設置預設的樣式
|
|
|
3445 |
$table_body_tr_td="class=\"__qbpwcf_border\"";
|
|
|
3446 |
|
| 226 |
liveuser |
3447 |
}#else
|
|
|
3448 |
|
| 3 |
liveuser |
3449 |
#table row group => tbody
|
|
|
3450 |
$tableRowGroup="<div style=\"display:table-row-group;\" ".$table_body." qbpwcfAttr=\"tbody\"></div>";
|
| 226 |
liveuser |
3451 |
|
| 3 |
liveuser |
3452 |
#串接空的tbody
|
|
|
3453 |
$result["content"]=$result["content"].$tableRowGroup;
|
|
|
3454 |
|
|
|
3455 |
#table row => tr
|
|
|
3456 |
$tableRow="<div style=\"display:table-row\" ".$table_body_tr." ></div>";
|
| 226 |
liveuser |
3457 |
|
| 3 |
liveuser |
3458 |
#table cell => td
|
|
|
3459 |
$tableCell="<div style=\"display:table-cell\" ".$table_body_tr_td." ></div>";
|
|
|
3460 |
|
|
|
3461 |
#div表格結束
|
|
|
3462 |
$result["content"]=$result["content"]."</div>";
|
| 226 |
liveuser |
3463 |
|
| 3 |
liveuser |
3464 |
#最外層用div包住
|
|
|
3465 |
$result["content"]="<div id=\"".$result["argued"]["id.table"]."_outer_div\">".$result["content"]."</div>";
|
|
|
3466 |
|
|
|
3467 |
#javaScript to get data
|
|
|
3468 |
#函式說明:
|
|
|
3469 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
3470 |
#回傳結果:
|
|
|
3471 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
3472 |
#$result["error"],錯誤訊息陣列
|
|
|
3473 |
#$result["function"],當前執行的函數名稱
|
|
|
3474 |
#$result["content"],要執行的javaScript語法
|
|
|
3475 |
#必填參數:
|
|
|
3476 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
3477 |
$conf["javaScript::toScript"]["script"]=
|
|
|
3478 |
"
|
|
|
3479 |
//抓取表格
|
|
|
3480 |
var ".$result["argued"]["id.table"]."=document.getElementById('".$result["argued"]["id.table"]."');
|
| 226 |
liveuser |
3481 |
|
| 3 |
liveuser |
3482 |
//抓取初始資料
|
|
|
3483 |
/*
|
|
|
3484 |
設置 window.qbpwcf.ajax 函數
|
|
|
3485 |
說明:
|
|
|
3486 |
傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.
|
|
|
3487 |
參數:
|
|
|
3488 |
params={};
|
|
|
3489 |
params.method='POST' or 'GET';
|
|
|
3490 |
params.headers={name:value};
|
|
|
3491 |
params.url='url to request';
|
|
|
3492 |
params.resType='json';
|
|
|
3493 |
params.preAc='function name to call before send request';
|
|
|
3494 |
params.aftAc='function name to call after send request';
|
|
|
3495 |
params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};
|
|
|
3496 |
*/
|
|
|
3497 |
params={};
|
|
|
3498 |
params.table=".$result["argued"]["id.table"].";
|
|
|
3499 |
params.method='POST';
|
|
|
3500 |
params.url='".$conf["dataUrl"]."';
|
|
|
3501 |
params.resType='json';
|
|
|
3502 |
params.preAc=function(){
|
| 226 |
liveuser |
3503 |
|
| 3 |
liveuser |
3504 |
//取得 tbody
|
|
|
3505 |
var tbody=params.table.querySelector('div[qbpwcfAttr=tbody]');
|
| 226 |
liveuser |
3506 |
|
| 3 |
liveuser |
3507 |
//清空表單內容
|
|
|
3508 |
tbody.innerHTML='';
|
| 226 |
liveuser |
3509 |
|
| 3 |
liveuser |
3510 |
//建立處理中的div
|
|
|
3511 |
var div=document.createElement('div');
|
|
|
3512 |
div.style.display='table-row';
|
| 226 |
liveuser |
3513 |
|
| 3 |
liveuser |
3514 |
//顯示處理中
|
|
|
3515 |
div.innerText='Processing...';
|
|
|
3516 |
tbody.appendChild(div);
|
| 226 |
liveuser |
3517 |
|
| 3 |
liveuser |
3518 |
}
|
|
|
3519 |
params.aftAc=function(res){
|
| 226 |
liveuser |
3520 |
|
| 207 |
liveuser |
3521 |
//如果沒有meta資料
|
|
|
3522 |
if(res===null){
|
| 226 |
liveuser |
3523 |
|
| 3 |
liveuser |
3524 |
//提示錯誤訊息
|
| 207 |
liveuser |
3525 |
console.error('no response data');
|
| 226 |
liveuser |
3526 |
|
| 207 |
liveuser |
3527 |
//結束執行
|
|
|
3528 |
return false;
|
| 226 |
liveuser |
3529 |
|
| 207 |
liveuser |
3530 |
}//if end
|
| 226 |
liveuser |
3531 |
|
| 207 |
liveuser |
3532 |
//如果沒有meta資料
|
|
|
3533 |
if(res.meta===null){
|
| 226 |
liveuser |
3534 |
|
| 207 |
liveuser |
3535 |
//提示錯誤訊息
|
| 3 |
liveuser |
3536 |
console.error('lost meta data');
|
| 226 |
liveuser |
3537 |
|
| 3 |
liveuser |
3538 |
//結束執行
|
|
|
3539 |
return false;
|
| 226 |
liveuser |
3540 |
|
| 3 |
liveuser |
3541 |
}//if end
|
| 226 |
liveuser |
3542 |
|
| 3 |
liveuser |
3543 |
//取得 tbody
|
|
|
3544 |
var tbody=params.table.querySelector('div[qbpwcfAttr=tbody]');
|
| 226 |
liveuser |
3545 |
|
| 3 |
liveuser |
3546 |
//結束處理中的效果
|
|
|
3547 |
tbody.innerHTML='';
|
| 226 |
liveuser |
3548 |
|
| 3 |
liveuser |
3549 |
//針對每筆資料
|
|
|
3550 |
for(var i=0;i<res.data.length;i++){
|
| 226 |
liveuser |
3551 |
|
| 3 |
liveuser |
3552 |
//解析html tr字串
|
|
|
3553 |
var parser = new DOMParser();
|
|
|
3554 |
var divTr = parser.parseFromString('".$tableRow."', 'text/html');
|
|
|
3555 |
divTr = divTr.children[0].children[1].children[0];
|
| 226 |
liveuser |
3556 |
|
| 3 |
liveuser |
3557 |
//初始化儲存class的字串
|
|
|
3558 |
var classStr='';
|
| 226 |
liveuser |
3559 |
|
| 3 |
liveuser |
3560 |
//針對tr每個既有的class
|
|
|
3561 |
for(var j=0;j<divTr.classList.length;j++){
|
| 226 |
liveuser |
3562 |
|
| 3 |
liveuser |
3563 |
//串接class
|
|
|
3564 |
classStr=classStr+divTr.classList[j];
|
| 226 |
liveuser |
3565 |
|
| 3 |
liveuser |
3566 |
}//for edn
|
| 226 |
liveuser |
3567 |
|
| 3 |
liveuser |
3568 |
//如果是奇數欄位
|
| 200 |
liveuser |
3569 |
if(i%2===1){
|
| 226 |
liveuser |
3570 |
|
| 3 |
liveuser |
3571 |
//套用 __qbpwcf_odd class
|
|
|
3572 |
divTr.className=classStr+' ".$table_body_tr_odd."';
|
| 226 |
liveuser |
3573 |
|
| 3 |
liveuser |
3574 |
}//if end
|
|
|
3575 |
|
|
|
3576 |
//反之是偶數欄位
|
|
|
3577 |
else{
|
| 226 |
liveuser |
3578 |
|
| 3 |
liveuser |
3579 |
//套用 __qbpwcf_even
|
|
|
3580 |
divTr.className=classStr+' ".$table_body_tr_even."';
|
| 226 |
liveuser |
3581 |
|
| 3 |
liveuser |
3582 |
}//else end
|
| 226 |
liveuser |
3583 |
|
| 3 |
liveuser |
3584 |
//針對每個欄位
|
|
|
3585 |
for(var j=0;j<res.data[i].length;j++){
|
| 226 |
liveuser |
3586 |
|
| 3 |
liveuser |
3587 |
//解析html td字串
|
|
|
3588 |
var parser = new DOMParser();
|
|
|
3589 |
var divTd = parser.parseFromString('".$tableCell."', 'text/html');
|
| 200 |
liveuser |
3590 |
divTd = divTd.children[0].children[1].children[0];
|
| 226 |
liveuser |
3591 |
|
| 3 |
liveuser |
3592 |
//放置內容
|
|
|
3593 |
divTd.innerHTML=res.data[i][j];
|
| 226 |
liveuser |
3594 |
|
| 3 |
liveuser |
3595 |
//放置 td
|
|
|
3596 |
divTr.appendChild(divTd);
|
| 226 |
liveuser |
3597 |
|
| 3 |
liveuser |
3598 |
}//for end
|
| 226 |
liveuser |
3599 |
|
| 3 |
liveuser |
3600 |
//放置 tr
|
|
|
3601 |
tbody.appendChild(divTr);
|
| 226 |
liveuser |
3602 |
|
| 3 |
liveuser |
3603 |
}//for end
|
| 226 |
liveuser |
3604 |
|
| 3 |
liveuser |
3605 |
//如果已經有 表格下方的root div,
|
|
|
3606 |
if(document.getElementById('".$result["argued"]["id.table"]."-rootBottomDiv')!==null){
|
| 226 |
liveuser |
3607 |
|
| 3 |
liveuser |
3608 |
//移除之
|
|
|
3609 |
document.getElementById('".$result["argued"]["id.table"]."-rootBottomDiv').remove();
|
| 226 |
liveuser |
3610 |
|
| 3 |
liveuser |
3611 |
}//if end
|
| 226 |
liveuser |
3612 |
|
| 3 |
liveuser |
3613 |
//表格下方的root div
|
|
|
3614 |
var rootBottomDiv=document.createElement('div');
|
|
|
3615 |
rootBottomDiv.id='".$result["argued"]["id.table"]."-rootBottomDiv';
|
|
|
3616 |
rootBottomDiv.style.margin='auto';
|
|
|
3617 |
rootBottomDiv.style.fontSize='1.8em';
|
|
|
3618 |
rootBottomDiv.style.width=getComputedStyle(document.getElementById('".$result["argued"]["id.table"]."')).width;
|
| 226 |
liveuser |
3619 |
|
| 3 |
liveuser |
3620 |
//當畫面寬度變動的時候
|
|
|
3621 |
window.addEventListener('resize', function(e){
|
| 226 |
liveuser |
3622 |
|
| 3 |
liveuser |
3623 |
//重新套用頁尾資訊寬度
|
|
|
3624 |
rootBottomDiv.style.width=getComputedStyle(document.getElementById('".$result["argued"]["id.table"]."')).width;
|
| 226 |
liveuser |
3625 |
|
| 3 |
liveuser |
3626 |
});
|
| 226 |
liveuser |
3627 |
|
| 3 |
liveuser |
3628 |
//取得第幾頁
|
|
|
3629 |
var pageNumber=res.meta.pageNumber;
|
| 226 |
liveuser |
3630 |
|
| 3 |
liveuser |
3631 |
//取得一頁的資料上限
|
|
|
3632 |
var numberPerPage=res.meta.numberPerPage;
|
| 226 |
liveuser |
3633 |
|
| 3 |
liveuser |
3634 |
//取得該頁筆數
|
| 226 |
liveuser |
3635 |
var currentNumber=res.meta.currentNumber;
|
|
|
3636 |
|
| 3 |
liveuser |
3637 |
//取得總共資料筆數
|
| 226 |
liveuser |
3638 |
var total=res.meta.total;
|
|
|
3639 |
|
| 3 |
liveuser |
3640 |
//資料開始點
|
|
|
3641 |
var startPoint=(parseInt(pageNumber)-1)*parseInt(numberPerPage)+1;
|
| 226 |
liveuser |
3642 |
|
| 3 |
liveuser |
3643 |
//資料結束點
|
|
|
3644 |
var endPoint=(parseInt(pageNumber)-1)*parseInt(numberPerPage)+(parseInt(currentNumber));
|
| 226 |
liveuser |
3645 |
|
| 3 |
liveuser |
3646 |
//描述資料狀況
|
|
|
3647 |
var desc=startPoint+'~'+endPoint+'/'+total;
|
|
|
3648 |
descDiv=document.createElement('div');
|
|
|
3649 |
descDiv.style.display='inline';
|
|
|
3650 |
descDiv.innerText=desc;
|
| 226 |
liveuser |
3651 |
|
| 3 |
liveuser |
3652 |
//換頁按鈕區塊
|
|
|
3653 |
var changePageDiv=document.createElement('div');
|
|
|
3654 |
changePageDiv.style.display='inline';
|
|
|
3655 |
changePageDiv.style.float='right';
|
| 226 |
liveuser |
3656 |
|
| 3 |
liveuser |
3657 |
//換前頁的區塊
|
|
|
3658 |
var prePageDiv=document.createElement('div');
|
|
|
3659 |
prePageDiv.style.display='inline';
|
|
|
3660 |
var prePageA=document.createElement('a');
|
|
|
3661 |
prePageA.style.cursor='pointer';
|
|
|
3662 |
prePageA.innerHTML='←';
|
|
|
3663 |
prePageA.pageNumber=pageNumber;
|
|
|
3664 |
prePageA.params=params;
|
|
|
3665 |
prePageA.addEventListener('click',function(e){
|
| 226 |
liveuser |
3666 |
|
| 3 |
liveuser |
3667 |
//如果當前頁碼大於等於2
|
|
|
3668 |
if(prePageA.pageNumber>=2){
|
| 226 |
liveuser |
3669 |
|
| 3 |
liveuser |
3670 |
//頁碼減少一
|
|
|
3671 |
prePageA.pageNumber--;
|
| 226 |
liveuser |
3672 |
|
| 3 |
liveuser |
3673 |
}//if end
|
| 226 |
liveuser |
3674 |
|
| 3 |
liveuser |
3675 |
//更新要求的頁碼
|
|
|
3676 |
prePageA.params.data='pageNumber='+encodeURIComponent(prePageA.pageNumber);
|
| 226 |
liveuser |
3677 |
|
| 3 |
liveuser |
3678 |
//遞迴呼叫
|
|
|
3679 |
return window.qbpwcf.ajax.call(this,prePageA.params);
|
| 226 |
liveuser |
3680 |
|
| 3 |
liveuser |
3681 |
});
|
|
|
3682 |
prePageDiv.appendChild(prePageA);
|
| 226 |
liveuser |
3683 |
|
| 3 |
liveuser |
3684 |
//換後頁的區塊
|
|
|
3685 |
var nextPageDiv=document.createElement('div');
|
|
|
3686 |
nextPageDiv.style.display='inline';
|
|
|
3687 |
var nextPageA=document.createElement('a');
|
|
|
3688 |
nextPageA.style.cursor='pointer';
|
|
|
3689 |
nextPageA.innerHTML='→';
|
|
|
3690 |
nextPageA.pageNumber=pageNumber;
|
|
|
3691 |
nextPageA.params=params;
|
|
|
3692 |
nextPageA.addEventListener('click',function(e){
|
| 226 |
liveuser |
3693 |
|
| 3 |
liveuser |
3694 |
//新增頁碼
|
|
|
3695 |
nextPageA.pageNumber++;
|
| 226 |
liveuser |
3696 |
|
| 3 |
liveuser |
3697 |
//更新要求的頁碼
|
|
|
3698 |
nextPageA.params.data='pageNumber='+encodeURIComponent(nextPageA.pageNumber);
|
| 226 |
liveuser |
3699 |
|
| 3 |
liveuser |
3700 |
//遞迴呼叫
|
|
|
3701 |
return window.qbpwcf.ajax.call(this,nextPageA.params);
|
| 226 |
liveuser |
3702 |
|
| 3 |
liveuser |
3703 |
});
|
|
|
3704 |
nextPageDiv.appendChild(nextPageA);
|
| 226 |
liveuser |
3705 |
|
| 3 |
liveuser |
3706 |
//放置上一頁與下一頁的link
|
| 207 |
liveuser |
3707 |
changePageDiv.appendChild(prePageDiv);
|
| 3 |
liveuser |
3708 |
changePageDiv.appendChild(nextPageDiv);
|
| 226 |
liveuser |
3709 |
|
| 3 |
liveuser |
3710 |
//放置資料描述
|
|
|
3711 |
rootBottomDiv.appendChild(descDiv);
|
| 226 |
liveuser |
3712 |
|
| 3 |
liveuser |
3713 |
//放置換頁區塊
|
|
|
3714 |
rootBottomDiv.appendChild(changePageDiv);
|
| 226 |
liveuser |
3715 |
|
| 3 |
liveuser |
3716 |
//放置表格下方的root div
|
|
|
3717 |
params.table.parentNode.appendChild(rootBottomDiv);
|
| 226 |
liveuser |
3718 |
|
| 3 |
liveuser |
3719 |
}
|
|
|
3720 |
params.data='pageNumber='+encodeURIComponent(1);
|
|
|
3721 |
window.qbpwcf.ajax.call(this,params);
|
| 226 |
liveuser |
3722 |
|
| 3 |
liveuser |
3723 |
";
|
|
|
3724 |
#可省略參數:
|
|
|
3725 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
3726 |
#$conf["onReady"]="true";
|
|
|
3727 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
3728 |
#$conf["globalJs"]=array();
|
|
|
3729 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
3730 |
#$conf["jsFunciton"]=array();
|
|
|
3731 |
#參考資料:
|
|
|
3732 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
3733 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
3734 |
unset($conf["javaScript::toScript"]);
|
|
|
3735 |
|
|
|
3736 |
#如果執行失敗
|
|
|
3737 |
if($toScript["status"]==="false"){
|
|
|
3738 |
|
|
|
3739 |
#設置執行錯誤識別
|
|
|
3740 |
$result["status"]="false";
|
|
|
3741 |
|
|
|
3742 |
#設置錯誤訊息
|
|
|
3743 |
$result["error"]=$toScript;
|
|
|
3744 |
|
|
|
3745 |
#回傳結果
|
|
|
3746 |
return $result;
|
|
|
3747 |
|
|
|
3748 |
}#if end
|
| 226 |
liveuser |
3749 |
|
| 3 |
liveuser |
3750 |
#串接js語法
|
|
|
3751 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
3752 |
|
|
|
3753 |
#設定執行正常
|
|
|
3754 |
$result["status"]="true";
|
|
|
3755 |
|
|
|
3756 |
#回傳結果
|
|
|
3757 |
return $result;
|
| 226 |
liveuser |
3758 |
|
| 3 |
liveuser |
3759 |
}#function divAjax end
|
|
|
3760 |
|
|
|
3761 |
/*
|
|
|
3762 |
#函式說明:
|
| 207 |
liveuser |
3763 |
#接收 funciton divAjax 的 ajax 要求,轉換成SQL語法.
|
|
|
3764 |
#回傳結果:
|
|
|
3765 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3766 |
#$result["error"],錯誤訊息.
|
|
|
3767 |
#$result["function"],當前執行的函數名稱.
|
|
|
3768 |
#$result["content"],json for table::divAjax.
|
|
|
3769 |
#$result["argu"],使用的參數.
|
|
|
3770 |
#必填參數:
|
|
|
3771 |
#$conf["mainTable"],字串,主資料表名稱.
|
|
|
3772 |
$conf["mainTable"]="";
|
|
|
3773 |
#$conf["columnYouWant"],字串陣列,為想要的資料表欄位,格式為 "dbName.dtName.colName".
|
|
|
3774 |
$conf["columnYouWant"]=array($dbName.".".$conf["mainTable"]."."."id");
|
|
|
3775 |
#可省略參數:
|
|
|
3776 |
#$conf["dbAddress"],字串,爲mysql-Server的位置,預設為$dbAddress.
|
|
|
3777 |
#$conf["dbAddress"]=$dbAddress;
|
|
|
3778 |
#$conf["dbAccount"],字串,爲用於連入mysql-Server時要使用的帳號,預設為$dbAccount.
|
|
|
3779 |
#$conf["dbAccount"]=$dbAccount;
|
|
|
3780 |
#$conf["dbName"],字串,爲要連的資料庫名稱,預設為$dbName.
|
|
|
3781 |
#$conf["dbName"]=$dbName;
|
|
|
3782 |
#$conf["dbPassword"],字串,爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼,預設為$dbPassword.
|
|
|
3783 |
#$conf["dbPassword"]=$dbPassword;
|
|
|
3784 |
#$conf["dbPort"],字串,為連線到mysql-Server時對應的port,可省略,預設為$dbPort.
|
|
|
3785 |
#$conf["dbPort"]=$dbPort;
|
|
|
3786 |
#$conf["numberPerPage"],每頁的資料上限,設為"30",
|
|
|
3787 |
#$conf["numberPerPage"]="30";
|
|
|
3788 |
#$conf["mainDtWhereColName"],字串陣列,用於主表判斷語句的欄位項目陣列.
|
|
|
3789 |
#$conf["mainDtWhereColName"]=array("");
|
|
|
3790 |
#$conf["mainDtWhereColVal"]=,字串陣列,用於主表判斷語句的欄位項目數值陣列,若與LIKE搭配,則可以在關鍵自字串的左右名加上「%」符號,這樣就可以搜尋具有該字串的內容.
|
|
|
3791 |
#$conf["mainDtWhereColVal"]=array("");
|
|
|
3792 |
#$conf["mainDtWhereColCombine"],字串陣列,用於主表判斷語句當中需要()起來的判斷式,須爲陣列值,"s"代表「(」,"e"代表「)」 ,若無則須設爲""。
|
|
|
3793 |
#$conf["mainDtWhereColCombine"]=array("");
|
|
|
3794 |
#$conf["mainWhereColumnOperator"],字串陣列,用於判斷語句的比較符號陣列,可以用的符號有「"="、">"、"<"、"LIKE"、"NOT LIKE"」,預設都爲「=」。
|
|
|
3795 |
#$conf["mainWhereColumnOperator"]=array("");
|
|
|
3796 |
#$conf["mainWhereColumnAndOr"],字串陣列,用於判斷語句條件之間成立的條件是AND還是OR,須爲陣列值。其數量應爲要判斷的欄位數量減一。
|
|
|
3797 |
#$conf["mainWhereColumnAndOr"]=array("");
|
|
|
3798 |
#$conf["mainWhereIn"],字串陣列,為每個in語句的內容,特定欄位數值等於陣列元素之一。array(array("colName",array("a","b","c")));代表欄位colName的值為a,b,c三者之一.
|
|
|
3799 |
#$conf["mainWhereIn"]=array(array("colName",array("a","b","c")));
|
|
|
3800 |
#$conf["mainWhereNotIn"],字串陣列,為每個not in語句的內容,array(array("colName",array("a","b","c")));代表欄位colName的值不為a,b,c三者之一.
|
|
|
3801 |
#$conf["mainWhereNotIn"]=array(array("colName",array("a","b","c")));
|
|
|
3802 |
#$conf["mainGroupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
|
|
|
3803 |
#$conf["mainGroupBy"]=array();
|
|
|
3804 |
#$conf["mainOrderItem"],字串,組好的資料的排序項目依據
|
|
|
3805 |
#$conf["mainOrderItem"]="";
|
|
|
3806 |
#$conf["mainAscORdesc"],字串,組好的資料要低增還是遞減排序,asc爲遞增;desc爲遞減,預設不做處理.
|
|
|
3807 |
#$conf["mainAscORdesc"]="";
|
|
|
3808 |
#參考資料:
|
|
|
3809 |
#https://www.w3.org/Style/css2-updates/css2/tables.html
|
|
|
3810 |
#備註:
|
|
|
3811 |
#無.
|
|
|
3812 |
*/
|
|
|
3813 |
public static function divAjaxRes(&$conf){
|
| 226 |
liveuser |
3814 |
|
| 207 |
liveuser |
3815 |
#初始化要回傳的變數
|
|
|
3816 |
$result=array();
|
|
|
3817 |
|
|
|
3818 |
#記錄當前執行的函數名稱
|
|
|
3819 |
$result["function"]=__FUNCTION__;
|
|
|
3820 |
|
|
|
3821 |
#初始化表格的html語法
|
|
|
3822 |
$result["content"]="";
|
|
|
3823 |
|
|
|
3824 |
#如果 $conf 不為陣列
|
|
|
3825 |
if(gettype($conf)!="array"){
|
|
|
3826 |
|
|
|
3827 |
#設置執行失敗
|
|
|
3828 |
$result["status"]="false";
|
|
|
3829 |
|
|
|
3830 |
#設置執行錯誤訊息
|
|
|
3831 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
3832 |
|
|
|
3833 |
#如果傳入的參數為 null
|
|
|
3834 |
if($conf==null){
|
|
|
3835 |
|
|
|
3836 |
#設置執行錯誤訊息
|
|
|
3837 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
3838 |
|
|
|
3839 |
}#if end
|
|
|
3840 |
|
|
|
3841 |
#回傳結果
|
|
|
3842 |
return $result;
|
|
|
3843 |
|
|
|
3844 |
}#if end
|
| 226 |
liveuser |
3845 |
|
| 207 |
liveuser |
3846 |
#取得使用的參數
|
|
|
3847 |
$result["argu"]=$conf;
|
| 226 |
liveuser |
3848 |
|
| 207 |
liveuser |
3849 |
#檢查參數
|
|
|
3850 |
#函式說明:
|
|
|
3851 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
|
|
|
3852 |
#回傳結果:
|
|
|
3853 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3854 |
#$result["error"],執行不正常結束的錯訊息陣列.
|
|
|
3855 |
#$result["simpleError"],簡單表示的錯誤訊息.
|
|
|
3856 |
#$result["function"],當前執行的函式名稱.
|
|
|
3857 |
#$result["argu"],設置給予的參數.
|
|
|
3858 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
3859 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
3860 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
3861 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
3862 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
3863 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
3864 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
3865 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
3866 |
#必填參數:
|
|
|
3867 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
3868 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
3869 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
3870 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
3871 |
#可省略參數:
|
|
|
3872 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
3873 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("mainTable","columnYouWant");
|
|
|
3874 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
|
|
|
3875 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
3876 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
3877 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
3878 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
3879 |
#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("numberPerPage");
|
|
|
3880 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
3881 |
#$conf["canBeEmpty"]=array();
|
|
|
3882 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
3883 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("numberPerPage","dbAddress","dbAccount","dbName","dbPassword","dbPort");
|
|
|
3884 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
3885 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("numberPerPage","dbAddress","dbAccount","dbName","dbPassword","dbPort","mainDtWhereColName","mainDtWhereColVal","mainDtWhereColCombine","mainWhereColumnOperator","mainWhereColumnAndOr","mainWhereIn","mainWhereNotIn","mainNumberStart","mainNumLimit","mainGroupBy","mainOrderItem","mainAscORdesc");
|
|
|
3886 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
3887 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","array","array","array","array","array","array","array","array","array","array","array","array");
|
|
|
3888 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
3889 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("30",$dbAddress,$dbAccount,$dbName,$dbPassword,$dbPort,null,null,null,null,null,null,null,null,null,null,null,null);
|
|
|
3890 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
3891 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
3892 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
3893 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
3894 |
#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
|
|
|
3895 |
#$conf["disallowAllSkipableVarNotExist"]="";
|
|
|
3896 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
3897 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
3898 |
#參考資料:
|
|
|
3899 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
3900 |
#備註:
|
|
|
3901 |
#無.
|
|
|
3902 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
3903 |
unset($conf["variableCheck::checkArguments"]);
|
| 226 |
liveuser |
3904 |
|
| 207 |
liveuser |
3905 |
#如果檢查失敗
|
|
|
3906 |
if($checkArguments["status"]=="false"){
|
|
|
3907 |
|
|
|
3908 |
#設置執行不正常
|
|
|
3909 |
$result["status"]="false";
|
|
|
3910 |
|
|
|
3911 |
#設置錯誤訊息
|
|
|
3912 |
$result["error"]=$checkArguments;
|
|
|
3913 |
|
|
|
3914 |
#回傳結果
|
|
|
3915 |
return $result;
|
|
|
3916 |
|
|
|
3917 |
}#if end
|
|
|
3918 |
|
|
|
3919 |
#如果檢查不通過
|
|
|
3920 |
if($checkArguments["passed"]=="false"){
|
|
|
3921 |
|
|
|
3922 |
#設置執行不正常
|
|
|
3923 |
$result["status"]="false";
|
|
|
3924 |
|
|
|
3925 |
#設置錯誤訊息
|
|
|
3926 |
$result["error"]=$checkArguments;
|
|
|
3927 |
|
|
|
3928 |
#回傳結果
|
|
|
3929 |
return $result;
|
|
|
3930 |
|
|
|
3931 |
}#if end
|
| 226 |
liveuser |
3932 |
|
| 207 |
liveuser |
3933 |
#函式說明:
|
|
|
3934 |
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
|
|
|
3935 |
#回傳結果:
|
|
|
3936 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
3937 |
#$result["error"],錯誤訊息陣列.
|
|
|
3938 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
3939 |
#$result["warning"],警告訊息陣列.
|
|
|
3940 |
#$result["passed"],是否有皆收到全部該接收到的變數,若有設定$conf["checkedVarName"]的話,執行正常後會回傳該結果。
|
|
|
3941 |
#$result["lostVarName"],沒有皆收到的變數名稱陣列
|
|
|
3942 |
#$result["inputDataContent"],所接收的參數陣列.
|
|
|
3943 |
#$result["inputDataContent"]["變數名稱"],所接收變數的內容.
|
|
|
3944 |
#$result["inputDataCount"],從表單總共接收到幾個元素.
|
|
|
3945 |
#$result["HTTP_REFERER"],前一頁的網址,null代表不存在.
|
|
|
3946 |
#必填參數:
|
|
|
3947 |
#$conf["method"],字串,傳送過來的資料是用"post/POST"還是"get/GET"?
|
|
|
3948 |
$conf["form::responseMultiInputDataSecurityEnhance"]["method"]="post";
|
|
|
3949 |
#可省略參數:
|
|
|
3950 |
#$conf["allowGet"],字串,是否要允許 get 傳值,"true",代表允許;"false" ,代表不允許,預設爲不允許.
|
|
|
3951 |
#$conf["allowGet"]="true";
|
|
|
3952 |
#$conf["limitPrePage"],字串陣列,是否要限定前一頁的網址為哪些,才能接收內容,不符合則轉址.
|
|
|
3953 |
$conf["form::responseMultiInputDataSecurityEnhance"]["limitPrePage"]=array("table::divAjax.php");
|
|
|
3954 |
#$conf["transferLocation"],字串,遇到get傳值,或前一個頁面不符合要求時要轉址到的頁面,預設爲資安素養網"https://isafe.moe.edu.tw/"
|
|
|
3955 |
#$conf["transferLocation"]="";
|
|
|
3956 |
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
|
|
|
3957 |
#$conf["ignore"]=array();
|
|
|
3958 |
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
|
|
|
3959 |
#$conf["correctCharacter"]="false";
|
|
|
3960 |
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
|
|
|
3961 |
$conf["form::responseMultiInputDataSecurityEnhance"]["checkedVarName"]=array("pageNumber");
|
|
|
3962 |
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
|
|
|
3963 |
#$conf["canBeEmptyString"]="false";
|
|
|
3964 |
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
|
|
|
3965 |
#$conf["sessionNameArray"]=array();
|
|
|
3966 |
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,預設為"false"代表不要卸除.
|
|
|
3967 |
#$conf["unsetSessionArray"]=array();
|
|
|
3968 |
#參考資料:
|
|
|
3969 |
#foreach 的用法 -> http://php.net/manual/en/control-structures.foreach.php
|
|
|
3970 |
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
|
|
|
3971 |
#備註:
|
|
|
3972 |
#表單變數的名稱若含有「.」,則會變成「-」。
|
|
|
3973 |
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf["form::responseMultiInputDataSecurityEnhance"]);
|
|
|
3974 |
unset($conf["form::responseMultiInputDataSecurityEnhance"]);
|
| 226 |
liveuser |
3975 |
|
| 207 |
liveuser |
3976 |
#如果執行異常
|
|
|
3977 |
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
|
| 226 |
liveuser |
3978 |
|
| 207 |
liveuser |
3979 |
#設置執行異常識別
|
|
|
3980 |
$result["status"]="false";
|
| 226 |
liveuser |
3981 |
|
|
|
3982 |
#設置執行錯誤
|
| 207 |
liveuser |
3983 |
$result["error"]=$responseMultiInputDataSecurityEnhance;
|
| 226 |
liveuser |
3984 |
|
| 207 |
liveuser |
3985 |
#回傳結果
|
|
|
3986 |
return $result;
|
| 226 |
liveuser |
3987 |
|
| 207 |
liveuser |
3988 |
}#if end
|
| 226 |
liveuser |
3989 |
|
| 207 |
liveuser |
3990 |
#如果檢查不通過
|
|
|
3991 |
if($responseMultiInputDataSecurityEnhance["passed"]==="false"){
|
| 226 |
liveuser |
3992 |
|
| 207 |
liveuser |
3993 |
#設置執行異常識別
|
|
|
3994 |
$result["status"]="false";
|
| 226 |
liveuser |
3995 |
|
|
|
3996 |
#設置執行錯誤
|
| 207 |
liveuser |
3997 |
$result["error"]=$responseMultiInputDataSecurityEnhance;
|
| 226 |
liveuser |
3998 |
|
| 207 |
liveuser |
3999 |
#回傳結果
|
|
|
4000 |
return $result;
|
| 226 |
liveuser |
4001 |
|
| 207 |
liveuser |
4002 |
}#if end
|
| 226 |
liveuser |
4003 |
|
| 207 |
liveuser |
4004 |
#取得當前頁面
|
|
|
4005 |
$pageNumber=$responseMultiInputDataSecurityEnhance["inputDataContent"]["pageNumber"];
|
| 226 |
liveuser |
4006 |
|
| 207 |
liveuser |
4007 |
#函式說明:
|
|
|
4008 |
#透過php來join多張資料表資料,提供各個欄位的包含資料庫、資料表、的資訊,會產生sql inner join的效果,資料會越來越多.
|
|
|
4009 |
#回傳結果:
|
|
|
4010 |
#$result["status"],執行結果"true"為成功;"false"為執行失敗。
|
|
|
4011 |
#$result["error"],錯誤訊息陣列。
|
|
|
4012 |
#$reuslt["function"],當前執行的函數
|
|
|
4013 |
#$result["content"],爲合併了子資料表欄位的父資料表的內容。
|
|
|
4014 |
#$result["content"][$conf["WhereColumnName"][$i]][$dataSetNum]
|
|
|
4015 |
#$dataSetNum 爲第$dataSetNum+1筆資料
|
|
|
4016 |
#$conf["WhereColumnName"][$i] 爲第 $i+1 個欄位的名稱
|
|
|
4017 |
#$result["parentTable"]["dataCount"],爲取得的資料筆數。
|
|
|
4018 |
#必填參數:
|
|
|
4019 |
#$conf["dbInfo"]["資料庫名稱"],字串陣列,爲要存取的"資料庫名稱"的連線資訊.
|
|
|
4020 |
#$conf["dbIfno"]["資料庫名稱"]["dbAddr"],字串,dbServer的位置.
|
|
|
4021 |
$conf["db::joinByPHP"]["dbInfo"][$conf["dbName"]]["dbAddr"]=$conf["dbAddress"];
|
|
|
4022 |
#$conf["dbIfno"]["資料庫名稱"]["dbAcct"],字串,dbServer的連線帳號.
|
|
|
4023 |
$conf["db::joinByPHP"]["dbInfo"][$conf["dbName"]]["dbAcct"]=$conf["dbAccount"];
|
|
|
4024 |
#$conf["mainTable"],字串,為 主資料庫.資料表 的名稱,例如 "dbA.dtA".
|
|
|
4025 |
$conf["db::joinByPHP"]["mainTable"]=$conf["mainTable"];
|
|
|
4026 |
#可省略參數:
|
|
|
4027 |
#$conf["linkColumnName"],二字串陣列,為資料表間相連結的欄位名稱,格式為 array("mergedDb.mergedDt.mergedCol","linkDb.linkDt.linkCol") 就代表當前組好的欄位 mergedDb.mergedDt.mergedCol 跟資料庫 linkDB 表 linkDt 欄位 linkCol 進行資料的配對。
|
|
|
4028 |
#$conf["linkColumnName"]=array(array(""));
|
|
|
4029 |
#$conf["dbInfo"]["資料庫名稱"]["dbPass"],字串,dbServer的連線密碼.
|
|
|
4030 |
$conf["db::joinByPHP"]["dbInfo"][$conf["dbName"]]["dbPass"]=$dbPassword;
|
|
|
4031 |
#$conf["dbInfo"]["資料庫名稱"]["dbPort"],字串,db連線用的port.
|
|
|
4032 |
$conf["db::joinByPHP"]["dbInfo"][$conf["dbName"]]["dbPort"]=$dbPort;
|
|
|
4033 |
#$conf["columnYouWant"],字串陣列,為想要的資料表欄位,格式為 "dbName.dtName.colName".
|
|
|
4034 |
$conf["db::joinByPHP"]["columnYouWant"]=$conf["columnYouWant"];
|
| 226 |
liveuser |
4035 |
|
| 207 |
liveuser |
4036 |
#如果有參數 $conf["mainDtWhereColName"]
|
|
|
4037 |
if(isset($conf["mainDtWhereColName"])){
|
| 226 |
liveuser |
4038 |
|
| 207 |
liveuser |
4039 |
#$conf["mainDtWhereColName"],字串陣列,用於主表判斷語句的欄位項目陣列.
|
|
|
4040 |
$conf["db::joinByPHP"]["mainDtWhereColName"]=$conf["mainDtWhereColName"];
|
| 226 |
liveuser |
4041 |
|
| 207 |
liveuser |
4042 |
}#if end
|
| 226 |
liveuser |
4043 |
|
| 207 |
liveuser |
4044 |
#如果有參數 $conf["mainDtWhereColName"]
|
|
|
4045 |
if(isset($conf["mainDtWhereColName"])){
|
| 226 |
liveuser |
4046 |
|
| 207 |
liveuser |
4047 |
#$conf["mainDtWhereColVal"]=,字串陣列,用於主表判斷語句的欄位項目數值陣列,若與LIKE搭配,則可以在關鍵自字串的左右名加上「%」符號,這樣就可以搜尋具有該字串的內容.
|
|
|
4048 |
$conf["db::joinByPHP"]["mainDtWhereColVal"]=$conf["mainDtWhereColName"];
|
| 226 |
liveuser |
4049 |
|
| 207 |
liveuser |
4050 |
}#if end
|
| 226 |
liveuser |
4051 |
|
| 207 |
liveuser |
4052 |
#如果有參數 $conf["mainDtWhereColCombine"]
|
|
|
4053 |
if(isset($conf["mainDtWhereColCombine"])){
|
| 226 |
liveuser |
4054 |
|
| 207 |
liveuser |
4055 |
#$conf["mainDtWhereColCombine"],字串陣列,用於主表判斷語句當中需要()起來的判斷式,須爲陣列值,"s"代表「(」,"e"代表「)」 ,若無則須設爲""。
|
|
|
4056 |
$conf["db::joinByPHP"]["mainDtWhereColCombine"]=$conf["mainDtWhereColCombine"];
|
| 226 |
liveuser |
4057 |
|
| 207 |
liveuser |
4058 |
}#if end
|
| 226 |
liveuser |
4059 |
|
| 207 |
liveuser |
4060 |
#如果有參數 $conf["mainWhereColumnOperator"]
|
|
|
4061 |
if(isset($conf["mainWhereColumnOperator"])){
|
| 226 |
liveuser |
4062 |
|
| 207 |
liveuser |
4063 |
#$conf["mainWhereColumnOperator"],字串陣列,用於判斷語句的比較符號陣列,可以用的符號有「"="、">"、"<"、"LIKE"、"NOT LIKE"」,預設都爲「=」。
|
|
|
4064 |
$conf["db::joinByPHP"]["mainWhereColumnOperator"]=$conf["mainWhereColumnOperator"];
|
| 226 |
liveuser |
4065 |
|
| 207 |
liveuser |
4066 |
}#if end
|
| 226 |
liveuser |
4067 |
|
| 207 |
liveuser |
4068 |
#如果有參數 $conf["mainWhereColumnAndOr"]
|
|
|
4069 |
if(isset($conf["mainWhereColumnAndOr"])){
|
| 226 |
liveuser |
4070 |
|
| 207 |
liveuser |
4071 |
#$conf["mainWhereColumnAndOr"],字串陣列,用於判斷語句條件之間成立的條件是AND還是OR,須爲陣列值。其數量應爲要判斷的欄位數量減一。
|
|
|
4072 |
$conf["db::joinByPHP"]["mainWhereColumnAndOr"]=$conf["mainWhereColumnAndOr"];
|
| 226 |
liveuser |
4073 |
|
| 207 |
liveuser |
4074 |
}#if end
|
| 226 |
liveuser |
4075 |
|
|
|
4076 |
|
| 207 |
liveuser |
4077 |
#如果有參數 $conf["mainWhereIn"]
|
|
|
4078 |
if(isset($conf["mainWhereIn"])){
|
| 226 |
liveuser |
4079 |
|
| 207 |
liveuser |
4080 |
#$conf["mainWhereIn"],字串陣列,為每個in語句的內容,特定欄位數值等於陣列元素之一。array(array("colName",array("a","b","c")));代表欄位colName的值為a,b,c三者之一.
|
|
|
4081 |
$conf["db::joinByPHP"]["mainWhereIn"]=$conf["mainWhereIn"];
|
| 226 |
liveuser |
4082 |
|
| 207 |
liveuser |
4083 |
}#if end
|
| 226 |
liveuser |
4084 |
|
| 207 |
liveuser |
4085 |
#如果有參數 $conf["mainWhereNotIn"]
|
|
|
4086 |
if(isset($conf["mainWhereNotIn"])){
|
| 226 |
liveuser |
4087 |
|
| 207 |
liveuser |
4088 |
#$conf["mainWhereNotIn"],字串陣列,為每個not in語句的內容,array(array("colName",array("a","b","c")));代表欄位colName的值不為a,b,c三者之一.
|
|
|
4089 |
$conf["db::joinByPHP"]["mainWhereNotIn"]=$conf["mainWhereNotIn"];
|
| 226 |
liveuser |
4090 |
|
| 207 |
liveuser |
4091 |
}#if end
|
| 226 |
liveuser |
4092 |
|
| 207 |
liveuser |
4093 |
#$conf["mainNumberStart"],字串,從第幾筆開始讀取,預設為"0",代筆第一筆.
|
|
|
4094 |
$conf["db::joinByPHP"]["mainNumberStart"]="".(30*$pageNumber-1);
|
|
|
4095 |
#$conf["mainNumLimit"],字串,要取幾筆資料,可以省略,省略則表示不限制數目.
|
|
|
4096 |
$conf["db::joinByPHP"]["mainNumLimit"]=$conf["numberPerPage"];
|
| 226 |
liveuser |
4097 |
|
| 207 |
liveuser |
4098 |
#如果有參數 $conf["mainGroupBy"]
|
|
|
4099 |
if(isset($conf["mainGroupBy"])){
|
| 226 |
liveuser |
4100 |
|
| 207 |
liveuser |
4101 |
#$conf["mainGroupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
|
|
|
4102 |
$conf["db::joinByPHP"]["mainGroupBy"]=$conf["mainGroupBy"];
|
| 226 |
liveuser |
4103 |
|
| 207 |
liveuser |
4104 |
}#if end
|
| 226 |
liveuser |
4105 |
|
| 207 |
liveuser |
4106 |
#如果有參數 $conf["mainOrderItem"]
|
|
|
4107 |
if(isset($conf["mainOrderItem"])){
|
| 226 |
liveuser |
4108 |
|
| 207 |
liveuser |
4109 |
#$conf["mainOrderItem"],字串,組好的資料的排序項目依據
|
|
|
4110 |
$conf["db::joinByPHP"]["mainOrderItem"]=$conf["mainOrderItem"];
|
| 226 |
liveuser |
4111 |
|
| 207 |
liveuser |
4112 |
}#if end
|
| 226 |
liveuser |
4113 |
|
| 207 |
liveuser |
4114 |
#如果有參數 $conf["mainAscORdesc"]
|
|
|
4115 |
if(isset($conf["mainAscORdesc"])){
|
| 226 |
liveuser |
4116 |
|
| 207 |
liveuser |
4117 |
#$conf["mainAscORdesc"],字串,組好的資料要低增還是遞減排序,asc爲遞增;desc爲遞減,預設不做處理.
|
|
|
4118 |
$conf["db::joinByPHP"]["mainOrderItem"]=$conf["mainAscORdesc"];
|
| 226 |
liveuser |
4119 |
|
| 207 |
liveuser |
4120 |
}#if end
|
| 226 |
liveuser |
4121 |
|
| 207 |
liveuser |
4122 |
#參考資料:
|
|
|
4123 |
#無.
|
|
|
4124 |
#備註:
|
|
|
4125 |
#無.
|
|
|
4126 |
$joinByPHP=db::joinByPHP($conf["db::joinByPHP"]);
|
|
|
4127 |
unset($conf["db::joinByPHP"]);
|
| 226 |
liveuser |
4128 |
|
| 207 |
liveuser |
4129 |
#如果執行異常
|
|
|
4130 |
if($joinByPHP["status"]==="false"){
|
| 226 |
liveuser |
4131 |
|
| 207 |
liveuser |
4132 |
#設置執行異常識別
|
|
|
4133 |
$result["status"]="false";
|
| 226 |
liveuser |
4134 |
|
|
|
4135 |
#設置執行錯誤
|
| 207 |
liveuser |
4136 |
$result["error"]=$joinByPHP;
|
| 226 |
liveuser |
4137 |
|
| 207 |
liveuser |
4138 |
#回傳結果
|
|
|
4139 |
return $result;
|
| 226 |
liveuser |
4140 |
|
| 207 |
liveuser |
4141 |
}#if end
|
| 226 |
liveuser |
4142 |
|
| 207 |
liveuser |
4143 |
#初始化要回給 divAjax 的 json 內容
|
|
|
4144 |
$ajaxDivRes=array();
|
| 226 |
liveuser |
4145 |
|
| 207 |
liveuser |
4146 |
#meta for divAjax
|
|
|
4147 |
$ajaxDivRes["meta"]=array();
|
| 226 |
liveuser |
4148 |
|
| 207 |
liveuser |
4149 |
#設置當前是第幾頁
|
|
|
4150 |
$ajaxDivRes["meta"]["pageNumber"]=$conf["pageNumber"];
|
| 226 |
liveuser |
4151 |
|
| 207 |
liveuser |
4152 |
#設置一頁的資料上限
|
|
|
4153 |
$ajaxDivRes["meta"]["numberPerPage"]=$conf["numberPerPage"];
|
| 226 |
liveuser |
4154 |
|
| 207 |
liveuser |
4155 |
#設置當前頁面的資料筆數
|
|
|
4156 |
$ajaxDivRes["meta"]["currentNumber"]=$conf["currentNumber"];
|
| 226 |
liveuser |
4157 |
|
| 207 |
liveuser |
4158 |
#設置總共的資料筆數
|
|
|
4159 |
$ajaxDivRes["meta"]["total"]=$conf["total"];
|
| 226 |
liveuser |
4160 |
|
| 207 |
liveuser |
4161 |
#設置每列資料的每個欄位內容
|
|
|
4162 |
$ajaxDivRes["data"]=$conf["data"];
|
| 226 |
liveuser |
4163 |
|
| 207 |
liveuser |
4164 |
#json encode res for divAjax
|
|
|
4165 |
$result["content"]=json_encode($ajaxDivRes);
|
| 226 |
liveuser |
4166 |
|
| 207 |
liveuser |
4167 |
#回傳結果
|
|
|
4168 |
return $result;
|
| 226 |
liveuser |
4169 |
|
| 207 |
liveuser |
4170 |
}#function divAjaxRes end
|
|
|
4171 |
|
|
|
4172 |
/*
|
|
|
4173 |
#函式說明:
|
| 3 |
liveuser |
4174 |
#建立<thead></thead>標籤,裡面放置表格的標題.
|
|
|
4175 |
#回傳結果:
|
|
|
4176 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
4177 |
#$result["error"],涵式錯誤訊息陣列.
|
|
|
4178 |
#$result["content"],thead的語法.
|
|
|
4179 |
#$result["function"],當前執行的函式名稱.
|
|
|
4180 |
#必填參數:
|
|
|
4181 |
#$conf["content"],陣列,要放到thead裡面的內容.
|
|
|
4182 |
$conf["content"]=array();
|
|
|
4183 |
#可省略參數:
|
|
|
4184 |
#無
|
|
|
4185 |
#參考資料:
|
|
|
4186 |
#無.
|
|
|
4187 |
#備註:
|
|
|
4188 |
#無.
|
|
|
4189 |
*/
|
|
|
4190 |
public static function head(&$conf){
|
|
|
4191 |
|
|
|
4192 |
#初始化要回傳的變數
|
|
|
4193 |
$result=array();
|
|
|
4194 |
|
|
|
4195 |
#初始化要回傳的變數
|
|
|
4196 |
$result["content"]="";
|
|
|
4197 |
|
|
|
4198 |
#初始化當前執行的函數名稱
|
|
|
4199 |
$result["funciton"]=__FUNCTION__;
|
|
|
4200 |
|
|
|
4201 |
#如果 $conf 不為陣列
|
|
|
4202 |
if(gettype($conf)!="array"){
|
|
|
4203 |
|
|
|
4204 |
#設置執行失敗
|
|
|
4205 |
$result["status"]="false";
|
|
|
4206 |
|
|
|
4207 |
#設置執行錯誤訊息
|
|
|
4208 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
4209 |
|
|
|
4210 |
#如果傳入的參數為 null
|
|
|
4211 |
if($conf==null){
|
|
|
4212 |
|
|
|
4213 |
#設置執行錯誤訊息
|
|
|
4214 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
4215 |
|
|
|
4216 |
}#if end
|
|
|
4217 |
|
|
|
4218 |
#回傳結果
|
|
|
4219 |
return $result;
|
|
|
4220 |
|
|
|
4221 |
}#if end
|
|
|
4222 |
|
|
|
4223 |
#檢查參數
|
|
|
4224 |
#函式說明:
|
|
|
4225 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
4226 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4227 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
4228 |
#$result["function"],當前執行的函式名稱.
|
|
|
4229 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
4230 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
4231 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
4232 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
4233 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
4234 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
4235 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
4236 |
#必填參數:
|
|
|
4237 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
4238 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
4239 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
4240 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("content");
|
|
|
4241 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
4242 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
4243 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
4244 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
4245 |
#可省略參數:
|
|
|
4246 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
4247 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
4248 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
4249 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("colspan","rowspan");
|
|
|
4250 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
4251 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
4252 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
4253 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null);
|
|
|
4254 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
4255 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
4256 |
#參考資料來源:
|
|
|
4257 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
4258 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
4259 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
4260 |
|
|
|
4261 |
#如果檢查失敗
|
|
|
4262 |
if($checkResult["status"]=="false"){
|
|
|
4263 |
|
|
|
4264 |
#設置執行不正常
|
|
|
4265 |
$result["status"]="false";
|
|
|
4266 |
|
|
|
4267 |
#設置錯誤訊息
|
|
|
4268 |
$result["error"]=$checkResult;
|
|
|
4269 |
|
|
|
4270 |
#回傳結果
|
|
|
4271 |
return $result;
|
|
|
4272 |
|
|
|
4273 |
}#if end
|
|
|
4274 |
|
|
|
4275 |
#如果檢查不通過
|
|
|
4276 |
if($checkResult["passed"]=="false"){
|
|
|
4277 |
|
|
|
4278 |
#設置執行不正常
|
|
|
4279 |
$result["status"]="false";
|
|
|
4280 |
|
|
|
4281 |
#設置錯誤訊息
|
|
|
4282 |
$result["error"]=$checkResult;
|
|
|
4283 |
|
|
|
4284 |
#回傳結果
|
|
|
4285 |
return $result;
|
|
|
4286 |
|
|
|
4287 |
}#if end
|
|
|
4288 |
|
|
|
4289 |
#串接用thead將內容包起來的內容
|
|
|
4290 |
$result["content"]=$result["content"]."<thead>".$conf["content"]."</thead>";
|
|
|
4291 |
|
|
|
4292 |
#設置執行正常
|
|
|
4293 |
$result["status"]="true";
|
|
|
4294 |
|
|
|
4295 |
#回傳結果
|
|
|
4296 |
return $result;
|
|
|
4297 |
|
|
|
4298 |
}#function head end
|
|
|
4299 |
|
|
|
4300 |
/*
|
|
|
4301 |
#函式說明:
|
|
|
4302 |
#建立多個tbody.
|
|
|
4303 |
#回傳結果:
|
|
|
4304 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
4305 |
#$result["error"],涵式錯誤訊息陣列.
|
|
|
4306 |
#$result["content"],tbody的語法.
|
|
|
4307 |
#$result["eachBody"],每個tbody的內容.
|
|
|
4308 |
#$result["function"],當前執行的函式名稱.
|
|
|
4309 |
#必填參數:
|
|
|
4310 |
#$conf["content"],陣列,要放到tbody裡面的內容.
|
|
|
4311 |
#$conf["content"]=array();
|
|
|
4312 |
#可省略參數:
|
|
|
4313 |
#無.
|
|
|
4314 |
#參考資料:
|
|
|
4315 |
#無.
|
|
|
4316 |
#備註:
|
|
|
4317 |
#一個<table></table>裡面可以有多個<tbody></tbody>
|
|
|
4318 |
*/
|
|
|
4319 |
public static function body(&$conf){
|
|
|
4320 |
|
|
|
4321 |
#初始化要回傳的變數
|
|
|
4322 |
$result=array();
|
|
|
4323 |
|
|
|
4324 |
#初始化要回傳的變數
|
|
|
4325 |
$result["content"]="";
|
|
|
4326 |
|
|
|
4327 |
#初始化當前執行的函數名稱
|
|
|
4328 |
$result["funciton"]=__FUNCTION__;
|
|
|
4329 |
|
|
|
4330 |
#如果 $conf 不為陣列
|
|
|
4331 |
if(gettype($conf)!="array"){
|
|
|
4332 |
|
|
|
4333 |
#設置執行失敗
|
|
|
4334 |
$result["status"]="false";
|
|
|
4335 |
|
|
|
4336 |
#設置執行錯誤訊息
|
|
|
4337 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
4338 |
|
|
|
4339 |
#如果傳入的參數為 null
|
|
|
4340 |
if($conf==null){
|
|
|
4341 |
|
|
|
4342 |
#設置執行錯誤訊息
|
|
|
4343 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
4344 |
|
|
|
4345 |
}#if end
|
|
|
4346 |
|
|
|
4347 |
#回傳結果
|
|
|
4348 |
return $result;
|
|
|
4349 |
|
|
|
4350 |
}#if end
|
|
|
4351 |
|
|
|
4352 |
#檢查參數
|
|
|
4353 |
#函式說明:
|
|
|
4354 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
4355 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4356 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
4357 |
#$result["function"],當前執行的函式名稱.
|
|
|
4358 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
4359 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
4360 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
4361 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
4362 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
4363 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
4364 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
4365 |
#必填參數:
|
|
|
4366 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
4367 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
4368 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
4369 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("content");
|
|
|
4370 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
4371 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
4372 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
4373 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
4374 |
#可省略參數:
|
|
|
4375 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
4376 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
4377 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
4378 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("colspan","rowspan");
|
|
|
4379 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
4380 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
4381 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
4382 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null);
|
|
|
4383 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
4384 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
4385 |
#參考資料來源:
|
|
|
4386 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
4387 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
4388 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
4389 |
|
|
|
4390 |
#如果檢查失敗
|
|
|
4391 |
if($checkResult["status"]=="false"){
|
|
|
4392 |
|
|
|
4393 |
#設置執行不正常
|
|
|
4394 |
$result["status"]="false";
|
|
|
4395 |
|
|
|
4396 |
#設置錯誤訊息
|
|
|
4397 |
$result["error"]=$checkResult;
|
|
|
4398 |
|
|
|
4399 |
#回傳結果
|
|
|
4400 |
return $result;
|
|
|
4401 |
|
|
|
4402 |
}#if end
|
|
|
4403 |
|
|
|
4404 |
#如果檢查不通過
|
|
|
4405 |
if($checkResult["passed"]=="false"){
|
|
|
4406 |
|
|
|
4407 |
#設置執行不正常
|
|
|
4408 |
$result["status"]="false";
|
|
|
4409 |
|
|
|
4410 |
#設置錯誤訊息
|
|
|
4411 |
$result["error"]=$checkResult;
|
|
|
4412 |
|
|
|
4413 |
#回傳結果
|
|
|
4414 |
return $result;
|
|
|
4415 |
|
|
|
4416 |
}#if end
|
|
|
4417 |
|
|
|
4418 |
#有幾個 $content 就執行幾次
|
|
|
4419 |
foreach($conf["content"] as $tbodyCon){
|
|
|
4420 |
|
|
|
4421 |
#用tboby將內容包起來
|
|
|
4422 |
$result["eachBody"][]="<tbody>".$tbodyCon."</tbody>";
|
|
|
4423 |
|
|
|
4424 |
#串接用tboby將內容包起來的內容
|
|
|
4425 |
$result["content"]=$result["content"]."<tbody>".$tbodyCon."</tbody>";
|
|
|
4426 |
|
|
|
4427 |
}#foreach end
|
|
|
4428 |
|
|
|
4429 |
#設置執行正常
|
|
|
4430 |
$result["status"]="true";
|
|
|
4431 |
|
|
|
4432 |
#回傳結果
|
|
|
4433 |
return $result;
|
|
|
4434 |
|
|
|
4435 |
}#function tbody end
|
|
|
4436 |
|
|
|
4437 |
}#class end
|
|
|
4438 |
|
|
|
4439 |
?>
|