| 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 |
namespace qbpwcf;
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
form表單應用的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class form{
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
#函式說明:
|
|
|
36 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
37 |
#回傳結果:
|
|
|
38 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
39 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
40 |
#$result["function"],當前執行的函式名稱.
|
|
|
41 |
#必填參數:
|
|
|
42 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
43 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
44 |
#可省略參數:
|
|
|
45 |
#無.
|
|
|
46 |
#參考資料:
|
|
|
47 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
48 |
#備註:
|
|
|
49 |
#無.
|
|
|
50 |
*/
|
|
|
51 |
public function __call($method,$arguments){
|
|
|
52 |
|
|
|
53 |
#取得當前執行的函式
|
|
|
54 |
$result["function"]=__FUNCTION__;
|
|
|
55 |
|
|
|
56 |
#設置執行不正常
|
|
|
57 |
$result["status"]="false";
|
|
|
58 |
|
|
|
59 |
#設置執行錯誤
|
|
|
60 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
61 |
|
|
|
62 |
#設置所丟入的參數
|
|
|
63 |
$result["error"][]=$arguments;
|
|
|
64 |
|
|
|
65 |
#回傳結果
|
|
|
66 |
return $result;
|
|
|
67 |
|
|
|
68 |
}#function __call end
|
|
|
69 |
|
|
|
70 |
/*
|
|
|
71 |
#函式說明:
|
|
|
72 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
73 |
#回傳結果:
|
|
|
74 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
75 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
76 |
#$result["function"],當前執行的函式名稱.
|
|
|
77 |
#必填參數:
|
|
|
78 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
79 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
80 |
#可省略參數:
|
|
|
81 |
#無.
|
|
|
82 |
#參考資料:
|
|
|
83 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
84 |
#備註:
|
|
|
85 |
#無.
|
|
|
86 |
*/
|
|
|
87 |
public static function __callStatic($method,$arguments){
|
|
|
88 |
|
|
|
89 |
#取得當前執行的函式
|
|
|
90 |
$result["function"]=__FUNCTION__;
|
|
|
91 |
|
|
|
92 |
#設置執行不正常
|
|
|
93 |
$result["status"]="false";
|
|
|
94 |
|
|
|
95 |
#設置執行錯誤
|
|
|
96 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
97 |
|
|
|
98 |
#設置所丟入的參數
|
|
|
99 |
$result["error"][]=$arguments;
|
|
|
100 |
|
|
|
101 |
#回傳結果
|
|
|
102 |
return $result;
|
|
|
103 |
|
|
|
104 |
}#function __callStatic end
|
|
|
105 |
|
|
|
106 |
/*
|
|
|
107 |
#函式說明:
|
|
|
108 |
#表單開始
|
|
|
109 |
#回傳結果:
|
|
|
110 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
111 |
#$result["error"],錯誤訊息陣列.
|
|
|
112 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
113 |
#$result["content"],表單開始的語法.
|
|
|
114 |
#必填參數:
|
|
|
115 |
#$conf["action"],字串,爲要交給那個檔案處理該表單傳送的內容.
|
|
|
116 |
$conf["action"]="";
|
|
|
117 |
#可省略參數:
|
|
|
118 |
#$conf["legend"]="";#顯示表單的標題
|
|
|
119 |
#$conf["name"]="";#爲該表單的名稱,id也跟$conf["name"]一樣.
|
|
|
120 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
121 |
#$conf["target"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
122 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是,"false"為否,預設為"false".
|
|
|
123 |
#$conf["tableClass"]="";#表格要套用的css樣式,預設爲"__withoutBorder"無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
124 |
#$conf["showFieldsetBorder"]="false";#是否要顯示表單區域的框線,預設為"false"不顯示,"true"代表要顯示.
|
|
|
125 |
#參考資料:
|
|
|
126 |
#http://www.w3schools.com/html/html_forms.asp
|
|
|
127 |
#http://www.w3schools.com/tags/tag_fieldset.asp
|
|
|
128 |
#備註:
|
|
|
129 |
#建議增加enctype的參數設定application/json=>https://imququ.com/post/four-ways-to-post-data-in-http.html
|
|
|
130 |
*/
|
|
|
131 |
public static function start(&$conf){
|
|
|
132 |
|
|
|
133 |
#初始化要回傳的變數
|
|
|
134 |
$result=array();
|
|
|
135 |
|
|
|
136 |
#設置當前執行的函式
|
|
|
137 |
$result["function"]=__FUNCTION__;
|
|
|
138 |
|
|
|
139 |
#初始化表單開始的語法
|
|
|
140 |
$result["content"]="";
|
|
|
141 |
|
|
|
142 |
#如果 $conf 不為陣列
|
|
|
143 |
if(gettype($conf)!="array"){
|
|
|
144 |
|
|
|
145 |
#設置執行失敗
|
|
|
146 |
$result["status"]="false";
|
|
|
147 |
|
|
|
148 |
#設置執行錯誤訊息
|
|
|
149 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
150 |
|
|
|
151 |
#如果傳入的參數為 null
|
|
|
152 |
if($conf==null){
|
|
|
153 |
|
|
|
154 |
#設置執行錯誤訊息
|
|
|
155 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
156 |
|
|
|
157 |
}#if end
|
|
|
158 |
|
|
|
159 |
#回傳結果
|
|
|
160 |
return $result;
|
|
|
161 |
|
|
|
162 |
}#if end
|
|
|
163 |
|
|
|
164 |
#檢查參數
|
|
|
165 |
#函式說明:
|
|
|
166 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
167 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
168 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
169 |
#$result["function"],當前執行的函式名稱.
|
|
|
170 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
171 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
172 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
173 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
174 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
175 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
176 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
177 |
#必填參數:
|
|
|
178 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
179 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
180 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
181 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("action");
|
|
|
182 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
183 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
184 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
185 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
186 |
#可省略參數:
|
|
|
187 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
188 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
189 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
190 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("legend","name","method","target","tableStart","tableClass","showFieldsetBorder");
|
|
|
191 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
192 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
|
|
|
193 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
194 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"post","_top","false","__withoutBorder","false");
|
|
|
195 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
196 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
197 |
#參考資料:
|
|
|
198 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
199 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
200 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
201 |
|
|
|
202 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
203 |
if($checkArguments["status"]=="false"){
|
|
|
204 |
|
|
|
205 |
#設置錯誤識別
|
|
|
206 |
$result["status"]="false";
|
|
|
207 |
|
|
|
208 |
#設置錯誤訊息
|
|
|
209 |
$result["error"]=$checkArguments;
|
|
|
210 |
|
|
|
211 |
#回傳結果
|
|
|
212 |
return $result;
|
|
|
213 |
|
|
|
214 |
}#if end
|
|
|
215 |
|
|
|
216 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
217 |
if($checkArguments["passed"]=="false"){
|
|
|
218 |
|
|
|
219 |
#設置錯誤識別
|
|
|
220 |
$result["status"]="false";
|
|
|
221 |
|
|
|
222 |
#設置錯誤訊息
|
|
|
223 |
$result["error"]=$checkArguments;
|
|
|
224 |
|
|
|
225 |
#回傳結果
|
|
|
226 |
return $result;
|
|
|
227 |
|
|
|
228 |
}#if end
|
|
|
229 |
|
|
|
230 |
#建立表格預設的 css 樣式 "__defaultTbaleCsssStyle"
|
|
|
231 |
#函式說明:
|
|
|
232 |
#創建 css 樣式
|
|
|
233 |
#必填參數:
|
|
|
234 |
$conf_createCssStyle["cssStyleName"]="__defaultTbaleCsssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
235 |
$conf_createCssStyle["attributes"]=array("table-layout","word-break","width","border");#為屬性名稱,須為陣列值
|
|
|
236 |
$conf_createCssStyle["content"]=array("fixed","break-all","100%","0px");#為屬性值,須為陣列值
|
|
|
237 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
238 |
unset($conf_createCssStyle);
|
|
|
239 |
|
|
|
240 |
#如果建立css樣式失敗
|
|
|
241 |
if($css["status"]=="false"){
|
|
|
242 |
|
|
|
243 |
#設置錯誤識別
|
|
|
244 |
$result["status"]="false";
|
|
|
245 |
|
|
|
246 |
#設置錯誤訊息
|
|
|
247 |
$result["error"]=$css;
|
|
|
248 |
|
|
|
249 |
#回傳結果
|
|
|
250 |
return $result;
|
|
|
251 |
|
|
|
252 |
}#if end
|
|
|
253 |
|
|
|
254 |
#取得表格預設的css語法
|
|
|
255 |
$result["content"]=$result["content"].$css["content"];
|
|
|
256 |
|
|
|
257 |
#如果 $conf["name"] 存在
|
|
|
258 |
if(isset($conf["name"])){
|
|
|
259 |
|
|
|
260 |
#如果 $conf["name"] 不為 ""
|
|
|
261 |
if($conf["name"]!=""){
|
|
|
262 |
|
|
|
263 |
#設定name與id屬性
|
|
|
264 |
$conf["name"]=" name=".$conf["name"]." id=".$conf["name"];
|
|
|
265 |
|
|
|
266 |
}#if end
|
|
|
267 |
|
|
|
268 |
}#if end
|
|
|
269 |
|
|
|
270 |
#反之$conf["name"]不存在
|
|
|
271 |
else{
|
|
|
272 |
|
|
|
273 |
#設為 ""
|
|
|
274 |
$conf["name"]="";
|
|
|
275 |
|
|
|
276 |
}#esle end
|
|
|
277 |
|
|
|
278 |
#判斷其值是否爲"true"
|
|
|
279 |
if($conf["tableStart"]=="true"){
|
|
|
280 |
|
|
|
281 |
#函式說明:
|
|
|
282 |
#表格開始,可以設定表格的厚度和位置
|
|
|
283 |
#回傳結果:
|
|
|
284 |
#$result,表格開始的語法
|
|
|
285 |
#必填寫的參數:
|
|
|
286 |
|
|
|
287 |
#如果 $conf["tableClass"] 存在
|
|
|
288 |
if(isset($conf["tableClass"])){
|
|
|
289 |
|
|
|
290 |
#則套用指定的樣式
|
|
|
291 |
$conf["table"]["start"]["class"]=$conf["tableClass"];
|
|
|
292 |
|
|
|
293 |
}#if end
|
|
|
294 |
|
|
|
295 |
#反之採用預設沒有線條的css樣式
|
|
|
296 |
else{
|
|
|
297 |
|
|
|
298 |
#則套用的預設的樣式
|
|
|
299 |
$conf["table"]["start"]["class"]="__withoutBorder";
|
|
|
300 |
|
|
|
301 |
}#else end
|
|
|
302 |
|
|
|
303 |
$tableStart=table::start($conf["table"]["start"]);
|
|
|
304 |
unset($conf["table"]["start"]);
|
|
|
305 |
|
|
|
306 |
#如果表格開始失敗
|
|
|
307 |
if($tableStart["status"]=="false"){
|
|
|
308 |
|
|
|
309 |
#設置錯誤識別
|
|
|
310 |
$result["status"]="false";
|
|
|
311 |
|
|
|
312 |
#設置錯誤訊息
|
|
|
313 |
$result["error"]=$tableStart;
|
|
|
314 |
|
|
|
315 |
#回傳結果
|
|
|
316 |
return $result;
|
|
|
317 |
|
|
|
318 |
}#if end
|
|
|
319 |
|
|
|
320 |
#串接表格開始的語法
|
|
|
321 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
322 |
|
|
|
323 |
}#if end
|
|
|
324 |
|
|
|
325 |
#如果有設置 $conf["legend"]
|
|
|
326 |
if(isset($conf["legend"])){
|
|
|
327 |
|
|
|
328 |
#設置要顯示的表單名稱
|
|
|
329 |
$conf["legend"]="<legend>".$conf["legend"]."</legend>";
|
|
|
330 |
|
|
|
331 |
}#if end
|
|
|
332 |
|
|
|
333 |
#反之
|
|
|
334 |
else{
|
|
|
335 |
|
|
|
336 |
#設為 ""
|
|
|
337 |
$conf["legend"]="";
|
|
|
338 |
|
|
|
339 |
}#else end
|
|
|
340 |
|
|
|
341 |
#如果 $conf["showFieldsetBorder"] 為 "false"
|
|
|
342 |
if($conf["showFieldsetBorder"]=="false"){
|
|
|
343 |
|
|
|
344 |
#設置要套用的樣式
|
|
|
345 |
$conf["showFieldsetBorder"]=" class=\"__qbpwcf_fieldsetCssStyle\" ";
|
|
|
346 |
|
|
|
347 |
}#if end
|
|
|
348 |
|
|
|
349 |
#反之設為 ""
|
|
|
350 |
else{
|
|
|
351 |
|
|
|
352 |
$conf["showFieldsetBorder"]="";
|
|
|
353 |
|
|
|
354 |
}#else end
|
|
|
355 |
|
|
|
356 |
#設定要印出/回傳的變數內容
|
|
|
357 |
$result["content"]=$result["content"]."<form action = ".$conf["action"]." class=\"__qbpwcf_hiddenFormBlank\" ".$conf["name"]." method = ".$conf["method"]." enctype= \"multipart/form-data\" target = ".$conf["target"]." ><fieldset ".$conf["showFieldsetBorder"]." >".$conf["legend"];
|
|
|
358 |
|
|
|
359 |
#設置執行正常
|
|
|
360 |
$result["status"]="true";
|
|
|
361 |
|
|
|
362 |
#回傳結果
|
|
|
363 |
return $result;
|
|
|
364 |
|
|
|
365 |
}#function start end
|
|
|
366 |
|
|
|
367 |
/*
|
|
|
368 |
#函式說明:
|
|
|
369 |
#表單結束
|
|
|
370 |
#回傳結果:
|
|
|
371 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
372 |
#$result["error"],錯誤訊息陣列.
|
|
|
373 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
374 |
#$result["content"],表單結束的語法.
|
|
|
375 |
#必填參數:
|
|
|
376 |
#$conf["tableEnd"],字串,爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
377 |
$conf["tableEnd"]="false";
|
|
|
378 |
#可省略參數:
|
|
|
379 |
#無.
|
|
|
380 |
#參考資料:
|
|
|
381 |
#無.
|
|
|
382 |
#備註:
|
|
|
383 |
#無.
|
|
|
384 |
*/
|
|
|
385 |
public static function end(&$conf){
|
|
|
386 |
|
|
|
387 |
#初始化要回傳的變數
|
|
|
388 |
$result=array();
|
|
|
389 |
|
|
|
390 |
#設置當前執行的函式
|
|
|
391 |
$result["function"]=__FUNCTION__;
|
|
|
392 |
|
|
|
393 |
#初始化表單開始的語法
|
|
|
394 |
$result["content"]="";
|
|
|
395 |
|
|
|
396 |
#如果 $conf 不為陣列
|
|
|
397 |
if(gettype($conf)!="array"){
|
|
|
398 |
|
|
|
399 |
#設置執行失敗
|
|
|
400 |
$result["status"]="false";
|
|
|
401 |
|
|
|
402 |
#設置執行錯誤訊息
|
|
|
403 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
404 |
|
|
|
405 |
#如果傳入的參數為 null
|
|
|
406 |
if($conf==null){
|
|
|
407 |
|
|
|
408 |
#設置執行錯誤訊息
|
|
|
409 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
410 |
|
|
|
411 |
}#if end
|
|
|
412 |
|
|
|
413 |
#回傳結果
|
|
|
414 |
return $result;
|
|
|
415 |
|
|
|
416 |
}#if end
|
|
|
417 |
|
|
|
418 |
#檢查參數
|
|
|
419 |
#函式說明:
|
|
|
420 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
421 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
422 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
423 |
#$result["function"],當前執行的函式名稱.
|
|
|
424 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
425 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
426 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
427 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
428 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
429 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
430 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
431 |
#必填參數:
|
|
|
432 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
433 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
434 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
435 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("tableEnd");
|
|
|
436 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
437 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
438 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
439 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
440 |
#可省略參數:
|
|
|
441 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
442 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
443 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
444 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("legend","name","method","target","tableStart","tableClass","showFieldsetBorder");
|
|
|
445 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
446 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
|
|
|
447 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
448 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"","post","_top",null,null,"false");
|
|
|
449 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
450 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
451 |
#參考資料:
|
|
|
452 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
453 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
454 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
455 |
|
|
|
456 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
457 |
if($checkArguments["status"]=="false"){
|
|
|
458 |
|
|
|
459 |
#設置錯誤識別
|
|
|
460 |
$result["status"]="false";
|
|
|
461 |
|
|
|
462 |
#設置錯誤訊息
|
|
|
463 |
$result["error"]=$checkArguments;
|
|
|
464 |
|
|
|
465 |
#回傳結果
|
|
|
466 |
return $result;
|
|
|
467 |
|
|
|
468 |
}#if end
|
|
|
469 |
|
|
|
470 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
471 |
if($checkArguments["passed"]=="false"){
|
|
|
472 |
|
|
|
473 |
#設置錯誤識別
|
|
|
474 |
$result["status"]="false";
|
|
|
475 |
|
|
|
476 |
#設置錯誤訊息
|
|
|
477 |
$result["error"]=$checkArguments;
|
|
|
478 |
|
|
|
479 |
#回傳結果
|
|
|
480 |
return $result;
|
|
|
481 |
|
|
|
482 |
}#if end
|
|
|
483 |
|
|
|
484 |
#儲存表單結束的html
|
|
|
485 |
$result["content"]=$result["content"]."</fieldset></form>";
|
|
|
486 |
|
|
|
487 |
#判斷其值是否爲"true"
|
|
|
488 |
if($conf["tableEnd"]=="true"){
|
|
|
489 |
|
|
|
490 |
#儲存表格結尾的標籤
|
|
|
491 |
$result["content"]=$result["content"]."</table>";
|
|
|
492 |
|
|
|
493 |
}#if end
|
|
|
494 |
|
|
|
495 |
#設置執行正常
|
|
|
496 |
$result["status"]="true";
|
|
|
497 |
|
|
|
498 |
#回傳結果
|
|
|
499 |
return $result;
|
|
|
500 |
|
|
|
501 |
}#function end end
|
|
|
502 |
|
|
|
503 |
/*
|
|
|
504 |
#函式說明:
|
|
|
505 |
#若有表單透過POST或GET的方式傳送的資料,則將內容回傳,若是用GET的方式傳送則轉址到 $headerLocation
|
|
|
506 |
#回傳結果:
|
|
|
507 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
508 |
#$result["error"],錯誤訊息陣列.
|
|
|
509 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
510 |
#$result["warning"],警告訊息.
|
|
|
511 |
#$result["content"],接收到變數內容,若為null則代表要接收的變數不存在.
|
|
|
512 |
#必填參數:
|
|
|
513 |
#$conf["inputName"],字串,讀取表單的資料時用來辨別的名稱。
|
|
|
514 |
$conf["inputName"]="";
|
|
|
515 |
#可省略參數
|
|
|
516 |
#$conf["refuseGetMethod"],字串,是否要擋 get 傳值,如果有設置,則不檔GET傳值。
|
|
|
517 |
#$conf["refuseGetMethod"]="true";
|
|
|
518 |
#$conf["transferLocation"],字串,如果是用GET傳值,則轉址到那個網址,預設爲資安素養網"https://isafe.moe.edu.tw/"
|
|
|
519 |
#$conf["transferLocation"]="";
|
|
|
520 |
#$conf["correctCharacter"],字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設為"true".
|
|
|
521 |
#$conf["correctCharacter"]="false";
|
|
|
522 |
#參考資料:
|
|
|
523 |
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
|
|
|
524 |
#備註:
|
|
|
525 |
#無.
|
|
|
526 |
*/
|
|
|
527 |
public static function responseInputData(&$conf){
|
|
|
528 |
|
|
|
529 |
#初始化要回傳的變數
|
|
|
530 |
$result=array();
|
|
|
531 |
|
|
|
532 |
#設置當前執行的函式
|
|
|
533 |
$result["function"]=__FUNCTION__;
|
|
|
534 |
|
|
|
535 |
#初始化表單開始的語法
|
|
|
536 |
$result["content"]="";
|
|
|
537 |
|
|
|
538 |
#如果 $conf 不為陣列
|
|
|
539 |
if(gettype($conf)!="array"){
|
|
|
540 |
|
|
|
541 |
#設置執行失敗
|
|
|
542 |
$result["status"]="false";
|
|
|
543 |
|
|
|
544 |
#設置執行錯誤訊息
|
|
|
545 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
546 |
|
|
|
547 |
#如果傳入的參數為 null
|
|
|
548 |
if($conf==null){
|
|
|
549 |
|
|
|
550 |
#設置執行錯誤訊息
|
|
|
551 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
552 |
|
|
|
553 |
}#if end
|
|
|
554 |
|
|
|
555 |
#回傳結果
|
|
|
556 |
return $result;
|
|
|
557 |
|
|
|
558 |
}#if end
|
|
|
559 |
|
|
|
560 |
#檢查參數
|
|
|
561 |
#函式說明:
|
|
|
562 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
563 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
564 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
565 |
#$result["function"],當前執行的函式名稱.
|
|
|
566 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
567 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
568 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
569 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
570 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
571 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
572 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
573 |
#必填參數:
|
|
|
574 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
575 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
576 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
577 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("inputName");
|
|
|
578 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
579 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
580 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
581 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
582 |
#可省略參數:
|
|
|
583 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
584 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
585 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
586 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("refuseGetMethod","transferLocation","correctCharacter");
|
|
|
587 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
588 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
|
|
|
589 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
590 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","https://isafe.moe.edu.tw/","true");
|
|
|
591 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
592 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
593 |
#參考資料:
|
|
|
594 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
595 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
596 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
597 |
|
|
|
598 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
599 |
if($checkArguments["status"]=="false"){
|
|
|
600 |
|
|
|
601 |
#設置錯誤識別
|
|
|
602 |
$result["status"]="false";
|
|
|
603 |
|
|
|
604 |
#設置錯誤訊息
|
|
|
605 |
$result["error"]=$checkArguments;
|
|
|
606 |
|
|
|
607 |
#回傳結果
|
|
|
608 |
return $result;
|
|
|
609 |
|
|
|
610 |
}#if end
|
|
|
611 |
|
|
|
612 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
613 |
if($checkArguments["passed"]=="false"){
|
|
|
614 |
|
|
|
615 |
#設置錯誤識別
|
|
|
616 |
$result["status"]="false";
|
|
|
617 |
|
|
|
618 |
#設置錯誤訊息
|
|
|
619 |
$result["error"]=$checkArguments;
|
|
|
620 |
|
|
|
621 |
#回傳結果
|
|
|
622 |
return $result;
|
|
|
623 |
|
|
|
624 |
}#if end
|
|
|
625 |
|
|
|
626 |
#如果$conf["security"]不存在,則代表採用預設值要防止get傳值
|
|
|
627 |
if($conf["refuseGetMethod"]=="true"){
|
|
|
628 |
|
|
|
629 |
#若有表單透過POST傳送的資料
|
|
|
630 |
if(isset($_POST[$conf["inputName"]])){
|
|
|
631 |
|
|
|
632 |
#如果 $conf["correctCharacter"] 爲 false
|
|
|
633 |
if($conf["correctCharacter"]=="false"){
|
|
|
634 |
|
|
|
635 |
#如果 $_POST[$conf["inputName"]] 存在
|
|
|
636 |
if(isset($_POST[$conf["inputName"]])){
|
|
|
637 |
|
|
|
638 |
#設置執行正常
|
|
|
639 |
$result["status"]="true";
|
|
|
640 |
|
|
|
641 |
#設置抓到的post數值
|
|
|
642 |
$result["content"]=$_POST[$conf["inputName"]];
|
|
|
643 |
|
|
|
644 |
#回傳結果
|
|
|
645 |
return $result;
|
|
|
646 |
|
|
|
647 |
}#if end
|
|
|
648 |
|
|
|
649 |
}#if end
|
|
|
650 |
|
|
|
651 |
#反之 $conf["correctCharacter"] 不爲 false
|
|
|
652 |
else{
|
|
|
653 |
|
|
|
654 |
#如果 $_POST[$conf["inputName"]] 存在
|
|
|
655 |
if(isset($_POST[$conf["inputName"]])){
|
|
|
656 |
|
|
|
657 |
#將字串作處理避免錯誤
|
|
|
658 |
#函式說明:
|
|
|
659 |
#處理字串避免網頁出錯
|
|
|
660 |
#回傳結果:
|
|
|
661 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
662 |
#$result["function"],當前執行的函數.
|
|
|
663 |
#$result["content"],爲處理好的字串.
|
|
|
664 |
#$result["error"],錯誤訊息陣列.
|
|
|
665 |
#必填參數:
|
|
|
666 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$_POST[$conf["inputName"]];#爲要處理的字串
|
|
|
667 |
#可省略的參數:
|
|
|
668 |
#$conf["selectedCharacter"]=array("");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
669 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
670 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
671 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
672 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
673 |
|
|
|
674 |
#如果處理字串失敗
|
|
|
675 |
if($correctCharacter["status"]=="false"){
|
|
|
676 |
|
|
|
677 |
#設置錯誤識別
|
|
|
678 |
$result["status"]="false";
|
|
|
679 |
|
|
|
680 |
#設置錯誤訊息
|
|
|
681 |
$result["error"]=$correctCharacter;
|
|
|
682 |
|
|
|
683 |
#回傳結果
|
|
|
684 |
return $result;
|
|
|
685 |
|
|
|
686 |
}#if end
|
|
|
687 |
|
|
|
688 |
#設置執行正常
|
|
|
689 |
$result["status"]="true";
|
|
|
690 |
|
|
|
691 |
#設置抓到的post數值
|
|
|
692 |
$result["content"]=$correctCharacter["content"];
|
|
|
693 |
|
|
|
694 |
#回傳結果
|
|
|
695 |
return $result;
|
|
|
696 |
|
|
|
697 |
}#if end
|
|
|
698 |
|
|
|
699 |
}#else end
|
|
|
700 |
|
|
|
701 |
}#if end
|
|
|
702 |
|
|
|
703 |
#若有表單透過GET傳送的資料
|
|
|
704 |
if(isset($_GET[$conf["inputName"]])){
|
|
|
705 |
|
|
|
706 |
#進行轉址的動作
|
|
|
707 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["header"]["redirectionNow"]["transferLocation"];
|
|
|
708 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
709 |
unset($conf["header"]["redirectionNow"]);
|
|
|
710 |
|
|
|
711 |
}#判斷式結束
|
|
|
712 |
|
|
|
713 |
}#判斷式結束
|
|
|
714 |
|
|
|
715 |
#如果不使用檔get傳值
|
|
|
716 |
else{
|
|
|
717 |
|
|
|
718 |
#若有表單透過POST傳送的資料
|
|
|
719 |
if(isset($_POST[$conf["inputName"]])){
|
|
|
720 |
|
|
|
721 |
#如果 $conf["correctCharacter"] 存在
|
|
|
722 |
if(isset($conf["correctCharacter"])){
|
|
|
723 |
|
|
|
724 |
#如果 $conf["correctCharacter"] 爲 false
|
|
|
725 |
if($conf["correctCharacter"]=="false"){
|
|
|
726 |
|
|
|
727 |
#設置執行正常
|
|
|
728 |
$result["status"]="true";
|
|
|
729 |
|
|
|
730 |
#設置抓到的post數值
|
|
|
731 |
$result["content"]=$_POST[$conf["inputName"]];
|
|
|
732 |
|
|
|
733 |
#回傳結果
|
|
|
734 |
return $result;
|
|
|
735 |
|
|
|
736 |
}#if end
|
|
|
737 |
|
|
|
738 |
}#if end
|
|
|
739 |
|
|
|
740 |
#反之
|
|
|
741 |
else{
|
|
|
742 |
|
|
|
743 |
#將字串作處理避免錯誤
|
|
|
744 |
$correctCharacter_conf["stringIn"]=$_POST[$conf["inputName"]];#爲要處理的字串
|
|
|
745 |
$correctCharacter=stringProcess::correctCharacter($correctCharacter_conf);
|
|
|
746 |
unset($correctCharacter_conf);
|
|
|
747 |
|
|
|
748 |
#如果處理字串失敗
|
|
|
749 |
if($correctCharacter["status"]=="false"){
|
|
|
750 |
|
|
|
751 |
#設置錯誤識別
|
|
|
752 |
$result["status"]="false";
|
|
|
753 |
|
|
|
754 |
#設置錯誤訊息
|
|
|
755 |
$result["error"]=$correctCharacter;
|
|
|
756 |
|
|
|
757 |
#回傳結果
|
|
|
758 |
return $result;
|
|
|
759 |
|
|
|
760 |
}#if end
|
|
|
761 |
|
|
|
762 |
#設置執行正常
|
|
|
763 |
$result["status"]="true";
|
|
|
764 |
|
|
|
765 |
#設置抓到的post數值
|
|
|
766 |
$result["content"]=$correctCharacter["content"];
|
|
|
767 |
|
|
|
768 |
#回傳結果
|
|
|
769 |
return $result;
|
|
|
770 |
|
|
|
771 |
}#else end
|
|
|
772 |
|
|
|
773 |
}#if end
|
|
|
774 |
|
|
|
775 |
#若有表單透過GET傳送的資料
|
|
|
776 |
if(isset($_GET[$conf["inputName"]])){
|
|
|
777 |
|
|
|
778 |
#如果 $conf["correctCharacter"] 存在
|
|
|
779 |
if(isset($conf["correctCharacter"])){
|
|
|
780 |
|
|
|
781 |
#如果 $conf["correctCharacter"] 爲 false
|
|
|
782 |
if($conf["correctCharacter"]=="false"){
|
|
|
783 |
|
|
|
784 |
#設置執行正常
|
|
|
785 |
$result["status"]="true";
|
|
|
786 |
|
|
|
787 |
#設置抓到的get數值
|
|
|
788 |
$result["content"]=$_GET[$conf["inputName"]];
|
|
|
789 |
|
|
|
790 |
#回傳結果
|
|
|
791 |
return $result;
|
|
|
792 |
|
|
|
793 |
}#判斷式結束
|
|
|
794 |
|
|
|
795 |
}#判斷式結束
|
|
|
796 |
|
|
|
797 |
#反之
|
|
|
798 |
else{
|
|
|
799 |
|
|
|
800 |
#將字串作處理避免錯誤
|
|
|
801 |
$correctCharacter_conf["stringIn"]=$_GET[$conf["inputName"]];#爲要處理的字串
|
|
|
802 |
$correctCharacter=stringProcess::correctCharacter($correctCharacter_conf);
|
|
|
803 |
unset($correctCharacter_conf);
|
|
|
804 |
|
|
|
805 |
#如果處理字串失敗
|
|
|
806 |
if($correctCharacter["status"]=="false"){
|
|
|
807 |
|
|
|
808 |
#設置錯誤識別
|
|
|
809 |
$result["status"]="false";
|
|
|
810 |
|
|
|
811 |
#設置錯誤訊息
|
|
|
812 |
$result["error"]=$correctCharacter;
|
|
|
813 |
|
|
|
814 |
#回傳結果
|
|
|
815 |
return $result;
|
|
|
816 |
|
|
|
817 |
}#if end
|
|
|
818 |
|
|
|
819 |
#設置執行正常
|
|
|
820 |
$result["status"]="true";
|
|
|
821 |
|
|
|
822 |
#設置抓到的get數值
|
|
|
823 |
$result["content"]=$correctCharacter["content"];
|
|
|
824 |
|
|
|
825 |
#回傳結果
|
|
|
826 |
return $result;
|
|
|
827 |
|
|
|
828 |
}#else end
|
|
|
829 |
|
|
|
830 |
}#if end
|
|
|
831 |
|
|
|
832 |
}#else end
|
|
|
833 |
|
|
|
834 |
#執行到這邊代表要接收的變數不存在
|
|
|
835 |
$result["warning"][]="表單變數「".$conf["inputName"]."」不存在";
|
|
|
836 |
|
|
|
837 |
#設置執行正常
|
|
|
838 |
$result["status"]="true";
|
|
|
839 |
|
|
|
840 |
#設置接收到的內容為 null
|
|
|
841 |
$result["content"]=null;
|
|
|
842 |
|
|
|
843 |
#回傳結果
|
|
|
844 |
return $result;
|
|
|
845 |
|
|
|
846 |
}#funcion responseInputData end
|
|
|
847 |
|
|
|
848 |
/*
|
|
|
849 |
#函式說明:
|
|
|
850 |
#若有表單透過POST或GET的方式傳送的資料,則將內容回傳,若是用GET的方式傳送則轉址到 $headerLocation
|
|
|
851 |
#回傳結果:
|
|
|
852 |
#$result["status"],是否執行成功,"true"代表執行成功;"false"代表執行失敗。
|
|
|
853 |
#$result["function"],當前執行的函數名稱.
|
|
|
854 |
#$result["error"],錯誤訊息。
|
|
|
855 |
#$result["reveivedVarName"],接收到的變數名稱
|
|
|
856 |
#$result["receivedVarValue"],接收到的變數內容
|
|
|
857 |
#$result["HTTP_REFERER"],前一頁的網址,null為不存在的意思.
|
|
|
858 |
#必填參數:
|
|
|
859 |
#$conf["inputName"],字串,讀取表單的資料時用來辨別的名稱,
|
|
|
860 |
$conf["inputName"]="";
|
|
|
861 |
#可省略參數:
|
|
|
862 |
#$conf["receiveType"],字串,要接收 post/POST 或 get/GET 的變數,預設爲 POST
|
|
|
863 |
#$conf["receiveType"]="POST";
|
|
|
864 |
#$conf["allowGet"],字串,是否要允許 get 傳值,"true",代表允許;"false" ,代表不允許,預設爲不允許。
|
|
|
865 |
#$conf["allowGet"]="true";
|
|
|
866 |
#$conf["limitPrePage"],字串陣列,限定前一頁的網址須爲改陣列裏面的其中一個位置,才能接收內容,不符合則轉址。
|
|
|
867 |
#$conf["limitPrePage"]=array();
|
|
|
868 |
#$conf["transferLocation"],字串,如果是用GET傳值,則轉址到那個網址,預設爲資安素養網"https://isafe.moe.edu.tw/"
|
|
|
869 |
#$conf["transferLocation"]="";#
|
|
|
870 |
#$conf["correctCharacter"],字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設為"true".
|
|
|
871 |
#$conf["correctCharacter"]="false";
|
|
|
872 |
#參考資料:
|
|
|
873 |
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
|
|
|
874 |
#備註:
|
|
|
875 |
#無.
|
|
|
876 |
*/
|
|
|
877 |
public static function responseInputDataSecurityEnhance(&$conf){
|
|
|
878 |
|
|
|
879 |
#初始化要回傳的變數
|
|
|
880 |
$result=array();
|
|
|
881 |
|
|
|
882 |
#設置當前執行的函式
|
|
|
883 |
$result["function"]=__FUNCTION__;
|
|
|
884 |
|
|
|
885 |
#如果 $conf 不為陣列
|
|
|
886 |
if(gettype($conf)!="array"){
|
|
|
887 |
|
|
|
888 |
#設置執行失敗
|
|
|
889 |
$result["status"]="false";
|
|
|
890 |
|
|
|
891 |
#設置執行錯誤訊息
|
|
|
892 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
893 |
|
|
|
894 |
#如果傳入的參數為 null
|
|
|
895 |
if($conf==null){
|
|
|
896 |
|
|
|
897 |
#設置執行錯誤訊息
|
|
|
898 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
899 |
|
|
|
900 |
}#if end
|
|
|
901 |
|
|
|
902 |
#回傳結果
|
|
|
903 |
return $result;
|
|
|
904 |
|
|
|
905 |
}#if end
|
|
|
906 |
|
|
|
907 |
#檢查參數
|
|
|
908 |
#函式說明:
|
|
|
909 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
910 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
911 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
912 |
#$result["function"],當前執行的函式名稱.
|
|
|
913 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
914 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
915 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
916 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
917 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
918 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
919 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
920 |
#必填參數:
|
|
|
921 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
922 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
923 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
924 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("inputName");
|
|
|
925 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
926 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
927 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
928 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
929 |
#可省略參數:
|
|
|
930 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
931 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
932 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
933 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("receiveType","allowGet","limitPrePage","transferLocation","correctCharacter");
|
|
|
934 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
935 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array","string","string");
|
|
|
936 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
937 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("POST","false",null,"https://isafe.moe.edu.tw/","true");
|
|
|
938 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
939 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
940 |
#參考資料:
|
|
|
941 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
942 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
943 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
944 |
|
|
|
945 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
946 |
if($checkArguments["status"]=="false"){
|
|
|
947 |
|
|
|
948 |
#設置錯誤識別
|
|
|
949 |
$result["status"]="false";
|
|
|
950 |
|
|
|
951 |
#設置錯誤訊息
|
|
|
952 |
$result["error"]=$checkArguments;
|
|
|
953 |
|
|
|
954 |
#回傳結果
|
|
|
955 |
return $result;
|
|
|
956 |
|
|
|
957 |
}#if end
|
|
|
958 |
|
|
|
959 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
960 |
if($checkArguments["passed"]=="false"){
|
|
|
961 |
|
|
|
962 |
#設置錯誤識別
|
|
|
963 |
$result["status"]="false";
|
|
|
964 |
|
|
|
965 |
#設置錯誤訊息
|
|
|
966 |
$result["error"]=$checkArguments;
|
|
|
967 |
|
|
|
968 |
#回傳結果
|
|
|
969 |
return $result;
|
|
|
970 |
|
|
|
971 |
}#if end
|
|
|
972 |
|
|
|
973 |
#如果 $_SERVER["HTTP_REFERER"] 存在
|
|
|
974 |
if(isset($_SERVER["HTTP_REFERER"])){
|
|
|
975 |
|
|
|
976 |
#取得前一個網址
|
|
|
977 |
$result["HTTP_REFERER"]=basename($_SERVER["HTTP_REFERER"]);
|
|
|
978 |
|
|
|
979 |
}#if end
|
|
|
980 |
|
|
|
981 |
#反之 $_SERVER["HTTP_REFERER"] 不存在
|
|
|
982 |
else{
|
|
|
983 |
|
|
|
984 |
#設為 null
|
|
|
985 |
$result["HTTP_REFERER"]=null;
|
|
|
986 |
|
|
|
987 |
}#else end
|
|
|
988 |
|
|
|
989 |
#初始化接收的變數內容
|
|
|
990 |
#$result["reveivedVarName"]="";
|
|
|
991 |
#$result["receivedVarValue"]="";
|
|
|
992 |
|
|
|
993 |
#更正 post 的名稱
|
|
|
994 |
if($conf["receiveType"]=="post"){
|
|
|
995 |
|
|
|
996 |
$conf["receiveType"]="POST";
|
|
|
997 |
|
|
|
998 |
}#if end
|
|
|
999 |
|
|
|
1000 |
#更正 get 的名稱
|
|
|
1001 |
if($conf["receiveType"]=="get"){
|
|
|
1002 |
|
|
|
1003 |
$conf["receiveType"]="GET";
|
|
|
1004 |
|
|
|
1005 |
}#if end
|
|
|
1006 |
|
|
|
1007 |
#如果是 post 的傳送方式
|
|
|
1008 |
if($conf["receiveType"]=="POST"){
|
|
|
1009 |
|
|
|
1010 |
#如果不存在要抓取的變數
|
|
|
1011 |
if(!isset($_POST[$conf["inputName"]])){
|
|
|
1012 |
|
|
|
1013 |
#設置執行狀態爲 "false"
|
|
|
1014 |
$result["status"]="false";
|
|
|
1015 |
|
|
|
1016 |
#設置錯誤訊息
|
|
|
1017 |
$result["error"]="key爲".$conf["inputName"]."的$".$conf["receiveType"]."變數不存在!";
|
|
|
1018 |
|
|
|
1019 |
#回傳結果
|
|
|
1020 |
return $result;
|
|
|
1021 |
|
|
|
1022 |
}#if end
|
|
|
1023 |
|
|
|
1024 |
#設置取得的變數內容
|
|
|
1025 |
$result["reveivedVarName"]=$conf["inputName"];
|
|
|
1026 |
$result["receivedVarValue"]=$_POST[$conf["inputName"]];
|
|
|
1027 |
|
|
|
1028 |
}#if end
|
|
|
1029 |
|
|
|
1030 |
#如果是 get 的傳送方式
|
|
|
1031 |
if($conf["receiveType"]=="GET"){
|
|
|
1032 |
|
|
|
1033 |
#如果不存在要抓取的變數
|
|
|
1034 |
if(!isset($_GET[$conf["inputName"]])){
|
|
|
1035 |
|
|
|
1036 |
#設置執行狀態爲 "false"
|
|
|
1037 |
$result["status"]="false";
|
|
|
1038 |
|
|
|
1039 |
#設置錯誤訊息
|
|
|
1040 |
$result["error"]="key爲".$conf["inputName"]."的$".$receiveType."變數不存在!";
|
|
|
1041 |
|
|
|
1042 |
#回傳結果
|
|
|
1043 |
return $result;
|
|
|
1044 |
|
|
|
1045 |
}#if end
|
|
|
1046 |
|
|
|
1047 |
#設置取得的變數內容
|
|
|
1048 |
$result["reveivedVarName"]=$conf["inputName"];
|
|
|
1049 |
$result["receivedVarValue"]=$_GET[$conf["inputName"]];
|
|
|
1050 |
|
|
|
1051 |
}#if end
|
|
|
1052 |
|
|
|
1053 |
#如果 $conf["allowGet"] 等於 "fasle"
|
|
|
1054 |
if($conf["allowGet"]=="false"){
|
|
|
1055 |
|
|
|
1056 |
#如果是用 get 傳送資料
|
|
|
1057 |
if(count($_GET)>0){
|
|
|
1058 |
|
|
|
1059 |
#設定session變數後,立即轉址
|
|
|
1060 |
#必填參數:
|
|
|
1061 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["transferLocation"];#為要轉址到的地方
|
|
|
1062 |
#若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
1063 |
#全民資安素養網爲 https://isafe.moe.edu.tw/
|
|
|
1064 |
#可省略參數:
|
|
|
1065 |
#$conf["sessionName"]=array("","","");#可省略,可以指派3維session變數的內容,此處爲該3維session變數的名稱。
|
|
|
1066 |
#$conf["sessionValue"]="";#可省略,該3維session變數的內容爲設爲何?
|
|
|
1067 |
#參靠資料來源:
|
|
|
1068 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
1069 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1070 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1071 |
|
|
|
1072 |
}#if end
|
|
|
1073 |
|
|
|
1074 |
}#if end
|
|
|
1075 |
|
|
|
1076 |
#如果 $conf["limitPrePage"] 有設定
|
|
|
1077 |
if(isset($conf["limitPrePage"])){
|
|
|
1078 |
|
|
|
1079 |
#如果 $conf["limitPrePage"] 為陣列型別
|
|
|
1080 |
if(gettype($conf["limitPrePage"])=="array"){
|
|
|
1081 |
|
|
|
1082 |
#檢查 前一拜訪頁的位址 是否在 $conf["limitPrePage"] 陣列裡面
|
|
|
1083 |
#函式說明:
|
|
|
1084 |
#檢查一個數值是否與陣列裏面的元素相同
|
|
|
1085 |
#回傳的結果:
|
|
|
1086 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
1087 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
1088 |
#$result["error"],錯誤訊息
|
|
|
1089 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
1090 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
1091 |
#必填參數:
|
|
|
1092 |
$conf["search"]["getEqualVar"]["conditionElement"]=basename($_SERVER["HTTP_REFERER"]);#條件元素,要等於的元素內容.
|
|
|
1093 |
$conf["search"]["getEqualVar"]["compareElements"]=$conf["limitPrePage"];#要比對的陣列變數內容.
|
|
|
1094 |
$getMatchResult=search::getEqualVar($conf["search"]["getEqualVar"]);
|
|
|
1095 |
unset($conf["search"]["getEqualVar"]);
|
|
|
1096 |
|
|
|
1097 |
#如果檢查出錯
|
|
|
1098 |
if($getMatchResult["status"]=="false"){
|
|
|
1099 |
|
|
|
1100 |
#設置錯誤識別
|
|
|
1101 |
$result["status"]="false";
|
|
|
1102 |
|
|
|
1103 |
#設置錯誤訊息
|
|
|
1104 |
$result["error"]=$getMatchResult;
|
|
|
1105 |
|
|
|
1106 |
#回傳結果
|
|
|
1107 |
return $result;
|
|
|
1108 |
|
|
|
1109 |
}#if end
|
|
|
1110 |
|
|
|
1111 |
#如果 $getMatchResult["founded"] 等於 "false"
|
|
|
1112 |
if($getMatchResult["founded"]=="false"){
|
|
|
1113 |
|
|
|
1114 |
#轉址
|
|
|
1115 |
#函式說明:
|
|
|
1116 |
#設定session變數後,立即轉址.
|
|
|
1117 |
#回傳的結果:
|
|
|
1118 |
#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
|
|
|
1119 |
#$result["error"],錯誤訊息陣列.
|
|
|
1120 |
#必填參數:
|
|
|
1121 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
1122 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["transferLocation"];
|
|
|
1123 |
#可省略的參數:
|
|
|
1124 |
#$conf["sessionName"],可省略,可以指派3維session變數的內容,此處爲該3維session變數的名稱.
|
|
|
1125 |
#$conf["sessionName"]=array("","","");
|
|
|
1126 |
#$conf["sessionValue"],可省略,該3維session變數的內容爲設爲何?
|
|
|
1127 |
#$conf["sessionValue"]="";
|
|
|
1128 |
#$conf["hostUnderNat"],為伺服器是否為透過NAT轉封包,且有設定轉址."true"為是,"true"的話會將轉址的服務修正,以免轉址到不能連線到的ip.
|
|
|
1129 |
#$conf["hostUnderNat"]["protocol"],#要連線到伺服器的通訊協定,"http"與"https"是可以用的選項.
|
|
|
1130 |
#$conf["hostUnderNat"]["protocol"]="https";
|
|
|
1131 |
#$conf["hostUnderNat"]["localhostIP"],可省略,為伺服器的IP位置.
|
|
|
1132 |
#$conf["hostUnderNat"]["localhostIP"]="";
|
|
|
1133 |
#參靠資料來源:
|
|
|
1134 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
1135 |
#建議:
|
|
|
1136 |
#新增可應用於在虛擬機器下透過NAT上網,且透過轉port的方式也能正確地轉址的辦法.
|
|
|
1137 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1138 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1139 |
|
|
|
1140 |
}#if end
|
|
|
1141 |
|
|
|
1142 |
}#if end
|
|
|
1143 |
|
|
|
1144 |
#反之代表參數型別有錯
|
|
|
1145 |
else{
|
|
|
1146 |
|
|
|
1147 |
#設置錯誤識別
|
|
|
1148 |
$result["status"]="false";
|
|
|
1149 |
|
|
|
1150 |
#設置錯誤訊息
|
|
|
1151 |
$result["error"]="\$conf[\"limitPrePage\"]參數須為字串陣列";
|
|
|
1152 |
|
|
|
1153 |
#回傳結果
|
|
|
1154 |
return $result;
|
|
|
1155 |
|
|
|
1156 |
}#else end
|
|
|
1157 |
|
|
|
1158 |
}#if end
|
|
|
1159 |
|
|
|
1160 |
#如果 $conf["correctCharacter"] 等於 true
|
|
|
1161 |
if($conf["correctCharacter"]=="true"){
|
|
|
1162 |
|
|
|
1163 |
#函式說明:
|
|
|
1164 |
#處理字串避免網頁出錯
|
|
|
1165 |
#回傳結果:
|
|
|
1166 |
#$result,爲處理好的字串。
|
|
|
1167 |
#必填參數:
|
|
|
1168 |
$conf["stringProcess"]["correctCharacter"]["stringIn"]=$result["receivedVarValue"];#爲要處理的字串
|
|
|
1169 |
#可省略的參數:
|
|
|
1170 |
#$conf["selectedCharacter"]=array("");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
1171 |
#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*/","#")。
|
|
|
1172 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
1173 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
|
|
|
1174 |
unset($conf["stringProcess"]["correctCharacter"]);
|
|
|
1175 |
|
|
|
1176 |
#如果修正字串失敗
|
|
|
1177 |
if($correctCharacter["status"]=="false"){
|
|
|
1178 |
|
|
|
1179 |
#設置錯誤識別
|
|
|
1180 |
$result["status"]="false";
|
|
|
1181 |
|
|
|
1182 |
#設置錯誤訊息
|
|
|
1183 |
$result["error"]=$correctCharacter;
|
|
|
1184 |
|
|
|
1185 |
#回傳結果
|
|
|
1186 |
return $result;
|
|
|
1187 |
|
|
|
1188 |
}#if end
|
|
|
1189 |
|
|
|
1190 |
#取得修正後接收到的變數內容
|
|
|
1191 |
$result["receivedVarValue"]=$correctCharacter["content"];
|
|
|
1192 |
|
|
|
1193 |
}#if end
|
|
|
1194 |
|
|
|
1195 |
#設置執行成功狀態
|
|
|
1196 |
$result["status"]="true";
|
|
|
1197 |
|
|
|
1198 |
#回傳結果
|
|
|
1199 |
return $result;
|
|
|
1200 |
|
|
|
1201 |
}#function responseInputDataSecurityEnhance end
|
|
|
1202 |
|
|
|
1203 |
/*
|
|
|
1204 |
#函式說明:
|
|
|
1205 |
#可以處理多個透過GET、POST而來的資訊,儲存成變數。
|
|
|
1206 |
#回傳結果:
|
|
|
1207 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
1208 |
#$result["error"],錯誤訊息陣列.
|
|
|
1209 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
1210 |
#$result["inputDataContent"],所接收的參數陣列。
|
|
|
1211 |
#$result["inputDataCount"],總共接收到幾個元素。
|
|
|
1212 |
#$result["inputDataKey"],所接收到的參數陣列元素key值。
|
|
|
1213 |
#必填參數:
|
|
|
1214 |
$conf["method"]="";#傳送過來的資料是用"post/POST"還是"get/GET"?
|
|
|
1215 |
#可省略參數:
|
|
|
1216 |
#$conf["stopGetMethod"]="true";#若設爲"true",則遇到以get方式傳送過來的數值時,則進行轉址,若為"false"則不轉址,預設為"true".
|
|
|
1217 |
#$conf["transferLocation"]="";#遇到get傳值的時候要轉址到的頁面,預設爲資安素養網"https:#isafe.moe.edu.tw/"
|
|
|
1218 |
#$conf["ignore"]=array();#如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面。
|
|
|
1219 |
#$conf["correctCharacter"]="false";#如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理。
|
|
|
1220 |
#參考資料:
|
|
|
1221 |
#foreach 的用法 -> http:#php.net/manual/en/control-structures.foreach.php
|
|
|
1222 |
#備註:
|
|
|
1223 |
#建議改用 responseInputData 實作
|
|
|
1224 |
*/
|
|
|
1225 |
public static function responseMultiInputData(&$conf){
|
|
|
1226 |
|
|
|
1227 |
#初始化要回傳的變數
|
|
|
1228 |
$result=array();
|
|
|
1229 |
|
|
|
1230 |
#設置當前執行的函式
|
|
|
1231 |
$result["function"]=__FUNCTION__;
|
|
|
1232 |
|
|
|
1233 |
#如果 $conf 不為陣列
|
|
|
1234 |
if(gettype($conf)!="array"){
|
|
|
1235 |
|
|
|
1236 |
#設置執行失敗
|
|
|
1237 |
$result["status"]="false";
|
|
|
1238 |
|
|
|
1239 |
#設置執行錯誤訊息
|
|
|
1240 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1241 |
|
|
|
1242 |
#如果傳入的參數為 null
|
|
|
1243 |
if($conf==null){
|
|
|
1244 |
|
|
|
1245 |
#設置執行錯誤訊息
|
|
|
1246 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1247 |
|
|
|
1248 |
}#if end
|
|
|
1249 |
|
|
|
1250 |
#回傳結果
|
|
|
1251 |
return $result;
|
|
|
1252 |
|
|
|
1253 |
}#if end
|
|
|
1254 |
|
|
|
1255 |
#檢查參數
|
|
|
1256 |
#函式說明:
|
|
|
1257 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1258 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1259 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1260 |
#$result["function"],當前執行的函式名稱.
|
|
|
1261 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1262 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1263 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1264 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1265 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
1266 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
1267 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
1268 |
#必填參數:
|
|
|
1269 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1270 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
1271 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1272 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("method");
|
|
|
1273 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1274 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
1275 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1276 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
1277 |
#可省略參數:
|
|
|
1278 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
1279 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
1280 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1281 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("stopGetMethod","transferLocation","ignore","correctCharacter");
|
|
|
1282 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1283 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array","string");
|
|
|
1284 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1285 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","https://isafe.moe.edu.tw/",null,"true");
|
|
|
1286 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1287 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
1288 |
#參考資料:
|
|
|
1289 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
1290 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1291 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1292 |
|
|
|
1293 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
1294 |
if($checkArguments["status"]=="false"){
|
|
|
1295 |
|
|
|
1296 |
#設置錯誤識別
|
|
|
1297 |
$result["status"]="false";
|
|
|
1298 |
|
|
|
1299 |
#設置錯誤訊息
|
|
|
1300 |
$result["error"]=$checkArguments;
|
|
|
1301 |
|
|
|
1302 |
#回傳結果
|
|
|
1303 |
return $result;
|
|
|
1304 |
|
|
|
1305 |
}#if end
|
|
|
1306 |
|
|
|
1307 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
1308 |
if($checkArguments["passed"]=="false"){
|
|
|
1309 |
|
|
|
1310 |
#設置錯誤識別
|
|
|
1311 |
$result["status"]="false";
|
|
|
1312 |
|
|
|
1313 |
#設置錯誤訊息
|
|
|
1314 |
$result["error"]=$checkArguments;
|
|
|
1315 |
|
|
|
1316 |
#回傳結果
|
|
|
1317 |
return $result;
|
|
|
1318 |
|
|
|
1319 |
}#if end
|
|
|
1320 |
|
|
|
1321 |
#若有表單透過GET傳送的資料
|
|
|
1322 |
#$_GET變數有可能有設定,但是是爲!isset,所以改用 !isset 來判斷是否爲空值
|
|
|
1323 |
if(!isset($_GET)){
|
|
|
1324 |
|
|
|
1325 |
#如果 $conf["stopGetMethod"] 有設定
|
|
|
1326 |
if(isset($conf["stopGetMethod"])){
|
|
|
1327 |
|
|
|
1328 |
#如果 $conf["stopGetMethod"] 爲 "true"
|
|
|
1329 |
if($conf["stopGetMethod"]=="true"){
|
|
|
1330 |
|
|
|
1331 |
#如果 $conf["transferLocation"] 有設定
|
|
|
1332 |
if(isset($conf["transferLocation"])){
|
|
|
1333 |
|
|
|
1334 |
#進行轉址的動作
|
|
|
1335 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["header"]["redirectionNow"]["transferLocation"];
|
|
|
1336 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1337 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1338 |
|
|
|
1339 |
}#if end
|
|
|
1340 |
|
|
|
1341 |
#如果 $conf["transferLocation"] 沒有設定
|
|
|
1342 |
else{
|
|
|
1343 |
|
|
|
1344 |
#進行預設的轉址位置
|
|
|
1345 |
$conf["header"]["redirectionNow"]["headerLocation"]="https:#isafe.moe.edu.tw/";
|
|
|
1346 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1347 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1348 |
|
|
|
1349 |
}#else end
|
|
|
1350 |
|
|
|
1351 |
}#if end
|
|
|
1352 |
|
|
|
1353 |
}#if end
|
|
|
1354 |
|
|
|
1355 |
}#if end
|
|
|
1356 |
|
|
|
1357 |
#初始化接收到的變數
|
|
|
1358 |
$result["inputDataContent"]=array();
|
|
|
1359 |
|
|
|
1360 |
#依據 $conf["method"] 判別
|
|
|
1361 |
switch($conf["method"]){
|
|
|
1362 |
|
|
|
1363 |
#如果 $conf["method"] 爲 "post"
|
|
|
1364 |
case "post":
|
|
|
1365 |
|
|
|
1366 |
#改為 "POST"
|
|
|
1367 |
$conf["method"]="POST";
|
|
|
1368 |
|
|
|
1369 |
#如果 $conf["method"] 爲 "POST"
|
|
|
1370 |
case "POST":
|
|
|
1371 |
|
|
|
1372 |
#陣列元素名稱的key編號初始值
|
|
|
1373 |
$inputDataKeyNum=0;
|
|
|
1374 |
|
|
|
1375 |
#將每個透過 POST 方式吃傳送過來的變數,轉存到變數裏面。
|
|
|
1376 |
foreach($_POST as $elementKey => $elementValue){
|
|
|
1377 |
|
|
|
1378 |
#如果 $conf["correctCharacter"]爲 "true"
|
|
|
1379 |
if($conf["correctCharacter"]==="true"){
|
| 226 |
liveuser |
1380 |
|
| 3 |
liveuser |
1381 |
#檢查是否邀接收的變數名稱是否為要忽略的清單裡面
|
|
|
1382 |
#回傳結果:
|
|
|
1383 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1384 |
#$result["function"],當前執行的函數
|
|
|
1385 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
1386 |
#$result["founded"][$i],若爲0代表沒有相同的元素;反之1代表有相同的元素,$i爲第i+1個參數判斷後的結果。
|
|
|
1387 |
#必填參數:
|
|
|
1388 |
$conf_checkEquality["inputElement"]=array($elementKey);#爲要進行比對的變數/數值。
|
|
|
1389 |
$conf_checkEquality["blackBoxElement"]=$conf["ignore"];#爲用來比對的變數/數值陣列
|
|
|
1390 |
$result_checkEquality=search::checkEquality($conf_checkEquality);
|
|
|
1391 |
unset($conf_checkEquality);
|
|
|
1392 |
|
|
|
1393 |
#如果檢查失敗
|
|
|
1394 |
if($result_checkEquality["status"]=="false"){
|
|
|
1395 |
|
|
|
1396 |
#設置錯誤識別
|
|
|
1397 |
$result["status"]="false";
|
|
|
1398 |
|
|
|
1399 |
#設置錯誤訊息
|
|
|
1400 |
$result["error"]=$result_checkEquality;
|
|
|
1401 |
|
|
|
1402 |
#回傳結果
|
|
|
1403 |
return $result;
|
|
|
1404 |
|
|
|
1405 |
}#if end
|
|
|
1406 |
|
|
|
1407 |
#如果變數的名稱等於要忽略的變數項目之一
|
|
|
1408 |
if($result_checkEquality["founded"][0]=="true"){
|
|
|
1409 |
|
|
|
1410 |
#略過這個變數的處理
|
|
|
1411 |
continue;
|
|
|
1412 |
|
| 226 |
liveuser |
1413 |
}#if end
|
|
|
1414 |
|
| 3 |
liveuser |
1415 |
#處理字串避免網頁出錯
|
|
|
1416 |
#函式說明:
|
|
|
1417 |
#處理字串避免網頁出錯
|
|
|
1418 |
#回傳結果:
|
|
|
1419 |
#$result,爲處理好的字串。
|
|
|
1420 |
#必天寫的參數:
|
|
|
1421 |
$conf_correctCharacter["stringIn"]=$elementValue;#爲要處理的字串
|
|
|
1422 |
#可省略的參數:
|
|
|
1423 |
#$conf["selectedCharacter"]=array("");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
1424 |
#若不設定則預設爲要將這些字串作替換(" ","<",">",";","=","#","*","'","$","%","&","|")。
|
|
|
1425 |
#$conf["changeTo"];#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
1426 |
$correctCharacter=stringProcess::correctCharacter($conf_correctCharacter);
|
|
|
1427 |
unset($conf_correctCharacter);
|
|
|
1428 |
|
|
|
1429 |
#如果矯正接收的變數內容失敗
|
|
|
1430 |
if($correctCharacter["status"]=="false"){
|
|
|
1431 |
|
|
|
1432 |
#設置錯誤識別
|
|
|
1433 |
$result["status"]="false";
|
|
|
1434 |
|
|
|
1435 |
#設置錯誤訊息
|
|
|
1436 |
$result["error"]=$correctCharacter;
|
|
|
1437 |
|
|
|
1438 |
#回傳結果
|
|
|
1439 |
return $result;
|
|
|
1440 |
|
|
|
1441 |
}#if end
|
|
|
1442 |
|
|
|
1443 |
#取得處理的變數字串內容
|
|
|
1444 |
$elementValue=$correctCharacter["content"];
|
|
|
1445 |
|
|
|
1446 |
}#if end
|
|
|
1447 |
|
|
|
1448 |
#如果 $conf["ignore"] 存在
|
|
|
1449 |
if(isset($conf["ignore"])){
|
|
|
1450 |
|
|
|
1451 |
#檢查是否邀接收的變數名稱是否為要忽略的清單裡面
|
|
|
1452 |
#回傳結果:
|
|
|
1453 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1454 |
#$result["function"],當前執行的函數
|
|
|
1455 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
1456 |
#$result["founded"][$i],若爲0代表沒有相同的元素;反之1代表有相同的元素,$i爲第i+1個參數判斷後的結果。
|
|
|
1457 |
#必填參數:
|
|
|
1458 |
$conf_checkEquality["inputElement"]=array($elementKey);#爲要進行比對的變數/數值。
|
|
|
1459 |
$conf_checkEquality["blackBoxElement"]=$conf["ignore"];#爲用來比對的變數/數值陣列
|
|
|
1460 |
$result_checkEquality=search::checkEquality($conf_checkEquality);
|
|
|
1461 |
unset($conf_checkEquality);
|
|
|
1462 |
|
|
|
1463 |
#如果檢查失敗
|
|
|
1464 |
if($result_checkEquality["status"]=="false"){
|
|
|
1465 |
|
|
|
1466 |
#設置錯誤識別
|
|
|
1467 |
$result["status"]="false";
|
|
|
1468 |
|
|
|
1469 |
#設置錯誤訊息
|
|
|
1470 |
$result["error"]=$result_checkEquality;
|
|
|
1471 |
|
|
|
1472 |
#回傳結果
|
|
|
1473 |
return $result;
|
|
|
1474 |
|
|
|
1475 |
}#if end
|
|
|
1476 |
|
|
|
1477 |
#如果變數的名稱等於要忽略的變數項目之一
|
|
|
1478 |
if($result_checkEquality["founded"][0]=="true"){
|
|
|
1479 |
|
|
|
1480 |
#略過這個變數的取得
|
|
|
1481 |
continue;
|
|
|
1482 |
|
|
|
1483 |
}#if end
|
|
|
1484 |
|
|
|
1485 |
#如果變數名稱不等於要忽略的變數項目之一
|
|
|
1486 |
else{
|
|
|
1487 |
|
|
|
1488 |
#將每個透過 POST 方式吃傳送過來的變數,轉存到 $result["inputDataContent"] 陣列變數裏面。
|
|
|
1489 |
$result["inputDataContent"][$elementKey]=$elementValue;
|
|
|
1490 |
|
|
|
1491 |
#將每個透過 POST 方式傳送過來的變數名稱,轉存到 $result["inputDataKey"] 陣列變數裏面。
|
|
|
1492 |
$result["inputDataKey"][$inputDataKeyNum]=$elementKey;
|
|
|
1493 |
|
|
|
1494 |
#陣列元素名稱的key加1
|
|
|
1495 |
$inputDataKeyNum++;
|
|
|
1496 |
|
|
|
1497 |
}#else end
|
|
|
1498 |
|
|
|
1499 |
}#if end
|
|
|
1500 |
|
|
|
1501 |
#反之不存在要忽略接收的變數
|
|
|
1502 |
else{
|
|
|
1503 |
|
|
|
1504 |
#將每個透過 POST 方式傳送過來的變數,轉存到 $result["inputDataContent"] 陣列變數裏面。
|
|
|
1505 |
$result["inputDataContent"][$elementKey]=$elementValue;
|
|
|
1506 |
|
|
|
1507 |
#將每個透過 POST 方式傳送過來的變數名稱,轉存到 $result["inputDataKey"] 陣列變數裏面。
|
|
|
1508 |
$result["inputDataKey"][$inputDataKeyNum]=$elementKey;$inputDataKeyNum++;
|
|
|
1509 |
|
|
|
1510 |
}#else end
|
|
|
1511 |
|
|
|
1512 |
}#foreach end
|
|
|
1513 |
|
|
|
1514 |
#取得總共有接收幾個變數
|
|
|
1515 |
$result["inputDataCount"]=count($result["inputDataContent"]);
|
|
|
1516 |
|
|
|
1517 |
#跳出 switch
|
|
|
1518 |
break;
|
|
|
1519 |
|
|
|
1520 |
#如果 $conf["method"] 爲 "get"
|
|
|
1521 |
case "get":
|
|
|
1522 |
|
|
|
1523 |
#改為 "get"
|
|
|
1524 |
$conf["method"]="GET";
|
|
|
1525 |
|
|
|
1526 |
#如果 $conf["method"] 爲 "GET"
|
|
|
1527 |
case "GET":
|
|
|
1528 |
|
|
|
1529 |
#陣列元素名稱的key編號初始值
|
|
|
1530 |
$inputDataKeyNum=0;
|
|
|
1531 |
|
|
|
1532 |
#將每個透過 GET 方式吃傳送過來的變數,轉存到變數裏面。
|
|
|
1533 |
foreach($_GET as $elementKey => $elementValue){
|
|
|
1534 |
|
|
|
1535 |
#如果 $conf["correctCharacter"] 爲 "true"
|
|
|
1536 |
if($conf["correctCharacter"]==="true"){
|
|
|
1537 |
|
|
|
1538 |
#處理字串避免網頁出錯
|
|
|
1539 |
#函式說明:
|
|
|
1540 |
#處理字串避免網頁出錯
|
|
|
1541 |
#回傳結果:
|
|
|
1542 |
#$result,爲處理好的字串。
|
|
|
1543 |
#必天寫的參數:
|
|
|
1544 |
$conf_correctCharacter["stringIn"]=$elementValue;#爲要處理的字串
|
|
|
1545 |
#可省略的參數:
|
|
|
1546 |
#$conf["selectedCharacter"]=array("");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
1547 |
#若不設定則預設爲要將這些字串作替換(" ","<",">",";","=","#","*","'","$","%","&","|")。
|
|
|
1548 |
#$conf["changeTo"];#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
1549 |
$correctCharacter=stringProcess::correctCharacter($conf_correctCharacter);
|
|
|
1550 |
unset($conf_correctCharacter);
|
|
|
1551 |
|
|
|
1552 |
#如果矯正接收的變數內容失敗
|
|
|
1553 |
if($correctCharacter["status"]=="false"){
|
|
|
1554 |
|
|
|
1555 |
#設置錯誤識別
|
|
|
1556 |
$result["status"]="false";
|
|
|
1557 |
|
|
|
1558 |
#設置錯誤訊息
|
|
|
1559 |
$result["error"]=$correctCharacter;
|
|
|
1560 |
|
|
|
1561 |
#回傳結果
|
|
|
1562 |
return $result;
|
|
|
1563 |
|
|
|
1564 |
}#if end
|
|
|
1565 |
|
|
|
1566 |
#取得處理的變數字串內容
|
|
|
1567 |
$elementValue=$correctCharacter["content"];
|
|
|
1568 |
|
|
|
1569 |
}#if end
|
|
|
1570 |
|
|
|
1571 |
#如果 $conf["ignore"] 存在
|
|
|
1572 |
if(isset($conf["ignore"])){
|
|
|
1573 |
|
|
|
1574 |
#檢查是否邀接收的變數名稱是否為要忽略的清單裡面
|
|
|
1575 |
#回傳結果:
|
|
|
1576 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1577 |
#$result["function"],當前執行的函數
|
|
|
1578 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
1579 |
#$result["founded"][$i],若爲0代表沒有相同的元素;反之1代表有相同的元素,$i爲第i+1個參數判斷後的結果。
|
|
|
1580 |
#必填參數:
|
|
|
1581 |
$conf_checkEquality["inputElement"]=array($elementKey);#爲要進行比對的變數/數值。
|
|
|
1582 |
$conf_checkEquality["blackBoxElement"]=$conf["ignore"];#爲用來比對的變數/數值陣列
|
|
|
1583 |
$result_checkEquality=search::checkEquality($conf_checkEquality);
|
|
|
1584 |
unset($conf_checkEquality);
|
|
|
1585 |
|
|
|
1586 |
#如果檢查失敗
|
|
|
1587 |
if($result_checkEquality["status"]=="false"){
|
|
|
1588 |
|
|
|
1589 |
#設置錯誤識別
|
|
|
1590 |
$result["status"]="false";
|
|
|
1591 |
|
|
|
1592 |
#設置錯誤訊息
|
|
|
1593 |
$result["error"]=$result_checkEquality;
|
|
|
1594 |
|
|
|
1595 |
#回傳結果
|
|
|
1596 |
return $result;
|
|
|
1597 |
|
|
|
1598 |
}#if end
|
|
|
1599 |
|
|
|
1600 |
#如果變數的名稱等於要忽略的變數項目之一
|
|
|
1601 |
if($result_checkEquality["founded"][0]=="true"){
|
|
|
1602 |
|
|
|
1603 |
#略過這個變數的取得
|
|
|
1604 |
continue;
|
|
|
1605 |
|
|
|
1606 |
}#if end
|
|
|
1607 |
|
|
|
1608 |
#如果變數名稱不等於要忽略的變數項目之一
|
|
|
1609 |
else{
|
|
|
1610 |
|
|
|
1611 |
#將每個透過 POST 方式吃傳送過來的變數,轉存到 $result["inputDataContent"] 陣列變數裏面。
|
|
|
1612 |
$result["inputDataContent"][$elementKey]=$elementValue;
|
|
|
1613 |
|
|
|
1614 |
#將每個透過 POST 方式傳送過來的變數名稱,轉存到 $result["inputDataKey"] 陣列變數裏面。
|
|
|
1615 |
$result["inputDataKey"][$inputDataKeyNum]=$elementKey;
|
|
|
1616 |
|
|
|
1617 |
#陣列元素名稱的key加1
|
|
|
1618 |
$inputDataKeyNum++;
|
|
|
1619 |
|
|
|
1620 |
}#else end
|
|
|
1621 |
|
|
|
1622 |
}#if end
|
|
|
1623 |
|
|
|
1624 |
}#foreach end
|
|
|
1625 |
|
|
|
1626 |
#取得總共有接收幾個變數
|
|
|
1627 |
$result["inputDataCount"]=count($result["inputDataContent"]);
|
|
|
1628 |
|
|
|
1629 |
#跳出 switch
|
|
|
1630 |
break;
|
|
|
1631 |
|
|
|
1632 |
}#switch end
|
|
|
1633 |
|
|
|
1634 |
#執行到這邊代表正常
|
|
|
1635 |
$result["status"]="true";
|
|
|
1636 |
|
|
|
1637 |
#回傳結果陣列
|
|
|
1638 |
return $result;
|
|
|
1639 |
|
|
|
1640 |
}#responseMutiInputData function end
|
|
|
1641 |
|
|
|
1642 |
/*
|
|
|
1643 |
#函式說明:
|
|
|
1644 |
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
|
|
|
1645 |
#回傳結果:
|
|
|
1646 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
1647 |
#$result["error"],錯誤訊息陣列.
|
|
|
1648 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
1649 |
#$result["warning"],警告訊息陣列.
|
|
|
1650 |
#$result["passed"],是否有皆收到全部該接收到的變數,若有設定$conf["checkedVarName"]的話,執行正常後會回傳該結果。
|
|
|
1651 |
#$result["lostVarName"],沒有皆收到的變數名稱陣列
|
|
|
1652 |
#$result["inputDataContent"],所接收的參數陣列.
|
|
|
1653 |
#$result["inputDataContent"]["變數名稱"],所接收變數的內容.
|
|
|
1654 |
#$result["inputDataCount"],從表單總共接收到幾個元素.
|
|
|
1655 |
#$result["HTTP_REFERER"],前一頁的網址,null代表不存在.
|
|
|
1656 |
#必填參數:
|
|
|
1657 |
#$conf["method"],字串,傳送過來的資料是用"post/POST"還是"get/GET"?
|
|
|
1658 |
$conf["method"]="";
|
|
|
1659 |
#可省略參數:
|
|
|
1660 |
#$conf["allowGet"],字串,是否要允許 get 傳值,"true",代表允許;"false" ,代表不允許,預設爲不允許.
|
|
|
1661 |
#$conf["allowGet"]="true";
|
|
|
1662 |
#$conf["limitPrePage"],字串陣列,是否要限定前一頁的網址為哪些,才能接收內容,不符合則轉址.
|
|
|
1663 |
#$conf["limitPrePage"]=array("");
|
|
|
1664 |
#$conf["transferLocation"],字串,遇到get傳值,或前一個頁面不符合要求時要轉址到的頁面,預設爲資安素養網"https://isafe.moe.edu.tw/"
|
|
|
1665 |
#$conf["transferLocation"]="";
|
|
|
1666 |
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
|
|
|
1667 |
#$conf["ignore"]=array();
|
|
|
1668 |
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
|
|
|
1669 |
#$conf["correctCharacter"]="false";
|
|
|
1670 |
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
|
|
|
1671 |
#$conf["checkedVarName"]=array();
|
|
|
1672 |
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
|
|
|
1673 |
#$conf["canBeEmptyString"]="false";
|
|
|
1674 |
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
|
|
|
1675 |
#$conf["sessionNameArray"]=array();
|
| 30 |
liveuser |
1676 |
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,預設為"false"代表不要卸除.
|
| 3 |
liveuser |
1677 |
#$conf["unsetSessionArray"]=array();
|
|
|
1678 |
#參考資料:
|
|
|
1679 |
#foreach 的用法 -> http://php.net/manual/en/control-structures.foreach.php
|
|
|
1680 |
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
|
|
|
1681 |
#備註:
|
|
|
1682 |
#表單變數的名稱若含有「.」,則會變成「-」。
|
|
|
1683 |
*/
|
|
|
1684 |
public static function responseMultiInputDataSecurityEnhance(&$conf){
|
|
|
1685 |
|
|
|
1686 |
#設置回傳變數的初始值
|
|
|
1687 |
$result=array();
|
|
|
1688 |
|
|
|
1689 |
#設置當前執行的函式
|
|
|
1690 |
$result["function"]=__FUNCTION__;
|
|
|
1691 |
|
|
|
1692 |
#如果 $conf 不為陣列
|
|
|
1693 |
if(gettype($conf)!="array"){
|
|
|
1694 |
|
|
|
1695 |
#設置執行失敗
|
|
|
1696 |
$result["status"]="false";
|
|
|
1697 |
|
|
|
1698 |
#設置執行錯誤訊息
|
|
|
1699 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1700 |
|
|
|
1701 |
#如果傳入的參數為 null
|
|
|
1702 |
if($conf==null){
|
|
|
1703 |
|
|
|
1704 |
#設置執行錯誤訊息
|
|
|
1705 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1706 |
|
|
|
1707 |
}#if end
|
|
|
1708 |
|
|
|
1709 |
#回傳結果
|
|
|
1710 |
return $result;
|
|
|
1711 |
|
|
|
1712 |
}#if end
|
|
|
1713 |
|
|
|
1714 |
#如果 $_SERVER["HTTP_REFERER"] 存在
|
|
|
1715 |
if(isset($_SERVER["HTTP_REFERER"])){
|
|
|
1716 |
|
|
|
1717 |
#取得前一個網址
|
|
|
1718 |
$result["HTTP_REFERER"]=basename($_SERVER["HTTP_REFERER"]);
|
|
|
1719 |
|
|
|
1720 |
}#if end
|
|
|
1721 |
|
|
|
1722 |
#反之 $_SERVER["HTTP_REFERER"] 不存在
|
|
|
1723 |
else{
|
|
|
1724 |
|
|
|
1725 |
#設為 null
|
|
|
1726 |
$result["HTTP_REFERER"]=null;
|
|
|
1727 |
|
|
|
1728 |
}#else end
|
|
|
1729 |
|
|
|
1730 |
#檢查參數
|
|
|
1731 |
#函式說明:
|
|
|
1732 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1733 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1734 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1735 |
#$result["function"],當前執行的函式名稱.
|
|
|
1736 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1737 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1738 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1739 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1740 |
#必填參數:
|
|
|
1741 |
#$conf["variableCheck.checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1742 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
1743 |
#$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1744 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"][]="method";
|
|
|
1745 |
#$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1746 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"][]="string";
|
|
|
1747 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1748 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
1749 |
#可省略參數:
|
|
|
1750 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
1751 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
1752 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1753 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="allowGet";
|
|
|
1754 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="limitPrePage";
|
|
|
1755 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="transferLocation";
|
|
|
1756 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="ignore";
|
|
|
1757 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="correctCharacter";
|
|
|
1758 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="checkedVarName";
|
|
|
1759 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="canBeEmptyString";
|
|
|
1760 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="sessionNameArray";
|
|
|
1761 |
$conf["variableCheck.checkArguments"]["skipableVariableName"][]="unsetSessionArray";
|
|
|
1762 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1763 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="string";
|
|
|
1764 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="array";
|
|
|
1765 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="string";
|
|
|
1766 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="array";
|
|
|
1767 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="string";
|
|
|
1768 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="array";
|
|
|
1769 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="string";
|
|
|
1770 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="array";
|
|
|
1771 |
$conf["variableCheck.checkArguments"]["skipableVariableType"][]="array";
|
|
|
1772 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1773 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
1774 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
1775 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]="https://isafe.moe.edu.tw/";
|
|
|
1776 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
1777 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]="true";
|
|
|
1778 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
1779 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
1780 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
1781 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
1782 |
#$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1783 |
$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"][]=array("checkedVarName","sessionNameArray","unsetSessionArray");
|
|
|
1784 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
1785 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
1786 |
|
|
|
1787 |
#如果檢查失敗
|
|
|
1788 |
if($checkResult["status"]=="false"){
|
|
|
1789 |
|
|
|
1790 |
#設置錯誤
|
|
|
1791 |
$result["status"]="false";
|
|
|
1792 |
|
|
|
1793 |
#設置錯誤訊息
|
|
|
1794 |
$result["error"]=$checkResult;
|
|
|
1795 |
|
|
|
1796 |
#回傳結果
|
|
|
1797 |
return $result;
|
|
|
1798 |
|
|
|
1799 |
}#if end
|
|
|
1800 |
|
|
|
1801 |
#如果檢查不通過
|
|
|
1802 |
if($checkResult["passed"]=="false"){
|
|
|
1803 |
|
|
|
1804 |
#設置錯誤
|
|
|
1805 |
$result["status"]="false";
|
|
|
1806 |
|
|
|
1807 |
#設置錯誤訊息
|
|
|
1808 |
$result["error"]=$checkResult;
|
|
|
1809 |
|
|
|
1810 |
#回傳結果
|
|
|
1811 |
return $result;
|
|
|
1812 |
|
|
|
1813 |
}#if end
|
|
|
1814 |
|
|
|
1815 |
#如果有設置要檢查有無於特定網址取得google recaptcha認證
|
|
|
1816 |
if(isset($conf["recaptcha_url"])){
|
|
|
1817 |
|
|
|
1818 |
#函式說明:
|
|
|
1819 |
#檢查是否擁有透過gl_reCAPTCHA_server授權的session網址記錄.
|
|
|
1820 |
#回傳結果:
|
|
|
1821 |
#$result["status"],執行正常與否,"false"代表不正常;"true"代表正常.
|
|
|
1822 |
#$result["error"],錯誤訊息陣列.
|
|
|
1823 |
#$result["function"],函式名稱.
|
|
|
1824 |
#$result["passed"],"true"代表通過檢查,"false"代表沒有通過檢查.
|
|
|
1825 |
#必填參數:
|
|
|
1826 |
#$conf["url"],字串,要有什麼的網址才通過檢查
|
|
|
1827 |
$conf["authenticate::gl_reCAPTCH_authCheck"]["url"]=$conf["recaptcha_url"];
|
|
|
1828 |
$gl_reCAPTCH_authCheck=authenticate::gl_reCAPTCH_authCheck($conf["authenticate::gl_reCAPTCH_authCheck"]);
|
|
|
1829 |
unset($conf["authenticate::gl_reCAPTCH_authCheck"]);
|
|
|
1830 |
|
|
|
1831 |
#如果檢驗有無通過 google reCAPTCHA 的記錄 失敗
|
|
|
1832 |
if($gl_reCAPTCH_authCheck["status"]==="false"){
|
|
|
1833 |
|
|
|
1834 |
#設置錯誤
|
|
|
1835 |
$result["status"]="false";
|
|
|
1836 |
|
|
|
1837 |
#設置錯誤訊息
|
|
|
1838 |
$result["error"]=$gl_reCAPTCH_authCheck;
|
|
|
1839 |
|
|
|
1840 |
#回傳結果
|
|
|
1841 |
return $result;
|
|
|
1842 |
|
|
|
1843 |
}#if end
|
|
|
1844 |
|
|
|
1845 |
#如果無通過 google reCAPTCHA 的記錄
|
|
|
1846 |
if($gl_reCAPTCH_authCheck["passed"]==="false"){
|
|
|
1847 |
|
|
|
1848 |
#設置正常
|
|
|
1849 |
$result["status"]="true";
|
|
|
1850 |
|
|
|
1851 |
#設置沒通過測試
|
|
|
1852 |
$result["passed"]="false";
|
|
|
1853 |
|
|
|
1854 |
#設置錯誤訊息
|
|
|
1855 |
$result["error"]=$gl_reCAPTCH_authCheck;
|
|
|
1856 |
|
|
|
1857 |
#回傳結果
|
|
|
1858 |
return $result;
|
|
|
1859 |
|
|
|
1860 |
}#if end
|
|
|
1861 |
|
|
|
1862 |
}#if end
|
|
|
1863 |
|
|
|
1864 |
#如果 $conf["method"] 為 get
|
|
|
1865 |
if($conf["method"]=="get"){
|
|
|
1866 |
|
|
|
1867 |
#將之轉換為 "GET"
|
|
|
1868 |
$conf["method"]="GET";
|
|
|
1869 |
|
|
|
1870 |
}#if end
|
|
|
1871 |
|
|
|
1872 |
#如果 $conf["method"] 為 post
|
|
|
1873 |
if($conf["method"]=="post"){
|
|
|
1874 |
|
|
|
1875 |
#將之轉換為 "POST"
|
|
|
1876 |
$conf["method"]="POST";
|
|
|
1877 |
|
|
|
1878 |
}#if end
|
|
|
1879 |
|
|
|
1880 |
#如果不允許 get 要求
|
|
|
1881 |
if($conf["allowGet"]=="false"){
|
|
|
1882 |
|
|
|
1883 |
#如果有 get 要求存在
|
|
|
1884 |
if(count($_GET)>0){
|
|
|
1885 |
|
|
|
1886 |
#轉址
|
|
|
1887 |
#函式說明:
|
|
|
1888 |
#設定session變數後,立即轉址.
|
|
|
1889 |
#回傳的結果:
|
|
|
1890 |
#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
|
|
|
1891 |
#$result["error"],錯誤訊息陣列.
|
|
|
1892 |
#必填參數:
|
|
|
1893 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
1894 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["transferLocation"];
|
|
|
1895 |
#可省略的參數:
|
|
|
1896 |
#$conf["sessionName"],可省略,可以指派3維session變數的內容,此處爲該3維session變數的名稱.
|
|
|
1897 |
#$conf["sessionName"]=array("","","");
|
|
|
1898 |
#$conf["sessionValue"],可省略,該3維session變數的內容爲設爲何?
|
|
|
1899 |
#$conf["sessionValue"]="";
|
|
|
1900 |
#$conf["hostUnderNat"],為伺服器是否為透過NAT轉封包,且有設定轉址."true"為是,"true"的話會將轉址的服務修正,以免轉址到不能連線到的ip.
|
|
|
1901 |
#$conf["hostUnderNat"]["protocol"],#要連線到伺服器的通訊協定,"http"與"https"是可以用的選項.
|
|
|
1902 |
#$conf["hostUnderNat"]["protocol"]="https";
|
|
|
1903 |
#$conf["hostUnderNat"]["localhostIP"],可省略,為伺服器的IP位置.
|
|
|
1904 |
#$conf["hostUnderNat"]["localhostIP"]="";
|
|
|
1905 |
#參靠資料來源:
|
|
|
1906 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
1907 |
#建議:
|
|
|
1908 |
#新增可應用於在虛擬機器下透過NAT上網,且透過轉port的方式也能正確地轉址的辦法.
|
|
|
1909 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1910 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1911 |
|
|
|
1912 |
#debug
|
|
|
1913 |
#echo "<p><p>有$_GET變數<p>";
|
|
|
1914 |
#var_dump($_GET);
|
|
|
1915 |
|
|
|
1916 |
}#if end
|
|
|
1917 |
|
|
|
1918 |
}#if end
|
|
|
1919 |
|
|
|
1920 |
#如果 $conf["limitPrePage"] 有設定
|
|
|
1921 |
if(isset($conf["limitPrePage"])){
|
|
|
1922 |
|
|
|
1923 |
#如果有前一頁瀏覽的網址記錄
|
|
|
1924 |
if($result["HTTP_REFERER"]!=null){
|
|
|
1925 |
|
|
|
1926 |
#檢查 前一拜訪頁的位址 是否在 $conf["limitPrePage"] 陣列裡面
|
|
|
1927 |
#函式說明:
|
|
|
1928 |
#檢查一個數值是否與陣列裏面的元素相同
|
|
|
1929 |
#回傳的結果:
|
|
|
1930 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
1931 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
1932 |
#$result["error"],錯誤訊息
|
|
|
1933 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
1934 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
1935 |
#必填參數:
|
|
|
1936 |
$conf["search"]["getEqualVar"]["conditionElement"]=$result["HTTP_REFERER"];#條件元素,要等於的元素內容.
|
|
|
1937 |
$conf["search"]["getEqualVar"]["compareElements"]=$conf["limitPrePage"];#要比對的陣列變數內容.
|
|
|
1938 |
$getMatchResult=search::getEqualVar($conf["search"]["getEqualVar"]);
|
|
|
1939 |
unset($conf["search"]["getEqualVar"]);
|
|
|
1940 |
|
|
|
1941 |
#如果檢查出錯
|
|
|
1942 |
if($getMatchResult["status"]=="false"){
|
|
|
1943 |
|
|
|
1944 |
#設置錯誤識別
|
|
|
1945 |
$result["status"]="false";
|
|
|
1946 |
|
|
|
1947 |
#設置錯誤訊息
|
|
|
1948 |
$result["error"]=$getMatchResult;
|
|
|
1949 |
|
|
|
1950 |
#回傳結果
|
|
|
1951 |
return $result;
|
|
|
1952 |
|
|
|
1953 |
}#if end
|
|
|
1954 |
|
|
|
1955 |
#如果 $getMatchResult["founded"] 等於 "false"
|
|
|
1956 |
if($getMatchResult["founded"]==="false"){
|
|
|
1957 |
|
|
|
1958 |
#轉址
|
|
|
1959 |
#函式說明:
|
|
|
1960 |
#設定session變數後,立即轉址.
|
|
|
1961 |
#回傳的結果:
|
|
|
1962 |
#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
|
|
|
1963 |
#$result["error"],錯誤訊息陣列.
|
|
|
1964 |
#必填參數:
|
|
|
1965 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
1966 |
$conf["header"]["redirectionNow"]["headerLocation"]=$conf["transferLocation"];
|
|
|
1967 |
#可省略的參數:
|
|
|
1968 |
#$conf["sessionName"],可省略,可以指派3維session變數的內容,此處爲該3維session變數的名稱.
|
|
|
1969 |
#$conf["sessionName"]=array("","","");
|
|
|
1970 |
#$conf["sessionValue"],可省略,該3維session變數的內容爲設爲何?
|
|
|
1971 |
#$conf["sessionValue"]="";
|
|
|
1972 |
#$conf["hostUnderNat"],為伺服器是否為透過NAT轉封包,且有設定轉址."true"為是,"true"的話會將轉址的服務修正,以免轉址到不能連線到的ip.
|
|
|
1973 |
#$conf["hostUnderNat"]["protocol"],#要連線到伺服器的通訊協定,"http"與"https"是可以用的選項.
|
|
|
1974 |
#$conf["hostUnderNat"]["protocol"]="https";
|
|
|
1975 |
#$conf["hostUnderNat"]["localhostIP"],可省略,為伺服器的IP位置.
|
|
|
1976 |
#$conf["hostUnderNat"]["localhostIP"]="";
|
|
|
1977 |
#參靠資料來源:
|
|
|
1978 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
1979 |
#建議:
|
|
|
1980 |
#新增可應用於在虛擬機器下透過NAT上網,且透過轉port的方式也能正確地轉址的辦法.
|
|
|
1981 |
header::redirectionNow($conf["header"]["redirectionNow"]);
|
|
|
1982 |
unset($conf["header"]["redirectionNow"]);
|
|
|
1983 |
|
|
|
1984 |
}#if end
|
|
|
1985 |
|
|
|
1986 |
}#if end
|
|
|
1987 |
|
|
|
1988 |
#反之沒有記錄前一頁瀏覽的頁面
|
|
|
1989 |
else{
|
|
|
1990 |
|
|
|
1991 |
#設置警告訊息
|
|
|
1992 |
$result["warning"][]="無法取得前一個瀏覽的頁面";
|
|
|
1993 |
|
|
|
1994 |
}#else end
|
|
|
1995 |
|
|
|
1996 |
}#if end
|
|
|
1997 |
|
|
|
1998 |
#依據 $conf["method"] 來分類判斷
|
|
|
1999 |
switch($conf["method"]){
|
|
|
2000 |
|
|
|
2001 |
#如果 $conf["method"] 為 "GET"
|
|
|
2002 |
case "GET":
|
|
|
2003 |
|
|
|
2004 |
#抓取每個$_GET變數
|
|
|
2005 |
$getVarArray=$_GET;
|
|
|
2006 |
|
|
|
2007 |
#如果接收的$_GET變數數量等於0
|
|
|
2008 |
if(count($getVarArray)==0){
|
|
|
2009 |
|
|
|
2010 |
#設置抓到的表單變數數量為0
|
|
|
2011 |
$result["inputDataCount"]=0;
|
|
|
2012 |
|
|
|
2013 |
#設置空的 $result["inputDataContent"] 陣列
|
|
|
2014 |
$result["inputDataContent"]=array();
|
|
|
2015 |
|
|
|
2016 |
}#if end
|
|
|
2017 |
|
|
|
2018 |
#反之代表有 get 變數
|
|
|
2019 |
else{
|
|
|
2020 |
|
|
|
2021 |
#針對每個$_GET變數
|
|
|
2022 |
foreach($getVarArray as $getVarKey=>$getVarValue){
|
|
|
2023 |
|
|
|
2024 |
#轉存每個$_GET變數
|
|
|
2025 |
$result["inputDataContent"][$getVarKey]=$getVarValue;
|
|
|
2026 |
|
|
|
2027 |
}#foreach end
|
|
|
2028 |
|
|
|
2029 |
}#else end
|
|
|
2030 |
|
|
|
2031 |
#中斷
|
|
|
2032 |
break;
|
|
|
2033 |
|
|
|
2034 |
#如果 $conf["method"] 為 "POST"
|
|
|
2035 |
case "POST":
|
|
|
2036 |
|
|
|
2037 |
#抓取每個$_POST變數
|
|
|
2038 |
$postVarArray=$_POST;
|
|
|
2039 |
|
|
|
2040 |
#如果接收的$_POST變數數量等於0
|
|
|
2041 |
if(count($postVarArray)==0){
|
|
|
2042 |
|
|
|
2043 |
#設置抓到的表單變數數量為0
|
|
|
2044 |
$result["inputDataCount"]=0;
|
|
|
2045 |
|
|
|
2046 |
#設置空的 $result["inputDataContent"] 陣列
|
|
|
2047 |
$result["inputDataContent"]=array();
|
|
|
2048 |
|
|
|
2049 |
}#if end
|
|
|
2050 |
|
|
|
2051 |
#反之有post變數
|
|
|
2052 |
else{
|
|
|
2053 |
|
|
|
2054 |
#針對每個$_POST變數
|
|
|
2055 |
foreach($postVarArray as $postVarKey=>$postVarValue){
|
|
|
2056 |
|
|
|
2057 |
#取得每個$_POST變數
|
|
|
2058 |
$result["inputDataContent"][$postVarKey]=$postVarValue;
|
|
|
2059 |
|
|
|
2060 |
}#foreach end
|
|
|
2061 |
|
|
|
2062 |
}#else end
|
|
|
2063 |
|
|
|
2064 |
#中斷
|
|
|
2065 |
break;
|
|
|
2066 |
|
|
|
2067 |
#如果 $conf["method"] 不為以上數值
|
|
|
2068 |
default:
|
|
|
2069 |
|
|
|
2070 |
#設置錯誤
|
|
|
2071 |
$result["status"]="false";
|
|
|
2072 |
|
|
|
2073 |
#設置錯誤訊息
|
|
|
2074 |
$result["error"][]="\$conf[\"method\"]須為 \"get\" 、 \"GET\" 、 \"post\" 、 \"POST\" ";
|
|
|
2075 |
|
|
|
2076 |
#回傳結果
|
|
|
2077 |
return $result;
|
|
|
2078 |
|
|
|
2079 |
}#switch end
|
|
|
2080 |
|
|
|
2081 |
#如果 $conf["ignore"] 有設置
|
|
|
2082 |
if(isset($conf["ignore"])){
|
|
|
2083 |
|
|
|
2084 |
#初始化暫存有那些key
|
|
|
2085 |
$inputDataKey=array();
|
|
|
2086 |
|
|
|
2087 |
#依據 $result["inputDataContent"] 的數目
|
|
|
2088 |
foreach($result["inputDataContent"] as $key=>$value){
|
|
|
2089 |
|
|
|
2090 |
#儲存key
|
|
|
2091 |
$inputDataKey[$key]=$key;
|
|
|
2092 |
|
|
|
2093 |
}#foreache end
|
|
|
2094 |
|
|
|
2095 |
#函式說明:
|
|
|
2096 |
#檢查多個字串裡面是否有多個關鍵字
|
|
|
2097 |
#回傳結果:
|
|
|
2098 |
#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
|
|
|
2099 |
#$result["function"],當前執行的函數名稱.
|
|
|
2100 |
#$result["foundedFalseKey"],$result[$i]["founded"]結果為"false"的元素key陣列。
|
|
|
2101 |
#$result["foundedAll"],是否每個關鍵字都有找到,"true"代表每個都有找到,"false"代表沒有每個都找到.
|
|
|
2102 |
#必填參數:
|
|
|
2103 |
$conf["search"]["findManyKeyWordsFromManyString"]["keyWords"]=$conf["ignore"];#想要搜尋的關鍵字
|
|
|
2104 |
$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$inputDataKey;#要被搜尋的字串內容陣列
|
|
|
2105 |
#可省略參數:
|
|
|
2106 |
$conf["search"]["findManyKeyWordsFromManyString"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
|
|
|
2107 |
$filted=search::findManyKeyWordsFromManyString($conf["search"]["findManyKeyWordsFromManyString"]);
|
|
|
2108 |
unset($conf["search"]["findManyKeyWordsFromManyString"]);
|
|
|
2109 |
|
|
|
2110 |
#debug
|
|
|
2111 |
#var_dump($filted);
|
|
|
2112 |
|
|
|
2113 |
#如果檢查多個字串裡面是否有多個關鍵字失敗
|
|
|
2114 |
if($filted["status"]=="false"){
|
|
|
2115 |
|
|
|
2116 |
#設置錯誤
|
|
|
2117 |
$result["status"]="false";
|
|
|
2118 |
|
|
|
2119 |
#設置錯誤訊息
|
|
|
2120 |
$result["error"]=$filted;
|
|
|
2121 |
|
|
|
2122 |
#回傳結果
|
|
|
2123 |
return $result;
|
|
|
2124 |
|
|
|
2125 |
}#if end
|
|
|
2126 |
|
|
|
2127 |
#如果全部都有找到
|
|
|
2128 |
if($filted["foundedAll"]=="true"){
|
|
|
2129 |
|
|
|
2130 |
#取得沒被篩選掉的內容
|
|
|
2131 |
$result["inputDataContent"]=array();
|
|
|
2132 |
|
|
|
2133 |
}#if end
|
|
|
2134 |
|
|
|
2135 |
#反之為有些沒有符合
|
|
|
2136 |
else{
|
|
|
2137 |
|
|
|
2138 |
#另存 $result["inputDataContent"]
|
|
|
2139 |
$temp["inputDataContent"]=$result["inputDataContent"];
|
|
|
2140 |
|
|
|
2141 |
#移除舊的 $result["inputDataContent"]
|
|
|
2142 |
unset($result["inputDataContent"]);
|
|
|
2143 |
|
|
|
2144 |
#依據沒被篩選掉的變數key
|
|
|
2145 |
foreach($filted["foundedFalseKey"] as $key){
|
|
|
2146 |
|
|
|
2147 |
#取得不是要忽略的表單變數
|
|
|
2148 |
$result["inputDataContent"][$key]=$temp["inputDataContent"][$key];
|
|
|
2149 |
|
|
|
2150 |
}#foreach end
|
|
|
2151 |
|
|
|
2152 |
#移除 $temp["inputDataContent"]
|
|
|
2153 |
unset($temp["inputDataContent"]);
|
|
|
2154 |
|
|
|
2155 |
}#else end
|
|
|
2156 |
|
|
|
2157 |
}#if end
|
|
|
2158 |
|
|
|
2159 |
#如果 $conf["correctCharacter"] 為 "true" 且 $result["inputDataContent"]元素數量大於0 則代表要過濾字串
|
|
|
2160 |
if($conf["correctCharacter"]=="true" && count($result["inputDataContent"])>0 ){
|
|
|
2161 |
|
|
|
2162 |
#如果 $result["inputDataContent"] 的元素不為字串就會出錯。
|
|
|
2163 |
|
|
|
2164 |
#函式說明:
|
|
|
2165 |
#處理多個字串避免網頁出錯
|
|
|
2166 |
#回傳結果:
|
|
|
2167 |
#$result["status"],"true"代表執行成功,"false"代表執行失敗。
|
|
|
2168 |
#$result["error"],錯誤訊息
|
|
|
2169 |
#$result["processedStrArray"],處理好的字串陣列
|
|
|
2170 |
#必填參數:
|
|
|
2171 |
$conf["stringProcess"]["correctMutiStrCharacter"]["stringIn"]=$result["inputDataContent"];#爲要處理的字串陣列
|
|
|
2172 |
#可省略的參數:
|
|
|
2173 |
#$conf["selectedCharacter"]=array("");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
2174 |
#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
|
|
|
2175 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
2176 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
2177 |
$peocessedStrArray=stringProcess::correctMutiStrCharacter($conf["stringProcess"]["correctMutiStrCharacter"]);
|
|
|
2178 |
unset($conf["stringProcess"]);
|
|
|
2179 |
|
|
|
2180 |
#如果分割失敗
|
|
|
2181 |
if($peocessedStrArray["status"]=="false"){
|
|
|
2182 |
|
|
|
2183 |
#設置執行不正常
|
|
|
2184 |
$result["status"]="false";
|
|
|
2185 |
|
|
|
2186 |
#設置執行錯誤訊息
|
|
|
2187 |
$result["error"]=$peocessedStrArray;
|
|
|
2188 |
|
|
|
2189 |
#回傳結果
|
|
|
2190 |
return $result;
|
|
|
2191 |
|
|
|
2192 |
}#if end
|
|
|
2193 |
|
|
|
2194 |
#取得處理好的字串陣列
|
|
|
2195 |
$result["inputDataContent"]=$peocessedStrArray["processedStrArray"];
|
|
|
2196 |
|
|
|
2197 |
}#if end
|
|
|
2198 |
|
|
|
2199 |
#取得接收到的變數數量
|
|
|
2200 |
$result["inputDataCount"]=count($result["inputDataContent"]);
|
|
|
2201 |
|
|
|
2202 |
#如果 $conf["checkedVarName"] 有設定
|
|
|
2203 |
if(isset($conf["checkedVarName"])){
|
|
|
2204 |
|
|
|
2205 |
#初始化沒有接收的變數陣列
|
|
|
2206 |
$result["lostVarName"]=array();
|
|
|
2207 |
|
|
|
2208 |
#檢查變數是否有皆收到
|
|
|
2209 |
#函式說明:
|
|
|
2210 |
#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
|
|
|
2211 |
#回傳的結果:
|
|
|
2212 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2213 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
2214 |
#$result["function"],當前執行的函式名稱.
|
|
|
2215 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
2216 |
#$result["content"][$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
2217 |
#$result["content"][$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
2218 |
#$result["content"][$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
2219 |
#必填參數:
|
|
|
2220 |
$conf["variableCheck.isexistMulti"]["varInput"]=$result["inputDataContent"];#要檢查的陣列變數
|
|
|
2221 |
$conf["variableCheck.isexistMulti"]["variableCheck"]=$conf["checkedVarName"];#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
|
|
|
2222 |
#可省略參數:
|
|
|
2223 |
#$conf["variableType"]=array();#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
|
|
|
2224 |
$conf["variableCheck.isexistMulti"]["canBeEmptyString"]=$conf["canBeEmptyString"];#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
|
|
|
2225 |
$checkShouldBeExistedVar=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
|
|
|
2226 |
#var_dump($conf["variableCheck.isexistMulti"]);
|
|
|
2227 |
unset($conf["variableCheck.isexistMulti"]);
|
|
|
2228 |
|
|
|
2229 |
#var_dump($checkShouldBeExistedVar);
|
|
|
2230 |
|
|
|
2231 |
#如果檢查要接收到的變數失敗
|
|
|
2232 |
if($checkShouldBeExistedVar["status"]=="false"){
|
|
|
2233 |
|
|
|
2234 |
#設置錯誤
|
|
|
2235 |
$result["status"]="false";
|
|
|
2236 |
|
|
|
2237 |
#設置錯誤訊息
|
|
|
2238 |
$result["error"]=$checkShouldBeExistedVar;
|
|
|
2239 |
|
|
|
2240 |
#回傳結果
|
|
|
2241 |
return $result;
|
|
|
2242 |
|
|
|
2243 |
}#if end
|
|
|
2244 |
|
|
|
2245 |
#如果 $checkShouldBeExistedVar["passed"] 等於 "false"
|
|
|
2246 |
if($checkShouldBeExistedVar["passed"]=="false"){
|
|
|
2247 |
|
|
|
2248 |
#設置沒有抓到全部的變數
|
|
|
2249 |
$result["passed"]="false";
|
|
|
2250 |
|
|
|
2251 |
#取得是哪些變數是沒有接收到
|
|
|
2252 |
foreach($conf["checkedVarName"] as $varName){
|
|
|
2253 |
|
|
|
2254 |
#如果該變數沒抓到
|
|
|
2255 |
if($checkShouldBeExistedVar["content"][$varName]["varExist"]=="false"){
|
|
|
2256 |
|
|
|
2257 |
#取得沒抓到的變數名稱
|
|
|
2258 |
$result["lostVarName"][]=$varName;
|
|
|
2259 |
|
|
|
2260 |
}#if end
|
|
|
2261 |
|
|
|
2262 |
}#for end
|
|
|
2263 |
|
|
|
2264 |
}#if end
|
|
|
2265 |
|
|
|
2266 |
#反之代表該取得的變數都有抓到
|
|
|
2267 |
else{
|
|
|
2268 |
|
|
|
2269 |
#設置沒有抓到全部的變數
|
|
|
2270 |
$result["passed"]="true";
|
|
|
2271 |
|
|
|
2272 |
}#if end
|
|
|
2273 |
|
|
|
2274 |
}#if end
|
|
|
2275 |
|
|
|
2276 |
#如果 $result["lostVarName"] 存在
|
|
|
2277 |
if(isset($result["lostVarName"])){
|
|
|
2278 |
|
|
|
2279 |
#如果找不到的變數($result["lostVarName"])數量大於0
|
|
|
2280 |
if(count($result["lostVarName"])>0){
|
|
|
2281 |
|
|
|
2282 |
#如果 $conf["sessionNameArray"] 有設置
|
|
|
2283 |
if(isset($conf["sessionNameArray"])){
|
|
|
2284 |
|
|
|
2285 |
#複製遺失的變數名稱陣列
|
|
|
2286 |
$copy["lostVarName"]=$result["lostVarName"];
|
|
|
2287 |
|
|
|
2288 |
#有幾個遺失的變數就執行幾次
|
|
|
2289 |
for($i=0;$i<count($copy["lostVarName"]);$i++){
|
|
|
2290 |
|
|
|
2291 |
#尋找 $result["lostVarName"][$i] 在 $conf["checkedVarName"] 中的哪一個,key為何?
|
|
|
2292 |
#函式說明:
|
|
|
2293 |
#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
|
|
|
2294 |
#回傳的結果:
|
|
|
2295 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
2296 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
2297 |
#$result["error"],錯誤訊息
|
|
|
2298 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
2299 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
2300 |
#必填參數:
|
|
|
2301 |
$conf["search::getEqualVar"]["conditionElement"]=$copy["lostVarName"][$i];#條件元素,要等於的元素內容.
|
|
|
2302 |
$conf["search::getEqualVar"]["compareElements"]=$conf["checkedVarName"];#要比對的陣列變數內容.
|
|
|
2303 |
$searchResult=search::getEqualVar($conf["search::getEqualVar"]);
|
|
|
2304 |
unset($conf["search::getEqualVar"]);
|
|
|
2305 |
|
|
|
2306 |
#如果尋找失敗
|
|
|
2307 |
if($searchResult["status"]=="false"){
|
|
|
2308 |
|
|
|
2309 |
#設置執行失敗
|
|
|
2310 |
$result["status"]="false";
|
|
|
2311 |
|
|
|
2312 |
#設置執行錯誤
|
|
|
2313 |
$result["error"]=$searchResult;
|
|
|
2314 |
|
|
|
2315 |
#回傳結果
|
|
|
2316 |
return $result;
|
|
|
2317 |
|
|
|
2318 |
}#if end
|
|
|
2319 |
|
|
|
2320 |
#如果沒有找到對應的變數名稱
|
|
|
2321 |
if($searchResult["founded"]=="false"){
|
|
|
2322 |
|
|
|
2323 |
#設置執行失敗
|
|
|
2324 |
$result["status"]="false";
|
|
|
2325 |
|
|
|
2326 |
#設置執行錯誤
|
|
|
2327 |
$result["error"]=$searchResult;
|
|
|
2328 |
|
|
|
2329 |
#回傳結果
|
|
|
2330 |
return $result;
|
|
|
2331 |
|
|
|
2332 |
}#if end
|
|
|
2333 |
|
|
|
2334 |
#如果該變數是不允許從session取得的
|
|
|
2335 |
if($conf["sessionNameArray"][$searchResult["equalVarName"]]==null){
|
|
|
2336 |
|
|
|
2337 |
#設置執行失敗
|
|
|
2338 |
$result["status"]="false";
|
|
|
2339 |
|
|
|
2340 |
#設置執行錯誤
|
|
|
2341 |
$result["error"][]="變數".$searchResult["equalVarValue"]."禁止從session中取得";
|
|
|
2342 |
|
|
|
2343 |
#回傳結果
|
|
|
2344 |
return $result;
|
|
|
2345 |
|
|
|
2346 |
}#if end
|
|
|
2347 |
|
|
|
2348 |
#取得遺失變數對應的session變數名稱
|
|
|
2349 |
$sessionVarName=$conf["sessionNameArray"][$searchResult["equalVarName"]];
|
|
|
2350 |
|
|
|
2351 |
#函式說明:
|
|
|
2352 |
#取得session變數裡面的數值,然後卸除該session變數
|
|
|
2353 |
#回傳結果:
|
|
|
2354 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表有誤.
|
|
|
2355 |
#$result["error"],錯誤訊息
|
|
|
2356 |
#$result["founded"],是否找到session變數,"true"代表找到,"false"代表沒找到.
|
|
|
2357 |
#$result["content"],取得的變數內容
|
|
|
2358 |
#必填參數:
|
|
|
2359 |
$conf["session::getSessionValue"]["sessionVarName"]=$sessionVarName;#要取得內容的session變數名稱
|
|
|
2360 |
#可省略參數:
|
|
|
2361 |
|
|
|
2362 |
#如果存在是否要卸除session變數的陣列
|
|
|
2363 |
if(isset($conf["unsetSessionArray"])){
|
|
|
2364 |
|
|
|
2365 |
#設置其是否要卸除
|
|
|
2366 |
$conf["unsetSessionVar"]=$conf["unsetSessionArray"][$searchResult["equalVarName"]];#"true"代表要卸除session變數,預設不卸除
|
|
|
2367 |
|
|
|
2368 |
}#if end
|
|
|
2369 |
|
|
|
2370 |
#參考資料:
|
|
|
2371 |
#http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available
|
|
|
2372 |
#可變變數->http://emn178.pixnet.net/blog/post/80119035-php%E6%95%99%E5%AD%B8---%E8%AE%8A%E6%95%B8%28variables%29
|
|
|
2373 |
#卸除參考的原始變數->http://stackoverflow.com/questions/6654538/php-function-to-unset-variables-passed-by-reference
|
|
|
2374 |
$getSessionValue=session::getSessionValue($conf["session::getSessionValue"]);
|
|
|
2375 |
unset($conf["session::getSessionValue"]);
|
|
|
2376 |
|
|
|
2377 |
#如果取得 session 變數失敗
|
|
|
2378 |
if($getSessionValue["status"]=="false"){
|
|
|
2379 |
|
|
|
2380 |
#設置執行失敗
|
|
|
2381 |
$result["status"]="false";
|
|
|
2382 |
|
|
|
2383 |
#設置執行錯誤
|
|
|
2384 |
$result["error"]=$getSessionValue;
|
|
|
2385 |
|
|
|
2386 |
#回傳結果
|
|
|
2387 |
return $result;
|
|
|
2388 |
|
|
|
2389 |
}#if end
|
|
|
2390 |
|
|
|
2391 |
#如果 session 變數不存在
|
|
|
2392 |
if($getSessionValue["founded"]=="false"){
|
|
|
2393 |
|
|
|
2394 |
#設置執行失敗
|
|
|
2395 |
$result["status"]="false";
|
|
|
2396 |
|
|
|
2397 |
#設置沒有找到所有指定的變數
|
|
|
2398 |
$result["passed"]="false";
|
|
|
2399 |
|
|
|
2400 |
#設置執行錯誤
|
|
|
2401 |
$result["error"]=$getSessionValue;
|
|
|
2402 |
|
|
|
2403 |
#回傳結果
|
|
|
2404 |
return $result;
|
|
|
2405 |
|
|
|
2406 |
}#if end
|
|
|
2407 |
|
|
|
2408 |
#將取得的session變數儲存起來
|
|
|
2409 |
$result["inputDataContent"][$copy["lostVarName"][$i]]=$getSessionValue["content"];
|
|
|
2410 |
|
|
|
2411 |
#從找不到的變數清單裡面移除已經找到的變數
|
|
|
2412 |
unset($result["lostVarName"][$i]);
|
|
|
2413 |
|
|
|
2414 |
}#for end
|
|
|
2415 |
|
|
|
2416 |
#如果沒有遺失的變數
|
|
|
2417 |
if(count($result["lostVarName"])==0){
|
|
|
2418 |
|
|
|
2419 |
#設置檢查都通過
|
|
|
2420 |
$result["passed"]="true";
|
|
|
2421 |
|
|
|
2422 |
}#if end
|
|
|
2423 |
|
|
|
2424 |
}#if end
|
|
|
2425 |
|
|
|
2426 |
}#if end
|
|
|
2427 |
|
|
|
2428 |
}#if end
|
|
|
2429 |
|
|
|
2430 |
#設置執行成功
|
|
|
2431 |
$result["status"]="true";
|
|
|
2432 |
|
|
|
2433 |
#回傳結果
|
|
|
2434 |
return $result;
|
|
|
2435 |
|
|
|
2436 |
}#function responseMutiInputDataSecurityEnhance end
|
|
|
2437 |
|
|
|
2438 |
/*
|
|
|
2439 |
#函式說明:
|
|
|
2440 |
#能夠接收數個指定的變數名稱
|
|
|
2441 |
#回傳的結果:
|
|
|
2442 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2443 |
#$result["function"],當前執行的函數
|
|
|
2444 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
2445 |
#$result["warning"],警告訊息陣列
|
|
|
2446 |
#$result["getedValue"][$elementKey],取得的變數內容,請將「$elementKey」替換成要取得的表單傳送名稱,例如:$result["getedValue"]["account"],如果該變數不存在則其值會等於null.
|
|
|
2447 |
#必填參數:
|
|
|
2448 |
$conf["receivedVarArray"]=array();#要接收的參數陣列
|
|
|
2449 |
#可省略參數:
|
|
|
2450 |
#$conf["correctStr"],是否要過濾字串,預設為"true"要過濾,"false"為不要過濾.
|
|
|
2451 |
#$conf["correctStr"]="true";
|
|
|
2452 |
#參考資料:
|
|
|
2453 |
#無.
|
|
|
2454 |
#備註:
|
|
|
2455 |
#無.
|
|
|
2456 |
*/
|
|
|
2457 |
public static function receiveCustomMultiData(&$conf){
|
|
|
2458 |
|
|
|
2459 |
#初始化要回傳的內容
|
|
|
2460 |
$result=array();
|
|
|
2461 |
|
|
|
2462 |
#設置當前執行的函數
|
|
|
2463 |
$result["function"]=__FUNCTION__;
|
|
|
2464 |
|
|
|
2465 |
#如果 $conf 不為陣列
|
|
|
2466 |
if(gettype($conf)!="array"){
|
|
|
2467 |
|
|
|
2468 |
#設置執行失敗
|
|
|
2469 |
$result["status"]="false";
|
|
|
2470 |
|
|
|
2471 |
#設置執行錯誤訊息
|
|
|
2472 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2473 |
|
|
|
2474 |
#如果傳入的參數為 null
|
|
|
2475 |
if($conf==null){
|
|
|
2476 |
|
|
|
2477 |
#設置執行錯誤訊息
|
|
|
2478 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
2479 |
|
|
|
2480 |
}#if end
|
|
|
2481 |
|
|
|
2482 |
#回傳結果
|
|
|
2483 |
return $result;
|
|
|
2484 |
|
|
|
2485 |
}#if end
|
|
|
2486 |
|
|
|
2487 |
#檢查參數
|
|
|
2488 |
#函式說明:
|
|
|
2489 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
2490 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2491 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
2492 |
#$result["function"],當前執行的函式名稱.
|
|
|
2493 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
2494 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
2495 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
2496 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
2497 |
#必填參數:
|
|
|
2498 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
2499 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
2500 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
2501 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("receivedVarArray");
|
|
|
2502 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
2503 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
2504 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
2505 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
2506 |
#可省略參數:
|
|
|
2507 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
2508 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
2509 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
2510 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("method","correctStr");
|
|
|
2511 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
2512 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
2513 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
2514 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("post","true");
|
|
|
2515 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
2516 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
2517 |
|
|
|
2518 |
#如果檢查失敗
|
|
|
2519 |
if($checkResult["status"]=="false"){
|
|
|
2520 |
|
|
|
2521 |
#設置執行不正常
|
|
|
2522 |
$result["status"]="false";
|
|
|
2523 |
|
|
|
2524 |
#程式停止執行
|
|
|
2525 |
$result["error"]=$checkResult;
|
|
|
2526 |
|
|
|
2527 |
#回傳結果
|
|
|
2528 |
return $result;
|
|
|
2529 |
|
|
|
2530 |
}#if end
|
|
|
2531 |
|
|
|
2532 |
#如果檢查不通過
|
|
|
2533 |
if($checkResult["passed"]=="false"){
|
|
|
2534 |
|
|
|
2535 |
#設置執行不正常
|
|
|
2536 |
$result["status"]="false";
|
|
|
2537 |
|
|
|
2538 |
#程式停止執行
|
|
|
2539 |
$result["error"]=$checkResult;
|
|
|
2540 |
|
|
|
2541 |
#回傳結果
|
|
|
2542 |
return $result;
|
|
|
2543 |
|
|
|
2544 |
}#if end
|
|
|
2545 |
|
|
|
2546 |
#根據接收的模式來判斷
|
|
|
2547 |
switch($conf["method"]){
|
|
|
2548 |
|
|
|
2549 |
#如果爲 post/POST
|
|
|
2550 |
case "post" || "POST" :
|
|
|
2551 |
|
|
|
2552 |
#有幾個變數要接收,就判斷幾次
|
|
|
2553 |
for($i=0;$i<count($conf["receivedVarArray"]);$i++){
|
|
|
2554 |
|
|
|
2555 |
#將每個post變數視爲$elementKey指到$elementValue
|
|
|
2556 |
foreach($_POST as $elementKey => $elementValue){
|
|
|
2557 |
|
|
|
2558 |
#如果 $elementKey 等於任何一個 $conf["receivedVarArray"] 裏陣列元素的key
|
|
|
2559 |
#函式說明:
|
|
|
2560 |
#檢查一個數值是否與陣列裏面的元素相同,如果有相同的則會傳其變數內容。
|
|
|
2561 |
#回傳結果:
|
|
|
2562 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
2563 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
2564 |
#$result["error"],錯誤訊息
|
|
|
2565 |
#$result["function"],當前執行的函數名稱
|
|
|
2566 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
2567 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
2568 |
#必填參數:
|
|
|
2569 |
$conf["search"]["getEqualVar"]["conditionElement"]=$conf["receivedVarArray"][$i];#條件元素,要等於的元素內容。
|
|
|
2570 |
$conf["search"]["getEqualVar"]["compareElements"]=array($elementKey);#要比對的陣列變數內容。
|
|
|
2571 |
$getEqualVarResult=search::getEqualVar($conf["search"]["getEqualVar"]);
|
|
|
2572 |
unset($conf["search"]["getEqualVar"]);
|
|
|
2573 |
|
|
|
2574 |
#如果 search::getEqualVar 執行失敗
|
|
|
2575 |
if($getEqualVarResult["status"]=="false"){
|
|
|
2576 |
|
|
|
2577 |
#設置執行不正常
|
|
|
2578 |
$result["status"]="false";
|
|
|
2579 |
|
|
|
2580 |
#程式停止執行
|
|
|
2581 |
$result["error"]=$getEqualVarResult;
|
|
|
2582 |
|
|
|
2583 |
#回傳結果
|
|
|
2584 |
return $result;
|
|
|
2585 |
|
|
|
2586 |
}#if end
|
|
|
2587 |
|
|
|
2588 |
#如果找到對應的變數名稱
|
|
|
2589 |
if($getEqualVarResult["founded"]=="true"){
|
|
|
2590 |
|
|
|
2591 |
#設定爲要回傳的變數之一
|
|
|
2592 |
#$result["getedValue"][$elementKey]=$getEqualVarResult["equalVarName"];
|
|
|
2593 |
$result["getedValue"][$elementKey]=$elementValue;
|
|
|
2594 |
|
|
|
2595 |
}#if end
|
|
|
2596 |
|
|
|
2597 |
}#foreach end
|
|
|
2598 |
|
|
|
2599 |
#如果該變數沒有接收到
|
|
|
2600 |
if(!isset($result["getedValue"][$conf["receivedVarArray"][$i]])){
|
|
|
2601 |
|
|
|
2602 |
#設為 null
|
|
|
2603 |
$result["getedValue"][$conf["receivedVarArray"][$i]]=null;
|
|
|
2604 |
|
|
|
2605 |
}#if end
|
|
|
2606 |
|
|
|
2607 |
}#for end
|
|
|
2608 |
|
|
|
2609 |
#挑出 case
|
|
|
2610 |
break;
|
|
|
2611 |
|
|
|
2612 |
#如果爲 get/GET
|
|
|
2613 |
case "get" || "GET" :
|
|
|
2614 |
|
|
|
2615 |
#有幾個變數要接收,就判斷幾次
|
|
|
2616 |
for($i=0;$i<count($conf["receivedVarArray"]);$i++){
|
|
|
2617 |
|
|
|
2618 |
#將每個post變數視爲$elementKey指到$elementValue
|
|
|
2619 |
foreach($_GET as $elementKey => $elementValue){
|
|
|
2620 |
|
|
|
2621 |
#如果 $elementKey 等於任何一個 $conf["receivedVarArray"] 裏陣列元素的key
|
|
|
2622 |
#函式說明:
|
|
|
2623 |
#檢查一個數值是否與陣列裏面的元素相同,如果有相同的則會傳其變數內容。
|
|
|
2624 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
2625 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
2626 |
#$result["error"],錯誤訊息
|
|
|
2627 |
#$result["function"],當前執行的函數名稱
|
|
|
2628 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
2629 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
2630 |
#必填參數:
|
|
|
2631 |
$conf["search"]["getEqualVar"]["conditionElement"]=$conf["receivedVarArray"][$i];#條件元素,要等於的元素內容。
|
|
|
2632 |
$conf["search"]["getEqualVar"]["compareElements"]=array($elementKey);#要比對的陣列變數內容。
|
|
|
2633 |
$getEqualVarResult=search::getEqualVar($conf["search"]["getEqualVar"]);
|
|
|
2634 |
unset($conf["search"]["getEqualVar"]);
|
|
|
2635 |
|
|
|
2636 |
#如果 search::getEqualVar 執行失敗
|
|
|
2637 |
if($getEqualVarResult["status"]=="false"){
|
|
|
2638 |
|
|
|
2639 |
#設置執行不正常
|
|
|
2640 |
$result["status"]="false";
|
|
|
2641 |
|
|
|
2642 |
#程式停止執行
|
|
|
2643 |
$result["error"]=$getEqualVarResult;
|
|
|
2644 |
|
|
|
2645 |
#回傳結果
|
|
|
2646 |
return $result;
|
|
|
2647 |
|
|
|
2648 |
}#if end
|
|
|
2649 |
|
|
|
2650 |
#如果找到對應的變數名稱
|
|
|
2651 |
if($getEqualVarResult["founded"]=="true"){
|
|
|
2652 |
|
|
|
2653 |
#設定爲要回傳的變數之一
|
|
|
2654 |
$result["getedValue"][$elementKey]=$elementValue;
|
|
|
2655 |
|
|
|
2656 |
}#if end
|
|
|
2657 |
|
|
|
2658 |
}#foreach end
|
|
|
2659 |
|
|
|
2660 |
#如果該變數沒有接收到
|
|
|
2661 |
if(!isset($result["getedValue"][$conf["receivedVarArray"][$i]])){
|
|
|
2662 |
|
|
|
2663 |
#設為 null
|
|
|
2664 |
$result["getedValue"][$conf["receivedVarArray"][$i]]=null;
|
|
|
2665 |
|
|
|
2666 |
}#if end
|
|
|
2667 |
|
|
|
2668 |
}#for end
|
|
|
2669 |
|
|
|
2670 |
#挑出 case
|
|
|
2671 |
break;
|
|
|
2672 |
|
|
|
2673 |
#如果不爲以上內容
|
|
|
2674 |
default :
|
|
|
2675 |
|
|
|
2676 |
#設置執行失敗
|
|
|
2677 |
$result["status"]="false";
|
|
|
2678 |
|
|
|
2679 |
#設置執行錯誤
|
|
|
2680 |
$result["error"][]="不適用的method參數";
|
|
|
2681 |
|
|
|
2682 |
#回傳false,表示函式使用有誤
|
|
|
2683 |
return $result;
|
|
|
2684 |
|
|
|
2685 |
}#switch end
|
|
|
2686 |
|
|
|
2687 |
#設置執行正常
|
|
|
2688 |
$result["status"]="true";
|
|
|
2689 |
|
|
|
2690 |
#回傳結果
|
|
|
2691 |
return $result;
|
|
|
2692 |
|
|
|
2693 |
}#function receiveCustomMultiData end
|
|
|
2694 |
|
|
|
2695 |
/*
|
|
|
2696 |
#函式說明:
|
|
|
2697 |
#放置按鈕
|
|
|
2698 |
#回傳結果:
|
|
|
2699 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2700 |
#$result["function"],當前執行的函數.
|
|
|
2701 |
#$result["error"],錯誤訊息陣列.
|
|
|
2702 |
#$result["content"],按鈕語法.
|
|
|
2703 |
#必填參數:
|
|
|
2704 |
$conf["buttonDisplayValue"]="";#爲按鈕上顯示的文字。
|
|
|
2705 |
#可省略參數:
|
|
|
2706 |
#$conf["buttonStyleName"]="";#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __qbpwcf_button 。
|
|
|
2707 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式或程式,預設不設定。
|
|
|
2708 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
2709 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
2710 |
#若搭配 javaScript 類別的 confirmWindow 函數的回傳結果,則會有確認視窗的效果.
|
|
|
2711 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
2712 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
2713 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
2714 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
2715 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
2716 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
2717 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
2718 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
2719 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
2720 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
2721 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
2722 |
#$conf["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
2723 |
#$conf["action"]="";#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
2724 |
#$conf["target"]="";#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
2725 |
#$conf["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
2726 |
#$conf["formId"],字串,表單的id.
|
|
|
2727 |
#$conf["formId"]="";
|
|
|
2728 |
#$conf["buttonId"],字串,按鈕的id.
|
|
|
2729 |
#$conf["buttonId"]="";
|
|
|
2730 |
#參考資料:
|
|
|
2731 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
2732 |
#備註:
|
|
|
2733 |
#無.
|
|
|
2734 |
*/
|
|
|
2735 |
public static function button(&$conf){
|
|
|
2736 |
|
|
|
2737 |
#初始化要回傳的內容
|
|
|
2738 |
$result=array();
|
|
|
2739 |
|
|
|
2740 |
#設置當前執行的函數
|
|
|
2741 |
$result["function"]=__FUNCTION__;
|
|
|
2742 |
|
|
|
2743 |
#初始化content樣式內容
|
|
|
2744 |
$result["content"]="";
|
|
|
2745 |
|
|
|
2746 |
#如果 $conf 不為陣列
|
|
|
2747 |
if(gettype($conf)!="array"){
|
|
|
2748 |
|
|
|
2749 |
#設置執行失敗
|
|
|
2750 |
$result["status"]="false";
|
|
|
2751 |
|
|
|
2752 |
#設置執行錯誤訊息
|
|
|
2753 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
2754 |
|
|
|
2755 |
#如果傳入的參數為 null
|
|
|
2756 |
if($conf==null){
|
|
|
2757 |
|
|
|
2758 |
#設置執行錯誤訊息
|
|
|
2759 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
2760 |
|
|
|
2761 |
}#if end
|
|
|
2762 |
|
|
|
2763 |
#回傳結果
|
|
|
2764 |
return $result;
|
|
|
2765 |
|
|
|
2766 |
}#if end
|
|
|
2767 |
|
|
|
2768 |
#檢查參數
|
|
|
2769 |
#函式說明:
|
|
|
2770 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
2771 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2772 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
2773 |
#$result["function"],當前執行的函式名稱.
|
|
|
2774 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
2775 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
2776 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
2777 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
2778 |
#必填參數:
|
|
|
2779 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
2780 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
2781 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
2782 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("buttonDisplayValue");
|
|
|
2783 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
2784 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
2785 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
2786 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
2787 |
#可省略參數:
|
|
|
2788 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
2789 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
2790 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
2791 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("buttonStyleName","buttonActionScriptFunction","buttonBorder","disabled","tableStart","tableClass","trStart","trClass","tdStart","tdClass","tdEnd","trEnd","tableEnd","formStart","action","target","formEnd","formId","buttonId");
|
|
|
2792 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
2793 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
2794 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
2795 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("__qbpwcf_button",null,"0","false","false","__defaultTbaleCsssStyle","false","__withoutBorder","false","__withoutBorder","false","false","false","false",null,"_self","false",null,null);
|
|
|
2796 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
2797 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
2798 |
|
|
|
2799 |
#如果檢查失敗
|
|
|
2800 |
if($checkResult["status"]=="false"){
|
|
|
2801 |
|
|
|
2802 |
#設置執行不正常
|
|
|
2803 |
$result["status"]="false";
|
|
|
2804 |
|
|
|
2805 |
#程式停止執行
|
|
|
2806 |
$result["error"]=$checkResult;
|
|
|
2807 |
|
|
|
2808 |
#回傳結果
|
|
|
2809 |
return $result;
|
|
|
2810 |
|
|
|
2811 |
}#if end
|
|
|
2812 |
|
|
|
2813 |
#如果檢查不通過
|
|
|
2814 |
if($checkResult["passed"]=="false"){
|
|
|
2815 |
|
|
|
2816 |
#設置執行不正常
|
|
|
2817 |
$result["status"]="false";
|
|
|
2818 |
|
|
|
2819 |
#程式停止執行
|
|
|
2820 |
$result["error"]=$checkResult;
|
|
|
2821 |
|
|
|
2822 |
#回傳結果
|
|
|
2823 |
return $result;
|
|
|
2824 |
|
|
|
2825 |
}#if end
|
|
|
2826 |
|
|
|
2827 |
#如果要表格開始
|
|
|
2828 |
if($conf["tableStart"]=="true"){
|
|
|
2829 |
|
|
|
2830 |
#函式說明:
|
|
|
2831 |
#表格開始,可以設定表格的厚度和位置
|
|
|
2832 |
#回傳結果:
|
|
|
2833 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
2834 |
#$result["content"],表格開始的語法
|
|
|
2835 |
#$result["function"],當前執行的函數
|
|
|
2836 |
#$result["error"],函式錯誤訊息
|
|
|
2837 |
#必填寫的參數:
|
|
|
2838 |
$conf["table::start"]["class"]=$conf["tableClass"];#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2839 |
$tableStart=table::start($conf["table::start"]);
|
|
|
2840 |
unset($conf["table::start"]);
|
|
|
2841 |
|
|
|
2842 |
#如果表開始立失敗
|
|
|
2843 |
if($tableStart["status"]=="false"){
|
|
|
2844 |
|
|
|
2845 |
#設置執行失敗
|
|
|
2846 |
$result["status"]="false";
|
|
|
2847 |
|
|
|
2848 |
#設置執行錯誤訊息
|
|
|
2849 |
$result["error"]=$tableStart;
|
|
|
2850 |
|
|
|
2851 |
#回傳結果
|
|
|
2852 |
return $result;
|
|
|
2853 |
|
|
|
2854 |
}#if end
|
|
|
2855 |
|
|
|
2856 |
#串接表格開始的語法
|
|
|
2857 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
2858 |
|
|
|
2859 |
}#if end
|
|
|
2860 |
|
|
|
2861 |
#如果其值爲 true
|
|
|
2862 |
if($conf["trStart"]=="true"){
|
|
|
2863 |
|
|
|
2864 |
#套用列開始指定的css樣式
|
|
|
2865 |
#函式說明:
|
|
|
2866 |
#列開始
|
|
|
2867 |
#回傳結果:
|
|
|
2868 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
2869 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
2870 |
#$result["content"],列開始的語法.
|
|
|
2871 |
#$result["function"],當前執行的函式名稱.
|
|
|
2872 |
#必填寫的參數:
|
|
|
2873 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];#爲tr的css樣式,若為""則為不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2874 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
2875 |
unset($conf["table"]);
|
|
|
2876 |
|
|
|
2877 |
#如果列開始失敗
|
|
|
2878 |
if($trStart["status"]=="false"){
|
|
|
2879 |
|
|
|
2880 |
#設置執行失敗
|
|
|
2881 |
$result["status"]="false";
|
|
|
2882 |
|
|
|
2883 |
#設置執行錯誤訊息
|
|
|
2884 |
$result["error"]=$trStart;
|
|
|
2885 |
|
|
|
2886 |
#回傳結果
|
|
|
2887 |
return $result;
|
|
|
2888 |
|
|
|
2889 |
}#if end
|
|
|
2890 |
|
|
|
2891 |
#串接列開始
|
|
|
2892 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
2893 |
|
|
|
2894 |
}#if end
|
|
|
2895 |
|
|
|
2896 |
#如果$conf["tdStart"]其值爲 "true"
|
|
|
2897 |
if($conf["tdStart"]=="true"){
|
|
|
2898 |
|
|
|
2899 |
#列開始且套用css樣式.
|
|
|
2900 |
#函式說明:
|
|
|
2901 |
#行開始
|
|
|
2902 |
#回傳結果:
|
|
|
2903 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
2904 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
2905 |
#$result["content"],行開始的語法.
|
|
|
2906 |
#$result["function"],當前執行的函式名稱.
|
|
|
2907 |
#必填寫的參數:
|
|
|
2908 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];#該 td 要套用套用的 css 樣式
|
|
|
2909 |
#預設的樣式
|
|
|
2910 |
#"border-width","border","border-color","border-style","margin-right","margin-left"
|
|
|
2911 |
#"100%","1px","#0000FF","solid","auto","auto"
|
|
|
2912 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
2913 |
unset($conf["table"]);
|
|
|
2914 |
|
|
|
2915 |
#若行開始失敗
|
|
|
2916 |
if($tdStart["status"]=="false"){
|
|
|
2917 |
|
|
|
2918 |
#設置執行失敗
|
|
|
2919 |
$result["status"]="false";
|
|
|
2920 |
|
|
|
2921 |
#設置執行錯誤訊息
|
|
|
2922 |
$result["error"]=$tdStart;
|
|
|
2923 |
|
|
|
2924 |
#回傳結果
|
|
|
2925 |
return $result;
|
|
|
2926 |
|
|
|
2927 |
}#if end
|
|
|
2928 |
|
|
|
2929 |
#串接行開始的語法
|
|
|
2930 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
2931 |
|
|
|
2932 |
}#if end
|
|
|
2933 |
|
|
|
2934 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
2935 |
if($conf["formStart"]=="true"){
|
|
|
2936 |
|
|
|
2937 |
#如果 $conf["action"] 有設定
|
|
|
2938 |
if(isset($conf["action"])){
|
|
|
2939 |
|
|
|
2940 |
#表單開始
|
|
|
2941 |
#函式說明:
|
|
|
2942 |
#表單開始
|
|
|
2943 |
#回傳結果:
|
|
|
2944 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
2945 |
#$result["error"],錯誤訊息陣列.
|
|
|
2946 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
2947 |
#$result["content"],表單開始的語法.
|
|
|
2948 |
$conf["form"]["start"]["action"]=$conf["action"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
2949 |
#可省略參數:
|
|
|
2950 |
#$conf["name"]="";#爲該表單的名稱
|
|
|
2951 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
2952 |
$conf["form"]["start"]["target"]=$conf["target"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
2953 |
#$conf["form"]["start"]["tableStart"]=$conf["tableStart"];#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
2954 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
2955 |
|
|
|
2956 |
#如果有設定 $conf["formId"]
|
|
|
2957 |
if(isset($conf["formId"])){
|
|
|
2958 |
|
|
|
2959 |
#設置表單的名稱與id
|
|
|
2960 |
$conf["form"]["start"]["name"]=$conf["formId"];#爲該表單的名稱,id也跟$conf["name"]一樣.
|
|
|
2961 |
|
|
|
2962 |
}#if end
|
|
|
2963 |
|
|
|
2964 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
2965 |
unset($conf["form"]);
|
|
|
2966 |
|
|
|
2967 |
#如果表單開始失敗
|
|
|
2968 |
if($formStart["status"]=="false"){
|
|
|
2969 |
|
|
|
2970 |
#設置執行失敗
|
|
|
2971 |
$result["status"]="false";
|
|
|
2972 |
|
|
|
2973 |
#設置執行錯誤訊息
|
|
|
2974 |
$result["error"]=$formStart;
|
|
|
2975 |
|
|
|
2976 |
#回傳結果
|
|
|
2977 |
return $result;
|
|
|
2978 |
|
|
|
2979 |
}#if end
|
|
|
2980 |
|
|
|
2981 |
#串接表單開始的語法
|
|
|
2982 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
2983 |
|
|
|
2984 |
}#if end
|
|
|
2985 |
|
|
|
2986 |
#反之不存在
|
|
|
2987 |
else{
|
|
|
2988 |
|
|
|
2989 |
#設置執行失敗
|
|
|
2990 |
$result["status"]="false";
|
|
|
2991 |
|
|
|
2992 |
#設置錯誤訊息
|
|
|
2993 |
$result["status"]="\$conf[\"action\"]參數沒有設置!";
|
|
|
2994 |
|
|
|
2995 |
#回傳結果
|
|
|
2996 |
return $result;
|
|
|
2997 |
|
|
|
2998 |
}#else end
|
|
|
2999 |
|
|
|
3000 |
}#if end
|
|
|
3001 |
|
|
|
3002 |
#套用按鈕的css樣式
|
|
|
3003 |
$conf["buttonStyleName"]=" class = '".$conf["buttonStyleName"]."' ";
|
|
|
3004 |
|
|
|
3005 |
#如果$conf["buttonActionScriptFunction"]不存在
|
|
|
3006 |
if(!isset($conf["buttonActionScriptFunction"])){
|
|
|
3007 |
|
|
|
3008 |
#則預設給與""
|
|
|
3009 |
$conf["buttonActionScriptFunction"]="";
|
|
|
3010 |
|
|
|
3011 |
}#if end
|
|
|
3012 |
|
|
|
3013 |
#反之$conf["buttonActionScriptFunction"]存在
|
|
|
3014 |
else{
|
|
|
3015 |
|
|
|
3016 |
#則套用設定的javaScript
|
|
|
3017 |
$conf["buttonActionScriptFunction"]=" onClick=\"".$conf["buttonActionScriptFunction"]."\"";
|
|
|
3018 |
|
|
|
3019 |
}#else end
|
|
|
3020 |
|
|
|
3021 |
#如果 $conf["disabled"] 為"true"
|
|
|
3022 |
if($conf["disabled"]=="true"){
|
|
|
3023 |
|
|
|
3024 |
#設置取消按鈕功能的屬性
|
|
|
3025 |
$conf["disabled"]=" disabled=\"disabled\" ";
|
|
|
3026 |
|
|
|
3027 |
}#if end
|
|
|
3028 |
|
|
|
3029 |
#反之 $conf["disabled"] 不為"true"
|
|
|
3030 |
else{
|
|
|
3031 |
|
|
|
3032 |
#預設功能要正常
|
|
|
3033 |
$conf["disabled"]="";
|
|
|
3034 |
|
|
|
3035 |
}#else end
|
|
|
3036 |
|
|
|
3037 |
#如果有設置 $conf["buttonId"]
|
|
|
3038 |
if(isset($conf["buttonId"])){
|
|
|
3039 |
|
|
|
3040 |
#設置按鈕id的語法
|
|
|
3041 |
$conf["buttonId"]=" id=\"".$conf["buttonId"]."\"";
|
|
|
3042 |
|
|
|
3043 |
}#if end
|
|
|
3044 |
|
|
|
3045 |
#反之
|
|
|
3046 |
else{
|
|
|
3047 |
|
|
|
3048 |
#設為空字串
|
|
|
3049 |
$conf["buttonId"]="";
|
|
|
3050 |
|
|
|
3051 |
}#else end
|
|
|
3052 |
|
|
|
3053 |
#放置按鈕
|
|
|
3054 |
$result["content"]=$result["content"]."<input type = submit ".$conf["disabled"]." value = \"".$conf["buttonDisplayValue"]."\" ".$conf["buttonStyleName"]." ".$conf["buttonActionScriptFunction"]." border = ".$conf["buttonBorder"]." ".$conf["buttonId"]." >";
|
|
|
3055 |
|
|
|
3056 |
#如果其值爲 true
|
|
|
3057 |
if($conf["tdEnd"]=="true"){
|
|
|
3058 |
|
|
|
3059 |
#加上 </td>
|
|
|
3060 |
$result["content"]=$result["content"]."</td>";
|
|
|
3061 |
|
|
|
3062 |
}#if end
|
|
|
3063 |
|
|
|
3064 |
#如果其值爲 true
|
|
|
3065 |
if($conf["trEnd"]=="true"){
|
|
|
3066 |
|
|
|
3067 |
#加上 </tr>
|
|
|
3068 |
$result["content"]=$result["content"]."</tr>";
|
|
|
3069 |
|
|
|
3070 |
}#if end
|
|
|
3071 |
|
|
|
3072 |
#如果 $conf["formEnd"] 等於 true
|
|
|
3073 |
if($conf["formEnd"]=="true"){
|
|
|
3074 |
|
|
|
3075 |
#說明:
|
|
|
3076 |
#表單結束
|
|
|
3077 |
#回傳結果:
|
|
|
3078 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
3079 |
#$result["error"],錯誤訊息陣列.
|
|
|
3080 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
3081 |
#$result["content"],表單結束的語法.
|
|
|
3082 |
#必填寫的參數:
|
|
|
3083 |
$conf_end["tableEnd"]=$conf["tableEnd"];#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
3084 |
$formEnd=form::end($conf_end);
|
|
|
3085 |
unset($conf_end);
|
|
|
3086 |
|
|
|
3087 |
#如果表單結束失敗
|
|
|
3088 |
if($formEnd["status"]=="false"){
|
|
|
3089 |
|
|
|
3090 |
#設置執行失敗
|
|
|
3091 |
$result["status"]="false";
|
|
|
3092 |
|
|
|
3093 |
#設置執行錯誤訊息
|
|
|
3094 |
$result["error"]=$formEnd;
|
|
|
3095 |
|
|
|
3096 |
#回傳結果
|
|
|
3097 |
return $result;
|
|
|
3098 |
|
|
|
3099 |
}#if end
|
|
|
3100 |
|
|
|
3101 |
#串聯表單結束的語法
|
|
|
3102 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
3103 |
|
|
|
3104 |
}#if end
|
|
|
3105 |
|
|
|
3106 |
#如果有表格結束
|
|
|
3107 |
if($conf["tableEnd"]=="true"){
|
|
|
3108 |
|
|
|
3109 |
#函式說明:
|
|
|
3110 |
#表格結束
|
|
|
3111 |
#回傳結果:
|
|
|
3112 |
#表格結束的語法
|
|
|
3113 |
$result["content"]=$result["content"].table::end();
|
|
|
3114 |
|
|
|
3115 |
}#if end
|
|
|
3116 |
|
|
|
3117 |
#執行到這邊代表執行正常
|
|
|
3118 |
$result["status"]="true";
|
|
|
3119 |
|
|
|
3120 |
#回傳結果
|
|
|
3121 |
return $result;
|
|
|
3122 |
|
|
|
3123 |
}#function button end
|
|
|
3124 |
|
|
|
3125 |
/*
|
|
|
3126 |
#函式說明:
|
|
|
3127 |
#以圖片代替的表單送出扭
|
|
|
3128 |
#回傳結果:
|
|
|
3129 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3130 |
#$result["function"],當前執行的函數.
|
|
|
3131 |
#$result["error"],錯誤訊息陣列.
|
|
|
3132 |
#$result["content"],按鈕語法.
|
|
|
3133 |
#必填參數:
|
|
|
3134 |
$conf["img"]="";#爲要作爲按鈕的圖片位置。
|
|
|
3135 |
#可省略參數:
|
|
|
3136 |
#$conf["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
3137 |
#$conf["formAction"]="";#字串,表單要傳送到哪邊
|
|
|
3138 |
#$conf["legend"]="";#字串,圖片按鈕的註解.
|
|
|
3139 |
#$conf["formMethod"]="";#字串,表單傳送的方式,預設為"post",也可以使用"get".
|
|
|
3140 |
#$conf["formTarget"]="";#字串,表單的回應要呈現在哪邊,預設為"_self"(當前頁面、頁框),"_top"為整個頁面,"_parent"為父頁面,"_blank"為開新頁面,也可以為iframe的名稱.
|
|
|
3141 |
#$conf["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
3142 |
#$conf["width"]="";#爲按鈕圖片的寬度,若省略,則按照原始圖片的寬度。
|
|
|
3143 |
#$conf["height"]="";#爲按鈕圖片的高度,若省略,則按照原始圖片的高度。
|
|
|
3144 |
#$conf["class"]="";#爲按鈕圖片要套用的css樣式名稱,若省略,則不套用任何css樣式。
|
|
|
3145 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
3146 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
3147 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
3148 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
3149 |
#$conf["formId"],字串,表單的id.
|
|
|
3150 |
#$conf["formId"]="";
|
|
|
3151 |
#$conf["buttonId"],字串,按鈕的id.
|
|
|
3152 |
#$conf["buttonId"]="";
|
|
|
3153 |
#參考資料:
|
|
|
3154 |
#無.
|
|
|
3155 |
#備註:
|
|
|
3156 |
#使用圖片作為傳送按時,會傳送點擊圖片的x軸與y軸數數值.
|
|
|
3157 |
*/
|
|
|
3158 |
public static function buttonImg(&$conf){
|
|
|
3159 |
|
|
|
3160 |
#初始化要回傳的內容
|
|
|
3161 |
$result=array();
|
|
|
3162 |
|
|
|
3163 |
#設置當前執行的函數
|
|
|
3164 |
$result["function"]=__FUNCTION__;
|
|
|
3165 |
|
|
|
3166 |
#初始化content樣式內容
|
|
|
3167 |
$result["content"]="";
|
|
|
3168 |
|
|
|
3169 |
#如果 $conf 不為陣列
|
|
|
3170 |
if(gettype($conf)!="array"){
|
|
|
3171 |
|
|
|
3172 |
#設置執行失敗
|
|
|
3173 |
$result["status"]="false";
|
|
|
3174 |
|
|
|
3175 |
#設置執行錯誤訊息
|
|
|
3176 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
3177 |
|
|
|
3178 |
#如果傳入的參數為 null
|
|
|
3179 |
if($conf==null){
|
|
|
3180 |
|
|
|
3181 |
#設置執行錯誤訊息
|
|
|
3182 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
3183 |
|
|
|
3184 |
}#if end
|
|
|
3185 |
|
|
|
3186 |
#回傳結果
|
|
|
3187 |
return $result;
|
|
|
3188 |
|
|
|
3189 |
}#if end
|
|
|
3190 |
|
|
|
3191 |
#檢查參數
|
|
|
3192 |
#函式說明:
|
|
|
3193 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
3194 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3195 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
3196 |
#$result["function"],當前執行的函式名稱.
|
|
|
3197 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
3198 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
3199 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
3200 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
3201 |
#必填參數:
|
|
|
3202 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
3203 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
3204 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
3205 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("img");
|
|
|
3206 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
3207 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
3208 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
3209 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
3210 |
#可省略參數:
|
|
|
3211 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
3212 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
3213 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
3214 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("formStart","formAction","legend","formMethod","formTarget","formEnd","width","height","class","trStart","tdStart","tdEnd","trEnd","formId","buttonId");
|
|
|
3215 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
3216 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
3217 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
3218 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("false",null,null,"post","_self","false",null,null,null,"false","false","false","false",null,null);
|
|
|
3219 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
3220 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
3221 |
|
|
|
3222 |
#如果檢查失敗
|
|
|
3223 |
if($checkResult["status"]=="false"){
|
|
|
3224 |
|
|
|
3225 |
#設置執行不正常
|
|
|
3226 |
$result["status"]="false";
|
|
|
3227 |
|
|
|
3228 |
#程式停止執行
|
|
|
3229 |
$result["error"]=$checkResult;
|
|
|
3230 |
|
|
|
3231 |
#回傳結果
|
|
|
3232 |
return $result;
|
|
|
3233 |
|
|
|
3234 |
}#if end
|
|
|
3235 |
|
|
|
3236 |
#如果檢查不通過
|
|
|
3237 |
if($checkResult["passed"]=="false"){
|
|
|
3238 |
|
|
|
3239 |
#設置執行不正常
|
|
|
3240 |
$result["status"]="false";
|
|
|
3241 |
|
|
|
3242 |
#程式停止執行
|
|
|
3243 |
$result["error"]=$checkResult;
|
|
|
3244 |
|
|
|
3245 |
#回傳結果
|
|
|
3246 |
return $result;
|
|
|
3247 |
|
|
|
3248 |
}#if end
|
|
|
3249 |
|
|
|
3250 |
#如果其值爲 true
|
|
|
3251 |
if($conf["trStart"]=="true"){
|
|
|
3252 |
|
|
|
3253 |
$result["content"]=$result["content"]."<tr>";
|
|
|
3254 |
|
|
|
3255 |
}#if end
|
|
|
3256 |
|
|
|
3257 |
#如果其值爲 true
|
|
|
3258 |
if($conf["tdStart"]=="true"){
|
|
|
3259 |
|
|
|
3260 |
$result["content"]=$result["content"]."<td>";
|
|
|
3261 |
|
|
|
3262 |
}#if end
|
|
|
3263 |
|
|
|
3264 |
#如果 $conf["formStart"] 為 "true" 且 $conf["formAction"] 有設置
|
|
|
3265 |
if($conf["formStart"]=="true" && isset($conf["formAction"])){
|
|
|
3266 |
|
|
|
3267 |
#函式說明:
|
|
|
3268 |
#表單開始
|
|
|
3269 |
#回傳結果:
|
|
|
3270 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
3271 |
#$result["error"],錯誤訊息陣列.
|
|
|
3272 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
3273 |
#$result["content"],表單開始的語法.
|
|
|
3274 |
#必填參數:
|
|
|
3275 |
$conf["form::start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
3276 |
#可省略參數:
|
|
|
3277 |
|
|
|
3278 |
#如果有設定 $conf["legend"]
|
|
|
3279 |
if(isset($conf["legend"])){
|
|
|
3280 |
|
|
|
3281 |
$conf["form::start"]["legend"]=$conf["legend"];#顯示表單的標題
|
|
|
3282 |
|
|
|
3283 |
}#if end
|
|
|
3284 |
|
|
|
3285 |
#如果有設置 $conf["formId"]
|
|
|
3286 |
if(isset($conf["formId"])){
|
|
|
3287 |
|
|
|
3288 |
#設置表單的名稱與id
|
|
|
3289 |
$conf["form::start"]["name"]=$conf["formId"];#爲該表單的名稱
|
|
|
3290 |
|
|
|
3291 |
}#if end
|
|
|
3292 |
|
|
|
3293 |
$conf["form::start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
3294 |
$conf["form::start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
3295 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是,"false"為否,預設為"false".
|
|
|
3296 |
#$conf["tableClass"]="";#表格要套用的css樣式,預設爲"__withoutBorder"無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
3297 |
#$conf["showFieldsetBorder"]="false";#是否要顯示表單區域的框線,預設為"false"不顯示,"true"代表要顯示.
|
|
|
3298 |
#參考資料:
|
|
|
3299 |
#http://www.w3schools.com/html/html_forms.asp
|
|
|
3300 |
#http://www.w3schools.com/tags/tag_fieldset.asp
|
|
|
3301 |
$formStart=form::start($conf["form::start"]);
|
|
|
3302 |
unset($conf["form::start"]);
|
|
|
3303 |
|
|
|
3304 |
#如果表單開始失敗
|
|
|
3305 |
if($formStart["status"]=="false"){
|
|
|
3306 |
|
|
|
3307 |
#設置執行不正常
|
|
|
3308 |
$result["status"]="false";
|
|
|
3309 |
|
|
|
3310 |
#程式停止執行
|
|
|
3311 |
$result["error"]=$formStart;
|
|
|
3312 |
|
|
|
3313 |
#回傳結果
|
|
|
3314 |
return $result;
|
|
|
3315 |
|
|
|
3316 |
}#if end
|
|
|
3317 |
|
|
|
3318 |
#串接表單開始
|
|
|
3319 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
3320 |
|
|
|
3321 |
}#if end
|
|
|
3322 |
|
|
|
3323 |
#如果$conf["class"]沒有設定
|
|
|
3324 |
if(!isset($conf["class"])){
|
|
|
3325 |
|
|
|
3326 |
#則$conf["class"]就爲空的
|
|
|
3327 |
$conf["class"] = "";
|
|
|
3328 |
|
|
|
3329 |
}#if end
|
|
|
3330 |
|
|
|
3331 |
#如果$conf["class"]有設定
|
|
|
3332 |
else{
|
|
|
3333 |
|
|
|
3334 |
#則套用css樣式
|
|
|
3335 |
$conf["class"] = "class=".$conf["class"];
|
|
|
3336 |
|
|
|
3337 |
}#else end
|
|
|
3338 |
|
|
|
3339 |
#如果$conf["width"]沒設定
|
|
|
3340 |
if(!isset($conf["width"])){
|
|
|
3341 |
|
|
|
3342 |
#則$conf["width"]設爲""
|
|
|
3343 |
$conf["width"]="";
|
|
|
3344 |
|
|
|
3345 |
}#if end
|
|
|
3346 |
|
|
|
3347 |
#如果$conf["width"]有設定
|
|
|
3348 |
else{
|
|
|
3349 |
|
|
|
3350 |
#就按照設定值
|
|
|
3351 |
$conf["width"]=" width=".$conf["width"];
|
|
|
3352 |
|
|
|
3353 |
}#else end
|
|
|
3354 |
|
|
|
3355 |
#如果$conf["height"]沒設定
|
|
|
3356 |
if(!isset($conf["height"])){
|
|
|
3357 |
|
|
|
3358 |
#則$conf["height"]設爲""
|
|
|
3359 |
$conf["height"]="";
|
|
|
3360 |
|
|
|
3361 |
}#if end
|
|
|
3362 |
|
|
|
3363 |
#$conf["height"]有設定
|
|
|
3364 |
else{
|
|
|
3365 |
|
|
|
3366 |
#就按照設定值
|
|
|
3367 |
$conf["height"]=" height=".$conf["height"];
|
|
|
3368 |
|
|
|
3369 |
}#else end
|
|
|
3370 |
|
|
|
3371 |
#如果 $conf["buttonId"] 存在
|
|
|
3372 |
if(isset($conf["buttonId"])){
|
|
|
3373 |
|
|
|
3374 |
#設置按鈕的id
|
|
|
3375 |
$conf["buttonId"]=" id=\"".$conf["buttonId"]."\"";
|
|
|
3376 |
|
|
|
3377 |
}#if end
|
|
|
3378 |
|
|
|
3379 |
#反之
|
|
|
3380 |
else{
|
|
|
3381 |
|
|
|
3382 |
#設為 ""
|
|
|
3383 |
$conf["buttonId"]="";
|
|
|
3384 |
|
|
|
3385 |
}#else end
|
|
|
3386 |
|
|
|
3387 |
#放置圖片按鈕的樣式
|
|
|
3388 |
$result["content"]=$result["content"]."<input type=image src=".$conf["img"]." alt=Submit ".$conf["width"]." ".$conf["height"]." ".$conf["class"]." border = 0 ".$conf["buttonId"]." >";
|
|
|
3389 |
|
|
|
3390 |
#如果 $conf["formEnd"] 為 "true"
|
|
|
3391 |
if($conf["formEnd"]=="true"){
|
|
|
3392 |
|
|
|
3393 |
#函式說明:
|
|
|
3394 |
#表單結束
|
|
|
3395 |
#回傳結果:
|
|
|
3396 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
3397 |
#$result["error"],錯誤訊息陣列.
|
|
|
3398 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
3399 |
#$result["content"],表單結束的語法.
|
|
|
3400 |
#必填參數:
|
|
|
3401 |
$conf["form::end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
3402 |
$formEnd=form::end($conf["form::end"]);
|
|
|
3403 |
unset($conf["form::end"]);
|
|
|
3404 |
|
|
|
3405 |
#如果 表單結束 失敗
|
|
|
3406 |
if($formEnd["status"]=="false"){
|
|
|
3407 |
|
|
|
3408 |
#設置執行不正常
|
|
|
3409 |
$result["status"]="false";
|
|
|
3410 |
|
|
|
3411 |
#程式停止執行
|
|
|
3412 |
$result["error"]=$formEnd;
|
|
|
3413 |
|
|
|
3414 |
#回傳結果
|
|
|
3415 |
return $result;
|
|
|
3416 |
|
|
|
3417 |
}#if end
|
|
|
3418 |
|
|
|
3419 |
#串接表單結束
|
|
|
3420 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
3421 |
|
|
|
3422 |
}#if end
|
|
|
3423 |
|
|
|
3424 |
#如果其值爲 true
|
|
|
3425 |
if($conf["tdEnd"]=="true"){
|
|
|
3426 |
|
|
|
3427 |
$result["content"]=$result["content"]."</td>";
|
|
|
3428 |
|
|
|
3429 |
}#if end
|
|
|
3430 |
|
|
|
3431 |
#如果其值爲 true
|
|
|
3432 |
if($conf["trEnd"]=="true"){
|
|
|
3433 |
|
|
|
3434 |
$result["content"]=$result["content"]."</tr>";
|
|
|
3435 |
|
|
|
3436 |
}#if end
|
|
|
3437 |
|
|
|
3438 |
#執行到這邊代表執行正常
|
|
|
3439 |
$result["status"]="true";
|
|
|
3440 |
|
|
|
3441 |
#回傳結果
|
|
|
3442 |
return $result;
|
|
|
3443 |
|
|
|
3444 |
}#function buttonImg end
|
|
|
3445 |
|
|
|
3446 |
/*
|
|
|
3447 |
#函式說明:
|
|
|
3448 |
#將表單填寫的狀態還原至預設值的按鈕.
|
|
|
3449 |
#回傳的內容:
|
|
|
3450 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3451 |
#$result["function"],當前執行的函數.
|
|
|
3452 |
#$result["error"],錯誤訊息陣列.
|
|
|
3453 |
#$result["content"],按鈕語法.
|
|
|
3454 |
#必填參數:
|
|
|
3455 |
#$conf["value"],字串,爲清空表單內容的按鈕顯示名稱
|
|
|
3456 |
$conf["value"]="reset";
|
|
|
3457 |
#可省略參數:
|
|
|
3458 |
#$conf["class"],字串,爲要套用的css樣式名稱,預設為__qbpwcf_button."
|
|
|
3459 |
#$conf["class"]="";
|
|
|
3460 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
3461 |
#$conf["trStart"]="true";
|
|
|
3462 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是",可以看成列裏面的元素開始,預設為"false".
|
|
|
3463 |
#$conf["tdStart"]="true";
|
|
|
3464 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
3465 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
3466 |
#$conf["buttonId"],字串,按鈕的id.
|
|
|
3467 |
#$conf["buttonId"]="";
|
|
|
3468 |
#參考資料:
|
|
|
3469 |
#無.
|
|
|
3470 |
#備註:
|
|
|
3471 |
#無.
|
|
|
3472 |
*/
|
|
|
3473 |
public static function buttonReset(&$conf){
|
|
|
3474 |
|
|
|
3475 |
#初始化要回傳的內容
|
|
|
3476 |
$result=array();
|
|
|
3477 |
|
|
|
3478 |
#設置當前執行的函數
|
|
|
3479 |
$result["function"]=__FUNCTION__;
|
|
|
3480 |
|
|
|
3481 |
#初始化content樣式內容
|
|
|
3482 |
$result["content"]="";
|
|
|
3483 |
|
|
|
3484 |
#如果 $conf 不為陣列
|
|
|
3485 |
if(gettype($conf)!="array"){
|
|
|
3486 |
|
|
|
3487 |
#設置執行失敗
|
|
|
3488 |
$result["status"]="false";
|
|
|
3489 |
|
|
|
3490 |
#設置執行錯誤訊息
|
|
|
3491 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
3492 |
|
|
|
3493 |
#如果傳入的參數為 null
|
|
|
3494 |
if($conf==null){
|
|
|
3495 |
|
|
|
3496 |
#設置執行錯誤訊息
|
|
|
3497 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
3498 |
|
|
|
3499 |
}#if end
|
|
|
3500 |
|
|
|
3501 |
#回傳結果
|
|
|
3502 |
return $result;
|
|
|
3503 |
|
|
|
3504 |
}#if end
|
|
|
3505 |
|
|
|
3506 |
#檢查參數
|
|
|
3507 |
#函式說明:
|
|
|
3508 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
3509 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3510 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
3511 |
#$result["function"],當前執行的函式名稱.
|
|
|
3512 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
3513 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
3514 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
3515 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
3516 |
#必填參數:
|
|
|
3517 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
3518 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
3519 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
3520 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("value");
|
|
|
3521 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
3522 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
3523 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
3524 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
3525 |
#可省略參數:
|
|
|
3526 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
3527 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
3528 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
3529 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("class","trStart","tdStart","tdEnd","trEnd","buttonId");
|
|
|
3530 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
3531 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string");
|
|
|
3532 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
3533 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("__qbpwcf_button","false","false","false","false",null);
|
|
|
3534 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
3535 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
3536 |
|
|
|
3537 |
#如果檢查失敗
|
|
|
3538 |
if($checkResult["status"]=="false"){
|
|
|
3539 |
|
|
|
3540 |
#設置執行不正常
|
|
|
3541 |
$result["status"]="false";
|
|
|
3542 |
|
|
|
3543 |
#程式停止執行
|
|
|
3544 |
$result["error"]=$checkResult;
|
|
|
3545 |
|
|
|
3546 |
#回傳結果
|
|
|
3547 |
return $result;
|
|
|
3548 |
|
|
|
3549 |
}#if end
|
|
|
3550 |
|
|
|
3551 |
#如果檢查不通過
|
|
|
3552 |
if($checkResult["passed"]=="false"){
|
|
|
3553 |
|
|
|
3554 |
#設置執行不正常
|
|
|
3555 |
$result["status"]="false";
|
|
|
3556 |
|
|
|
3557 |
#程式停止執行
|
|
|
3558 |
$result["error"]=$checkResult;
|
|
|
3559 |
|
|
|
3560 |
#回傳結果
|
|
|
3561 |
return $result;
|
|
|
3562 |
|
|
|
3563 |
}#if end
|
|
|
3564 |
|
|
|
3565 |
#如果其值爲 true
|
|
|
3566 |
if($conf["trStart"]=="true"){
|
|
|
3567 |
|
|
|
3568 |
#串接 "<tr>"
|
|
|
3569 |
$result["content"]=$result["content"]."<tr>";
|
|
|
3570 |
|
|
|
3571 |
}#if end
|
|
|
3572 |
|
|
|
3573 |
#如果其值爲 true
|
|
|
3574 |
if($conf["tdStart"]=="true"){
|
|
|
3575 |
|
|
|
3576 |
#串接 "<td>"
|
|
|
3577 |
$result["content"]=$result["content"]."<td>";
|
|
|
3578 |
|
|
|
3579 |
}#if end
|
|
|
3580 |
|
|
|
3581 |
#如果不使用樣式
|
|
|
3582 |
if(!isset($conf["class"])){
|
|
|
3583 |
|
|
|
3584 |
#則$class就爲空的
|
|
|
3585 |
$conf["class"] = "";
|
|
|
3586 |
|
|
|
3587 |
}#if end
|
|
|
3588 |
|
|
|
3589 |
#如果有使用class樣式
|
|
|
3590 |
else{
|
|
|
3591 |
|
|
|
3592 |
#則套用樣式
|
|
|
3593 |
$conf["class"] = " class=".$conf["class"];
|
|
|
3594 |
|
|
|
3595 |
}#else end
|
|
|
3596 |
|
|
|
3597 |
#套用設定值
|
|
|
3598 |
$conf["value"]=" value =".$conf["value"];
|
|
|
3599 |
|
|
|
3600 |
#如果 $conf["buttonId"] 有設置
|
|
|
3601 |
if(isset($conf["buttonId"])){
|
|
|
3602 |
|
|
|
3603 |
#設置按鈕id
|
|
|
3604 |
$conf["buttonId"]=" id=\"".$conf["buttonId"]."\"";
|
|
|
3605 |
|
|
|
3606 |
}#if end
|
|
|
3607 |
|
|
|
3608 |
#反之
|
|
|
3609 |
else{
|
|
|
3610 |
|
|
|
3611 |
#設為 ""
|
|
|
3612 |
$conf["buttonId"]="";
|
|
|
3613 |
|
|
|
3614 |
}#else end
|
|
|
3615 |
|
|
|
3616 |
#放置表單內容清空的按鈕
|
|
|
3617 |
$result["content"]=$result["content"]."<input type = reset ".$conf["value"]." ".$conf["class"]." border = 0 ".$conf["buttonId"]." >";
|
|
|
3618 |
|
|
|
3619 |
#如果其值爲 true
|
|
|
3620 |
if($conf["tdEnd"]=="true"){
|
|
|
3621 |
|
|
|
3622 |
#串接 "</td>"
|
|
|
3623 |
$result["content"]=$result["content"]."</td>";
|
|
|
3624 |
|
|
|
3625 |
}#if end
|
|
|
3626 |
|
|
|
3627 |
#如果其值爲 true
|
|
|
3628 |
if($conf["trEnd"]=="true"){
|
|
|
3629 |
|
|
|
3630 |
#串接 "</tr>"
|
|
|
3631 |
$result["content"]=$result["content"]."</tr>";
|
|
|
3632 |
|
|
|
3633 |
}#if end
|
|
|
3634 |
|
|
|
3635 |
#設置執行正常
|
|
|
3636 |
$result["status"]="true";
|
|
|
3637 |
|
|
|
3638 |
#回傳語法
|
|
|
3639 |
return $result;
|
|
|
3640 |
|
|
|
3641 |
}#function buttonReset end
|
|
|
3642 |
|
|
|
3643 |
/*
|
|
|
3644 |
#函式說明:
|
|
|
3645 |
#一個簡單的按鈕,按了可以到指定的頁面,同時也可以傳送多個隱藏的變數
|
|
|
3646 |
#回傳的結果
|
|
|
3647 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3648 |
#$result["error"],錯誤訊息陣列
|
|
|
3649 |
#$result["function"],當前執行的函數名稱.
|
|
|
3650 |
#$result["content"],語法內容
|
|
|
3651 |
#必填參數:
|
|
|
3652 |
#$conf["buttonDisplayValue"],字串,按鈕上要顯示的文字
|
|
|
3653 |
$conf["buttonDisplayValue"]="";
|
|
|
3654 |
#可省略參數:
|
|
|
3655 |
#$conf["buttonStyleName"],字串,按鈕的css樣式應該爲何,若省略的話預設會採用 __qbpwcf_button 的樣式
|
|
|
3656 |
#$conf["buttonStyleName"]="";
|
|
|
3657 |
#$conf["hiddenVarName"],陣列,要傳送的隱藏變數名稱,與 $conf["hiddenVarContent"] 相對應。
|
|
|
3658 |
#$conf["hiddenVarName"]=array();
|
|
|
3659 |
#$conf["hiddenVarContent"],陣列,要傳誦的隱藏變數內容,與 $conf["hiddenVarName"] 相對應。
|
|
|
3660 |
#$conf["hiddenVarContent"]=array();
|
|
|
3661 |
#$conf["disabled"],字串,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
3662 |
#$conf["disabled"]="true";
|
|
|
3663 |
#$conf["formStart"],字串,爲是否要表單開始,如果爲"true"則代表要表單開始,預設爲"false".
|
|
|
3664 |
#$conf["formStart"]="true";
|
|
|
3665 |
#$conf["method"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
3666 |
#$conf["method"]="";
|
|
|
3667 |
#$conf["formName"],字串,該表單的名稱
|
|
|
3668 |
#$conf["formName"]="";
|
|
|
3669 |
#$conf["buttonId"],字串,按鈕的id
|
|
|
3670 |
#$conf["buttonId"]="";
|
|
|
3671 |
#$conf["actionPage"],字串,按鈕按了之後要到哪個地方?若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
3672 |
#$conf["actionPage"]="";
|
|
|
3673 |
#$conf["buttonActionScriptFunction"],字串,爲按下按鈕時所要執行的javaScript函式,預設不設定,可以是"document.forms.formName.submit()"(傳送名爲testForm的表單內容).
|
|
|
3674 |
#$conf["buttonActionScriptFunction"]="";
|
|
|
3675 |
#$conf["formEnd"],字串,爲是否要表單結束,如果爲"true"則代表要表單結束,預設爲"false"
|
|
|
3676 |
#$conf["formEnd"]="true";
|
|
|
3677 |
#$conf["tableStart"],字串,爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
3678 |
#$conf["tableStart"]="true";
|
|
|
3679 |
#$conf["tableClass"],字串,爲表格要採用的css樣式名稱,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder".
|
|
|
3680 |
#$conf["tableClass"]="__withoutBorder";
|
|
|
3681 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
3682 |
#$conf["trStart"]="true"
|
|
|
3683 |
#$conf["trClass"],字串,列開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
3684 |
#$conf["trClass"]="__withoutBorder";
|
|
|
3685 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false"
|
|
|
3686 |
#$conf["tdStart"]="true";
|
|
|
3687 |
#$conf["tdClass"],字串,行開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
3688 |
#$conf["tdClass"]="__withoutBorder";
|
|
|
3689 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
3690 |
#$conf["tdEnd"]="true";
|
|
|
3691 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
3692 |
#$conf["trEnd"]="true";
|
|
|
3693 |
#$conf["displayTarget"],字串,頁面的呈現方法,可以是開新視窗(_blank)、在目前頁面、頁框裏面(_self)、在父頁面(_parent)、最上層頁面(_top),預設為"_top"。
|
|
|
3694 |
#$conf["displayTarget"]="";
|
|
|
3695 |
#$conf["tableEnd"],字串,爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
3696 |
#$conf["tableEnd"]="true";
|
|
|
3697 |
#參考資料:
|
|
|
3698 |
#無.
|
|
|
3699 |
#備註:
|
|
|
3700 |
#無.
|
|
|
3701 |
*/
|
|
|
3702 |
public static function sendHugeDataButton(&$conf){
|
|
|
3703 |
|
|
|
3704 |
#初始化要回傳的內容
|
|
|
3705 |
$result=array();
|
|
|
3706 |
|
|
|
3707 |
#設置當前執行的函數
|
|
|
3708 |
$result["function"]=__FUNCTION__;
|
|
|
3709 |
|
|
|
3710 |
#初始化content樣式內容
|
|
|
3711 |
$result["content"]="";
|
|
|
3712 |
|
|
|
3713 |
#如果 $conf 不為陣列
|
|
|
3714 |
if(gettype($conf)!="array"){
|
|
|
3715 |
|
|
|
3716 |
#設置執行失敗
|
|
|
3717 |
$result["status"]="false";
|
|
|
3718 |
|
|
|
3719 |
#設置執行錯誤訊息
|
|
|
3720 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
3721 |
|
|
|
3722 |
#如果傳入的參數為 null
|
|
|
3723 |
if($conf==null){
|
|
|
3724 |
|
|
|
3725 |
#設置執行錯誤訊息
|
|
|
3726 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
3727 |
|
|
|
3728 |
}#if end
|
|
|
3729 |
|
|
|
3730 |
#回傳結果
|
|
|
3731 |
return $result;
|
|
|
3732 |
|
|
|
3733 |
}#if end
|
|
|
3734 |
|
|
|
3735 |
#檢查參數
|
|
|
3736 |
#函式說明:
|
|
|
3737 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
3738 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3739 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
3740 |
#$result["function"],當前執行的函式名稱.
|
|
|
3741 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
3742 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
3743 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
3744 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
3745 |
#必填參數:
|
|
|
3746 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
3747 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
3748 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
3749 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("buttonDisplayValue");
|
|
|
3750 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
3751 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
3752 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
3753 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
3754 |
#可省略參數:
|
|
|
3755 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
3756 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
3757 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
3758 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("method","buttonStyleName","hiddenVarName","hiddenVarContent","disabled","formStart","formName","actionPage","buttonActionScriptFunction","formEnd","tableStart","tableClass","trStart","trClass","tdStart","tdClass","tdEnd","trEnd","displayTarget","tableEnd","formName","buttonId");
|
|
|
3759 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
3760 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","array","array","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
3761 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
3762 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("post","__qbpwcf_button",null,null,"false","false",null,null,null,"false","false","__withoutBorder","false","__withoutBorder","false","__withoutBorder","false","false","_top","false",null,null);
|
|
|
3763 |
#$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
3764 |
$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"][]=array("hiddenVarName","hiddenVarContent");
|
|
|
3765 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
3766 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
3767 |
|
|
|
3768 |
#如果檢查失敗
|
|
|
3769 |
if($checkResult["status"]=="false"){
|
|
|
3770 |
|
|
|
3771 |
#設置執行不正常
|
|
|
3772 |
$result["status"]="false";
|
|
|
3773 |
|
|
|
3774 |
#程式停止執行
|
|
|
3775 |
$result["error"]=$checkResult;
|
|
|
3776 |
|
|
|
3777 |
#回傳結果
|
|
|
3778 |
return $result;
|
|
|
3779 |
|
|
|
3780 |
}#if end
|
|
|
3781 |
|
|
|
3782 |
#如果檢查不通過
|
|
|
3783 |
if($checkResult["passed"]=="false"){
|
|
|
3784 |
|
|
|
3785 |
#設置執行不正常
|
|
|
3786 |
$result["status"]="false";
|
|
|
3787 |
|
|
|
3788 |
#程式停止執行
|
|
|
3789 |
$result["error"]=$checkResult;
|
|
|
3790 |
|
|
|
3791 |
#回傳結果
|
|
|
3792 |
return $result;
|
|
|
3793 |
|
|
|
3794 |
}#if end
|
|
|
3795 |
|
|
|
3796 |
#如果要表格開始
|
|
|
3797 |
if($conf["tableStart"]=="true"){
|
|
|
3798 |
|
|
|
3799 |
#函式說明:
|
|
|
3800 |
#表格開始,可以設定表格的厚度和位置
|
|
|
3801 |
#回傳結果:
|
|
|
3802 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
3803 |
#$result["content"],表格開始的語法
|
|
|
3804 |
#$result["function"],當前執行的函數
|
|
|
3805 |
#$result["error"],函式錯誤訊息
|
|
|
3806 |
#必填寫的參數:
|
|
|
3807 |
$conf["table::start"]["class"]=$conf["tableClass"];#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
3808 |
$tableStart=table::start($conf["table::start"]);
|
|
|
3809 |
unset($conf["table::start"]);
|
|
|
3810 |
|
|
|
3811 |
#如果表開始立失敗
|
|
|
3812 |
if($tableStart["status"]=="false"){
|
|
|
3813 |
|
|
|
3814 |
#設置執行失敗
|
|
|
3815 |
$result["status"]="false";
|
|
|
3816 |
|
|
|
3817 |
#設置執行錯誤訊息
|
|
|
3818 |
$result["error"]=$tableStart;
|
|
|
3819 |
|
|
|
3820 |
#回傳結果
|
|
|
3821 |
return $result;
|
|
|
3822 |
|
|
|
3823 |
}#if end
|
|
|
3824 |
|
|
|
3825 |
#串接表格開始的語法
|
|
|
3826 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
3827 |
|
|
|
3828 |
}#if end
|
|
|
3829 |
|
|
|
3830 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
3831 |
if($conf["formStart"]=="true"){
|
|
|
3832 |
|
|
|
3833 |
#如果 $conf["actionPage"] 有設定
|
|
|
3834 |
if(isset($conf["actionPage"])){
|
|
|
3835 |
|
|
|
3836 |
#表單開始
|
|
|
3837 |
#函式說明:
|
|
|
3838 |
#表單開始
|
|
|
3839 |
#回傳結果:
|
|
|
3840 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
3841 |
#$result["error"],錯誤訊息陣列.
|
|
|
3842 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
3843 |
#$result["content"],表單開始的語法.
|
|
|
3844 |
$conf["form"]["start"]["action"]=$conf["actionPage"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
3845 |
#可省略參數:
|
|
|
3846 |
|
|
|
3847 |
#如果有設定 $conf["formName"]
|
|
|
3848 |
if(isset($conf["formName"])){
|
|
|
3849 |
|
|
|
3850 |
$conf["form"]["start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
3851 |
|
|
|
3852 |
}#if end
|
|
|
3853 |
|
|
|
3854 |
$conf["form"]["start"]["method"]=$conf["method"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
3855 |
$conf["form"]["start"]["target"]=$conf["displayTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
3856 |
#$conf["form"]["start"]["tableStart"]=$conf["tableStart"];#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
3857 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
3858 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
3859 |
unset($conf["form"]);
|
|
|
3860 |
|
|
|
3861 |
#如果表單開始失敗
|
|
|
3862 |
if($formStart["status"]=="false"){
|
|
|
3863 |
|
|
|
3864 |
#設置執行失敗
|
|
|
3865 |
$result["status"]="false";
|
|
|
3866 |
|
|
|
3867 |
#設置執行錯誤訊息
|
|
|
3868 |
$result["error"]=$formStart;
|
|
|
3869 |
|
|
|
3870 |
#回傳結果
|
|
|
3871 |
return $result;
|
|
|
3872 |
|
|
|
3873 |
}#if end
|
|
|
3874 |
|
|
|
3875 |
#串接表單開始的語法
|
|
|
3876 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
3877 |
|
|
|
3878 |
}#if end
|
|
|
3879 |
|
|
|
3880 |
#反之不存在
|
|
|
3881 |
else{
|
|
|
3882 |
|
|
|
3883 |
#設置執行失敗
|
|
|
3884 |
$result["status"]="false";
|
|
|
3885 |
|
|
|
3886 |
#設置錯誤訊息
|
|
|
3887 |
$result["status"]="\$conf[\"action\"]參數沒有設置!";
|
|
|
3888 |
|
|
|
3889 |
#回傳結果
|
|
|
3890 |
return $result;
|
|
|
3891 |
|
|
|
3892 |
}#else end
|
|
|
3893 |
|
|
|
3894 |
}#if end
|
|
|
3895 |
|
|
|
3896 |
#如果其值爲 true
|
|
|
3897 |
if($conf["trStart"]=="true"){
|
|
|
3898 |
|
|
|
3899 |
#套用列開始指定的css樣式
|
|
|
3900 |
#函式說明:
|
|
|
3901 |
#列開始
|
|
|
3902 |
#回傳結果:
|
|
|
3903 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
3904 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
3905 |
#$result["content"],列開始的語法.
|
|
|
3906 |
#$result["function"],當前執行的函式名稱.
|
|
|
3907 |
#必填寫的參數:
|
|
|
3908 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];#爲tr的css樣式,若為""則為不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
3909 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
3910 |
unset($conf["table"]);
|
|
|
3911 |
|
|
|
3912 |
#如果列開始失敗
|
|
|
3913 |
if($trStart["status"]=="false"){
|
|
|
3914 |
|
|
|
3915 |
#設置執行失敗
|
|
|
3916 |
$result["status"]="false";
|
|
|
3917 |
|
|
|
3918 |
#設置執行錯誤訊息
|
|
|
3919 |
$result["error"]=$trStart;
|
|
|
3920 |
|
|
|
3921 |
#回傳結果
|
|
|
3922 |
return $result;
|
|
|
3923 |
|
|
|
3924 |
}#if end
|
|
|
3925 |
|
|
|
3926 |
#串接列開始
|
|
|
3927 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
3928 |
|
|
|
3929 |
}#if end
|
|
|
3930 |
|
|
|
3931 |
#如果$conf["tdStart"]其值爲 "true"
|
|
|
3932 |
if($conf["tdStart"]=="true"){
|
|
|
3933 |
|
|
|
3934 |
#列開始且套用css樣式.
|
|
|
3935 |
#函式說明:
|
|
|
3936 |
#行開始
|
|
|
3937 |
#回傳結果:
|
|
|
3938 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
3939 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
3940 |
#$result["content"],行開始的語法.
|
|
|
3941 |
#$result["function"],當前執行的函式名稱.
|
|
|
3942 |
#必填寫的參數:
|
|
|
3943 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];#該 td 要套用套用的 css 樣式
|
|
|
3944 |
#預設的樣式
|
|
|
3945 |
#"border-width","border","border-color","border-style","margin-right","margin-left"
|
|
|
3946 |
#"100%","1px","#0000FF","solid","auto","auto"
|
|
|
3947 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
3948 |
unset($conf["table"]);
|
|
|
3949 |
|
|
|
3950 |
#若行開始失敗
|
|
|
3951 |
if($tdStart["status"]=="false"){
|
|
|
3952 |
|
|
|
3953 |
#設置執行失敗
|
|
|
3954 |
$result["status"]="false";
|
|
|
3955 |
|
|
|
3956 |
#設置執行錯誤訊息
|
|
|
3957 |
$result["error"]=$tdStart;
|
|
|
3958 |
|
|
|
3959 |
#回傳結果
|
|
|
3960 |
return $result;
|
|
|
3961 |
|
|
|
3962 |
}#if end
|
|
|
3963 |
|
|
|
3964 |
#串接行開始的語法
|
|
|
3965 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
3966 |
|
|
|
3967 |
}#if end
|
|
|
3968 |
|
|
|
3969 |
#如果 $conf["hiddenVarName"] 存在
|
|
|
3970 |
if(isset($conf["hiddenVarName"])){
|
|
|
3971 |
|
|
|
3972 |
#傳送多個隱藏表單的資訊
|
|
|
3973 |
#回傳的數值:
|
|
|
3974 |
#如果回傳值等於1,則代表參數設定錯誤。
|
|
|
3975 |
#$result["sendedArrayName"],
|
|
|
3976 |
#$result["sendedArrayValue"],
|
|
|
3977 |
#$result["sendedArrayCount"],
|
|
|
3978 |
#必填參數:
|
|
|
3979 |
$conf_inputMutiHidden["nameArray"]=$conf["hiddenVarName"];#欲傳送的隱藏陣列變數名稱
|
|
|
3980 |
$conf_inputMutiHidden["valueArray"]=$conf["hiddenVarContent"];#欲傳送的隱藏陣列變數數值
|
|
|
3981 |
$hiddenVar=form::inputMultiHidden($conf_inputMutiHidden);
|
|
|
3982 |
unset($conf_inputMutiHidden);
|
|
|
3983 |
|
|
|
3984 |
#如果隱藏的表單變數設置失敗
|
|
|
3985 |
if($hiddenVar["status"]=="false"){
|
|
|
3986 |
|
|
|
3987 |
#設置執行不正常
|
|
|
3988 |
$result["status"]="false";
|
|
|
3989 |
|
|
|
3990 |
#設置執行錯誤的訊息
|
|
|
3991 |
$result["error"]=$hiddenVar;
|
|
|
3992 |
|
|
|
3993 |
#回傳結果
|
|
|
3994 |
return $result;
|
|
|
3995 |
|
|
|
3996 |
}#if end
|
|
|
3997 |
|
|
|
3998 |
#接上語法
|
|
|
3999 |
$result["content"]=$result["content"].$hiddenVar["content"];
|
|
|
4000 |
|
|
|
4001 |
}#if end
|
|
|
4002 |
|
|
|
4003 |
#一般按鈕
|
|
|
4004 |
#函式說明:
|
|
|
4005 |
#放置按鈕
|
|
|
4006 |
#回傳結果:
|
|
|
4007 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4008 |
#$result["function"],當前執行的函數.
|
|
|
4009 |
#$result["error"],錯誤訊息陣列.
|
|
|
4010 |
#$result["content"],按鈕語法.
|
|
|
4011 |
#必填參數:
|
|
|
4012 |
$conf["form::button"]["buttonDisplayValue"]=$conf["buttonDisplayValue"];#爲按鈕上顯示的文字。
|
|
|
4013 |
#可省略參數:
|
|
|
4014 |
$conf["form::button"]["buttonStyleName"]=$conf["buttonStyleName"];#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
4015 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
4016 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
4017 |
|
|
|
4018 |
#如果有設定 $conf["buttonActionScriptFunction"]
|
|
|
4019 |
if(isset($conf["buttonActionScriptFunction"])){
|
|
|
4020 |
|
|
|
4021 |
$conf["form::button"]["buttonActionScriptFunction"]=$conf["buttonActionScriptFunction"];#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
4022 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
4023 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
4024 |
|
|
|
4025 |
}#if end
|
|
|
4026 |
|
|
|
4027 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
4028 |
$conf["form::button"]["disabled"]=$conf["disabled"];#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
4029 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
4030 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
4031 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
4032 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
4033 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
4034 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
4035 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
4036 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
4037 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
4038 |
#$conf["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
4039 |
#$conf["action"]="";#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
4040 |
#$conf["target"]="";#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
4041 |
#$conf["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
4042 |
#$conf["buttonId"],字串,按鈕的id.
|
|
|
4043 |
|
|
|
4044 |
#如果 $conf["buttonId"] 有設置
|
|
|
4045 |
if(isset($conf["buttonId"])){
|
|
|
4046 |
|
|
|
4047 |
#設置按鈕id
|
|
|
4048 |
$conf["form::button"]["buttonId"]=$conf["buttonId"];
|
|
|
4049 |
|
|
|
4050 |
}#if end
|
|
|
4051 |
|
|
|
4052 |
#參考資料:
|
|
|
4053 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
4054 |
$button=form::button($conf["form::button"]);
|
|
|
4055 |
unset($conf["form::button"]);
|
|
|
4056 |
|
|
|
4057 |
#如果建立按鈕失敗
|
|
|
4058 |
if($button["status"]=="false"){
|
|
|
4059 |
|
|
|
4060 |
#設置執行不正常
|
|
|
4061 |
$result["status"]="false";
|
|
|
4062 |
|
|
|
4063 |
#設置執行錯誤的訊息
|
|
|
4064 |
$result["error"]=$button;
|
|
|
4065 |
|
|
|
4066 |
#回傳結果
|
|
|
4067 |
return $result;
|
|
|
4068 |
|
|
|
4069 |
}#if end
|
|
|
4070 |
|
|
|
4071 |
#接上按鈕語法
|
|
|
4072 |
$result["content"]=$result["content"].$button["content"];
|
|
|
4073 |
|
|
|
4074 |
#如果其值爲 true
|
|
|
4075 |
if($conf["tdEnd"]=="true"){
|
|
|
4076 |
|
|
|
4077 |
#加上 </td>
|
|
|
4078 |
$result["content"]=$result["content"]."</td>";
|
|
|
4079 |
|
|
|
4080 |
}#if end
|
|
|
4081 |
|
|
|
4082 |
#如果其值爲 true
|
|
|
4083 |
if($conf["trEnd"]=="true"){
|
|
|
4084 |
|
|
|
4085 |
#加上 </tr>
|
|
|
4086 |
$result["content"]=$result["content"]."</tr>";
|
|
|
4087 |
|
|
|
4088 |
}#if end
|
|
|
4089 |
|
|
|
4090 |
#如果 $conf["formEnd"] 等於 true
|
|
|
4091 |
if($conf["formEnd"]=="true"){
|
|
|
4092 |
|
|
|
4093 |
#說明:
|
|
|
4094 |
#表單結束
|
|
|
4095 |
#回傳結果:
|
|
|
4096 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
4097 |
#$result["error"],錯誤訊息陣列.
|
|
|
4098 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
4099 |
#$result["content"],表單結束的語法.
|
|
|
4100 |
#必填寫的參數:
|
|
|
4101 |
$conf_end["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
4102 |
$formEnd=form::end($conf_end);
|
|
|
4103 |
unset($conf_end);
|
|
|
4104 |
|
|
|
4105 |
#如果表單結束失敗
|
|
|
4106 |
if($formEnd["status"]=="false"){
|
|
|
4107 |
|
|
|
4108 |
#設置執行失敗
|
|
|
4109 |
$result["status"]="false";
|
|
|
4110 |
|
|
|
4111 |
#設置執行錯誤訊息
|
|
|
4112 |
$result["error"]=$formEnd;
|
|
|
4113 |
|
|
|
4114 |
#回傳結果
|
|
|
4115 |
return $result;
|
|
|
4116 |
|
|
|
4117 |
}#if end
|
|
|
4118 |
|
|
|
4119 |
#串聯表單結束的語法
|
|
|
4120 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
4121 |
|
|
|
4122 |
}#if end
|
|
|
4123 |
|
|
|
4124 |
#如果有表格結束
|
|
|
4125 |
if($conf["tableEnd"]=="true"){
|
|
|
4126 |
|
|
|
4127 |
#函式說明:
|
|
|
4128 |
#表格結束
|
|
|
4129 |
#回傳結果:
|
|
|
4130 |
#表格結束的語法
|
|
|
4131 |
$result["content"]=$result["content"].table::end();
|
|
|
4132 |
|
|
|
4133 |
}#if end
|
|
|
4134 |
|
|
|
4135 |
#設置執行正常
|
|
|
4136 |
$result["status"]="true";
|
|
|
4137 |
|
|
|
4138 |
#回傳結果
|
|
|
4139 |
return $result;
|
|
|
4140 |
|
|
|
4141 |
}#function sendHugeDataButton end
|
|
|
4142 |
|
|
|
4143 |
/*
|
|
|
4144 |
#函式說明:
|
|
|
4145 |
#可以輸入文字的表單
|
|
|
4146 |
#回傳結果:
|
|
|
4147 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4148 |
#$result["function"],當前執行的函數.
|
|
|
4149 |
#$result["error"],錯誤訊息陣列.
|
|
|
4150 |
#$result["content"],按鈕語法.
|
|
|
4151 |
#必填參數:
|
|
|
4152 |
#$conf["name"],字串,爲該文字輸入框的名稱,用於讓接收頁面讀取的名稱。
|
|
|
4153 |
$conf["name"]="";
|
|
|
4154 |
#$conf["readOnly"],字串,爲該文字框是否可以填寫資料,若要只能觀看不能填寫,那麼就必須將其值設爲"true",反之要設爲"false".
|
|
|
4155 |
$conf["readOnly"]="false";
|
|
|
4156 |
#可省略參數:
|
|
|
4157 |
#$conf["width"],字串,爲文字框的外觀長度,預設為"100%".
|
|
|
4158 |
#$conf["width"]="";
|
|
|
4159 |
#$conf["maxInputLength"],字串,爲可輸入的最大位元長度,預設不限制.
|
|
|
4160 |
#$conf["maxInputLength"]="";
|
|
|
4161 |
#$conf["autoFocus"],字串,是否為將填寫的指標移到該表單,"true"代表要,預設為"false".
|
|
|
4162 |
#$conf["autoFocus"]="";
|
|
|
4163 |
#$conf["value"],字串,爲該文字框預設要顯示的文字,預設爲"".
|
|
|
4164 |
#$conf["value"]="";
|
|
|
4165 |
#$conf["class"],字串,爲要套用的css樣式,若省略,則會套用預設的 "__qbpwcf_inputTextCssStyle" 樣式,其屬性爲 "width:100%","font-size:30px"
|
|
|
4166 |
#$conf["class"]="";
|
|
|
4167 |
#$conf["classList"],字串陣列,為要使用的多個css class樣式,若有使用,則會取代"class"參數的設定.
|
|
|
4168 |
#$conf["classList"]=array();
|
|
|
4169 |
#$conf["jsActivitor"],字串,爲觸發js的條件,可以是"onChange"(已改變內容時)、"onClick"(按下按鈕時)、"onkeyup"(當鍵盤按下放開後)、"onmouseover"(當滑鼠移過去的時候)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
4170 |
#$conf["jsActivitor"]="";
|
|
|
4171 |
#$conf["jsAction"],字串,爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
4172 |
#$conf["jsAction"]="";
|
|
|
4173 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
4174 |
#$conf["trStart"]="";
|
|
|
4175 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
4176 |
#$conf["tdStart"]="";
|
|
|
4177 |
#$conf["formStart"],字串,爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
4178 |
#$conf["formStart"]="";
|
|
|
4179 |
#$conf["formAction"],字串,表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
4180 |
#$conf["formAction"]="";
|
|
|
4181 |
#$conf["formName"],字串,爲該表單的名稱
|
|
|
4182 |
#$conf["formName"]="";
|
|
|
4183 |
#$conf["formMethod"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
4184 |
#$conf["formMethod"]="";
|
|
|
4185 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
4186 |
#$conf["formTarget"]="";
|
|
|
4187 |
#$conf["tableStart"],字串,爲該表單是否要以<table>開始。"true"爲是,預設為"false".
|
|
|
4188 |
#$conf["tableStart"]="";
|
|
|
4189 |
#$conf["tableClass"],字串,表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder".
|
|
|
4190 |
#$conf["tableClass"]="";
|
|
|
4191 |
#$conf["formEnd"],字串,爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
4192 |
#$conf["formEnd"]="true";
|
|
|
4193 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
4194 |
#$conf["tdEnd"]="true";
|
|
|
4195 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
4196 |
#$conf["trEnd"]="true";
|
|
|
4197 |
#$conf["tableEnd"],字串,爲該表單是否要以</table>結尾,"true"爲是,預設為"false".
|
|
|
4198 |
#$conf["tableEnd"]="true";
|
|
|
4199 |
#$conf["autocomplete"],字串,是否依據使用者過往輸入的記錄來提示可能要的輸入內容,"on"為啟用,"off"為停用,預設為"on".
|
|
|
4200 |
#$conf["autocomplete"]="off";
|
|
|
4201 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
4202 |
#$conf["required"]="true";
|
|
|
4203 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
4204 |
#$conf["comment"]="";
|
|
|
4205 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
4206 |
#$conf["placeholder"]="";
|
|
|
4207 |
#$conf["br"],字串,"true"代表最後要換行,預設為"false".
|
|
|
4208 |
#$conf["br"]="true";
|
|
|
4209 |
#$conf["p"],字串,"true"代表最後要空一行,預設為"false".
|
|
|
4210 |
#$conf["p"]="true";
|
|
|
4211 |
#$conf["id"],字串,該元素的id,預設不使用.
|
|
|
4212 |
#$conf["id"]="";
|
|
|
4213 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
4214 |
#$conf["dataFormId"]="";
|
|
|
4215 |
#參考資料:
|
|
|
4216 |
#input=>http://www.w3schools.com/tags/tag_input.asp
|
|
|
4217 |
#備註:
|
|
|
4218 |
#無.
|
|
|
4219 |
*/
|
|
|
4220 |
public static function inputText(&$conf){
|
|
|
4221 |
|
|
|
4222 |
#初始化要回傳的內容
|
|
|
4223 |
$result=array();
|
|
|
4224 |
|
|
|
4225 |
#設置當前執行的函數
|
|
|
4226 |
$result["function"]=__FUNCTION__;
|
|
|
4227 |
|
|
|
4228 |
#初始化content樣式內容
|
|
|
4229 |
$result["content"]="";
|
|
|
4230 |
|
|
|
4231 |
#如果 $conf 不為陣列
|
|
|
4232 |
if(gettype($conf)!="array"){
|
|
|
4233 |
|
|
|
4234 |
#設置執行失敗
|
|
|
4235 |
$result["status"]="false";
|
|
|
4236 |
|
|
|
4237 |
#設置執行錯誤訊息
|
|
|
4238 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
4239 |
|
|
|
4240 |
#如果傳入的參數為 null
|
|
|
4241 |
if($conf==null){
|
|
|
4242 |
|
|
|
4243 |
#設置執行錯誤訊息
|
|
|
4244 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
4245 |
|
|
|
4246 |
}#if end
|
|
|
4247 |
|
|
|
4248 |
#回傳結果
|
|
|
4249 |
return $result;
|
|
|
4250 |
|
|
|
4251 |
}#if end
|
|
|
4252 |
|
|
|
4253 |
#函式說明:
|
|
|
4254 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
4255 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4256 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
4257 |
#$result["function"],當前執行的函式名稱.
|
|
|
4258 |
#$result["argu"],設置給予的參數.
|
|
|
4259 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
4260 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
4261 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
4262 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
4263 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
4264 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
4265 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
4266 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
4267 |
#必填寫的參數:
|
|
|
4268 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
4269 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
4270 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
4271 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
4272 |
#可以省略的參數:
|
|
|
4273 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
4274 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name","readOnly");
|
|
|
4275 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
4276 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
4277 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
4278 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
4279 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
4280 |
#$conf["canNotBeEmpty"]=array();
|
|
|
4281 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
4282 |
#$conf["canBeEmpty"]=array();
|
|
|
4283 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
4284 |
#$conf["skipableVariableCanNotBeEmpty"]=array();
|
|
|
4285 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
4286 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("width","maxInputLength","autoFocus","value","class","jsActivitor","jsAction","trStart","tdStart","formStart","formAction","formName","formMethod","formTarget","tableStart","tableClass","formEnd","tdEnd","trEnd","tableEnd","autocomplete","comment","placeholder","br","p","required","id","dataFormId","classList");
|
|
|
4287 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
4288 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","array");
|
|
|
4289 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
4290 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"__qbpwcf_inputTextCssStyle",null,null,"false","false","false",null,null,"post","_self","false","__withoutBorder","false","false","false","false","on",null,null,"false","false","false",null,null,null);
|
|
|
4291 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
4292 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
4293 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
4294 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
4295 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
4296 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
4297 |
#參考資料:
|
|
|
4298 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
4299 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
4300 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
4301 |
|
|
|
4302 |
#如果檢查失敗
|
|
|
4303 |
if($checkArguments["status"]=="false"){
|
|
|
4304 |
|
|
|
4305 |
#設置執行不正常
|
|
|
4306 |
$result["status"]="false";
|
|
|
4307 |
|
|
|
4308 |
#程式停止執行
|
|
|
4309 |
$result["error"]=$checkArguments;
|
|
|
4310 |
|
|
|
4311 |
#回傳結果
|
|
|
4312 |
return $result;
|
|
|
4313 |
|
|
|
4314 |
}#if end
|
|
|
4315 |
|
|
|
4316 |
#如果檢查不通過
|
|
|
4317 |
if($checkArguments["passed"]=="false"){
|
|
|
4318 |
|
|
|
4319 |
#設置執行不正常
|
|
|
4320 |
$result["status"]="false";
|
|
|
4321 |
|
|
|
4322 |
#程式停止執行
|
|
|
4323 |
$result["error"]=$checkArguments;
|
|
|
4324 |
|
|
|
4325 |
#回傳結果
|
|
|
4326 |
return $result;
|
|
|
4327 |
|
|
|
4328 |
}#if end
|
|
|
4329 |
|
|
|
4330 |
#如果 $conf["tableStart"] 為 "true"
|
|
|
4331 |
if($conf["tableStart"]=="true"){
|
|
|
4332 |
|
|
|
4333 |
#函式說明:
|
|
|
4334 |
#表格開始,可以設定表格的厚度和位置
|
|
|
4335 |
#回傳結果:
|
|
|
4336 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4337 |
#$result["content"],表格開始的語法
|
|
|
4338 |
#$result["function"],當前執行的函數
|
|
|
4339 |
#$result["error"],函式錯誤訊息
|
|
|
4340 |
#必填寫的參數:
|
|
|
4341 |
$conf["table::start"]["class"]=$conf["tableClass"];#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
4342 |
$tableStart=table::start($conf["table::start"]);
|
|
|
4343 |
unset($conf["table::start"]);
|
|
|
4344 |
|
|
|
4345 |
#如果表開始立失敗
|
|
|
4346 |
if($tableStart["status"]=="false"){
|
|
|
4347 |
|
|
|
4348 |
#設置執行失敗
|
|
|
4349 |
$result["status"]="false";
|
|
|
4350 |
|
|
|
4351 |
#設置執行錯誤訊息
|
|
|
4352 |
$result["error"]=$tableStart;
|
|
|
4353 |
|
|
|
4354 |
#回傳結果
|
|
|
4355 |
return $result;
|
|
|
4356 |
|
|
|
4357 |
}#if end
|
|
|
4358 |
|
|
|
4359 |
#串接表格開始的語法
|
|
|
4360 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
4361 |
|
|
|
4362 |
}#if end
|
|
|
4363 |
|
|
|
4364 |
#如果 $conf["comment"] 有設置
|
|
|
4365 |
if(isset($conf["comment"])){
|
|
|
4366 |
|
|
|
4367 |
#新增label,且套用css樣式.
|
|
|
4368 |
$result["content"]=$result["content"]."<label for=\"".$conf["name"]."\" class=\"".$conf["class"]."\" >".$conf["comment"]."</label>";
|
|
|
4369 |
|
|
|
4370 |
}#if end
|
|
|
4371 |
|
|
|
4372 |
#如果其值爲 true
|
|
|
4373 |
if($conf["trStart"]=="true"){
|
|
|
4374 |
|
|
|
4375 |
#串接列開始<tr>
|
|
|
4376 |
$result["content"]=$result["content"]."<tr>";
|
|
|
4377 |
|
|
|
4378 |
}#if end
|
|
|
4379 |
|
|
|
4380 |
#如果其值爲 true
|
|
|
4381 |
if($conf["tdStart"]=="true"){
|
|
|
4382 |
|
|
|
4383 |
#串接欄位開始<td>
|
|
|
4384 |
$result["content"]=$result["content"]."<td>";
|
|
|
4385 |
|
|
|
4386 |
}#if end
|
|
|
4387 |
|
|
|
4388 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
4389 |
if($conf["formStart"]=="true"){
|
|
|
4390 |
|
|
|
4391 |
#函式說明:
|
|
|
4392 |
#表單開始
|
|
|
4393 |
#回傳結果:
|
|
|
4394 |
#$result,表單開始的語法
|
|
|
4395 |
#必填參數:
|
|
|
4396 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
4397 |
#可省略參數:
|
|
|
4398 |
|
|
|
4399 |
#如果 $conf["formName"] 有設置
|
|
|
4400 |
if(isset($conf["formName"])){
|
|
|
4401 |
|
|
|
4402 |
#過濾 $conf["formName"] 避免錯誤
|
|
|
4403 |
#函式說明:
|
|
|
4404 |
#處理字串避免網頁出錯
|
|
|
4405 |
#回傳結果:
|
|
|
4406 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4407 |
#$result["function"],當前執行的函數.
|
|
|
4408 |
#$result["content"],爲處理好的字串.
|
|
|
4409 |
#$result["error"],錯誤訊息陣列.
|
|
|
4410 |
#必填參數:
|
|
|
4411 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
4412 |
#可省略的參數:
|
|
|
4413 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
4414 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
4415 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
4416 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
4417 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
4418 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
4419 |
|
|
|
4420 |
#如果過濾 $conf["formName"] 失敗
|
|
|
4421 |
if($correctCharacter["status"]=="false"){
|
|
|
4422 |
|
|
|
4423 |
#設置執行失敗
|
|
|
4424 |
$result["status"]="false";
|
|
|
4425 |
|
|
|
4426 |
#設置執行錯誤訊息
|
|
|
4427 |
$result["error"]=$correctCharacter;
|
|
|
4428 |
|
|
|
4429 |
#回傳結果
|
|
|
4430 |
return $result;
|
|
|
4431 |
|
|
|
4432 |
}#if end
|
|
|
4433 |
|
|
|
4434 |
#則設定其數值
|
|
|
4435 |
$conf["form"]["start"]["name"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
4436 |
|
|
|
4437 |
}#if end
|
|
|
4438 |
|
|
|
4439 |
#如果 $conf["formMethod"] 有設置
|
|
|
4440 |
if(isset($conf["formMethod"])){
|
|
|
4441 |
|
|
|
4442 |
#則設定其數值
|
|
|
4443 |
$conf["form"]["start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
4444 |
|
|
|
4445 |
}#if end
|
|
|
4446 |
|
|
|
4447 |
#如果 $conf["formTarget"] 有設定
|
|
|
4448 |
if(isset($conf["formTarget"])){
|
|
|
4449 |
|
|
|
4450 |
#則設定其數值
|
|
|
4451 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
4452 |
|
|
|
4453 |
}#if end
|
|
|
4454 |
|
|
|
4455 |
#則設定其參數數值
|
|
|
4456 |
$conf["form"]["start"]["tableStart"]="false";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
4457 |
|
|
|
4458 |
#則設定其數值
|
|
|
4459 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
4460 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
4461 |
unset($conf["form"]["start"]);
|
|
|
4462 |
|
|
|
4463 |
#如果表單開始失敗
|
|
|
4464 |
if($formStart["status"]=="false"){
|
|
|
4465 |
|
|
|
4466 |
#設置執行失敗
|
|
|
4467 |
$result["status"]="false";
|
|
|
4468 |
|
|
|
4469 |
#設置執行錯誤訊息
|
|
|
4470 |
$result["error"]=$formStart;
|
|
|
4471 |
|
|
|
4472 |
#回傳結果
|
|
|
4473 |
return $result;
|
|
|
4474 |
|
|
|
4475 |
}#if end
|
|
|
4476 |
|
|
|
4477 |
#串接表單開始的語法
|
|
|
4478 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
4479 |
|
|
|
4480 |
}#if end
|
|
|
4481 |
|
|
|
4482 |
#如果$conf["width"]沒設定
|
|
|
4483 |
if(!isset($conf["width"])){
|
|
|
4484 |
|
|
|
4485 |
#則$conf["width"]爲空值
|
|
|
4486 |
$conf["width"]="";
|
|
|
4487 |
|
|
|
4488 |
}#if end
|
|
|
4489 |
|
|
|
4490 |
#如果$conf["width"]有設定
|
|
|
4491 |
else{
|
|
|
4492 |
|
|
|
4493 |
#則套用寬度的css設定值
|
|
|
4494 |
$conf["width"]=" style=\"width:".$conf["width"].";\" ";
|
|
|
4495 |
|
|
|
4496 |
}#else end
|
|
|
4497 |
|
|
|
4498 |
#如果$conf["maxInputLength"]沒設定
|
|
|
4499 |
if(!isset($conf["maxInputLength"])){
|
|
|
4500 |
|
|
|
4501 |
#則$conf["maxInputLength"]爲空值
|
|
|
4502 |
$conf["maxInputLength"]="";
|
|
|
4503 |
|
|
|
4504 |
}#if end
|
|
|
4505 |
|
|
|
4506 |
#如果$conf["maxInputLength"]有設定
|
|
|
4507 |
else{
|
|
|
4508 |
|
|
|
4509 |
$conf["maxInputLength"]=" maxlength=".$conf["maxInputLength"];
|
|
|
4510 |
|
|
|
4511 |
}#else end
|
|
|
4512 |
|
|
|
4513 |
#如果$conf["value"]沒有設定
|
|
|
4514 |
if(!isset($conf["value"])){
|
|
|
4515 |
|
|
|
4516 |
#則$value就爲空值
|
|
|
4517 |
$conf["value"]="";
|
|
|
4518 |
|
|
|
4519 |
}#if end
|
|
|
4520 |
|
|
|
4521 |
#如果$conf["value"]有設定,且不為空.
|
|
|
4522 |
else if($conf["value"]!==""){
|
|
|
4523 |
|
|
|
4524 |
#過濾 $conf["value"] 的內容,避免錯誤。
|
|
|
4525 |
#函式說明:
|
|
|
4526 |
#處理字串避免網頁出錯
|
|
|
4527 |
#回傳結果:
|
|
|
4528 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4529 |
#$result["function"],當前執行的函數.
|
|
|
4530 |
#$result["content"],爲處理好的字串.
|
|
|
4531 |
#$result["error"],錯誤訊息陣列.
|
|
|
4532 |
#必填參數:
|
|
|
4533 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["value"];#爲要處理的字串
|
|
|
4534 |
#可省略的參數:
|
|
|
4535 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
4536 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
4537 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
4538 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
4539 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
4540 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
4541 |
|
|
|
4542 |
#如果過濾字串失敗
|
|
|
4543 |
if($correctCharacter["status"]=="false"){
|
|
|
4544 |
|
|
|
4545 |
#設置執行失敗
|
|
|
4546 |
$result["status"]="false";
|
|
|
4547 |
|
|
|
4548 |
#設置執行錯誤訊息
|
|
|
4549 |
$result["error"]=$correctCharacter;
|
|
|
4550 |
|
|
|
4551 |
#回傳結果
|
|
|
4552 |
return $result;
|
|
|
4553 |
|
|
|
4554 |
}#if end
|
|
|
4555 |
|
|
|
4556 |
#就設定預設的內容
|
|
|
4557 |
$conf["value"] =" value= \"".$correctCharacter["content"]."\" ";
|
|
|
4558 |
|
|
|
4559 |
}#else end
|
|
|
4560 |
|
|
|
4561 |
#如果$conf["readOnly"]爲"true"
|
|
|
4562 |
if($conf["readOnly"]=="true"){
|
|
|
4563 |
|
|
|
4564 |
#則$conf["readOnly"] 爲 readonly
|
|
|
4565 |
$conf["readOnly"]="readonly=true disabled=true";
|
|
|
4566 |
|
|
|
4567 |
}#if end
|
|
|
4568 |
|
|
|
4569 |
#反之
|
|
|
4570 |
else{
|
|
|
4571 |
|
|
|
4572 |
#$conf["readOnly"]爲空
|
|
|
4573 |
$conf["readOnly"]="";
|
|
|
4574 |
|
|
|
4575 |
}#if end
|
|
|
4576 |
|
|
|
4577 |
#判斷 $conf["autoFocus"] 的數值
|
|
|
4578 |
switch($conf["autoFocus"]){
|
|
|
4579 |
|
|
|
4580 |
#如果是 "true"
|
|
|
4581 |
case "true":
|
|
|
4582 |
|
|
|
4583 |
#設置為 "autofocus"
|
|
|
4584 |
$conf["autoFocus"]=" autofocus=true ";
|
|
|
4585 |
|
|
|
4586 |
#跳出 switch
|
|
|
4587 |
break;
|
|
|
4588 |
|
|
|
4589 |
#如果是其他內容
|
|
|
4590 |
default:
|
|
|
4591 |
|
|
|
4592 |
#則設置為 ""
|
|
|
4593 |
$conf["autoFocus"]="";
|
|
|
4594 |
|
|
|
4595 |
}#switch end
|
|
|
4596 |
|
|
|
4597 |
#如果有設置 $conf["class"]
|
|
|
4598 |
if(isset($conf["class"])){
|
|
|
4599 |
|
|
|
4600 |
#套用css設定
|
|
|
4601 |
$conf["class"]=" class = \"".$conf["class"]."\"";
|
|
|
4602 |
|
|
|
4603 |
}#if end
|
| 226 |
liveuser |
4604 |
|
| 3 |
liveuser |
4605 |
#反之
|
|
|
4606 |
else{
|
|
|
4607 |
#設置為空字串
|
|
|
4608 |
$conf["class"]="";
|
| 226 |
liveuser |
4609 |
|
| 3 |
liveuser |
4610 |
}#else end
|
| 226 |
liveuser |
4611 |
|
| 3 |
liveuser |
4612 |
#如果有 $conf["classList"]
|
|
|
4613 |
if(isset($conf["classList"])){
|
| 226 |
liveuser |
4614 |
|
| 3 |
liveuser |
4615 |
#傳接 class 開始
|
|
|
4616 |
$conf["class"]=" class = \"";
|
| 226 |
liveuser |
4617 |
|
| 3 |
liveuser |
4618 |
#針對 $conf["classList"] 的每個元素
|
|
|
4619 |
foreach($conf["classList"] as $index => $cssClassName){
|
| 226 |
liveuser |
4620 |
|
| 3 |
liveuser |
4621 |
#串接 class 名稱
|
|
|
4622 |
$conf["class"]=$conf["class"].$cssClassName;
|
| 226 |
liveuser |
4623 |
|
| 3 |
liveuser |
4624 |
#若後面還有未串接的 class 名稱
|
|
|
4625 |
if(isset($conf["classList"][$index+1])){
|
| 226 |
liveuser |
4626 |
|
| 3 |
liveuser |
4627 |
#串接空格
|
|
|
4628 |
$conf["class"]=$conf["class"]." ";
|
| 226 |
liveuser |
4629 |
|
| 3 |
liveuser |
4630 |
}#if end
|
| 226 |
liveuser |
4631 |
|
| 3 |
liveuser |
4632 |
}#foreach end
|
| 226 |
liveuser |
4633 |
|
| 3 |
liveuser |
4634 |
#串接 class 結束
|
|
|
4635 |
$conf["class"]=$conf["class"]."\"";
|
| 226 |
liveuser |
4636 |
|
| 3 |
liveuser |
4637 |
}#if end
|
|
|
4638 |
|
|
|
4639 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
4640 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
4641 |
|
|
|
4642 |
#則將設定值組合
|
|
|
4643 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
4644 |
|
|
|
4645 |
}#if end
|
|
|
4646 |
|
|
|
4647 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
4648 |
if(!isset($conf["jsCustom"])){
|
|
|
4649 |
|
|
|
4650 |
#將其設爲空值
|
|
|
4651 |
$conf["jsCustom"]="";
|
|
|
4652 |
|
|
|
4653 |
}#if end
|
|
|
4654 |
|
|
|
4655 |
#過濾 $conf["name"] 避免錯誤
|
|
|
4656 |
#函式說明:
|
|
|
4657 |
#處理字串避免網頁出錯
|
|
|
4658 |
#回傳結果:
|
|
|
4659 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4660 |
#$result["function"],當前執行的函數.
|
|
|
4661 |
#$result["content"],爲處理好的字串.
|
|
|
4662 |
#$result["error"],錯誤訊息陣列.
|
|
|
4663 |
#必填參數:
|
|
|
4664 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
4665 |
#可省略的參數:
|
|
|
4666 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
4667 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
4668 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
4669 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
4670 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
4671 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
4672 |
|
|
|
4673 |
#如果過濾字串失敗
|
|
|
4674 |
if($correctCharacter["status"]=="false"){
|
|
|
4675 |
|
|
|
4676 |
#設置執行失敗
|
|
|
4677 |
$result["status"]="false";
|
|
|
4678 |
|
|
|
4679 |
#設置執行錯誤訊息
|
|
|
4680 |
$result["error"]=$correctCharacter;
|
|
|
4681 |
|
|
|
4682 |
#回傳結果
|
|
|
4683 |
return $result;
|
|
|
4684 |
|
|
|
4685 |
}#if end
|
|
|
4686 |
|
|
|
4687 |
#置換過濾好了的$conf["name"]
|
|
|
4688 |
$conf["name"]=$correctCharacter["content"];
|
|
|
4689 |
|
|
|
4690 |
#如果有設定 $conf["placeholder"]
|
|
|
4691 |
if(isset($conf["placeholder"])){
|
|
|
4692 |
|
|
|
4693 |
#串接 placeholder 的內容
|
|
|
4694 |
$conf["placeholder"]=" placeholder=\"".$conf["placeholder"]."\" ";
|
|
|
4695 |
|
|
|
4696 |
}#if end
|
|
|
4697 |
|
|
|
4698 |
#反之沒有設定 $conf["placeholder"]
|
|
|
4699 |
else{
|
|
|
4700 |
|
|
|
4701 |
#設為 ""
|
|
|
4702 |
$conf["placeholder"]="";
|
|
|
4703 |
|
|
|
4704 |
}#else end
|
|
|
4705 |
|
|
|
4706 |
#如果 $conf["required"] 為"true"
|
|
|
4707 |
if($conf["required"]=="true"){
|
|
|
4708 |
|
|
|
4709 |
#設置 "required" 屬性
|
|
|
4710 |
$conf["required"]="required=true";
|
|
|
4711 |
|
|
|
4712 |
}#if end
|
|
|
4713 |
|
|
|
4714 |
#反之
|
|
|
4715 |
else{
|
|
|
4716 |
|
|
|
4717 |
#設為空值
|
|
|
4718 |
$conf["required"]="";
|
|
|
4719 |
|
|
|
4720 |
}#else end
|
|
|
4721 |
|
|
|
4722 |
#如果有設置id
|
|
|
4723 |
if(isset($conf["id"])){
|
|
|
4724 |
|
|
|
4725 |
#設置id屬性
|
|
|
4726 |
$conf["id"]="id=\"".$conf["id"]."\"";
|
|
|
4727 |
|
|
|
4728 |
}#if end
|
|
|
4729 |
|
|
|
4730 |
#反之
|
|
|
4731 |
else{
|
|
|
4732 |
|
|
|
4733 |
#設為空值
|
|
|
4734 |
$conf["id"]="";
|
|
|
4735 |
|
|
|
4736 |
}#else end
|
|
|
4737 |
|
|
|
4738 |
#如果有設置 $conf["dataFormId"]
|
|
|
4739 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
4740 |
|
| 3 |
liveuser |
4741 |
#設置 data-id 屬性
|
|
|
4742 |
$conf["dataFormId"]="data-form-id=\"".$conf["dataFormId"]."\"";
|
| 226 |
liveuser |
4743 |
|
| 3 |
liveuser |
4744 |
}#if end
|
| 226 |
liveuser |
4745 |
|
|
|
4746 |
#反之設置為空數值
|
| 3 |
liveuser |
4747 |
else{
|
| 226 |
liveuser |
4748 |
|
| 3 |
liveuser |
4749 |
$conf["dataFormId"]="";
|
|
|
4750 |
|
| 226 |
liveuser |
4751 |
}#else end
|
|
|
4752 |
|
| 3 |
liveuser |
4753 |
#如果要 autocomplete
|
| 30 |
liveuser |
4754 |
if($conf["autocomplete"]==="on"){
|
| 226 |
liveuser |
4755 |
|
| 3 |
liveuser |
4756 |
#設置為 "autocomplete"
|
|
|
4757 |
$conf["autocomplete"]="autocomplete";
|
| 226 |
liveuser |
4758 |
|
| 30 |
liveuser |
4759 |
}#if end
|
| 226 |
liveuser |
4760 |
|
| 3 |
liveuser |
4761 |
#反之
|
| 30 |
liveuser |
4762 |
else{
|
| 226 |
liveuser |
4763 |
|
| 3 |
liveuser |
4764 |
#設置為空字串
|
|
|
4765 |
$conf["autocomplete"]="";
|
| 226 |
liveuser |
4766 |
|
| 30 |
liveuser |
4767 |
}#else end
|
| 3 |
liveuser |
4768 |
|
|
|
4769 |
#放置可以輸入文字的表單
|
|
|
4770 |
$result["content"]=$result["content"]."<input ".$conf["id"]." type = \"text\" ".$conf["width"]." ".$conf["maxInputLength"]." name = ".$conf["name"]." id = ".$conf["name"]." ".$conf["value"]." ".$conf["readOnly"]." ".$conf["autoFocus"]." ".$conf["class"]." ".$conf["jsCustom"]." ".$conf["placeholder"]." ".$conf["autocomplete"]." ".$conf["required"]." ".$conf["dataFormId"]." >";
|
|
|
4771 |
|
|
|
4772 |
#如果 $conf["formEnd"] 等於 "true"
|
| 66 |
liveuser |
4773 |
if($conf["formEnd"]==="true"){
|
| 3 |
liveuser |
4774 |
|
|
|
4775 |
#函式說明:
|
|
|
4776 |
#表單結束
|
|
|
4777 |
#回傳結果:
|
|
|
4778 |
#$result,表單結束的語法
|
|
|
4779 |
#必填參數:
|
|
|
4780 |
#則設定其數值
|
|
|
4781 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
4782 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
4783 |
unset($conf["form"]["end"]);
|
|
|
4784 |
|
|
|
4785 |
#串接表單結束的語法
|
|
|
4786 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
4787 |
|
|
|
4788 |
}#if end
|
|
|
4789 |
|
|
|
4790 |
#如果其值爲 true
|
| 66 |
liveuser |
4791 |
if($conf["tdEnd"]==="true"){
|
| 3 |
liveuser |
4792 |
|
|
|
4793 |
#串接欄位結束的語法
|
|
|
4794 |
$result["content"]=$result["content"]."</td>";
|
|
|
4795 |
|
|
|
4796 |
}#if end
|
|
|
4797 |
|
|
|
4798 |
#如果其值爲 true
|
| 66 |
liveuser |
4799 |
if($conf["trEnd"]==="true"){
|
| 3 |
liveuser |
4800 |
|
|
|
4801 |
#串接列結束的語法
|
|
|
4802 |
$result["content"]=$result["content"]."</tr>";
|
|
|
4803 |
|
|
|
4804 |
}#if end
|
|
|
4805 |
|
|
|
4806 |
#如果 $conf["br"] 等於 "true"
|
| 66 |
liveuser |
4807 |
if($conf["br"]==="true"){
|
| 3 |
liveuser |
4808 |
|
|
|
4809 |
#結尾加上<br>
|
|
|
4810 |
$result["content"]=$result["content"]."<br>";
|
|
|
4811 |
|
|
|
4812 |
}#if end
|
|
|
4813 |
|
|
|
4814 |
#如果 $conf["p"] 等於 "true"
|
| 66 |
liveuser |
4815 |
if($conf["p"]==="true"){
|
| 3 |
liveuser |
4816 |
|
|
|
4817 |
#結尾加上<p>
|
|
|
4818 |
$result["content"]=$result["content"]."<p>";
|
|
|
4819 |
|
|
|
4820 |
}#if end
|
|
|
4821 |
|
|
|
4822 |
#執行到這邊代表執行成功
|
|
|
4823 |
$result["status"]="true";
|
|
|
4824 |
|
|
|
4825 |
#回傳結果
|
|
|
4826 |
return $result;
|
|
|
4827 |
|
|
|
4828 |
}#function inputText end
|
| 226 |
liveuser |
4829 |
|
| 3 |
liveuser |
4830 |
/*
|
|
|
4831 |
#函式說明:
|
| 30 |
liveuser |
4832 |
#可以輸入Email的輸入方框
|
|
|
4833 |
#回傳結果:
|
|
|
4834 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4835 |
#$result["function"],當前執行的函數.
|
|
|
4836 |
#$result["error"],錯誤訊息陣列.
|
|
|
4837 |
#$result["content"],按鈕語法.
|
|
|
4838 |
#必填參數:
|
|
|
4839 |
#$conf["name"],字串,爲該文字輸入框的名稱,用於讓接收頁面讀取的名稱。
|
|
|
4840 |
$conf["name"]="";
|
|
|
4841 |
#$conf["readOnly"],字串,爲該文字框是否可以填寫資料,若要只能觀看不能填寫,那麼就必須將其值設爲"true",反之要設爲"false".
|
|
|
4842 |
$conf["readOnly"]="false";
|
|
|
4843 |
#可省略參數:
|
|
|
4844 |
#$conf["width"],字串,爲文字框的外觀長度,預設為"100%".
|
|
|
4845 |
#$conf["width"]="";
|
|
|
4846 |
#$conf["maxInputLength"],字串,爲可輸入的最大位元長度,預設不限制.
|
|
|
4847 |
#$conf["maxInputLength"]="";
|
|
|
4848 |
#$conf["autoFocus"],字串,是否為將填寫的指標移到該表單,"true"代表要,預設為"false".
|
|
|
4849 |
#$conf["autoFocus"]="";
|
|
|
4850 |
#$conf["value"],字串,爲該文字框預設要顯示的文字,預設爲"".
|
|
|
4851 |
#$conf["value"]="";
|
|
|
4852 |
#$conf["class"],字串,爲要套用的css樣式,若省略,則會套用預設的 "__qbpwcf_inputTextCssStyle" 樣式,其屬性爲 "width:100%","font-size:30px"
|
|
|
4853 |
#$conf["class"]="";
|
|
|
4854 |
#$conf["classList"],字串陣列,為要使用的多個css class樣式,若有使用,則會取代"class"參數的設定.
|
|
|
4855 |
#$conf["classList"]=array();
|
|
|
4856 |
#$conf["jsActivitor"],字串,爲觸發js的條件,可以是"onChange"(已改變內容時)、"onClick"(按下按鈕時)、"onkeyup"(當鍵盤按下放開後)、"onmouseover"(當滑鼠移過去的時候)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
4857 |
#$conf["jsActivitor"]="";
|
|
|
4858 |
#$conf["jsAction"],字串,爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
4859 |
#$conf["jsAction"]="";
|
|
|
4860 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
4861 |
#$conf["trStart"]="";
|
|
|
4862 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
4863 |
#$conf["tdStart"]="";
|
|
|
4864 |
#$conf["formStart"],字串,爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
4865 |
#$conf["formStart"]="";
|
|
|
4866 |
#$conf["formAction"],字串,表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
4867 |
#$conf["formAction"]="";
|
|
|
4868 |
#$conf["formName"],字串,爲該表單的名稱
|
|
|
4869 |
#$conf["formName"]="";
|
|
|
4870 |
#$conf["formMethod"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
4871 |
#$conf["formMethod"]="";
|
|
|
4872 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
4873 |
#$conf["formTarget"]="";
|
|
|
4874 |
#$conf["tableStart"],字串,爲該表單是否要以<table>開始。"true"爲是,預設為"false".
|
|
|
4875 |
#$conf["tableStart"]="";
|
|
|
4876 |
#$conf["tableClass"],字串,表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder".
|
|
|
4877 |
#$conf["tableClass"]="";
|
|
|
4878 |
#$conf["formEnd"],字串,爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
4879 |
#$conf["formEnd"]="true";
|
|
|
4880 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
4881 |
#$conf["tdEnd"]="true";
|
|
|
4882 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
4883 |
#$conf["trEnd"]="true";
|
|
|
4884 |
#$conf["tableEnd"],字串,爲該表單是否要以</table>結尾,"true"爲是,預設為"false".
|
|
|
4885 |
#$conf["tableEnd"]="true";
|
|
|
4886 |
#$conf["autocomplete"],字串,是否依據使用者過往輸入的記錄來提示可能要的輸入內容,"on"為啟用,"off"為停用,預設為"on".
|
|
|
4887 |
#$conf["autocomplete"]="off";
|
|
|
4888 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
4889 |
#$conf["required"]="true";
|
|
|
4890 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
4891 |
#$conf["comment"]="";
|
|
|
4892 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
4893 |
#$conf["placeholder"]="";
|
|
|
4894 |
#$conf["br"],字串,"true"代表最後要換行,預設為"false".
|
|
|
4895 |
#$conf["br"]="true";
|
|
|
4896 |
#$conf["p"],字串,"true"代表最後要空一行,預設為"false".
|
|
|
4897 |
#$conf["p"]="true";
|
|
|
4898 |
#$conf["id"],字串,該元素的id,預設不使用.
|
|
|
4899 |
#$conf["id"]="";
|
|
|
4900 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
4901 |
#$conf["dataFormId"]="";
|
|
|
4902 |
#參考資料:
|
|
|
4903 |
#https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/email
|
|
|
4904 |
#備註:
|
|
|
4905 |
#無.
|
|
|
4906 |
*/
|
|
|
4907 |
public static function inputEmail(&$conf){
|
| 226 |
liveuser |
4908 |
|
| 30 |
liveuser |
4909 |
#初始化要回傳的內容
|
|
|
4910 |
$result=array();
|
|
|
4911 |
|
|
|
4912 |
#設置當前執行的函數
|
|
|
4913 |
$result["function"]=__FUNCTION__;
|
|
|
4914 |
|
|
|
4915 |
#初始化content樣式內容
|
|
|
4916 |
$result["content"]="";
|
|
|
4917 |
|
|
|
4918 |
#如果 $conf 不為陣列
|
|
|
4919 |
if(gettype($conf)!="array"){
|
|
|
4920 |
|
|
|
4921 |
#設置執行失敗
|
|
|
4922 |
$result["status"]="false";
|
|
|
4923 |
|
|
|
4924 |
#設置執行錯誤訊息
|
|
|
4925 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
4926 |
|
|
|
4927 |
#如果傳入的參數為 null
|
|
|
4928 |
if($conf==null){
|
|
|
4929 |
|
|
|
4930 |
#設置執行錯誤訊息
|
|
|
4931 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
4932 |
|
|
|
4933 |
}#if end
|
|
|
4934 |
|
|
|
4935 |
#回傳結果
|
|
|
4936 |
return $result;
|
|
|
4937 |
|
|
|
4938 |
}#if end
|
|
|
4939 |
|
|
|
4940 |
#函式說明:
|
|
|
4941 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
4942 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
4943 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
4944 |
#$result["function"],當前執行的函式名稱.
|
|
|
4945 |
#$result["argu"],設置給予的參數.
|
|
|
4946 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
4947 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
4948 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
4949 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
4950 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
4951 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
4952 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
4953 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
4954 |
#必填寫的參數:
|
|
|
4955 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
4956 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
4957 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
4958 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
4959 |
#可以省略的參數:
|
|
|
4960 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
4961 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name","readOnly");
|
|
|
4962 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
4963 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
4964 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
4965 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
4966 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
4967 |
#$conf["canNotBeEmpty"]=array();
|
|
|
4968 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
4969 |
#$conf["canBeEmpty"]=array();
|
|
|
4970 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
4971 |
#$conf["skipableVariableCanNotBeEmpty"]=array();
|
|
|
4972 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
4973 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("width","maxInputLength","autoFocus","value","class","jsActivitor","jsAction","trStart","tdStart","formStart","formAction","formName","formMethod","formTarget","tableStart","tableClass","formEnd","tdEnd","trEnd","tableEnd","autocomplete","comment","placeholder","br","p","required","id","dataFormId","classList");
|
|
|
4974 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
4975 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","array");
|
|
|
4976 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
4977 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"__qbpwcf_inputTextCssStyle",null,null,"false","false","false",null,null,"post","_self","false","__withoutBorder","false","false","false","false","on",null,null,"false","false","false",null,null,null);
|
|
|
4978 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
4979 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
4980 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
4981 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
4982 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
4983 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
4984 |
#參考資料:
|
|
|
4985 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
4986 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
4987 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
4988 |
|
|
|
4989 |
#如果檢查失敗
|
|
|
4990 |
if($checkArguments["status"]=="false"){
|
|
|
4991 |
|
|
|
4992 |
#設置執行不正常
|
|
|
4993 |
$result["status"]="false";
|
|
|
4994 |
|
|
|
4995 |
#程式停止執行
|
|
|
4996 |
$result["error"]=$checkArguments;
|
|
|
4997 |
|
|
|
4998 |
#回傳結果
|
|
|
4999 |
return $result;
|
|
|
5000 |
|
|
|
5001 |
}#if end
|
|
|
5002 |
|
|
|
5003 |
#如果檢查不通過
|
|
|
5004 |
if($checkArguments["passed"]=="false"){
|
|
|
5005 |
|
|
|
5006 |
#設置執行不正常
|
|
|
5007 |
$result["status"]="false";
|
|
|
5008 |
|
|
|
5009 |
#程式停止執行
|
|
|
5010 |
$result["error"]=$checkArguments;
|
|
|
5011 |
|
|
|
5012 |
#回傳結果
|
|
|
5013 |
return $result;
|
|
|
5014 |
|
|
|
5015 |
}#if end
|
|
|
5016 |
|
|
|
5017 |
#如果 $conf["tableStart"] 為 "true"
|
|
|
5018 |
if($conf["tableStart"]=="true"){
|
|
|
5019 |
|
|
|
5020 |
#函式說明:
|
|
|
5021 |
#表格開始,可以設定表格的厚度和位置
|
|
|
5022 |
#回傳結果:
|
|
|
5023 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5024 |
#$result["content"],表格開始的語法
|
|
|
5025 |
#$result["function"],當前執行的函數
|
|
|
5026 |
#$result["error"],函式錯誤訊息
|
|
|
5027 |
#必填寫的參數:
|
|
|
5028 |
$conf["table::start"]["class"]=$conf["tableClass"];#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
5029 |
$tableStart=table::start($conf["table::start"]);
|
|
|
5030 |
unset($conf["table::start"]);
|
|
|
5031 |
|
|
|
5032 |
#如果表開始立失敗
|
|
|
5033 |
if($tableStart["status"]=="false"){
|
|
|
5034 |
|
|
|
5035 |
#設置執行失敗
|
|
|
5036 |
$result["status"]="false";
|
|
|
5037 |
|
|
|
5038 |
#設置執行錯誤訊息
|
|
|
5039 |
$result["error"]=$tableStart;
|
|
|
5040 |
|
|
|
5041 |
#回傳結果
|
|
|
5042 |
return $result;
|
|
|
5043 |
|
|
|
5044 |
}#if end
|
|
|
5045 |
|
|
|
5046 |
#串接表格開始的語法
|
|
|
5047 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
5048 |
|
|
|
5049 |
}#if end
|
|
|
5050 |
|
|
|
5051 |
#如果 $conf["comment"] 有設置
|
|
|
5052 |
if(isset($conf["comment"])){
|
|
|
5053 |
|
|
|
5054 |
#新增label,且套用css樣式.
|
|
|
5055 |
$result["content"]=$result["content"]."<label for=\"".$conf["name"]."\" class=\"".$conf["class"]."\" >".$conf["comment"]."</label>";
|
|
|
5056 |
|
|
|
5057 |
}#if end
|
|
|
5058 |
|
|
|
5059 |
#如果其值爲 true
|
|
|
5060 |
if($conf["trStart"]=="true"){
|
|
|
5061 |
|
|
|
5062 |
#串接列開始<tr>
|
|
|
5063 |
$result["content"]=$result["content"]."<tr>";
|
|
|
5064 |
|
|
|
5065 |
}#if end
|
|
|
5066 |
|
|
|
5067 |
#如果其值爲 true
|
|
|
5068 |
if($conf["tdStart"]=="true"){
|
|
|
5069 |
|
|
|
5070 |
#串接欄位開始<td>
|
|
|
5071 |
$result["content"]=$result["content"]."<td>";
|
|
|
5072 |
|
|
|
5073 |
}#if end
|
|
|
5074 |
|
|
|
5075 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
5076 |
if($conf["formStart"]=="true"){
|
|
|
5077 |
|
|
|
5078 |
#函式說明:
|
|
|
5079 |
#表單開始
|
|
|
5080 |
#回傳結果:
|
|
|
5081 |
#$result,表單開始的語法
|
|
|
5082 |
#必填參數:
|
|
|
5083 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
5084 |
#可省略參數:
|
|
|
5085 |
|
|
|
5086 |
#如果 $conf["formName"] 有設置
|
|
|
5087 |
if(isset($conf["formName"])){
|
|
|
5088 |
|
|
|
5089 |
#過濾 $conf["formName"] 避免錯誤
|
|
|
5090 |
#函式說明:
|
|
|
5091 |
#處理字串避免網頁出錯
|
|
|
5092 |
#回傳結果:
|
|
|
5093 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5094 |
#$result["function"],當前執行的函數.
|
|
|
5095 |
#$result["content"],爲處理好的字串.
|
|
|
5096 |
#$result["error"],錯誤訊息陣列.
|
|
|
5097 |
#必填參數:
|
|
|
5098 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
5099 |
#可省略的參數:
|
|
|
5100 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
5101 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
5102 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
5103 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
5104 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
5105 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
5106 |
|
|
|
5107 |
#如果過濾 $conf["formName"] 失敗
|
|
|
5108 |
if($correctCharacter["status"]=="false"){
|
|
|
5109 |
|
|
|
5110 |
#設置執行失敗
|
|
|
5111 |
$result["status"]="false";
|
|
|
5112 |
|
|
|
5113 |
#設置執行錯誤訊息
|
|
|
5114 |
$result["error"]=$correctCharacter;
|
|
|
5115 |
|
|
|
5116 |
#回傳結果
|
|
|
5117 |
return $result;
|
|
|
5118 |
|
|
|
5119 |
}#if end
|
|
|
5120 |
|
|
|
5121 |
#則設定其數值
|
|
|
5122 |
$conf["form"]["start"]["name"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
5123 |
|
|
|
5124 |
}#if end
|
|
|
5125 |
|
|
|
5126 |
#如果 $conf["formMethod"] 有設置
|
|
|
5127 |
if(isset($conf["formMethod"])){
|
|
|
5128 |
|
|
|
5129 |
#則設定其數值
|
|
|
5130 |
$conf["form"]["start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
5131 |
|
|
|
5132 |
}#if end
|
|
|
5133 |
|
|
|
5134 |
#如果 $conf["formTarget"] 有設定
|
|
|
5135 |
if(isset($conf["formTarget"])){
|
|
|
5136 |
|
|
|
5137 |
#則設定其數值
|
|
|
5138 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
5139 |
|
|
|
5140 |
}#if end
|
|
|
5141 |
|
|
|
5142 |
#則設定其參數數值
|
|
|
5143 |
$conf["form"]["start"]["tableStart"]="false";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
5144 |
|
|
|
5145 |
#則設定其數值
|
|
|
5146 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
5147 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
5148 |
unset($conf["form"]["start"]);
|
|
|
5149 |
|
|
|
5150 |
#如果表單開始失敗
|
|
|
5151 |
if($formStart["status"]=="false"){
|
|
|
5152 |
|
|
|
5153 |
#設置執行失敗
|
|
|
5154 |
$result["status"]="false";
|
|
|
5155 |
|
|
|
5156 |
#設置執行錯誤訊息
|
|
|
5157 |
$result["error"]=$formStart;
|
|
|
5158 |
|
|
|
5159 |
#回傳結果
|
|
|
5160 |
return $result;
|
|
|
5161 |
|
|
|
5162 |
}#if end
|
|
|
5163 |
|
|
|
5164 |
#串接表單開始的語法
|
|
|
5165 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
5166 |
|
|
|
5167 |
}#if end
|
|
|
5168 |
|
|
|
5169 |
#如果$conf["width"]沒設定
|
|
|
5170 |
if(!isset($conf["width"])){
|
|
|
5171 |
|
|
|
5172 |
#則$conf["width"]爲空值
|
|
|
5173 |
$conf["width"]="";
|
|
|
5174 |
|
|
|
5175 |
}#if end
|
|
|
5176 |
|
|
|
5177 |
#如果$conf["width"]有設定
|
|
|
5178 |
else{
|
|
|
5179 |
|
|
|
5180 |
#則套用寬度的css設定值
|
|
|
5181 |
$conf["width"]=" style=\"width:".$conf["width"].";\" ";
|
|
|
5182 |
|
|
|
5183 |
}#else end
|
|
|
5184 |
|
|
|
5185 |
#如果$conf["maxInputLength"]沒設定
|
|
|
5186 |
if(!isset($conf["maxInputLength"])){
|
|
|
5187 |
|
|
|
5188 |
#則$conf["maxInputLength"]爲空值
|
|
|
5189 |
$conf["maxInputLength"]="";
|
|
|
5190 |
|
|
|
5191 |
}#if end
|
|
|
5192 |
|
|
|
5193 |
#如果$conf["maxInputLength"]有設定
|
|
|
5194 |
else{
|
|
|
5195 |
|
|
|
5196 |
$conf["maxInputLength"]=" maxlength=".$conf["maxInputLength"];
|
|
|
5197 |
|
|
|
5198 |
}#else end
|
|
|
5199 |
|
|
|
5200 |
#如果$conf["value"]沒有設定
|
|
|
5201 |
if(!isset($conf["value"])){
|
|
|
5202 |
|
|
|
5203 |
#則$value就爲空值
|
|
|
5204 |
$conf["value"]="";
|
|
|
5205 |
|
|
|
5206 |
}#if end
|
|
|
5207 |
|
|
|
5208 |
#如果$conf["value"]有設定,且不為空.
|
|
|
5209 |
else if($conf["value"]!==""){
|
|
|
5210 |
|
|
|
5211 |
#過濾 $conf["value"] 的內容,避免錯誤。
|
|
|
5212 |
#函式說明:
|
|
|
5213 |
#處理字串避免網頁出錯
|
|
|
5214 |
#回傳結果:
|
|
|
5215 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5216 |
#$result["function"],當前執行的函數.
|
|
|
5217 |
#$result["content"],爲處理好的字串.
|
|
|
5218 |
#$result["error"],錯誤訊息陣列.
|
|
|
5219 |
#必填參數:
|
|
|
5220 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["value"];#爲要處理的字串
|
|
|
5221 |
#可省略的參數:
|
|
|
5222 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
5223 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
5224 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
5225 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
5226 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
5227 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
5228 |
|
|
|
5229 |
#如果過濾字串失敗
|
|
|
5230 |
if($correctCharacter["status"]=="false"){
|
|
|
5231 |
|
|
|
5232 |
#設置執行失敗
|
|
|
5233 |
$result["status"]="false";
|
|
|
5234 |
|
|
|
5235 |
#設置執行錯誤訊息
|
|
|
5236 |
$result["error"]=$correctCharacter;
|
|
|
5237 |
|
|
|
5238 |
#回傳結果
|
|
|
5239 |
return $result;
|
|
|
5240 |
|
|
|
5241 |
}#if end
|
|
|
5242 |
|
|
|
5243 |
#就設定預設的內容
|
|
|
5244 |
$conf["value"] =" value= \"".$correctCharacter["content"]."\" ";
|
|
|
5245 |
|
|
|
5246 |
}#else end
|
|
|
5247 |
|
|
|
5248 |
#如果$conf["readOnly"]爲"true"
|
|
|
5249 |
if($conf["readOnly"]=="true"){
|
|
|
5250 |
|
|
|
5251 |
#則$conf["readOnly"] 爲 readonly
|
|
|
5252 |
$conf["readOnly"]="readonly=true disabled=true";
|
|
|
5253 |
|
|
|
5254 |
}#if end
|
|
|
5255 |
|
|
|
5256 |
#反之
|
|
|
5257 |
else{
|
|
|
5258 |
|
|
|
5259 |
#$conf["readOnly"]爲空
|
|
|
5260 |
$conf["readOnly"]="";
|
|
|
5261 |
|
|
|
5262 |
}#if end
|
|
|
5263 |
|
|
|
5264 |
#判斷 $conf["autoFocus"] 的數值
|
|
|
5265 |
switch($conf["autoFocus"]){
|
|
|
5266 |
|
|
|
5267 |
#如果是 "true"
|
|
|
5268 |
case "true":
|
|
|
5269 |
|
|
|
5270 |
#設置為 "autofocus"
|
|
|
5271 |
$conf["autoFocus"]=" autofocus=true ";
|
|
|
5272 |
|
|
|
5273 |
#跳出 switch
|
|
|
5274 |
break;
|
|
|
5275 |
|
|
|
5276 |
#如果是其他內容
|
|
|
5277 |
default:
|
|
|
5278 |
|
|
|
5279 |
#則設置為 ""
|
|
|
5280 |
$conf["autoFocus"]="";
|
|
|
5281 |
|
|
|
5282 |
}#switch end
|
|
|
5283 |
|
|
|
5284 |
#如果有設置 $conf["class"]
|
|
|
5285 |
if(isset($conf["class"])){
|
|
|
5286 |
|
|
|
5287 |
#套用css設定
|
|
|
5288 |
$conf["class"]=" class = \"".$conf["class"]."\"";
|
|
|
5289 |
|
|
|
5290 |
}#if end
|
| 226 |
liveuser |
5291 |
|
| 30 |
liveuser |
5292 |
#反之
|
|
|
5293 |
else{
|
|
|
5294 |
#設置為空字串
|
|
|
5295 |
$conf["class"]="";
|
| 226 |
liveuser |
5296 |
|
| 30 |
liveuser |
5297 |
}#else end
|
| 226 |
liveuser |
5298 |
|
| 30 |
liveuser |
5299 |
#如果有 $conf["classList"]
|
|
|
5300 |
if(isset($conf["classList"])){
|
| 226 |
liveuser |
5301 |
|
| 30 |
liveuser |
5302 |
#傳接 class 開始
|
|
|
5303 |
$conf["class"]=" class = \"";
|
| 226 |
liveuser |
5304 |
|
| 30 |
liveuser |
5305 |
#針對 $conf["classList"] 的每個元素
|
|
|
5306 |
foreach($conf["classList"] as $index => $cssClassName){
|
| 226 |
liveuser |
5307 |
|
| 30 |
liveuser |
5308 |
#串接 class 名稱
|
|
|
5309 |
$conf["class"]=$conf["class"].$cssClassName;
|
| 226 |
liveuser |
5310 |
|
| 30 |
liveuser |
5311 |
#若後面還有未串接的 class 名稱
|
|
|
5312 |
if(isset($conf["classList"][$index+1])){
|
| 226 |
liveuser |
5313 |
|
| 30 |
liveuser |
5314 |
#串接空格
|
|
|
5315 |
$conf["class"]=$conf["class"]." ";
|
| 226 |
liveuser |
5316 |
|
| 30 |
liveuser |
5317 |
}#if end
|
| 226 |
liveuser |
5318 |
|
| 30 |
liveuser |
5319 |
}#foreach end
|
| 226 |
liveuser |
5320 |
|
| 30 |
liveuser |
5321 |
#串接 class 結束
|
|
|
5322 |
$conf["class"]=$conf["class"]."\"";
|
| 226 |
liveuser |
5323 |
|
| 30 |
liveuser |
5324 |
}#if end
|
|
|
5325 |
|
|
|
5326 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
5327 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
5328 |
|
|
|
5329 |
#則將設定值組合
|
|
|
5330 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
5331 |
|
|
|
5332 |
}#if end
|
|
|
5333 |
|
|
|
5334 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
5335 |
if(!isset($conf["jsCustom"])){
|
|
|
5336 |
|
|
|
5337 |
#將其設爲空值
|
|
|
5338 |
$conf["jsCustom"]="";
|
|
|
5339 |
|
|
|
5340 |
}#if end
|
|
|
5341 |
|
|
|
5342 |
#過濾 $conf["name"] 避免錯誤
|
|
|
5343 |
#函式說明:
|
|
|
5344 |
#處理字串避免網頁出錯
|
|
|
5345 |
#回傳結果:
|
|
|
5346 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5347 |
#$result["function"],當前執行的函數.
|
|
|
5348 |
#$result["content"],爲處理好的字串.
|
|
|
5349 |
#$result["error"],錯誤訊息陣列.
|
|
|
5350 |
#必填參數:
|
|
|
5351 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
5352 |
#可省略的參數:
|
|
|
5353 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
5354 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
5355 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
5356 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
5357 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
5358 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
5359 |
|
|
|
5360 |
#如果過濾字串失敗
|
|
|
5361 |
if($correctCharacter["status"]=="false"){
|
|
|
5362 |
|
|
|
5363 |
#設置執行失敗
|
|
|
5364 |
$result["status"]="false";
|
|
|
5365 |
|
|
|
5366 |
#設置執行錯誤訊息
|
|
|
5367 |
$result["error"]=$correctCharacter;
|
|
|
5368 |
|
|
|
5369 |
#回傳結果
|
|
|
5370 |
return $result;
|
|
|
5371 |
|
|
|
5372 |
}#if end
|
|
|
5373 |
|
|
|
5374 |
#置換過濾好了的$conf["name"]
|
|
|
5375 |
$conf["name"]=$correctCharacter["content"];
|
|
|
5376 |
|
|
|
5377 |
#如果有設定 $conf["placeholder"]
|
|
|
5378 |
if(isset($conf["placeholder"])){
|
|
|
5379 |
|
|
|
5380 |
#串接 placeholder 的內容
|
|
|
5381 |
$conf["placeholder"]=" placeholder=\"".$conf["placeholder"]."\" ";
|
|
|
5382 |
|
|
|
5383 |
}#if end
|
|
|
5384 |
|
|
|
5385 |
#反之沒有設定 $conf["placeholder"]
|
|
|
5386 |
else{
|
|
|
5387 |
|
|
|
5388 |
#設為 ""
|
|
|
5389 |
$conf["placeholder"]="";
|
|
|
5390 |
|
|
|
5391 |
}#else end
|
|
|
5392 |
|
|
|
5393 |
#如果 $conf["required"] 為"true"
|
|
|
5394 |
if($conf["required"]=="true"){
|
|
|
5395 |
|
|
|
5396 |
#設置 "required" 屬性
|
|
|
5397 |
$conf["required"]="required=true";
|
|
|
5398 |
|
|
|
5399 |
}#if end
|
|
|
5400 |
|
|
|
5401 |
#反之
|
|
|
5402 |
else{
|
|
|
5403 |
|
|
|
5404 |
#設為空值
|
|
|
5405 |
$conf["required"]="";
|
|
|
5406 |
|
|
|
5407 |
}#else end
|
|
|
5408 |
|
|
|
5409 |
#如果有設置id
|
|
|
5410 |
if(isset($conf["id"])){
|
|
|
5411 |
|
|
|
5412 |
#設置id屬性
|
|
|
5413 |
$conf["id"]="id=\"".$conf["id"]."\"";
|
|
|
5414 |
|
|
|
5415 |
}#if end
|
|
|
5416 |
|
|
|
5417 |
#反之
|
|
|
5418 |
else{
|
|
|
5419 |
|
|
|
5420 |
#設為空值
|
|
|
5421 |
$conf["id"]="";
|
|
|
5422 |
|
|
|
5423 |
}#else end
|
|
|
5424 |
|
|
|
5425 |
#如果有設置 $conf["dataFormId"]
|
|
|
5426 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
5427 |
|
| 30 |
liveuser |
5428 |
#設置 data-id 屬性
|
|
|
5429 |
$conf["dataFormId"]="data-form-id=\"".$conf["dataFormId"]."\"";
|
| 226 |
liveuser |
5430 |
|
| 30 |
liveuser |
5431 |
}#if end
|
| 226 |
liveuser |
5432 |
|
|
|
5433 |
#反之設置為空數值
|
| 30 |
liveuser |
5434 |
else{
|
| 226 |
liveuser |
5435 |
|
| 30 |
liveuser |
5436 |
$conf["dataFormId"]="";
|
|
|
5437 |
|
| 226 |
liveuser |
5438 |
}#else end
|
|
|
5439 |
|
| 30 |
liveuser |
5440 |
#如果要 autocomplete
|
|
|
5441 |
if($conf["autocomplete"]==="on"){
|
| 226 |
liveuser |
5442 |
|
| 30 |
liveuser |
5443 |
#設置為 "autocomplete"
|
|
|
5444 |
$conf["autocomplete"]="autocomplete";
|
| 226 |
liveuser |
5445 |
|
| 30 |
liveuser |
5446 |
}#if end
|
| 226 |
liveuser |
5447 |
|
| 30 |
liveuser |
5448 |
#反之
|
|
|
5449 |
else{
|
|
|
5450 |
#設置為空字串
|
|
|
5451 |
$conf["autocomplete"]="";
|
| 226 |
liveuser |
5452 |
|
| 30 |
liveuser |
5453 |
}#else end
|
|
|
5454 |
|
|
|
5455 |
#放置可以輸入email的表單
|
|
|
5456 |
$result["content"]=$result["content"]."<input ".$conf["id"]." type = \"email\" ".$conf["width"]." ".$conf["maxInputLength"]." name = ".$conf["name"]." id = ".$conf["name"]." ".$conf["value"]." ".$conf["readOnly"]." ".$conf["autoFocus"]." ".$conf["class"]." ".$conf["jsCustom"]." ".$conf["placeholder"]." ".$conf["autocomplete"]." ".$conf["required"]." ".$conf["dataFormId"]." >";
|
|
|
5457 |
|
|
|
5458 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
5459 |
if($conf["formEnd"]=="true"){
|
|
|
5460 |
|
|
|
5461 |
#函式說明:
|
|
|
5462 |
#表單結束
|
|
|
5463 |
#回傳結果:
|
|
|
5464 |
#$result,表單結束的語法
|
|
|
5465 |
#必填參數:
|
|
|
5466 |
#則設定其數值
|
|
|
5467 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
5468 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
5469 |
unset($conf["form"]["end"]);
|
|
|
5470 |
|
|
|
5471 |
#串接表單結束的語法
|
|
|
5472 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
5473 |
|
|
|
5474 |
}#if end
|
|
|
5475 |
|
|
|
5476 |
#如果其值爲 true
|
|
|
5477 |
if($conf["tdEnd"]=="true"){
|
|
|
5478 |
|
|
|
5479 |
#串接欄位結束的語法
|
|
|
5480 |
$result["content"]=$result["content"]."</td>";
|
|
|
5481 |
|
|
|
5482 |
}#if end
|
|
|
5483 |
|
|
|
5484 |
#如果其值爲 true
|
|
|
5485 |
if($conf["trEnd"]=="true"){
|
|
|
5486 |
|
|
|
5487 |
#串接列結束的語法
|
|
|
5488 |
$result["content"]=$result["content"]."</tr>";
|
|
|
5489 |
|
|
|
5490 |
}#if end
|
|
|
5491 |
|
|
|
5492 |
#如果 $conf["br"] 等於 "true"
|
|
|
5493 |
if($conf["br"]=="true"){
|
|
|
5494 |
|
|
|
5495 |
#結尾加上<br>
|
|
|
5496 |
$result["content"]=$result["content"]."<br>";
|
|
|
5497 |
|
|
|
5498 |
}#if end
|
|
|
5499 |
|
|
|
5500 |
#如果 $conf["p"] 等於 "true"
|
|
|
5501 |
if($conf["p"]=="true"){
|
|
|
5502 |
|
|
|
5503 |
#結尾加上<p>
|
|
|
5504 |
$result["content"]=$result["content"]."<p>";
|
|
|
5505 |
|
|
|
5506 |
}#if end
|
|
|
5507 |
|
|
|
5508 |
#執行到這邊代表執行成功
|
|
|
5509 |
$result["status"]="true";
|
|
|
5510 |
|
|
|
5511 |
#回傳結果
|
|
|
5512 |
return $result;
|
| 226 |
liveuser |
5513 |
|
| 30 |
liveuser |
5514 |
}#function inputEmail end
|
| 226 |
liveuser |
5515 |
|
| 30 |
liveuser |
5516 |
/*
|
|
|
5517 |
#函式說明:
|
| 3 |
liveuser |
5518 |
#可以輸入文字的區塊
|
|
|
5519 |
#回傳結果:
|
|
|
5520 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5521 |
#$result["function"],當前執行的函數.
|
|
|
5522 |
#$result["error"],錯誤訊息陣列.
|
|
|
5523 |
#$result["content"],按鈕語法.
|
|
|
5524 |
#必填參數:
|
|
|
5525 |
$conf["name"]="";#爲文字輸入框的名稱,供接收端辨識用。
|
|
|
5526 |
$conf["readOnly"]="false";#爲是否要爲唯讀,如果爲"true",則爲唯讀。反之則爲"false"。
|
|
|
5527 |
#可省略參數:
|
|
|
5528 |
#$conf["id"],字串,文字區塊的id,供javaScript呼叫用.
|
|
|
5529 |
#$conf["id"]="";
|
|
|
5530 |
#$conf["width"]="";#為輸入框的寬度,預設不指定.
|
|
|
5531 |
#$conf["cols"]="";#爲文字輸入框的欄位數(寬),預設爲按照瀏覽器設定值。
|
|
|
5532 |
#$conf["rows"]="";#爲文字輸入框的列數(高),預設爲按照瀏覽器設定值。
|
|
|
5533 |
#$conf["maxInputLength"]="";#爲文字輸入的長度限制,預設無限制。
|
|
|
5534 |
#$conf["defaultText"]="";#爲文字輸入框裏面的預設文字內容,預設是空的。
|
|
|
5535 |
#$conf["class"]=;#爲要套用的css樣式。如果沒有指定 ,則採用預設的css樣式,"__qbpwcf_inputTextAreaCssStyle",其屬性爲 "width:100%","height:120px","font-size:30px"
|
|
|
5536 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
5537 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
5538 |
#$conf["formStart"]="true";#爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
5539 |
#$conf["formAction"]="";#表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
5540 |
#$conf["formName"]="";#爲該表單的名稱
|
|
|
5541 |
#$conf["formMethod"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
5542 |
#$conf["formTarget"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
5543 |
#$conf["formEnd"]="true";#爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
5544 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
5545 |
#$conf["comment"]="";
|
|
|
5546 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
5547 |
#$conf["required"]="true";
|
|
|
5548 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
5549 |
#$conf["placeholder"]="";
|
|
|
5550 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
5551 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
5552 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
5553 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
5554 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
5555 |
#$conf["dataFormId"]="";
|
|
|
5556 |
#參考資料:
|
|
|
5557 |
#input=>http://www.w3schools.com/tags/tag_input.asp
|
|
|
5558 |
#備註:
|
|
|
5559 |
#無.
|
|
|
5560 |
*/
|
|
|
5561 |
public static function inputTextArea(&$conf){
|
|
|
5562 |
|
|
|
5563 |
#初始化要回傳的內容
|
|
|
5564 |
$result=array();
|
|
|
5565 |
|
|
|
5566 |
#設置當前執行的函數
|
|
|
5567 |
$result["function"]=__FUNCTION__;
|
|
|
5568 |
|
|
|
5569 |
#初始化content樣式內容
|
|
|
5570 |
$result["content"]="";
|
|
|
5571 |
|
|
|
5572 |
#如果 $conf 不為陣列
|
|
|
5573 |
if(gettype($conf)!="array"){
|
|
|
5574 |
|
|
|
5575 |
#設置執行失敗
|
|
|
5576 |
$result["status"]="false";
|
|
|
5577 |
|
|
|
5578 |
#設置執行錯誤訊息
|
|
|
5579 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
5580 |
|
|
|
5581 |
#如果傳入的參數為 null
|
|
|
5582 |
if($conf==null){
|
|
|
5583 |
|
|
|
5584 |
#設置執行錯誤訊息
|
|
|
5585 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
5586 |
|
|
|
5587 |
}#if end
|
|
|
5588 |
|
|
|
5589 |
#回傳結果
|
|
|
5590 |
return $result;
|
|
|
5591 |
|
|
|
5592 |
}#if end
|
|
|
5593 |
|
|
|
5594 |
#檢查參數
|
|
|
5595 |
#函式說明:
|
|
|
5596 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
5597 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5598 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
5599 |
#$result["function"],當前執行的函式名稱.
|
|
|
5600 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
5601 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
5602 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
5603 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
5604 |
#必填參數:
|
|
|
5605 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
5606 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
5607 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
5608 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("name","readOnly");
|
|
|
5609 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
5610 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
5611 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
5612 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
5613 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
5614 |
$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
5615 |
#可省略參數:
|
|
|
5616 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
5617 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
5618 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
5619 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("id","width","cols","rows","maxInputLength","defaultText","class","jsActivitor","jsAction","comment","trStart","tdStart","tdEnd","trEnd","placeholder","required","formStart","formAction","formName","formMethod","formTarget","formEnd","dataFormId");
|
|
|
5620 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
5621 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
5622 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
5623 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,null,null,"","__qbpwcf_inputTextAreaCssStyle",null,null,null,"false","false","false","false",null,"false","false","false","false","false","false","false",null);
|
|
|
5624 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
5625 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
5626 |
|
|
|
5627 |
#如果檢查失敗
|
|
|
5628 |
if($checkResult["status"]=="false"){
|
|
|
5629 |
|
|
|
5630 |
#設置執行不正常
|
|
|
5631 |
$result["status"]="false";
|
|
|
5632 |
|
|
|
5633 |
#程式停止執行
|
|
|
5634 |
$result["error"]=$checkResult;
|
|
|
5635 |
|
|
|
5636 |
#回傳結果
|
|
|
5637 |
return $result;
|
|
|
5638 |
|
|
|
5639 |
}#if end
|
|
|
5640 |
|
|
|
5641 |
#如果檢查不通過
|
|
|
5642 |
if($checkResult["passed"]=="false"){
|
|
|
5643 |
|
|
|
5644 |
#設置執行不正常
|
|
|
5645 |
$result["status"]="false";
|
|
|
5646 |
|
|
|
5647 |
#程式停止執行
|
|
|
5648 |
$result["error"]=$checkResult;
|
|
|
5649 |
|
|
|
5650 |
#回傳結果
|
|
|
5651 |
return $result;
|
|
|
5652 |
|
|
|
5653 |
}#if end
|
|
|
5654 |
|
|
|
5655 |
#如果其值爲 true
|
|
|
5656 |
if($conf["trStart"]=="true"){
|
|
|
5657 |
|
|
|
5658 |
#串接列開始
|
|
|
5659 |
$result["content"]=$result["content"]."<tr>";
|
|
|
5660 |
|
|
|
5661 |
}#if end
|
|
|
5662 |
|
|
|
5663 |
#如果其值爲 true
|
|
|
5664 |
if($conf["tdStart"]=="true"){
|
|
|
5665 |
|
|
|
5666 |
#串接欄開始
|
|
|
5667 |
$result["content"]=$result["content"]."<td>";
|
|
|
5668 |
|
|
|
5669 |
}#if end
|
|
|
5670 |
|
|
|
5671 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
5672 |
if($conf["formStart"]=="true"){
|
|
|
5673 |
|
|
|
5674 |
#函式說明:
|
|
|
5675 |
#表單開始
|
|
|
5676 |
#回傳結果:
|
|
|
5677 |
#$result,表單開始的語法
|
|
|
5678 |
#必填參數:
|
|
|
5679 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
5680 |
#可省略參數:
|
|
|
5681 |
|
|
|
5682 |
#如果 $conf["formName"] 有設置
|
|
|
5683 |
if(isset($conf["formName"])){
|
|
|
5684 |
|
|
|
5685 |
#過濾 $conf["formName"] 避免錯誤
|
|
|
5686 |
#函式說明:
|
|
|
5687 |
#處理字串避免網頁出錯
|
|
|
5688 |
#回傳結果:
|
|
|
5689 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5690 |
#$result["function"],當前執行的函數.
|
|
|
5691 |
#$result["content"],爲處理好的字串.
|
|
|
5692 |
#$result["error"],錯誤訊息陣列.
|
|
|
5693 |
#必填參數:
|
|
|
5694 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
5695 |
#可省略的參數:
|
|
|
5696 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
5697 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
5698 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
5699 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
5700 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
5701 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
5702 |
|
|
|
5703 |
#如果過濾 $conf["formName"] 失敗
|
|
|
5704 |
if($correctCharacter["status"]=="false"){
|
|
|
5705 |
|
|
|
5706 |
#設置執行失敗
|
|
|
5707 |
$result["status"]="false";
|
|
|
5708 |
|
|
|
5709 |
#設置執行錯誤訊息
|
|
|
5710 |
$result["error"]=$correctCharacter;
|
|
|
5711 |
|
|
|
5712 |
#回傳結果
|
|
|
5713 |
return $result;
|
|
|
5714 |
|
|
|
5715 |
}#if end
|
|
|
5716 |
|
|
|
5717 |
#則設定其數值
|
|
|
5718 |
$conf["form"]["start"]["name"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
5719 |
|
|
|
5720 |
}#if end
|
|
|
5721 |
|
|
|
5722 |
#如果 $conf["formMethod"] 有設置
|
|
|
5723 |
if(isset($conf["formMethod"])){
|
|
|
5724 |
|
|
|
5725 |
#則設定其數值
|
|
|
5726 |
$conf["form"]["start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
5727 |
|
|
|
5728 |
}#if end
|
|
|
5729 |
|
|
|
5730 |
#如果 $conf["formTarget"] 有設定
|
|
|
5731 |
if(isset($conf["formTarget"])){
|
|
|
5732 |
|
|
|
5733 |
#則設定其數值
|
|
|
5734 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
5735 |
|
|
|
5736 |
}#if end
|
|
|
5737 |
|
|
|
5738 |
#則設定其參數數值
|
|
|
5739 |
$conf["form"]["start"]["tableStart"]="false";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
5740 |
|
|
|
5741 |
#則設定其數值
|
|
|
5742 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
5743 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
5744 |
unset($conf["form"]["start"]);
|
|
|
5745 |
|
|
|
5746 |
#如果表單開始失敗
|
|
|
5747 |
if($formStart["status"]=="false"){
|
|
|
5748 |
|
|
|
5749 |
#設置執行失敗
|
|
|
5750 |
$result["status"]="false";
|
|
|
5751 |
|
|
|
5752 |
#設置執行錯誤訊息
|
|
|
5753 |
$result["error"]=$formStart;
|
|
|
5754 |
|
|
|
5755 |
#回傳結果
|
|
|
5756 |
return $result;
|
|
|
5757 |
|
|
|
5758 |
}#if end
|
|
|
5759 |
|
|
|
5760 |
#串接表單開始的語法
|
|
|
5761 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
5762 |
|
|
|
5763 |
}#if end
|
|
|
5764 |
|
|
|
5765 |
#如果$conf["readOnly"]沒有設定
|
|
|
5766 |
if($conf["readOnly"]=="false"){
|
|
|
5767 |
|
|
|
5768 |
#$conf["readOnly"]就爲空值
|
|
|
5769 |
$conf["readOnly"]="";
|
|
|
5770 |
|
|
|
5771 |
}#if end
|
|
|
5772 |
|
|
|
5773 |
#如果$conf["readOnly"]有設定
|
|
|
5774 |
if($conf["readOnly"]=="true"){
|
|
|
5775 |
|
|
|
5776 |
#就設置 readonly 屬性
|
|
|
5777 |
$conf["readOnly"]=" readonly = readonly ";
|
|
|
5778 |
|
|
|
5779 |
}#if end
|
|
|
5780 |
|
|
|
5781 |
#如果$conf["cols"]沒設定
|
|
|
5782 |
if(!isset($conf["cols"])){
|
|
|
5783 |
|
|
|
5784 |
#則$conf["cols"]爲空
|
|
|
5785 |
$conf["cols"]="";
|
|
|
5786 |
|
|
|
5787 |
}#if end
|
|
|
5788 |
|
|
|
5789 |
#如果$conf["cols"]有設定
|
|
|
5790 |
else{
|
|
|
5791 |
|
|
|
5792 |
#則套用設定值
|
|
|
5793 |
$conf["cols"]=" cols=".$conf["cols"];
|
|
|
5794 |
|
|
|
5795 |
}#else end
|
|
|
5796 |
|
|
|
5797 |
#如果$conf["rows"]沒設定
|
|
|
5798 |
if(!isset($conf["rows"])){
|
|
|
5799 |
|
|
|
5800 |
#則$conf["rows"]爲空
|
|
|
5801 |
$conf["rows"]="";
|
|
|
5802 |
|
|
|
5803 |
}#if end
|
|
|
5804 |
|
|
|
5805 |
#如果$conf["rows"]有設定
|
|
|
5806 |
else{
|
|
|
5807 |
|
|
|
5808 |
#就套用設定值
|
|
|
5809 |
$conf["rows"]=" rows=".$conf["rows"];
|
|
|
5810 |
|
|
|
5811 |
}#else end
|
|
|
5812 |
|
|
|
5813 |
#如果$conf["width"]沒設定
|
|
|
5814 |
if(!isset($conf["width"])){
|
|
|
5815 |
|
|
|
5816 |
#則$conf["width"]爲空值
|
|
|
5817 |
$conf["width"]="";
|
|
|
5818 |
|
|
|
5819 |
}#if end
|
|
|
5820 |
|
|
|
5821 |
#如果$conf["width"]有設定
|
|
|
5822 |
else{
|
|
|
5823 |
|
|
|
5824 |
#則套用寬度的css設定值
|
|
|
5825 |
$conf["width"]=" style=\"width:100%;\" ";
|
|
|
5826 |
|
|
|
5827 |
}#else end
|
|
|
5828 |
|
|
|
5829 |
#如果$conf["maxInputLength"]沒設定
|
|
|
5830 |
if(!isset($conf["maxInputLength"])){
|
|
|
5831 |
|
|
|
5832 |
#則$conf["maxInputLength"]爲空
|
|
|
5833 |
$conf["maxInputLength"]="";
|
|
|
5834 |
|
|
|
5835 |
}#if end
|
|
|
5836 |
|
|
|
5837 |
#如果$conf["maxInputLength"]有設定
|
|
|
5838 |
else{
|
|
|
5839 |
|
|
|
5840 |
$conf["maxInputLength"]=" maxlength=".$conf["maxInputLength"];
|
|
|
5841 |
|
|
|
5842 |
}#else end
|
|
|
5843 |
|
|
|
5844 |
#初始化僅儲存css類別名稱的變數
|
|
|
5845 |
$className=$conf["class"];
|
|
|
5846 |
|
|
|
5847 |
#採用自定的css樣式
|
|
|
5848 |
$conf["class"] = " class=".$conf["class"];
|
|
|
5849 |
|
|
|
5850 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
5851 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
5852 |
|
|
|
5853 |
#則將設定值組合
|
|
|
5854 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
5855 |
|
|
|
5856 |
}#if end
|
|
|
5857 |
|
|
|
5858 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
5859 |
if(!isset($conf["jsCustom"])){
|
|
|
5860 |
|
|
|
5861 |
#將其設爲空值
|
|
|
5862 |
$conf["jsCustom"]="";
|
|
|
5863 |
|
|
|
5864 |
}#if end
|
|
|
5865 |
|
|
|
5866 |
#如果有設置 $conf["comment"]
|
|
|
5867 |
if(isset($conf["comment"])){
|
|
|
5868 |
|
|
|
5869 |
#函式說明:
|
|
|
5870 |
#<div>標籤的開始到結束的區段
|
|
|
5871 |
#回傳結果:
|
|
|
5872 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
5873 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
5874 |
#$result["error"],陣列,錯訊訊息.
|
|
|
5875 |
#$result["content"],字串,<div>標籤的開始與設定語法.
|
|
|
5876 |
#必填參數:
|
|
|
5877 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
5878 |
$conf["css.divSection"]["contentArray"]=array($conf["comment"]);
|
|
|
5879 |
#可省略參數
|
|
|
5880 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
5881 |
$conf["css.divSection"]["class"]=$className;
|
|
|
5882 |
$spanSection=css::spanSection($conf["css.divSection"]);
|
|
|
5883 |
unset($conf["css.divSection"]);
|
|
|
5884 |
|
|
|
5885 |
#如果 spanSection 建立失敗
|
|
|
5886 |
if($spanSection["status"]=="false"){
|
|
|
5887 |
|
|
|
5888 |
#設置執行失敗
|
|
|
5889 |
$result["status"]="false";
|
|
|
5890 |
|
|
|
5891 |
#設置執行錯誤訊息
|
|
|
5892 |
$result["error"]=$spanSection;
|
|
|
5893 |
|
|
|
5894 |
#回傳結果
|
|
|
5895 |
return $result;
|
|
|
5896 |
|
|
|
5897 |
}#if end
|
|
|
5898 |
|
|
|
5899 |
#新增label,且套用css樣式.
|
|
|
5900 |
$result["content"]=$result["content"]."<label for=\"".$conf["name"]."\" class=\"".$className."\" >".$conf["comment"]."</label>";
|
|
|
5901 |
|
|
|
5902 |
}#if end
|
|
|
5903 |
|
|
|
5904 |
#如果有設定 $conf["placeholder"]
|
|
|
5905 |
if(isset($conf["placeholder"])){
|
|
|
5906 |
|
|
|
5907 |
#設定 "placeholder" 屬性
|
|
|
5908 |
$conf["placeholder"]=" placeholder=".$conf["placeholder"]." ";
|
|
|
5909 |
|
|
|
5910 |
}#if end
|
|
|
5911 |
|
|
|
5912 |
#反之
|
|
|
5913 |
else{
|
|
|
5914 |
|
|
|
5915 |
#設為 ""
|
|
|
5916 |
$conf["placeholder"]="";
|
|
|
5917 |
|
|
|
5918 |
}#else end
|
|
|
5919 |
|
|
|
5920 |
#過濾 $conf["name"] 避免錯誤
|
|
|
5921 |
#函式說明:
|
|
|
5922 |
#處理字串避免網頁出錯
|
|
|
5923 |
#回傳結果:
|
|
|
5924 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
5925 |
#$result["function"],當前執行的函數.
|
|
|
5926 |
#$result["content"],爲處理好的字串.
|
|
|
5927 |
#$result["error"],錯誤訊息陣列.
|
|
|
5928 |
#必填參數:
|
|
|
5929 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
5930 |
#可省略的參數:
|
|
|
5931 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
5932 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
5933 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
5934 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
5935 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
5936 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
5937 |
|
|
|
5938 |
#如果過濾字串失敗
|
|
|
5939 |
if($correctCharacter["status"]=="false"){
|
|
|
5940 |
|
|
|
5941 |
#設置執行失敗
|
|
|
5942 |
$result["status"]="false";
|
|
|
5943 |
|
|
|
5944 |
#設置執行錯誤訊息
|
|
|
5945 |
$result["error"]=$correctCharacter;
|
|
|
5946 |
|
|
|
5947 |
#回傳結果
|
|
|
5948 |
return $result;
|
|
|
5949 |
|
|
|
5950 |
}#if end
|
|
|
5951 |
|
|
|
5952 |
#置換過濾好了的$conf["name"]
|
|
|
5953 |
$conf["name"]=$correctCharacter["content"];
|
|
|
5954 |
|
|
|
5955 |
#如果 $conf["required"] 為 "true"
|
|
|
5956 |
if($conf["required"]=="true"){
|
|
|
5957 |
|
|
|
5958 |
#設置 "required" 屬性
|
|
|
5959 |
$conf["required"]=" required=true ";
|
|
|
5960 |
|
|
|
5961 |
}#if end
|
|
|
5962 |
|
|
|
5963 |
#反之
|
|
|
5964 |
else{
|
|
|
5965 |
|
|
|
5966 |
#設置為空值
|
|
|
5967 |
$conf["required"]="";
|
|
|
5968 |
|
|
|
5969 |
}#else end
|
|
|
5970 |
|
|
|
5971 |
#如果有設置 $conf["id"]
|
|
|
5972 |
if(isset($conf["id"])){
|
|
|
5973 |
|
|
|
5974 |
#產生id字串
|
|
|
5975 |
$conf["id"]="id=\"".$conf["id"]."\"";
|
|
|
5976 |
|
|
|
5977 |
}#if end
|
|
|
5978 |
|
|
|
5979 |
#反之
|
|
|
5980 |
else{
|
|
|
5981 |
|
|
|
5982 |
#設為空字串
|
|
|
5983 |
$conf["id"]="";
|
|
|
5984 |
|
|
|
5985 |
}#else end
|
|
|
5986 |
|
|
|
5987 |
#如果有設置 $conf["dataFormId"]
|
|
|
5988 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
5989 |
|
| 3 |
liveuser |
5990 |
#設置 data-id 屬性
|
|
|
5991 |
$conf["dataFormId"]="data-form-id=\"".$conf["dataFormId"]."\"";
|
| 226 |
liveuser |
5992 |
|
| 3 |
liveuser |
5993 |
}#if end
|
| 226 |
liveuser |
5994 |
|
|
|
5995 |
#反之設置為空數值
|
| 3 |
liveuser |
5996 |
else{
|
| 226 |
liveuser |
5997 |
|
| 3 |
liveuser |
5998 |
$conf["dataFormId"]="";
|
| 226 |
liveuser |
5999 |
|
| 3 |
liveuser |
6000 |
}#else end
|
|
|
6001 |
|
|
|
6002 |
#放置可以文字的區塊
|
|
|
6003 |
$result["content"]=$result["content"]."<textarea ".$conf["width"]." ".$conf["cols"]." ".$conf["rows"]." ".$conf["maxInputLength"]." name=".$conf["name"]." ".$conf["readOnly"]." ".$conf["class"]." ".$conf["jsCustom"]." ".$conf["placeholder"]." ".$conf["required"]." ".$conf["id"]." ".$conf["dataFormId"]." >".$conf["defaultText"]."</textarea>";
|
|
|
6004 |
|
|
|
6005 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
6006 |
if($conf["formEnd"]=="true"){
|
|
|
6007 |
|
|
|
6008 |
#函式說明:
|
|
|
6009 |
#表單結束
|
|
|
6010 |
#回傳結果:
|
|
|
6011 |
#$result,表單結束的語法
|
|
|
6012 |
#必填參數:
|
|
|
6013 |
#則設定其數值
|
|
|
6014 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
6015 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
6016 |
unset($conf["form"]["end"]);
|
|
|
6017 |
|
|
|
6018 |
#串接表單結束的語法
|
|
|
6019 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
6020 |
|
|
|
6021 |
}#if end
|
|
|
6022 |
|
|
|
6023 |
#如果其值爲 true
|
|
|
6024 |
if($conf["tdEnd"]=="true"){
|
|
|
6025 |
|
|
|
6026 |
#串接欄結束
|
|
|
6027 |
$result["content"]=$result["content"]."</td>";
|
|
|
6028 |
|
|
|
6029 |
}#if end
|
|
|
6030 |
|
|
|
6031 |
#如果其值爲 true
|
|
|
6032 |
if($conf["trEnd"]=="true"){
|
|
|
6033 |
|
|
|
6034 |
#串接列結束
|
|
|
6035 |
$result["content"]=$result["content"]."</tr>";
|
|
|
6036 |
|
|
|
6037 |
}#if end
|
|
|
6038 |
|
|
|
6039 |
#設置執行正常
|
|
|
6040 |
$result["status"]="true";
|
|
|
6041 |
|
|
|
6042 |
#印出表格的設定以及表單的目的、呈現的方式、傳送的方式。
|
|
|
6043 |
return $result;
|
|
|
6044 |
|
|
|
6045 |
}#function inputTextArea end
|
|
|
6046 |
|
|
|
6047 |
/*
|
|
|
6048 |
#函式說明:
|
|
|
6049 |
#可以輸入密碼的表單
|
|
|
6050 |
#回傳結果:
|
|
|
6051 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6052 |
#$result["function"],當前執行的函數.
|
|
|
6053 |
#$result["error"],錯誤訊息陣列.
|
|
|
6054 |
#$result["content"],按鈕語法.
|
|
|
6055 |
#必填參數:
|
|
|
6056 |
$conf["name"]="";#爲密碼輸入框的名稱,供接收端進行處理時的獨立名稱,也提供id.
|
|
|
6057 |
#可省略參數:
|
|
|
6058 |
#$conf["width"]="";#爲密碼輸入框的長度,預設無限制。
|
|
|
6059 |
#$conf["maxInputLength"]="";#爲密碼輸入的長度限制,預設無限制。
|
|
|
6060 |
#$conf["defaultValue"]="";#預設的密碼,不得為空
|
|
|
6061 |
#$conf["class"]="";#爲要套用的css樣式,若省略,則會套用預設的 __qbpwcf_inputPasswordCssStyle 樣式,其屬性爲 "width:100%","font-size:30px","margin-left:auto;","margin-right:auto;"
|
|
|
6062 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
6063 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
6064 |
#$conf["autoFocus"],字串,是否為將填寫的指標移到該表單,"true"代表要,預設為"false".
|
|
|
6065 |
#$conf["autoFocus"]="true";
|
|
|
6066 |
#$conf["autocomplete"],字串,是否依據使用者過往輸入的記錄來提示可能要的輸入內容,"on"為啟用,"off"為停用,預設為"on".
|
|
|
6067 |
#$conf["autocomplete"]="off";
|
|
|
6068 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
6069 |
#$conf["required"]="true";
|
|
|
6070 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
6071 |
#$conf["comment"]="";
|
|
|
6072 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
6073 |
#$conf["placeholder"]="";
|
|
|
6074 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
6075 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
6076 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
6077 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
6078 |
#$conf["formStart"]="true";#爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
6079 |
#$conf["formAction"]="";#表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
6080 |
#$conf["formName"]="";#爲該表單的名稱
|
|
|
6081 |
#$conf["formMethod"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
6082 |
#$conf["formTarget"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
6083 |
#$conf["formEnd"]="true";#爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
6084 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
6085 |
#$conf["dataFormId"]="";
|
|
|
6086 |
#參考資料:
|
|
|
6087 |
#無.
|
|
|
6088 |
#備註:
|
|
|
6089 |
#無.
|
|
|
6090 |
*/
|
|
|
6091 |
public static function inputPassword($conf){
|
|
|
6092 |
|
|
|
6093 |
#初始化要回傳的內容
|
|
|
6094 |
$result=array();
|
|
|
6095 |
|
|
|
6096 |
#設置當前執行的函數
|
|
|
6097 |
$result["function"]=__FUNCTION__;
|
|
|
6098 |
|
|
|
6099 |
#初始化content樣式內容
|
|
|
6100 |
$result["content"]="";
|
|
|
6101 |
|
|
|
6102 |
#如果 $conf 不為陣列
|
|
|
6103 |
if(gettype($conf)!="array"){
|
|
|
6104 |
|
|
|
6105 |
#設置執行失敗
|
|
|
6106 |
$result["status"]="false";
|
|
|
6107 |
|
|
|
6108 |
#設置執行錯誤訊息
|
|
|
6109 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
6110 |
|
|
|
6111 |
#如果傳入的參數為 null
|
|
|
6112 |
if($conf==null){
|
|
|
6113 |
|
|
|
6114 |
#設置執行錯誤訊息
|
|
|
6115 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
6116 |
|
|
|
6117 |
}#if end
|
|
|
6118 |
|
|
|
6119 |
#回傳結果
|
|
|
6120 |
return $result;
|
|
|
6121 |
|
|
|
6122 |
}#if end
|
|
|
6123 |
|
|
|
6124 |
#檢查參數
|
|
|
6125 |
#函式說明:
|
|
|
6126 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
6127 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6128 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
6129 |
#$result["function"],當前執行的函式名稱.
|
|
|
6130 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
6131 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
6132 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
6133 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
6134 |
#必填參數:
|
|
|
6135 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
6136 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
6137 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
6138 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("name");
|
|
|
6139 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
6140 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
6141 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
6142 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
6143 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
6144 |
$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
6145 |
#可省略參數:
|
|
|
6146 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
6147 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
6148 |
#$conf["variableCheck.checkArguments"]["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
|
|
|
6149 |
$conf["variableCheck.checkArguments"]["skipableVariableCanNotBeEmpty"]=array("defaultValue");
|
|
|
6150 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
6151 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("autoFocus","autocomplete","required","width","maxInputLength","defaultValue","class","jsActivitor","jsAction","trStart","tdStart","tdEnd","trEnd","comment","placeholder","formStart","formAction","formName","formMethod","formTarget","formEnd","dataFormId");
|
|
|
6152 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
6153 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
6154 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
6155 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("false","on","false",null,null,null,"__qbpwcf_inputPasswordCssStyle",null,null,"false","false","false","false",null,null,"false",null,null,"post","_self","false",null);
|
|
|
6156 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
6157 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
6158 |
|
|
|
6159 |
#如果檢查失敗
|
|
|
6160 |
if($checkResult["status"]=="false"){
|
|
|
6161 |
|
|
|
6162 |
#設置執行不正常
|
|
|
6163 |
$result["status"]="false";
|
|
|
6164 |
|
|
|
6165 |
#程式停止執行
|
|
|
6166 |
$result["error"]=$checkResult;
|
|
|
6167 |
|
|
|
6168 |
#回傳結果
|
|
|
6169 |
return $result;
|
|
|
6170 |
|
|
|
6171 |
}#if end
|
|
|
6172 |
|
|
|
6173 |
#如果檢查不通過
|
|
|
6174 |
if($checkResult["passed"]=="false"){
|
|
|
6175 |
|
|
|
6176 |
#設置執行不正常
|
|
|
6177 |
$result["status"]="false";
|
|
|
6178 |
|
|
|
6179 |
#程式停止執行
|
|
|
6180 |
$result["error"]=$checkResult;
|
|
|
6181 |
|
|
|
6182 |
#回傳結果
|
|
|
6183 |
return $result;
|
|
|
6184 |
|
|
|
6185 |
}#if end
|
|
|
6186 |
|
|
|
6187 |
#如果其值爲 true
|
|
|
6188 |
if($conf["trStart"]=="true"){
|
|
|
6189 |
|
|
|
6190 |
#串接列開始
|
|
|
6191 |
$result["content"]=$result["content"]."<tr>";
|
|
|
6192 |
|
|
|
6193 |
}#if end
|
|
|
6194 |
|
|
|
6195 |
#如果其值爲 true
|
|
|
6196 |
if($conf["tdStart"]=="true"){
|
|
|
6197 |
|
|
|
6198 |
#串接欄開始
|
|
|
6199 |
$result["content"]=$result["content"]."<td>";
|
|
|
6200 |
|
|
|
6201 |
}#if end
|
|
|
6202 |
|
|
|
6203 |
#如果 $conf["formStart"] 有設置
|
|
|
6204 |
if(isset($conf["formStart"])){
|
|
|
6205 |
|
|
|
6206 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
6207 |
if($conf["formStart"]=="true"){
|
|
|
6208 |
|
|
|
6209 |
#函式說明:
|
|
|
6210 |
#表單開始
|
|
|
6211 |
#回傳結果:
|
|
|
6212 |
#$result,表單開始的語法
|
|
|
6213 |
#必填參數:
|
|
|
6214 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
6215 |
#可省略參數:
|
|
|
6216 |
|
|
|
6217 |
#如果 $conf["formName"] 有設置
|
|
|
6218 |
if(isset($conf["formName"])){
|
|
|
6219 |
|
|
|
6220 |
#過濾 $conf["formName"] 避免錯誤
|
|
|
6221 |
#函式說明:
|
|
|
6222 |
#處理字串避免網頁出錯
|
|
|
6223 |
#回傳結果:
|
|
|
6224 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6225 |
#$result["function"],當前執行的函數.
|
|
|
6226 |
#$result["content"],爲處理好的字串.
|
|
|
6227 |
#$result["error"],錯誤訊息陣列.
|
|
|
6228 |
#必填參數:
|
|
|
6229 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
6230 |
#可省略的參數:
|
|
|
6231 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
6232 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
6233 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
6234 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
6235 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
6236 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
6237 |
|
|
|
6238 |
#如果過濾 $conf["formName"] 失敗
|
|
|
6239 |
if($correctCharacter["status"]=="false"){
|
|
|
6240 |
|
|
|
6241 |
#設置執行失敗
|
|
|
6242 |
$result["status"]="false";
|
|
|
6243 |
|
|
|
6244 |
#設置執行錯誤訊息
|
|
|
6245 |
$result["error"]=$correctCharacter;
|
|
|
6246 |
|
|
|
6247 |
#回傳結果
|
|
|
6248 |
return $result;
|
|
|
6249 |
|
|
|
6250 |
}#if end
|
|
|
6251 |
|
|
|
6252 |
#則設定其數值
|
|
|
6253 |
$conf["form"]["start"]["name"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
6254 |
|
|
|
6255 |
}#if end
|
|
|
6256 |
|
|
|
6257 |
#如果 $conf["formMethod"] 有設置
|
|
|
6258 |
if(isset($conf["formMethod"])){
|
|
|
6259 |
|
|
|
6260 |
#則設定其數值
|
|
|
6261 |
$conf["form"]["start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
6262 |
|
|
|
6263 |
}#if end
|
|
|
6264 |
|
|
|
6265 |
#如果 $conf["formTarget"] 有設定
|
|
|
6266 |
if(isset($conf["formTarget"])){
|
|
|
6267 |
|
|
|
6268 |
#則設定其數值
|
|
|
6269 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
6270 |
|
|
|
6271 |
}#if end
|
|
|
6272 |
|
|
|
6273 |
#則設定其參數數值
|
|
|
6274 |
$conf["form"]["start"]["tableStart"]="false";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
6275 |
|
|
|
6276 |
#則設定其數值
|
|
|
6277 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
6278 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
6279 |
unset($conf["form"]["start"]);
|
|
|
6280 |
|
|
|
6281 |
#如果表單開始失敗
|
|
|
6282 |
if($formStart["status"]=="false"){
|
|
|
6283 |
|
|
|
6284 |
#設置執行失敗
|
|
|
6285 |
$result["status"]="false";
|
|
|
6286 |
|
|
|
6287 |
#設置執行錯誤訊息
|
|
|
6288 |
$result["error"]=$formStart;
|
|
|
6289 |
|
|
|
6290 |
#回傳結果
|
|
|
6291 |
return $result;
|
|
|
6292 |
|
|
|
6293 |
}#if end
|
|
|
6294 |
|
|
|
6295 |
#串接表單開始的語法
|
|
|
6296 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
6297 |
|
|
|
6298 |
}#if end
|
|
|
6299 |
|
|
|
6300 |
}#if end
|
|
|
6301 |
|
|
|
6302 |
#如果 $conf["comment"] 有設置
|
|
|
6303 |
if(isset($conf["comment"])){
|
|
|
6304 |
|
|
|
6305 |
#新增註解,且套用css樣式.結尾換行.ok
|
|
|
6306 |
$result["content"]=$result["content"]."<label name=\"".$conf["name"]."\" class=\"".$conf["class"]."\">".$conf["comment"]."</label>";
|
|
|
6307 |
|
|
|
6308 |
}#if end
|
|
|
6309 |
|
|
|
6310 |
#如果$conf["maxInputLength"]沒設定
|
|
|
6311 |
if(!isset($conf["maxInputLength"])){
|
|
|
6312 |
|
|
|
6313 |
#$conf["maxInputLength"]就爲空
|
|
|
6314 |
$conf["maxInputLength"]="";
|
|
|
6315 |
|
|
|
6316 |
}#if end
|
|
|
6317 |
|
|
|
6318 |
#如果$conf["maxInputLength"]有設定
|
|
|
6319 |
else{
|
|
|
6320 |
|
|
|
6321 |
#就按照設定值
|
|
|
6322 |
$conf["maxInputLength"]=" maxlength=".$conf["maxInputLength"];
|
|
|
6323 |
|
|
|
6324 |
}#else end
|
|
|
6325 |
|
|
|
6326 |
#如果$conf["width"]沒設定
|
|
|
6327 |
if(!isset($conf["width"])){
|
|
|
6328 |
|
|
|
6329 |
#則$conf["width"]爲空值
|
|
|
6330 |
$conf["width"]="";
|
|
|
6331 |
|
|
|
6332 |
}#if end
|
|
|
6333 |
|
|
|
6334 |
#如果$conf["width"]有設定
|
|
|
6335 |
else{
|
|
|
6336 |
|
|
|
6337 |
#則套用寬度的css設定值
|
|
|
6338 |
$conf["width"]=" style=\"width:100%;\" ";
|
|
|
6339 |
|
|
|
6340 |
}#else end
|
|
|
6341 |
|
|
|
6342 |
#如果$conf["defaultValue"]沒設定
|
|
|
6343 |
if(!isset($conf["defaultValue"])){
|
|
|
6344 |
|
|
|
6345 |
#則$conf["defaultValue"]爲空
|
|
|
6346 |
$conf["defaultValue"]="";
|
|
|
6347 |
|
|
|
6348 |
}#else end
|
|
|
6349 |
|
|
|
6350 |
#反之則設定該屬性
|
|
|
6351 |
else{
|
|
|
6352 |
|
|
|
6353 |
$conf["defaultValue"]=" value = ".$conf["defaultValue"];
|
|
|
6354 |
|
|
|
6355 |
}#else end
|
|
|
6356 |
|
|
|
6357 |
#如果$conf["class"]沒設定
|
|
|
6358 |
if(!isset($conf["class"])){
|
|
|
6359 |
|
|
|
6360 |
#則套用預設的css樣式
|
|
|
6361 |
$conf["class"]=" class = __inputPasswordCssStyle ";
|
|
|
6362 |
|
|
|
6363 |
}#if end
|
|
|
6364 |
|
|
|
6365 |
#如果$conf["class"]有設定
|
|
|
6366 |
else{
|
|
|
6367 |
|
|
|
6368 |
#則套用樣式
|
|
|
6369 |
$conf["class"]=" class = \"".$conf["class"]."\"";
|
|
|
6370 |
|
|
|
6371 |
}#else end
|
|
|
6372 |
|
|
|
6373 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
6374 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
6375 |
|
|
|
6376 |
#則將設定值組合
|
|
|
6377 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
6378 |
|
|
|
6379 |
}#if end
|
|
|
6380 |
|
|
|
6381 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
6382 |
if(!isset($conf["jsCustom"])){
|
|
|
6383 |
|
|
|
6384 |
#將其設爲空值
|
|
|
6385 |
$conf["jsCustom"]="";
|
|
|
6386 |
|
|
|
6387 |
}#if end
|
|
|
6388 |
|
|
|
6389 |
#如果 $conf["placeholder"] 有設定
|
|
|
6390 |
if(isset($conf["placeholder"])){
|
|
|
6391 |
|
|
|
6392 |
#設定 "placeholder" 屬性
|
|
|
6393 |
$conf["placeholder"]=" placeholder=".$conf["placeholder"]." ";
|
|
|
6394 |
|
|
|
6395 |
}#if end
|
|
|
6396 |
|
|
|
6397 |
#反之設為 ""
|
|
|
6398 |
else{
|
|
|
6399 |
|
|
|
6400 |
$conf["placeholder"]="";
|
|
|
6401 |
|
|
|
6402 |
}#else end
|
|
|
6403 |
|
|
|
6404 |
#如果 $conf["required"] 為"true"
|
|
|
6405 |
if($conf["required"]=="true"){
|
|
|
6406 |
|
|
|
6407 |
#設置 "required" 屬性
|
|
|
6408 |
$conf["required"]="required=true";
|
|
|
6409 |
|
|
|
6410 |
}#if end
|
|
|
6411 |
|
|
|
6412 |
#反之
|
|
|
6413 |
else{
|
|
|
6414 |
|
|
|
6415 |
#設為空值
|
|
|
6416 |
$conf["required"]="";
|
|
|
6417 |
|
|
|
6418 |
}#else end
|
|
|
6419 |
|
|
|
6420 |
#過濾 $conf["name"] 避免錯誤
|
|
|
6421 |
#函式說明:
|
|
|
6422 |
#處理字串避免網頁出錯
|
|
|
6423 |
#回傳結果:
|
|
|
6424 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6425 |
#$result["function"],當前執行的函數.
|
|
|
6426 |
#$result["content"],爲處理好的字串.
|
|
|
6427 |
#$result["error"],錯誤訊息陣列.
|
|
|
6428 |
#必填參數:
|
|
|
6429 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
6430 |
#可省略的參數:
|
|
|
6431 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
6432 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
6433 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
6434 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
6435 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
6436 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
6437 |
|
|
|
6438 |
#如果過濾字串失敗
|
|
|
6439 |
if($correctCharacter["status"]=="false"){
|
|
|
6440 |
|
|
|
6441 |
#設置執行失敗
|
|
|
6442 |
$result["status"]="false";
|
|
|
6443 |
|
|
|
6444 |
#設置執行錯誤訊息
|
|
|
6445 |
$result["error"]=$correctCharacter;
|
|
|
6446 |
|
|
|
6447 |
#回傳結果
|
|
|
6448 |
return $result;
|
|
|
6449 |
|
|
|
6450 |
}#if end
|
|
|
6451 |
|
|
|
6452 |
#置換過濾好了的$conf["name"]
|
|
|
6453 |
$conf["name"]=$correctCharacter["content"];
|
|
|
6454 |
|
|
|
6455 |
#如果 $conf["autoFocus"] 為 "true"
|
|
|
6456 |
if($conf["autoFocus"]=="true"){
|
|
|
6457 |
|
|
|
6458 |
#設置自動選取
|
|
|
6459 |
$conf["autoFocus"]=" autofocus='ture' ";
|
|
|
6460 |
|
|
|
6461 |
}#if end
|
|
|
6462 |
|
|
|
6463 |
#反之
|
|
|
6464 |
else{
|
|
|
6465 |
|
|
|
6466 |
#設為 ""
|
|
|
6467 |
$conf["autoFocus"]="";
|
|
|
6468 |
|
|
|
6469 |
}#else end
|
|
|
6470 |
|
|
|
6471 |
#如果有設置 $conf["dataFormId"]
|
|
|
6472 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
6473 |
|
| 3 |
liveuser |
6474 |
#設置 data-id 屬性
|
|
|
6475 |
$conf["dataFormId"]="data-form-id=\"".$conf["dataFormId"]."\"";
|
| 226 |
liveuser |
6476 |
|
| 3 |
liveuser |
6477 |
}#if end
|
| 226 |
liveuser |
6478 |
|
|
|
6479 |
#反之設置為空數值
|
| 3 |
liveuser |
6480 |
else{
|
| 226 |
liveuser |
6481 |
|
| 3 |
liveuser |
6482 |
$conf["dataFormId"]="";
|
| 226 |
liveuser |
6483 |
|
| 3 |
liveuser |
6484 |
}#else end
|
| 226 |
liveuser |
6485 |
|
| 3 |
liveuser |
6486 |
#放置可以輸入密碼的表單
|
|
|
6487 |
$result["content"]=$result["content"]."<input type = password ".$conf["autoFocus"]." ".$conf["width"]." ".$conf["maxInputLength"]." name = ".$conf["name"]." id = ".$conf["name"]." ".$conf["defaultValue"]." ".$conf["class"]." ".$conf["jsCustom"]." ".$conf["placeholder"]." ".$conf["required"]." autocomplete=".$conf["autocomplete"]." ".$conf["dataFormId"].">";
|
|
|
6488 |
|
|
|
6489 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
6490 |
if($conf["formEnd"]=="true"){
|
|
|
6491 |
|
|
|
6492 |
#函式說明:
|
|
|
6493 |
#表單結束
|
|
|
6494 |
#回傳結果:
|
|
|
6495 |
#$result,表單結束的語法
|
|
|
6496 |
#必填參數:
|
|
|
6497 |
#則設定其數值
|
|
|
6498 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
6499 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
6500 |
unset($conf["form"]["end"]);
|
|
|
6501 |
|
|
|
6502 |
#串接表單結束的語法
|
|
|
6503 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
6504 |
|
|
|
6505 |
}#if end
|
|
|
6506 |
|
|
|
6507 |
#如果其值爲 true
|
|
|
6508 |
if($conf["tdEnd"]=="true"){
|
|
|
6509 |
|
|
|
6510 |
#串接欄結束
|
|
|
6511 |
$result["content"]=$result["content"]."</td>";
|
|
|
6512 |
|
|
|
6513 |
}#if end
|
|
|
6514 |
|
|
|
6515 |
#如果其值爲 true
|
|
|
6516 |
if($conf["trEnd"]=="true"){
|
|
|
6517 |
|
|
|
6518 |
#串接列結束
|
|
|
6519 |
$result["content"]=$result["content"]."</tr>";
|
|
|
6520 |
|
|
|
6521 |
}#if end
|
|
|
6522 |
|
|
|
6523 |
#設置執行成功
|
|
|
6524 |
$result["status"]="true";
|
|
|
6525 |
|
|
|
6526 |
#回傳語法
|
|
|
6527 |
return $result;
|
|
|
6528 |
|
|
|
6529 |
}#function inputPassword end
|
|
|
6530 |
|
|
|
6531 |
/*
|
|
|
6532 |
#函式說明:
|
|
|
6533 |
#建立下拉式表單
|
|
|
6534 |
#回傳結果:
|
|
|
6535 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
6536 |
#$result["error"],錯誤訊息陣列.
|
|
|
6537 |
#$result["content"],語法內容.
|
|
|
6538 |
#$result["function"],設置當前執行的函式
|
|
|
6539 |
#必填參數:
|
|
|
6540 |
#$conf["name"],字串,爲該下拉式選單的名稱
|
|
|
6541 |
$conf["name"]="";
|
|
|
6542 |
#$conf["sendValue"],陣列值,爲每個選項的實際傳送的數值,e.g. $sendValue = array("a","b","c","d","e");
|
|
|
6543 |
$conf["sendValue"]=array();
|
|
|
6544 |
#可省略參數:
|
|
|
6545 |
#$conf["formName"]="";#該表單的名稱
|
|
|
6546 |
#$conf["outputValue"]=array();#爲陣列值,爲每個選項的實際顯示的數值, e.g. $outputValue = array("p","o","i","t","e");,如果沒有設定,則其值同$conf["sendValue"]。
|
|
|
6547 |
#$conf["viewCount"]="";#為一次要顯示幾個選項,預設爲顯示一個。
|
|
|
6548 |
#$conf["defaultValue"]="";#為預設選取那個選項,須爲$conf["sendValue"]其中的一個值。
|
|
|
6549 |
#$conf["class"]="";#爲要套用的class樣式,預設為 "__qbpwcf_inputSelect".
|
|
|
6550 |
#$conf["readOnly"],字串,內容是否唯獨,預設為"false",不唯獨,"true"為唯獨.
|
|
|
6551 |
#$conf["readOnly"]="true";
|
|
|
6552 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
6553 |
#$conf["comment"]="";
|
|
|
6554 |
#$conf["formAction"]="";#爲該下拉式表單要傳送到的位置
|
|
|
6555 |
#$conf["actionTarget"]="_self";#要如何接收網頁的迴應,預設爲_self
|
|
|
6556 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsAction"]參數。
|
|
|
6557 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.forms.formName.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
6558 |
#$conf["independentForm"]="false";#是否該下拉式選單就是一個完整的表單,"true"代表是,"false"代表不是,預設為"true"
|
|
|
6559 |
#$conf["hiddenVar"],字串陣列,隱藏的變數名稱陣列.
|
|
|
6560 |
#$conf["hiddenVar"]=array("");
|
|
|
6561 |
#$conf["hiddanVarValue"],字串陣列,隱藏變數的數值內容.
|
|
|
6562 |
#$conf["hiddenVarValue"]=array("");
|
|
|
6563 |
#$conf["fixedPosition"],字串,該下拉式選單是否要隨着滾軸滾動時固定在畫面上特定的位置,於設為"false",代表不固定,"true"代表要固定.
|
|
|
6564 |
#$conf["fixedPosition"]="true";
|
|
|
6565 |
#$conf["fixedPosition.fixedTop"],字串,該選單距離畫面頂部的固定距離,預設為0px.
|
|
|
6566 |
#$conf["fixedPosition.fixedTop"]="0px";
|
|
|
6567 |
#$conf["fixedPosition.fixedLeft"],字串,該選單距離畫面左方的固定距離.預設為0px.
|
|
|
6568 |
#$conf["fixedPosition.fixedLeft"]="0px";
|
|
|
6569 |
#$conf["fixedPosition.emptySpaceSize"],字串,表單位置要放置多寬的空白,於設為40px.
|
|
|
6570 |
#$conf["fixedPosition.emptySpaceSize"]="40px";
|
|
|
6571 |
#$conf["tableStartClass"]="__withoutBorder";#表格要採用的css樣式,預設為__withoutBorder,__withoutBorder為沒有框線的樣式,__withBorder為有樣式的表格.
|
|
|
6572 |
#$conf["tableStart"]="true";#爲是否要以<table>結尾,"true"表示"是"。也可以看作表格結束。
|
|
|
6573 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
6574 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
6575 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
6576 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
6577 |
#$conf["tableEnd"]="true";#爲是否要以</table>結尾,"true"表示"是"。也可以看作表格結束。
|
|
|
6578 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
6579 |
#$conf["dataFormId"]="";
|
|
|
6580 |
#參考資料:
|
|
|
6581 |
#無.
|
|
|
6582 |
#備註:
|
|
|
6583 |
#$_SERVER["PHP_SELF"]為php檔案自己
|
|
|
6584 |
#http://stackoverflow.com/questions/833032/submit-is-not-a-function-in-javascript => form的id重複會導致"document.testForm.submit()"的javaScript語法出錯。
|
|
|
6585 |
#http://stackoverflow.com/questions/14622124/all-of-commands-for-submit-in-onchange-select-not-work => documents.forms.formName.submit() 才會將正確的表單送出。
|
|
|
6586 |
#http://stackoverflow.com/questions/368813/html-form-readonly-select-tag-input => 禁止改變選項,且也不會傳送該名稱表單
|
|
|
6587 |
#tableStart & tableEnd 要補上
|
|
|
6588 |
*/
|
|
|
6589 |
public static function inputSelect(&$conf){
|
|
|
6590 |
|
|
|
6591 |
#預設要回傳的數值
|
|
|
6592 |
$result=array();
|
|
|
6593 |
|
|
|
6594 |
#初始化要回傳的語法
|
|
|
6595 |
$result["content"]="";
|
|
|
6596 |
|
|
|
6597 |
#設置當前執行的函式
|
|
|
6598 |
$result["function"]=__FUNCTION__;
|
|
|
6599 |
|
|
|
6600 |
#如果 $conf 不為陣列
|
|
|
6601 |
if(gettype($conf)!="array"){
|
|
|
6602 |
|
|
|
6603 |
#設置執行失敗
|
|
|
6604 |
$result["status"]="false";
|
|
|
6605 |
|
|
|
6606 |
#設置執行錯誤訊息
|
|
|
6607 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
6608 |
|
|
|
6609 |
#如果傳入的參數為 null
|
|
|
6610 |
if($conf==null){
|
|
|
6611 |
|
|
|
6612 |
#設置執行錯誤訊息
|
|
|
6613 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
6614 |
|
|
|
6615 |
}#if end
|
|
|
6616 |
|
|
|
6617 |
#回傳結果
|
|
|
6618 |
return $result;
|
|
|
6619 |
|
|
|
6620 |
}#if end
|
|
|
6621 |
|
|
|
6622 |
#檢查參數
|
|
|
6623 |
#函式說明:
|
|
|
6624 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
6625 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6626 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
6627 |
#$result["function"],當前執行的函式名稱.
|
|
|
6628 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
6629 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
6630 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
6631 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
6632 |
#必填參數:
|
|
|
6633 |
#$conf["form.checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
6634 |
$conf["form.checkArguments"]["varInput"]=&$conf;
|
|
|
6635 |
#$conf["form.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
6636 |
$conf["form.checkArguments"]["mustBeFilledVariableName"][]="name";
|
|
|
6637 |
$conf["form.checkArguments"]["mustBeFilledVariableName"][]="sendValue";
|
|
|
6638 |
#$conf["form.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
6639 |
$conf["form.checkArguments"]["mustBeFilledVariableType"][]="string";
|
|
|
6640 |
$conf["form.checkArguments"]["mustBeFilledVariableType"][]="array";
|
|
|
6641 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
6642 |
$conf["form.checkArguments"]["referenceVarKey"]="form.checkArguments";
|
|
|
6643 |
#可省略參數:
|
|
|
6644 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
6645 |
#$conf["canBeEmptyString"]="false";
|
|
|
6646 |
#$conf["form.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
6647 |
$conf["form.checkArguments"]["skipableVariableName"][]="tableStart";
|
|
|
6648 |
$conf["form.checkArguments"]["skipableVariableName"][]="formAction";
|
|
|
6649 |
$conf["form.checkArguments"]["skipableVariableName"][]="formName";
|
|
|
6650 |
$conf["form.checkArguments"]["skipableVariableName"][]="hiddenVar";
|
|
|
6651 |
$conf["form.checkArguments"]["skipableVariableName"][]="hiddenVarValue";
|
|
|
6652 |
$conf["form.checkArguments"]["skipableVariableName"][]="fixedPosition";
|
|
|
6653 |
$conf["form.checkArguments"]["skipableVariableName"][]="fixedPosition.top";
|
|
|
6654 |
$conf["form.checkArguments"]["skipableVariableName"][]="fixedPosition.left";
|
|
|
6655 |
$conf["form.checkArguments"]["skipableVariableName"][]="trStart";
|
|
|
6656 |
$conf["form.checkArguments"]["skipableVariableName"][]="tdStart";
|
|
|
6657 |
$conf["form.checkArguments"]["skipableVariableName"][]="defaultValue";
|
|
|
6658 |
$conf["form.checkArguments"]["skipableVariableName"][]="viewCount";
|
|
|
6659 |
$conf["form.checkArguments"]["skipableVariableName"][]="outputValue";
|
|
|
6660 |
$conf["form.checkArguments"]["skipableVariableName"][]="jsActivitor";
|
|
|
6661 |
$conf["form.checkArguments"]["skipableVariableName"][]="jsAction";
|
|
|
6662 |
$conf["form.checkArguments"]["skipableVariableName"][]="jsCustom";
|
|
|
6663 |
$conf["form.checkArguments"]["skipableVariableName"][]="readOnly";
|
|
|
6664 |
$conf["form.checkArguments"]["skipableVariableName"][]="comment";
|
|
|
6665 |
$conf["form.checkArguments"]["skipableVariableName"][]="class";
|
|
|
6666 |
$conf["form.checkArguments"]["skipableVariableName"][]="tdEnd";
|
|
|
6667 |
$conf["form.checkArguments"]["skipableVariableName"][]="trtdEnd";
|
|
|
6668 |
$conf["form.checkArguments"]["skipableVariableName"][]="formAction";
|
|
|
6669 |
$conf["form.checkArguments"]["skipableVariableName"][]="independentForm";
|
|
|
6670 |
$conf["form.checkArguments"]["skipableVariableName"][]="tableEnd";
|
|
|
6671 |
$conf["form.checkArguments"]["skipableVariableName"][]="actionTarget";
|
|
|
6672 |
$conf["form.checkArguments"]["skipableVariableName"][]="dataFormId";
|
|
|
6673 |
#$conf["form.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
6674 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6675 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6676 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6677 |
$conf["form.checkArguments"]["skipableVariableType"][]="array";
|
|
|
6678 |
$conf["form.checkArguments"]["skipableVariableType"][]="array";
|
|
|
6679 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6680 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6681 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6682 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6683 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6684 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6685 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6686 |
$conf["form.checkArguments"]["skipableVariableType"][]="array";
|
|
|
6687 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6688 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6689 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6690 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6691 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6692 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6693 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6694 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6695 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6696 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6697 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6698 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6699 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
6700 |
#$conf["form.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
6701 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6702 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6703 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=" ";
|
|
|
6704 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6705 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6706 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6707 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6708 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6709 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6710 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6711 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=" ";
|
|
|
6712 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="1";
|
|
|
6713 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="\$conf[\"sendValue\"]";
|
|
|
6714 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6715 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6716 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=" ";
|
|
|
6717 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=" ";
|
|
|
6718 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=" ";
|
|
|
6719 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_inputSelect";
|
|
|
6720 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6721 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6722 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6723 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="true";
|
|
|
6724 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6725 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="_self";
|
|
|
6726 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
6727 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
6728 |
$conf["form.checkArguments"]["canBeEmptyString"]="false";
|
|
|
6729 |
$checkResult=variableCheck::checkArguments($conf["form.checkArguments"]);
|
|
|
6730 |
unset($conf["form.checkArguments"]);
|
|
|
6731 |
|
|
|
6732 |
#如果$checkResult["status"] 等於 "false"
|
|
|
6733 |
#意即如果檢查出錯
|
|
|
6734 |
if($checkResult["status"]=="false"){
|
|
|
6735 |
|
|
|
6736 |
#設置錯誤識別
|
|
|
6737 |
$result["status"]="false";
|
|
|
6738 |
|
|
|
6739 |
#設置錯誤訊息
|
|
|
6740 |
$result["error"]=$checkResult;
|
|
|
6741 |
|
|
|
6742 |
#回傳結果
|
|
|
6743 |
return $result;
|
|
|
6744 |
|
|
|
6745 |
}#if end
|
|
|
6746 |
|
|
|
6747 |
#如果$checkResult["passed"] 等於 "false"
|
|
|
6748 |
#意即如果檢查出錯
|
|
|
6749 |
if($checkResult["passed"]=="false"){
|
|
|
6750 |
|
|
|
6751 |
#設置錯誤識別
|
|
|
6752 |
$result["status"]="false";
|
|
|
6753 |
|
|
|
6754 |
#設置錯誤訊息
|
|
|
6755 |
$result["error"]=$checkResult;
|
|
|
6756 |
|
|
|
6757 |
#回傳結果
|
|
|
6758 |
return $result;
|
|
|
6759 |
|
|
|
6760 |
}#if end
|
|
|
6761 |
|
|
|
6762 |
#如果 $conf["tableStart"] 有設置
|
|
|
6763 |
if(isset($conf["tableStart"])){
|
|
|
6764 |
|
|
|
6765 |
#如果 $conf["tableStart"] 等於 "true"
|
|
|
6766 |
if($conf["tableStart"]=="true"){
|
|
|
6767 |
|
|
|
6768 |
#函式說明:
|
|
|
6769 |
#表格開始,可以設定表格的厚度和位置
|
|
|
6770 |
#回傳結果:
|
|
|
6771 |
#$result,表格開始的語法
|
|
|
6772 |
#必填寫的參數:
|
|
|
6773 |
$conf["table.start"]["class"]=$conf["tableStartClass"];#爲表格的css樣式,若為"",則代表不套用css樣式;若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
6774 |
$tableStart=table::start($conf["table.start"]);
|
|
|
6775 |
unset($conf["table.start"]);
|
|
|
6776 |
|
|
|
6777 |
#如果表格開始失敗
|
|
|
6778 |
if($tableStart["status"]=="false"){
|
|
|
6779 |
|
|
|
6780 |
#設置錯誤識別
|
|
|
6781 |
$result["status"]="false";
|
|
|
6782 |
|
|
|
6783 |
#設置錯誤訊息
|
|
|
6784 |
$result["error"]=$tableStart;
|
|
|
6785 |
|
|
|
6786 |
#回傳結果
|
|
|
6787 |
return $result;
|
|
|
6788 |
|
|
|
6789 |
}#if end
|
|
|
6790 |
|
|
|
6791 |
#串接表格開始的字串
|
|
|
6792 |
$result["content"]=$result["content"].$tableStart["content"];
|
|
|
6793 |
|
|
|
6794 |
}#if end
|
|
|
6795 |
|
|
|
6796 |
}#if end
|
|
|
6797 |
|
|
|
6798 |
#如果 $conf["formAction"] 有設定
|
|
|
6799 |
if(isset($conf["formAction"])){
|
|
|
6800 |
|
|
|
6801 |
#如果 $conf["actionTarget"] 有設定
|
|
|
6802 |
if(isset($conf["actionTarget"])){
|
|
|
6803 |
|
|
|
6804 |
#指派設定值
|
|
|
6805 |
$conf["form.start"]["target"]=$conf["actionTarget"];
|
|
|
6806 |
|
|
|
6807 |
}#if end
|
|
|
6808 |
|
|
|
6809 |
#如果 $conf["formName"] 沒有設置
|
|
|
6810 |
if(!isset($conf["formName"])){
|
|
|
6811 |
|
|
|
6812 |
#預設爲空數值
|
|
|
6813 |
$conf["formName"]=" ";
|
|
|
6814 |
|
|
|
6815 |
}#if end
|
|
|
6816 |
|
|
|
6817 |
#反之 $conf["formName"] 有設置
|
|
|
6818 |
else{
|
|
|
6819 |
|
|
|
6820 |
#過濾 $conf["formName"] 避免錯誤
|
|
|
6821 |
#函式說明:
|
|
|
6822 |
#處理字串避免網頁出錯
|
|
|
6823 |
#回傳結果:
|
|
|
6824 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6825 |
#$result["function"],當前執行的函數.
|
|
|
6826 |
#$result["content"],爲處理好的字串.
|
|
|
6827 |
#$result["error"],錯誤訊息陣列.
|
|
|
6828 |
#必填參數:
|
|
|
6829 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formName"];#爲要處理的字串
|
|
|
6830 |
#可省略的參數:
|
|
|
6831 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
6832 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
6833 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
6834 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
6835 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
6836 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
6837 |
|
|
|
6838 |
#如果過濾 $conf["formName"] 失敗
|
|
|
6839 |
if($correctCharacter["status"]=="false"){
|
|
|
6840 |
|
|
|
6841 |
#設置執行失敗
|
|
|
6842 |
$result["status"]="false";
|
|
|
6843 |
|
|
|
6844 |
#設置執行錯誤訊息
|
|
|
6845 |
$result["error"]=$correctCharacter;
|
|
|
6846 |
|
|
|
6847 |
#回傳結果
|
|
|
6848 |
return $result;
|
|
|
6849 |
|
|
|
6850 |
}#if end
|
|
|
6851 |
|
|
|
6852 |
#則設定其數值
|
|
|
6853 |
$conf["formName"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
6854 |
|
|
|
6855 |
}#if end
|
|
|
6856 |
|
|
|
6857 |
#函式說明:
|
|
|
6858 |
#表單開始
|
|
|
6859 |
#回傳結果:
|
|
|
6860 |
#$result,表單開始的語法
|
|
|
6861 |
#必填參數:
|
|
|
6862 |
$conf["form.start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
6863 |
#可省略參數:
|
|
|
6864 |
$conf["form.start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
6865 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
6866 |
#$conf["target"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
6867 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
6868 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100%
|
|
|
6869 |
$formStart=form::start($conf["form.start"]);
|
|
|
6870 |
unset($conf["form.start"]);
|
|
|
6871 |
|
|
|
6872 |
#如果表單開始失敗
|
|
|
6873 |
if($formStart["status"]=="false"){
|
|
|
6874 |
|
|
|
6875 |
#設置錯誤識別
|
|
|
6876 |
$result["status"]="false";
|
|
|
6877 |
|
|
|
6878 |
#設置錯誤訊息
|
|
|
6879 |
$result["error"]=$formStart;
|
|
|
6880 |
|
|
|
6881 |
#回傳結果
|
|
|
6882 |
return $result;
|
|
|
6883 |
|
|
|
6884 |
}#if end
|
|
|
6885 |
|
|
|
6886 |
#串接表單開始
|
|
|
6887 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
6888 |
|
|
|
6889 |
}#if end
|
|
|
6890 |
|
|
|
6891 |
#如果 $conf["hiddenVar"]與$conf["hiddenVarValue"]皆有設置
|
|
|
6892 |
if(isset($conf["hiddenVar"]) && isset($conf["hiddenVarValue"])){
|
|
|
6893 |
|
|
|
6894 |
#且陣列元素數目相同
|
|
|
6895 |
if(count($conf["hiddenVar"])==count($conf["hiddenVarValue"])){
|
|
|
6896 |
|
|
|
6897 |
#建立隱藏的表單
|
|
|
6898 |
#傳送多個隱藏表單的資訊
|
|
|
6899 |
#回傳的數值:
|
|
|
6900 |
#$result,語法
|
|
|
6901 |
#$result["sendedArrayName"],
|
|
|
6902 |
#$result["sendedArrayValue"],
|
|
|
6903 |
#$result["sendedArrayCount"],
|
|
|
6904 |
#必填參數:
|
|
|
6905 |
$conf["form"]["inputMutiHidden"]["nameArray"]=$conf["hiddenVar"];#欲傳送的隱藏陣列變數名稱
|
|
|
6906 |
$conf["form"]["inputMutiHidden"]["valueArray"]=$conf["hiddenVarValue"];#欲傳送的隱藏陣列變數數值
|
|
|
6907 |
$hiddenVar=form::inputMultiHidden($conf["form"]["inputMutiHidden"]);
|
|
|
6908 |
unset($conf["form"]);
|
|
|
6909 |
|
|
|
6910 |
#如果隱藏的表單變數設置失敗
|
|
|
6911 |
if($hiddenVar["status"]=="false"){
|
|
|
6912 |
|
|
|
6913 |
#設置錯誤識別
|
|
|
6914 |
$result["status"]="false";
|
|
|
6915 |
|
|
|
6916 |
#設置錯誤訊息
|
|
|
6917 |
$result["error"]=$hiddenVar;
|
|
|
6918 |
|
|
|
6919 |
#回傳結果
|
|
|
6920 |
return $result;
|
|
|
6921 |
|
|
|
6922 |
}#if end
|
|
|
6923 |
|
|
|
6924 |
#接上語法
|
|
|
6925 |
$result["content"]=$result["content"].$hiddenVar["content"];
|
|
|
6926 |
|
|
|
6927 |
}#if end
|
|
|
6928 |
|
|
|
6929 |
}#if end
|
|
|
6930 |
|
|
|
6931 |
#如果有設定 $conf["fixedPosition"]
|
|
|
6932 |
if(isset($conf["fixedPosition"])){
|
|
|
6933 |
|
|
|
6934 |
#如果 $conf["fixedPosition"] 等於 "true"
|
|
|
6935 |
if($conf["fixedPosition"]=="true"){
|
|
|
6936 |
|
|
|
6937 |
#如果 $conf["fixedPosition.fixedTop"] 沒有設置
|
|
|
6938 |
if(!isset($conf["fixedPosition.fixedTop"])){
|
|
|
6939 |
|
|
|
6940 |
#於設為0px
|
|
|
6941 |
$conf["fixedPosition.fixedTop"]="0px";
|
|
|
6942 |
|
|
|
6943 |
}#if end
|
|
|
6944 |
|
|
|
6945 |
#如果 $conf["fixedPosition.fixedLeft"] 沒有設置
|
|
|
6946 |
if(!isset($conf["fixedPosition.fixedLeft"])){
|
|
|
6947 |
|
|
|
6948 |
#預設為0px
|
|
|
6949 |
$conf["fixedPosition.fixedLeft"]="0px";
|
|
|
6950 |
|
|
|
6951 |
}#if end
|
|
|
6952 |
|
|
|
6953 |
#如果 $conf["fixedPosition.emptySpaceSize"] 沒有設置
|
|
|
6954 |
if(!isset($conf["fixedPosition.emptySpaceSize"])){
|
|
|
6955 |
|
|
|
6956 |
#預設為40px
|
|
|
6957 |
$conf["fixedPosition.emptySpaceSize"]="40px";
|
|
|
6958 |
|
|
|
6959 |
}#if end
|
|
|
6960 |
|
|
|
6961 |
#建立按鈕的預設css樣式
|
|
|
6962 |
#函式說明:
|
|
|
6963 |
#創建 css 樣式
|
|
|
6964 |
#必填參數:
|
|
|
6965 |
$conf_createCssStyle["cssStyleName"]="__simpleButtonLinkDefaultButtonFixedPositionCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
6966 |
$conf_createCssStyle["attributes"]=array("width","height","font-size","text-align","position","top","left");#為屬性名稱,須為陣列值
|
|
|
6967 |
$conf_createCssStyle["content"]=array("100%",(50*$conf["viewCount"])."px","30","center","fixed",$conf["fixedPosition.fixedTop"],$conf["fixedPosition.fixedLeft"]);#為屬性值,須為陣列值
|
|
|
6968 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
6969 |
unset($conf_createCssStyle);
|
|
|
6970 |
|
|
|
6971 |
#如果建立css樣式失敗
|
|
|
6972 |
if($css["status"]=="false"){
|
|
|
6973 |
|
|
|
6974 |
#設置錯誤識別
|
|
|
6975 |
$result["status"]="false";
|
|
|
6976 |
|
|
|
6977 |
#設置錯誤訊息
|
|
|
6978 |
$result["error"]=$css;
|
|
|
6979 |
|
|
|
6980 |
#回傳結果
|
|
|
6981 |
return $result;
|
|
|
6982 |
|
|
|
6983 |
}#if end
|
|
|
6984 |
|
|
|
6985 |
#串接css樣式
|
|
|
6986 |
$result["content"]=$result["content"].$css["content"];
|
|
|
6987 |
|
|
|
6988 |
#函式說明:
|
|
|
6989 |
#創建 css 樣式
|
|
|
6990 |
#回傳結果:
|
|
|
6991 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
6992 |
#$result["css"],css設定內容
|
|
|
6993 |
#$result["function"],當前執行的函數
|
|
|
6994 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
6995 |
#必填參數:
|
|
|
6996 |
$conf["css.createCssStyle"]["cssStyleName"]="emptyStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
6997 |
$conf["css.createCssStyle"]["attributes"]=array("font-size");#為屬性名稱,須為陣列值
|
|
|
6998 |
$conf["css.createCssStyle"]["content"]=array("40px");#為屬性值,須為陣列值
|
|
|
6999 |
$css=css::createCssStyle($conf["css.createCssStyle"]);
|
|
|
7000 |
unset($conf["css.createCssStyle"]);
|
|
|
7001 |
|
|
|
7002 |
#如果建立css樣式失敗
|
|
|
7003 |
if($css["status"]=="false"){
|
|
|
7004 |
|
|
|
7005 |
#設置錯誤識別
|
|
|
7006 |
$result["status"]="false";
|
|
|
7007 |
|
|
|
7008 |
#設置錯誤訊息
|
|
|
7009 |
$result["error"]=$css;
|
|
|
7010 |
|
|
|
7011 |
#回傳結果
|
|
|
7012 |
return $result;
|
|
|
7013 |
|
|
|
7014 |
}#if end
|
|
|
7015 |
|
|
|
7016 |
#串接css樣式
|
|
|
7017 |
$result["content"]=$result["content"].$css["content"];
|
|
|
7018 |
|
|
|
7019 |
}#if end
|
|
|
7020 |
|
|
|
7021 |
}#if end
|
|
|
7022 |
|
|
|
7023 |
#如果 $conf["trStart"] 存在
|
|
|
7024 |
if(isset($conf["trStart"])){
|
|
|
7025 |
|
|
|
7026 |
#如果其值爲 true
|
|
|
7027 |
if($conf["trStart"]=="true"){
|
|
|
7028 |
|
|
|
7029 |
#串接列開始
|
|
|
7030 |
$result["content"]=$result["content"]."<tr>";
|
|
|
7031 |
|
|
|
7032 |
}#if end
|
|
|
7033 |
|
|
|
7034 |
}#if end
|
|
|
7035 |
|
|
|
7036 |
#如果 $conf["tdStart"] 存在
|
|
|
7037 |
if(isset($conf["tdStart"])){
|
|
|
7038 |
|
|
|
7039 |
#如果其值爲 true
|
|
|
7040 |
if($conf["tdStart"]=="true"){
|
|
|
7041 |
|
|
|
7042 |
#串接欄開始
|
|
|
7043 |
$result["content"]=$result["content"]."<td>";
|
|
|
7044 |
|
|
|
7045 |
}#if end
|
|
|
7046 |
|
|
|
7047 |
}#if end
|
|
|
7048 |
|
|
|
7049 |
#如果 $conf["viewCount"] 有設定
|
|
|
7050 |
if(isset($conf["viewCount"])){
|
|
|
7051 |
|
|
|
7052 |
#就按照設定值
|
|
|
7053 |
$conf["viewCount"]=" size = ".$conf["viewCount"]." ";
|
|
|
7054 |
|
|
|
7055 |
}#if end
|
|
|
7056 |
|
|
|
7057 |
#反之
|
|
|
7058 |
else{
|
|
|
7059 |
|
|
|
7060 |
#設為""
|
|
|
7061 |
$conf["viewCount"]="";
|
|
|
7062 |
|
|
|
7063 |
}#else end
|
|
|
7064 |
|
|
|
7065 |
#如果有設定 $conf["fixedPosition"]
|
|
|
7066 |
if(isset($conf["fixedPosition"])){
|
|
|
7067 |
|
|
|
7068 |
#如果 $conf["fixedPosition"] 等於 "true"
|
|
|
7069 |
if($conf["fixedPosition"]=="true"){
|
|
|
7070 |
|
|
|
7071 |
#用固定位置的樣式
|
|
|
7072 |
$conf["class"]="__simpleButtonLinkDefaultButtonFixedPositionCssStyle";
|
|
|
7073 |
|
|
|
7074 |
}#if end
|
|
|
7075 |
|
|
|
7076 |
}#if end
|
|
|
7077 |
|
|
|
7078 |
#設定要套用的css類別樣式
|
|
|
7079 |
$conf["class"] = " class='".$conf["class"]."' ";
|
|
|
7080 |
|
|
|
7081 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
7082 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
7083 |
|
|
|
7084 |
#處理jsAction裏面不能有空格
|
|
|
7085 |
#函式說明:
|
|
|
7086 |
#處理字串避免網頁出錯
|
|
|
7087 |
#回傳結果:
|
|
|
7088 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
7089 |
#$result["function"],當前執行的函數.
|
|
|
7090 |
#$result["content"],爲處理好的字串.
|
|
|
7091 |
#$result["error"],錯誤訊息陣列.
|
| 226 |
liveuser |
7092 |
#$result["argu"],使用的參數.
|
| 3 |
liveuser |
7093 |
#必填參數:
|
|
|
7094 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["jsAction"];#爲要處理的字串
|
|
|
7095 |
#可省略的參數:
|
|
|
7096 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array(" ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
7097 |
#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
|
|
|
7098 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
7099 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
7100 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
7101 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
7102 |
|
|
|
7103 |
#如果處理失敗
|
|
|
7104 |
if($correctCharacter["status"]==="false"){
|
|
|
7105 |
|
|
|
7106 |
#設置執行失敗
|
|
|
7107 |
$result["status"]="false";
|
|
|
7108 |
|
|
|
7109 |
#設置執行錯誤
|
|
|
7110 |
$result["error"]=$correctCharacter;
|
|
|
7111 |
|
|
|
7112 |
#回傳結果
|
|
|
7113 |
return $result;
|
|
|
7114 |
|
| 226 |
liveuser |
7115 |
}#if end
|
| 3 |
liveuser |
7116 |
|
|
|
7117 |
#get new jsAction
|
|
|
7118 |
$conf["jsAction"]=$correctCharacter["content"];#爲該表單的名稱
|
|
|
7119 |
|
|
|
7120 |
#則將設定值組合
|
|
|
7121 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
7122 |
|
|
|
7123 |
}#if end
|
|
|
7124 |
|
|
|
7125 |
#如果 $conf["readOnly"] 為 "true"
|
|
|
7126 |
if($conf["readOnly"]=="true"){
|
|
|
7127 |
|
|
|
7128 |
#設置為 " readonly "
|
|
|
7129 |
$conf["readOnly"]=" disabled ";
|
|
|
7130 |
|
|
|
7131 |
}#if end
|
|
|
7132 |
|
|
|
7133 |
#反之
|
|
|
7134 |
else{
|
|
|
7135 |
|
|
|
7136 |
#設置為 ""
|
|
|
7137 |
$conf["readOnly"]="";
|
|
|
7138 |
|
|
|
7139 |
}#else end
|
|
|
7140 |
|
|
|
7141 |
#過濾 $conf["name"] 避免錯誤
|
|
|
7142 |
#函式說明:
|
|
|
7143 |
#處理字串避免網頁出錯
|
|
|
7144 |
#回傳結果:
|
|
|
7145 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
7146 |
#$result["function"],當前執行的函數.
|
|
|
7147 |
#$result["content"],爲處理好的字串.
|
|
|
7148 |
#$result["error"],錯誤訊息陣列.
|
|
|
7149 |
#必填參數:
|
|
|
7150 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
7151 |
#可省略的參數:
|
|
|
7152 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
7153 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
7154 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
7155 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
7156 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
7157 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
7158 |
|
|
|
7159 |
#如果過濾字串失敗
|
|
|
7160 |
if($correctCharacter["status"]=="false"){
|
|
|
7161 |
|
|
|
7162 |
#設置執行失敗
|
|
|
7163 |
$result["status"]="false";
|
|
|
7164 |
|
|
|
7165 |
#設置執行錯誤訊息
|
|
|
7166 |
$result["error"]=$correctCharacter;
|
|
|
7167 |
|
|
|
7168 |
#回傳結果
|
|
|
7169 |
return $result;
|
|
|
7170 |
|
|
|
7171 |
}#if end
|
|
|
7172 |
|
|
|
7173 |
#置換過濾好了的$conf["name"]
|
|
|
7174 |
$conf["name"]=$correctCharacter["content"];
|
|
|
7175 |
|
|
|
7176 |
#建立註解文字用的預設css樣式
|
|
|
7177 |
#函式說明:
|
|
|
7178 |
#創建 css 樣式
|
|
|
7179 |
#必填參數:
|
|
|
7180 |
$conf_createCssStyle["cssStyleName"]="__commentDefaultCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
7181 |
$conf_createCssStyle["attributes"]=array("font-size","text-align");#為屬性名稱,須為陣列值
|
|
|
7182 |
$conf_createCssStyle["content"]=array("30","center");#為屬性值,須為陣列值
|
|
|
7183 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
7184 |
unset($conf_createCssStyle);
|
|
|
7185 |
|
|
|
7186 |
#如果建立css樣式失敗
|
|
|
7187 |
if($css["status"]=="false"){
|
|
|
7188 |
|
|
|
7189 |
#設置錯誤識別
|
|
|
7190 |
$result["status"]="false";
|
|
|
7191 |
|
|
|
7192 |
#設置錯誤訊息
|
|
|
7193 |
$result["error"]=$css;
|
|
|
7194 |
|
|
|
7195 |
#回傳結果
|
|
|
7196 |
return $result;
|
|
|
7197 |
|
|
|
7198 |
}#if end
|
|
|
7199 |
|
|
|
7200 |
#串接css樣式
|
|
|
7201 |
$result["content"]=$result["content"].$css["content"];
|
|
|
7202 |
|
|
|
7203 |
#如果有設置 $conf["dataFormId"]
|
|
|
7204 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
7205 |
|
| 3 |
liveuser |
7206 |
#設置 data-id 屬性
|
|
|
7207 |
$conf["dataFormId"]="data-form-id=\"".$conf["dataFormId"]."\"";
|
| 226 |
liveuser |
7208 |
|
| 3 |
liveuser |
7209 |
}#if end
|
| 226 |
liveuser |
7210 |
|
|
|
7211 |
#反之設置為空數值
|
| 3 |
liveuser |
7212 |
else{
|
| 226 |
liveuser |
7213 |
|
| 3 |
liveuser |
7214 |
$conf["dataFormId"]="";
|
| 226 |
liveuser |
7215 |
|
| 3 |
liveuser |
7216 |
}#else end
|
|
|
7217 |
|
|
|
7218 |
#下拉式表單的名稱
|
|
|
7219 |
$result["content"]=$result["content"]." <label class=\"__commentDefaultCssStyle\" for=\"".$conf["name"]."\">".$conf["comment"]."</label><select id=\"".$conf["name"]."\" name = \"".$conf["name"]."\" ".$conf["viewCount"]." ".$conf["class"]." ".$conf["jsCustom"]." ".$conf["readOnly"]." ".$conf["dataFormId"].">";
|
|
|
7220 |
|
|
|
7221 |
#將有幾個選項的數目放進 $count
|
|
|
7222 |
$count=count($conf["sendValue"]);
|
|
|
7223 |
|
|
|
7224 |
#n個選項跑n次
|
|
|
7225 |
for($i=0;$i<$count;$i++){
|
|
|
7226 |
|
|
|
7227 |
#如果選項的內容等於預設的數值,
|
|
|
7228 |
if($conf["defaultValue"]==$conf["sendValue"][$i]){
|
|
|
7229 |
|
|
|
7230 |
#增加可用的選項,且設為預設選項。
|
|
|
7231 |
$result["content"]=$result["content"]."<option value = \"".$conf["sendValue"][$i]."\" selected='selected'>".$conf["outputValue"][$i]."</option>";
|
|
|
7232 |
|
|
|
7233 |
}#if end
|
|
|
7234 |
|
|
|
7235 |
#反之則照常處理
|
|
|
7236 |
else{
|
|
|
7237 |
|
|
|
7238 |
#謹增加可用的選項
|
|
|
7239 |
$result["content"]=$result["content"]."<option value = \"".$conf["sendValue"][$i]."\">".$conf["outputValue"][$i]."</option>";
|
|
|
7240 |
|
|
|
7241 |
}#else end
|
|
|
7242 |
|
|
|
7243 |
}#回圈結束
|
|
|
7244 |
|
|
|
7245 |
#選項結束
|
|
|
7246 |
$result["content"]=$result["content"]."</select>";
|
|
|
7247 |
|
|
|
7248 |
#如果有設定 $conf["fixedPosition"]
|
|
|
7249 |
if(isset($conf["fixedPosition"])){
|
|
|
7250 |
|
|
|
7251 |
#如果 $conf["fixedPosition"] 等於 "true"
|
|
|
7252 |
if($conf["fixedPosition"]=="true"){
|
|
|
7253 |
|
|
|
7254 |
#空白區塊
|
|
|
7255 |
#函式說明:
|
|
|
7256 |
#<span>區塊:
|
|
|
7257 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
7258 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
7259 |
#$result["error"],陣列,錯訊訊息.
|
|
|
7260 |
#$result["content"],字串,<div>標籤的開始與設定語法.
|
|
|
7261 |
#必填參數:
|
|
|
7262 |
#$conf["css.spanSection"]["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
7263 |
$conf["css.spanSection"]["contentArray"]=array(" ");
|
|
|
7264 |
#可省略參數
|
|
|
7265 |
#$conf["css.spanSection"]["class"],字串,div區段要套用的css樣式.
|
|
|
7266 |
$conf["css.spanSection"]["class"]="emptyStyle";
|
|
|
7267 |
$spanSection=css::spanSection($conf["css.spanSection"]);
|
|
|
7268 |
unset($conf["css.spanSection"]);
|
|
|
7269 |
|
|
|
7270 |
#如果 spanSection 建立失敗
|
|
|
7271 |
if($spanSection["status"]==="false"){
|
|
|
7272 |
|
|
|
7273 |
#設置錯誤識別
|
|
|
7274 |
$result["status"]="false";
|
|
|
7275 |
|
|
|
7276 |
#設置錯誤訊息
|
|
|
7277 |
$result["error"]=$spanSection;
|
|
|
7278 |
|
|
|
7279 |
#回傳結果
|
|
|
7280 |
return $result;
|
|
|
7281 |
|
|
|
7282 |
}#if end
|
|
|
7283 |
|
|
|
7284 |
#串接 spanSection
|
|
|
7285 |
$result["content"]=$result["content"].$spanSection["content"];
|
|
|
7286 |
|
|
|
7287 |
}#if end
|
|
|
7288 |
|
|
|
7289 |
}#if end
|
|
|
7290 |
|
|
|
7291 |
#如果 $conf["tdEnd"] 存在
|
|
|
7292 |
if(isset($conf["tdEnd"])){
|
|
|
7293 |
|
|
|
7294 |
#如果其值爲 true
|
|
|
7295 |
if($conf["tdEnd"]==="true"){
|
|
|
7296 |
|
|
|
7297 |
#欄結束
|
|
|
7298 |
$result["content"]=$result["content"]."</td>";
|
|
|
7299 |
|
|
|
7300 |
}#if end
|
|
|
7301 |
|
|
|
7302 |
}#if end
|
|
|
7303 |
|
|
|
7304 |
#如果 $conf["trtdEnd"] 存在
|
|
|
7305 |
if(isset($conf["trEnd"])){
|
|
|
7306 |
|
|
|
7307 |
#如果其值爲 true
|
|
|
7308 |
if($conf["trEnd"]==="true"){
|
|
|
7309 |
|
|
|
7310 |
#列結束
|
|
|
7311 |
$result["content"]=$result["content"]."</tr>";
|
|
|
7312 |
|
|
|
7313 |
}#if end
|
|
|
7314 |
|
|
|
7315 |
}#if end
|
|
|
7316 |
|
|
|
7317 |
#如果 $conf["formAction"] 有設定
|
|
|
7318 |
if(isset($conf["formAction"])){
|
|
|
7319 |
|
|
|
7320 |
#如果 $conf["independentForm"] 等於 "true"
|
|
|
7321 |
if($conf["independentForm"]=="true"){
|
|
|
7322 |
|
|
|
7323 |
#函式說明:
|
|
|
7324 |
#表單結束
|
|
|
7325 |
#回傳結果:
|
|
|
7326 |
#$result,表單結束的語法
|
|
|
7327 |
#必填參數:
|
|
|
7328 |
$conf["form.end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
7329 |
$formEnd=form::end($conf["form.end"]);
|
|
|
7330 |
unset($conf["form.end"]);
|
|
|
7331 |
|
|
|
7332 |
#如果表單結束失敗
|
|
|
7333 |
if($formEnd["status"]==="false"){
|
|
|
7334 |
|
|
|
7335 |
#設置錯誤識別
|
|
|
7336 |
$result["status"]="false";
|
|
|
7337 |
|
|
|
7338 |
#設置錯誤訊息
|
|
|
7339 |
$result["error"]=$formEnd;
|
|
|
7340 |
|
|
|
7341 |
#回傳結果
|
|
|
7342 |
return $result;
|
|
|
7343 |
|
|
|
7344 |
}#if end
|
|
|
7345 |
|
|
|
7346 |
#串接表單結束
|
|
|
7347 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
7348 |
|
|
|
7349 |
}#if end
|
|
|
7350 |
|
|
|
7351 |
}#if end
|
|
|
7352 |
|
|
|
7353 |
#如果 $conf["tableEnd"] 有設置
|
|
|
7354 |
if(isset($conf["tableEnd"])){
|
|
|
7355 |
|
|
|
7356 |
#如果 $conf["tableEnd"] 等於 "true"
|
|
|
7357 |
if($conf["tableEnd"]=="true"){
|
|
|
7358 |
|
|
|
7359 |
#函式說明:
|
|
|
7360 |
#表格結束
|
|
|
7361 |
#回傳結果:
|
|
|
7362 |
#表格結束的語法
|
|
|
7363 |
$result["content"]=$result["content"].table::end();
|
|
|
7364 |
|
|
|
7365 |
}#if end
|
|
|
7366 |
|
|
|
7367 |
}#if end
|
|
|
7368 |
|
|
|
7369 |
#設置執行正常
|
|
|
7370 |
$result["status"]="true";
|
|
|
7371 |
|
|
|
7372 |
#印出表格的設定以及表單的目的、呈現的方式、傳送的方式。
|
|
|
7373 |
return $result;
|
|
|
7374 |
|
|
|
7375 |
}#function inputSelect end
|
|
|
7376 |
|
|
|
7377 |
/*
|
|
|
7378 |
#函式說明:
|
|
|
7379 |
#建立下拉式表單,選項會用全螢幕的div區塊呈現.
|
|
|
7380 |
#回傳結果:
|
|
|
7381 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
7382 |
#$result["error"],錯誤訊息陣列.
|
|
|
7383 |
#$result["content"],語法內容.
|
|
|
7384 |
#$result["function"],設置當前執行的函式
|
|
|
7385 |
#必填參數:
|
|
|
7386 |
#$conf["name"],字串,爲該下拉式選單的名稱
|
|
|
7387 |
$conf["name"]="";
|
|
|
7388 |
#$conf["sendValue"],陣列值,爲每個選項的實際傳送的數值,e.g. $sendValue = array("a","b","c","d","e");
|
|
|
7389 |
$conf["sendValue"]=array();
|
|
|
7390 |
#可省略參數:
|
|
|
7391 |
#$conf["formName"]="";#該表單的名稱,不能跟 "name" 一樣,會造成關閉選單後,選單也跟着消失的問題.
|
|
|
7392 |
#$conf["outputValue"]=array();#爲陣列值,爲每個選項的實際顯示的數值, e.g. $outputValue = array("p","o","i","t","e");,如果沒有設定,則其值同$conf["sendValue"]。
|
|
|
7393 |
#$conf["viewCount"]="";#為一次要顯示幾個選項,預設爲顯示一個。
|
|
|
7394 |
#$conf["defaultValue"]="";#為預設選取那個選項,須爲$conf["sendValue"]其中的一個值。
|
|
|
7395 |
#$conf["class"]="";#爲要套用的class樣式,預設為 "__qbpwcf_inputSelect".
|
|
|
7396 |
#$conf["readOnly"],字串,內容是否唯獨,預設為"false",不唯獨,"true"為唯獨.
|
|
|
7397 |
#$conf["readOnly"]="true";
|
|
|
7398 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
7399 |
#$conf["comment"]="";
|
|
|
7400 |
#$conf["formAction"]="";#爲該下拉式表單要傳送到的位置
|
|
|
7401 |
#$conf["actionTarget"]="_self";#要如何接收網頁的迴應,預設爲_self
|
|
|
7402 |
#$conf["independentForm"]="false";#是否該下拉式選單就是一個完整的表單,"true"代表是,"false"代表不是,預設為"true"
|
|
|
7403 |
#$conf["hiddenVar"],字串陣列,隱藏的變數名稱陣列.
|
|
|
7404 |
#$conf["hiddenVar"]=array("");
|
|
|
7405 |
#$conf["hiddanVarValue"],字串陣列,隱藏變數的數值內容.
|
|
|
7406 |
#$conf["hiddenVarValue"]=array("");
|
|
|
7407 |
#$conf["fixedPosition"],字串,該下拉式選單是否要隨着滾軸滾動時固定在畫面上特定的位置,於設為"false",代表不固定,"true"代表要固定.
|
|
|
7408 |
#$conf["fixedPosition"]="true";
|
|
|
7409 |
#$conf["fixedPosition.fixedTop"],字串,該選單距離畫面頂部的固定距離,預設為0px.
|
|
|
7410 |
#$conf["fixedPosition.fixedTop"]="0px";
|
|
|
7411 |
#$conf["fixedPosition.fixedLeft"],字串,該選單距離畫面左方的固定距離.預設為0px.
|
|
|
7412 |
#$conf["fixedPosition.fixedLeft"]="0px";
|
|
|
7413 |
#$conf["fixedPosition.emptySpaceSize"],字串,表單位置要放置多寬的空白,於設為40px.
|
|
|
7414 |
#$conf["fixedPosition.emptySpaceSize"]="40px";
|
|
|
7415 |
#$conf["tableStartClass"]="__withoutBorder";#表格要採用的css樣式,預設為__withoutBorder,__withoutBorder為沒有框線的樣式,__withBorder為有樣式的表格.
|
|
|
7416 |
#$conf["tableStart"]="true";#爲是否要以<table>結尾,"true"表示"是"。也可以看作表格結束。
|
|
|
7417 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
7418 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
7419 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
7420 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
7421 |
#$conf["tableEnd"]="true";#爲是否要以</table>結尾,"true"表示"是"。也可以看作表格結束。
|
|
|
7422 |
#$conf["closeIcon"],字串,關閉滾軸選單的按鈕圖示,預設為"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K".
|
|
|
7423 |
#$conf["closeIcon"]="";
|
|
|
7424 |
#$conf["valNotSend"],字串,如果選擇的選項數值為何,就不傳送表單.
|
|
|
7425 |
#$conf["valNotSend"]="";
|
|
|
7426 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
7427 |
#$conf["dataFormId"]="";
|
|
|
7428 |
#參考資料:
|
|
|
7429 |
#http://stackoverflow.com/questions/833032/submit-is-not-a-function-in-javascript => form的id重複會導致"document.testForm.submit()"的javaScript語法出錯。
|
|
|
7430 |
#http://stackoverflow.com/questions/14622124/all-of-commands-for-submit-in-onchange-select-not-work => documents.forms.formName.submit() 才會將正確的表單送出。
|
|
|
7431 |
#http://stackoverflow.com/questions/368813/html-form-readonly-select-tag-input => 禁止改變選項,且也不會傳送該名稱表單
|
|
|
7432 |
#備註:
|
|
|
7433 |
#$_SERVER["PHP_SELF"]為php檔案自己
|
|
|
7434 |
#在手機網頁瀏覽器不支援.
|
|
|
7435 |
#tableStart & tableEnd 要補上
|
|
|
7436 |
*/
|
|
|
7437 |
public static function scrollingList(&$conf){
|
|
|
7438 |
|
|
|
7439 |
#初始化要回傳的結果
|
|
|
7440 |
$result=array();
|
|
|
7441 |
|
|
|
7442 |
#取得當前執行的函數名稱
|
|
|
7443 |
$result["function"]=__FUNCTION__;
|
|
|
7444 |
|
|
|
7445 |
#如果沒有參數
|
|
|
7446 |
if(func_num_args()==0){
|
|
|
7447 |
|
|
|
7448 |
#設置執行失敗
|
|
|
7449 |
$result["status"]="false";
|
|
|
7450 |
|
|
|
7451 |
#設置執行錯誤訊息
|
|
|
7452 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
7453 |
|
|
|
7454 |
#回傳結果
|
|
|
7455 |
return $result;
|
|
|
7456 |
|
|
|
7457 |
}#if end
|
|
|
7458 |
|
|
|
7459 |
#取得參數
|
|
|
7460 |
$result["argu"]=$conf;
|
|
|
7461 |
|
|
|
7462 |
#如果 $conf 不為陣列
|
|
|
7463 |
if(gettype($conf)!=="array"){
|
|
|
7464 |
|
|
|
7465 |
#設置執行失敗
|
|
|
7466 |
$result["status"]="false";
|
|
|
7467 |
|
|
|
7468 |
#設置執行錯誤訊息
|
|
|
7469 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
7470 |
|
|
|
7471 |
#如果傳入的參數為 null
|
|
|
7472 |
if($conf===null){
|
|
|
7473 |
|
|
|
7474 |
#設置執行錯誤訊息
|
|
|
7475 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
7476 |
|
|
|
7477 |
}#if end
|
|
|
7478 |
|
|
|
7479 |
#回傳結果
|
|
|
7480 |
return $result;
|
|
|
7481 |
|
|
|
7482 |
}#if end
|
|
|
7483 |
|
|
|
7484 |
#如果有設置close icon
|
|
|
7485 |
if(isset($conf["closeIcon"])){
|
|
|
7486 |
|
|
|
7487 |
#另存路徑
|
|
|
7488 |
$closeIcon=$conf["closeIcon"];
|
|
|
7489 |
|
|
|
7490 |
#卸除不被 form::inputSelect 接受的參數
|
|
|
7491 |
unset($conf["closeIcon"]);
|
|
|
7492 |
|
|
|
7493 |
}#if end
|
|
|
7494 |
|
|
|
7495 |
#反之
|
|
|
7496 |
else{
|
|
|
7497 |
|
|
|
7498 |
#用預設的 close icon
|
|
|
7499 |
$closeIcon="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K";
|
|
|
7500 |
|
|
|
7501 |
}#else end
|
|
|
7502 |
|
|
|
7503 |
#如果有設置 $conf["valNotSend"]
|
|
|
7504 |
if(isset($conf["valNotSend"])){
|
|
|
7505 |
|
|
|
7506 |
#設置不傳送表單的js語法
|
|
|
7507 |
$valNotSend=
|
|
|
7508 |
"
|
|
|
7509 |
//如果表單的數值為 ".$conf["valNotSend"]."
|
|
|
7510 |
if(clickedValue==='".$conf["valNotSend"]."'){
|
|
|
7511 |
|
|
|
7512 |
//結束動作
|
|
|
7513 |
return true;
|
|
|
7514 |
|
|
|
7515 |
}//if end
|
|
|
7516 |
";
|
|
|
7517 |
|
|
|
7518 |
}#if end
|
|
|
7519 |
|
|
|
7520 |
#反之
|
|
|
7521 |
else{
|
|
|
7522 |
|
|
|
7523 |
#設為空值
|
|
|
7524 |
$valNotSend="";
|
|
|
7525 |
|
|
|
7526 |
}#else end
|
|
|
7527 |
|
|
|
7528 |
#卸除不被 form::inputSelect 接受的參數
|
|
|
7529 |
unset($conf["valNotSend"]);
|
|
|
7530 |
|
|
|
7531 |
#如果有設置 formName
|
|
|
7532 |
if(isset($conf["formName"])){
|
|
|
7533 |
|
|
|
7534 |
#如果 formName 跟 name 一樣
|
|
|
7535 |
if($conf["formName"]===$conf["name"]){
|
|
|
7536 |
|
|
|
7537 |
#增加 formName 的名稱
|
|
|
7538 |
$conf["formName"]=$conf["formName"]."FormName";
|
|
|
7539 |
|
|
|
7540 |
}#if end
|
|
|
7541 |
|
|
|
7542 |
}#if end
|
|
|
7543 |
|
|
|
7544 |
#函式說明:
|
|
|
7545 |
#建立下拉式表單
|
|
|
7546 |
#回傳結果:
|
|
|
7547 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
7548 |
#$result["error"],錯誤訊息陣列.
|
|
|
7549 |
#$result["content"],語法內容.
|
|
|
7550 |
#$result["function"],設置當前執行的函式
|
|
|
7551 |
#必填參數:
|
|
|
7552 |
#$conf["name"],字串,爲該下拉式選單的名稱
|
|
|
7553 |
#$conf["name"]="";
|
|
|
7554 |
#$conf["sendValue"],陣列值,爲每個選項的實際傳送的數值,e.g. $sendValue = array("a","b","c","d","e");
|
|
|
7555 |
#$conf["sendValue"]=array();
|
|
|
7556 |
#可省略參數:
|
|
|
7557 |
#$conf["formName"]="";#該表單的名稱
|
|
|
7558 |
#$conf["outputValue"]=array();#爲陣列值,爲每個選項的實際顯示的數值, e.g. $outputValue = array("p","o","i","t","e");,如果沒有設定,則其值同$conf["sendValue"]。
|
|
|
7559 |
#$conf["viewCount"]="";#為一次要顯示幾個選項,預設爲顯示一個。
|
|
|
7560 |
#$conf["defaultValue"]="";#為預設選取那個選項,須爲$conf["sendValue"]其中的一個值。
|
|
|
7561 |
#$conf["class"]="";#爲要套用的class樣式,預設為 "__qbpwcf_inputSelect".
|
|
|
7562 |
#$conf["readOnly"],字串,內容是否唯獨,預設為"false",不唯獨,"true"為唯獨.
|
|
|
7563 |
#$conf["readOnly"]="true";
|
|
|
7564 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
7565 |
#$conf["comment"]="";
|
|
|
7566 |
#$conf["formAction"]="";#爲該下拉式表單要傳送到的位置
|
|
|
7567 |
#$conf["actionTarget"]="_self";#要如何接收網頁的迴應,預設爲_self
|
|
|
7568 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsAction"]參數。
|
|
|
7569 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.forms.formName.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
7570 |
#$conf["independentForm"]="true";#是否該下拉式選單就是一個完整的表單,"true"代表是,"false"代表不是,預設為"true"
|
|
|
7571 |
#$conf["hiddenVar"],字串陣列,隱藏的變數名稱陣列.
|
|
|
7572 |
#$conf["hiddenVar"]=array("");
|
|
|
7573 |
#$conf["hiddanVarValue"],字串陣列,隱藏變數的數值內容.
|
|
|
7574 |
#$conf["hiddenVarValue"]=array("");
|
|
|
7575 |
#$conf["fixedPosition"],字串,該下拉式選單是否要隨着滾軸滾動時固定在畫面上特定的位置,於設為"false",代表不固定,"true"代表要固定.
|
|
|
7576 |
#$conf["fixedPosition"]="true";
|
|
|
7577 |
#$conf["fixedPosition.fixedTop"],字串,該選單距離畫面頂部的固定距離,預設為0px.
|
|
|
7578 |
#$conf["fixedPosition.fixedTop"]="0px";
|
|
|
7579 |
#$conf["fixedPosition.fixedLeft"],字串,該選單距離畫面左方的固定距離.預設為0px.
|
|
|
7580 |
#$conf["fixedPosition.fixedLeft"]="0px";
|
|
|
7581 |
#$conf["fixedPosition.emptySpaceSize"],字串,表單位置要放置多寬的空白,於設為40px.
|
|
|
7582 |
#$conf["fixedPosition.emptySpaceSize"]="40px";
|
|
|
7583 |
#$conf["tableStartClass"]="__withoutBorder";#表格要採用的css樣式,預設為__withoutBorder,__withoutBorder為沒有框線的樣式,__withBorder為有樣式的表格.
|
|
|
7584 |
#$conf["tableStart"]="true";#爲是否要以<table>結尾,"true"表示"是"。也可以看作表格結束。
|
|
|
7585 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
7586 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
7587 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
7588 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
7589 |
#$conf["tableEnd"]="true";#爲是否要以</table>結尾,"true"表示"是"。也可以看作表格結束。
|
| 226 |
liveuser |
7590 |
|
| 3 |
liveuser |
7591 |
#如果有設置 $conf["dataFormId"]
|
|
|
7592 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
7593 |
|
| 3 |
liveuser |
7594 |
#設置 data-id 屬性
|
|
|
7595 |
$conf["dataFormId"]=$conf["dataFormId"];
|
| 226 |
liveuser |
7596 |
|
| 3 |
liveuser |
7597 |
}#if end
|
| 226 |
liveuser |
7598 |
|
| 3 |
liveuser |
7599 |
#備註:
|
|
|
7600 |
#$_SERVER["PHP_SELF"]為php檔案自己
|
|
|
7601 |
#參考資料來源:
|
|
|
7602 |
#http://stackoverflow.com/questions/833032/submit-is-not-a-function-in-javascript => form的id重複會導致"document.testForm.submit()"的javaScript語法出錯。
|
|
|
7603 |
#http://stackoverflow.com/questions/14622124/all-of-commands-for-submit-in-onchange-select-not-work => documents.forms.formName.submit() 才會將正確的表單送出。
|
|
|
7604 |
#http://stackoverflow.com/questions/368813/html-form-readonly-select-tag-input => 禁止改變選項,且也不會傳送該名稱表單
|
|
|
7605 |
#tableStart & tableEnd 要補上
|
|
|
7606 |
$inputSelect=form::inputSelect($conf);
|
|
|
7607 |
|
|
|
7608 |
#如果建立失敗
|
|
|
7609 |
if($inputSelect["content"]==="false"){
|
| 226 |
liveuser |
7610 |
|
| 3 |
liveuser |
7611 |
#設置執行失敗
|
|
|
7612 |
$result["status"]="false";
|
| 226 |
liveuser |
7613 |
|
| 3 |
liveuser |
7614 |
#設置錯誤訊息
|
|
|
7615 |
$result["error"]=$inputSelect;
|
| 226 |
liveuser |
7616 |
|
| 3 |
liveuser |
7617 |
#回傳結果
|
|
|
7618 |
return $result;
|
| 226 |
liveuser |
7619 |
|
| 3 |
liveuser |
7620 |
}#if end
|
|
|
7621 |
|
|
|
7622 |
#將$conf["name"]進行處理,避免js錯誤
|
|
|
7623 |
#函式說明:
|
|
|
7624 |
#處理字串避免網頁出錯
|
|
|
7625 |
#回傳結果:
|
|
|
7626 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
7627 |
#$result["function"],當前執行的函數.
|
|
|
7628 |
#$result["content"],爲處理好的字串.
|
|
|
7629 |
#$result["error"],錯誤訊息陣列.
|
|
|
7630 |
#必填參數:
|
|
|
7631 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
7632 |
#可省略的參數:
|
|
|
7633 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*","#","\"","-");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
7634 |
#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
|
|
|
7635 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
7636 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
7637 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
7638 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
7639 |
|
|
|
7640 |
#如果處理失敗
|
|
|
7641 |
if($correctCharacter["status"]==="false"){
|
| 226 |
liveuser |
7642 |
|
| 3 |
liveuser |
7643 |
#設置執行失敗
|
|
|
7644 |
$result["status"]="false";
|
| 226 |
liveuser |
7645 |
|
| 3 |
liveuser |
7646 |
#設置錯誤訊息
|
|
|
7647 |
$result["error"]=$correctCharacter;
|
| 226 |
liveuser |
7648 |
|
| 3 |
liveuser |
7649 |
#回傳結果
|
|
|
7650 |
return $result;
|
| 226 |
liveuser |
7651 |
|
| 3 |
liveuser |
7652 |
}#if end
|
|
|
7653 |
|
|
|
7654 |
#比對名稱是否符合規則
|
|
|
7655 |
if($conf["name"]!==$correctCharacter["content"]){
|
| 226 |
liveuser |
7656 |
|
| 3 |
liveuser |
7657 |
#設置執行失敗
|
|
|
7658 |
$result["status"]="false";
|
| 226 |
liveuser |
7659 |
|
| 3 |
liveuser |
7660 |
#設置錯誤訊息
|
|
|
7661 |
$result["error"]=$correctCharacter;
|
| 226 |
liveuser |
7662 |
|
| 3 |
liveuser |
7663 |
#設置額外錯誤訊息
|
|
|
7664 |
$result["error"][]=$conf["name"]." 不是合法的參數";
|
| 226 |
liveuser |
7665 |
|
| 3 |
liveuser |
7666 |
#回傳結果
|
|
|
7667 |
return $result;
|
| 226 |
liveuser |
7668 |
|
| 3 |
liveuser |
7669 |
}#if end
|
|
|
7670 |
|
|
|
7671 |
#另存表單的名稱
|
|
|
7672 |
$name=$conf["name"];
|
|
|
7673 |
|
|
|
7674 |
#設置用js傳送表單的動作
|
|
|
7675 |
$sendForm=
|
|
|
7676 |
"
|
|
|
7677 |
return false;
|
|
|
7678 |
";
|
|
|
7679 |
if(isset($conf["independentForm"])){
|
|
|
7680 |
$independentForm=$conf["independentForm"];
|
|
|
7681 |
if($independentForm==="true"){
|
|
|
7682 |
if(isset($conf["formName"]) && isset($conf["formAction"])){
|
|
|
7683 |
$sendForm=
|
|
|
7684 |
"
|
|
|
7685 |
document.forms.".$conf["formName"].".submit();
|
|
|
7686 |
";
|
|
|
7687 |
}#if end
|
|
|
7688 |
}#if end
|
|
|
7689 |
}#if end
|
|
|
7690 |
unset($conf);
|
|
|
7691 |
|
|
|
7692 |
#如果建立失敗
|
|
|
7693 |
if($inputSelect["status"]==="false"){
|
|
|
7694 |
|
|
|
7695 |
#設置執行失敗
|
|
|
7696 |
$result["status"]="false";
|
|
|
7697 |
|
|
|
7698 |
#設置錯誤訊息
|
|
|
7699 |
$result["error"]=$inputSelect;
|
|
|
7700 |
|
|
|
7701 |
#回傳結果
|
|
|
7702 |
return $result;
|
|
|
7703 |
|
|
|
7704 |
}#if end
|
|
|
7705 |
|
|
|
7706 |
#取得下拉式選單的語法
|
|
|
7707 |
$result["content"]=$inputSelect["content"];
|
|
|
7708 |
|
|
|
7709 |
#建立 scrollingList() 用的js
|
|
|
7710 |
#函式說明:
|
|
|
7711 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
7712 |
#回傳結果:
|
|
|
7713 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
7714 |
#$result["error"],錯誤訊息陣列
|
|
|
7715 |
#$result["function"],當前執行的函數名稱
|
|
|
7716 |
#$result["content"],要執行的javaScript語法
|
|
|
7717 |
#必填參數:
|
|
|
7718 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
7719 |
$conf["javaScript::toScript"]["script"]=
|
|
|
7720 |
"
|
|
|
7721 |
//取得下拉式選單元素
|
|
|
7722 |
var ".$name."=document.getElementById('".$name."');
|
|
|
7723 |
|
|
|
7724 |
//將下拉式選單綁定'mousedown'事件,
|
|
|
7725 |
var scrollingListMousedownEvent = ".$name.".addEventListener('mousedown',function(event){
|
|
|
7726 |
|
|
|
7727 |
//debug
|
|
|
7728 |
console.log('mousedown event start');
|
|
|
7729 |
|
|
|
7730 |
//取消預設按下滑鼠的效果
|
|
|
7731 |
event.preventDefault();
|
|
|
7732 |
|
|
|
7733 |
//停止擴散事件
|
|
|
7734 |
event.stopPropagation();
|
|
|
7735 |
|
|
|
7736 |
//debug
|
|
|
7737 |
console.log('mousedown event end');
|
|
|
7738 |
|
|
|
7739 |
});
|
|
|
7740 |
|
|
|
7741 |
//將下拉式選單綁定'mouseup'事件,
|
|
|
7742 |
var scrollingListMouseupEvent = ".$name.".addEventListener('mouseup',function(event){
|
|
|
7743 |
|
|
|
7744 |
//debug
|
|
|
7745 |
console.log('mouseup event start');
|
|
|
7746 |
|
|
|
7747 |
//取消預設滑鼠放開的效果
|
|
|
7748 |
event.preventDefault();
|
|
|
7749 |
|
|
|
7750 |
//停止擴散事件
|
|
|
7751 |
event.stopPropagation();
|
|
|
7752 |
|
|
|
7753 |
//debug
|
|
|
7754 |
console.log('mouseup event end');
|
|
|
7755 |
|
|
|
7756 |
});
|
|
|
7757 |
|
|
|
7758 |
//將下拉式選單綁定'ontouchstart'事件,
|
|
|
7759 |
var scrollingListTouchStartEvent = ".$name.".addEventListener('ontouchstart',function(event){
|
|
|
7760 |
|
|
|
7761 |
//debug
|
|
|
7762 |
console.log('ontouch event start');
|
|
|
7763 |
|
|
|
7764 |
//取消預設觸碰的效果
|
|
|
7765 |
event.preventDefault();
|
|
|
7766 |
|
|
|
7767 |
//停止擴散事件
|
|
|
7768 |
event.stopPropagation();
|
|
|
7769 |
|
|
|
7770 |
//debug
|
|
|
7771 |
console.log('ontouch event end');
|
|
|
7772 |
|
|
|
7773 |
});
|
|
|
7774 |
|
|
|
7775 |
//將下拉式選單綁定'ontouchend'事件,
|
|
|
7776 |
var scrollingListTouchEndEvent = ".$name.".addEventListener('ontouchend',function(event){
|
|
|
7777 |
|
|
|
7778 |
//debug
|
|
|
7779 |
console.log('ontouch event start');
|
|
|
7780 |
|
|
|
7781 |
//取消預設觸碰的效果
|
|
|
7782 |
event.preventDefault();
|
|
|
7783 |
|
|
|
7784 |
//停止擴散事件
|
|
|
7785 |
event.stopPropagation();
|
|
|
7786 |
|
|
|
7787 |
//debug
|
|
|
7788 |
console.log('ontouch event end');
|
|
|
7789 |
|
|
|
7790 |
});
|
|
|
7791 |
|
|
|
7792 |
//將下拉式選單綁定'click'事件,觸發時要執行物件__qbpwcf_scrollingList的函數
|
|
|
7793 |
var scrollingListClickEvent = ".$name.".addEventListener('click',function(event){
|
|
|
7794 |
|
|
|
7795 |
//debug
|
|
|
7796 |
console.log(event);
|
|
|
7797 |
|
|
|
7798 |
//取消預設點擊的效果
|
|
|
7799 |
event.preventDefault();
|
|
|
7800 |
|
|
|
7801 |
//取得下拉式選單內容
|
|
|
7802 |
var inputSelect=event.target;
|
|
|
7803 |
|
|
|
7804 |
//debug
|
|
|
7805 |
//console.log(inputSelect);
|
|
|
7806 |
|
|
|
7807 |
//讓下拉式選單趕緊隱藏
|
|
|
7808 |
inputSelect.style.opacity='0';
|
|
|
7809 |
|
|
|
7810 |
//取得選項的數目
|
|
|
7811 |
var opLen=inputSelect.options.length;
|
|
|
7812 |
|
|
|
7813 |
//debug
|
|
|
7814 |
//console.log(opLen);
|
|
|
7815 |
|
|
|
7816 |
//新增覆蓋全螢幕的div
|
|
|
7817 |
var root=document.createElement('div');
|
|
|
7818 |
|
|
|
7819 |
//設置最外層div的id
|
|
|
7820 |
root.setAttribute('id','scrollingListRootDiv');
|
|
|
7821 |
|
|
|
7822 |
//設置最外層div的樣式
|
|
|
7823 |
root.setAttribute('class','__qbpwcf_scrollingListRootDiv');
|
|
|
7824 |
|
|
|
7825 |
//新增為了將不足divForMiddle可見高度的選項們置中的div
|
|
|
7826 |
var divForMiddle=document.createElement('div');
|
|
|
7827 |
|
|
|
7828 |
//設置為了上下置中的div樣式
|
|
|
7829 |
divForMiddle.setAttribute('class','__qbpwcf_scrollingListOutterDiv');
|
|
|
7830 |
|
|
|
7831 |
//初始化記錄選擇的選項index
|
|
|
7832 |
var selectedOptionIndex=-1;
|
|
|
7833 |
|
|
|
7834 |
//針對每個選項
|
|
|
7835 |
for(var i=0;i< opLen;i++){
|
|
|
7836 |
|
|
|
7837 |
//debug
|
|
|
7838 |
//console.log(i);
|
|
|
7839 |
|
|
|
7840 |
//debug
|
|
|
7841 |
//console.log(inputSelect.options[i].value);
|
|
|
7842 |
|
|
|
7843 |
//取得選項實際數值
|
|
|
7844 |
var opVal=inputSelect.options[i].value;
|
|
|
7845 |
|
|
|
7846 |
//debug
|
|
|
7847 |
//console.log(inputSelect.options[i].innerHTML);
|
|
|
7848 |
|
|
|
7849 |
//取得選項顯示名稱
|
|
|
7850 |
var opShow=inputSelect.options[i].innerHTML;
|
|
|
7851 |
|
|
|
7852 |
//debug
|
|
|
7853 |
//console.log(opVal+'=>'+opShow);
|
|
|
7854 |
|
|
|
7855 |
//建立選項的div
|
|
|
7856 |
var opDiv=document.createElement('div');
|
|
|
7857 |
|
|
|
7858 |
//設置選項div的class
|
|
|
7859 |
opDiv.setAttribute('class','__qbpwcf_inputSelect __qbpwcf_inputSelect_hover');
|
|
|
7860 |
|
|
|
7861 |
//設置選項div的數值內容
|
|
|
7862 |
opDiv.setAttribute('data-val',opVal);
|
|
|
7863 |
|
|
|
7864 |
//設置選項div的編號(從0開始)
|
|
|
7865 |
opDiv.setAttribute('data-no',i);
|
|
|
7866 |
|
|
|
7867 |
//若該選項有 'selected' 屬性
|
|
|
7868 |
if(inputSelect.options[i].attributes['selected']!==undefined){
|
|
|
7869 |
|
|
|
7870 |
//debug
|
|
|
7871 |
//console.log('第'+opDiv.attributes['data-no'].value+'個選項為現有選擇的項目');
|
|
|
7872 |
|
|
|
7873 |
//標記該選項為原先所選擇的項目
|
|
|
7874 |
opDiv.setAttribute('data-selected','true');
|
|
|
7875 |
|
|
|
7876 |
//記錄原先所選擇的項目的index
|
|
|
7877 |
var selectedOptionIndex=parseInt(opDiv.attributes['data-no'].value);
|
|
|
7878 |
|
|
|
7879 |
}//if end
|
|
|
7880 |
|
|
|
7881 |
//建立選項名稱文字節點
|
|
|
7882 |
var textnode = document.createTextNode(opShow);
|
|
|
7883 |
|
|
|
7884 |
//將文字放進選項的div
|
|
|
7885 |
opDiv.appendChild(textnode);
|
|
|
7886 |
|
|
|
7887 |
//將選項放進為了上下左右置中的div
|
|
|
7888 |
divForMiddle.appendChild(opDiv);
|
|
|
7889 |
|
|
|
7890 |
}//for end
|
|
|
7891 |
|
|
|
7892 |
//新增為了上下左右置中的div
|
|
|
7893 |
var divForCenterMiddle=document.createElement('div');
|
|
|
7894 |
|
|
|
7895 |
//設置為了內部元素都上下左右置中的div樣式
|
|
|
7896 |
//divForCenterMiddle.setAttribute('style','background-color:white;position:fixed;top:15%;left:15%;height:70%;width:70%;overflow-y:auto;border:1px solid black;');
|
|
|
7897 |
divForCenterMiddle.setAttribute('class','__qbpwcf_scrollingListInnerDiv');
|
|
|
7898 |
|
|
|
7899 |
//將上下置中的選項們放進可以上下左右置中的div
|
|
|
7900 |
divForCenterMiddle.appendChild(divForMiddle);
|
|
|
7901 |
|
|
|
7902 |
//將選項放進最外層的div
|
|
|
7903 |
root.appendChild(divForCenterMiddle);
|
|
|
7904 |
|
|
|
7905 |
//將整個div放到body裡面
|
|
|
7906 |
document.body.appendChild(root);
|
|
|
7907 |
|
|
|
7908 |
//調整滾軸表單的置中效果
|
|
|
7909 |
scrollingListMiddleFunction();
|
|
|
7910 |
|
|
|
7911 |
//取得所有選項
|
|
|
7912 |
var allOptions=document.getElementsByClassName('__qbpwcf_inputSelect_hover');
|
|
|
7913 |
|
|
|
7914 |
//debug
|
|
|
7915 |
//console.log(allOptions);
|
|
|
7916 |
|
|
|
7917 |
//移動滾軸讓原本選擇的選項盡量置中
|
|
|
7918 |
|
|
|
7919 |
//原先選擇的項目索引
|
|
|
7920 |
//console.log(selectedOptionIndex);
|
|
|
7921 |
|
|
|
7922 |
//opLen 選項的數目
|
|
|
7923 |
//console.log(opLen);
|
|
|
7924 |
|
|
|
7925 |
//取得選單的滾軸上端位置
|
|
|
7926 |
//var scrollingListScrollTop=document.getElementById('scrollingListRootDiv').children[0].scrollTop;
|
|
|
7927 |
|
|
|
7928 |
//debug
|
|
|
7929 |
//console.log(scrollingListScrollTop);
|
|
|
7930 |
|
|
|
7931 |
//取得選單的滾軸上端位置最大值
|
|
|
7932 |
var scrollingListScrollTopMax=document.getElementById('scrollingListRootDiv').children[0].scrollTopMax;
|
|
|
7933 |
|
|
|
7934 |
//debug
|
|
|
7935 |
//console.log(scrollingListScrollTopMax);
|
|
|
7936 |
|
|
|
7937 |
//取得選單的可見高度
|
|
|
7938 |
//var scrollingListViewHeight=document.getElementById('scrollingListRootDiv').children[0].clientHeight;
|
|
|
7939 |
|
|
|
7940 |
//debug
|
|
|
7941 |
//console.log(scrollingListViewHeight);
|
|
|
7942 |
|
|
|
7943 |
//取得選單含滾軸的總高度
|
|
|
7944 |
//var scrollingListScrollHeight=document.getElementById('scrollingListRootDiv').children[0].scrollHeight;
|
|
|
7945 |
|
|
|
7946 |
//debug
|
|
|
7947 |
//console.log(scrollingListScrollHeight);
|
|
|
7948 |
|
|
|
7949 |
//debug
|
|
|
7950 |
//console.log(selectedOptionIndex);
|
|
|
7951 |
|
|
|
7952 |
//如果有滾軸
|
|
|
7953 |
if(scrollingListScrollTopMax!==0){
|
|
|
7954 |
|
|
|
7955 |
//如果是第一個選項
|
|
|
7956 |
if(selectedOptionIndex===0){
|
|
|
7957 |
|
|
|
7958 |
//滾軸拉到最上面
|
|
|
7959 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=0;
|
|
|
7960 |
|
|
|
7961 |
//debug
|
|
|
7962 |
//console.log('scrollingListScrollTop=0');
|
|
|
7963 |
|
|
|
7964 |
}//if end
|
|
|
7965 |
|
|
|
7966 |
//如果之前選擇的選項索引剛好等於 opLen/2
|
|
|
7967 |
else if(((selectedOptionIndex+1)===(opLen/2))){
|
|
|
7968 |
|
|
|
7969 |
//debug
|
|
|
7970 |
//console.log('之前選擇的選項索引剛好等於一半');
|
|
|
7971 |
|
|
|
7972 |
//取得新的滾軸高度
|
|
|
7973 |
var newScrollTop=scrollingListScrollTopMax/2;
|
|
|
7974 |
|
|
|
7975 |
//設置滾軸的上端位置
|
|
|
7976 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
7977 |
|
|
|
7978 |
//debug
|
|
|
7979 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
7980 |
|
|
|
7981 |
}//if end
|
|
|
7982 |
|
|
|
7983 |
//如果之前選擇的選項索引小於半
|
|
|
7984 |
else if((selectedOptionIndex+1)<(opLen/2)){
|
|
|
7985 |
|
|
|
7986 |
//debug
|
|
|
7987 |
//console.log('之前選擇的選項索引未過半,加幾個'+(selectedOptionIndex+1).toString());
|
|
|
7988 |
|
|
|
7989 |
//取得新的滾軸高度
|
|
|
7990 |
var newScrollTop=scrollingListScrollTopMax/opLen*selectedOptionIndex+1;
|
|
|
7991 |
|
|
|
7992 |
//設置滾軸的上端位置
|
|
|
7993 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
7994 |
|
|
|
7995 |
//debug
|
|
|
7996 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
7997 |
|
|
|
7998 |
}//if end
|
|
|
7999 |
|
|
|
8000 |
//如果之前選擇的選項索引過半
|
|
|
8001 |
else if((selectedOptionIndex+1)>(opLen/2)){
|
|
|
8002 |
|
|
|
8003 |
//debug
|
|
|
8004 |
//console.log('之前選擇的選項索引過半,減幾個'+(opLen-selectedOptionIndex-1).toString());
|
|
|
8005 |
|
|
|
8006 |
//取得新的滾軸高度
|
|
|
8007 |
var newScrollTop=scrollingListScrollTopMax-scrollingListScrollTopMax/opLen*(opLen-selectedOptionIndex-1);
|
|
|
8008 |
|
|
|
8009 |
//設置滾軸的上端位置
|
|
|
8010 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
8011 |
|
|
|
8012 |
//debug
|
|
|
8013 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
8014 |
|
|
|
8015 |
}//if end
|
|
|
8016 |
|
|
|
8017 |
//如果是最後一個選項
|
|
|
8018 |
else if(selectedOptionIndex===opLen){
|
|
|
8019 |
|
|
|
8020 |
//如果是最後一個選項
|
|
|
8021 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=scrollingListScrollTopMax;
|
|
|
8022 |
|
|
|
8023 |
//debug
|
|
|
8024 |
//console.log('scrollingListScrollTop='+scrollingListScrollTopMax);
|
|
|
8025 |
|
|
|
8026 |
}//if end
|
|
|
8027 |
|
|
|
8028 |
//不應該跑到的地方
|
|
|
8029 |
else{
|
|
|
8030 |
|
|
|
8031 |
//debug
|
|
|
8032 |
console.log('error occur!');
|
|
|
8033 |
|
|
|
8034 |
}//else end
|
|
|
8035 |
|
|
|
8036 |
}//if end
|
|
|
8037 |
|
|
|
8038 |
//針對每個選項
|
|
|
8039 |
for(var i=0;i<allOptions.length;i++){
|
|
|
8040 |
|
|
|
8041 |
//綁定所有選項的 'click' 事件
|
|
|
8042 |
allOptions[i].addEventListener('click',function(event){
|
|
|
8043 |
|
|
|
8044 |
//debug
|
|
|
8045 |
//console.log(event);
|
|
|
8046 |
|
|
|
8047 |
//取得點擊到的選項
|
|
|
8048 |
var clickedOption=event.target;
|
|
|
8049 |
|
|
|
8050 |
//debug
|
|
|
8051 |
//console.log(clickedOption);
|
|
|
8052 |
|
|
|
8053 |
//取得點擊到的選項數值
|
|
|
8054 |
var clickedValue=clickedOption.attributes['data-val'].value;
|
|
|
8055 |
|
|
|
8056 |
//debug
|
|
|
8057 |
//console.log(clickedValue);
|
|
|
8058 |
|
|
|
8059 |
//取得點擊到的選項編號
|
|
|
8060 |
var clickedNo=clickedOption.attributes['data-no'].value;
|
|
|
8061 |
|
|
|
8062 |
//debug
|
|
|
8063 |
//console.log(clickedNo);
|
|
|
8064 |
|
|
|
8065 |
//取得點擊到的選項名稱
|
|
|
8066 |
var clickedName=clickedOption.innerHTML;
|
|
|
8067 |
|
|
|
8068 |
//debug
|
|
|
8069 |
//console.log(clickedName);
|
|
|
8070 |
|
|
|
8071 |
//修改下拉式選單選則的數值
|
|
|
8072 |
|
|
|
8073 |
//針對每個下拉式選單實際的選項
|
|
|
8074 |
for(var j=0;j<allOptions.length;j++){
|
|
|
8075 |
|
|
|
8076 |
//移除 selected 屬性
|
|
|
8077 |
inputSelect.options[j].removeAttribute('selected');
|
|
|
8078 |
|
|
|
8079 |
}//for end
|
|
|
8080 |
|
|
|
8081 |
//debug
|
|
|
8082 |
//console.log('設置 inputSelect.options['+clickedNo+'] 的 selected 屬性');
|
|
|
8083 |
|
|
|
8084 |
//設置點選的選項的 selected 屬性
|
|
|
8085 |
inputSelect.options[clickedNo].setAttribute('selected','');
|
|
|
8086 |
|
|
|
8087 |
//取得要移除 scrolling list 的 div
|
|
|
8088 |
var divToDel=document.getElementById('scrollingListRootDiv');
|
|
|
8089 |
|
|
|
8090 |
//debug
|
|
|
8091 |
//console.log(divTodel);
|
|
|
8092 |
|
|
|
8093 |
//移除 scrolling list div
|
|
|
8094 |
divToDel.remove();
|
|
|
8095 |
|
|
|
8096 |
//復原下拉式選單
|
|
|
8097 |
inputSelect.style.opacity='unset';
|
|
|
8098 |
|
|
|
8099 |
".$valNotSend."
|
|
|
8100 |
|
|
|
8101 |
//馬上傳送表單
|
|
|
8102 |
sendForm();
|
|
|
8103 |
|
|
|
8104 |
});//function end
|
|
|
8105 |
|
|
|
8106 |
}//for end
|
|
|
8107 |
|
|
|
8108 |
//建立 close icon
|
|
|
8109 |
closeIcon();
|
|
|
8110 |
|
|
|
8111 |
});
|
|
|
8112 |
|
|
|
8113 |
//停止擴散事件
|
|
|
8114 |
event.stopPropagation();
|
|
|
8115 |
";
|
|
|
8116 |
#可省略參數:
|
|
|
8117 |
#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
8118 |
#$conf["onReady"]="true";
|
|
|
8119 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
8120 |
$conf["javaScript::toScript"]["globalJs"][]=
|
|
|
8121 |
"
|
|
|
8122 |
//取得下拉式選單元素
|
|
|
8123 |
var ".$name."=document.getElementById('".$name."');
|
|
|
8124 |
";
|
|
|
8125 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
8126 |
$conf["javaScript::toScript"]["jsFunciton"][]=
|
|
|
8127 |
"
|
|
|
8128 |
//馬上傳送表單
|
|
|
8129 |
function sendForm(){
|
|
|
8130 |
|
|
|
8131 |
".$sendForm."
|
|
|
8132 |
|
|
|
8133 |
}//function sendForm end
|
|
|
8134 |
|
|
|
8135 |
//關閉 list 的按鈕與事件
|
|
|
8136 |
function closeIcon(){
|
|
|
8137 |
|
|
|
8138 |
//建立 close icon
|
|
|
8139 |
var closeIcon = document.createElement('img');
|
|
|
8140 |
|
|
|
8141 |
//設置 close icon 的樣式
|
|
|
8142 |
closeIcon.style['position']='fixed';
|
|
|
8143 |
closeIcon.style['top']='15%';
|
|
|
8144 |
closeIcon.style['left']='85%';
|
|
|
8145 |
closeIcon.style['width']='5%';
|
|
|
8146 |
closeIcon.style['min-width']='30px';
|
|
|
8147 |
closeIcon.style['max-width']='50px';
|
|
|
8148 |
closeIcon.style['cursor']='pointer';
|
|
|
8149 |
|
|
|
8150 |
//設置 close icon img 的屬性
|
|
|
8151 |
closeIcon.src='".$closeIcon."';
|
|
|
8152 |
|
|
|
8153 |
//設置 close icon img 的id
|
|
|
8154 |
closeIcon.setAttribute('id','qbpwcfScrollingListCloseIcon');
|
|
|
8155 |
|
|
|
8156 |
//取得 scrollingList 的 root div
|
|
|
8157 |
var slrd=document.getElementById('scrollingListRootDiv');
|
|
|
8158 |
|
|
|
8159 |
//將 close icon outer div 放到 scrollingList 的 root div 裡面
|
|
|
8160 |
slrd.appendChild(closeIcon);
|
|
|
8161 |
|
|
|
8162 |
//取得 close icon img
|
|
|
8163 |
var closeIcon=document.getElementById('qbpwcfScrollingListCloseIcon');
|
|
|
8164 |
|
|
|
8165 |
//新增 close icon img 的點擊事件
|
|
|
8166 |
closeIcon.addEventListener('click',function(){
|
|
|
8167 |
|
|
|
8168 |
//取得要移除 scrolling list 的 div
|
|
|
8169 |
var divToDel=document.getElementById('scrollingListRootDiv');
|
|
|
8170 |
|
|
|
8171 |
//debug
|
|
|
8172 |
//console.log(divTodel);
|
|
|
8173 |
|
|
|
8174 |
//移除 scrolling list div
|
|
|
8175 |
divToDel.remove();
|
|
|
8176 |
|
|
|
8177 |
//復原下拉式選單
|
|
|
8178 |
".$name.".style.opacity='unset';
|
|
|
8179 |
|
|
|
8180 |
});
|
|
|
8181 |
|
|
|
8182 |
}//function closeIcon end
|
|
|
8183 |
";
|
|
|
8184 |
#參考資料:
|
|
|
8185 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
8186 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
8187 |
unset($conf["javaScript::toScript"]);
|
|
|
8188 |
|
|
|
8189 |
#如果建立js失敗
|
|
|
8190 |
if($toScript["status"]==="false"){
|
|
|
8191 |
|
|
|
8192 |
#設置執行失敗
|
|
|
8193 |
$result["status"]="false";
|
|
|
8194 |
|
|
|
8195 |
#設置錯誤訊息
|
|
|
8196 |
$result["error"]=$toScript;
|
|
|
8197 |
|
|
|
8198 |
#回傳結果
|
|
|
8199 |
return $result;
|
|
|
8200 |
|
|
|
8201 |
}#if end
|
|
|
8202 |
|
|
|
8203 |
#串接scrollingList用的js
|
|
|
8204 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
8205 |
|
|
|
8206 |
#設置執行正常
|
|
|
8207 |
$result["status"]="true";
|
|
|
8208 |
|
|
|
8209 |
#回傳結果
|
|
|
8210 |
return $result;
|
|
|
8211 |
|
|
|
8212 |
}#function scrollingList end
|
|
|
8213 |
|
|
|
8214 |
/*
|
|
|
8215 |
#函式說明:
|
|
|
8216 |
#建立滾軸式表單取代傳統下拉式選單,選項會用全螢幕的div區塊呈現.
|
|
|
8217 |
#回傳結果:
|
|
|
8218 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
8219 |
#$result["error"],錯誤訊息陣列.
|
|
|
8220 |
#$result["content"],語法內容.
|
|
|
8221 |
#$result["function"],設置當前執行的函式
|
|
|
8222 |
#必填參數:
|
|
|
8223 |
#$conf["name"],字串,爲該下拉式選單的元素的id.
|
|
|
8224 |
$conf["name"]="";
|
|
|
8225 |
#$conf["sendValue"],陣列值,爲每個選項的實際傳送的數值,e.g. $sendValue = array("a","b","c","d","e");
|
|
|
8226 |
$conf["sendValue"]=array();
|
|
|
8227 |
#可省略參數:
|
|
|
8228 |
#$conf["outputValue"],字串陣列,爲每個選項的實際顯示的數值, e.g. $outputValue = array("p","o","i","t","e");,如果沒有設定,則其值同$conf["sendValue"]。
|
|
|
8229 |
#$conf["outputValue"]=array();
|
|
|
8230 |
#$conf["defaultValue"],字串,為預設選取那個選項,須爲$conf["sendValue"]其中的一個值。
|
|
|
8231 |
#$conf["defaultValue"]="";
|
|
|
8232 |
#$conf["class"],字串,爲要套用的class樣式,預設為 "__qbpwcf_inputSelect".
|
|
|
8233 |
#$conf["class"]="";
|
|
|
8234 |
#$conf["readOnly"],字串,內容是否唯獨,預設為"false",不唯獨,"true"為唯獨.
|
|
|
8235 |
#$conf["readOnly"]="true";
|
|
|
8236 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
8237 |
#$conf["comment"]="";
|
|
|
8238 |
#$conf["formAction"],字串,爲該下拉式表單要傳送到的位置.
|
|
|
8239 |
#$conf["formAction"]="";
|
|
|
8240 |
#$conf["independentForm"],字串,是否該下拉式選單就是一個完整的表單,"true"代表是,"false"代表不是,預設為"true".
|
|
|
8241 |
#$conf["independentForm"]="false";
|
|
|
8242 |
#$conf["hiddenVar"],字串陣列,隱藏的變數名稱陣列.
|
|
|
8243 |
#$conf["hiddenVar"]=array("");
|
|
|
8244 |
#$conf["hiddanVarValue"],字串陣列,隱藏變數的數值內容.
|
|
|
8245 |
#$conf["hiddenVarValue"]=array("");
|
|
|
8246 |
#$conf["closeIcon"],字串,關閉滾軸選單的按鈕圖示,預設為"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K".
|
|
|
8247 |
#$conf["closeIcon"]="";
|
|
|
8248 |
#$conf["valNotSend"],字串,如果選擇的選項數值為何,就不傳送表單.
|
|
|
8249 |
#$conf["valNotSend"]="";
|
|
|
8250 |
#$conf["newLineOption"],字串,"true"代表要建立換行的div選單元素,"false"代表要建立不換行的 span 元素,與設為"false".
|
|
|
8251 |
#$conf["newLineOption"]="false";
|
|
|
8252 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
8253 |
#$conf["dataFormId"]="";
|
|
|
8254 |
#參考資料:
|
|
|
8255 |
#無.
|
|
|
8256 |
#備註:
|
| 176 |
liveuser |
8257 |
#建議用javaScript::qbpwcfScript中的window.qbpwcf.form.fakeScrollingList來實作.
|
| 3 |
liveuser |
8258 |
*/
|
|
|
8259 |
public static function fakeScrollingList(&$conf){
|
|
|
8260 |
|
|
|
8261 |
#初始化要回傳的結果
|
|
|
8262 |
$result=array();
|
|
|
8263 |
|
|
|
8264 |
#取得當前執行的函數名稱
|
|
|
8265 |
$result["function"]=__FUNCTION__;
|
|
|
8266 |
|
|
|
8267 |
#如果沒有參數
|
|
|
8268 |
if(func_num_args()==0){
|
|
|
8269 |
|
|
|
8270 |
#設置執行失敗
|
|
|
8271 |
$result["status"]="false";
|
|
|
8272 |
|
|
|
8273 |
#設置執行錯誤訊息
|
|
|
8274 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
8275 |
|
|
|
8276 |
#回傳結果
|
|
|
8277 |
return $result;
|
|
|
8278 |
|
|
|
8279 |
}#if end
|
|
|
8280 |
|
|
|
8281 |
#取得參數
|
|
|
8282 |
$result["argu"]=$conf;
|
|
|
8283 |
|
|
|
8284 |
#如果 $conf 不為陣列
|
|
|
8285 |
if(gettype($conf)!=="array"){
|
|
|
8286 |
|
|
|
8287 |
#設置執行失敗
|
|
|
8288 |
$result["status"]="false";
|
|
|
8289 |
|
|
|
8290 |
#設置執行錯誤訊息
|
|
|
8291 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
8292 |
|
|
|
8293 |
#如果傳入的參數為 null
|
|
|
8294 |
if($conf===null){
|
|
|
8295 |
|
|
|
8296 |
#設置執行錯誤訊息
|
|
|
8297 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
8298 |
|
|
|
8299 |
}#if end
|
|
|
8300 |
|
|
|
8301 |
#回傳結果
|
|
|
8302 |
return $result;
|
|
|
8303 |
|
|
|
8304 |
}#if end
|
|
|
8305 |
|
|
|
8306 |
#如果有設置close icon
|
|
|
8307 |
if(isset($conf["closeIcon"])){
|
|
|
8308 |
|
|
|
8309 |
#另存路徑
|
|
|
8310 |
$closeIcon=$conf["closeIcon"];
|
|
|
8311 |
|
|
|
8312 |
#卸除不被 form::inputSelect 接受的參數
|
|
|
8313 |
unset($conf["closeIcon"]);
|
|
|
8314 |
|
|
|
8315 |
}#if end
|
|
|
8316 |
|
|
|
8317 |
#反之
|
|
|
8318 |
else{
|
|
|
8319 |
|
|
|
8320 |
#用預設的 close icon
|
|
|
8321 |
$closeIcon="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K";
|
|
|
8322 |
|
|
|
8323 |
}#else end
|
|
|
8324 |
|
|
|
8325 |
#如果有設置 $conf["valNotSend"]
|
|
|
8326 |
if(isset($conf["valNotSend"])){
|
|
|
8327 |
|
|
|
8328 |
#設置不傳送表單的js語法
|
|
|
8329 |
$valNotSend=
|
|
|
8330 |
"
|
|
|
8331 |
//如果表單的數值為 ".$conf["valNotSend"]."
|
|
|
8332 |
if(clickedValue==='".$conf["valNotSend"]."'){
|
|
|
8333 |
|
|
|
8334 |
//結束動作
|
|
|
8335 |
return true;
|
|
|
8336 |
|
|
|
8337 |
}//if end
|
|
|
8338 |
";
|
|
|
8339 |
|
|
|
8340 |
}#if end
|
|
|
8341 |
|
|
|
8342 |
#反之
|
|
|
8343 |
else{
|
|
|
8344 |
|
|
|
8345 |
#設為空值
|
|
|
8346 |
$valNotSend="";
|
|
|
8347 |
|
|
|
8348 |
}#else end
|
|
|
8349 |
|
|
|
8350 |
#卸除不被 form::inputSelect 接受的參數
|
|
|
8351 |
unset($conf["valNotSend"]);
|
|
|
8352 |
|
|
|
8353 |
#檢查參數
|
|
|
8354 |
#函式說明:
|
|
|
8355 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
8356 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
8357 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
8358 |
#$result["function"],當前執行的函式名稱.
|
|
|
8359 |
#$result["argu"],設置給予的參數.
|
|
|
8360 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
8361 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
8362 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
8363 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
8364 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
8365 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
8366 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
8367 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
8368 |
#必填寫的參數:
|
|
|
8369 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
8370 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
8371 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
8372 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
8373 |
#可以省略的參數:
|
|
|
8374 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
8375 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name","sendValue");
|
|
|
8376 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
8377 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
|
|
|
8378 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
8379 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
8380 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
8381 |
$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("name","sendValue");
|
|
|
8382 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
8383 |
#$conf["canBeEmpty"]=array();
|
|
|
8384 |
#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
8385 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("outputValue","defaultValue","newLineOption","formAction","hiddenVar","hiddenVarValue");
|
|
|
8386 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
8387 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("outputValue","defaultValue","newLineOption","formAction","hiddenVar","hiddenVarValue","comment","class","readOnly","dataFormId");
|
|
|
8388 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
8389 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","string","array","array","string","string","string","string");
|
|
|
8390 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
8391 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"sendValue\"]",null,"false",null,null,null,null,"__qbpwcf_inputSelect","false",null);
|
|
|
8392 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
8393 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
8394 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
8395 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
8396 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
8397 |
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("hiddenVar","hiddenVarValue");
|
|
|
8398 |
#參考資料:
|
|
|
8399 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
8400 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
8401 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
8402 |
|
|
|
8403 |
#如果檢查失敗
|
|
|
8404 |
if($checkArguments["status"]==="false"){
|
|
|
8405 |
|
|
|
8406 |
#設置執行失敗
|
|
|
8407 |
$result["status"]="false";
|
|
|
8408 |
|
|
|
8409 |
#設置執行錯誤訊息
|
|
|
8410 |
$result["error"]=$checkArguments;
|
|
|
8411 |
|
|
|
8412 |
#回傳結果
|
|
|
8413 |
return $result;
|
|
|
8414 |
|
|
|
8415 |
}#if end
|
|
|
8416 |
|
|
|
8417 |
#如果檢查失敗
|
|
|
8418 |
if($checkArguments["passed"]==="false"){
|
|
|
8419 |
|
|
|
8420 |
#設置執行失敗
|
|
|
8421 |
$result["status"]="false";
|
|
|
8422 |
|
|
|
8423 |
#設置執行錯誤訊息
|
|
|
8424 |
$result["error"]=$checkArguments;
|
|
|
8425 |
|
|
|
8426 |
#回傳結果
|
|
|
8427 |
return $result;
|
|
|
8428 |
|
|
|
8429 |
}#if end
|
|
|
8430 |
|
|
|
8431 |
#設置傳送表單的參數
|
|
|
8432 |
$sendForm="";
|
|
|
8433 |
|
|
|
8434 |
#如果有設置 $conf["formAction"]
|
|
|
8435 |
if(isset($conf["formAction"])){
|
|
|
8436 |
|
|
|
8437 |
#預設隱藏的變數為""
|
|
|
8438 |
$hiddenVar="";
|
|
|
8439 |
|
|
|
8440 |
#如果有設置隱藏的參數 hiddenVar 與 hiddenVarValue
|
|
|
8441 |
if(isset($conf["hiddenVar"]) && isset($conf["hiddenVarValue"])){
|
|
|
8442 |
|
|
|
8443 |
#加密要傳送的隱藏表單資料
|
|
|
8444 |
$hiddenVar=base64_encode(json_encode(array("hiddenVar"=>$conf["hiddenVar"],"hiddenVarValue"=>$conf["hiddenVarValue"])));
|
|
|
8445 |
|
|
|
8446 |
}#if end
|
|
|
8447 |
|
|
|
8448 |
#設置傳送表單的參數
|
|
|
8449 |
$sendForm=
|
|
|
8450 |
"
|
|
|
8451 |
//馬上傳送表單
|
|
|
8452 |
window.form_fakeScrollingList_sendForm_".$conf["name"]."('".$conf["name"]."',oriOptionsInfo.sendValue[clickedNo],'".$conf["formAction"]."','".$hiddenVar."');
|
|
|
8453 |
";
|
|
|
8454 |
|
|
|
8455 |
}#if end
|
|
|
8456 |
|
|
|
8457 |
#儲存選項呈現的元素變數
|
|
|
8458 |
$optionOutEle="";
|
|
|
8459 |
|
|
|
8460 |
#如果沒有指定預設的選項
|
|
|
8461 |
if(!isset($conf["defaultValue"])){
|
|
|
8462 |
|
|
|
8463 |
#預設為第一個選項的內容
|
|
|
8464 |
$conf["defaultValue"]=$conf["sendValue"][0];
|
|
|
8465 |
|
|
|
8466 |
}#if end
|
|
|
8467 |
|
|
|
8468 |
#取得預設選項對應的顯示內容
|
|
|
8469 |
#函式說明:
|
|
|
8470 |
#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
|
|
|
8471 |
#回傳的結果:
|
|
|
8472 |
#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
|
|
|
8473 |
#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
|
|
|
8474 |
#$result["error"],錯誤訊息
|
|
|
8475 |
#$result["function"],當前執行的函數名稱
|
|
|
8476 |
#$result["argv"],使用的參數
|
|
|
8477 |
#$result["equalVarName"],相等的變數名稱或key.
|
|
|
8478 |
#$result["equalVarValue"],相等的變數數值內容.
|
|
|
8479 |
#必填參數:
|
|
|
8480 |
$conf["search::getEqualVar"]["conditionElement"]=$conf["defaultValue"];#條件元素,要等於的元素內容.
|
|
|
8481 |
$conf["search::getEqualVar"]["compareElements"]=$conf["sendValue"];#要比對的陣列變數內容.
|
|
|
8482 |
$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
|
|
|
8483 |
unset($conf["search::getEqualVar"]);
|
|
|
8484 |
|
|
|
8485 |
#如果執失敗
|
|
|
8486 |
if($getEqualVar["status"]==="false"){
|
|
|
8487 |
|
|
|
8488 |
#設置執行失敗
|
|
|
8489 |
$result["status"]="false";
|
|
|
8490 |
|
|
|
8491 |
#設置執行錯誤訊息
|
|
|
8492 |
$result["error"]=$getEqualVar;
|
|
|
8493 |
|
|
|
8494 |
#回傳結果
|
|
|
8495 |
return $result;
|
|
|
8496 |
|
|
|
8497 |
}#if end
|
|
|
8498 |
|
|
|
8499 |
#如果沒有對應的選項
|
|
|
8500 |
if($getEqualVar["founded"]==="false"){
|
|
|
8501 |
|
|
|
8502 |
#設置執行失敗
|
|
|
8503 |
$result["status"]="false";
|
|
|
8504 |
|
|
|
8505 |
#設置執行錯誤訊息
|
|
|
8506 |
$result["error"]=$getEqualVar;
|
|
|
8507 |
|
|
|
8508 |
#回傳結果
|
|
|
8509 |
return $result;
|
|
|
8510 |
|
|
|
8511 |
}#if end
|
|
|
8512 |
|
|
|
8513 |
#取得預設選項的顯示內容
|
|
|
8514 |
$defaultShowVal=$conf["outputValue"][$getEqualVar["equalVarName"]];
|
|
|
8515 |
|
|
|
8516 |
#fake scrolling list data var name
|
|
|
8517 |
$fakeScrollingListDataVar="qbpwcf-fakeScrollingList-options";
|
|
|
8518 |
|
|
|
8519 |
#判斷 $conf["newLineOption"] 參數的內容
|
|
|
8520 |
switch($conf["newLineOption"]){
|
|
|
8521 |
|
|
|
8522 |
#如果要建立 div 選項
|
|
|
8523 |
case "true":
|
|
|
8524 |
|
|
|
8525 |
#函式說明:
|
|
|
8526 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
8527 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
8528 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
8529 |
#$result["error"],陣列,錯訊訊息.
|
|
|
8530 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
8531 |
#必填參數:
|
|
|
8532 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
8533 |
$conf["css::divSection"]["contentArray"]=array($defaultShowVal);
|
|
|
8534 |
#可省略參數
|
|
|
8535 |
#$conf["id"],字串,div區塊的id.
|
|
|
8536 |
$conf["css::divSection"]["id"]=$conf["name"];
|
|
|
8537 |
#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.
|
|
|
8538 |
#$conf["styleAttr"]=array();
|
|
|
8539 |
#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.
|
|
|
8540 |
#$conf["styleVal"]=array();
|
|
|
8541 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
8542 |
$conf["css::divSection"]["class"]=$conf["class"];
|
|
|
8543 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容.
|
|
|
8544 |
#$conf["title"]=array();
|
|
|
8545 |
#$conf["oneScreenSize"],字串,div區塊是否要占一個螢幕的大小,預設為"false"不設定,"true"為設定成一個螢幕的大小.
|
|
|
8546 |
#$conf["oneScreenSize"]="false";
|
|
|
8547 |
#$conf["textAlignCenter"],字串,div區塊是否要置中,預設為$conf["oneScreenSize"]的值,"false"為不置中,"true"代表要置中.
|
|
|
8548 |
#$conf["textAlignCenter"]="";
|
|
|
8549 |
#$conf["css::divSection"["data"],字串陣列,每個要設置的屬性data內容,例如array("option1"=>"A","option2"=>"B"),預設不使用.
|
|
|
8550 |
$conf["css::divSection"]["data"]=array($fakeScrollingListDataVar=>base64_encode(json_encode(array("outputValue"=>$conf["outputValue"],"sendValue"=>$conf["sendValue"],"defaultValue"=>$conf["defaultValue"],"defaultShowVal"=>$defaultShowVal))));
|
| 226 |
liveuser |
8551 |
|
| 3 |
liveuser |
8552 |
#如果有設置 $conf["dataFormId"]
|
|
|
8553 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
8554 |
|
| 3 |
liveuser |
8555 |
#設置 data-form-id 屬性
|
|
|
8556 |
$conf["css::divSection"]["data"]["form-id"]=$conf["dataFormId"];
|
| 226 |
liveuser |
8557 |
|
| 3 |
liveuser |
8558 |
}#if end
|
| 226 |
liveuser |
8559 |
|
| 3 |
liveuser |
8560 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
8561 |
unset($conf["css::divSection"]);
|
|
|
8562 |
|
|
|
8563 |
#如果建立div區段失敗
|
|
|
8564 |
if($divSection["status"]==="false"){
|
|
|
8565 |
|
|
|
8566 |
#設置執行失敗
|
|
|
8567 |
$result["status"]="false";
|
|
|
8568 |
|
|
|
8569 |
#設置執行錯誤訊息
|
|
|
8570 |
$result["error"]=$divSection;
|
|
|
8571 |
|
|
|
8572 |
#回傳結果
|
|
|
8573 |
return $result;
|
|
|
8574 |
|
|
|
8575 |
}#if end
|
|
|
8576 |
|
|
|
8577 |
#取得div的內容
|
|
|
8578 |
$optionOutEle=$optionOutEle.$divSection["content"];
|
|
|
8579 |
|
|
|
8580 |
#跳出switch
|
|
|
8581 |
break;
|
|
|
8582 |
|
|
|
8583 |
#如果要建立 span 選項
|
|
|
8584 |
case "false":
|
|
|
8585 |
|
|
|
8586 |
#函式說明:
|
|
|
8587 |
#<span>區塊,裡面可以指定css的class樣式,可以指定提示文字,若要使用移動的css樣式,請改用divSection函數.
|
|
|
8588 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
8589 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
8590 |
#$result["error"],陣列,錯訊訊息.
|
|
|
8591 |
#$result["content"],字串,含有<span>標籤的內容.
|
|
|
8592 |
#必填參數:
|
|
|
8593 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
8594 |
$conf["css::spanSection"]["contentArray"]=array($defaultShowVal);
|
|
|
8595 |
#可省略參數
|
|
|
8596 |
#$conf["id"],字串,span區塊的id.
|
|
|
8597 |
$conf["css::spanSection"]["id"]=$conf["name"];
|
|
|
8598 |
#$conf["class"],字串,span區段要套用的css樣式.
|
|
|
8599 |
$conf["css::spanSection"]["class"]=$conf["class"];
|
|
|
8600 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
8601 |
#$conf["title"]=array();
|
|
|
8602 |
#$conf["css::spanSection"]["data"],字串陣列,每個data屬性名稱為數值內容,例如array("a"=>"A","b"=>"B")
|
|
|
8603 |
$conf["css::spanSection"]["data"]=array($fakeScrollingListDataVar=>base64_encode(json_encode(array("outputValue"=>$conf["outputValue"],"sendValue"=>$conf["sendValue"],"defaultValue"=>$conf["defaultValue"],"defaultShowVal"=>$defaultShowVal))));
|
| 226 |
liveuser |
8604 |
|
| 3 |
liveuser |
8605 |
#如果有設置 $conf["dataFormId"]
|
|
|
8606 |
if(isset($conf["dataFormId"])){
|
| 226 |
liveuser |
8607 |
|
| 3 |
liveuser |
8608 |
#設置 data-form-id 屬性
|
|
|
8609 |
$conf["css::spanSection"]["data"]["form-id"]=$conf["dataFormId"];
|
| 226 |
liveuser |
8610 |
|
| 3 |
liveuser |
8611 |
}#if end
|
| 226 |
liveuser |
8612 |
|
| 3 |
liveuser |
8613 |
$spanSection=css::spanSection($conf["css::spanSection"]);
|
|
|
8614 |
unset($conf["css::spanSection"]);
|
|
|
8615 |
|
|
|
8616 |
#如果建立span區段失敗
|
|
|
8617 |
if($spanSection["status"]==="false"){
|
|
|
8618 |
|
|
|
8619 |
#設置執行失敗
|
|
|
8620 |
$result["status"]="false";
|
|
|
8621 |
|
|
|
8622 |
#設置執行錯誤訊息
|
|
|
8623 |
$result["error"]=$spanSection;
|
|
|
8624 |
|
|
|
8625 |
#回傳結果
|
|
|
8626 |
return $result;
|
|
|
8627 |
|
|
|
8628 |
}#if end
|
|
|
8629 |
|
|
|
8630 |
#取得span的內容
|
|
|
8631 |
$optionOutEle=$optionOutEle.$spanSection["content"];
|
|
|
8632 |
|
|
|
8633 |
#跳出switch
|
|
|
8634 |
break;
|
|
|
8635 |
|
|
|
8636 |
#其他數值的內容
|
|
|
8637 |
default :
|
|
|
8638 |
|
|
|
8639 |
#設置不換行
|
|
|
8640 |
$conf["newLineOption"]="false";
|
|
|
8641 |
|
|
|
8642 |
#跳出switch
|
|
|
8643 |
break;
|
|
|
8644 |
|
|
|
8645 |
}#switch end
|
|
|
8646 |
|
|
|
8647 |
#如果有設置提示文字
|
|
|
8648 |
if(isset($conf["comment"])){
|
|
|
8649 |
|
|
|
8650 |
#設置提示文字
|
|
|
8651 |
#函式說明:
|
|
|
8652 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
8653 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
8654 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
8655 |
#$result["error"],陣列,錯訊訊息.
|
|
|
8656 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
8657 |
#必填參數:
|
|
|
8658 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
8659 |
$conf["css::divSection"]["contentArray"]=array($conf["comment"]);
|
|
|
8660 |
#可省略參數
|
|
|
8661 |
#$conf["id"],字串,div區塊的id.
|
|
|
8662 |
$conf["css::divSection"]["id"]=$conf["name"]."_comment";
|
|
|
8663 |
#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.
|
|
|
8664 |
#$conf["styleAttr"]=array();
|
|
|
8665 |
#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.
|
|
|
8666 |
#$conf["styleVal"]=array();
|
|
|
8667 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
8668 |
#$conf["class"]="";
|
|
|
8669 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容.
|
|
|
8670 |
#$conf["title"]=array();
|
|
|
8671 |
#$conf["oneScreenSize"],字串,div區塊是否要占一個螢幕的大小,預設為"false"不設定,"true"為設定成一個螢幕的大小.
|
|
|
8672 |
#$conf["oneScreenSize"]="false";
|
|
|
8673 |
#$conf["textAlignCenter"],字串,div區塊是否要置中,預設為$conf["oneScreenSize"]的值,"false"為不置中,"true"代表要置中.
|
|
|
8674 |
#$conf["textAlignCenter"]="";
|
|
|
8675 |
#$conf["css::divSection"["data"],字串陣列,每個要設置的屬性data內容,例如array("option1"=>"A","option2"=>"B"),預設不使用.
|
|
|
8676 |
#$conf["css::divSection"]["data"]=array($fakeScrollingListDataVar=>base64_encode(json_encode(array("outputValue"=>$conf["outputValue"],"sendValue"=>$conf["sendValue"],"defaultValue"=>$conf["defaultValue"],"defaultShowVal"=>$defaultShowVal))));
|
|
|
8677 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
8678 |
unset($conf["css::divSection"]);
|
|
|
8679 |
|
|
|
8680 |
#如果建立div區段失敗
|
|
|
8681 |
if($divSection["status"]==="false"){
|
|
|
8682 |
|
|
|
8683 |
#設置執行失敗
|
|
|
8684 |
$result["status"]="false";
|
|
|
8685 |
|
|
|
8686 |
#設置執行錯誤訊息
|
|
|
8687 |
$result["error"]=$divSection;
|
|
|
8688 |
|
|
|
8689 |
#回傳結果
|
|
|
8690 |
return $result;
|
|
|
8691 |
|
|
|
8692 |
}#if end
|
|
|
8693 |
|
|
|
8694 |
#取得div的內容
|
|
|
8695 |
$optionOutEle=$divSection["content"].$optionOutEle;
|
|
|
8696 |
|
|
|
8697 |
}#if end
|
|
|
8698 |
|
|
|
8699 |
#設置語法內容
|
|
|
8700 |
$result["content"]=&$optionOutEle;
|
|
|
8701 |
|
|
|
8702 |
#取得表單的名稱
|
|
|
8703 |
$name=$conf["name"];
|
|
|
8704 |
|
|
|
8705 |
#如果 readOnly
|
|
|
8706 |
if($conf["readOnly"]==="true"){
|
| 226 |
liveuser |
8707 |
|
| 3 |
liveuser |
8708 |
#設置執行正常
|
|
|
8709 |
$result["status"]="true";
|
|
|
8710 |
|
|
|
8711 |
#回傳結果
|
| 176 |
liveuser |
8712 |
return $result;
|
| 226 |
liveuser |
8713 |
|
| 3 |
liveuser |
8714 |
}#if end
|
|
|
8715 |
|
|
|
8716 |
#函式說明:
|
|
|
8717 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
8718 |
#回傳結果:
|
|
|
8719 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
8720 |
#$result["error"],錯誤訊息陣列
|
|
|
8721 |
#$result["function"],當前執行的函數名稱
|
|
|
8722 |
#$result["content"],要執行的javaScript語法
|
|
|
8723 |
#必填參數:
|
|
|
8724 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
8725 |
$conf["javaScript::toScript"]["script"]="";
|
|
|
8726 |
#可省略參數:
|
|
|
8727 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
8728 |
#$conf["onReady"]="true";
|
|
|
8729 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
8730 |
$conf["javaScript::toScript"]["globalJs"][]=
|
|
|
8731 |
"
|
|
|
8732 |
var ".$name."=document.getElementById('".$name."');
|
|
|
8733 |
|
|
|
8734 |
//將下拉式選單綁定'click'事件,觸發時要執行物件__qbpwcf_scrollingList的函數
|
|
|
8735 |
".$name.".addEventListener('click',function(event){
|
|
|
8736 |
|
|
|
8737 |
//debug
|
|
|
8738 |
console.log(event);
|
|
|
8739 |
|
|
|
8740 |
//取消預設點擊的效果
|
|
|
8741 |
event.preventDefault();
|
|
|
8742 |
|
|
|
8743 |
//取得下拉式選單內容
|
|
|
8744 |
var inputSelect=event.target;
|
|
|
8745 |
|
|
|
8746 |
//debug
|
|
|
8747 |
//console.log(inputSelect);
|
|
|
8748 |
|
|
|
8749 |
//讓下拉式選單趕緊隱藏
|
|
|
8750 |
inputSelect.style.opacity='0';
|
|
|
8751 |
|
|
|
8752 |
//解析選項的資訊
|
|
|
8753 |
var optionsInfo=JSON.parse(atob(inputSelect.dataset.qbpwcfFakescrollinglistOptions));
|
|
|
8754 |
|
|
|
8755 |
//取得選項的數目
|
|
|
8756 |
var opLen=optionsInfo.sendValue.length;
|
|
|
8757 |
|
|
|
8758 |
//新增覆蓋全螢幕的div
|
|
|
8759 |
var root=document.createElement('div');
|
|
|
8760 |
|
|
|
8761 |
//設置最外層div的id
|
|
|
8762 |
root.setAttribute('id','scrollingListRootDiv');
|
|
|
8763 |
|
|
|
8764 |
//設置最外層div的樣式
|
|
|
8765 |
root.setAttribute('class','__qbpwcf_scrollingListRootDiv');
|
|
|
8766 |
|
|
|
8767 |
//新增為了將不足divForMiddle可見高度的選項們置中的div
|
|
|
8768 |
var divForMiddle=document.createElement('div');
|
|
|
8769 |
|
|
|
8770 |
//設置為了上下置中的div樣式
|
|
|
8771 |
divForMiddle.setAttribute('class','__qbpwcf_scrollingListOutterDiv');
|
|
|
8772 |
|
|
|
8773 |
//初始化記錄選擇的選項index
|
|
|
8774 |
var selectedOptionIndex=-1;
|
|
|
8775 |
|
|
|
8776 |
//針對每個選項
|
|
|
8777 |
for(var i=0;i<opLen;i++){
|
|
|
8778 |
|
|
|
8779 |
//debug
|
|
|
8780 |
//console.log(i);
|
|
|
8781 |
|
|
|
8782 |
//debug
|
|
|
8783 |
//console.log(optionsInfo.sendValue[i]);
|
|
|
8784 |
|
|
|
8785 |
//取得選項實際數值
|
|
|
8786 |
var opVal=optionsInfo.sendValue[i];
|
|
|
8787 |
|
|
|
8788 |
//debug
|
|
|
8789 |
//console.log(optionsInfo.showValue[i]);
|
|
|
8790 |
|
|
|
8791 |
//取得選項顯示名稱
|
|
|
8792 |
//var opShow=optionsInfo.sendValue[i];
|
|
|
8793 |
var opShow=optionsInfo.outputValue[i];
|
|
|
8794 |
|
|
|
8795 |
//debug
|
|
|
8796 |
//console.log(opVal+'=>'+opShow);
|
|
|
8797 |
|
|
|
8798 |
//建立選項的div
|
|
|
8799 |
var opDiv=document.createElement('div');
|
|
|
8800 |
|
|
|
8801 |
//讓選項上下置中
|
|
|
8802 |
opDiv.style.paddingTop='15px';
|
|
|
8803 |
|
|
|
8804 |
//設置選項div的class
|
|
|
8805 |
opDiv.setAttribute('class','__qbpwcf_inputSelect __qbpwcf_inputSelect_hover');
|
|
|
8806 |
|
|
|
8807 |
//設置選項div的數值內容
|
|
|
8808 |
opDiv.setAttribute('data-val',opVal);
|
|
|
8809 |
|
|
|
8810 |
//設置選項div的編號(從0開始)
|
|
|
8811 |
opDiv.setAttribute('data-no',i);
|
| 226 |
liveuser |
8812 |
|
| 3 |
liveuser |
8813 |
//設置裡面的文字要換行的時候改用...表示
|
|
|
8814 |
opDiv.style.whiteSpace='nowrap';
|
| 176 |
liveuser |
8815 |
opDiv.style.width='100%';
|
| 3 |
liveuser |
8816 |
opDiv.style.overflow='hidden';
|
|
|
8817 |
opDiv.style.textOverflow='ellipsis';
|
| 226 |
liveuser |
8818 |
|
| 3 |
liveuser |
8819 |
//偶數欄位
|
|
|
8820 |
if(i%2===0)
|
|
|
8821 |
{
|
|
|
8822 |
//設置選項div底色為藍色
|
|
|
8823 |
opDiv.style.backgroundColor='CCCCFF';
|
|
|
8824 |
}
|
|
|
8825 |
//反之為奇數欄位
|
|
|
8826 |
else
|
|
|
8827 |
{
|
|
|
8828 |
//設置選項div底色為紅色
|
|
|
8829 |
opDiv.style.backgroundColor='FFCCCC';
|
|
|
8830 |
}
|
|
|
8831 |
|
|
|
8832 |
//解析選項的資訊
|
|
|
8833 |
var oriOptionsInfo=JSON.parse(atob(inputSelect.dataset.qbpwcfFakescrollinglistOptions));
|
|
|
8834 |
|
|
|
8835 |
//若該選項為當前選擇的項目
|
|
|
8836 |
if(oriOptionsInfo.sendValue[i]===inputSelect.innerText){
|
|
|
8837 |
|
|
|
8838 |
//debug
|
|
|
8839 |
//console.log('第'+opDiv.attributes['data-no'].value+'個選項為現有選擇的項目');
|
|
|
8840 |
|
|
|
8841 |
//標記該選項為原先所選擇的項目
|
|
|
8842 |
opDiv.setAttribute('data-selected','true');
|
|
|
8843 |
|
|
|
8844 |
//記錄原先所選擇的項目的index
|
|
|
8845 |
var selectedOptionIndex=parseInt(opDiv.attributes['data-no'].value);
|
|
|
8846 |
|
|
|
8847 |
}//if end
|
|
|
8848 |
|
|
|
8849 |
//建立選項名稱文字節點
|
|
|
8850 |
var textnode = document.createTextNode(opShow);
|
|
|
8851 |
|
|
|
8852 |
//將文字放進選項的div
|
|
|
8853 |
opDiv.appendChild(textnode);
|
|
|
8854 |
|
|
|
8855 |
//將選項放進為了上下左右置中的div
|
|
|
8856 |
divForMiddle.appendChild(opDiv);
|
|
|
8857 |
|
|
|
8858 |
}//for end
|
|
|
8859 |
|
|
|
8860 |
//新增為了上下左右置中的div
|
|
|
8861 |
var divForCenterMiddle=document.createElement('div');
|
|
|
8862 |
|
|
|
8863 |
//設置為了內部元素都上下左右置中的div樣式
|
|
|
8864 |
divForCenterMiddle.setAttribute('class','__qbpwcf_scrollingListInnerDiv');
|
|
|
8865 |
|
|
|
8866 |
//將上下置中的選項們放進可以上下左右置中的div
|
|
|
8867 |
divForCenterMiddle.appendChild(divForMiddle);
|
|
|
8868 |
|
|
|
8869 |
//將選項放進最外層的div
|
|
|
8870 |
root.appendChild(divForCenterMiddle);
|
|
|
8871 |
|
|
|
8872 |
//將整個div放到body裡面
|
|
|
8873 |
document.body.appendChild(root);
|
|
|
8874 |
|
|
|
8875 |
//調整滾軸表單的置中效果
|
|
|
8876 |
scrollingListMiddleFunction();
|
|
|
8877 |
|
|
|
8878 |
//取得所有選項
|
|
|
8879 |
var allOptions=document.getElementsByClassName('__qbpwcf_inputSelect_hover');
|
|
|
8880 |
|
|
|
8881 |
//debug
|
|
|
8882 |
//console.log(allOptions);
|
|
|
8883 |
|
|
|
8884 |
//移動滾軸讓原本選擇的選項盡量置中
|
|
|
8885 |
|
|
|
8886 |
//原先選擇的項目索引
|
|
|
8887 |
//console.log(selectedOptionIndex);
|
|
|
8888 |
|
|
|
8889 |
//opLen 選項的數目
|
|
|
8890 |
//console.log(opLen);
|
|
|
8891 |
|
|
|
8892 |
//取得選單的滾軸上端位置
|
|
|
8893 |
//var scrollingListScrollTop=document.getElementById('scrollingListRootDiv').children[0].scrollTop;
|
|
|
8894 |
|
|
|
8895 |
//debug
|
|
|
8896 |
//console.log(scrollingListScrollTop);
|
|
|
8897 |
|
|
|
8898 |
//取得選單的滾軸上端位置最大值
|
|
|
8899 |
var scrollingListScrollTopMax=document.getElementById('scrollingListRootDiv').children[0].scrollTopMax;
|
|
|
8900 |
|
|
|
8901 |
//debug
|
|
|
8902 |
//console.log(scrollingListScrollTopMax);
|
|
|
8903 |
|
|
|
8904 |
//取得選單的可見高度
|
|
|
8905 |
//var scrollingListViewHeight=document.getElementById('scrollingListRootDiv').children[0].clientHeight;
|
|
|
8906 |
|
|
|
8907 |
//debug
|
|
|
8908 |
//console.log(scrollingListViewHeight);
|
|
|
8909 |
|
|
|
8910 |
//取得選單含滾軸的總高度
|
|
|
8911 |
//var scrollingListScrollHeight=document.getElementById('scrollingListRootDiv').children[0].scrollHeight;
|
|
|
8912 |
|
|
|
8913 |
//debug
|
|
|
8914 |
//console.log(scrollingListScrollHeight);
|
|
|
8915 |
|
|
|
8916 |
//debug
|
|
|
8917 |
//console.log(selectedOptionIndex);
|
|
|
8918 |
|
|
|
8919 |
//如果有滾軸
|
|
|
8920 |
if(scrollingListScrollTopMax!==0){
|
|
|
8921 |
|
|
|
8922 |
//如果是第一個選項
|
|
|
8923 |
if(selectedOptionIndex===0){
|
|
|
8924 |
|
|
|
8925 |
//滾軸拉到最上面
|
|
|
8926 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=0;
|
|
|
8927 |
|
|
|
8928 |
//debug
|
|
|
8929 |
//console.log('scrollingListScrollTop=0');
|
|
|
8930 |
|
|
|
8931 |
}//if end
|
|
|
8932 |
|
|
|
8933 |
//如果之前選擇的選項索引剛好等於 opLen/2
|
|
|
8934 |
else if(((selectedOptionIndex+1)===(opLen/2))){
|
|
|
8935 |
|
|
|
8936 |
//debug
|
|
|
8937 |
//console.log('之前選擇的選項索引剛好等於一半');
|
|
|
8938 |
|
|
|
8939 |
//取得新的滾軸高度
|
|
|
8940 |
var newScrollTop=scrollingListScrollTopMax/2;
|
|
|
8941 |
|
|
|
8942 |
//設置滾軸的上端位置
|
|
|
8943 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
8944 |
|
|
|
8945 |
//debug
|
|
|
8946 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
8947 |
|
|
|
8948 |
}//if end
|
|
|
8949 |
|
|
|
8950 |
//如果之前選擇的選項索引小於半
|
|
|
8951 |
else if((selectedOptionIndex+1)<(opLen/2)){
|
|
|
8952 |
|
|
|
8953 |
//debug
|
|
|
8954 |
//console.log('之前選擇的選項索引未過半,加幾個'+(selectedOptionIndex+1).toString());
|
|
|
8955 |
|
|
|
8956 |
//取得新的滾軸高度
|
|
|
8957 |
var newScrollTop=scrollingListScrollTopMax/opLen*selectedOptionIndex+1;
|
|
|
8958 |
|
|
|
8959 |
//設置滾軸的上端位置
|
|
|
8960 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
8961 |
|
|
|
8962 |
//debug
|
|
|
8963 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
8964 |
|
|
|
8965 |
}//if end
|
|
|
8966 |
|
|
|
8967 |
//如果之前選擇的選項索引過半
|
|
|
8968 |
else if((selectedOptionIndex+1)>(opLen/2)){
|
|
|
8969 |
|
|
|
8970 |
//debug
|
|
|
8971 |
//console.log('之前選擇的選項索引過半,減幾個'+(opLen-selectedOptionIndex-1).toString());
|
|
|
8972 |
|
|
|
8973 |
//取得新的滾軸高度
|
|
|
8974 |
var newScrollTop=scrollingListScrollTopMax-scrollingListScrollTopMax/opLen*(opLen-selectedOptionIndex-1);
|
|
|
8975 |
|
|
|
8976 |
//設置滾軸的上端位置
|
|
|
8977 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;
|
|
|
8978 |
|
|
|
8979 |
//debug
|
|
|
8980 |
//console.log('scrollingListScrollTop='+newScrollTop.toString());
|
|
|
8981 |
|
|
|
8982 |
}//if end
|
|
|
8983 |
|
|
|
8984 |
//如果是最後一個選項
|
|
|
8985 |
else if(selectedOptionIndex===opLen){
|
|
|
8986 |
|
|
|
8987 |
//如果是最後一個選項
|
|
|
8988 |
document.getElementById('scrollingListRootDiv').children[0].scrollTop=scrollingListScrollTopMax;
|
|
|
8989 |
|
|
|
8990 |
//debug
|
|
|
8991 |
//console.log('scrollingListScrollTop='+scrollingListScrollTopMax);
|
|
|
8992 |
|
|
|
8993 |
}//if end
|
|
|
8994 |
|
|
|
8995 |
//不應該跑到的地方
|
|
|
8996 |
else{
|
|
|
8997 |
|
|
|
8998 |
//debug
|
|
|
8999 |
console.log('error occur!');
|
|
|
9000 |
|
|
|
9001 |
}//else end
|
|
|
9002 |
|
|
|
9003 |
}//if end
|
|
|
9004 |
|
|
|
9005 |
//針對每個選項
|
|
|
9006 |
for(var i=0;i<allOptions.length;i++){
|
|
|
9007 |
|
|
|
9008 |
//綁定所有選項的 'click' 事件
|
|
|
9009 |
allOptions[i].addEventListener('click',function(event){
|
|
|
9010 |
|
|
|
9011 |
//debug
|
|
|
9012 |
//console.log(event);
|
|
|
9013 |
|
|
|
9014 |
//取得點擊到的選項
|
|
|
9015 |
var clickedOption=event.target;
|
|
|
9016 |
|
|
|
9017 |
//debug
|
|
|
9018 |
//console.log(clickedOption);
|
|
|
9019 |
|
|
|
9020 |
//取得點擊到的選項數值
|
|
|
9021 |
var clickedValue=clickedOption.attributes['data-val'].value;
|
|
|
9022 |
|
|
|
9023 |
//debug
|
|
|
9024 |
//console.log(clickedValue);
|
|
|
9025 |
|
|
|
9026 |
//取得點擊到的選項編號
|
|
|
9027 |
var clickedNo=clickedOption.attributes['data-no'].value;
|
|
|
9028 |
|
|
|
9029 |
//debug
|
|
|
9030 |
//console.log(clickedNo);
|
|
|
9031 |
|
|
|
9032 |
//取得點擊到的選項名稱
|
|
|
9033 |
var clickedName=clickedOption.innerHTML;
|
|
|
9034 |
|
|
|
9035 |
//debug
|
|
|
9036 |
//console.log(clickedName);
|
|
|
9037 |
|
|
|
9038 |
//解析選項的資訊
|
|
|
9039 |
var oriOptionsInfo=JSON.parse(atob(inputSelect.dataset.qbpwcfFakescrollinglistOptions));
|
|
|
9040 |
|
|
|
9041 |
//取得顯示元素
|
|
|
9042 |
var ".$name."=document.getElementById('".$name."');
|
|
|
9043 |
|
|
|
9044 |
//更新選取的選項數值顯示內容
|
|
|
9045 |
".$name.".innerText=oriOptionsInfo.outputValue[clickedNo];
|
|
|
9046 |
|
|
|
9047 |
//取消透明效果
|
|
|
9048 |
".$name.".style.opacity='unset';
|
|
|
9049 |
|
|
|
9050 |
//取得要移除 scrolling list 的 div
|
|
|
9051 |
var divToDel=document.getElementById('scrollingListRootDiv');
|
|
|
9052 |
|
|
|
9053 |
//debug
|
|
|
9054 |
//console.log(divTodel);
|
|
|
9055 |
|
|
|
9056 |
//移除 scrolling list div
|
|
|
9057 |
divToDel.remove();
|
|
|
9058 |
|
|
|
9059 |
//復原下拉式選單
|
|
|
9060 |
inputSelect.style.opacity='unset';
|
|
|
9061 |
|
|
|
9062 |
".$valNotSend."
|
|
|
9063 |
|
|
|
9064 |
".$sendForm."
|
|
|
9065 |
|
|
|
9066 |
});//function end
|
|
|
9067 |
|
|
|
9068 |
}//for end
|
|
|
9069 |
|
|
|
9070 |
//建立 close icon
|
|
|
9071 |
window.form_fakeScrollingList_closeIcon_".$conf["name"]."(".$name.");
|
|
|
9072 |
});
|
|
|
9073 |
";
|
|
|
9074 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
9075 |
$conf["javaScript::toScript"]["jsFunciton"][]=
|
|
|
9076 |
"
|
|
|
9077 |
//馬上傳送表單,key代表要傳送的元素名稱,val代表元素對應的數值內容,rev代表要傳送到哪個地方.
|
|
|
9078 |
window.form_fakeScrollingList_sendForm_".$conf["name"]."=function(key,val,rev,hidvar){
|
|
|
9079 |
|
|
|
9080 |
//debug
|
|
|
9081 |
console.log('prepare send form');
|
|
|
9082 |
|
|
|
9083 |
//new XMLHttpRequest
|
|
|
9084 |
xmlhttp=new XMLHttpRequest();
|
|
|
9085 |
|
|
|
9086 |
//set response type to html document
|
|
|
9087 |
xmlhttp.responseType='document';
|
|
|
9088 |
|
|
|
9089 |
//當運行狀態改變時
|
|
|
9090 |
xmlhttp.onreadystatechange=function(){
|
|
|
9091 |
|
|
|
9092 |
//如果狀態為4且response code為200
|
|
|
9093 |
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
|
|
9094 |
|
|
|
9095 |
//將回應進行處理
|
|
|
9096 |
res=xmlhttp.response;
|
|
|
9097 |
|
|
|
9098 |
//debug
|
|
|
9099 |
console.log(res);
|
|
|
9100 |
console.log('url:'+res.URL);
|
|
|
9101 |
console.log('title:'+res.title);
|
|
|
9102 |
|
|
|
9103 |
//將回應刷新到當前頁面
|
| 226 |
liveuser |
9104 |
|
| 3 |
liveuser |
9105 |
//no use?
|
|
|
9106 |
stateObj={};
|
| 226 |
liveuser |
9107 |
|
| 3 |
liveuser |
9108 |
//取得新 title
|
|
|
9109 |
title=res.title;
|
| 226 |
liveuser |
9110 |
|
| 3 |
liveuser |
9111 |
//取得新 url
|
|
|
9112 |
newUrl=res.URL;
|
| 226 |
liveuser |
9113 |
|
| 3 |
liveuser |
9114 |
//更新網頁標題與網址
|
|
|
9115 |
//參考資料:https://developer.mozilla.org/en-US/docs/Web/API/History_API
|
|
|
9116 |
history.pushState(stateObj, title, newUrl);
|
|
|
9117 |
|
|
|
9118 |
//開新文件
|
|
|
9119 |
document.open('text/html',true);
|
|
|
9120 |
|
|
|
9121 |
//寫入取得的完整回應
|
|
|
9122 |
document.write(res.all[0].outerHTML);
|
|
|
9123 |
|
|
|
9124 |
//結束輸出
|
|
|
9125 |
document.close();
|
|
|
9126 |
|
|
|
9127 |
}//if end
|
|
|
9128 |
|
|
|
9129 |
}//function end
|
|
|
9130 |
|
|
|
9131 |
//建立表單物件
|
|
|
9132 |
var formData = new FormData();
|
|
|
9133 |
|
|
|
9134 |
//新增表單的名稱與對應的數值
|
|
|
9135 |
formData.append(key,val);
|
|
|
9136 |
|
|
|
9137 |
//如果有隱藏的表單變數
|
|
|
9138 |
if(hidvar!==''){
|
|
|
9139 |
|
|
|
9140 |
//解析隱藏的表單變數
|
|
|
9141 |
hidvar=JSON.parse(atob(hidvar));
|
|
|
9142 |
|
|
|
9143 |
//另存隱藏變數的名稱
|
|
|
9144 |
hiddenVar=hidvar.hiddenVar;
|
|
|
9145 |
|
|
|
9146 |
//另存隱藏變數對應的數值內容
|
|
|
9147 |
hiddenVarValue=hidvar.hiddenVarValue;
|
|
|
9148 |
|
|
|
9149 |
//取得隱藏變數的數量
|
|
|
9150 |
hiddenVarCount=hiddenVar.length;
|
|
|
9151 |
|
|
|
9152 |
//針對每個隱藏的表單變數
|
|
|
9153 |
for(i=0;i<hiddenVarCount;i++){
|
|
|
9154 |
|
|
|
9155 |
//新增表單隱藏變數的名稱與對應的數值
|
|
|
9156 |
formData.append(hiddenVar[i],hiddenVarValue[i]);
|
|
|
9157 |
|
|
|
9158 |
}//for end
|
|
|
9159 |
|
|
|
9160 |
}//if end
|
|
|
9161 |
|
|
|
9162 |
//用 post 傳送到 rev
|
|
|
9163 |
xmlhttp.open('POST',rev);
|
|
|
9164 |
|
|
|
9165 |
//set ajax header
|
|
|
9166 |
xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');
|
|
|
9167 |
|
|
|
9168 |
//傳送數值
|
|
|
9169 |
xmlhttp.send(formData);
|
|
|
9170 |
|
|
|
9171 |
//debug
|
|
|
9172 |
console.log('form sended');
|
|
|
9173 |
|
|
|
9174 |
}//function sendForm end
|
|
|
9175 |
|
|
|
9176 |
//關閉 list 的按鈕與事件
|
|
|
9177 |
window.form_fakeScrollingList_closeIcon_".$conf["name"]."=function(sectionId){
|
|
|
9178 |
|
|
|
9179 |
//debug
|
|
|
9180 |
console.log(sectionId);
|
|
|
9181 |
|
|
|
9182 |
//建立 close icon
|
|
|
9183 |
var closeIcon = document.createElement('img');
|
|
|
9184 |
|
|
|
9185 |
//取得顯示項目的元素id
|
|
|
9186 |
closeIcon.sectionId=sectionId;
|
|
|
9187 |
|
|
|
9188 |
//設置 close icon 的樣式
|
|
|
9189 |
closeIcon.style['position']='fixed';
|
|
|
9190 |
closeIcon.style['top']='15%';
|
|
|
9191 |
closeIcon.style['left']='85%';
|
|
|
9192 |
closeIcon.style['width']='5%';
|
|
|
9193 |
closeIcon.style['min-width']='30px';
|
|
|
9194 |
closeIcon.style['max-width']='50px';
|
|
|
9195 |
closeIcon.style['cursor']='pointer';
|
|
|
9196 |
|
|
|
9197 |
//設置 close icon img 的屬性
|
|
|
9198 |
closeIcon.src='".$closeIcon."';
|
|
|
9199 |
|
|
|
9200 |
//設置 close icon img 的id
|
|
|
9201 |
closeIcon.setAttribute('id','qbpwcfScrollingListCloseIcon');
|
|
|
9202 |
|
|
|
9203 |
//取得 scrollingList 的 root div
|
|
|
9204 |
var slrd=document.getElementById('scrollingListRootDiv');
|
|
|
9205 |
|
|
|
9206 |
//將 close icon outer div 放到 scrollingList 的 root div 裡面
|
|
|
9207 |
slrd.appendChild(closeIcon);
|
|
|
9208 |
|
|
|
9209 |
//取得 close icon img
|
|
|
9210 |
var closeIcon=document.getElementById('qbpwcfScrollingListCloseIcon');
|
|
|
9211 |
|
|
|
9212 |
//新增 close icon img 的點擊事件
|
|
|
9213 |
closeIcon.addEventListener('click',function(){
|
|
|
9214 |
|
|
|
9215 |
//取得要移除 scrolling list 的 div
|
|
|
9216 |
var divToDel=document.getElementById('scrollingListRootDiv');
|
|
|
9217 |
|
|
|
9218 |
//debug
|
|
|
9219 |
//console.log(divTodel);
|
|
|
9220 |
|
|
|
9221 |
//移除 scrolling list div
|
|
|
9222 |
divToDel.remove();
|
|
|
9223 |
|
|
|
9224 |
//debug
|
|
|
9225 |
console.log(closeIcon.sectionId);
|
|
|
9226 |
|
|
|
9227 |
//取得顯示元素,移除透明效果,顯示數值
|
|
|
9228 |
closeIcon.sectionId.style.opacity='unset';
|
|
|
9229 |
|
|
|
9230 |
});
|
|
|
9231 |
|
|
|
9232 |
}//function closeIcon end
|
|
|
9233 |
";
|
|
|
9234 |
#參考資料:
|
|
|
9235 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
9236 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
9237 |
unset($conf["javaScript::toScript"]);
|
|
|
9238 |
|
|
|
9239 |
#如果建立 script 失敗
|
|
|
9240 |
if($toScript["status"]==="false"){
|
|
|
9241 |
|
|
|
9242 |
#設置執行失敗
|
|
|
9243 |
$result["status"]="false";
|
|
|
9244 |
|
|
|
9245 |
#設置執行錯誤訊息
|
|
|
9246 |
$result["error"]=$toScript;
|
|
|
9247 |
|
|
|
9248 |
#回傳結果
|
|
|
9249 |
return $result;
|
|
|
9250 |
|
|
|
9251 |
}#if end
|
|
|
9252 |
|
|
|
9253 |
#傳接 js
|
|
|
9254 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
9255 |
|
|
|
9256 |
#設置執行正常
|
|
|
9257 |
$result["status"]="true";
|
|
|
9258 |
|
|
|
9259 |
#回傳結果
|
|
|
9260 |
return $result;
|
|
|
9261 |
|
|
|
9262 |
}#funciton fakeScrollingList end
|
|
|
9263 |
|
|
|
9264 |
/*
|
|
|
9265 |
#函式說明:
|
|
|
9266 |
#建立含有分群功能的下拉式選單
|
|
|
9267 |
#回傳結果:
|
|
|
9268 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9269 |
#$result["error"],錯誤訊息陣列.
|
|
|
9270 |
#$result["content"],語法.
|
|
|
9271 |
#必填參數:
|
|
|
9272 |
#$conf["option"][$group][$optionDisplayName]=$autualVal,二、三維字串陣列,代表$group群組的選項$optionDisplayName實際上傳送的內容為$autualVal;若為$conf["option"][$option]=$autualVal,則代表無群組的選項$option值為$autualVal.
|
|
|
9273 |
$conf["option"][][]="";
|
|
|
9274 |
#可省略參數:
|
|
|
9275 |
#$conf["name"],字串,選單用於傳送的名稱,預設為"pullDownList[]".
|
|
|
9276 |
#$conf["name"]="pullDownList[]";
|
|
|
9277 |
#$conf["id"],字串,元素id,預設跟$conf["name"]一樣.
|
|
|
9278 |
#$conf["id"]="pullDownList[]";
|
|
|
9279 |
#$conf["default"],字串陣列,代表哪個群組的選項是預設要選取的,$conf["default"]=array("g1","v1")代表g1群組的v1選擇為預設值;$conf["default"]=array("o1")代表選項顯示為o1者為預設的選項.
|
|
|
9280 |
#$conf["default"]=array($group,$optionDisplayName);
|
|
|
9281 |
#$conf["class"],字串陣列,代表要使用哪些css的class.
|
|
|
9282 |
#$conf["class"]=array();
|
|
|
9283 |
#$conf["style"],二維字串陣列,代表要使用哪些css style,例如$conf["style"]["color"]="black",就代表使用"color"屬性,屬性值為"black".
|
|
|
9284 |
#$conf["style"]["attr"]="";
|
|
|
9285 |
#$conf["notSelectedText"],一維陣列字串,沒有選擇項目時要顯示的選項為何,預設為$conf["notSelectedText"]["請選擇"]="unSelected";則代表顯示"請選擇",值為"unSelected".
|
|
|
9286 |
#$conf["notSelectedText"]["請選擇"]="unSelected"
|
|
|
9287 |
#$conf["onChangeFunction"],字串,當下拉式選單的內容變動時,要執行哪個js函數與要帶的參數,或要做的js,預設為"return false;".
|
|
|
9288 |
#$conf["onChangeFunction"]="return false;";
|
|
|
9289 |
#參考資料:
|
|
|
9290 |
#HTML <optgroup> Tag=>http://www.w3schools.com/Tags/tag_optgroup.asp
|
|
|
9291 |
#備註:
|
|
|
9292 |
#無.
|
|
|
9293 |
*/
|
|
|
9294 |
public static function pullDownList(&$conf){
|
|
|
9295 |
|
|
|
9296 |
#初始化要回傳的結果
|
|
|
9297 |
$result=array();
|
|
|
9298 |
|
|
|
9299 |
#取得當前執行的函數名稱
|
|
|
9300 |
$result["function"]=__FUNCTION__;
|
|
|
9301 |
|
|
|
9302 |
#如果沒有參數
|
|
|
9303 |
if(func_num_args()==0){
|
|
|
9304 |
|
|
|
9305 |
#設置執行失敗
|
|
|
9306 |
$result["status"]="false";
|
|
|
9307 |
|
|
|
9308 |
#設置執行錯誤訊息
|
|
|
9309 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
9310 |
|
|
|
9311 |
#回傳結果
|
|
|
9312 |
return $result;
|
|
|
9313 |
|
|
|
9314 |
}#if end
|
|
|
9315 |
|
|
|
9316 |
#取得參數
|
|
|
9317 |
$result["argu"]=$conf;
|
|
|
9318 |
|
|
|
9319 |
#如果 $conf 不為陣列
|
|
|
9320 |
if(gettype($conf)!=="array"){
|
|
|
9321 |
|
|
|
9322 |
#設置執行失敗
|
|
|
9323 |
$result["status"]="false";
|
|
|
9324 |
|
|
|
9325 |
#設置執行錯誤訊息
|
|
|
9326 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
9327 |
|
|
|
9328 |
#如果傳入的參數為 null
|
|
|
9329 |
if($conf===null){
|
|
|
9330 |
|
|
|
9331 |
#設置執行錯誤訊息
|
|
|
9332 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
9333 |
|
|
|
9334 |
}#if end
|
|
|
9335 |
|
|
|
9336 |
#回傳結果
|
|
|
9337 |
return $result;
|
|
|
9338 |
|
|
|
9339 |
}#if end
|
|
|
9340 |
|
|
|
9341 |
#檢查參數
|
|
|
9342 |
#函式說明:
|
|
|
9343 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
9344 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9345 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
9346 |
#$result["function"],當前執行的函式名稱.
|
|
|
9347 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
9348 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
9349 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
9350 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
9351 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
9352 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
9353 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
9354 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
9355 |
#必填參數:
|
|
|
9356 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
9357 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
9358 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
9359 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("option");
|
|
|
9360 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
9361 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
9362 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
9363 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
9364 |
#可省略參數:
|
|
|
9365 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
9366 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
9367 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
9368 |
#$conf["canNotBeEmpty"]=array();
|
|
|
9369 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
9370 |
#$conf["canBeEmpty"]=array();
|
|
|
9371 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
9372 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("name","id","default","class","style");
|
|
|
9373 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
9374 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("name","id","default","class","style","notSelectedText","onChangeFunction");
|
|
|
9375 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
9376 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array","array","array","array","string");
|
|
|
9377 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
9378 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("pullDownList[]","pullDownList[]",null,null,null,array("請選擇"=>"unSelected"),"return false;");
|
|
|
9379 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
9380 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
9381 |
#參考資料:
|
|
|
9382 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
9383 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
9384 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
9385 |
|
|
|
9386 |
#如果檢查參數失敗
|
|
|
9387 |
if($checkArguments["status"]==="false"){
|
|
|
9388 |
|
|
|
9389 |
#設置錯誤識別
|
|
|
9390 |
$result["status"]="false";
|
|
|
9391 |
|
|
|
9392 |
#設置錯誤訊息
|
|
|
9393 |
$result["error"]=$checkArguments;
|
|
|
9394 |
|
|
|
9395 |
#回傳結果
|
|
|
9396 |
return $result;
|
|
|
9397 |
|
|
|
9398 |
}#if end
|
|
|
9399 |
|
|
|
9400 |
#如果檢查不通過
|
|
|
9401 |
if($checkArguments["passed"]==="false"){
|
|
|
9402 |
|
|
|
9403 |
#設置錯誤識別
|
|
|
9404 |
$result["status"]="false";
|
|
|
9405 |
|
|
|
9406 |
#設置錯誤訊息
|
|
|
9407 |
$result["error"]=$checkArguments;
|
|
|
9408 |
|
|
|
9409 |
#回傳結果
|
|
|
9410 |
return $result;
|
|
|
9411 |
|
|
|
9412 |
}#if end
|
|
|
9413 |
|
|
|
9414 |
#檢查 $conf["option"] 是否為二維陣列
|
|
|
9415 |
#針對$conf["option"]的每個元素
|
|
|
9416 |
foreach($conf["option"] as $groups){
|
|
|
9417 |
|
|
|
9418 |
#如果$arrays不為陣列形態
|
|
|
9419 |
if(gettype($groups)!=="array" && gettype($groups)!=="string"){
|
|
|
9420 |
|
|
|
9421 |
#設置錯誤識別
|
|
|
9422 |
$result["status"]="false";
|
|
|
9423 |
|
|
|
9424 |
#設置錯誤訊息
|
|
|
9425 |
$result["error"][]="參數 option 須為一、二維字串陣列";
|
|
|
9426 |
|
|
|
9427 |
#回傳結果
|
|
|
9428 |
return $result;
|
|
|
9429 |
|
|
|
9430 |
}#if end
|
|
|
9431 |
|
|
|
9432 |
}#foreach end
|
|
|
9433 |
|
|
|
9434 |
#初始化要套用 css style 屬性字串
|
|
|
9435 |
$style="";
|
|
|
9436 |
|
|
|
9437 |
#如果有設定 $conf["style"]
|
|
|
9438 |
if(isset($conf["style"])){
|
|
|
9439 |
|
|
|
9440 |
#初始化儲存style屬性的陣列
|
|
|
9441 |
$styleAttr=array();
|
|
|
9442 |
|
|
|
9443 |
#初始化儲存style屬性值的陣列
|
|
|
9444 |
$styleVal=array();
|
|
|
9445 |
|
|
|
9446 |
#$conf["style"] 有幾個元素就執行幾次
|
|
|
9447 |
foreach($conf["style"] as $attr => $val){
|
|
|
9448 |
|
|
|
9449 |
#如果屬性值不為字串
|
|
|
9450 |
if(gettype($attr)!=="string" || gettype($val)!=="string"){
|
|
|
9451 |
|
|
|
9452 |
#設置執行不正常
|
|
|
9453 |
$result["status"]="false";
|
|
|
9454 |
|
|
|
9455 |
#設置執行錯誤
|
|
|
9456 |
$result["error"][]="參數style的元素key與value皆須為字串";
|
|
|
9457 |
|
|
|
9458 |
#回傳結果
|
|
|
9459 |
return $result;
|
|
|
9460 |
|
|
|
9461 |
}#if end
|
|
|
9462 |
|
|
|
9463 |
#取得屬性
|
|
|
9464 |
$styleAttr[]=$attr;
|
|
|
9465 |
|
|
|
9466 |
#取得屬性值
|
|
|
9467 |
$styleVal[]=$val;
|
|
|
9468 |
|
|
|
9469 |
}#foreach end
|
|
|
9470 |
|
|
|
9471 |
#如果有屬性與值,且數量對應正確
|
|
|
9472 |
if(count($styleAttr)>0 && count($styleVal)>0 && count($styleAttr)===count($styleVal)){
|
|
|
9473 |
|
|
|
9474 |
#建立 css style 屬性字串
|
|
|
9475 |
#函式說明:
|
|
|
9476 |
#建立給與html標籤使用的style屬性字串.
|
|
|
9477 |
#回傳結果:
|
|
|
9478 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9479 |
#$result["function"],當前執行的函數
|
|
|
9480 |
#$result["error"],錯誤訊息陣列
|
|
|
9481 |
#$result["content"],css設定內容
|
|
|
9482 |
#必填參數:
|
|
|
9483 |
$conf["css::styleStr"]["styleName"]=$styleAttr;#為屬性名稱,須為陣列值
|
|
|
9484 |
$conf["css::styleStr"]["styleValue"]=$styleVal;#為屬性值,須為陣列值
|
|
|
9485 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
9486 |
unset($conf["css::styleStr"]);
|
|
|
9487 |
|
|
|
9488 |
#如果建立style字串失敗
|
|
|
9489 |
if($styleStr["status"]==="false"){
|
|
|
9490 |
|
|
|
9491 |
#設置執行不正常
|
|
|
9492 |
$result["status"]="false";
|
|
|
9493 |
|
|
|
9494 |
#設置執行錯誤
|
|
|
9495 |
$result["error"]=$styleStr;
|
|
|
9496 |
|
|
|
9497 |
#回傳結果
|
|
|
9498 |
return $result;
|
|
|
9499 |
|
|
|
9500 |
}#if end
|
|
|
9501 |
|
|
|
9502 |
#設置屬性字串
|
|
|
9503 |
$style=$styleStr["content"];
|
|
|
9504 |
|
|
|
9505 |
}#if end
|
|
|
9506 |
|
|
|
9507 |
}#if end
|
|
|
9508 |
|
|
|
9509 |
#初始化要套用的 css class 屬性字串
|
|
|
9510 |
$class="";
|
|
|
9511 |
|
|
|
9512 |
#如果有設定 $conf["class"]
|
|
|
9513 |
if(isset($conf["class"])){
|
|
|
9514 |
|
|
|
9515 |
#設定要套用的css類別
|
|
|
9516 |
#函式說明:
|
|
|
9517 |
#建立class屬性字串,亦即套用多個class樣式的設定字串.
|
|
|
9518 |
#回傳結果:
|
|
|
9519 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9520 |
#$result["function"],當前執行的函數
|
|
|
9521 |
#$result["error"],錯誤訊息陣列
|
|
|
9522 |
#$result["content"],class屬性字串的內容
|
|
|
9523 |
#必填參數:
|
|
|
9524 |
#$conf["class"],字串陣列,要套用的類別樣式名稱.
|
|
|
9525 |
$conf["css::classStr"]["class"]=$conf["class"];
|
|
|
9526 |
$classStr=css::classStr($conf["css::classStr"]);
|
|
|
9527 |
unset($conf["css::classStr"]);
|
|
|
9528 |
|
|
|
9529 |
#如果建立套用css類別的屬性字串失敗
|
|
|
9530 |
if($classStr["status"]==="false"){
|
|
|
9531 |
|
|
|
9532 |
#設置錯誤識別
|
|
|
9533 |
$result["status"]="false";
|
|
|
9534 |
|
|
|
9535 |
#設置錯誤訊息
|
|
|
9536 |
$result["error"]=$classStr;
|
|
|
9537 |
|
|
|
9538 |
#回傳結果
|
|
|
9539 |
return $result;
|
|
|
9540 |
|
|
|
9541 |
}#if end
|
|
|
9542 |
|
|
|
9543 |
#取得css類別屬性字串
|
|
|
9544 |
$class=$classStr["content"];
|
|
|
9545 |
|
|
|
9546 |
}#if end
|
|
|
9547 |
|
|
|
9548 |
#設置當內容改變時要觸發的js
|
|
|
9549 |
$onChangeJs="onChange=\"".$conf["onChangeFunction"]."\"";
|
|
|
9550 |
|
|
|
9551 |
#初始化要回傳的語法
|
|
|
9552 |
$result["content"]="<select name=\"".$conf["name"]."\" id=\"".$conf["id"]."\" ".$style." ".$class." ".$onChangeJs." >";
|
|
|
9553 |
|
|
|
9554 |
#針對 $conf["notSelectedText"] 變數
|
|
|
9555 |
foreach($conf["notSelectedText"] as $unSelText => $unSelVal){
|
|
|
9556 |
|
|
|
9557 |
#設置未選擇的選項
|
|
|
9558 |
$result["content"]=$result["content"]."<option value=\"".$unSelVal."\">".$unSelText."</option>";
|
|
|
9559 |
|
|
|
9560 |
}#foreach end
|
|
|
9561 |
|
|
|
9562 |
#針對每個 $conf["option"]
|
|
|
9563 |
foreach($conf["option"] as $groupName => $options){
|
|
|
9564 |
|
|
|
9565 |
#如果 $options 為陣列
|
|
|
9566 |
if(gettype($options)==="array"){
|
|
|
9567 |
|
|
|
9568 |
#則代表是群組選項
|
|
|
9569 |
|
|
|
9570 |
#群組 $groupName 開始
|
|
|
9571 |
$result["content"]=$result["content"]."<optgroup label=\"".$groupName."\">";
|
|
|
9572 |
|
|
|
9573 |
#針對每個 $options
|
|
|
9574 |
foreach($options as $optionName => $optionVal){
|
|
|
9575 |
|
|
|
9576 |
#初始化預設選取的語法
|
|
|
9577 |
$selected="";
|
|
|
9578 |
|
|
|
9579 |
#如果有設置預設值
|
|
|
9580 |
if(isset($conf["default"])){
|
|
|
9581 |
|
|
|
9582 |
#如果存在群組選項
|
|
|
9583 |
if(isset($conf["default"][1]) && isset($conf["default"][1])){
|
|
|
9584 |
|
|
|
9585 |
#如果是預設的群組選項
|
|
|
9586 |
if($groupName===$conf["default"][0] && $optionName===$conf["default"][1]){
|
|
|
9587 |
|
|
|
9588 |
#設置選取的語法
|
|
|
9589 |
$selected="selected";
|
|
|
9590 |
|
|
|
9591 |
}#if end
|
|
|
9592 |
|
|
|
9593 |
}#if end
|
|
|
9594 |
|
|
|
9595 |
}#if end
|
|
|
9596 |
|
|
|
9597 |
#選項 $optionName
|
|
|
9598 |
$result["content"]=$result["content"]."<option value=\"".$optionVal."\" ".$selected." >$optionName</option>";
|
|
|
9599 |
|
|
|
9600 |
}#foreache end
|
|
|
9601 |
|
|
|
9602 |
#群組 $groupName 結束
|
|
|
9603 |
$result["content"]=$result["content"]."</optgroup>";
|
|
|
9604 |
|
|
|
9605 |
}#if end
|
|
|
9606 |
|
|
|
9607 |
#反之如果是字串
|
|
|
9608 |
else if(gettype($options)==="string"){
|
|
|
9609 |
|
|
|
9610 |
#則代表無歸屬群組的選項
|
|
|
9611 |
#初始化預設選取的語法
|
|
|
9612 |
$selected="";
|
|
|
9613 |
|
|
|
9614 |
#如果有設置預設值
|
|
|
9615 |
if(isset($conf["default"])){
|
|
|
9616 |
|
|
|
9617 |
#如果存在選項
|
|
|
9618 |
if(isset($conf["default"][0])){
|
|
|
9619 |
|
|
|
9620 |
#如果是預設的選項
|
|
|
9621 |
if($groupName===$conf["default"][0]){
|
|
|
9622 |
|
|
|
9623 |
#設置選取的語法
|
|
|
9624 |
$selected="selected";
|
|
|
9625 |
|
|
|
9626 |
}#if end
|
|
|
9627 |
|
|
|
9628 |
}#if end
|
|
|
9629 |
|
|
|
9630 |
}#if end
|
|
|
9631 |
|
|
|
9632 |
#選項 $groupName 的值為 $options
|
|
|
9633 |
$result["content"]=$result["content"]."<option value=\"".$options."\" ".$selected." >$groupName</option>";
|
|
|
9634 |
|
|
|
9635 |
}#if end
|
|
|
9636 |
|
|
|
9637 |
}#foreach end
|
|
|
9638 |
|
|
|
9639 |
#下拉式選單結束
|
|
|
9640 |
$result["content"]=$result["content"]."</select>";
|
|
|
9641 |
|
|
|
9642 |
#設置執行正常
|
|
|
9643 |
$result["status"]="true";
|
|
|
9644 |
|
|
|
9645 |
#回傳結果
|
|
|
9646 |
return $result;
|
|
|
9647 |
|
|
|
9648 |
}#function pullDownList end
|
|
|
9649 |
|
|
|
9650 |
/*
|
|
|
9651 |
#函式說明:
|
|
|
9652 |
#黑點式選單(單選)
|
|
|
9653 |
#回傳結果:
|
|
|
9654 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
9655 |
#$result["error"],錯誤訊息陣列.
|
|
|
9656 |
#$result["content"],語法內容.
|
|
|
9657 |
#$result["function"],設置當前執行的函式
|
|
|
9658 |
#必填參數:
|
|
|
9659 |
$conf["name"]="";#爲黑點式選單的名稱
|
|
|
9660 |
$conf["sendValue"]=array();#爲陣列值,爲每個選項的實際傳送的數值,e.g. $sendValue = array("a","b","c","d","e");
|
|
|
9661 |
#可省略參數:
|
|
|
9662 |
#$conf["class"]="__withoutBorder";#爲要套用的class樣式,"__qbpwcf_inputRadioWithoutBorder"爲沒有框線的樣式;__qbpwcf_inputRadioWithBorder爲有框線的樣式
|
|
|
9663 |
#$conf["outputValue"]=array();#爲陣列值,爲每個選項的實際顯示的數值, e.g. $outputValue = array("p","o","i","t","e"); 預設爲跟$conf["sendValue"]一樣。
|
|
|
9664 |
#$conf["defaultValue"]="";#爲預設的選項,爲實際傳送的數值之一。
|
|
|
9665 |
#$conf["comment"],字串,下拉式表單的註解文字.
|
|
|
9666 |
#$conf["comment"]="";
|
|
|
9667 |
#$conf["disableHr"]="true";#如果設爲"true",則結尾不用<hr>來結束單選的範圍,預設為"false".
|
|
|
9668 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
9669 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
9670 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
9671 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",其爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
9672 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
9673 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,預設為"__withoutBorder",其爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
9674 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
9675 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
9676 |
#$conf["brBetweenOption"]="true";#是否每個選項用<br>標籤隔開,預設為"true".
|
|
|
9677 |
#參考資料:
|
|
|
9678 |
#無.
|
|
|
9679 |
#備註:
|
|
|
9680 |
#無.
|
|
|
9681 |
*/
|
|
|
9682 |
public static function inputRadio($conf){
|
|
|
9683 |
|
|
|
9684 |
#預設要回傳的數值
|
|
|
9685 |
$result=array();
|
|
|
9686 |
|
|
|
9687 |
#初始化要回傳的語法
|
|
|
9688 |
$result["content"]="";
|
|
|
9689 |
|
|
|
9690 |
#設置當前執行的函式
|
|
|
9691 |
$result["function"]=__FUNCTION__;
|
|
|
9692 |
|
|
|
9693 |
#如果 $conf 不為陣列
|
|
|
9694 |
if(gettype($conf)!="array"){
|
|
|
9695 |
|
|
|
9696 |
#設置執行失敗
|
|
|
9697 |
$result["status"]="false";
|
|
|
9698 |
|
|
|
9699 |
#設置執行錯誤訊息
|
|
|
9700 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
9701 |
|
|
|
9702 |
#如果傳入的參數為 null
|
|
|
9703 |
if($conf==null){
|
|
|
9704 |
|
|
|
9705 |
#設置執行錯誤訊息
|
|
|
9706 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
9707 |
|
|
|
9708 |
}#if end
|
|
|
9709 |
|
|
|
9710 |
#回傳結果
|
|
|
9711 |
return $result;
|
|
|
9712 |
|
|
|
9713 |
}#if end
|
|
|
9714 |
|
|
|
9715 |
#檢查參數
|
|
|
9716 |
#函式說明:
|
|
|
9717 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
9718 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9719 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
9720 |
#$result["function"],當前執行的函式名稱.
|
|
|
9721 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
9722 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
9723 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
9724 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
9725 |
#必填參數:
|
|
|
9726 |
#$conf["form.checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
9727 |
$conf["form.checkArguments"]["varInput"]=&$conf;
|
|
|
9728 |
#$conf["form.checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
9729 |
$conf["form.checkArguments"]["mustBeFilledVariableName"][]="name";
|
|
|
9730 |
$conf["form.checkArguments"]["mustBeFilledVariableName"][]="sendValue";
|
|
|
9731 |
#$conf["form.checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
9732 |
$conf["form.checkArguments"]["mustBeFilledVariableType"][]="string";
|
|
|
9733 |
$conf["form.checkArguments"]["mustBeFilledVariableType"][]="array";
|
|
|
9734 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
9735 |
$conf["form.checkArguments"]["referenceVarKey"]="form.checkArguments";
|
|
|
9736 |
#可省略參數:
|
|
|
9737 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
9738 |
#$conf["canBeEmptyString"]="false";
|
|
|
9739 |
#$conf["form.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
9740 |
$conf["form.checkArguments"]["skipableVariableName"][]="class";
|
|
|
9741 |
$conf["form.checkArguments"]["skipableVariableName"][]="outputValue";
|
|
|
9742 |
$conf["form.checkArguments"]["skipableVariableName"][]="comment";
|
|
|
9743 |
$conf["form.checkArguments"]["skipableVariableName"][]="disableHr";
|
|
|
9744 |
$conf["form.checkArguments"]["skipableVariableName"][]="jsActivitor";
|
|
|
9745 |
$conf["form.checkArguments"]["skipableVariableName"][]="jsAction";
|
|
|
9746 |
$conf["form.checkArguments"]["skipableVariableName"][]="trStart";
|
|
|
9747 |
$conf["form.checkArguments"]["skipableVariableName"][]="trClass";
|
|
|
9748 |
$conf["form.checkArguments"]["skipableVariableName"][]="tdStart";
|
|
|
9749 |
$conf["form.checkArguments"]["skipableVariableName"][]="tdClass";
|
|
|
9750 |
$conf["form.checkArguments"]["skipableVariableName"][]="tdEnd";
|
|
|
9751 |
$conf["form.checkArguments"]["skipableVariableName"][]="trEnd";
|
|
|
9752 |
$conf["form.checkArguments"]["skipableVariableName"][]="brBetweenOption";
|
|
|
9753 |
$conf["form.checkArguments"]["skipableVariableName"][]="defaultValue";
|
|
|
9754 |
#$conf["form.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
9755 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9756 |
$conf["form.checkArguments"]["skipableVariableType"][]="array";
|
|
|
9757 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9758 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9759 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9760 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9761 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9762 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9763 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9764 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9765 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9766 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9767 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9768 |
$conf["form.checkArguments"]["skipableVariableType"][]="string";
|
|
|
9769 |
#$conf["form.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
9770 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_inputRadioWithoutBorder";
|
|
|
9771 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="\$conf[\"sendValue\"]";
|
|
|
9772 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
9773 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
9774 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
9775 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
9776 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
9777 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_inputRadioWithoutBorder";
|
|
|
9778 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
9779 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_inputRadioWithoutBorder";
|
|
|
9780 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
9781 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="false";
|
|
|
9782 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]="true";
|
|
|
9783 |
$conf["form.checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
9784 |
$checkResult=variableCheck::checkArguments($conf["form.checkArguments"]);
|
|
|
9785 |
unset($conf["form.checkArguments"]);
|
|
|
9786 |
|
|
|
9787 |
#如果$checkResult["status"] 等於 "false"
|
|
|
9788 |
#意即如果檢查出錯
|
|
|
9789 |
if($checkResult["status"]=="false"){
|
|
|
9790 |
|
|
|
9791 |
#設置錯誤識別
|
|
|
9792 |
$result["status"]="false";
|
|
|
9793 |
|
|
|
9794 |
#設置錯誤訊息
|
|
|
9795 |
$result["error"]=$checkResult;
|
|
|
9796 |
|
|
|
9797 |
#回傳結果
|
|
|
9798 |
return $result;
|
|
|
9799 |
|
|
|
9800 |
}#if end
|
|
|
9801 |
|
|
|
9802 |
#如果$checkResult["passed"] 等於 "false"
|
|
|
9803 |
#意即如果檢查出錯
|
|
|
9804 |
if($checkResult["passed"]=="false"){
|
|
|
9805 |
|
|
|
9806 |
#設置錯誤識別
|
|
|
9807 |
$result["status"]="false";
|
|
|
9808 |
|
|
|
9809 |
#設置錯誤訊息
|
|
|
9810 |
$result["error"]=$checkResult;
|
|
|
9811 |
|
|
|
9812 |
#回傳結果
|
|
|
9813 |
return $result;
|
|
|
9814 |
|
|
|
9815 |
}#if end
|
|
|
9816 |
|
|
|
9817 |
#如果其值爲 true
|
|
|
9818 |
if($conf["trStart"]=="true"){
|
|
|
9819 |
|
|
|
9820 |
#函式說明:
|
|
|
9821 |
#列開始
|
|
|
9822 |
#回傳結果:
|
|
|
9823 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
9824 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
9825 |
#$result["content"],列開始的語法.
|
|
|
9826 |
#$result["function"],當前執行的函式名稱.
|
|
|
9827 |
#必填寫的參數:
|
|
|
9828 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];#該 tr 要套用套用的 css 樣式若爲 "" 則會採用預設的css樣式 __defaultTrCsssStyle,其屬性爲 border:1px solid blue
|
|
|
9829 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
9830 |
unset($conf["table"]["trStart"]);
|
|
|
9831 |
|
|
|
9832 |
#如果列開始失敗
|
|
|
9833 |
if($trStart["status"]=="false"){
|
|
|
9834 |
|
|
|
9835 |
#設置錯誤識別
|
|
|
9836 |
$result["status"]="false";
|
|
|
9837 |
|
|
|
9838 |
#設置錯誤訊息
|
|
|
9839 |
$result["error"]=$trStart;
|
|
|
9840 |
|
|
|
9841 |
#回傳結果
|
|
|
9842 |
return $result;
|
|
|
9843 |
|
|
|
9844 |
}#if end
|
|
|
9845 |
|
|
|
9846 |
#串接列開始
|
|
|
9847 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
9848 |
|
|
|
9849 |
}#if end
|
|
|
9850 |
|
|
|
9851 |
#如果其值爲 true
|
|
|
9852 |
if($conf["tdStart"]=="true"){
|
|
|
9853 |
|
|
|
9854 |
#函式說明:
|
|
|
9855 |
#行開始
|
|
|
9856 |
#回傳結果:
|
|
|
9857 |
#$result,行開始的語法
|
|
|
9858 |
#必填寫的參數:
|
|
|
9859 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];#該 td 要套用套用的 css 樣式
|
|
|
9860 |
#預設的樣式
|
|
|
9861 |
#"border-width","border","border-color","border-style","margin-right","margin-left"
|
|
|
9862 |
#"100%","1px","#0000FF","solid","auto","auto"
|
|
|
9863 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
9864 |
unset($conf["table"]["tdStart"]);
|
|
|
9865 |
|
|
|
9866 |
#如果 欄開始 失敗
|
|
|
9867 |
if($tdStart["status"]=="false"){
|
|
|
9868 |
|
|
|
9869 |
#設置錯誤識別
|
|
|
9870 |
$result["status"]="false";
|
|
|
9871 |
|
|
|
9872 |
#設置錯誤訊息
|
|
|
9873 |
$result["error"]=$tdStar;
|
|
|
9874 |
|
|
|
9875 |
#回傳結果
|
|
|
9876 |
return $result;
|
|
|
9877 |
|
|
|
9878 |
}#if end
|
|
|
9879 |
|
|
|
9880 |
#串接欄開始
|
|
|
9881 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
9882 |
|
|
|
9883 |
}#if end
|
|
|
9884 |
|
|
|
9885 |
#如果$conf["defaultValue"]沒有設定
|
|
|
9886 |
if(!isset($conf["defaultValue"])){
|
|
|
9887 |
|
|
|
9888 |
#則$conf["defaultValue"]爲""
|
|
|
9889 |
$conf["defaultValue"]="";
|
|
|
9890 |
|
|
|
9891 |
}#if end
|
|
|
9892 |
|
|
|
9893 |
#如果$conf["outputValue"]沒設定
|
|
|
9894 |
if(!isset($conf["outputValue"])){
|
|
|
9895 |
|
|
|
9896 |
#則$conf["outputValue"]陣列內容將會等於$conf["sendValue"]陣列內容
|
|
|
9897 |
$conf["outputValue"]=$conf["sendValue"];
|
|
|
9898 |
|
|
|
9899 |
}#if end
|
|
|
9900 |
|
|
|
9901 |
#暫存給註解用的css樣式
|
|
|
9902 |
$commentCssStyle="";
|
|
|
9903 |
|
|
|
9904 |
#如果爲 "__withBorder"
|
|
|
9905 |
if($conf["class"]=="__withBorder"){
|
|
|
9906 |
|
|
|
9907 |
#變更爲有框線的預設樣式
|
|
|
9908 |
$conf["class"]="__withBorderInputRadioCssStyle";
|
|
|
9909 |
|
|
|
9910 |
#取得註解要用的css樣式
|
|
|
9911 |
$commentCssStyle=$conf["class"];
|
|
|
9912 |
|
|
|
9913 |
}#if ned
|
|
|
9914 |
|
|
|
9915 |
#如果爲 "__withoutBorder"
|
|
|
9916 |
if($conf["class"]=="__withoutBorder"){
|
|
|
9917 |
|
|
|
9918 |
#變更爲有框線的預設樣式
|
|
|
9919 |
$conf["class"]="__withoutBorderInputRadioCssStyle";
|
|
|
9920 |
|
|
|
9921 |
#取得註解要用的css樣式
|
|
|
9922 |
$commentCssStyle=$conf["class"];
|
|
|
9923 |
|
|
|
9924 |
}#if ned
|
|
|
9925 |
|
|
|
9926 |
#則按照設定值
|
|
|
9927 |
$conf["class"]=" class = ".$conf["class"]." ";
|
|
|
9928 |
|
|
|
9929 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
9930 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
9931 |
|
|
|
9932 |
#則將設定值組合
|
|
|
9933 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
9934 |
|
|
|
9935 |
}#if end
|
|
|
9936 |
|
|
|
9937 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
9938 |
if(!isset($conf["jsCustom"])){
|
|
|
9939 |
|
|
|
9940 |
#將其設爲空值
|
|
|
9941 |
$conf["jsCustom"]="";
|
|
|
9942 |
|
|
|
9943 |
}#if end
|
|
|
9944 |
|
|
|
9945 |
#將有幾個選項的數目放進 $count
|
|
|
9946 |
$count=count($conf["sendValue"]);
|
|
|
9947 |
|
|
|
9948 |
#套用css樣式
|
|
|
9949 |
$result["content"]=$result["content"]."<span ".$conf["class"]." >";
|
|
|
9950 |
|
|
|
9951 |
#過濾 $conf["name"] 避免錯誤
|
|
|
9952 |
#函式說明:
|
|
|
9953 |
#處理字串避免網頁出錯
|
|
|
9954 |
#回傳結果:
|
|
|
9955 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
9956 |
#$result["function"],當前執行的函數.
|
|
|
9957 |
#$result["content"],爲處理好的字串.
|
|
|
9958 |
#$result["error"],錯誤訊息陣列.
|
|
|
9959 |
#必填參數:
|
|
|
9960 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["name"];#爲要處理的字串
|
|
|
9961 |
#可省略的參數:
|
|
|
9962 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
9963 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
9964 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
9965 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
9966 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
9967 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
9968 |
|
|
|
9969 |
#如果過濾字串失敗
|
|
|
9970 |
if($correctCharacter["status"]=="false"){
|
|
|
9971 |
|
|
|
9972 |
#設置執行失敗
|
|
|
9973 |
$result["status"]="false";
|
|
|
9974 |
|
|
|
9975 |
#設置執行錯誤訊息
|
|
|
9976 |
$result["error"]=$correctCharacter;
|
|
|
9977 |
|
|
|
9978 |
#回傳結果
|
|
|
9979 |
return $result;
|
|
|
9980 |
|
|
|
9981 |
}#if end
|
|
|
9982 |
|
|
|
9983 |
#置換過濾好了的$conf["name"]
|
|
|
9984 |
$conf["name"]=$correctCharacter["content"];
|
|
|
9985 |
|
|
|
9986 |
#n個選項跑n此
|
|
|
9987 |
for($i=0;$i<=($count-1);$i++){
|
|
|
9988 |
|
|
|
9989 |
#如果選項的數值等於 預設的數值
|
|
|
9990 |
if($conf["sendValue"][$i]==$conf["defaultValue"]){
|
|
|
9991 |
|
|
|
9992 |
#則選取該選項
|
|
|
9993 |
$result["content"]=$result["content"]."<label><input type = \"radio\" name = ".$conf["name"]." value = ".$conf["sendValue"][$i]." checked ".$conf["jsCustom"]." >".$conf["outputValue"][$i]."</label>";
|
|
|
9994 |
|
|
|
9995 |
}#if end
|
|
|
9996 |
|
|
|
9997 |
#反之
|
|
|
9998 |
else{
|
|
|
9999 |
|
|
|
10000 |
#選項的值等於現在畫面上的值
|
|
|
10001 |
$result["content"]=$result["content"]."<label><input type = \"radio\" name = ".$conf["name"]." value = ".$conf["sendValue"][$i]." ".$conf["jsCustom"]." >".$conf["outputValue"][$i]."</label>";
|
|
|
10002 |
|
|
|
10003 |
}#else end
|
|
|
10004 |
|
|
|
10005 |
#如果 $conf["brBetweenOption"] 等於 "true"
|
|
|
10006 |
if(($conf["brBetweenOption"]=="true")){
|
|
|
10007 |
|
|
|
10008 |
#加上<br>標籤
|
|
|
10009 |
$result["content"]=$result["content"]."<br>";
|
|
|
10010 |
|
|
|
10011 |
}#if end
|
|
|
10012 |
|
|
|
10013 |
}#for end
|
|
|
10014 |
|
|
|
10015 |
#套用css樣式的範圍結束
|
|
|
10016 |
$result["content"]=$result["content"]."</span ".$conf["class"]." >";
|
|
|
10017 |
|
|
|
10018 |
#如果 不使用<hr> 的變數不存在
|
|
|
10019 |
if(!isset($conf["disableHr"])){
|
|
|
10020 |
|
|
|
10021 |
#則印出<hr>進行分割,以便放置下一個radioButton
|
|
|
10022 |
$result["content"]=$result["content"]."<hr width = 0>";
|
|
|
10023 |
|
|
|
10024 |
}#if end
|
|
|
10025 |
|
|
|
10026 |
#如果其值爲 true
|
|
|
10027 |
if($conf["tdEnd"]=="true"){
|
|
|
10028 |
|
|
|
10029 |
#串接欄結束
|
|
|
10030 |
$result["content"]=$result["content"]."</td>";
|
|
|
10031 |
|
|
|
10032 |
}#if end
|
|
|
10033 |
|
|
|
10034 |
#如果其值爲 true
|
|
|
10035 |
if($conf["trEnd"]=="true"){
|
|
|
10036 |
|
|
|
10037 |
#串接列結束
|
|
|
10038 |
$result["content"]=$result["content"]."</tr>";
|
|
|
10039 |
|
|
|
10040 |
}#if end
|
|
|
10041 |
|
|
|
10042 |
#如果 $conf["comment"] 存在
|
|
|
10043 |
if(isset($conf["comment"])){
|
|
|
10044 |
|
|
|
10045 |
#給註解套上css樣式
|
|
|
10046 |
#函式說明:
|
|
|
10047 |
#<span>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
10048 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
10049 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
10050 |
#$result["error"],陣列,錯訊訊息.
|
|
|
10051 |
#$result["content"],字串,含有<span>標籤的內容.
|
|
|
10052 |
#必填參數:
|
|
|
10053 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
10054 |
$conf["css::spanSection"]["contentArray"]=array($conf["comment"]);
|
|
|
10055 |
#可省略參數
|
|
|
10056 |
#$conf["css::spanSection"]["class"],字串,div區段要套用的css樣式.
|
|
|
10057 |
$conf["css::spanSection"]["class"]=$commentCssStyle;
|
|
|
10058 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
10059 |
#$conf["title"]=array();
|
|
|
10060 |
$spanSection=css::spanSection($conf["css::spanSection"]);
|
|
|
10061 |
unset($conf["css::spanSection"]);
|
|
|
10062 |
|
|
|
10063 |
#若建立 spanSection 失敗
|
|
|
10064 |
if($spanSection["status"]=="false"){
|
|
|
10065 |
|
|
|
10066 |
#設置錯誤識別
|
|
|
10067 |
$result["status"]="false";
|
|
|
10068 |
|
|
|
10069 |
#設置錯誤訊息
|
|
|
10070 |
$result["error"]=$spanSection;
|
|
|
10071 |
|
|
|
10072 |
#回傳結果
|
|
|
10073 |
return $result;
|
|
|
10074 |
|
|
|
10075 |
}#if end
|
|
|
10076 |
|
|
|
10077 |
#加上註解
|
|
|
10078 |
$result["content"]=$spanSection["content"]."<br>".$result["content"];
|
|
|
10079 |
|
|
|
10080 |
}#if end
|
|
|
10081 |
|
|
|
10082 |
#設置執行正常
|
|
|
10083 |
$result["status"]="true";
|
|
|
10084 |
|
|
|
10085 |
#回傳語法
|
|
|
10086 |
return $result;
|
|
|
10087 |
|
|
|
10088 |
}#function inputRadio end
|
|
|
10089 |
|
|
|
10090 |
/*
|
|
|
10091 |
#函式說明:
|
|
|
10092 |
#勾選式選單(複選)
|
|
|
10093 |
#回傳結果:
|
|
|
10094 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表失敗.
|
|
|
10095 |
#$result["error"],錯誤訊息陣列.
|
|
|
10096 |
#$result["content"],語法內容.
|
|
|
10097 |
#$result["function"],當前執行的函式.
|
|
|
10098 |
#必填參數:
|
|
|
10099 |
$conf["name"]=array();#爲勾選式選單傳送時的各選項的名稱。例如:$conf["name"]=array("q-1","q-2","q-3","q-4","q-5");
|
|
|
10100 |
$conf["sendValue"]=array();#爲陣列值,為勾選式選單實際傳送的內容.例如:$conf["sendValue"]=array("a","b","c","d","e");
|
|
|
10101 |
#可省略參數:
|
|
|
10102 |
#$conf["class"]=;#爲要套用的class樣式,預設為"__inputCheckBoxCssStyle",其樣式為"font-size:30px;text-align:center;"
|
|
|
10103 |
#$conf["outputValue"]=array();#爲陣列值,爲每個選項的實際顯示的數值, e.g. $conf["outputValue"] = array("p","o","i","t","e"); 預設爲跟$conf["sendValue"]一樣。
|
|
|
10104 |
#$conf["checkedOption"]=array();#爲那些選項是否要勾選,須爲陣列值。例如array("1","3","4"),就代表第1、3、4個選項是勾選的狀態。
|
|
|
10105 |
#$conf["comment"]="";#為選單的註解
|
|
|
10106 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
10107 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
10108 |
#$conf["formName"]="";#爲表單的名稱
|
|
|
10109 |
#$conf["formAction"]="";#爲表單要送到哪個php檔案。
|
|
|
10110 |
#$conf["actionTarget"]="";#爲表單處理好後的呈現方式,有_top,_self,_blank,_parent,元素名稱也可以,預設為"_self"
|
|
|
10111 |
#$conf["hiddenVar"],字串陣列,隱藏的變數名稱陣列.
|
|
|
10112 |
#$conf["hiddenVar"]=array("");
|
|
|
10113 |
#$conf["hiddanVarValue"],字串陣列,隱藏變數的數值內容.
|
|
|
10114 |
#$conf["hiddenVarValue"]=array("");
|
|
|
10115 |
#$conf["formEnd"]="false";#爲是否要表單結束,預設爲"false".
|
|
|
10116 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設爲"false".
|
|
|
10117 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設爲"false".
|
|
|
10118 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設爲"false".
|
|
|
10119 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設爲"false".
|
|
|
10120 |
#$conf["brBetweenOption"]="true";#是否每個選項用<br>標籤隔開,"true"為要,預設爲"false".
|
|
|
10121 |
#參考資料:
|
|
|
10122 |
#無.
|
|
|
10123 |
#備註:
|
|
|
10124 |
#每個選項傳送的內容,修改成預設爲"true".
|
|
|
10125 |
*/
|
|
|
10126 |
public static function inputCheckBox(&$conf){
|
|
|
10127 |
|
|
|
10128 |
#預設要回傳的數值
|
|
|
10129 |
$result=array();
|
|
|
10130 |
|
|
|
10131 |
#設置當前執行的函式
|
|
|
10132 |
$result["function"]=__FUNCTION__;
|
|
|
10133 |
|
|
|
10134 |
#初始化要回傳的語法
|
|
|
10135 |
$result["content"]="";
|
|
|
10136 |
|
|
|
10137 |
#如果 $conf 不為陣列
|
|
|
10138 |
if(gettype($conf)!="array"){
|
|
|
10139 |
|
|
|
10140 |
#設置執行失敗
|
|
|
10141 |
$result["status"]="false";
|
|
|
10142 |
|
|
|
10143 |
#設置執行錯誤訊息
|
|
|
10144 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
10145 |
|
|
|
10146 |
#如果傳入的參數為 null
|
|
|
10147 |
if($conf==null){
|
|
|
10148 |
|
|
|
10149 |
#設置執行錯誤訊息
|
|
|
10150 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
10151 |
|
|
|
10152 |
}#if end
|
|
|
10153 |
|
|
|
10154 |
#回傳結果
|
|
|
10155 |
return $result;
|
|
|
10156 |
|
|
|
10157 |
}#if end
|
|
|
10158 |
|
|
|
10159 |
#檢查參數
|
|
|
10160 |
#函式說明:
|
|
|
10161 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
10162 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10163 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
10164 |
#$result["function"],當前執行的函式名稱.
|
|
|
10165 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
10166 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
10167 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
10168 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
10169 |
#必填參數:
|
|
|
10170 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
10171 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
10172 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
10173 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("name","sendValue");
|
|
|
10174 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
10175 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array","array");
|
|
|
10176 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
10177 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
10178 |
#可省略參數:
|
|
|
10179 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
10180 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
10181 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
10182 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("class","outputValue","checkedOption","comment","jsActivitor","jsAction","formName","formAction","actionTarget","trStart","tdStart","tdEnd","trEnd","brBetweenOption","hiddenVar","hiddenVarValue","formEnd");
|
|
|
10183 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
10184 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","array","array","string","string","string","string","string","string","string","string","string","string","string","array","array","string");
|
|
|
10185 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
10186 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("__qbpwcf_inputCheckBoxCssStyle","\$conf[\"sendValue\"]",null,null,null,null,null,null,"_self","false","false","false","false","true",null,null,"false");
|
|
|
10187 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
10188 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
10189 |
|
|
|
10190 |
#如果檢查失敗
|
|
|
10191 |
if($checkResult["status"]=="false"){
|
|
|
10192 |
|
|
|
10193 |
#設置執行不正常
|
|
|
10194 |
$result["status"]="false";
|
|
|
10195 |
|
|
|
10196 |
#程式停止執行
|
|
|
10197 |
$result["error"]=$checkResult;
|
|
|
10198 |
|
|
|
10199 |
#回傳結果
|
|
|
10200 |
return $result;
|
|
|
10201 |
|
|
|
10202 |
}#if end
|
|
|
10203 |
|
|
|
10204 |
#如果檢查不通過
|
|
|
10205 |
if($checkResult["passed"]=="false"){
|
|
|
10206 |
|
|
|
10207 |
#設置執行不正常
|
|
|
10208 |
$result["status"]="false";
|
|
|
10209 |
|
|
|
10210 |
#程式停止執行
|
|
|
10211 |
$result["error"]=$checkResult;
|
|
|
10212 |
|
|
|
10213 |
#回傳結果
|
|
|
10214 |
return $result;
|
|
|
10215 |
|
|
|
10216 |
}#if end
|
|
|
10217 |
|
|
|
10218 |
#如果 $conf["formAction"] 有設定
|
|
|
10219 |
if(isset($conf["formAction"])){
|
|
|
10220 |
|
|
|
10221 |
#如果 $conf["actionTarget"] 有設定
|
|
|
10222 |
if(isset($conf["actionTarget"])){
|
|
|
10223 |
|
|
|
10224 |
#指派設定值
|
|
|
10225 |
$conf["form"]["start"]["target"]=$conf["actionTarget"];
|
|
|
10226 |
|
|
|
10227 |
}#if end
|
|
|
10228 |
|
|
|
10229 |
#如果 $conf["formName"] 沒有設置
|
|
|
10230 |
if(!isset($conf["formName"])){
|
|
|
10231 |
|
|
|
10232 |
#預設爲空數值
|
|
|
10233 |
$conf["form"]["start"]["formName"]=" ";
|
|
|
10234 |
|
|
|
10235 |
}#if end
|
|
|
10236 |
|
|
|
10237 |
#函式說明:
|
|
|
10238 |
#表單開始
|
|
|
10239 |
#回傳結果:
|
|
|
10240 |
#$result,表單開始的語法
|
|
|
10241 |
#必填參數:
|
|
|
10242 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
10243 |
#可省略參數:
|
|
|
10244 |
#$conf["form"]["start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
10245 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
10246 |
#$conf["form"]["start"]["target"]=$conf["actionTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
10247 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
10248 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100%
|
|
|
10249 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
10250 |
unset($conf["form"]["start"]);
|
|
|
10251 |
|
|
|
10252 |
#如果表單開始失敗
|
|
|
10253 |
if($formStart["status"]=="false"){
|
|
|
10254 |
|
|
|
10255 |
#設置執行不正常
|
|
|
10256 |
$result["status"]="false";
|
|
|
10257 |
|
|
|
10258 |
#程式停止執行
|
|
|
10259 |
$result["error"]=$formStart;
|
|
|
10260 |
|
|
|
10261 |
#回傳結果
|
|
|
10262 |
return $result;
|
|
|
10263 |
|
|
|
10264 |
}#if end
|
|
|
10265 |
|
|
|
10266 |
#串接表單開始
|
|
|
10267 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
10268 |
|
|
|
10269 |
}#if end
|
|
|
10270 |
|
|
|
10271 |
#如果 $conf["hiddenVar"]與$conf["hiddenVarValue"]皆有設置
|
|
|
10272 |
if(isset($conf["hiddenVar"]) && isset($conf["hiddenVarValue"])){
|
|
|
10273 |
|
|
|
10274 |
#且陣列元素數目相同
|
|
|
10275 |
if(count($conf["hiddenVar"])==count($conf["hiddenVarValue"])){
|
|
|
10276 |
|
|
|
10277 |
#建立隱藏的表單
|
|
|
10278 |
#傳送多個隱藏表單的資訊
|
|
|
10279 |
#回傳的數值:
|
|
|
10280 |
#$result,語法
|
|
|
10281 |
#$result["sendedArrayName"],
|
|
|
10282 |
#$result["sendedArrayValue"],
|
|
|
10283 |
#$result["sendedArrayCount"],
|
|
|
10284 |
#必填參數:
|
|
|
10285 |
$conf["form"]["inputMutiHidden"]["nameArray"]=$conf["hiddenVar"];#欲傳送的隱藏陣列變數名稱
|
|
|
10286 |
$conf["form"]["inputMutiHidden"]["valueArray"]=$conf["hiddenVarValue"];#欲傳送的隱藏陣列變數數值
|
|
|
10287 |
$inputMultiHidden=form::inputMultiHidden($conf["form"]["inputMutiHidden"])["content"];
|
|
|
10288 |
unset($conf["form"]["inputMutiHidden"]);
|
|
|
10289 |
|
|
|
10290 |
#建立隱藏的表單失敗
|
|
|
10291 |
if($inputMultiHidden["status"]=="false"){
|
|
|
10292 |
|
|
|
10293 |
#設置執行不正常
|
|
|
10294 |
$result["status"]="false";
|
|
|
10295 |
|
|
|
10296 |
#程式停止執行
|
|
|
10297 |
$result["error"]=$inputMultiHidden;
|
|
|
10298 |
|
|
|
10299 |
#回傳結果
|
|
|
10300 |
return $result;
|
|
|
10301 |
|
|
|
10302 |
}#if end
|
|
|
10303 |
|
|
|
10304 |
#串接隱藏的表單
|
|
|
10305 |
$result["content"]=$result["content"].$inputMultiHidden;
|
|
|
10306 |
|
|
|
10307 |
}#if end
|
|
|
10308 |
|
|
|
10309 |
}#if end
|
|
|
10310 |
|
|
|
10311 |
#如果其值爲 true
|
|
|
10312 |
if($conf["trStart"]=="true"){
|
|
|
10313 |
|
|
|
10314 |
#串接列開始
|
|
|
10315 |
$result["content"]=$result["content"]."<tr>";
|
|
|
10316 |
|
|
|
10317 |
}#if end
|
|
|
10318 |
|
|
|
10319 |
#如果其值爲 true
|
|
|
10320 |
if($conf["tdStart"]=="true"){
|
|
|
10321 |
|
|
|
10322 |
#串接欄開始
|
|
|
10323 |
$result["content"]=$result["content"]."<td>";
|
|
|
10324 |
|
|
|
10325 |
}#if end
|
|
|
10326 |
|
|
|
10327 |
#如果$conf["outputValue"]沒設定
|
|
|
10328 |
if(!isset($conf["outputValue"])){
|
|
|
10329 |
|
|
|
10330 |
#則$conf["outputValue"]陣列內容將會等於$conf["sendValue"]陣列內容
|
|
|
10331 |
$conf["outputValue"]=$conf["sendValue"];
|
|
|
10332 |
|
|
|
10333 |
}#if end
|
|
|
10334 |
|
|
|
10335 |
#如果$conf["class"]沒設定
|
|
|
10336 |
if(!isset($conf["class"])){
|
|
|
10337 |
|
|
|
10338 |
#則$conf["class"]爲空
|
|
|
10339 |
$conf["class"]="";
|
|
|
10340 |
|
|
|
10341 |
}#if end
|
|
|
10342 |
|
|
|
10343 |
#如果有$conf["class"]有設定
|
|
|
10344 |
else{
|
|
|
10345 |
|
|
|
10346 |
#則按照設定值
|
|
|
10347 |
$conf["class"]=" class=".$conf["class"];
|
|
|
10348 |
|
|
|
10349 |
}#else end
|
|
|
10350 |
|
|
|
10351 |
#如果 $conf["jsActivitor"] 與 $conf["jsAction"] 皆有設定
|
|
|
10352 |
if( isset($conf["jsActivitor"]) && isset($conf["jsAction"]) ){
|
|
|
10353 |
|
|
|
10354 |
#則將設定值組合
|
|
|
10355 |
$conf["jsCustom"]=" ".$conf["jsActivitor"]."=".$conf["jsAction"]." ";
|
|
|
10356 |
|
|
|
10357 |
}#if end
|
|
|
10358 |
|
|
|
10359 |
#如果 $conf["jsCustom"] 沒有設定
|
|
|
10360 |
if(!isset($conf["jsCustom"])){
|
|
|
10361 |
|
|
|
10362 |
#將其設爲空值
|
|
|
10363 |
$conf["jsCustom"]="";
|
|
|
10364 |
|
|
|
10365 |
}#if end
|
|
|
10366 |
|
|
|
10367 |
#將有幾個選項的數目放進 $count
|
|
|
10368 |
$count=count($conf["sendValue"]);
|
|
|
10369 |
|
|
|
10370 |
#如果 $conf["comment"] 有設定
|
|
|
10371 |
if(isset($conf["comment"])){
|
|
|
10372 |
|
|
|
10373 |
#一開始先擺註解
|
|
|
10374 |
$result["content"]=$result["content"]."<span ".$conf["class"].">".$conf["comment"]."</span><br>";
|
|
|
10375 |
|
|
|
10376 |
}#if end
|
|
|
10377 |
|
|
|
10378 |
#有幾個選項就執行幾次
|
|
|
10379 |
for($i=0;$i<$count;$i++){
|
|
|
10380 |
|
|
|
10381 |
#如果 $conf["checkedOption"] 參數存在
|
|
|
10382 |
if(isset($conf["checkedOption"])){
|
|
|
10383 |
|
|
|
10384 |
#檢查多個數值,是否與陣列裏面的某些元素相同。
|
|
|
10385 |
#回傳結果:
|
|
|
10386 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10387 |
#$result["function"],當前執行的函數
|
|
|
10388 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
10389 |
#$result["founded"][$i],若爲"false"代表沒有相同的元素;反之"true"代表有相同的元素,$i爲第i+1個參數判斷後的結果。
|
|
|
10390 |
#必填參數:
|
|
|
10391 |
$conf_checkEquality["inputElement"]=array($i+1);#爲要進行比對的變數/數值。
|
|
|
10392 |
$conf_checkEquality["blackBoxElement"]=$conf["checkedOption"];#爲用來比對的變數/數值陣列
|
|
|
10393 |
$result_checkEquality=search::checkEquality($conf_checkEquality);
|
|
|
10394 |
unset($conf_checkEquality);
|
|
|
10395 |
|
|
|
10396 |
#如果檢查失敗
|
|
|
10397 |
if($result_checkEquality["status"]=="false"){
|
|
|
10398 |
|
|
|
10399 |
#設置執行不正常
|
|
|
10400 |
$result["status"]="false";
|
|
|
10401 |
|
|
|
10402 |
#程式停止執行
|
|
|
10403 |
$result["error"]=$result_checkEquality;
|
|
|
10404 |
|
|
|
10405 |
#回傳結果
|
|
|
10406 |
return $result;
|
|
|
10407 |
|
|
|
10408 |
}#if end
|
|
|
10409 |
|
|
|
10410 |
#如果 $result_checkEquality"founded"][$i] 存在
|
|
|
10411 |
if(isset($result_checkEquality["founded"][0])){
|
|
|
10412 |
|
|
|
10413 |
#如果該選項是要勾選的
|
|
|
10414 |
if($result_checkEquality["founded"][0]=="true"){
|
|
|
10415 |
|
|
|
10416 |
#選取
|
|
|
10417 |
$checked=" checked ";
|
|
|
10418 |
|
|
|
10419 |
}#if end
|
|
|
10420 |
|
|
|
10421 |
#反之
|
|
|
10422 |
else{
|
|
|
10423 |
|
|
|
10424 |
#不選取
|
|
|
10425 |
$checked="";
|
|
|
10426 |
|
|
|
10427 |
}#else end
|
|
|
10428 |
|
|
|
10429 |
}#if end
|
|
|
10430 |
|
|
|
10431 |
#反之
|
|
|
10432 |
else{
|
|
|
10433 |
|
|
|
10434 |
#不選取
|
|
|
10435 |
$checked="";
|
|
|
10436 |
|
|
|
10437 |
}#else end
|
|
|
10438 |
|
|
|
10439 |
}#if end
|
|
|
10440 |
|
|
|
10441 |
#反之
|
|
|
10442 |
else{
|
|
|
10443 |
|
|
|
10444 |
#不選取
|
|
|
10445 |
$checked="";
|
|
|
10446 |
|
|
|
10447 |
}#else end
|
|
|
10448 |
|
|
|
10449 |
#放置勾選式表單
|
|
|
10450 |
$result["content"]=$result["content"]."<label><input type = \"checkbox\" name = ".$conf["name"][$i]." value = ".$conf["sendValue"][$i]." ".$conf["class"]." ".$checked." ".$conf["jsCustom"]." >" ."<span ".$conf["class"].">".$conf["outputValue"][$i]."</span>"."</label>";
|
|
|
10451 |
|
|
|
10452 |
#如果 $conf["brBetweenOption"] 有設定
|
|
|
10453 |
if(isset($conf["brBetweenOption"])){
|
|
|
10454 |
|
|
|
10455 |
#如果 $conf["brBetweenOption"] 等於 "true"
|
|
|
10456 |
if($conf["brBetweenOption"]=="true"){
|
|
|
10457 |
|
|
|
10458 |
#如果不是最後一個選項
|
|
|
10459 |
if($i!=$count-1){
|
|
|
10460 |
|
|
|
10461 |
#加上<br>標籤
|
|
|
10462 |
$result["content"]=$result["content"]."<br>";
|
|
|
10463 |
|
|
|
10464 |
}#if end
|
|
|
10465 |
|
|
|
10466 |
}#if end
|
|
|
10467 |
|
|
|
10468 |
}#if end
|
|
|
10469 |
|
|
|
10470 |
}#for end
|
|
|
10471 |
|
|
|
10472 |
#如果其值爲 true
|
|
|
10473 |
if($conf["tdEnd"]=="true"){
|
|
|
10474 |
|
|
|
10475 |
#串接欄結束
|
|
|
10476 |
$result["content"]=$result["content"]."</td>";
|
|
|
10477 |
|
|
|
10478 |
}#if end
|
|
|
10479 |
|
|
|
10480 |
#如果其值爲 true
|
|
|
10481 |
if($conf["trEnd"]=="true"){
|
|
|
10482 |
|
|
|
10483 |
#串接列結束
|
|
|
10484 |
$result["content"]=$result["content"]."</tr>";
|
|
|
10485 |
|
|
|
10486 |
}#if end
|
|
|
10487 |
|
|
|
10488 |
#如果 $conf["formAction"] 有設定
|
|
|
10489 |
if(isset($conf["formAction"])){
|
|
|
10490 |
|
|
|
10491 |
#如果有設置 $conf["formEnd"]
|
|
|
10492 |
if(isset($conf["formEnd"])){
|
|
|
10493 |
|
|
|
10494 |
#如果 $conf["formEnd"] 設爲 "true"
|
|
|
10495 |
if($conf["formEnd"]=="true"){
|
|
|
10496 |
|
|
|
10497 |
#函式說明:
|
|
|
10498 |
#表單結束
|
|
|
10499 |
#回傳結果:
|
|
|
10500 |
#$result,表單結束的語法
|
|
|
10501 |
#必填參數:
|
|
|
10502 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
10503 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
10504 |
unset($conf["form"]["end"]);
|
|
|
10505 |
|
|
|
10506 |
#如果表單結束失敗
|
|
|
10507 |
if($formEnd["status"]=="false"){
|
|
|
10508 |
|
|
|
10509 |
#設置執行不正常
|
|
|
10510 |
$result["status"]="false";
|
|
|
10511 |
|
|
|
10512 |
#程式停止執行
|
|
|
10513 |
$result["error"]=$formEnd;
|
|
|
10514 |
|
|
|
10515 |
#回傳結果
|
|
|
10516 |
return $result;
|
|
|
10517 |
|
|
|
10518 |
}#if end
|
|
|
10519 |
|
|
|
10520 |
#串接表單結束
|
|
|
10521 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
10522 |
|
|
|
10523 |
}#if end
|
|
|
10524 |
|
|
|
10525 |
}#if end
|
|
|
10526 |
|
|
|
10527 |
}#if end
|
|
|
10528 |
|
|
|
10529 |
#反之沒有設置$conf["formAction"]
|
|
|
10530 |
else{
|
|
|
10531 |
|
|
|
10532 |
#如果 $conf["formEnd"] 設爲 "true"
|
|
|
10533 |
if($conf["formEnd"]=="true"){
|
|
|
10534 |
|
|
|
10535 |
#函式說明:
|
|
|
10536 |
#表單結束
|
|
|
10537 |
#回傳結果:
|
|
|
10538 |
#$result,表單結束的語法
|
|
|
10539 |
#必填參數:
|
|
|
10540 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
10541 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
10542 |
unset($conf["form"]["end"]);
|
|
|
10543 |
|
|
|
10544 |
#如果表單結束失敗
|
|
|
10545 |
if($formEnd["status"]==="false"){
|
|
|
10546 |
|
|
|
10547 |
#設置執行不正常
|
|
|
10548 |
$result["status"]="false";
|
|
|
10549 |
|
|
|
10550 |
#程式停止執行
|
|
|
10551 |
$result["error"]=$formEnd;
|
|
|
10552 |
|
|
|
10553 |
#回傳結果
|
|
|
10554 |
return $result;
|
|
|
10555 |
|
|
|
10556 |
}#if end
|
|
|
10557 |
|
|
|
10558 |
#串接表單結束
|
|
|
10559 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
10560 |
|
|
|
10561 |
}#if end
|
|
|
10562 |
|
|
|
10563 |
}#else end
|
|
|
10564 |
|
|
|
10565 |
#設置執行成功
|
|
|
10566 |
$result["status"]="true";
|
|
|
10567 |
|
|
|
10568 |
#回傳結果
|
|
|
10569 |
return $result;
|
|
|
10570 |
|
|
|
10571 |
}#function inputCheckBox end
|
|
|
10572 |
|
|
|
10573 |
/*
|
|
|
10574 |
#函式說明:
|
|
|
10575 |
#隱藏的表單傳送資訊
|
|
|
10576 |
#回傳結果:
|
|
|
10577 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10578 |
#$result["error"],錯誤訊息
|
|
|
10579 |
#$result["content"],語法
|
|
|
10580 |
#$result["function"],當前執行的函數名稱
|
|
|
10581 |
#必填參數:
|
|
|
10582 |
$conf["name"]="";#隱藏的表單名稱
|
|
|
10583 |
$conf["value"]="";#等於要傳送的數值
|
|
|
10584 |
#可省略參數:
|
|
|
10585 |
#無.
|
|
|
10586 |
#參考資料:
|
|
|
10587 |
#無.
|
|
|
10588 |
#備註:
|
|
|
10589 |
#無.
|
|
|
10590 |
*/
|
|
|
10591 |
public static function inputHidden($conf){
|
|
|
10592 |
|
|
|
10593 |
#初始化要回傳的變數
|
|
|
10594 |
$result=array();
|
|
|
10595 |
|
|
|
10596 |
#設置當前執行的函式
|
|
|
10597 |
$result["function"]=__FUNCTION__;
|
|
|
10598 |
|
|
|
10599 |
#初始化表單開始的語法
|
|
|
10600 |
$result["content"]="";
|
|
|
10601 |
|
|
|
10602 |
#如果 $conf 不為陣列
|
|
|
10603 |
if(gettype($conf)!="array"){
|
|
|
10604 |
|
|
|
10605 |
#設置執行失敗
|
|
|
10606 |
$result["status"]="false";
|
|
|
10607 |
|
|
|
10608 |
#設置執行錯誤訊息
|
|
|
10609 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
10610 |
|
|
|
10611 |
#如果傳入的參數為 null
|
|
|
10612 |
if($conf==null){
|
|
|
10613 |
|
|
|
10614 |
#設置執行錯誤訊息
|
|
|
10615 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
10616 |
|
|
|
10617 |
}#if end
|
|
|
10618 |
|
|
|
10619 |
#回傳結果
|
|
|
10620 |
return $result;
|
|
|
10621 |
|
|
|
10622 |
}#if end
|
|
|
10623 |
|
|
|
10624 |
#檢查參數
|
|
|
10625 |
#函式說明:
|
|
|
10626 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
10627 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10628 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
10629 |
#$result["function"],當前執行的函式名稱.
|
|
|
10630 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
10631 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
10632 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
10633 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
10634 |
#必填參數:
|
|
|
10635 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
10636 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
10637 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
10638 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name","value");
|
|
|
10639 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
10640 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
10641 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
10642 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
10643 |
#可省略參數:
|
|
|
10644 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
10645 |
#$conf["canBeEmptyString"]="false";
|
|
|
10646 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
10647 |
#$conf["skipableVariableName"]=array();
|
|
|
10648 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
10649 |
#$conf["skipableVariableType"]=array();
|
|
|
10650 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
10651 |
#$conf["skipableVarDefaultValue"]=array("");
|
|
|
10652 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
10653 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
10654 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
10655 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
10656 |
|
|
|
10657 |
#如果檢查參數失敗
|
|
|
10658 |
if($checkResult["status"]=="false"){
|
|
|
10659 |
|
|
|
10660 |
#設置執行失敗
|
|
|
10661 |
$result["status"]="false";
|
|
|
10662 |
|
|
|
10663 |
#設置執行錯誤
|
|
|
10664 |
$result["error"]=$checkResult;
|
|
|
10665 |
|
|
|
10666 |
#回傳結果
|
|
|
10667 |
return $result;
|
|
|
10668 |
|
|
|
10669 |
}#if end
|
|
|
10670 |
|
|
|
10671 |
#如果檢查參數不通過
|
|
|
10672 |
if($checkResult["passed"]=="false"){
|
|
|
10673 |
|
|
|
10674 |
#設置執行失敗
|
|
|
10675 |
$result["status"]="false";
|
|
|
10676 |
|
|
|
10677 |
#設置執行錯誤
|
|
|
10678 |
$result["error"]=$checkResult;
|
|
|
10679 |
|
|
|
10680 |
#回傳結果
|
|
|
10681 |
return $result;
|
|
|
10682 |
|
|
|
10683 |
}#if end
|
|
|
10684 |
|
|
|
10685 |
#放置隱藏的表單
|
|
|
10686 |
$result["content"]="<input type = hidden name = ".$conf["name"]." value = \"".$conf["value"]."\">";
|
|
|
10687 |
|
|
|
10688 |
#執行到這邊代表執行正常
|
|
|
10689 |
$result["status"]="true";
|
|
|
10690 |
|
|
|
10691 |
#回傳結果
|
|
|
10692 |
return $result;
|
|
|
10693 |
|
|
|
10694 |
}#function inputHidden end
|
|
|
10695 |
|
|
|
10696 |
/*
|
|
|
10697 |
#函式說明:
|
|
|
10698 |
#傳送多個隱藏表單的資訊
|
|
|
10699 |
#回傳的數值:
|
|
|
10700 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10701 |
#$result["error"],錯誤訊息陣列
|
|
|
10702 |
#$result["function"],當前執行的函數
|
|
|
10703 |
#$result["content"],語法
|
|
|
10704 |
#$result["sendedArrayName"],傳送的隱藏變數陣列
|
|
|
10705 |
#$result["sendedArrayValue"],傳送的隱藏變數陣列數值
|
|
|
10706 |
#$result["sendedArrayCount"],傳送的隱藏變數計數
|
|
|
10707 |
#必填參數:
|
|
|
10708 |
$conf["nameArray"]=array("");#欲傳送的隱藏陣列變數名稱
|
|
|
10709 |
$conf["valueArray"]=array("");#欲傳送的隱藏陣列變數數值
|
|
|
10710 |
#可省略參數:
|
|
|
10711 |
#無.
|
|
|
10712 |
#參考資料:
|
|
|
10713 |
#無.
|
|
|
10714 |
#備註:
|
|
|
10715 |
#無.
|
|
|
10716 |
*/
|
|
|
10717 |
public static function inputMultiHidden(&$conf){
|
|
|
10718 |
|
|
|
10719 |
#預設要回傳的數值
|
|
|
10720 |
$result=array();
|
|
|
10721 |
|
|
|
10722 |
#設置當前執行的函數
|
|
|
10723 |
$result["function"]=__FUNCTION__;
|
|
|
10724 |
|
|
|
10725 |
#初始化要回傳的語法
|
|
|
10726 |
$result["content"]="";
|
|
|
10727 |
|
|
|
10728 |
#如果 $conf 不為陣列
|
|
|
10729 |
if(gettype($conf)!="array"){
|
|
|
10730 |
|
|
|
10731 |
#設置執行失敗
|
|
|
10732 |
$result["status"]="false";
|
|
|
10733 |
|
|
|
10734 |
#設置執行錯誤訊息
|
|
|
10735 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
10736 |
|
|
|
10737 |
#如果傳入的參數為 null
|
|
|
10738 |
if($conf==null){
|
|
|
10739 |
|
|
|
10740 |
#設置執行錯誤訊息
|
|
|
10741 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
10742 |
|
|
|
10743 |
}#if end
|
|
|
10744 |
|
|
|
10745 |
#回傳結果
|
|
|
10746 |
return $result;
|
|
|
10747 |
|
|
|
10748 |
}#if end
|
|
|
10749 |
|
|
|
10750 |
#檢查參數
|
|
|
10751 |
#函式說明:
|
|
|
10752 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
10753 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10754 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
10755 |
#$result["function"],當前執行的函式名稱.
|
|
|
10756 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
10757 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
10758 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
10759 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
10760 |
#必填參數:
|
|
|
10761 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
10762 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
10763 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
10764 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("nameArray","valueArray");
|
|
|
10765 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
10766 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array","array");
|
|
|
10767 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
10768 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
10769 |
#可省略參數:
|
|
|
10770 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
10771 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
10772 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
10773 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("width","maxInputLength","defaultValue","class","jsActivitor","jsAction","trStart","tdStart","tdEnd","trEnd","comment","placeholder");
|
|
|
10774 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
10775 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
10776 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
10777 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"__inputPasswordCssStyle",null,null,"false","false","false","false",null,null);
|
|
|
10778 |
#$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
10779 |
$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"][]=array("nameArray","valueArray");
|
|
|
10780 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
10781 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
10782 |
|
|
|
10783 |
#如果檢查失敗
|
|
|
10784 |
if($checkResult["status"]=="false"){
|
|
|
10785 |
|
|
|
10786 |
#設置執行不正常
|
|
|
10787 |
$result["status"]="false";
|
|
|
10788 |
|
|
|
10789 |
#程式停止執行
|
|
|
10790 |
$result["error"]=$checkResult;
|
|
|
10791 |
|
|
|
10792 |
#回傳結果
|
|
|
10793 |
return $result;
|
|
|
10794 |
|
|
|
10795 |
}#if end
|
|
|
10796 |
|
|
|
10797 |
#如果檢查不通過
|
|
|
10798 |
if($checkResult["passed"]=="false"){
|
|
|
10799 |
|
|
|
10800 |
#設置執行不正常
|
|
|
10801 |
$result["status"]="false";
|
|
|
10802 |
|
|
|
10803 |
#程式停止執行
|
|
|
10804 |
$result["error"]=$checkResult;
|
|
|
10805 |
|
|
|
10806 |
#回傳結果
|
|
|
10807 |
return $result;
|
|
|
10808 |
|
|
|
10809 |
}#if end
|
|
|
10810 |
|
|
|
10811 |
#透過foreach建立陣列
|
|
|
10812 |
#將陣列的key重新排序,然後回傳,以便後續存取,也可以指定key的內容,但一定要跟元素數量相同。
|
|
|
10813 |
#回傳的解果:
|
|
|
10814 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
10815 |
#$result["error"],執行錯誤的訊息.
|
|
|
10816 |
#$result["function"],當前執行的函數名稱.
|
|
|
10817 |
#$result["dataContent"],儲存陣列元素的內容.
|
|
|
10818 |
#必填參數:
|
|
|
10819 |
$conf_createV2["arrayContent"]=$conf["nameArray"];#陣列元素的value,須爲陣列值。
|
|
|
10820 |
#可省略的參數:
|
|
|
10821 |
#$conf["arrayCounts"]="";#爲陣列的元素有幾個,若沒設定,則數量爲$conf["arrayContent"]裏的元素數量
|
|
|
10822 |
#$conf["theSameAs"]="true";#若設爲"true",則所有元素內容都跟第一個元素內容相同
|
|
|
10823 |
$result_nameArray=arrays::createV2($conf_createV2);
|
|
|
10824 |
unset($conf_createV2);
|
|
|
10825 |
|
|
|
10826 |
#如果重新排序陣列失敗
|
|
|
10827 |
if($result_nameArray["status"]=="false"){
|
|
|
10828 |
|
|
|
10829 |
#設置執行不正常
|
|
|
10830 |
$result["status"]="false";
|
|
|
10831 |
|
|
|
10832 |
#程式停止執行
|
|
|
10833 |
$result["error"]=$result_nameArray;
|
|
|
10834 |
|
|
|
10835 |
#回傳結果
|
|
|
10836 |
return $result;
|
|
|
10837 |
|
|
|
10838 |
}#if end
|
|
|
10839 |
|
|
|
10840 |
#透過foreach建立陣列
|
|
|
10841 |
#將陣列的key重新排序,然後回傳,以便後續存取。
|
|
|
10842 |
#回傳的解果:
|
|
|
10843 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
10844 |
#$result["error"],執行錯誤的訊息.
|
|
|
10845 |
#$result["function"],當前執行的函數名稱.
|
|
|
10846 |
#$result["dataContent"],儲存陣列元素的內容.
|
|
|
10847 |
#必填參數:
|
|
|
10848 |
$conf_createV2["arrayContent"]=$conf["valueArray"];#陣列元素的value,須爲陣列值。
|
|
|
10849 |
#可省略的參數:
|
|
|
10850 |
#$conf["arrayCounts"]="";#爲陣列的元素有幾個,若沒設定,則數量爲$conf["arrayContent"]裏的元素數量
|
|
|
10851 |
#$conf["theSameAs"]="true";#若設爲"true",則所有元素內容都跟第一個元素內容相同
|
|
|
10852 |
$result_valueArray=arrays::createV2($conf_createV2);
|
|
|
10853 |
unset($conf_createV2);
|
|
|
10854 |
|
|
|
10855 |
#如果重新排序陣列失敗
|
|
|
10856 |
if($result_valueArray["status"]=="false"){
|
|
|
10857 |
|
|
|
10858 |
#設置執行不正常
|
|
|
10859 |
$result["status"]="false";
|
|
|
10860 |
|
|
|
10861 |
#程式停止執行
|
|
|
10862 |
$result["error"]=$result_valueArray;
|
|
|
10863 |
|
|
|
10864 |
#回傳結果
|
|
|
10865 |
return $result;
|
|
|
10866 |
|
|
|
10867 |
}#if end
|
|
|
10868 |
|
|
|
10869 |
#有幾個要傳送的元素就執行幾次
|
|
|
10870 |
for($i=0;$i<count($conf["nameArray"]);$i++){
|
|
|
10871 |
|
|
|
10872 |
#隱藏的表單傳送資訊
|
|
|
10873 |
#必填參數:
|
|
|
10874 |
$conf_inputHidden["name"]=$result_nameArray["dataContent"][$i];#隱藏的表單名稱
|
|
|
10875 |
$conf_inputHidden["value"]=$result_valueArray["dataContent"][$i];#等於要穿送的數值
|
|
|
10876 |
$inputHidden=form::inputHidden($conf_inputHidden);
|
|
|
10877 |
unset($conf_inputHidden);
|
|
|
10878 |
|
|
|
10879 |
#如果建立隱藏的表單失敗
|
|
|
10880 |
if($inputHidden["status"]=="false"){
|
|
|
10881 |
|
|
|
10882 |
#設置錯誤
|
|
|
10883 |
$result["status"]="false";
|
|
|
10884 |
|
|
|
10885 |
#設置錯誤訊息
|
|
|
10886 |
$result["error"]=$inputHidden;
|
|
|
10887 |
|
|
|
10888 |
#回傳結果
|
|
|
10889 |
return $inputHidden;
|
|
|
10890 |
|
|
|
10891 |
}#if end
|
|
|
10892 |
|
|
|
10893 |
#串接 隱藏的表單
|
|
|
10894 |
$result["content"]=$result["content"].$inputHidden["content"];
|
|
|
10895 |
|
|
|
10896 |
}#for end
|
|
|
10897 |
|
|
|
10898 |
#設置執行正常
|
|
|
10899 |
$result["status"]="true";
|
|
|
10900 |
|
|
|
10901 |
#回傳結果
|
|
|
10902 |
return $result;
|
|
|
10903 |
|
|
|
10904 |
}#function inputMutiHidden end
|
|
|
10905 |
|
|
|
10906 |
/*
|
|
|
10907 |
#函式說明:
|
|
|
10908 |
#簡單的控制面板,可以點選"新增"、"回上頁"的簡易面板
|
|
|
10909 |
#回傳的結果:
|
|
|
10910 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10911 |
#$result["error"],錯誤訊息
|
|
|
10912 |
#$result["content"],控制面板的語法
|
|
|
10913 |
#$result["function"],當前執行的函數名稱
|
|
|
10914 |
#必填參數:
|
|
|
10915 |
$conf["addActionPage"]="";#不可省略,爲新增表單要交給那個頁面處理,屬性內容爲網頁位置。
|
|
|
10916 |
$conf["goBackActionPage"]="";#不可省略,爲回上頁的目的地,屬性內容爲網頁位置。
|
|
|
10917 |
#可省略參數:
|
|
|
10918 |
#$conf["addActionPresentPage"]="";#可省略,爲新增表單的處理頁面要在那邊出現,可以用的數值有 _self (面板所處的頁面) _parent (父頁面) _blank (新視窗) 頁框名稱,預設爲_self
|
|
|
10919 |
#$conf["addButtonName"]="";#可省略,預設爲"新增",爲新增表單的按鈕顯示名稱,屬性內容爲字串。
|
|
|
10920 |
#$conf["addButtonStyleName"]="";#可省略,爲新增表單的按鈕css樣式,屬性內容爲 css 的類別名稱。
|
|
|
10921 |
#$conf["goBackActionPresentPage"]="";#可省略,爲回上頁的目的地的頁面要在那邊出現,可以用的數值有 _self (面板所處的頁面) _parent (父頁面) _blank (新視窗) 頁框名稱,預設爲_self
|
|
|
10922 |
#$conf["goBackButtonName"]="";#可省略,預設爲"回上頁",爲回上頁的按鈕顯示名稱,屬性內容爲字串。
|
|
|
10923 |
#$conf["goBackButtonStyleName"]="";#可省略,爲回上頁按鈕的css樣式,屬性內容爲 css 的類別名稱。
|
|
|
10924 |
#參考資料:
|
|
|
10925 |
#無.
|
|
|
10926 |
#備註:
|
|
|
10927 |
#無.
|
|
|
10928 |
*/
|
|
|
10929 |
public static function simpleControlPanel($conf){
|
|
|
10930 |
|
|
|
10931 |
#初始化要回傳的內容
|
|
|
10932 |
$result=array();
|
|
|
10933 |
|
|
|
10934 |
#設置當前執行的函數
|
|
|
10935 |
$result["function"]=__FUNCTION__;
|
|
|
10936 |
|
|
|
10937 |
#初始化content樣式內容
|
|
|
10938 |
$result["content"]="";
|
|
|
10939 |
|
|
|
10940 |
#如果 $conf 不為陣列
|
|
|
10941 |
if(gettype($conf)!="array"){
|
|
|
10942 |
|
|
|
10943 |
#設置執行失敗
|
|
|
10944 |
$result["status"]="false";
|
|
|
10945 |
|
|
|
10946 |
#設置執行錯誤訊息
|
|
|
10947 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
10948 |
|
|
|
10949 |
#如果傳入的參數為 null
|
|
|
10950 |
if($conf==null){
|
|
|
10951 |
|
|
|
10952 |
#設置執行錯誤訊息
|
|
|
10953 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
10954 |
|
|
|
10955 |
}#if end
|
|
|
10956 |
|
|
|
10957 |
#回傳結果
|
|
|
10958 |
return $result;
|
|
|
10959 |
|
|
|
10960 |
}#if end
|
|
|
10961 |
|
|
|
10962 |
#檢查參數
|
|
|
10963 |
#函式說明:
|
|
|
10964 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
10965 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
10966 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
10967 |
#$result["function"],當前執行的函式名稱.
|
|
|
10968 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
10969 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
10970 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
10971 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
10972 |
#必填參數:
|
|
|
10973 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
10974 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
10975 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
10976 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("addActionPage","goBackActionPage");
|
|
|
10977 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
10978 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
10979 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
10980 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
10981 |
#可省略參數:
|
|
|
10982 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
10983 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
10984 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
10985 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("addActionPresentPage","addButtonName","addButtonStyleName","goBackActionPresentPage","goBackButtonName","goBackButtonStyleName");
|
|
|
10986 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
10987 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string");
|
|
|
10988 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
10989 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array("_self","新增","__simpleButtonLinkDefaultButtonCssStyle","_self","回上頁","__simpleButtonLinkDefaultButtonCssStyle");
|
|
|
10990 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
10991 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
10992 |
|
|
|
10993 |
#如果檢查失敗
|
|
|
10994 |
if($checkResult["status"]=="false"){
|
|
|
10995 |
|
|
|
10996 |
#設置執行不正常
|
|
|
10997 |
$result["status"]="false";
|
|
|
10998 |
|
|
|
10999 |
#程式停止執行
|
|
|
11000 |
$result["error"]=$checkResult;
|
|
|
11001 |
|
|
|
11002 |
#回傳結果
|
|
|
11003 |
return $result;
|
|
|
11004 |
|
|
|
11005 |
}#if end
|
|
|
11006 |
|
|
|
11007 |
#如果檢查不通過
|
|
|
11008 |
if($checkResult["passed"]=="false"){
|
|
|
11009 |
|
|
|
11010 |
#設置執行不正常
|
|
|
11011 |
$result["status"]="false";
|
|
|
11012 |
|
|
|
11013 |
#程式停止執行
|
|
|
11014 |
$result["error"]=$checkResult;
|
|
|
11015 |
|
|
|
11016 |
#回傳結果
|
|
|
11017 |
return $result;
|
|
|
11018 |
|
|
|
11019 |
}#if end
|
|
|
11020 |
|
|
|
11021 |
#新增的按鈕
|
|
|
11022 |
#函式說明:
|
|
|
11023 |
#放置按鈕
|
|
|
11024 |
#回傳結果:
|
|
|
11025 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11026 |
#$result["function"],當前執行的函數.
|
|
|
11027 |
#$result["error"],錯誤訊息陣列.
|
|
|
11028 |
#$result["content"],按鈕語法.
|
|
|
11029 |
#必填參數:
|
|
|
11030 |
$conf["form::button"]["buttonDisplayValue"]=$conf["addButtonName"];#爲按鈕上顯示的文字。
|
|
|
11031 |
#可省略參數:
|
|
|
11032 |
$conf["form::button"]["buttonStyleName"]=$conf["addButtonStyleName"];#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
11033 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
11034 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
11035 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
11036 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
11037 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
11038 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
11039 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
11040 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
11041 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
11042 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
11043 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
11044 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
11045 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11046 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
11047 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
11048 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
11049 |
$conf["form::button"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
11050 |
$conf["form::button"]["action"]=$conf["addActionPage"];#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
11051 |
$conf["form::button"]["target"]=$conf["addActionPresentPage"];#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
11052 |
$conf["form::button"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
11053 |
#參考資料:
|
|
|
11054 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
11055 |
$addButton=form::button($conf["form::button"]);
|
|
|
11056 |
unset($conf["form::button"]);
|
|
|
11057 |
|
|
|
11058 |
#如果建立新增按鈕失敗
|
|
|
11059 |
if($addButton["status"]=="false"){
|
|
|
11060 |
|
|
|
11061 |
#設置執行不正常
|
|
|
11062 |
$result["status"]="false";
|
|
|
11063 |
|
|
|
11064 |
#程式停止執行
|
|
|
11065 |
$result["error"]=$addButton;
|
|
|
11066 |
|
|
|
11067 |
#回傳結果
|
|
|
11068 |
return $result;
|
|
|
11069 |
|
|
|
11070 |
}#if end
|
|
|
11071 |
|
|
|
11072 |
#回前頁的按鈕
|
|
|
11073 |
#函式說明:
|
|
|
11074 |
#放置按鈕
|
|
|
11075 |
#回傳結果:
|
|
|
11076 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11077 |
#$result["function"],當前執行的函數.
|
|
|
11078 |
#$result["error"],錯誤訊息陣列.
|
|
|
11079 |
#$result["content"],按鈕語法.
|
|
|
11080 |
#必填參數:
|
|
|
11081 |
$conf["form::button"]["buttonDisplayValue"]=$conf["goBackButtonName"];#爲按鈕上顯示的文字。
|
|
|
11082 |
#可省略參數:
|
|
|
11083 |
$conf["form::button"]["buttonStyleName"]=$conf["goBackButtonStyleName"];#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
11084 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
11085 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
11086 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
11087 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
11088 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
11089 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
11090 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
11091 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
11092 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
11093 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
11094 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
11095 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
11096 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11097 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
11098 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
11099 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
11100 |
$conf["form::button"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
11101 |
$conf["form::button"]["action"]=$conf["goBackActionPage"];#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
11102 |
$conf["form::button"]["target"]=$conf["goBackActionPresentPage"];#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
11103 |
$conf["form::button"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
11104 |
#參考資料:
|
|
|
11105 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
11106 |
$backButton=form::button($conf["form::button"]);
|
|
|
11107 |
unset($conf["form::button"]);
|
|
|
11108 |
|
|
|
11109 |
#如果建立回上頁按鈕失敗
|
|
|
11110 |
if($backButton["status"]=="false"){
|
|
|
11111 |
|
|
|
11112 |
#設置執行不正常
|
|
|
11113 |
$result["status"]="false";
|
|
|
11114 |
|
|
|
11115 |
#程式停止執行
|
|
|
11116 |
$result["error"]=$backButton;
|
|
|
11117 |
|
|
|
11118 |
#回傳結果
|
|
|
11119 |
return $result;
|
|
|
11120 |
|
|
|
11121 |
}#if end
|
|
|
11122 |
|
|
|
11123 |
#函式說明:
|
|
|
11124 |
#建立列的元素,以及指定裏面要放什麼內容
|
|
|
11125 |
#回傳的變數:
|
|
|
11126 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
11127 |
#$result["error"],錯誤訊息陣列.
|
|
|
11128 |
#$result["function"],當前執行的函數名稱.
|
|
|
11129 |
#$result["content"],建立列元素的語法.
|
|
|
11130 |
#必填參數:
|
|
|
11131 |
$conf["table"]["printRow"]["trClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11132 |
$conf["table"]["printRow"]["tdClass"]="__withoutBorder";#行的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11133 |
$conf["table"]["printRow"]["tdContent"]=array($backButton["content"],$addButton["content"]);#列裏面要放的元素是?如果要空一列則可以輸array(" ")
|
|
|
11134 |
#可省略參數:
|
|
|
11135 |
$conf["table"]["printRow"]["tableStartClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11136 |
#$conf["tableBorder"]="1px";#表格的厚度預設為"1px"
|
|
|
11137 |
$conf["table"]["printRow"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是"。
|
|
|
11138 |
$conf["table"]["printRow"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是"。
|
|
|
11139 |
#$conf["formStart"]="true";#是否要有表單的開始
|
|
|
11140 |
#$conf["formName"]="";#該表單的名稱
|
|
|
11141 |
#$conf["formAction"]="";#表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置
|
|
|
11142 |
#$conf["formTarget"]="_self";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
11143 |
#$conf["formEnd"]="true";#是否要有表單的結束
|
|
|
11144 |
$printRow=table::printRow($conf["table"]["printRow"]);
|
|
|
11145 |
unset($conf["table"]["printRow"]);
|
|
|
11146 |
|
|
|
11147 |
#如果建立一列表格失敗
|
|
|
11148 |
if($printRow["status"]=="false"){
|
|
|
11149 |
|
|
|
11150 |
#設置執行不正常
|
|
|
11151 |
$result["status"]="false";
|
|
|
11152 |
|
|
|
11153 |
#程式停止執行
|
|
|
11154 |
$result["error"]=$printRow;
|
|
|
11155 |
|
|
|
11156 |
#回傳結果
|
|
|
11157 |
return $result;
|
|
|
11158 |
|
|
|
11159 |
}#if end
|
|
|
11160 |
|
|
|
11161 |
#串接一列表格
|
|
|
11162 |
$result["content"]=$result["content"].$printRow["content"];
|
|
|
11163 |
|
|
|
11164 |
#設置執行成功
|
|
|
11165 |
$result["status"]="true";
|
|
|
11166 |
|
|
|
11167 |
#回傳結果
|
|
|
11168 |
return $result;
|
|
|
11169 |
|
|
|
11170 |
}#函式 simpleControlPanel 結束
|
|
|
11171 |
|
|
|
11172 |
/*
|
|
|
11173 |
#函式說明:
|
|
|
11174 |
#移除東西的確認視窗.
|
|
|
11175 |
#回傳結果:
|
|
|
11176 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表有問題
|
|
|
11177 |
#$reuslt["error"],錯誤訊息陣列
|
|
|
11178 |
#$result["function"],當前執行的函數名稱
|
|
|
11179 |
#$result["content"],語法
|
|
|
11180 |
#必填參數:
|
|
|
11181 |
$conf["itemName"]="";#爲要刪除的物件提示名稱,格式爲字串。
|
|
|
11182 |
$conf["cancleActionPage"]="";#爲按下取消按鈕後,要交給那個頁面處理。
|
|
|
11183 |
$conf["removeActionPage"]="";#爲移除按鈕傳送的內容要交給哪一個頁面處理。
|
|
|
11184 |
#可省略參數:
|
|
|
11185 |
#$conf["itemNameFontColor"]="";#可省略預設爲 "#000000"(黑色),爲要刪除物件提示名稱文字的字型顏色,格式範圍爲 #000000~#FFFFFF。
|
|
|
11186 |
#$conf["dbAddress"]=$dbAddress;#資料庫的位置.
|
|
|
11187 |
#$conf["dbName"]=$dbName;#連線到資料庫的名稱.
|
|
|
11188 |
#$conf["dtName"]="";#目標資料所屬資料表名稱.
|
|
|
11189 |
#$conf["dbAccount"]=$dbAccount;#連線到資料庫的帳號名稱.
|
|
|
11190 |
#$conf["dbPassword"]=$dbPassword;#連線到資料庫的帳號密碼.
|
|
|
11191 |
#$conf["indexColumnName"]="id";#用於識別要移除資料的索引鍵欄位名稱,預設為"id".
|
|
|
11192 |
#$conf["indexColumnValue"]="";#用於識別要移除資料的索引鍵欄位數值內容。
|
|
|
11193 |
#$conf["columnForComment"]=array();#陣列字串,為要從資料庫取出作為要除物件的提示文字的資料表欄位名稱陣列。
|
|
|
11194 |
#$conf["commentsName"]=array();#陣列字串,為要從資料庫取出作為要除物件的提示文字的資料表欄位名的顯示名稱,預設跟 $conf["columnForComment"] 一樣.
|
|
|
11195 |
#$conf["cancleActionDisplayMethod"]="";#可省略,預設爲"_top",爲按下取消按鈕後,交給的處理的頁面要怎麼顯現,類型爲字串,可能值有 "_top" "_self" "_blank" "_blank"
|
|
|
11196 |
#$conf["cancleButtonStyle"]="";#可省略,爲取消鈕的css樣式類別名稱,預設為"__qbpwcf_button".
|
|
|
11197 |
#$conf["cancleButtonDisplayName"]="";#可省略,預設爲"取消",爲取消鈕的顯示名稱。
|
|
|
11198 |
#$conf["cancleSendingVarName"]=array("");#爲按下取消按鈕後要傳送的數值名稱
|
|
|
11199 |
#$conf["cancleSendingVarValue"]=array("");#爲按下取消按鈕後要傳送的數值內容
|
|
|
11200 |
#$conf["removeActionDisplayMethod"]="";#可省略預設爲"_top",爲處理移除內容的頁面要如何顯現,類型爲字串,可能值有 "_top" "_self" "_blank" "_blank"
|
|
|
11201 |
#$conf["removeButtonStyle"]="";#可省略,爲移除按鈕的css樣式類別名稱,,預設為"__qbpwcf_button".
|
|
|
11202 |
#$conf["removeButtonDisplayName"]="";#可省略,預設爲"確認移除",爲移除按鈕的顯示文字內容
|
|
|
11203 |
#$conf["removeSendingVarName"]=array("");#爲按下移除按鈕後要傳送的數值名稱
|
|
|
11204 |
#$conf["removeSendingVarValue"]=array("");#爲按下移除按鈕後要傳送的數值內容
|
|
|
11205 |
#參考資料:
|
|
|
11206 |
#無.
|
|
|
11207 |
#備註:
|
|
|
11208 |
#建議參數 $conf["indexColumnName"] 與 $conf["indexColumnValue"] 的形態為字串陣列,以便擁有更多限制條件取得需要的資料.
|
|
|
11209 |
*/
|
|
|
11210 |
public static function removeConfirm(&$conf){
|
|
|
11211 |
|
|
|
11212 |
#初始化要回傳的內容
|
|
|
11213 |
$result=array();
|
|
|
11214 |
|
|
|
11215 |
#初始化要回傳的語法
|
|
|
11216 |
$result["content"]="";
|
|
|
11217 |
|
|
|
11218 |
#記錄當前執行的函數名稱
|
|
|
11219 |
$result["function"]=__FUNCTION__;
|
|
|
11220 |
|
|
|
11221 |
#如果 $conf 不為陣列
|
|
|
11222 |
if(gettype($conf)!="array"){
|
|
|
11223 |
|
|
|
11224 |
#設置執行失敗
|
|
|
11225 |
$result["status"]="false";
|
|
|
11226 |
|
|
|
11227 |
#設置執行錯誤訊息
|
|
|
11228 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
11229 |
|
|
|
11230 |
#如果傳入的參數為 null
|
|
|
11231 |
if($conf==null){
|
|
|
11232 |
|
|
|
11233 |
#設置執行錯誤訊息
|
|
|
11234 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
11235 |
|
|
|
11236 |
}#if end
|
|
|
11237 |
|
|
|
11238 |
#回傳結果
|
|
|
11239 |
return $result;
|
|
|
11240 |
|
|
|
11241 |
}#if end
|
|
|
11242 |
|
|
|
11243 |
#檢查參數:
|
|
|
11244 |
#函式說明:
|
|
|
11245 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
11246 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11247 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
11248 |
#$result["function"],當前執行的函式名稱.
|
|
|
11249 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
11250 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
11251 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
11252 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
11253 |
#必填參數:
|
|
|
11254 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
11255 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
11256 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
11257 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("itemName","cancleActionPage","removeActionPage");
|
|
|
11258 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
11259 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
|
|
|
11260 |
#可省略參數:
|
|
|
11261 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
11262 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
11263 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
11264 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array();
|
|
|
11265 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="dbAddress";
|
|
|
11266 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="dbName";
|
|
|
11267 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="dbAccount";
|
|
|
11268 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="dbPassword";
|
|
|
11269 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="dtName";
|
|
|
11270 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="indexColumnName";
|
|
|
11271 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="indexColumnValue";
|
|
|
11272 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="columnForComment";
|
|
|
11273 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="commentsName";
|
|
|
11274 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="itemNameFontColor";
|
|
|
11275 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="cancleButtonDisplayName";
|
|
|
11276 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="cancleActionDisplayMethod";
|
|
|
11277 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="cancleButtonStyle";
|
|
|
11278 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="cancleSendingVarName";
|
|
|
11279 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="cancleSendingVarValue";
|
|
|
11280 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="removeButtonDisplayName";
|
|
|
11281 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="removeActionDisplayMethod";
|
|
|
11282 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="removeButtonStyle";
|
|
|
11283 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="removeSendingVarName";
|
|
|
11284 |
$conf["variableCheck::checkArguments"]["skipableVariableName"][]="removeSendingVarValue";
|
|
|
11285 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
11286 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array();
|
|
|
11287 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11288 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11289 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11290 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11291 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11292 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11293 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11294 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11295 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11296 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11297 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11298 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11299 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11300 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11301 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11302 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11303 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11304 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="string";
|
|
|
11305 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11306 |
$conf["variableCheck::checkArguments"]["skipableVariableType"][]="array";
|
|
|
11307 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
11308 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array();
|
|
|
11309 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11310 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11311 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11312 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11313 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11314 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="id";
|
|
|
11315 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11316 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11317 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="\$conf[\"columnForComment\"]";
|
|
|
11318 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="#000000";
|
|
|
11319 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="取消";
|
|
|
11320 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="_top";
|
|
|
11321 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_button";
|
|
|
11322 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11323 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11324 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="確認移除";
|
|
|
11325 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="_top";
|
|
|
11326 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]="__qbpwcf_button";
|
|
|
11327 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11328 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"][]=null;
|
|
|
11329 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
11330 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
11331 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
11332 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
11333 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
11334 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
11335 |
|
|
|
11336 |
#如果檢查出錯
|
|
|
11337 |
if($checkResult["status"]=="false"){
|
|
|
11338 |
|
|
|
11339 |
#設置執行錯誤
|
|
|
11340 |
$result["status"]="false";
|
|
|
11341 |
|
|
|
11342 |
#設置錯誤訊息
|
|
|
11343 |
$result["error"]=$checkResult;
|
|
|
11344 |
|
|
|
11345 |
#回傳結果
|
|
|
11346 |
return $result;
|
|
|
11347 |
|
|
|
11348 |
}#if end
|
|
|
11349 |
|
|
|
11350 |
#如果檢查不通過
|
|
|
11351 |
if($checkResult["passed"]=="false"){
|
|
|
11352 |
|
|
|
11353 |
#設置執行錯誤
|
|
|
11354 |
$result["status"]="false";
|
|
|
11355 |
|
|
|
11356 |
#設置錯誤訊息
|
|
|
11357 |
$result["error"]=$checkResult;
|
|
|
11358 |
|
|
|
11359 |
#回傳結果
|
|
|
11360 |
return $result;
|
|
|
11361 |
|
|
|
11362 |
}#if end
|
|
|
11363 |
|
|
|
11364 |
#取消移除的按鈕
|
|
|
11365 |
#函式說明:
|
|
|
11366 |
#一個簡單的按鈕,按了可以到指定的頁面,同時也可以傳送多個隱藏的變數
|
|
|
11367 |
#回傳的結果
|
|
|
11368 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11369 |
#$result["error"],錯誤訊息陣列
|
|
|
11370 |
#$result["function"],當前執行的函數名稱.
|
|
|
11371 |
#$result["content"],語法內容
|
|
|
11372 |
#必填參數:
|
|
|
11373 |
$conf["form::sendHugeDataButton"]["buttonDisplayValue"]=$conf["cancleButtonDisplayName"];#按鈕上要顯示的文字
|
|
|
11374 |
#可省略參數:
|
|
|
11375 |
$conf["form::sendHugeDataButton"]["buttonStyleName"]=$conf["cancleButtonStyle"];#按鈕的css樣式應該爲何,若省略的話預設會採用 __simpleButtonLinkDefaultButtonCssStyle 的樣式,其設定為"width:100%;height:50;font-size:30;text-align:center;
|
|
|
11376 |
|
|
|
11377 |
#如果 $conf["cancleSendingVarName"] 有存在
|
|
|
11378 |
if(isset($conf["cancleSendingVarName"])){
|
|
|
11379 |
|
|
|
11380 |
$conf["form::sendHugeDataButton"]["hiddenVarName"]=$conf["cancleSendingVarName"];#要傳送的隱藏變數名稱,與 $conf["hiddenVarContent"] 相對應。
|
|
|
11381 |
|
|
|
11382 |
}#if end
|
|
|
11383 |
|
|
|
11384 |
#如果 $conf["cancleSendingVarValue"] 有設定
|
|
|
11385 |
if(isset($conf["cancleSendingVarValue"])){
|
|
|
11386 |
|
|
|
11387 |
$conf["form::sendHugeDataButton"]["hiddenVarContent"]=$conf["cancleSendingVarValue"];#要傳誦的隱藏變數內容,與 $conf["hiddenVarName"] 相對應。
|
|
|
11388 |
|
|
|
11389 |
}#if end
|
|
|
11390 |
|
|
|
11391 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
11392 |
$conf["form::sendHugeDataButton"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設爲"false".
|
|
|
11393 |
#$conf["form::sendHugeDataButton"]["method"]=;#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
11394 |
#$conf["formName"]="";#該表單的名稱
|
|
|
11395 |
$conf["form::sendHugeDataButton"]["actionPage"]=$conf["cancleActionPage"];#按鈕按了之後要到哪個地方?若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
11396 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
11397 |
#可以是"document.forms.formName.submit()"(傳送名爲testForm的表單內容).
|
|
|
11398 |
$conf["form::sendHugeDataButton"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設爲"false"
|
|
|
11399 |
#$conf["tableStart"]="true";#爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
11400 |
#$conf["tableClass"]="__withoutBorder";#爲表格要採用的css樣式名稱,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder".
|
|
|
11401 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
11402 |
#$conf["trClass"]="__withoutBorder";#列開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
11403 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false"
|
|
|
11404 |
#$conf["tdClass"]="__withoutBorder";#行開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
11405 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
11406 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
11407 |
$conf["form::sendHugeDataButton"]["displayTarget"]=$conf["cancleActionDisplayMethod"];#頁面的呈現方法,可以是開新視窗(_blank)、在目前頁面、頁框裏面(_self)、在父頁面(_parent)、最上層頁面(_top),預設為"_top"。
|
|
|
11408 |
#$conf["tableEnd"]="true";#爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
11409 |
$cancleButton=form::sendHugeDataButton($conf["form::sendHugeDataButton"]);
|
|
|
11410 |
unset($conf["form::sendHugeDataButton"]);
|
|
|
11411 |
|
|
|
11412 |
#如果取消按鈕建立失敗
|
|
|
11413 |
if($cancleButton["status"]==="false"){
|
|
|
11414 |
|
|
|
11415 |
#設置執行錯誤
|
|
|
11416 |
$result["status"]="false";
|
|
|
11417 |
|
|
|
11418 |
#設置錯誤訊息
|
|
|
11419 |
$result["error"]=$cancleButton;
|
|
|
11420 |
|
|
|
11421 |
#回傳結果
|
|
|
11422 |
return $result;
|
|
|
11423 |
|
|
|
11424 |
}#if end
|
|
|
11425 |
|
|
|
11426 |
#串接取消按鈕的語法
|
|
|
11427 |
$conf["table.printColumn"]["tdContent"][]=$cancleButton["content"];
|
|
|
11428 |
|
|
|
11429 |
#創建提示文字的css樣式
|
|
|
11430 |
#函式說明:
|
|
|
11431 |
#創建 css 樣式
|
|
|
11432 |
#回傳結果:
|
|
|
11433 |
#$result["css"],css設定內容
|
|
|
11434 |
#$result["error"],函式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
11435 |
#必填參數:
|
|
|
11436 |
$conf["css.createCssStyle"]["cssStyleName"]="__removeConfiremStrCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
11437 |
$conf["css.createCssStyle"]["attributes"]=array("text-align","font-size","color");#為屬性名稱,須為陣列值
|
|
|
11438 |
$conf["css.createCssStyle"]["content"]=array("center","30px",$conf["itemNameFontColor"]);#為屬性值,須為陣列值
|
|
|
11439 |
$css=css::createCssStyle($conf["css.createCssStyle"]);
|
|
|
11440 |
unset($conf["css.createCssStyle"]);
|
|
|
11441 |
|
|
|
11442 |
#如果css樣式建立失敗
|
|
|
11443 |
if($css["status"]=="false"){
|
|
|
11444 |
|
|
|
11445 |
#設置執行失敗
|
|
|
11446 |
$result["status"]="false";
|
|
|
11447 |
|
|
|
11448 |
#設置錯誤訊息
|
|
|
11449 |
$result["error"]=$css;
|
|
|
11450 |
|
|
|
11451 |
#回傳結果
|
|
|
11452 |
return $result;
|
|
|
11453 |
|
|
|
11454 |
}#if end
|
|
|
11455 |
|
|
|
11456 |
#傳接css語法
|
|
|
11457 |
$result["content"]=$result["content"].$css["content"];
|
|
|
11458 |
|
|
|
11459 |
#確認移除的文字
|
|
|
11460 |
#函式說明:
|
|
|
11461 |
#<span>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
11462 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
11463 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
11464 |
#$result["error"],陣列,錯訊訊息.
|
|
|
11465 |
#$result["content"],字串,含有<span>標籤的內容.
|
|
|
11466 |
#必填參數:
|
|
|
11467 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
11468 |
$conf["css::spanSection"]["contentArray"]=array("您確定要移除該 「".$conf["itemName"]."」 嗎?");
|
|
|
11469 |
#可省略參數
|
|
|
11470 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
11471 |
$conf["css::spanSection"]["class"]="__removeConfiremStrCssStyle";
|
|
|
11472 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
11473 |
#$conf["title"]=array();
|
|
|
11474 |
$spanSection=css::divSection($conf["css::spanSection"]);
|
|
|
11475 |
unset($conf["css::spanSection"]);
|
|
|
11476 |
|
|
|
11477 |
#如果 spanSection 建立失敗
|
|
|
11478 |
if($spanSection["status"]=="false"){
|
|
|
11479 |
|
|
|
11480 |
#設置執行失敗
|
|
|
11481 |
$result["status"]="false";
|
|
|
11482 |
|
|
|
11483 |
#設置錯誤訊息
|
|
|
11484 |
$result["error"]=$spanSection;
|
|
|
11485 |
|
|
|
11486 |
#回傳結果
|
|
|
11487 |
return $result;
|
|
|
11488 |
|
|
|
11489 |
}#if end
|
|
|
11490 |
|
|
|
11491 |
#串接提示訊息
|
|
|
11492 |
$conf["table.printColumn"]["tdContent"][]=$spanSection["content"];
|
|
|
11493 |
|
|
|
11494 |
#如果 $conf["indexColumnValue"] 有設定
|
|
|
11495 |
if(isset($conf["indexColumnValue"]) && isset($conf["dbName"]) && isset($conf["dbAddress"]) && isset($conf["dbAccount"]) && isset($conf["dtName"])){
|
|
|
11496 |
|
|
|
11497 |
#如果 $conf["columnForComment"] 有設定
|
|
|
11498 |
if(isset($conf["columnForComment"])){
|
|
|
11499 |
|
|
|
11500 |
#函式說明:
|
|
|
11501 |
#<span>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
11502 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
11503 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
11504 |
#$result["error"],陣列,錯訊訊息.
|
|
|
11505 |
#$result["content"],字串,含有<span>標籤的內容.
|
|
|
11506 |
#必填參數:
|
|
|
11507 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
11508 |
$conf["css::spanSection"]["contentArray"]=array("相關資訊如下所示:");
|
|
|
11509 |
#可省略參數
|
|
|
11510 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
11511 |
$conf["css::spanSection"]["class"]="__removeConfiremStrCssStyle";
|
|
|
11512 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
11513 |
#$conf["title"]=array();
|
|
|
11514 |
$spanSection=css::divSection($conf["css::spanSection"]);
|
|
|
11515 |
unset($conf["css::spanSection"]);
|
|
|
11516 |
|
|
|
11517 |
#如果 spanSection 建立失敗
|
|
|
11518 |
if($spanSection["status"]=="false"){
|
|
|
11519 |
|
|
|
11520 |
#設置執行失敗
|
|
|
11521 |
$result["status"]="false";
|
|
|
11522 |
|
|
|
11523 |
#設置錯誤訊息
|
|
|
11524 |
$result["error"]=$spanSection;
|
|
|
11525 |
|
|
|
11526 |
#回傳結果
|
|
|
11527 |
return $result;
|
|
|
11528 |
|
|
|
11529 |
}#if end
|
|
|
11530 |
|
|
|
11531 |
#串接提示訊息
|
|
|
11532 |
$conf["table.printColumn"]["tdContent"][]=$spanSection["content"];
|
|
|
11533 |
|
|
|
11534 |
#取得特定資料的指定欄位資料
|
|
|
11535 |
#函式說明:
|
|
|
11536 |
#一次取得資料庫、表的資料
|
|
|
11537 |
#回傳的結果
|
|
|
11538 |
#$result["status"],執行結果"true"為成功;"false"為執行失敗。
|
|
|
11539 |
#$result["error"],錯誤訊息陣列。
|
|
|
11540 |
#$result["dataColumnName"],抓取的資料欄位名稱陣列.
|
|
|
11541 |
#$result["dataColumnName"][$i]代表第$i+1個欄位名稱
|
|
|
11542 |
#$result["dataContent"],爲資料的內容。
|
|
|
11543 |
#$result["dataContent"][$conf["WhereColumnName"][$i]][$dataSetNum]
|
|
|
11544 |
#$dataSetNum 爲第$dataSetNum+1筆資料
|
|
|
11545 |
#$conf["WhereColumnName"][$i] 爲第 $i+1 個欄位的名稱
|
|
|
11546 |
#$result["dataCount"],爲取得的資料筆數。
|
|
|
11547 |
#$result["sql"],執行的sql字串.
|
|
|
11548 |
#必填參數:
|
|
|
11549 |
$conf["db.fastGetDbData"]["dbAddress"]=$conf["dbAddress"];#爲dbServer的位置。
|
|
|
11550 |
$conf["db.fastGetDbData"]["dbAccount"]=$conf["dbAccount"];#爲登入dbServer的帳號。
|
|
|
11551 |
$conf["db.fastGetDbData"]["dbName"]=$conf["dbName"];#爲要存取的資料庫名稱
|
|
|
11552 |
$conf["db.fastGetDbData"]["tableName"]=$conf["dtName"];#爲要存取的資料表名稱
|
|
|
11553 |
$conf["db.fastGetDbData"]["columnYouWant"]=$conf["columnForComment"];#你想要的欄位!,若設為「array("*")」則代表全部欄位.
|
|
|
11554 |
#可省略參數:
|
|
|
11555 |
|
|
|
11556 |
#如果 $conf["dbPassword"] 有設定
|
|
|
11557 |
if(isset($conf["dbPassword"])){
|
|
|
11558 |
|
|
|
11559 |
$conf["db.fastGetDbData"]["dbPassword"]=$conf["dbPassword"];#爲要存取dbServer的密碼
|
|
|
11560 |
|
|
|
11561 |
}#if end
|
|
|
11562 |
|
|
|
11563 |
$conf["db.fastGetDbData"]["WhereColumnName"]=array($conf["indexColumnName"]);#用於判斷語句的欄位項目陣列。
|
|
|
11564 |
$conf["db.fastGetDbData"]["WhereColumnValue"]=array($conf["indexColumnValue"]);#用於判斷語句的欄位數值陣列,若與LIKE搭配,則可以在關鍵自字串的左右名加上「%」符號,這樣就可以搜尋具有該字串的內容。
|
|
|
11565 |
#$conf["WhereColumnCombine"]=array("");#用於判斷語句當中需要()起來的判斷式,須爲陣列值,"s"代表「(」,"e"代表「)」 ,若無則須設爲""。
|
|
|
11566 |
#$conf["WhereColumnOperator"]=array("");#用於判斷語句的比較符號陣列,可以用的符號有「"="、">"、"<"、"LIKE"、"NOT LIKE"」,預設都爲「=」。
|
|
|
11567 |
#$conf["WhereColumnAndOr"]=array("");#用於判斷語句條件之間成立的條件是AND還是OR,須爲陣列值。其數量應爲要判斷的欄位數量減一。
|
|
|
11568 |
#$conf["orderItem"]="";#爲排序的項目依據,若要用隨機抽樣,可以用"rand()",可省略。
|
|
|
11569 |
#$conf["ascORdesc"]="";#爲要低增還是遞減排序,asc爲遞增;desc爲遞減。
|
|
|
11570 |
#$conf["numberStart"]="0";#為從第幾筆開始讀取,預設為0,代筆第一筆。
|
|
|
11571 |
#$conf["numLimit"]="30";#為要取幾筆資料,可以省略,省略則表示不限制數目。
|
|
|
11572 |
#$conf["groupBy"]=array("");#爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
|
|
|
11573 |
$getDbDataResult=db::fastGetDbData($conf["db.fastGetDbData"]);
|
|
|
11574 |
unset($conf["db.fastGetDbData"]);
|
|
|
11575 |
|
|
|
11576 |
#如果 查詢要刪除的資料失敗
|
|
|
11577 |
if($getDbDataResult["status"]=="false"){
|
|
|
11578 |
|
|
|
11579 |
#設置執行失敗
|
|
|
11580 |
$result["status"]="false";
|
|
|
11581 |
|
|
|
11582 |
#設置錯誤訊息
|
|
|
11583 |
$result["error"]=$getDbDataResult;
|
|
|
11584 |
|
|
|
11585 |
#回傳結果
|
|
|
11586 |
return $result;
|
|
|
11587 |
|
|
|
11588 |
}#if end
|
|
|
11589 |
|
|
|
11590 |
#如果資料不足一筆
|
|
|
11591 |
if($getDbDataResult["dataCount"]==0){
|
|
|
11592 |
|
|
|
11593 |
#設置執行失敗
|
|
|
11594 |
$result["status"]="false";
|
|
|
11595 |
|
|
|
11596 |
#設置錯誤訊息
|
|
|
11597 |
$result["error"][]="查不到要刪除的資料";
|
|
|
11598 |
|
|
|
11599 |
#回傳結果
|
|
|
11600 |
return $result;
|
|
|
11601 |
|
|
|
11602 |
}#if end
|
|
|
11603 |
|
|
|
11604 |
#有幾個欄位就執行幾次
|
|
|
11605 |
for($i=0;$i<count($conf["columnForComment"]);$i++){
|
|
|
11606 |
|
|
|
11607 |
#函式說明:
|
|
|
11608 |
#可以輸入文字的區塊
|
|
|
11609 |
#回傳結果:
|
|
|
11610 |
#$result,語法
|
|
|
11611 |
#必填參數:
|
|
|
11612 |
$conf["form.inputTextArea"]["name"]="readOnly-".$i;#爲文字輸入框的名稱,供接收端辨識用。
|
|
|
11613 |
$conf["form.inputTextArea"]["readOnly"]="true";#爲是否要爲唯讀,如果爲"true",則爲唯讀。反之則爲"false"。
|
|
|
11614 |
#可省略參數:
|
|
|
11615 |
#$conf["cols"]="";#爲文字輸入框的欄位數(寬),預設爲按照瀏覽器設定值。
|
|
|
11616 |
#$conf["rows"]="";#爲文字輸入框的列數(高),預設爲按照瀏覽器設定值。
|
|
|
11617 |
#$conf["maxInputLength"]="";#爲文字輸入的長度限制,預設無限制。
|
|
|
11618 |
$conf["form.inputTextArea"]["defaultText"]=$getDbDataResult["dataContent"][$conf["columnForComment"][$i]][0];#爲文字輸入框裏面的預設文字內容,預設是空的。
|
|
|
11619 |
#$conf["class"]=;#爲要套用的css樣式。如果沒有指定 ,則採用預設的css樣式,其屬性爲 "width:100%","height:120px","font-size:30px"
|
|
|
11620 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
11621 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
11622 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字.
|
|
|
11623 |
$conf["form.inputTextArea"]["comment"]=$conf["commentsName"][$i];
|
|
|
11624 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
11625 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
11626 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
11627 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
11628 |
$columnData=form::inputTextArea($conf["form.inputTextArea"]);
|
|
|
11629 |
unset($conf["form.inputTextArea"]);
|
|
|
11630 |
|
|
|
11631 |
#如果 inputTextArea 建立失敗
|
|
|
11632 |
if($columnData["status"]=="false"){
|
|
|
11633 |
|
|
|
11634 |
#設置執行失敗
|
|
|
11635 |
$result["status"]="false";
|
|
|
11636 |
|
|
|
11637 |
#設置錯誤訊息
|
|
|
11638 |
$result["error"]=$columnData;
|
|
|
11639 |
|
|
|
11640 |
#回傳結果
|
|
|
11641 |
return $result;
|
|
|
11642 |
|
|
|
11643 |
}#if end
|
|
|
11644 |
|
|
|
11645 |
#接上描述資訊
|
|
|
11646 |
$conf["table.printColumn"]["tdContent"][]=$columnData["content"];
|
|
|
11647 |
|
|
|
11648 |
}#for end
|
|
|
11649 |
|
|
|
11650 |
}#if end
|
|
|
11651 |
|
|
|
11652 |
}#if end
|
|
|
11653 |
|
|
|
11654 |
#確認移除的按鈕
|
|
|
11655 |
#函式說明:
|
|
|
11656 |
#一個簡單的按鈕,按了可以到指定的頁面,同時也可以傳送多個隱藏的變數
|
|
|
11657 |
#回傳的結果
|
|
|
11658 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11659 |
#$result["error"],錯誤訊息陣列
|
|
|
11660 |
#$result["function"],當前執行的函數名稱.
|
|
|
11661 |
#$result["content"],語法內容
|
|
|
11662 |
#必填參數:
|
|
|
11663 |
$conf["form::sendHugeDataButton"]["buttonDisplayValue"]=$conf["removeButtonDisplayName"];#按鈕上要顯示的文字
|
|
|
11664 |
#可省略參數:
|
|
|
11665 |
$conf["form::sendHugeDataButton"]["buttonStyleName"]=$conf["removeButtonStyle"];#按鈕的css樣式應該爲何,若省略的話預設會採用 __simpleButtonLinkDefaultButtonCssStyle 的樣式,其設定為"width:100%;height:50;font-size:30;text-align:center;
|
|
|
11666 |
|
|
|
11667 |
#如果 $conf["removeSendingVarName"] 有存在
|
|
|
11668 |
if(isset($conf["removeSendingVarName"])){
|
|
|
11669 |
|
|
|
11670 |
$conf["form::sendHugeDataButton"]["hiddenVarName"]=$conf["removeSendingVarName"];#要傳送的隱藏變數名稱,與 $conf["hiddenVarContent"] 相對應。
|
|
|
11671 |
|
|
|
11672 |
}#if end
|
|
|
11673 |
|
|
|
11674 |
#如果 $conf["removeSendingVarValue"] 有設定
|
|
|
11675 |
if(isset($conf["removeSendingVarValue"])){
|
|
|
11676 |
|
|
|
11677 |
$conf["form::sendHugeDataButton"]["hiddenVarContent"]=$conf["removeSendingVarValue"];#要傳誦的隱藏變數內容,與 $conf["hiddenVarName"] 相對應。
|
|
|
11678 |
|
|
|
11679 |
}#if end
|
|
|
11680 |
|
|
|
11681 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
11682 |
$conf["form::sendHugeDataButton"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設爲"false".
|
|
|
11683 |
#$conf["form::sendHugeDataButton"]["method"]=;#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
11684 |
#$conf["formName"]="";#該表單的名稱
|
|
|
11685 |
$conf["form::sendHugeDataButton"]["actionPage"]=$conf["removeActionPage"];#按鈕按了之後要到哪個地方?若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
11686 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
11687 |
#可以是"document.forms.formName.submit()"(傳送名爲testForm的表單內容).
|
|
|
11688 |
$conf["form::sendHugeDataButton"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設爲"false"
|
|
|
11689 |
#$conf["tableStart"]="true";#爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
11690 |
#$conf["tableClass"]="__withoutBorder";#爲表格要採用的css樣式名稱,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder".
|
|
|
11691 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
11692 |
#$conf["trClass"]="__withoutBorder";#列開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
11693 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false"
|
|
|
11694 |
#$conf["tdClass"]="__withoutBorder";#行開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式,預設為"__withoutBorder"
|
|
|
11695 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
11696 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
11697 |
$conf["form::sendHugeDataButton"]["displayTarget"]=$conf["removeActionDisplayMethod"];#頁面的呈現方法,可以是開新視窗(_blank)、在目前頁面、頁框裏面(_self)、在父頁面(_parent)、最上層頁面(_top),預設為"_top"。
|
|
|
11698 |
#$conf["tableEnd"]="true";#爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
11699 |
$confirmButton=form::sendHugeDataButton($conf["form::sendHugeDataButton"]);
|
|
|
11700 |
unset($conf["form::sendHugeDataButton"]);
|
|
|
11701 |
|
|
|
11702 |
#如果取消按鈕建立失敗
|
|
|
11703 |
if($confirmButton["status"]=="false"){
|
|
|
11704 |
|
|
|
11705 |
#設置執行錯誤
|
|
|
11706 |
$result["status"]="false";
|
|
|
11707 |
|
|
|
11708 |
#設置錯誤訊息
|
|
|
11709 |
$result["error"]=$confirmButton;
|
|
|
11710 |
|
|
|
11711 |
#回傳結果
|
|
|
11712 |
return $result;
|
|
|
11713 |
|
|
|
11714 |
}#if end
|
|
|
11715 |
|
|
|
11716 |
#串接確認移除按鈕的語法
|
|
|
11717 |
$conf["table.printColumn"]["tdContent"][]=$confirmButton["content"];
|
|
|
11718 |
|
|
|
11719 |
#函式說明:
|
|
|
11720 |
#建立欄的元素,以及指定裏面要放什麼內容
|
|
|
11721 |
#回傳的變數:
|
|
|
11722 |
#$result["content"],建立欄元素的語法
|
|
|
11723 |
#$result["status"],"true"代表執行成功;"false"代表執行失敗。
|
|
|
11724 |
#$result["error"],錯誤訊息陣列
|
|
|
11725 |
#必填參數:
|
|
|
11726 |
$conf["table.printColumn"]["trClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11727 |
$conf["table.printColumn"]["tdClass"]="__withoutBorder";#行的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11728 |
#列裏面要放的元素是?如果要空一列則可以輸array(" ")
|
|
|
11729 |
#$conf["table.printColumn"]["tdContent"][]="";
|
|
|
11730 |
#可省略參數:
|
|
|
11731 |
$conf["table.printColumn"]["tableStartClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
11732 |
$conf["table.printColumn"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是"。
|
|
|
11733 |
$conf["table.printColumn"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是"。
|
|
|
11734 |
#$conf["formStart"]="true";#是否要有表單的開始
|
|
|
11735 |
#$conf["formName"]="";#該表單的名稱
|
|
|
11736 |
#$conf["formAction"]="";#表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置
|
|
|
11737 |
#$conf["formTarget"]="_self";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
11738 |
#$conf["formEnd"]="true";#是否要有表單的結束
|
|
|
11739 |
$conf["table.printColumn"]["spaceBlockAferPerElement"]="true";#是否每個欄元素(除了最後一個元素)後面都要空一列。"true"代表要空一列.預設是不空一列.
|
|
|
11740 |
$fullTable=table::printColumn($conf["table.printColumn"]);
|
|
|
11741 |
unset($conf["table.printColumn"]);
|
|
|
11742 |
|
|
|
11743 |
#如果 表格建立失敗
|
|
|
11744 |
if($fullTable["status"]=="false"){
|
|
|
11745 |
|
|
|
11746 |
#設置執行失敗
|
|
|
11747 |
$result["status"]="false";
|
|
|
11748 |
|
|
|
11749 |
#設置錯誤訊息
|
|
|
11750 |
$result["error"]=$fullTable;
|
|
|
11751 |
|
|
|
11752 |
#回傳結果
|
|
|
11753 |
return $result;
|
|
|
11754 |
|
|
|
11755 |
}#if end
|
|
|
11756 |
|
|
|
11757 |
#串接整個表格
|
|
|
11758 |
$result["content"]=$result["content"].$fullTable["content"];
|
|
|
11759 |
|
|
|
11760 |
#設置執行正常
|
|
|
11761 |
$result["status"]="true";
|
|
|
11762 |
|
|
|
11763 |
#回傳結果
|
|
|
11764 |
return $result;
|
|
|
11765 |
|
|
|
11766 |
}#function removeConfirm end
|
|
|
11767 |
|
|
|
11768 |
/*
|
|
|
11769 |
#函式說明:
|
|
|
11770 |
#確認執行的視窗
|
|
|
11771 |
#回傳結果:
|
|
|
11772 |
#$result,確認執行的視窗語法
|
|
|
11773 |
#必填參數:
|
|
|
11774 |
$conf["actionName"]="";#要執行的動作
|
|
|
11775 |
$conf["itemName"]="";#爲要執行的物件提示名稱,格式爲字串。
|
|
|
11776 |
$conf["cancleActionPage"]="";#爲按下取消按鈕後,要交給那個頁面處理。
|
|
|
11777 |
$conf["confirmActionPage"]="";#爲移除按鈕傳送的內容要交給哪一個頁面處理。
|
|
|
11778 |
#可省略參數:
|
|
|
11779 |
#$conf["actionFontCss"]="";#可省略,爲動作提示的字型css樣式,預設為"__actionFontCssStyle"
|
|
|
11780 |
#$conf["itemNameFontCss"]="";#可省略預,爲物件提示的字型css樣式,預設為"__itemNameFontCssStyle"
|
|
|
11781 |
#$conf["cancleActionDisplayMethod"]="";#可省略,預設爲"_self",爲按下取消按鈕後,交給的處理的頁面要怎麼顯現,類型爲字串,可能值有 "_top" "_self" "_blank" "_blank"
|
|
|
11782 |
#$conf["cancleButtonStyle"]="";#可省略,爲取消鈕的css樣式類別名稱。
|
|
|
11783 |
#$conf["cancleRequestMethod"],字串,取消要求的表單要用什麼方式傳送,預設為"post",也可以為"get".
|
|
|
11784 |
#$conf["cancleRequestMethod"]="get";
|
|
|
11785 |
#$conf["cancleButtonDisplayName"]="";#可省略,預設爲"取消",爲取消鈕的顯示名稱。
|
|
|
11786 |
#$conf["cancleSendingVarName"]=array("");#爲按下取消按鈕後要傳送的數值名稱
|
|
|
11787 |
#$conf["cancleSendingVarValue"]=array("");#爲按下取消按鈕後要傳送的數值內容
|
|
|
11788 |
#$conf["confirmActionDisplayMethod"]="";#可省略預設爲"_self",爲處理移除內容的頁面要如何顯現,類型爲字串,可能值有 "_top" "_self" "_blank" "_blank"
|
|
|
11789 |
#$conf["confirmButtonStyle"]="";#可省略,爲移除按鈕的css樣式類別名稱。
|
|
|
11790 |
#$conf["confirmRequestMethod"],字串,確認要求的表單要用什麼方式傳送,預設為"post",也可以為"get".
|
|
|
11791 |
#$conf["confirmRequestMethod"]="get";
|
|
|
11792 |
#$conf["confirmButtonDisplayName"]="";#可省略,預設爲"確認移除",爲移除按鈕的顯示文字內容
|
|
|
11793 |
#$conf["confirmSendingVarName"]=array("");#爲按下移除按鈕後要傳送的數值名稱
|
|
|
11794 |
#$conf["confirmSendingVarValue"]=array("");#爲按下移除按鈕後要傳送的數值內容
|
|
|
11795 |
#參考資料:
|
|
|
11796 |
#無.
|
|
|
11797 |
#備註:
|
|
|
11798 |
#要執行動作的物件提示名稱,如果可以擺方多個資訊將會更方便。
|
|
|
11799 |
*/
|
|
|
11800 |
public static function customConfirm(&$conf){
|
|
|
11801 |
|
|
|
11802 |
#初始化要回傳的內容
|
|
|
11803 |
$result=array();
|
|
|
11804 |
|
|
|
11805 |
#初始化要回傳的語法
|
|
|
11806 |
$result["content"]="";
|
|
|
11807 |
|
|
|
11808 |
#記錄當前執行的函數名稱
|
|
|
11809 |
$result["function"]=__FUNCTION__;
|
|
|
11810 |
|
|
|
11811 |
#如果 $conf 不為陣列
|
|
|
11812 |
if(gettype($conf)!="array"){
|
|
|
11813 |
|
|
|
11814 |
#設置執行失敗
|
|
|
11815 |
$result["status"]="false";
|
|
|
11816 |
|
|
|
11817 |
#設置執行錯誤訊息
|
|
|
11818 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
11819 |
|
|
|
11820 |
#如果傳入的參數為 null
|
|
|
11821 |
if($conf==null){
|
|
|
11822 |
|
|
|
11823 |
#設置執行錯誤訊息
|
|
|
11824 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
11825 |
|
|
|
11826 |
}#if end
|
|
|
11827 |
|
|
|
11828 |
#回傳結果
|
|
|
11829 |
return $result;
|
|
|
11830 |
|
|
|
11831 |
}#if end
|
|
|
11832 |
|
|
|
11833 |
#檢查參數
|
|
|
11834 |
#函式說明:
|
|
|
11835 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
11836 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
11837 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
11838 |
#$result["function"],當前執行的函式名稱.
|
|
|
11839 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
11840 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
11841 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
11842 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
11843 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
11844 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
11845 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
11846 |
#必填參數:
|
|
|
11847 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
11848 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
11849 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
11850 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("actionName","itemName","cancleActionPage","confirmActionPage");
|
|
|
11851 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
|
|
|
11852 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string");
|
|
|
11853 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
11854 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
11855 |
#可省略參數:
|
|
|
11856 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
11857 |
#$conf["canBeEmptyString"]="false";
|
|
|
11858 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
11859 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("actionFontCss","itemNameFontCss","cancleActionDisplayMethod","cancleRequestMethod","confirmRequestMethod");
|
|
|
11860 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
11861 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");
|
|
|
11862 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
11863 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("__qbpwcf_actionFontCssStyle","__qbpwcf_itemNameFontCssStyle","_self","post","post");
|
|
|
11864 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
11865 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
11866 |
#參考資料:
|
|
|
11867 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
11868 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
11869 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
11870 |
|
|
|
11871 |
#如果檢查不通過
|
|
|
11872 |
if($checkResult["passed"]=="fasle"){
|
|
|
11873 |
|
|
|
11874 |
#設置錯誤
|
|
|
11875 |
$result["status"]="false";
|
|
|
11876 |
|
|
|
11877 |
#設置錯誤訊息
|
|
|
11878 |
$result["error"]=$checkResult;
|
|
|
11879 |
|
|
|
11880 |
#回傳結果
|
|
|
11881 |
return $result;
|
|
|
11882 |
|
|
|
11883 |
}#if end
|
|
|
11884 |
|
|
|
11885 |
#如果有指定 $conf["actionFontCss"]
|
|
|
11886 |
if(isset($conf["actionFontCss"])){
|
|
|
11887 |
|
|
|
11888 |
#套用其css樣式
|
|
|
11889 |
$conf["actionName"]="<span class=".$conf["actionFontCss"].">".$conf["actionName"]."</span>";
|
|
|
11890 |
|
|
|
11891 |
}#if end
|
|
|
11892 |
|
|
|
11893 |
#如果有指定 $conf["itemNameFontCss"]
|
|
|
11894 |
if(isset($conf["itemNameFontCss"])){
|
|
|
11895 |
|
|
|
11896 |
#套用其css樣式
|
|
|
11897 |
$conf["itemName"]="<span class=".$conf["itemNameFontCss"].">".$conf["itemName"]."</span>";
|
|
|
11898 |
|
|
|
11899 |
}#if end
|
|
|
11900 |
|
|
|
11901 |
#函式說明:
|
|
|
11902 |
#表格形式的文字描述:
|
|
|
11903 |
#回傳結果:
|
|
|
11904 |
#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
|
|
|
11905 |
#$result["error"],函式錯誤訊息陣列.
|
|
|
11906 |
#$result["content"],表格形式文字描述的語法.
|
|
|
11907 |
#$result["function"],當前執行的函式名稱.
|
|
|
11908 |
#必填參數:
|
|
|
11909 |
$conf["table"]["text"]["outputString"]="您確定要 「".$conf["actionName"]."」 「".$conf["itemName"]."」 嗎?";#要印出來的文字
|
|
|
11910 |
#可省略參數:
|
|
|
11911 |
$conf["table"]["text"]["tableStart"]="true";#是否要表格開始<table>,"true"代表是。
|
|
|
11912 |
$conf["table"]["text"]["tableClass"]="__withoutBorder";#為表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
11913 |
$conf["table"]["text"]["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
11914 |
$conf["table"]["text"]["trClass"]="__textCssType";#爲tr的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
11915 |
$conf["table"]["text"]["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
11916 |
$conf["table"]["text"]["tdClass"]="__withoutBorder";#該 td 要套用套用的 css 樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
11917 |
$conf["table"]["text"]["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
11918 |
$conf["table"]["text"]["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
11919 |
$conf["table"]["text"]["tableEnd"]="true";#是否要表格結束</table>,"true"代表是。
|
|
|
11920 |
$message=table::text($conf["table"]["text"]);
|
|
|
11921 |
unset($conf["table"]);
|
|
|
11922 |
|
|
|
11923 |
#如果表格文字建立失敗
|
|
|
11924 |
if($message["status"]=="false"){
|
|
|
11925 |
|
|
|
11926 |
#設置執行失敗
|
|
|
11927 |
$result["status"]="false";
|
|
|
11928 |
|
|
|
11929 |
#設置錯誤訊息
|
|
|
11930 |
$result["error"]=$message;
|
|
|
11931 |
|
|
|
11932 |
#回傳結果
|
|
|
11933 |
return $result;
|
|
|
11934 |
|
|
|
11935 |
}#if end
|
|
|
11936 |
|
|
|
11937 |
#如果 $conf["cancleButtonDisplayName"] 沒有設定
|
|
|
11938 |
if(!isset($conf["cancleButtonDisplayName"])){
|
|
|
11939 |
|
|
|
11940 |
$conf["cancleButtonDisplayName"]="取消";
|
|
|
11941 |
|
|
|
11942 |
}#if end
|
|
|
11943 |
|
|
|
11944 |
#函式說明:
|
|
|
11945 |
#一個簡單的按鈕,按了可以到指定的頁面。同時也可以傳送多個隱藏的變數
|
|
|
11946 |
#回傳的結果
|
|
|
11947 |
#$result,語法內容
|
|
|
11948 |
#必填參數:
|
|
|
11949 |
$conf["form"]["sendHugeDataButton"]["actionPage"]=$conf["cancleActionPage"];#按鈕按了之後要到哪個地方?若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
11950 |
$conf["form"]["sendHugeDataButton"]["buttonDisplayValue"]=$conf["cancleButtonDisplayName"];#按鈕上要顯示的文字
|
|
|
11951 |
#可省略參數:
|
|
|
11952 |
|
|
|
11953 |
#如果有設置 $conf["cancleButtonStyle"]
|
|
|
11954 |
if(isset($conf["cancleButtonStyle"])){
|
|
|
11955 |
|
|
|
11956 |
$conf["form"]["sendHugeDataButton"]["buttonStyleName"]=$conf["cancleButtonStyle"];#按鈕的css樣式應該爲何,若省略的話預設會採用 __simpleButtonLinkDefaultButtonCssStyle 的樣式
|
|
|
11957 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
11958 |
#其屬性值爲 "300" , "50" , "30" , "center"
|
|
|
11959 |
#備註:
|
|
|
11960 |
# __simpleButtonLinkDefaultButtonCssStyle,爲預設的按鈕css樣式,請勿使用相同類別名稱的css樣式,以免衝突。
|
|
|
11961 |
|
|
|
11962 |
}#if end
|
|
|
11963 |
|
|
|
11964 |
#如果 $conf["cancleSendingVarName"] 有設定
|
|
|
11965 |
if(isset($conf["cancleSendingVarName"])){
|
|
|
11966 |
|
|
|
11967 |
$conf["form"]["sendHugeDataButton"]["hiddenVarName"]=$conf["cancleSendingVarName"];#要傳送的隱藏變數名稱,與 $conf["hiddenVarContent"] 相對應。
|
|
|
11968 |
|
|
|
11969 |
}#if end
|
|
|
11970 |
|
|
|
11971 |
#如果 $conf["cancleSendingVarValue"] 有設定
|
|
|
11972 |
if(isset($conf["cancleSendingVarValue"])){
|
|
|
11973 |
|
|
|
11974 |
$conf["form"]["sendHugeDataButton"]["hiddenVarContent"]=$conf["cancleSendingVarValue"];#要傳誦的隱藏變數內容,與 $conf["hiddenVarName"] 相對應。
|
|
|
11975 |
|
|
|
11976 |
}#if end
|
|
|
11977 |
|
|
|
11978 |
$conf["form"]["sendHugeDataButton"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設爲"false".
|
|
|
11979 |
$conf["form"]["sendHugeDataButton"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設爲"false"
|
|
|
11980 |
#$conf["form"]["sendHugeDataButton"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是"。
|
|
|
11981 |
#$conf["form"]["sendHugeDataButton"]["tableClass"]="__withoutBorder";#爲表格要採用的css樣式名稱,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
11982 |
#$conf["form"]["sendHugeDataButton"]["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
11983 |
#$conf["form"]["sendHugeDataButton"]["trClass"]="__withoutBorder";#列開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
11984 |
#$conf["form"]["sendHugeDataButton"]["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
11985 |
#$conf["form"]["sendHugeDataButton"]["tdClass"]="__withoutBorder";#行開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
11986 |
#$conf["form"]["sendHugeDataButton"]["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
11987 |
#$conf["form"]["sendHugeDataButton"]["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
11988 |
|
|
|
11989 |
$conf["form"]["sendHugeDataButton"]["method"]=$conf["cancleRequestMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
11990 |
|
|
|
11991 |
#如果 $conf["confirmActionDisplayMethod"] 有設定
|
|
|
11992 |
if(isset($conf["confirmActionDisplayMethod"])){
|
|
|
11993 |
|
|
|
11994 |
$conf["form"]["sendHugeDataButton"]["displayTarget"]=$conf["confirmActionDisplayMethod"];#頁面的呈現方法,可以是開新視窗(_blank)、在目前頁面、頁框裏面(_self)、在父頁面(_parent)、最上層頁面(_top)。
|
|
|
11995 |
|
|
|
11996 |
}#if end
|
|
|
11997 |
|
|
|
11998 |
#$conf["form"]["sendHugeDataButton"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是"。
|
|
|
11999 |
$cancle=form::sendHugeDataButton($conf["form"]["sendHugeDataButton"]);
|
|
|
12000 |
unset($conf["form"]["sendHugeDataButton"]);
|
|
|
12001 |
|
|
|
12002 |
#如果取消的按鈕建立失敗
|
|
|
12003 |
if($cancle["status"]=="false"){
|
|
|
12004 |
|
|
|
12005 |
#設置執行失敗
|
|
|
12006 |
$result["status"]="false";
|
|
|
12007 |
|
|
|
12008 |
#設置錯誤訊息
|
|
|
12009 |
$result["error"]=$cancle;
|
|
|
12010 |
|
|
|
12011 |
#回傳結果
|
|
|
12012 |
return $result;
|
|
|
12013 |
|
|
|
12014 |
}#if end
|
|
|
12015 |
|
|
|
12016 |
#如果 $conf["confirmButtonDisplayName"] 沒有設定
|
|
|
12017 |
if(!isset($conf["confirmButtonDisplayName"])){
|
|
|
12018 |
|
|
|
12019 |
$conf["confirmButtonDisplayName"]="確認";
|
|
|
12020 |
|
|
|
12021 |
}#if end
|
|
|
12022 |
|
|
|
12023 |
#函式說明:
|
|
|
12024 |
#一個簡單的按鈕,按了可以到指定的頁面。同時也可以傳送多個隱藏的變數
|
|
|
12025 |
#回傳的結果
|
|
|
12026 |
#$result,語法內容
|
|
|
12027 |
#必填參數:
|
|
|
12028 |
$conf["form"]["sendHugeDataButton"]["actionPage"]=$conf["confirmActionPage"];#按鈕按了之後要到哪個地方?若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面。
|
|
|
12029 |
$conf["form"]["sendHugeDataButton"]["buttonDisplayValue"]=$conf["confirmButtonDisplayName"];#按鈕上要顯示的文字
|
|
|
12030 |
#可省略參數:
|
|
|
12031 |
|
|
|
12032 |
#如果 $conf["confirmButtonStyle"] 存在
|
|
|
12033 |
if(isset($conf["confirmButtonStyle"])){
|
|
|
12034 |
|
|
|
12035 |
$conf["form"]["sendHugeDataButton"]["buttonStyleName"]=$conf["confirmButtonStyle"];#按鈕的css樣式應該爲何,若省略的話預設會採用 __simpleButtonLinkDefaultButtonCssStyle 的樣式
|
|
|
12036 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
12037 |
#其屬性值爲 "300" , "50" , "30" , "center"
|
|
|
12038 |
#備註:
|
|
|
12039 |
# __simpleButtonLinkDefaultButtonCssStyle,爲預設的按鈕css樣式,請勿使用相同類別名稱的css樣式,以免衝突。
|
|
|
12040 |
|
|
|
12041 |
}#if end
|
|
|
12042 |
|
|
|
12043 |
#如果 $conf["confirmSendingVarName"] 有設定
|
|
|
12044 |
if(isset($conf["confirmSendingVarName"])){
|
|
|
12045 |
|
|
|
12046 |
$conf["form"]["sendHugeDataButton"]["hiddenVarName"]=$conf["confirmSendingVarName"];#要傳送的隱藏變數名稱,與 $conf["hiddenVarContent"] 相對應。
|
|
|
12047 |
|
|
|
12048 |
}#if end
|
|
|
12049 |
|
|
|
12050 |
#如果 $conf["confirmSendingVarValue"] 有設定
|
|
|
12051 |
if(isset($conf["confirmSendingVarValue"])){
|
|
|
12052 |
|
|
|
12053 |
$conf["form"]["sendHugeDataButton"]["hiddenVarContent"]=$conf["confirmSendingVarValue"];#要傳誦的隱藏變數內容,與 $conf["hiddenVarName"] 相對應。
|
|
|
12054 |
|
|
|
12055 |
}#if end
|
|
|
12056 |
|
|
|
12057 |
$conf["form"]["sendHugeDataButton"]["method"]=$conf["confirmRequestMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
12058 |
$conf["form"]["sendHugeDataButton"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設爲"false".
|
|
|
12059 |
$conf["form"]["sendHugeDataButton"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設爲"false"
|
|
|
12060 |
#$conf["form"]["sendHugeDataButton"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是"。
|
|
|
12061 |
#$conf["form"]["sendHugeDataButton"]["tableClass"]="__withoutBorder";#爲表格要採用的css樣式名稱,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
12062 |
#$conf["form"]["sendHugeDataButton"]["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始。
|
|
|
12063 |
#$conf["form"]["sendHugeDataButton"]["trClass"]="__withoutBorder";#列開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
12064 |
#$conf["form"]["sendHugeDataButton"]["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始
|
|
|
12065 |
#$conf["form"]["sendHugeDataButton"]["tdClass"]="__withoutBorder";#行開始的css樣式,"__withoutBorder"代表沒有框線的預設樣式;"__withBorder"代表有框線的預設樣式
|
|
|
12066 |
#$conf["form"]["sendHugeDataButton"]["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束
|
|
|
12067 |
#$conf["form"]["sendHugeDataButton"]["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束。
|
|
|
12068 |
|
|
|
12069 |
#如果 $conf["confirmActionDisplayMethod"] 有設定
|
|
|
12070 |
if(isset($conf["confirmActionDisplayMethod"])){
|
|
|
12071 |
|
|
|
12072 |
$conf["form"]["sendHugeDataButton"]["displayTarget"]=$conf["confirmActionDisplayMethod"];#頁面的呈現方法,可以是開新視窗(_blank)、在目前頁面、頁框裏面(_self)、在父頁面(_parent)、最上層頁面(_top)。
|
|
|
12073 |
|
|
|
12074 |
}#if end
|
|
|
12075 |
|
|
|
12076 |
#$conf["form"]["sendHugeDataButton"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是"。
|
|
|
12077 |
$confirm=form::sendHugeDataButton($conf["form"]["sendHugeDataButton"]);
|
|
|
12078 |
unset($conf["form"]["sendHugeDataButton"]);
|
|
|
12079 |
|
|
|
12080 |
#如果確認的按鈕建立失敗
|
|
|
12081 |
if($confirm["status"]=="false"){
|
|
|
12082 |
|
|
|
12083 |
#設置執行失敗
|
|
|
12084 |
$result["status"]="false";
|
|
|
12085 |
|
|
|
12086 |
#設置錯誤訊息
|
|
|
12087 |
$result["error"]=$confirm;
|
|
|
12088 |
|
|
|
12089 |
#回傳結果
|
|
|
12090 |
return $result;
|
|
|
12091 |
|
|
|
12092 |
}#if end
|
|
|
12093 |
|
|
|
12094 |
#建立一欄表格
|
|
|
12095 |
#函式說明:
|
|
|
12096 |
#建立欄的元素,以及指定裏面要放什麼內容
|
|
|
12097 |
#回傳的變數:
|
|
|
12098 |
#$result["content"],建立欄元素的語法
|
|
|
12099 |
#$result["status"],"true"代表執行成功;"false"代表執行失敗。
|
|
|
12100 |
#$result["error"],錯誤訊息陣列
|
|
|
12101 |
#必填參數:
|
|
|
12102 |
$conf["table::printColumn"]["trClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
12103 |
$conf["table::printColumn"]["tdClass"]="__withoutBorder";#行的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
12104 |
$conf["table::printColumn"]["tdContent"]=array($cancle["content"],$message["content"],$confirm["content"]);#列裏面要放的元素是?如果要空一列則可以輸array(" ")
|
|
|
12105 |
#可省略參數:
|
|
|
12106 |
$conf["table::printColumn"]["tableStartClass"]="__withoutBorder";#列的樣式,預設為"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
12107 |
$conf["table::printColumn"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
12108 |
$conf["table::printColumn"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
12109 |
#$conf["formStart"]="true";#是否要有表單的開始,預設為"false".
|
|
|
12110 |
#$conf["formName"]="";#該表單的名稱
|
|
|
12111 |
#$conf["formAction"]="";#表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置
|
|
|
12112 |
#$conf["formTarget"]="_self";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
12113 |
#$conf["formEnd"]="true";#是否要有表單的結束,預設為"false".
|
|
|
12114 |
$conf["spaceBlockAferPerElement"]="true";#是否每個欄元素(除了最後一個元素)後面都要空一列。"true"代表要空一列.預設是不空一列.
|
|
|
12115 |
$printColumn=table::printColumn($conf["table::printColumn"]);
|
|
|
12116 |
unset($conf["table::printColumn"]);
|
|
|
12117 |
|
|
|
12118 |
#如果建立一欄表格失敗
|
|
|
12119 |
if($printColumn["status"]=="false"){
|
|
|
12120 |
|
|
|
12121 |
#設置執行失敗
|
|
|
12122 |
$result["status"]="false";
|
|
|
12123 |
|
|
|
12124 |
#設置錯誤訊息
|
|
|
12125 |
$result["error"]=$printColumn;
|
|
|
12126 |
|
|
|
12127 |
#回傳結果
|
|
|
12128 |
return $result;
|
|
|
12129 |
|
|
|
12130 |
}#if end
|
|
|
12131 |
|
|
|
12132 |
#取得一欄表格的語法
|
|
|
12133 |
$result["content"]=$result["content"].$printColumn["content"];
|
|
|
12134 |
|
|
|
12135 |
#設置執行正常
|
|
|
12136 |
$result["status"]="true";
|
|
|
12137 |
|
|
|
12138 |
#回傳結果
|
|
|
12139 |
return $result;
|
|
|
12140 |
|
|
|
12141 |
}#function customConfirm end
|
|
|
12142 |
|
|
|
12143 |
/*
|
|
|
12144 |
#函式說明:
|
|
|
12145 |
#上傳檔案的表單
|
|
|
12146 |
#回傳結果:
|
|
|
12147 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12148 |
#$result["function"],當前執行的函數.
|
|
|
12149 |
#$result["error"],錯誤訊息陣列.
|
|
|
12150 |
#$result["content"],上傳檔案的語法.
|
|
|
12151 |
#必填參數:
|
|
|
12152 |
#$conf["formFileName"],字串,該檔案上傳時的表單名稱。
|
|
|
12153 |
$conf["formFileName"]="";
|
|
|
12154 |
#可省略參數:
|
|
|
12155 |
#$conf["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
12156 |
#$conf["acceptType"]="";
|
|
|
12157 |
#$conf["class"],字串,該上傳表單所要套用的css樣式,若省略則採用預設的css樣式"__qbpwcf_inputFileCssStyle",其屬性爲 width:100% font-size:30px
|
|
|
12158 |
#$conf["class"]="";
|
|
|
12159 |
#$conf["id"],字串,爲該上傳表單的id,預設跟$conf["formFileName"]一樣.
|
|
|
12160 |
#$conf["id"]="";
|
|
|
12161 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
12162 |
#$conf["required"]="true";
|
|
|
12163 |
#$conf["comment"],字串,輔助說明的文字,會出現在檔案上傳的上一行.
|
|
|
12164 |
#$conf["comment"]="";
|
|
|
12165 |
#$conf["formStart"],字串,爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
12166 |
#$conf["formStart"]="true";
|
|
|
12167 |
#$conf["formAction"],字串,表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略,預設為"false".
|
|
|
12168 |
#$conf["formAction"]="";
|
|
|
12169 |
#$conf["formName"],字串,爲該表單的名稱
|
|
|
12170 |
#$conf["formName"]="";
|
|
|
12171 |
#$conf["formMethod"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
12172 |
#$conf["formMethod"]="";
|
|
|
12173 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
12174 |
#$conf["formTarget"]="";
|
|
|
12175 |
#$conf["formEnd"],字串,爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
12176 |
#$conf["formEnd"]="true";
|
|
|
12177 |
#參考資料:
|
|
|
12178 |
#http://www.w3schools.com/tags/tag_input.asp
|
|
|
12179 |
#備註:
|
|
|
12180 |
#無.
|
|
|
12181 |
*/
|
|
|
12182 |
public static function inputFile(&$conf){
|
|
|
12183 |
|
|
|
12184 |
#初始化要回傳的變數
|
|
|
12185 |
$result=array();
|
|
|
12186 |
|
|
|
12187 |
#設置當前執行的函式
|
|
|
12188 |
$result["function"]=__FUNCTION__;
|
|
|
12189 |
|
|
|
12190 |
#初始化表單開始的語法
|
|
|
12191 |
$result["content"]="";
|
|
|
12192 |
|
|
|
12193 |
#如果 $conf 不為陣列
|
|
|
12194 |
if(gettype($conf)!="array"){
|
|
|
12195 |
|
|
|
12196 |
#設置執行失敗
|
|
|
12197 |
$result["status"]="false";
|
|
|
12198 |
|
|
|
12199 |
#設置執行錯誤訊息
|
|
|
12200 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
12201 |
|
|
|
12202 |
#如果傳入的參數為 null
|
|
|
12203 |
if($conf==null){
|
|
|
12204 |
|
|
|
12205 |
#設置執行錯誤訊息
|
|
|
12206 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
12207 |
|
|
|
12208 |
}#if end
|
|
|
12209 |
|
|
|
12210 |
#回傳結果
|
|
|
12211 |
return $result;
|
|
|
12212 |
|
|
|
12213 |
}#if end
|
|
|
12214 |
|
|
|
12215 |
#檢查參數
|
|
|
12216 |
#函式說明:
|
|
|
12217 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
12218 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12219 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
12220 |
#$result["function"],當前執行的函式名稱.
|
|
|
12221 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
12222 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
12223 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
12224 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
12225 |
#必填參數:
|
|
|
12226 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
12227 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
12228 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
12229 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName");
|
|
|
12230 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
12231 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
12232 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
12233 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
12234 |
#可省略參數:
|
|
|
12235 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
12236 |
#$conf["canBeEmptyString"]="false";
|
|
|
12237 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
12238 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("acceptType","class","id","comment","formStart","formAction","formName","formMethod","formTarget","formEnd","required");
|
|
|
12239 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
12240 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string");
|
|
|
12241 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
12242 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"__qbpwcf_inputFileCssStyle","\$conf[\"formFileName\"]",null,"false",null,null,"post","_self","false","false");
|
|
|
12243 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
12244 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
12245 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
12246 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
12247 |
|
|
|
12248 |
#如果檢查參數失敗
|
|
|
12249 |
if($checkResult["status"]=="false"){
|
|
|
12250 |
|
|
|
12251 |
#設置執行失敗
|
|
|
12252 |
$result["status"]="false";
|
|
|
12253 |
|
|
|
12254 |
#設置執行錯誤
|
|
|
12255 |
$result["error"]=$checkResult;
|
|
|
12256 |
|
|
|
12257 |
#回傳結果
|
|
|
12258 |
return $result;
|
|
|
12259 |
|
|
|
12260 |
}#if end
|
|
|
12261 |
|
|
|
12262 |
#如果檢查參數不通過
|
|
|
12263 |
if($checkResult["passed"]=="false"){
|
|
|
12264 |
|
|
|
12265 |
#設置執行失敗
|
|
|
12266 |
$result["status"]="false";
|
|
|
12267 |
|
|
|
12268 |
#設置執行錯誤
|
|
|
12269 |
$result["error"]=$checkResult;
|
|
|
12270 |
|
|
|
12271 |
#回傳結果
|
|
|
12272 |
return $result;
|
|
|
12273 |
|
|
|
12274 |
}#if end
|
|
|
12275 |
|
|
|
12276 |
#如果 $conf["formStart"] 等於 "true"
|
|
|
12277 |
if($conf["formStart"]=="true"){
|
|
|
12278 |
|
|
|
12279 |
#函式說明:
|
|
|
12280 |
#表單開始
|
|
|
12281 |
#回傳結果:
|
|
|
12282 |
#$result,表單開始的語法
|
|
|
12283 |
#必填參數:
|
|
|
12284 |
$conf["form"]["start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
12285 |
#可省略參數:
|
|
|
12286 |
|
|
|
12287 |
#如果 $conf["formName"] 有設置
|
|
|
12288 |
if(isset($conf["formName"])){
|
|
|
12289 |
|
|
|
12290 |
#則設定其數值
|
|
|
12291 |
$conf["form"]["start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
12292 |
|
|
|
12293 |
}#if end
|
|
|
12294 |
|
|
|
12295 |
#設定 method 參數
|
|
|
12296 |
$conf["form"]["start"]["method"]=$conf["formMethod"];#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
12297 |
|
|
|
12298 |
#設定 "formTarget" 參數
|
|
|
12299 |
$conf["form"]["start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
12300 |
|
|
|
12301 |
#$conf["form"]["start"]["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是;
|
|
|
12302 |
#$conf["form"]["start"]["tableClass"]=$conf["tableClass"];#表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
12303 |
$formStart=form::start($conf["form"]["start"]);
|
|
|
12304 |
unset($conf["form"]["start"]);
|
|
|
12305 |
|
|
|
12306 |
#串接表單開始
|
|
|
12307 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
12308 |
|
|
|
12309 |
}#if end
|
|
|
12310 |
|
|
|
12311 |
#過濾 $conf["formFileName"] 避免錯誤
|
|
|
12312 |
#函式說明:
|
|
|
12313 |
#處理字串避免網頁出錯
|
|
|
12314 |
#回傳結果:
|
|
|
12315 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12316 |
#$result["function"],當前執行的函數.
|
|
|
12317 |
#$result["content"],爲處理好的字串.
|
|
|
12318 |
#$result["error"],錯誤訊息陣列.
|
|
|
12319 |
#必填參數:
|
|
|
12320 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formFileName"];#爲要處理的字串
|
|
|
12321 |
#可省略的參數:
|
|
|
12322 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
12323 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
12324 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
12325 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
12326 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
12327 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
12328 |
|
|
|
12329 |
#debug
|
|
|
12330 |
#var_dump($correctCharacter);
|
|
|
12331 |
|
|
|
12332 |
#如果過濾字串失敗
|
|
|
12333 |
if($correctCharacter["status"]=="false"){
|
|
|
12334 |
|
|
|
12335 |
#設置執行失敗
|
|
|
12336 |
$result["status"]="false";
|
|
|
12337 |
|
|
|
12338 |
#設置執行錯誤訊息
|
|
|
12339 |
$result["error"]=$correctCharacter;
|
|
|
12340 |
|
|
|
12341 |
#回傳結果
|
|
|
12342 |
return $result;
|
|
|
12343 |
|
|
|
12344 |
}#if end
|
|
|
12345 |
|
|
|
12346 |
#置換過濾好了的$conf["name"]
|
|
|
12347 |
$conf["formFileName"]=$correctCharacter["content"];
|
|
|
12348 |
|
|
|
12349 |
#過濾 $conf["id"] 避免錯誤
|
|
|
12350 |
#函式說明:
|
|
|
12351 |
#處理字串避免網頁出錯
|
|
|
12352 |
#回傳結果:
|
|
|
12353 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12354 |
#$result["function"],當前執行的函數.
|
|
|
12355 |
#$result["content"],爲處理好的字串.
|
|
|
12356 |
#$result["error"],錯誤訊息陣列.
|
|
|
12357 |
#必填參數:
|
|
|
12358 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["id"];#爲要處理的字串
|
|
|
12359 |
#可省略的參數:
|
|
|
12360 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
12361 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
12362 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
12363 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
12364 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
12365 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
12366 |
|
|
|
12367 |
#debug
|
|
|
12368 |
#var_dump($correctCharacter);
|
|
|
12369 |
|
|
|
12370 |
#如果過濾字串失敗
|
|
|
12371 |
if($correctCharacter["status"]=="false"){
|
|
|
12372 |
|
|
|
12373 |
#設置執行失敗
|
|
|
12374 |
$result["status"]="false";
|
|
|
12375 |
|
|
|
12376 |
#設置執行錯誤訊息
|
|
|
12377 |
$result["error"]=$correctCharacter;
|
|
|
12378 |
|
|
|
12379 |
#回傳結果
|
|
|
12380 |
return $result;
|
|
|
12381 |
|
|
|
12382 |
}#if end
|
|
|
12383 |
|
|
|
12384 |
#置換過濾好了的$conf["id"]
|
|
|
12385 |
$conf["id"]=$correctCharacter["content"];
|
|
|
12386 |
|
|
|
12387 |
#設定id
|
|
|
12388 |
$conf["id"]=" id=".$conf["id"]." ";
|
|
|
12389 |
|
|
|
12390 |
#設定 css 樣式
|
|
|
12391 |
$conf["class"]=" class=".$conf["class"]." ";
|
|
|
12392 |
|
|
|
12393 |
#如果 $conf["comment"] 有設置
|
|
|
12394 |
if(isset($conf["comment"])){
|
|
|
12395 |
|
|
|
12396 |
#放置說明文字
|
|
|
12397 |
$result["content"]=$result["content"]."<span ".$conf["class"]." >".$conf["comment"]."</span><br>";
|
|
|
12398 |
|
|
|
12399 |
}#if end
|
|
|
12400 |
|
|
|
12401 |
#如果有設置 $conf["acceptType"]
|
|
|
12402 |
if(isset($conf["acceptType"])){
|
|
|
12403 |
|
|
|
12404 |
#設置 "accept" 屬性
|
|
|
12405 |
$conf["acceptType"]=" accept=".$conf["acceptType"]." ";
|
|
|
12406 |
|
|
|
12407 |
}#if end
|
|
|
12408 |
|
|
|
12409 |
#反之
|
|
|
12410 |
else{
|
|
|
12411 |
|
|
|
12412 |
#設置為 ""
|
|
|
12413 |
$conf["acceptType"]="";
|
|
|
12414 |
|
|
|
12415 |
}#else end
|
|
|
12416 |
|
|
|
12417 |
#如果 $conf["required"] 為 "true"
|
|
|
12418 |
if($conf["required"]=="true"){
|
|
|
12419 |
|
|
|
12420 |
#設置 "required" 屬性
|
|
|
12421 |
$conf["required"]="required";
|
|
|
12422 |
|
|
|
12423 |
}#if end
|
|
|
12424 |
|
|
|
12425 |
#反之
|
|
|
12426 |
else{
|
|
|
12427 |
|
|
|
12428 |
#設置為 ""
|
|
|
12429 |
$conf["required"]="";
|
|
|
12430 |
|
|
|
12431 |
}#else end
|
|
|
12432 |
|
|
|
12433 |
#放置上傳檔案表單的語法
|
|
|
12434 |
$result["content"]=$result["content"]."<input type = file ".$conf["class"]." name = ".$conf["formFileName"]." ".$conf["id"]." ".$conf["acceptType"]." ".$conf["required"]." >";
|
|
|
12435 |
|
|
|
12436 |
#如果 $conf["formEnd"] 等於 "true"
|
|
|
12437 |
if($conf["formEnd"]=="true"){
|
|
|
12438 |
|
|
|
12439 |
$conf["form"]["end"]["tableEnd"]="false";#爲該表單是否要以</table>結尾。"true"爲是;"false"爲否。
|
|
|
12440 |
$formEnd=form::end($conf["form"]["end"]);
|
|
|
12441 |
unset($conf["form"]["end"]);
|
|
|
12442 |
|
|
|
12443 |
#如果表單結束失敗
|
|
|
12444 |
if($formEnd["status"]=="false"){
|
|
|
12445 |
|
|
|
12446 |
#設置執行失敗
|
|
|
12447 |
$result["status"]="false";
|
|
|
12448 |
|
|
|
12449 |
#設置執行錯誤
|
|
|
12450 |
$result["error"]=$formEnd;
|
|
|
12451 |
|
|
|
12452 |
#回傳結果
|
|
|
12453 |
return $result;
|
|
|
12454 |
|
|
|
12455 |
}#if end
|
|
|
12456 |
|
|
|
12457 |
#串接表單結束
|
|
|
12458 |
$result["content"]=$result["content"].$formEnd["content"];
|
|
|
12459 |
|
|
|
12460 |
}#if end
|
|
|
12461 |
|
|
|
12462 |
#設置執行正常
|
|
|
12463 |
$result["status"]="true";
|
|
|
12464 |
|
|
|
12465 |
#回傳語法
|
|
|
12466 |
return $result;
|
|
|
12467 |
|
|
|
12468 |
}#function inputFile end
|
|
|
12469 |
|
|
|
12470 |
/*
|
|
|
12471 |
#函式說明:
|
|
|
12472 |
#可以瀏覽要上傳的檔案
|
|
|
12473 |
#回傳結果:
|
|
|
12474 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12475 |
#$result["function"],當前執行的函數.
|
|
|
12476 |
#$result["error"],錯誤訊息陣列.
|
|
|
12477 |
#$result["content"],上傳檔案的語法.
|
|
|
12478 |
#必填參數:
|
|
|
12479 |
#$conf["formFileName"],字串,該上傳檔案的表單名稱.
|
|
|
12480 |
$conf["formFileName"]="";
|
|
|
12481 |
#可省略參數:
|
|
|
12482 |
#$conf["maxFileSize"],字串,檔案的最大限制,單位是位元組(byte)。1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設是10240000(10MB)
|
|
|
12483 |
#$conf["maxFileSize"]="10240000";
|
|
|
12484 |
#$conf["browseButtonClass"],字串,瀏覽檔案的按鈕樣式,預設為"__qbpwcf_inputFileCssStyle".
|
|
|
12485 |
#$conf["browseButtonClass"]="__inputFileCssStyle";
|
|
|
12486 |
#$conf["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
12487 |
#$conf["acceptType"]="";
|
|
|
12488 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
12489 |
#$conf["required"]="true";
|
|
|
12490 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
12491 |
#$conf["trStart"]="true";
|
|
|
12492 |
#$conf["trClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
12493 |
#$conf["trClass"]="__withoutBorder";
|
|
|
12494 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
12495 |
#$conf["tdStart"]="false";
|
|
|
12496 |
#$conf["tdClass"],字串,行的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
12497 |
#$conf["tdClass"]="__withoutBorder";
|
|
|
12498 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
12499 |
#$conf["tdEnd"]="true";
|
|
|
12500 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
12501 |
#$conf["trEnd"]="true";
|
|
|
12502 |
#$conf["formStart"],字串,是否為表單的開始,"true"為是,預設為"false".
|
|
|
12503 |
#$conf["formStart"]="true";
|
|
|
12504 |
#$conf["formName"],字串,表單的名稱
|
|
|
12505 |
#$conf["formName"]="";
|
|
|
12506 |
#$conf["formAction"],字串,表單的目標,若有設置$conf["formStart"]為"true",則預設為php檔案自己
|
|
|
12507 |
#$conf["formAction"]="";
|
|
|
12508 |
#$conf["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
12509 |
#$conf["formTarget"]="_self";
|
|
|
12510 |
#$conf["formEnd"],字串,是否為表單的結束,"true"為是,預設為"false".
|
|
|
12511 |
#$conf["formEnd"]="true";
|
|
|
12512 |
#$conf["comment"],字串,該上傳檔案的註解,預設不顯示.
|
|
|
12513 |
#$conf["comment"]="";
|
|
|
12514 |
#參考資料:
|
|
|
12515 |
#無.
|
|
|
12516 |
#備註:
|
|
|
12517 |
#無.
|
|
|
12518 |
*/
|
|
|
12519 |
public static function uploadOneFile(&$conf){
|
|
|
12520 |
|
|
|
12521 |
#初始化要回傳的變數
|
|
|
12522 |
$result=array();
|
|
|
12523 |
|
|
|
12524 |
#設置當前執行的函式
|
|
|
12525 |
$result["function"]=__FUNCTION__;
|
|
|
12526 |
|
|
|
12527 |
#初始化表單開始的語法
|
|
|
12528 |
$result["content"]="";
|
|
|
12529 |
|
|
|
12530 |
#如果 $conf 不為陣列
|
|
|
12531 |
if(gettype($conf)!="array"){
|
|
|
12532 |
|
|
|
12533 |
#設置執行失敗
|
|
|
12534 |
$result["status"]="false";
|
|
|
12535 |
|
|
|
12536 |
#設置執行錯誤訊息
|
|
|
12537 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
12538 |
|
|
|
12539 |
#如果傳入的參數為 null
|
|
|
12540 |
if($conf==null){
|
|
|
12541 |
|
|
|
12542 |
#設置執行錯誤訊息
|
|
|
12543 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
12544 |
|
|
|
12545 |
}#if end
|
|
|
12546 |
|
|
|
12547 |
#回傳結果
|
|
|
12548 |
return $result;
|
|
|
12549 |
|
|
|
12550 |
}#if end
|
|
|
12551 |
|
|
|
12552 |
#檢查參數
|
|
|
12553 |
#函式說明:
|
|
|
12554 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
12555 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12556 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
12557 |
#$result["function"],當前執行的函式名稱.
|
|
|
12558 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
12559 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
12560 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
12561 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
12562 |
#必填參數:
|
|
|
12563 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
12564 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
12565 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
12566 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName");
|
|
|
12567 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
12568 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
12569 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
12570 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
12571 |
#可省略參數:
|
|
|
12572 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
12573 |
#$conf["canBeEmptyString"]="false";
|
|
|
12574 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
12575 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("maxFileSize","browseButtonClass","trStart","trClass","tdStart","tdClass","tdEnd","trEnd","formStart","formAction","formTarget","formEnd","comment","formName","acceptType","required");
|
|
|
12576 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
12577 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
12578 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
12579 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("10240000","__qbpwcf_inputFileCssStyle","false","withoutBorder","false","withoutBorder","false","false","false",null,"_self","false",null,null,null,"false");
|
|
|
12580 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
12581 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
12582 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
12583 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
12584 |
|
|
|
12585 |
#如果檢查參數失敗
|
|
|
12586 |
if($checkResult["status"]=="false"){
|
|
|
12587 |
|
|
|
12588 |
#設置執行失敗
|
|
|
12589 |
$result["status"]="false";
|
|
|
12590 |
|
|
|
12591 |
#設置執行錯誤
|
|
|
12592 |
$result["error"]=$checkResult;
|
|
|
12593 |
|
|
|
12594 |
#回傳結果
|
|
|
12595 |
return $result;
|
|
|
12596 |
|
|
|
12597 |
}#if end
|
|
|
12598 |
|
|
|
12599 |
#如果檢查參數不通過
|
|
|
12600 |
if($checkResult["passed"]=="false"){
|
|
|
12601 |
|
|
|
12602 |
#設置執行失敗
|
|
|
12603 |
$result["status"]="false";
|
|
|
12604 |
|
|
|
12605 |
#設置執行錯誤
|
|
|
12606 |
$result["error"]=$checkResult;
|
|
|
12607 |
|
|
|
12608 |
#回傳結果
|
|
|
12609 |
return $result;
|
|
|
12610 |
|
|
|
12611 |
}#if end
|
|
|
12612 |
|
|
|
12613 |
#建立沒有框線的表單css樣式
|
|
|
12614 |
#函式說明:
|
|
|
12615 |
#創建 css 樣式
|
|
|
12616 |
#必填參數:
|
|
|
12617 |
$conf_createCssStyle["cssStyleName"]="__withoutBorderUploadOneFileCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
12618 |
$conf_createCssStyle["attributes"]=array("width","font-size","border","border-style");#為屬性名稱,須為陣列值
|
|
|
12619 |
$conf_createCssStyle["content"]=array("100%","30px","0px","solid");#為屬性值,須為陣列值
|
|
|
12620 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
12621 |
unset($conf_createCssStyle);
|
|
|
12622 |
|
|
|
12623 |
#若創建css樣式失敗
|
|
|
12624 |
if($css["status"]=="false"){
|
|
|
12625 |
|
|
|
12626 |
#設置執行失敗
|
|
|
12627 |
$result["status"]="false";
|
|
|
12628 |
|
|
|
12629 |
#設置執行錯誤
|
|
|
12630 |
$result["error"]=$css;
|
|
|
12631 |
|
|
|
12632 |
#回傳結果
|
|
|
12633 |
return $result;
|
|
|
12634 |
|
|
|
12635 |
}#if end
|
|
|
12636 |
|
|
|
12637 |
#串接css語法
|
|
|
12638 |
$result["content"]=$result["content"].$css["content"];
|
|
|
12639 |
|
|
|
12640 |
#建立有框線的表單css樣式
|
|
|
12641 |
#函式說明:
|
|
|
12642 |
#創建 css 樣式
|
|
|
12643 |
#必填參數:
|
|
|
12644 |
$conf_createCssStyle["cssStyleName"]="__withBorderUploadOneFileCssStyle";#為該 css 樣式的名稱,不能以數字開頭。
|
|
|
12645 |
$conf_createCssStyle["attributes"]=array("width","font-size","border","border-style");#為屬性名稱,須為陣列值
|
|
|
12646 |
$conf_createCssStyle["content"]=array("100%","30px","1px","solid");#為屬性值,須為陣列值
|
|
|
12647 |
$css=css::createCssStyle($conf_createCssStyle);
|
|
|
12648 |
unset($conf_createCssStyle);
|
|
|
12649 |
|
|
|
12650 |
#若創建css樣式失敗
|
|
|
12651 |
if($css["status"]=="false"){
|
|
|
12652 |
|
|
|
12653 |
#設置執行失敗
|
|
|
12654 |
$result["status"]="false";
|
|
|
12655 |
|
|
|
12656 |
#設置執行錯誤
|
|
|
12657 |
$result["error"]=$css;
|
|
|
12658 |
|
|
|
12659 |
#回傳結果
|
|
|
12660 |
return $result;
|
|
|
12661 |
|
|
|
12662 |
}#if end
|
|
|
12663 |
|
|
|
12664 |
#串接css語法
|
|
|
12665 |
$result["content"]=$result["content"].$css["content"];
|
|
|
12666 |
|
|
|
12667 |
#如果 $conf["trStart"] 等於 "true"
|
|
|
12668 |
if($conf["trStart"]=="true"){
|
|
|
12669 |
|
|
|
12670 |
#套用指定的css樣式
|
|
|
12671 |
$conf["table"]["trStart"]["class"]=$conf["trClass"];
|
|
|
12672 |
|
|
|
12673 |
#函式說明:
|
|
|
12674 |
#列開始
|
|
|
12675 |
#回傳結果:
|
|
|
12676 |
#$result,列開始的語法
|
|
|
12677 |
#必填寫的參數:
|
|
|
12678 |
#$conf["table"]["trStart"]["class"]="";#該 tr 要套用套用的 css 樣式若爲 "" 則會採用預設的css樣式 __defaultTrCsssStyle,其屬性爲 border:1px solid blue
|
|
|
12679 |
$trStart=table::trStart($conf["table"]["trStart"]);
|
|
|
12680 |
unset($conf["table"]["trStart"]);
|
|
|
12681 |
|
|
|
12682 |
#如果列歐開始結束
|
|
|
12683 |
if($trStart["status"]=="false"){
|
|
|
12684 |
|
|
|
12685 |
#設置執行失敗
|
|
|
12686 |
$result["status"]="false";
|
|
|
12687 |
|
|
|
12688 |
#設置執行錯誤
|
|
|
12689 |
$result["error"]=$trStart;
|
|
|
12690 |
|
|
|
12691 |
#回傳結果
|
|
|
12692 |
return $result;
|
|
|
12693 |
|
|
|
12694 |
}#if end
|
|
|
12695 |
|
|
|
12696 |
#串接列開始
|
|
|
12697 |
$result["content"]=$result["content"].$trStart["content"];
|
|
|
12698 |
|
|
|
12699 |
}#if end
|
|
|
12700 |
|
|
|
12701 |
#如果 $conf["tdStart"] 等於 "true"
|
|
|
12702 |
if($conf["tdStart"]=="true"){
|
|
|
12703 |
|
|
|
12704 |
#套用指定的css樣式
|
|
|
12705 |
$conf["table"]["tdStart"]["class"]=$conf["tdClass"];
|
|
|
12706 |
|
|
|
12707 |
#函式說明:
|
|
|
12708 |
#列開始
|
|
|
12709 |
#回傳結果:
|
|
|
12710 |
#$result,列開始的語法
|
|
|
12711 |
#必填寫的參數:
|
|
|
12712 |
#$conf["table"]["tdStart"]["class"]="";#該 td 要套用套用的 css 樣式若爲 "" 則會採用預設的css樣式 __defaultTrCsssStyle,其屬性爲 border:1px solid blue
|
|
|
12713 |
$tdStart=table::tdStart($conf["table"]["tdStart"]);
|
|
|
12714 |
unset($conf["table"]["tdStart"]);
|
|
|
12715 |
|
|
|
12716 |
#如果欄開始結束
|
|
|
12717 |
if($tdStart["status"]=="false"){
|
|
|
12718 |
|
|
|
12719 |
#設置執行失敗
|
|
|
12720 |
$result["status"]="false";
|
|
|
12721 |
|
|
|
12722 |
#設置執行錯誤
|
|
|
12723 |
$result["error"]=$tdStart;
|
|
|
12724 |
|
|
|
12725 |
#回傳結果
|
|
|
12726 |
return $result;
|
|
|
12727 |
|
|
|
12728 |
}#if end
|
|
|
12729 |
|
|
|
12730 |
#串接欄開始
|
|
|
12731 |
$result["content"]=$result["content"].$tdStart["content"];
|
|
|
12732 |
|
|
|
12733 |
}#if end
|
|
|
12734 |
|
|
|
12735 |
#如果 $conf["formStart"] 為 "true"
|
|
|
12736 |
if($conf["formStart"]=="true"){
|
|
|
12737 |
|
|
|
12738 |
#函式說明:
|
|
|
12739 |
#表單開始
|
|
|
12740 |
#回傳結果:
|
|
|
12741 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
12742 |
#$result["error"],錯誤訊息陣列.
|
|
|
12743 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
12744 |
#$result["content"],表單開始的語法.
|
|
|
12745 |
#必填參數:
|
|
|
12746 |
$conf["form::start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
12747 |
#可省略參數:
|
|
|
12748 |
#$conf["legend"]="";#顯示表單的標題
|
|
|
12749 |
|
|
|
12750 |
#如果 $conf["formName"] 有設置
|
|
|
12751 |
if(isset($conf["formName"])){
|
|
|
12752 |
|
|
|
12753 |
$conf["form::start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
12754 |
|
|
|
12755 |
}#if end
|
|
|
12756 |
|
|
|
12757 |
#$conf["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
12758 |
$conf["form::start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
12759 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是,"false"為否,預設為"false".
|
|
|
12760 |
#$conf["tableClass"]="";#表格要套用的css樣式,預設爲"__withoutBorder"無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
12761 |
#$conf["showFieldsetBorder"]="false";#是否要顯示表單區域的框線,預設為"false"不顯示,"true"代表要顯示.
|
|
|
12762 |
#參考資料:
|
|
|
12763 |
#http://www.w3schools.com/html/html_forms.asp
|
|
|
12764 |
#http://www.w3schools.com/tags/tag_fieldset.asp
|
|
|
12765 |
$formStart=form::start($conf["form::start"]);
|
|
|
12766 |
unset($conf["form::start"]);
|
|
|
12767 |
|
|
|
12768 |
#如果表單開始失敗
|
|
|
12769 |
if($formStart["status"]=="false"){
|
|
|
12770 |
|
|
|
12771 |
#設置執行失敗
|
|
|
12772 |
$result["status"]="false";
|
|
|
12773 |
|
|
|
12774 |
#設置執行錯誤
|
|
|
12775 |
$result["error"]=$formStart;
|
|
|
12776 |
|
|
|
12777 |
#回傳結果
|
|
|
12778 |
return $result;
|
|
|
12779 |
|
|
|
12780 |
}#if end
|
|
|
12781 |
|
|
|
12782 |
#串接表單的開始
|
|
|
12783 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
12784 |
|
|
|
12785 |
}#if end
|
|
|
12786 |
|
|
|
12787 |
#設定上傳到檔案最大大小限制,單位爲byte
|
|
|
12788 |
$conf_inputHidden["name"]="max_file_size";
|
|
|
12789 |
$conf_inputHidden["value"]=$conf["maxFileSize"];
|
|
|
12790 |
$hiddenVar=form::inputHidden($conf_inputHidden);
|
|
|
12791 |
unset($conf_inputHidden);#清空變數避免出錯
|
|
|
12792 |
|
|
|
12793 |
#建立隱藏的表單失敗
|
|
|
12794 |
if($hiddenVar["status"]=="false"){
|
|
|
12795 |
|
|
|
12796 |
#設置執行失敗
|
|
|
12797 |
$result["status"]="false";
|
|
|
12798 |
|
|
|
12799 |
#設置執行錯誤
|
|
|
12800 |
$result["error"]=$hiddenVar;
|
|
|
12801 |
|
|
|
12802 |
#回傳結果
|
|
|
12803 |
return $result;
|
|
|
12804 |
|
|
|
12805 |
}#if end
|
|
|
12806 |
|
|
|
12807 |
#串接檔案大小的限制
|
|
|
12808 |
$result["content"]=$result["content"].$hiddenVar["content"];
|
|
|
12809 |
|
|
|
12810 |
#函式說明:
|
|
|
12811 |
#上傳檔案的表單
|
|
|
12812 |
#回傳結果:
|
|
|
12813 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12814 |
#$result["function"],當前執行的函數.
|
|
|
12815 |
#$result["error"],錯誤訊息陣列.
|
|
|
12816 |
#$result["content"],上傳檔案的語法.
|
|
|
12817 |
#必填參數:
|
|
|
12818 |
#$conf["formFileName"],字串,該檔案上傳時的表單名稱。
|
|
|
12819 |
$conf["form::inputFile"]["formFileName"]=$conf["formFileName"];
|
|
|
12820 |
#可省略參數:
|
|
|
12821 |
|
|
|
12822 |
#如果已有設置 $conf["acceptType"]
|
|
|
12823 |
if(isset($conf["acceptType"])){
|
|
|
12824 |
|
|
|
12825 |
#$conf["form::inputFile"]["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
12826 |
$conf["form::inputFile"]["acceptType"]=$conf["acceptType"];
|
|
|
12827 |
|
|
|
12828 |
}#if end
|
|
|
12829 |
|
|
|
12830 |
#$conf["form::inputFile"]["class"],字串,該上傳表單所要套用的css樣式,若省略則採用預設的css樣式"__inputFileCssStyle",其屬性爲 width:100% font-size:30px
|
|
|
12831 |
$conf["form::inputFile"]["class"]=$conf["browseButtonClass"];
|
|
|
12832 |
#$conf["id"],字串,爲該上傳表單的id,預設跟$conf["formFileName"]一樣.
|
|
|
12833 |
#$conf["id"]="";
|
|
|
12834 |
|
|
|
12835 |
#如果有設置 $conf["required"]
|
|
|
12836 |
if(isset($conf["required"])){
|
|
|
12837 |
|
|
|
12838 |
#$conf["form::inputFile"]["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
12839 |
$conf["form::inputFile"]["required"]=$conf["required"];
|
|
|
12840 |
|
|
|
12841 |
}#if end
|
|
|
12842 |
|
|
|
12843 |
#有設置註解
|
|
|
12844 |
if(isset($conf["comment"])){
|
|
|
12845 |
|
|
|
12846 |
#$conf["form::inputFile"]["comment"],字串,輔助說明的文字,會出現在檔案上傳的上一行.
|
|
|
12847 |
$conf["form::inputFile"]["comment"]=$conf["comment"];
|
|
|
12848 |
|
|
|
12849 |
}#if end
|
|
|
12850 |
|
|
|
12851 |
#$conf["form::inputFile"]["formStart"],字串,爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
12852 |
#$conf["form::inputFile"]["formStart"]=$conf["formStart"];
|
|
|
12853 |
#$conf["form::inputFile"]["formAction"],字串,表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略,預設為"false".
|
|
|
12854 |
#$conf["form::inputFile"]["formAction"]=$conf["formAction"];
|
|
|
12855 |
#$conf["form::inputFile"]["formName"],字串,爲該表單的名稱
|
|
|
12856 |
#$conf["form::inputFile"]["formName"]=$conf["formName"];
|
|
|
12857 |
#$conf["form::inputFile"]["formMethod"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
12858 |
#$conf["form::inputFile"]["formMethod"]="";
|
|
|
12859 |
#$conf["form::inputFile"]["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
12860 |
#$conf["form::inputFile"]["formTarget"]=$conf["formTarget"];
|
|
|
12861 |
#$conf["form::inputFile"]["formEnd"],字串,爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
12862 |
$conf["form::inputFile"]["formEnd"]=$conf["formEnd"];
|
|
|
12863 |
#參考資料:
|
|
|
12864 |
#http://www.w3schools.com/tags/tag_input.asp
|
|
|
12865 |
$inputFile=form::inputFile($conf["form::inputFile"]);
|
|
|
12866 |
unset($conf["form::inputFile"]);
|
|
|
12867 |
|
|
|
12868 |
#如果上傳檔案的表單建立失敗
|
|
|
12869 |
if($inputFile["status"]=="false"){
|
|
|
12870 |
|
|
|
12871 |
#設置執行失敗
|
|
|
12872 |
$result["status"]="false";
|
|
|
12873 |
|
|
|
12874 |
#設置執行錯誤
|
|
|
12875 |
$result["error"]=$inputFile;
|
|
|
12876 |
|
|
|
12877 |
#回傳結果
|
|
|
12878 |
return $result;
|
|
|
12879 |
|
|
|
12880 |
}#if end
|
|
|
12881 |
|
|
|
12882 |
#串接上傳檔案的表單
|
|
|
12883 |
$result["content"]=$result["content"].$inputFile["content"];
|
|
|
12884 |
|
|
|
12885 |
#如果 $conf["tdEnd"] 等於 "true"
|
|
|
12886 |
if($conf["tdEnd"]=="true"){
|
|
|
12887 |
|
|
|
12888 |
#串接欄的結束tag
|
|
|
12889 |
$result["content"]=$result["content"]."</td>";
|
|
|
12890 |
|
|
|
12891 |
}#if end
|
|
|
12892 |
|
|
|
12893 |
#如果 $conf["trEnd"] 等於 "true"
|
|
|
12894 |
if($conf["trEnd"]=="true"){
|
|
|
12895 |
|
|
|
12896 |
#串接列的結束tag
|
|
|
12897 |
$result["content"]=$result["content"]."</tr>";
|
|
|
12898 |
|
|
|
12899 |
}#if end
|
|
|
12900 |
|
|
|
12901 |
#設置執行正常
|
|
|
12902 |
$result["status"]="true";
|
|
|
12903 |
|
|
|
12904 |
#回傳結果
|
|
|
12905 |
return $result;
|
|
|
12906 |
|
|
|
12907 |
}#function uploadOneFile end
|
|
|
12908 |
|
|
|
12909 |
/*
|
|
|
12910 |
#函式說明:
|
|
|
12911 |
#上傳一個檔案,包含送出鈕與回上頁的按鈕
|
|
|
12912 |
#回傳結果:
|
|
|
12913 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12914 |
#$result["function"],當前執行的函數.
|
|
|
12915 |
#$result["error"],錯誤訊息陣列.
|
|
|
12916 |
#$result["content"],語法.
|
|
|
12917 |
#必填參數:
|
|
|
12918 |
#$conf["formFileName"],字串,該上傳檔案的表單名稱.
|
|
|
12919 |
$conf["formFileName"]="";
|
|
|
12920 |
#$conf["actionPage"],字串,處理表單資訊的頁面.
|
|
|
12921 |
$conf["actionPage"]="";
|
|
|
12922 |
#可省略參數:
|
|
|
12923 |
#$conf["backButtonName"],字串,退回上一頁的按鈕要顯示的名稱,預設爲"回上頁"
|
|
|
12924 |
#$conf["backButtonName"]="回上頁";
|
|
|
12925 |
#$conf["backPage"],字串,返回的按鈕點了之後要到哪個頁面,預設是不使用.
|
|
|
12926 |
#$conf["backPage"]="";
|
|
|
12927 |
#$conf["backTarget"],字串,返回按鈕的顯示區塊.
|
|
|
12928 |
#$conf["backTarget"]="";
|
|
|
12929 |
#$conf["backButtonClass"],字串,回上頁按鈕的css樣式,預設為"__simpleButtonLinkDefaultButtonCssStyle".
|
|
|
12930 |
#$conf["backButtonClass"]="__simpleButtonLinkDefaultButtonCssStyle";
|
|
|
12931 |
#$conf["comment"],字串,該上傳檔案的註解,預設不顯示.
|
|
|
12932 |
#$conf["comment"]="";
|
|
|
12933 |
#$conf["formName"],字串,表單的名稱
|
|
|
12934 |
#$conf["formName"]="";
|
|
|
12935 |
#$conf["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
12936 |
#$conf["formTarget"]="_self";
|
|
|
12937 |
#$conf["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
12938 |
#$conf["acceptType"]="";
|
|
|
12939 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
12940 |
#$conf["required"]="true";
|
|
|
12941 |
#$conf["maxFileSize"],字串,檔案的最大限制,單位是位元組(byte),1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設爲"102400000"(100MB)
|
|
|
12942 |
#$conf["maxFileSize"]="102400000";
|
|
|
12943 |
#$conf["browseButtonClass"],字串,瀏覽要上傳檔案的css樣式,預設為"__qbpwcf_inputFileCssStyle".
|
|
|
12944 |
#$conf["browseButtonClass"]="__inputFileCssStyle";
|
|
|
12945 |
#$conf["submitButtonClass"],字串,上傳按鈕的css樣式,預設為"__simpleButtonLinkDefaultButtonCssStyle".
|
|
|
12946 |
#$conf["submitButtonClass"]="__simpleButtonLinkDefaultButtonCssStyle";
|
|
|
12947 |
#$conf["submitButtonName"],字串,送出鈕要顯示的名稱,預設爲"上傳"
|
|
|
12948 |
#$conf["submitButtonName"]="上傳";
|
|
|
12949 |
#參考資料:
|
|
|
12950 |
#無.
|
|
|
12951 |
#備註:
|
|
|
12952 |
#無.
|
|
|
12953 |
*/
|
|
|
12954 |
public static function uploadOneFileCom(&$conf){
|
|
|
12955 |
|
|
|
12956 |
#初始化要回傳的變數
|
|
|
12957 |
$result=array();
|
|
|
12958 |
|
|
|
12959 |
#設置當前執行的函式
|
|
|
12960 |
$result["function"]=__FUNCTION__;
|
|
|
12961 |
|
|
|
12962 |
#初始化表單開始的語法
|
|
|
12963 |
$result["content"]="";
|
|
|
12964 |
|
|
|
12965 |
#如果 $conf 不為陣列
|
|
|
12966 |
if(gettype($conf)!="array"){
|
|
|
12967 |
|
|
|
12968 |
#設置執行失敗
|
|
|
12969 |
$result["status"]="false";
|
|
|
12970 |
|
|
|
12971 |
#設置執行錯誤訊息
|
|
|
12972 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
12973 |
|
|
|
12974 |
#如果傳入的參數為 null
|
|
|
12975 |
if($conf==null){
|
|
|
12976 |
|
|
|
12977 |
#設置執行錯誤訊息
|
|
|
12978 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
12979 |
|
|
|
12980 |
}#if end
|
|
|
12981 |
|
|
|
12982 |
#回傳結果
|
|
|
12983 |
return $result;
|
|
|
12984 |
|
|
|
12985 |
}#if end
|
|
|
12986 |
|
|
|
12987 |
#檢查參數
|
|
|
12988 |
#函式說明:
|
|
|
12989 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
12990 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
12991 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
12992 |
#$result["function"],當前執行的函式名稱.
|
|
|
12993 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
12994 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
12995 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
12996 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
12997 |
#必填參數:
|
|
|
12998 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
12999 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
13000 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
13001 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName","actionPage");
|
|
|
13002 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
13003 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
13004 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
13005 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
13006 |
#可省略參數:
|
|
|
13007 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
13008 |
#$conf["canBeEmptyString"]="false";
|
|
|
13009 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
13010 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("browseButtonClass","submitButtonClass","backPage","backButtonClass","maxFileSize","submitButtonName","backButtonName","comment","formTarget","acceptType","required","formName","backTarget");
|
|
|
13011 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
13012 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string","string","string");
|
|
|
13013 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
13014 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("__qbpwcf_inputFileCssStyle","__qbpwcf_button",null,"__qbpwcf_button","102400000","上傳","回上頁",null,"_self",null,"false",null,"_self");
|
|
|
13015 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
13016 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
13017 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
13018 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
13019 |
|
|
|
13020 |
#如果檢查參數失敗
|
|
|
13021 |
if($checkResult["status"]=="false"){
|
|
|
13022 |
|
|
|
13023 |
#設置執行失敗
|
|
|
13024 |
$result["status"]="false";
|
|
|
13025 |
|
|
|
13026 |
#設置執行錯誤
|
|
|
13027 |
$result["error"]=$checkResult;
|
|
|
13028 |
|
|
|
13029 |
#回傳結果
|
|
|
13030 |
return $result;
|
|
|
13031 |
|
|
|
13032 |
}#if end
|
|
|
13033 |
|
|
|
13034 |
#如果檢查參數不通過
|
|
|
13035 |
if($checkResult["passed"]=="false"){
|
|
|
13036 |
|
|
|
13037 |
#設置執行失敗
|
|
|
13038 |
$result["status"]="false";
|
|
|
13039 |
|
|
|
13040 |
#設置執行錯誤
|
|
|
13041 |
$result["error"]=$checkResult;
|
|
|
13042 |
|
|
|
13043 |
#回傳結果
|
|
|
13044 |
return $result;
|
|
|
13045 |
|
|
|
13046 |
}#if end
|
|
|
13047 |
|
|
|
13048 |
#如果$conf["backPage"]有存在,則放置回上頁的按鈕
|
|
|
13049 |
if(isset($conf["backPage"])){
|
|
|
13050 |
|
|
|
13051 |
#函式說明:
|
|
|
13052 |
#放置按鈕
|
|
|
13053 |
#回傳結果:
|
|
|
13054 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13055 |
#$result["function"],當前執行的函數.
|
|
|
13056 |
#$result["error"],錯誤訊息陣列.
|
|
|
13057 |
#$result["content"],按鈕語法.
|
|
|
13058 |
#必填參數:
|
|
|
13059 |
$conf["form::button"]["buttonDisplayValue"]=$conf["backButtonName"];#爲按鈕上顯示的文字。
|
|
|
13060 |
#可省略參數:
|
|
|
13061 |
$conf["form::button"]["buttonStyleName"]=$conf["backButtonClass"];#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
13062 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
13063 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
13064 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
13065 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
13066 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
13067 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
13068 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
13069 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
13070 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
13071 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
13072 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
13073 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
13074 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
13075 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
13076 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
13077 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
13078 |
$conf["form::button"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
13079 |
$conf["form::button"]["action"]=$conf["backPage"];#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
13080 |
$conf["form::button"]["target"]=$conf["backTarget"];#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
13081 |
$conf["form::button"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
13082 |
#參考資料:
|
|
|
13083 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
13084 |
$prePageButton=form::button($conf["form::button"]);
|
|
|
13085 |
unset($conf["form::button"]);
|
|
|
13086 |
|
|
|
13087 |
#如果回上頁的按鈕建立失敗
|
|
|
13088 |
if($prePageButton["status"]=="false"){
|
|
|
13089 |
|
|
|
13090 |
#設置執行失敗
|
|
|
13091 |
$result["status"]="false";
|
|
|
13092 |
|
|
|
13093 |
#設置執行錯誤
|
|
|
13094 |
$result["error"]=$prePageButton;
|
|
|
13095 |
|
|
|
13096 |
#回傳結果
|
|
|
13097 |
return $result;
|
|
|
13098 |
|
|
|
13099 |
}#if end
|
|
|
13100 |
|
|
|
13101 |
#放置回上頁的按鈕
|
|
|
13102 |
$conf["table::printColumn"]["tdContent"][]=$prePageButton["content"];
|
|
|
13103 |
|
|
|
13104 |
}#if end
|
|
|
13105 |
|
|
|
13106 |
#上傳檔案的表單
|
|
|
13107 |
#函式說明:
|
|
|
13108 |
#可以瀏覽要上傳的檔案
|
|
|
13109 |
#回傳結果:
|
|
|
13110 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13111 |
#$result["function"],當前執行的函數.
|
|
|
13112 |
#$result["error"],錯誤訊息陣列.
|
|
|
13113 |
#$result["content"],上傳檔案的語法.
|
|
|
13114 |
#必填參數:
|
|
|
13115 |
#$conf["formFileName"],字串,該上傳檔案的表單名稱.
|
|
|
13116 |
$conf["form::uploadOneFile"]["formFileName"]=$conf["formFileName"];
|
|
|
13117 |
#可省略參數:
|
|
|
13118 |
#$conf["form::uploadOneFile"]["maxFileSize"],字串,檔案的最大限制,單位是位元組(byte)。1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設是10240000(10MB)
|
|
|
13119 |
$conf["form::uploadOneFile"]["maxFileSize"]=$conf["maxFileSize"];
|
|
|
13120 |
#$conf["browseButtonClass"],字串,瀏覽檔案的按鈕樣式,預設為"__inputFileCssStyle".
|
|
|
13121 |
$conf["form::uploadOneFile"]["browseButtonClass"]=$conf["browseButtonClass"];
|
|
|
13122 |
|
|
|
13123 |
#如果有設定 $conf["acceptType"]
|
|
|
13124 |
if(isset($conf["acceptType"])){
|
|
|
13125 |
|
|
|
13126 |
#$conf["form::uploadOneFile"][["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
13127 |
$conf["form::uploadOneFile"]["acceptType"]=$conf["acceptType"];
|
|
|
13128 |
|
|
|
13129 |
}#if end
|
|
|
13130 |
|
|
|
13131 |
#$conf["form::uploadOneFile"]["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
13132 |
$conf["form::uploadOneFile"]["required"]=$conf["required"];
|
|
|
13133 |
|
|
|
13134 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
13135 |
#$conf["trStart"]="true";
|
|
|
13136 |
#$conf["trClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
13137 |
#$conf["trClass"]="__withoutBorder";
|
|
|
13138 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
13139 |
#$conf["tdStart"]="false";
|
|
|
13140 |
#$conf["tdClass"],字串,行的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
13141 |
#$conf["tdClass"]="__withoutBorder";
|
|
|
13142 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
13143 |
#$conf["tdEnd"]="true";
|
|
|
13144 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
13145 |
#$conf["trEnd"]="true";
|
|
|
13146 |
#$conf["formStart"],字串,是否為表單的開始,"true"為是,預設為"false".
|
|
|
13147 |
$conf["form::uploadOneFile"]["formStart"]="true";
|
|
|
13148 |
|
|
|
13149 |
#如果有設置 $conf["formName"]
|
|
|
13150 |
if(isset($conf["formName"])){
|
|
|
13151 |
|
|
|
13152 |
#$conf["formName"],字串,表單的名稱
|
|
|
13153 |
$conf["form::uploadOneFile"]["formName"]=$conf["formName"];
|
|
|
13154 |
|
|
|
13155 |
}#if end
|
|
|
13156 |
|
|
|
13157 |
#$conf["formAction"],字串,表單的目標,若有設置$conf["formStart"]為"true",則預設為php檔案自己
|
|
|
13158 |
$conf["form::uploadOneFile"]["formAction"]=$conf["actionPage"];
|
|
|
13159 |
#$conf["form::uploadOneFile"]["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
13160 |
$conf["form::uploadOneFile"]["formTarget"]=$conf["formTarget"];
|
|
|
13161 |
#$conf["formEnd"],字串,是否為表單的結束,"true"為是,預設為"false".
|
|
|
13162 |
#$conf["form::uploadOneFile"]["formEnd"]="false";
|
|
|
13163 |
|
|
|
13164 |
#如果 $conf["comment"] 有設定
|
|
|
13165 |
if(isset($conf["comment"])){
|
|
|
13166 |
|
|
|
13167 |
#$conf["form::uploadOneFile"]["comment"],字串,該上傳檔案的註解,預設不顯示.
|
|
|
13168 |
$conf["form::uploadOneFile"]["comment"]=$conf["comment"];
|
|
|
13169 |
|
|
|
13170 |
}#if end
|
|
|
13171 |
|
|
|
13172 |
$uploadOneFile=form::uploadOneFile($conf["form::uploadOneFile"]);
|
|
|
13173 |
unset($conf["form::uploadOneFile"]);
|
|
|
13174 |
|
|
|
13175 |
#如果建立上傳的表單失敗
|
|
|
13176 |
if($uploadOneFile["status"]=="false"){
|
|
|
13177 |
|
|
|
13178 |
#設置執行失敗
|
|
|
13179 |
$result["status"]="false";
|
|
|
13180 |
|
|
|
13181 |
#設置執行錯誤
|
|
|
13182 |
$result["error"]=$uploadOneFile;
|
|
|
13183 |
|
|
|
13184 |
#回傳結果
|
|
|
13185 |
return $result;
|
|
|
13186 |
|
|
|
13187 |
}#if end
|
|
|
13188 |
|
|
|
13189 |
#放置上傳檔案的表單
|
|
|
13190 |
$conf["table::printColumn"]["tdContent"][]=$uploadOneFile["content"];
|
|
|
13191 |
|
|
|
13192 |
#上傳的按鈕
|
|
|
13193 |
#函式說明:
|
|
|
13194 |
#放置按鈕
|
|
|
13195 |
#回傳結果:
|
|
|
13196 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13197 |
#$result["function"],當前執行的函數.
|
|
|
13198 |
#$result["error"],錯誤訊息陣列.
|
|
|
13199 |
#$result["content"],按鈕語法.
|
|
|
13200 |
#必填參數:
|
|
|
13201 |
$conf["form::button"]["buttonDisplayValue"]=$conf["submitButtonName"];#爲按鈕上顯示的文字。
|
|
|
13202 |
#可省略參數:
|
|
|
13203 |
$conf["form::button"]["buttonStyleName"]=$conf["submitButtonClass"];#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
13204 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
13205 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
13206 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
13207 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
13208 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
13209 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
13210 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
13211 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
13212 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
13213 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
13214 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
13215 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
13216 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
13217 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
13218 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
13219 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
13220 |
#$conf["form::button"]["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
13221 |
#$conf["form::button"]["action"]=$conf["backPage"];#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
13222 |
#$conf["target"]="";#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
13223 |
$conf["form::button"]["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
13224 |
#參考資料:
|
|
|
13225 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
13226 |
$submitButton=form::button($conf["form::button"]);
|
|
|
13227 |
unset($conf["form::button"]);
|
|
|
13228 |
|
|
|
13229 |
#如果回上頁的按鈕建立失敗
|
|
|
13230 |
if($submitButton["status"]=="false"){
|
|
|
13231 |
|
|
|
13232 |
#設置執行失敗
|
|
|
13233 |
$result["status"]="false";
|
|
|
13234 |
|
|
|
13235 |
#設置執行錯誤
|
|
|
13236 |
$result["error"]=$submitButton;
|
|
|
13237 |
|
|
|
13238 |
#回傳結果
|
|
|
13239 |
return $result;
|
|
|
13240 |
|
|
|
13241 |
}#if end
|
|
|
13242 |
|
|
|
13243 |
#放置上傳的按鈕
|
|
|
13244 |
$conf["table::printColumn"]["tdContent"][]=$submitButton["content"];
|
|
|
13245 |
|
|
|
13246 |
#建立一欄表格
|
|
|
13247 |
#函式說明:
|
|
|
13248 |
#建立欄的元素,以及指定裏面要放什麼內容
|
|
|
13249 |
#回傳的變數:
|
|
|
13250 |
#$result["content"],建立欄元素的語法
|
|
|
13251 |
#$result["status"],"true"代表執行成功;"false"代表執行失敗。
|
|
|
13252 |
#$result["error"],錯誤訊息陣列
|
|
|
13253 |
#必填參數:
|
|
|
13254 |
$conf["table::printColumn"]["trClass"]="__withoutBorder";#列的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
13255 |
$conf["table::printColumn"]["tdClass"]="__withoutBorder";#行的樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
13256 |
#$conf["table::printColumn"]["tdContent"]=array();#列裏面要放的元素是?如果要空一列則可以輸array(" ")
|
|
|
13257 |
#可省略參數:
|
|
|
13258 |
#$conf["table::printColumn"]["formData"],字串,$conf["tdContent"]裡面要放的元素是否含有表單,"true"代表有,"false"代表沒有,預設為"false".
|
|
|
13259 |
$conf["table::printColumn"]["formData"]="true";
|
|
|
13260 |
$conf["table::printColumn"]["tableStartClass"]="__withoutBorder";#列的樣式,預設為"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
13261 |
$conf["table::printColumn"]["tableStart"]="true";#爲是否要表格開始,"true"表示"是",預設為"false".
|
|
|
13262 |
$conf["table::printColumn"]["tableEnd"]="true";#爲是否要表格結束,"true"表示"是",預設為"false".
|
|
|
13263 |
#$conf["formStart"]="true";#是否要有表單的開始,預設為"false".
|
|
|
13264 |
#$conf["formName"]="";#該表單的名稱
|
|
|
13265 |
#$conf["formAction"]="";#表單提交的目的地,若$conf["formStart"]有設置,則該參數也要設置
|
|
|
13266 |
#$conf["formTarget"]="_self";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
13267 |
#$conf["formEnd"]="true";#是否要有表單的結束,預設為"false".
|
|
|
13268 |
#$conf["table::printColumn"]["spaceBlockAferPerElement"]="true";#是否每個欄元素(除了最後一個元素)後面都要空一列。"true"代表要空一列.預設是不空一列.
|
|
|
13269 |
$printColumn=table::printColumn($conf["table::printColumn"]);
|
|
|
13270 |
unset($conf["table::printColumn"]);
|
|
|
13271 |
|
|
|
13272 |
#串接一欄表格
|
|
|
13273 |
$result["content"]=$result["content"].$printColumn["content"];
|
|
|
13274 |
|
|
|
13275 |
#設置執行正常
|
|
|
13276 |
$result["status"]="true";
|
|
|
13277 |
|
|
|
13278 |
#回傳結果
|
|
|
13279 |
return $result;
|
|
|
13280 |
|
|
|
13281 |
}#function uploadOneFileCom end
|
|
|
13282 |
|
|
|
13283 |
/*
|
|
|
13284 |
#函式說明:
|
|
|
13285 |
#檢測接收的檔案是否符合條件
|
|
|
13286 |
#回傳的內容:
|
|
|
13287 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13288 |
#$result["function"],當前執行的函數.
|
|
|
13289 |
#$result["error"],錯誤訊息陣列.
|
|
|
13290 |
#$result["passed"],檢查是否都通過.
|
|
|
13291 |
#$result["fileNameCheck"],若爲"true"則代表檔案名稱正確,"false"檔案名稱不正確.
|
|
|
13292 |
#$result["fileSizeCheck"],若爲"true"則代表檔案大小正確。
|
|
|
13293 |
#$result["fileTypeCheck"],若爲"true"則代表檔案類型正確。
|
|
|
13294 |
#必填參數:
|
|
|
13295 |
$conf["formFileName"]="";#爲該檔案上傳時候的表單名稱
|
|
|
13296 |
#可省略參數:
|
|
|
13297 |
#$conf["uploadedFileName"]="";#爲檔案上傳時的檔案名稱,省略則跳過此部分驗證
|
|
|
13298 |
#$conf["uploadedFileSize"]="";#爲檔案上傳時的檔案大小,省略則跳過此部分驗證
|
|
|
13299 |
#$conf["uploadedFileType"]=array("");#爲檔案上傳時的檔案型別,需爲陣列型別,省略則跳過此部分驗證
|
|
|
13300 |
#參考資料:
|
|
|
13301 |
#無.
|
|
|
13302 |
#備註:
|
|
|
13303 |
#無.
|
|
|
13304 |
*/
|
|
|
13305 |
public static function simpleFileAuthentication(&$conf){
|
|
|
13306 |
|
|
|
13307 |
#初始化要回傳的變數
|
|
|
13308 |
$result=array();
|
|
|
13309 |
|
|
|
13310 |
#設置當前執行的函式
|
|
|
13311 |
$result["function"]=__FUNCTION__;
|
|
|
13312 |
|
|
|
13313 |
#初始化表單開始的語法
|
|
|
13314 |
$result["content"]="";
|
|
|
13315 |
|
|
|
13316 |
#如果 $conf 不為陣列
|
|
|
13317 |
if(gettype($conf)!="array"){
|
|
|
13318 |
|
|
|
13319 |
#設置執行失敗
|
|
|
13320 |
$result["status"]="false";
|
|
|
13321 |
|
|
|
13322 |
#設置執行錯誤訊息
|
|
|
13323 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
13324 |
|
|
|
13325 |
#如果傳入的參數為 null
|
|
|
13326 |
if($conf==null){
|
|
|
13327 |
|
|
|
13328 |
#設置執行錯誤訊息
|
|
|
13329 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
13330 |
|
|
|
13331 |
}#if end
|
|
|
13332 |
|
|
|
13333 |
#回傳結果
|
|
|
13334 |
return $result;
|
|
|
13335 |
|
|
|
13336 |
}#if end
|
|
|
13337 |
|
|
|
13338 |
#檢查參數
|
|
|
13339 |
#函式說明:
|
|
|
13340 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
13341 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13342 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
13343 |
#$result["function"],當前執行的函式名稱.
|
|
|
13344 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
13345 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
13346 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
13347 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
13348 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
13349 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
13350 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
13351 |
#必填參數:
|
|
|
13352 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
13353 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
13354 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
13355 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName");
|
|
|
13356 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
13357 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
13358 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
13359 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
13360 |
#可省略參數:
|
|
|
13361 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
13362 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
13363 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
13364 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("uploadedFileName","uploadedFileSize","uploadedFileType");
|
|
|
13365 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
13366 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");
|
|
|
13367 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
13368 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null);
|
|
|
13369 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
13370 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
13371 |
#參考資料:
|
|
|
13372 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
13373 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
13374 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
13375 |
|
|
|
13376 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
13377 |
if($checkArguments["status"]=="false"){
|
|
|
13378 |
|
|
|
13379 |
#設置錯誤識別
|
|
|
13380 |
$result["status"]="false";
|
|
|
13381 |
|
|
|
13382 |
#設置錯誤訊息
|
|
|
13383 |
$result["error"]=$checkArguments;
|
|
|
13384 |
|
|
|
13385 |
#回傳結果
|
|
|
13386 |
return $result;
|
|
|
13387 |
|
|
|
13388 |
}#if end
|
|
|
13389 |
|
|
|
13390 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
13391 |
if($checkArguments["passed"]=="false"){
|
|
|
13392 |
|
|
|
13393 |
#設置錯誤識別
|
|
|
13394 |
$result["status"]="false";
|
|
|
13395 |
|
|
|
13396 |
#設置錯誤訊息
|
|
|
13397 |
$result["error"]=$checkArguments;
|
|
|
13398 |
|
|
|
13399 |
#回傳結果
|
|
|
13400 |
return $result;
|
|
|
13401 |
|
|
|
13402 |
}#if end
|
|
|
13403 |
|
|
|
13404 |
#預設為檢查通過
|
|
|
13405 |
$result["passed"]="true";
|
|
|
13406 |
|
|
|
13407 |
#檢查上傳的檔案表單名稱是否正確
|
|
|
13408 |
if(!isset($_FILES[$conf["formFileName"]])){
|
|
|
13409 |
|
|
|
13410 |
#設置錯誤識別
|
|
|
13411 |
$result["status"]="false";
|
|
|
13412 |
|
|
|
13413 |
#設置錯誤訊息
|
|
|
13414 |
$result["error"][]="未接收到名為 ".$conf["formFileName"]." 的表單變數";
|
|
|
13415 |
|
|
|
13416 |
#回傳結果
|
|
|
13417 |
return $result;
|
|
|
13418 |
|
|
|
13419 |
}#if end
|
|
|
13420 |
|
|
|
13421 |
#如果$conf["uploadedFileName"]有設定
|
|
|
13422 |
if(isset($conf["uploadedFileName"])){
|
|
|
13423 |
|
|
|
13424 |
#如果 $_FILES[$conf["formFileName"]]["name"] 有設定
|
|
|
13425 |
if(isset($_FILES[$conf["formFileName"]]["name"])){
|
|
|
13426 |
|
|
|
13427 |
#則驗證檔案名稱
|
|
|
13428 |
if($_FILES[$conf["formFileName"]]["name"]==$conf["uploadedFileName"]){
|
|
|
13429 |
|
|
|
13430 |
#$result["fileNameCheck"]設爲"true"
|
|
|
13431 |
$result["fileNameCheck"]="true";
|
|
|
13432 |
|
|
|
13433 |
}#if end
|
|
|
13434 |
|
|
|
13435 |
#若檔案名稱驗證失敗
|
|
|
13436 |
else{
|
|
|
13437 |
|
|
|
13438 |
#$result["fileNameCheck"]設爲"false"
|
|
|
13439 |
$result["fileNameCheck"]="false";
|
|
|
13440 |
|
|
|
13441 |
#設置驗證失敗
|
|
|
13442 |
$result["passed"]="false";
|
|
|
13443 |
|
|
|
13444 |
}#if end
|
|
|
13445 |
|
|
|
13446 |
}#if end
|
|
|
13447 |
|
|
|
13448 |
}#if end
|
|
|
13449 |
|
|
|
13450 |
#如果$conf["uploadedFileSize"]有設定
|
|
|
13451 |
if(isset($conf["uploadedFileSize"])) {
|
|
|
13452 |
|
|
|
13453 |
#如果 $_FILES[$conf["formFileName"]]["name"] 有設定
|
|
|
13454 |
if(isset($_FILES[$conf["formFileName"]]["name"])){
|
|
|
13455 |
|
|
|
13456 |
#則驗證檔案大小
|
|
|
13457 |
if($_FILES[$conf["formFileName"]]["size"]==$conf["uploadedFileSize"]){
|
|
|
13458 |
|
|
|
13459 |
#$result["fileSizeCheck"]設爲"true"
|
|
|
13460 |
$result["fileSizeCheck"]="true";
|
|
|
13461 |
|
|
|
13462 |
}#if end
|
|
|
13463 |
|
|
|
13464 |
#反之檔案大小不正確
|
|
|
13465 |
else{
|
|
|
13466 |
|
|
|
13467 |
#$result["fileSizeCheck"]設爲"false"
|
|
|
13468 |
$result["fileSizeCheck"]="false";
|
|
|
13469 |
|
|
|
13470 |
#設置驗證失敗
|
|
|
13471 |
$result["passed"]="false";
|
|
|
13472 |
|
|
|
13473 |
}#else end
|
|
|
13474 |
|
|
|
13475 |
}#if end
|
|
|
13476 |
|
|
|
13477 |
}#if end
|
|
|
13478 |
|
|
|
13479 |
#如果有設定$conf["uploadedFileType"]則檢查檔案形態是否符合規定
|
|
|
13480 |
if(isset($conf["uploadedFileType"])){
|
|
|
13481 |
|
|
|
13482 |
#如果 $_FILES[$conf["formFileName"]]["name"] 有設定
|
|
|
13483 |
if(isset($_FILES[$conf["formFileName"]]["name"])){
|
|
|
13484 |
|
|
|
13485 |
#取得可以通過驗證的檔案類型數量
|
|
|
13486 |
$fileTypeCount=count($conf["uploadedFileType"]);
|
|
|
13487 |
|
|
|
13488 |
#檔案類型只要是以下其中一種即可
|
|
|
13489 |
for($i=0;$i<$fileTypeCount;$i++){
|
|
|
13490 |
|
|
|
13491 |
#中間的幾種,若有符合的
|
|
|
13492 |
if($_FILES[$conf["formFileName"]]['type']==$conf["uploadedFileType"][$i]){
|
|
|
13493 |
|
|
|
13494 |
#符合檔案形態則設爲"true"
|
|
|
13495 |
$result["fileTypeCheck"]="true";
|
|
|
13496 |
|
|
|
13497 |
#挑出迴圈
|
|
|
13498 |
break;
|
|
|
13499 |
|
|
|
13500 |
}#if end
|
|
|
13501 |
|
|
|
13502 |
#反之代表
|
|
|
13503 |
else{
|
|
|
13504 |
|
|
|
13505 |
#不符合檔案形態則設爲"false"
|
|
|
13506 |
$result["fileTypeCheck"]="false";
|
|
|
13507 |
|
|
|
13508 |
#設置驗證失敗
|
|
|
13509 |
$result["passed"]="false";
|
|
|
13510 |
|
|
|
13511 |
}#else end
|
|
|
13512 |
|
|
|
13513 |
}#for end
|
|
|
13514 |
|
|
|
13515 |
}#if end
|
|
|
13516 |
|
|
|
13517 |
}#if end
|
|
|
13518 |
|
|
|
13519 |
#如果 $result["status"] 沒有設置
|
|
|
13520 |
if(!isset($result["status"])){
|
|
|
13521 |
|
|
|
13522 |
#代表執行到這邊代表執行正常
|
|
|
13523 |
$result["status"]="true";
|
|
|
13524 |
|
|
|
13525 |
}#if end
|
|
|
13526 |
|
|
|
13527 |
#回傳結果
|
|
|
13528 |
return $result;
|
|
|
13529 |
|
|
|
13530 |
}#function simpleFileAuthentication end
|
|
|
13531 |
|
|
|
13532 |
/*
|
|
|
13533 |
#函式說明:
|
|
|
13534 |
#處理一個已上傳的檔案,用作驗證
|
|
|
13535 |
#回傳結果:
|
|
|
13536 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13537 |
#$result["function"],當前執行的函數.
|
|
|
13538 |
#$result["error"],錯誤訊息陣列.
|
|
|
13539 |
#$result["passed"],驗證成功為"true"失敗則為false".
|
|
|
13540 |
#$result["fileNameCheck"],若爲"true"則代表檔案名稱正確,"false"檔案名稱不正確.
|
|
|
13541 |
#$result["fileSizeCheck"],若爲"true"則代表檔案大小正確。
|
|
|
13542 |
#$result["fileTypeCheck"],若爲"true"則代表檔案類型正確。
|
|
|
13543 |
#必填參數:
|
|
|
13544 |
$conf["formFileName"]="";#該上傳檔案的表單名稱
|
|
|
13545 |
$conf["uploadFileName"]="";#如果上傳的檔案名稱等於 $conf["uploadFileName"] 則通過第一階段驗證
|
|
|
13546 |
$conf["uploadFileSize"]="";#如果上傳的檔案大小等於 $conf["uploadFileSize"] 則通過第二階段驗證
|
|
|
13547 |
$conf["uploadedFileType"]="";#如果上傳的檔案類型等於 $conf["uploadedFileType"] 則通過第三階段驗證
|
|
|
13548 |
$conf["password"]="";#供驗證用的內容。
|
|
|
13549 |
#用戶段會取得的變數內容:
|
|
|
13550 |
#$_SESSION["password"],用來做檢查,是否通過認證的session變數,若php設定檔沒有自動啓用session的話,此行前面必須要有 session_start();
|
|
|
13551 |
#可省略參數:
|
|
|
13552 |
#$conf["passAction"]="";#如果檔案驗證成功,轉址到?沒設定則不轉址
|
|
|
13553 |
#$conf["failedAction"]="";#如果檔案驗正不通過則,轉址到?沒設定則不轉址
|
|
|
13554 |
#參考資料:
|
|
|
13555 |
#無.
|
|
|
13556 |
#備註:
|
|
|
13557 |
#無.
|
|
|
13558 |
*/
|
|
|
13559 |
public static function responseOneFileForAuthentication($conf){
|
|
|
13560 |
|
|
|
13561 |
#初始化要回傳的變數
|
|
|
13562 |
$result=array();
|
|
|
13563 |
|
|
|
13564 |
#設置當前執行的函式
|
|
|
13565 |
$result["function"]=__FUNCTION__;
|
|
|
13566 |
|
|
|
13567 |
#初始化表單開始的語法
|
|
|
13568 |
$result["content"]="";
|
|
|
13569 |
|
|
|
13570 |
#如果 $conf 不為陣列
|
|
|
13571 |
if(gettype($conf)!="array"){
|
|
|
13572 |
|
|
|
13573 |
#設置執行失敗
|
|
|
13574 |
$result["status"]="false";
|
|
|
13575 |
|
|
|
13576 |
#設置執行錯誤訊息
|
|
|
13577 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
13578 |
|
|
|
13579 |
#如果傳入的參數為 null
|
|
|
13580 |
if($conf==null){
|
|
|
13581 |
|
|
|
13582 |
#設置執行錯誤訊息
|
|
|
13583 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
13584 |
|
|
|
13585 |
}#if end
|
|
|
13586 |
|
|
|
13587 |
#回傳結果
|
|
|
13588 |
return $result;
|
|
|
13589 |
|
|
|
13590 |
}#if end
|
|
|
13591 |
|
|
|
13592 |
#檢查參數
|
|
|
13593 |
#函式說明:
|
|
|
13594 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
13595 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13596 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
13597 |
#$result["function"],當前執行的函式名稱.
|
|
|
13598 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
13599 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
13600 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
13601 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
13602 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
13603 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
13604 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
13605 |
#必填參數:
|
|
|
13606 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
13607 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
13608 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
13609 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName","uploadedFileName","uploadedFileSize","uploadedFileType");
|
|
|
13610 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
13611 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","array");
|
|
|
13612 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
13613 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
13614 |
#可省略參數:
|
|
|
13615 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
13616 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
13617 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
13618 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("passAction","failedAction");
|
|
|
13619 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
13620 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
13621 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
13622 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null);
|
|
|
13623 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
13624 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
13625 |
#參考資料:
|
|
|
13626 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
13627 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
13628 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
13629 |
|
|
|
13630 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
13631 |
if($checkArguments["status"]=="false"){
|
|
|
13632 |
|
|
|
13633 |
#設置錯誤識別
|
|
|
13634 |
$result["status"]="false";
|
|
|
13635 |
|
|
|
13636 |
#設置錯誤訊息
|
|
|
13637 |
$result["error"]=$checkArguments;
|
|
|
13638 |
|
|
|
13639 |
#回傳結果
|
|
|
13640 |
return $result;
|
|
|
13641 |
|
|
|
13642 |
}#if end
|
|
|
13643 |
|
|
|
13644 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
13645 |
if($checkArguments["passed"]=="false"){
|
|
|
13646 |
|
|
|
13647 |
#設置錯誤識別
|
|
|
13648 |
$result["status"]="false";
|
|
|
13649 |
|
|
|
13650 |
#設置錯誤訊息
|
|
|
13651 |
$result["error"]=$checkArguments;
|
|
|
13652 |
|
|
|
13653 |
#回傳結果
|
|
|
13654 |
return $result;
|
|
|
13655 |
|
|
|
13656 |
}#if end
|
|
|
13657 |
|
|
|
13658 |
#取得驗證的結果
|
|
|
13659 |
#函式說明:
|
|
|
13660 |
#檢測接收的檔案是否符合條件
|
|
|
13661 |
#回傳的內容:
|
|
|
13662 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13663 |
#$result["function"],當前執行的函數.
|
|
|
13664 |
#$result["error"],錯誤訊息陣列.
|
|
|
13665 |
#$result["passed"],檢查是否都通過.
|
|
|
13666 |
#$result["fileNameCheck"],若爲"true"則代表檔案名稱正確,"false"檔案名稱不正確.
|
|
|
13667 |
#$result["fileSizeCheck"],若爲"true"則代表檔案大小正確。
|
|
|
13668 |
#$result["fileTypeCheck"],若爲"true"則代表檔案類型正確。
|
|
|
13669 |
#必填參數:
|
|
|
13670 |
$conf["form::simpleFileAuthentication"]["formFileName"]=$conf["formFileName"];#爲該檔案上傳時候的表單名稱
|
|
|
13671 |
#可省略參數:
|
|
|
13672 |
$conf["form::simpleFileAuthentication"]["uploadedFileName"]=$conf["uploadFileName"];#爲檔案上傳時的檔案名稱,省略則跳過此部分驗證
|
|
|
13673 |
$conf["form::simpleFileAuthentication"]["uploadedFileSize"]=$conf["uploadedFileSize"];#爲檔案上傳時的檔案大小,省略則跳過此部分驗證
|
|
|
13674 |
$conf["form::simpleFileAuthentication"]["uploadedFileType"]=$conf["uploadedFileType"];#爲檔案上傳時的檔案型別,需爲陣列型別,省略則跳過此部分驗證
|
|
|
13675 |
$simpleFileAuthentication=form::simpleFileAuthentication($conf["form::simpleFileAuthentication"]);
|
|
|
13676 |
unset($conf["form::simpleFileAuthentication"]);
|
|
|
13677 |
|
|
|
13678 |
#如果驗證出錯
|
|
|
13679 |
if($simpleFileAuthentication["status"]=="false"){
|
|
|
13680 |
|
|
|
13681 |
#設置錯誤識別
|
|
|
13682 |
$result["status"]="false";
|
|
|
13683 |
|
|
|
13684 |
#設置錯誤訊息
|
|
|
13685 |
$result["error"]=$simpleFileAuthentication;
|
|
|
13686 |
|
|
|
13687 |
#回傳結果
|
|
|
13688 |
return $result;
|
|
|
13689 |
|
|
|
13690 |
}#if end
|
|
|
13691 |
|
|
|
13692 |
#如果驗證不通過
|
|
|
13693 |
if($simpleFileAuthentication["passed"]=="false"){
|
|
|
13694 |
|
|
|
13695 |
#設置執行正常
|
|
|
13696 |
$result["status"]="true";
|
|
|
13697 |
|
|
|
13698 |
#設置驗證不通過
|
|
|
13699 |
$result["passed"]="false";
|
|
|
13700 |
|
|
|
13701 |
#設置檢查結果資訊
|
|
|
13702 |
$result["fileNameCheck"]=$simpleFileAuthentication["fileNameCheck"];
|
|
|
13703 |
$result["fileSizeCheck"]=$simpleFileAuthentication["fileNameCheck"];
|
|
|
13704 |
$result["fileTypeCheck"]=$simpleFileAuthentication["fileNameCheck"];
|
|
|
13705 |
|
|
|
13706 |
#如果 $conf["failedAction"] 有設定
|
|
|
13707 |
if(isset($conf["failedAction"])){
|
|
|
13708 |
|
|
|
13709 |
#轉址到 $conf["failedAction"]
|
|
|
13710 |
$conf["header"]["headerLocation"]["headerLocation"]=$conf["failedAction"];
|
|
|
13711 |
header::redirectionNow($conf["header"]["headerLocation"]);
|
|
|
13712 |
unset($conf["header"]["headerLocation"]);
|
|
|
13713 |
|
|
|
13714 |
}#if end
|
|
|
13715 |
|
|
|
13716 |
#回傳結果
|
|
|
13717 |
return $result;
|
|
|
13718 |
|
|
|
13719 |
}#if end
|
|
|
13720 |
|
|
|
13721 |
#如果 $authenticalResult["passed"] 等於 "true"
|
|
|
13722 |
if($authenticalResult["passed"]=="true"){
|
|
|
13723 |
|
|
|
13724 |
#給予通行碼
|
|
|
13725 |
$_SESSION["password"]=$conf["password"];
|
|
|
13726 |
|
|
|
13727 |
#如果 $conf["passAction"] 有設定
|
|
|
13728 |
if(isset($conf["passAction"])){
|
|
|
13729 |
|
|
|
13730 |
#轉址到 $conf["passAction"]
|
|
|
13731 |
$conf["header"]["headerLocation"]["headerLocation"]=$conf["passAction"];
|
|
|
13732 |
header::redirectionNow($conf["header"]["headerLocation"]);
|
|
|
13733 |
unset($conf["header"]["headerLocation"]);
|
|
|
13734 |
|
|
|
13735 |
}#if end
|
|
|
13736 |
|
|
|
13737 |
#設置驗證通過
|
|
|
13738 |
$result["passed"]="true";
|
|
|
13739 |
|
|
|
13740 |
}#if end
|
|
|
13741 |
|
|
|
13742 |
#設置執行正常
|
|
|
13743 |
$result["status"]="true";
|
|
|
13744 |
|
|
|
13745 |
#回傳結果
|
|
|
13746 |
return $result;
|
|
|
13747 |
|
|
|
13748 |
}#function responseOneFileForAuthentication end
|
|
|
13749 |
|
|
|
13750 |
/*
|
|
|
13751 |
#函式說明:
|
|
|
13752 |
#處理上傳到暫存目錄的檔案,可以移動到指定的位置,並指定檔案的名稱。並且可以指定刪除舊有的檔案,然後將新檔案的相對位置寫入到資料庫裏面。
|
|
|
13753 |
#回傳的變數:
|
|
|
13754 |
#$result["status"],整體上傳有無成功。"true"代表完整成功 "false"代表有過程有錯誤
|
|
|
13755 |
#$result["error"],錯誤訊息陣列,$result["error"][0] 為"沒有接收到上傳的檔案",則代表沒有上傳檔案.
|
|
|
13756 |
#$result["warning"],警告訊息陣列
|
|
|
13757 |
#$result["ServerFileName"],檔案名稱
|
|
|
13758 |
#$result["ServerFileType"],檔案類型
|
|
|
13759 |
#$result["ServerFileSize"],檔案大小
|
|
|
13760 |
#$result["fileRelativePosition"],檔案的相對位置,包含檔案名稱與附檔名。
|
|
|
13761 |
#必填參數:
|
|
|
13762 |
#$conf["formFileName"],字串,為上傳檔案時表單傳送時的名稱
|
|
|
13763 |
$conf["formFileName"]="";
|
|
|
13764 |
#$conf["fileArgu"],字串,__FILE__的內容
|
|
|
13765 |
$conf["fileArgu"]=__FILE__;
|
|
|
13766 |
#可省略參數:
|
|
|
13767 |
#$conf["uploadDirUserDefine"],字串,為存放上傳檔案的目錄,如果沒設定則會自行建立依照系統時間的年月日十分秒來替資料夾命名,並將上傳的檔案存在裏面。
|
|
|
13768 |
#$conf["uploadDirUserDefine"]="";
|
|
|
13769 |
#$conf["ServerFilenameUserDefine"],字串,為存放在伺服器上的檔案名稱,如果沒設定則依照台灣時間的年月日時分秒命名
|
|
|
13770 |
#$conf["ServerFilenameUserDefine"]="";
|
|
|
13771 |
#$conf["NoFileExtension"],字串,若為 "true" 則表 指定了檔案名稱後,不用再加上檔案型的副檔名,預設為"false".
|
|
|
13772 |
#$conf["NoFileExtension"]="true";
|
|
|
13773 |
#$conf["limitPage"],字串陣列,限制只能從哪些網頁檔案過來。
|
|
|
13774 |
#$conf["limitPage"]=array("");
|
|
|
13775 |
#$conf["taskName"],字串,爲該上傳作業的名稱,若沒設定,則預設爲"上傳作業"。
|
|
|
13776 |
#$conf["taskName"]="";
|
|
|
13777 |
#$conf["eraseOldFile"],字串,如果為"true"的話會移除同名的舊檔案,其值爲檔案的相對位置,預設為"false",不移除同名的檔案,並透過編號保留新的檔案.
|
|
|
13778 |
#$conf["eraseOldFile"]="";
|
|
|
13779 |
#$conf["dbProcess"],字串,如果爲"true",則會進行資料表資料更新的動作,亦即要設定 $conf["updatingMysqlServerAddress"] $conf["updatingMysqlAccount"] $conf["updatingDataBaseName"] $conf["updatingDataTableName"] $conf["updatingConditionDataTableColumnName"] $conf["updatingConditionDataTableColumnValue"] $conf["updatingTargetDataTableColumnName"] $conf["updatingTargetDataTableColumnValue"] 的內容,預設為"false".
|
|
|
13780 |
#$conf["dbProcess"]="true";
|
|
|
13781 |
#$conf["updatingMysqlServerAddress"],字串,資料庫位於網路上的哪個位置.
|
|
|
13782 |
#$conf["updatingMysqlServerAddress"]=$dbAddress;
|
|
|
13783 |
#$conf["updatingMysqlAccount"],字串,連線時要使用的帳號,省略時代表不用密碼進行連線.
|
|
|
13784 |
#$conf["updatingMysqlAccount"]=$dbAccount;
|
|
|
13785 |
#$conf["updatingMysqlPassword"],字串,連線時要使用的密碼.
|
|
|
13786 |
#$conf["updatingMysqlPassword"]=$dbPassword;
|
|
|
13787 |
#$conf["updatingDataBaseName"],字串,要更新的目標資料所屬資料庫名稱.
|
|
|
13788 |
#$conf["updatingDataBaseName"]=$dbName;
|
|
|
13789 |
#$conf["updatingDataTableName"],字串,要更新的目標資料位於哪個資料表.
|
|
|
13790 |
#$conf["updatingDataTableName"]="";
|
|
|
13791 |
#$conf["updatingConditionDataTableColumnName"],字串陣列,要用哪些欄位來識別要更新哪一筆資料,預設為array("id").
|
|
|
13792 |
#$conf["updatingConditionDataTableColumnName"]=array("id");
|
|
|
13793 |
#$conf["updatingConditionDataTableColumnValue"],字串陣列,該條件欄位內容的數值要爲多少,才是我們要修改的那筆資料。
|
|
|
13794 |
#$conf["updatingConditionDataTableColumnValue"]=array("");
|
|
|
13795 |
#$conf["updatingTargetDataTableColumnName"],字串陣列,要更新的資料欄位有?
|
|
|
13796 |
#$conf["updatingTargetDataTableColumnName"]=array("");
|
|
|
13797 |
#$conf["updatingTargetDataTableColumnValue"],字串陣列,目標資料欄位要改成什麼樣的數值,如果其元素含有"filePosition",則會替換成新檔案的相對位置
|
|
|
13798 |
#$conf["updatingTargetDataTableColumnValue"]=array("");
|
|
|
13799 |
#參考資料:
|
|
|
13800 |
#file_exist()的用法
|
|
|
13801 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
13802 |
#備註:
|
|
|
13803 |
#無.
|
|
|
13804 |
*/
|
|
|
13805 |
public static function processUploadedFile($conf){
|
|
|
13806 |
|
|
|
13807 |
#初始化要回傳的內容
|
|
|
13808 |
$result=array();
|
|
|
13809 |
|
|
|
13810 |
#設置當前執行的函數
|
|
|
13811 |
$result["function"]=__FUNCTION__;
|
|
|
13812 |
|
|
|
13813 |
#如果 $conf 不為陣列
|
|
|
13814 |
if(gettype($conf)!="array"){
|
|
|
13815 |
|
|
|
13816 |
#設置執行失敗
|
|
|
13817 |
$result["status"]="false";
|
|
|
13818 |
|
|
|
13819 |
#設置執行錯誤訊息
|
|
|
13820 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
13821 |
|
|
|
13822 |
#如果傳入的參數為 null
|
|
|
13823 |
if($conf==null){
|
|
|
13824 |
|
|
|
13825 |
#設置執行錯誤訊息
|
|
|
13826 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
13827 |
|
|
|
13828 |
}#if end
|
|
|
13829 |
|
|
|
13830 |
#回傳結果
|
|
|
13831 |
return $result;
|
|
|
13832 |
|
|
|
13833 |
}#if end
|
|
|
13834 |
|
|
|
13835 |
#檢查參數
|
|
|
13836 |
#函式說明:
|
|
|
13837 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
13838 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13839 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
13840 |
#$result["function"],當前執行的函式名稱.
|
|
|
13841 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
13842 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
13843 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
13844 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
13845 |
#必填參數:
|
|
|
13846 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
13847 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
13848 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
13849 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("formFileName","fileArgu");
|
|
|
13850 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
13851 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
13852 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
13853 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
13854 |
#可省略參數:
|
|
|
13855 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
13856 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
13857 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
13858 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("uploadDirUserDefine","ServerFilenameUserDefine","NoFileExtension","limitPage","taskName","eraseOldFile","dbProcess","updatingMysqlServerAddress","updatingMysqlAccount","updatingMysqlPassword","updatingDataBaseName","updatingDataTableName","updatingConditionDataTableColumnName","updatingConditionDataTableColumnValue","updatingTargetDataTableColumnName","updatingTargetDataTableColumnValue");
|
|
|
13859 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
13860 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("string","string","string","array","string","string","string","string","string","string","string","string","array","array","array","array");
|
|
|
13861 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
13862 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"上傳作業","false","false",null,null,null,null,null,array("id"),null,null,null);
|
|
|
13863 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
13864 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
13865 |
|
|
|
13866 |
#如果檢查失敗
|
|
|
13867 |
if($checkResult["status"]=="false"){
|
|
|
13868 |
|
|
|
13869 |
#設置執行不正常
|
|
|
13870 |
$result["status"]="false";
|
|
|
13871 |
|
|
|
13872 |
#程式停止執行
|
|
|
13873 |
$result["error"]=$checkResult;
|
|
|
13874 |
|
|
|
13875 |
#回傳結果
|
|
|
13876 |
return $result;
|
|
|
13877 |
|
|
|
13878 |
}#if end
|
|
|
13879 |
|
|
|
13880 |
#如果檢查不通過
|
|
|
13881 |
if($checkResult["passed"]=="false"){
|
|
|
13882 |
|
|
|
13883 |
#設置執行不正常
|
|
|
13884 |
$result["status"]="false";
|
|
|
13885 |
|
|
|
13886 |
#程式停止執行
|
|
|
13887 |
$result["error"]=$checkResult;
|
|
|
13888 |
|
|
|
13889 |
#回傳結果
|
|
|
13890 |
return $result;
|
|
|
13891 |
|
|
|
13892 |
}#if end
|
|
|
13893 |
|
|
|
13894 |
#過濾 $conf["formFileName"] 避免錯誤
|
|
|
13895 |
#函式說明:
|
|
|
13896 |
#處理字串避免網頁出錯
|
|
|
13897 |
#回傳結果:
|
|
|
13898 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13899 |
#$result["function"],當前執行的函數.
|
|
|
13900 |
#$result["content"],爲處理好的字串.
|
|
|
13901 |
#$result["error"],錯誤訊息陣列.
|
|
|
13902 |
#必填參數:
|
|
|
13903 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$conf["formFileName"];#爲要處理的字串
|
|
|
13904 |
#可省略的參數:
|
|
|
13905 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("<",">","=","//","'","$","%","&","|","/*","*\/","#","\""," ");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
13906 |
#若不設定則預設爲要將這些字串作替換("<",">","=","//","'","$","%","&","|","/*","*\/","#","\"")。
|
|
|
13907 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
13908 |
#$conf["stringProcess::correctCharacter"]["changeTo"]=array("","","","","","","","","","","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
13909 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
13910 |
unset($conf["stringProcess::correctCharacter"]);
|
|
|
13911 |
|
|
|
13912 |
#如果過濾字串失敗
|
|
|
13913 |
if($correctCharacter["status"]=="false"){
|
|
|
13914 |
|
|
|
13915 |
#設置執行失敗
|
|
|
13916 |
$result["status"]="false";
|
|
|
13917 |
|
|
|
13918 |
#設置執行錯誤訊息
|
|
|
13919 |
$result["error"]=$correctCharacter;
|
|
|
13920 |
|
|
|
13921 |
#回傳結果
|
|
|
13922 |
return $result;
|
|
|
13923 |
|
|
|
13924 |
}#if end
|
|
|
13925 |
|
|
|
13926 |
#置換成處理過後的 $conf["formFileName"]
|
|
|
13927 |
$conf["formFileName"]=$correctCharacter["content"];
|
|
|
13928 |
|
|
|
13929 |
#如果檔案的表單變數存在
|
|
|
13930 |
if(isset($_FILES[$conf["formFileName"]])){
|
|
|
13931 |
|
|
|
13932 |
#如果原始檔案名稱爲空的
|
|
|
13933 |
if($_FILES[$conf["formFileName"]]["name"]==""){
|
|
|
13934 |
|
|
|
13935 |
#設置錯誤識別
|
|
|
13936 |
$result["status"]="false";
|
|
|
13937 |
|
|
|
13938 |
#設置錯誤訊息
|
|
|
13939 |
$result["error"][]="沒有接收到上傳的檔案";
|
|
|
13940 |
|
|
|
13941 |
#回傳結果
|
|
|
13942 |
return $result;
|
|
|
13943 |
|
|
|
13944 |
}#if end
|
|
|
13945 |
|
|
|
13946 |
}#if end
|
|
|
13947 |
|
|
|
13948 |
#如果檔案的表單變數不存在
|
|
|
13949 |
else{
|
|
|
13950 |
|
|
|
13951 |
#設置錯誤識別
|
|
|
13952 |
$result["status"]="false";
|
|
|
13953 |
|
|
|
13954 |
#設置錯誤訊息
|
|
|
13955 |
$result["error"][]="沒有接收到上傳的檔案";
|
|
|
13956 |
|
|
|
13957 |
#回傳結果
|
|
|
13958 |
return $result;
|
|
|
13959 |
|
|
|
13960 |
}#else end
|
|
|
13961 |
|
|
|
13962 |
#取得系統時間
|
|
|
13963 |
#函式說明:
|
|
|
13964 |
#回傳西元的目前時間,格式為2010年07月24日15時30分33秒
|
|
|
13965 |
#回傳結果:
|
|
|
13966 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
13967 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
13968 |
#$result["function"],當前執行的函式名稱.
|
|
|
13969 |
#$result["content"],西元的目前時間.
|
|
|
13970 |
#必填參數:
|
|
|
13971 |
$conf["time::getFullDateAndTime"]["timeZone"]="Asia/Taipei";#時區代號,可以設定的時區列表:http://www.php.net/manual/en/timezones.php
|
|
|
13972 |
#ex:"Asia/Taipei"
|
|
|
13973 |
#可省略參數:
|
|
|
13974 |
$conf["time::getFullDateAndTime"]["showSecond"]="true";#若爲"true"則會顯示秒數,預設為"true".
|
|
|
13975 |
#參考資料:
|
|
|
13976 |
#date函數用法=>http://php.net/manual/en/function.date.php.
|
|
|
13977 |
$getFullDateAndTime=time::getFullDateAndTime($conf["time::getFullDateAndTime"]);
|
|
|
13978 |
unset($conf["time::getFullDateAndTime"]);
|
|
|
13979 |
|
|
|
13980 |
#如果取得取得時間失敗
|
|
|
13981 |
if($getFullDateAndTime["status"]=="false"){
|
|
|
13982 |
|
|
|
13983 |
#設置錯誤識別
|
|
|
13984 |
$result["status"]="false";
|
|
|
13985 |
|
|
|
13986 |
#設置錯誤訊息
|
|
|
13987 |
$result["error"]=$getFullDateAndTime;
|
|
|
13988 |
|
|
|
13989 |
#回傳結果
|
|
|
13990 |
return $result;
|
|
|
13991 |
|
|
|
13992 |
}#if end
|
|
|
13993 |
|
|
|
13994 |
#取得格林威治時間+八小時
|
|
|
13995 |
$timeTw=$getFullDateAndTime["content"];
|
|
|
13996 |
|
|
|
13997 |
#如果$conf["uploadDirUserDefine"]有設定
|
|
|
13998 |
if(isset($conf["uploadDirUserDefine"])){
|
|
|
13999 |
|
|
|
14000 |
#則套用存放上傳檔案的目錄
|
|
|
14001 |
$uploadDir=$conf["uploadDirUserDefine"] ;
|
|
|
14002 |
|
|
|
14003 |
}#if end
|
|
|
14004 |
|
|
|
14005 |
#否則存放的資料夾名稱爲臺灣的時間
|
|
|
14006 |
else{
|
|
|
14007 |
|
|
|
14008 |
$uploadDir=$timeTw;
|
|
|
14009 |
|
|
|
14010 |
#建立特定資料夾
|
|
|
14011 |
#函式說明:
|
|
|
14012 |
#建立資料夾
|
|
|
14013 |
#回傳結果:
|
|
|
14014 |
#$result,true爲建立成功,false爲建立失敗
|
|
|
14015 |
#必填參數:
|
|
|
14016 |
$conf["fileAccess"]["createNewFolder"]["dirPositionAndName"]=$uploadDir;#新建的位置與名稱
|
|
|
14017 |
#可省略參數:
|
|
|
14018 |
#$conf["dirPermission"]="";新建資料夾的權限設定,預設爲0777,亦即所有人皆可以讀、寫、存取
|
|
|
14019 |
#參考資料:
|
|
|
14020 |
#http:#php.net/manual/en/function.mkdir.php
|
|
|
14021 |
#範本:
|
|
|
14022 |
# mkdir("/path/to/my/dir", 0700);
|
|
|
14023 |
$createFolder=fileAccess::createNewFolder($conf["fileAccess"]["createNewFolder"]);
|
|
|
14024 |
unset($conf["fileAccess"]["createNewFolder"]);
|
|
|
14025 |
|
|
|
14026 |
#如果 $createFolder 等於 "false"
|
|
|
14027 |
if($createFolder["status"]==="false"){
|
|
|
14028 |
|
|
|
14029 |
#設置錯誤識別
|
|
|
14030 |
$result["status"]="false";
|
|
|
14031 |
|
|
|
14032 |
#設置錯誤訊息
|
|
|
14033 |
$result["error"]=$createFolder;
|
|
|
14034 |
|
|
|
14035 |
#回傳結果
|
|
|
14036 |
return $result;
|
|
|
14037 |
|
|
|
14038 |
}#if end
|
|
|
14039 |
|
|
|
14040 |
}#else end
|
|
|
14041 |
|
|
|
14042 |
#如果$conf["uploadDirUserDefine"]有設定
|
|
|
14043 |
if(isset($conf["ServerFilenameUserDefine"])){
|
|
|
14044 |
|
|
|
14045 |
#給予伺服器檔案的名稱
|
|
|
14046 |
$ServerFilename=$conf["ServerFilenameUserDefine"];
|
|
|
14047 |
|
|
|
14048 |
}#if end
|
|
|
14049 |
|
|
|
14050 |
#否則檔案名稱指定為臺灣時間
|
|
|
14051 |
else{
|
|
|
14052 |
|
|
|
14053 |
$ServerFilename=$timeTw;
|
|
|
14054 |
|
|
|
14055 |
}#else end
|
|
|
14056 |
|
|
|
14057 |
#原始檔案名稱
|
|
|
14058 |
$fileOrginalName=$_FILES[$conf["formFileName"]]["name"];
|
|
|
14059 |
|
|
|
14060 |
#初始化儲存檔案副檔名的變數
|
|
|
14061 |
$FileExtension="";
|
|
|
14062 |
|
|
|
14063 |
#檔案的附檔名爲上傳的檔案名稱最後一個小數點後面的內容。
|
|
|
14064 |
|
|
|
14065 |
#函式說明:
|
|
|
14066 |
#將固定格式的字串分開,並回傳分開的結果。
|
|
|
14067 |
#回傳的參數:
|
|
|
14068 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
14069 |
#$result["error"],錯誤訊息陣列
|
|
|
14070 |
#$result["oriStr"],要分割的原始字串內容
|
|
|
14071 |
#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
|
|
|
14072 |
#$result["dataCounts"],爲總共分成幾段
|
|
|
14073 |
#必填參數:
|
|
|
14074 |
$conf["stringProcess::spiltString"]["stringIn"]=$fileOrginalName;#要處理的字串。
|
|
|
14075 |
$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
|
|
|
14076 |
#備註:
|
|
|
14077 |
#建議新增如果透過" "分割後的內容含有""的元素,將其移除,並將後面有內容的元素補上,key也重新排序。
|
|
|
14078 |
$stringProcessedResult=stringProcess::spiltString($conf["stringProcess::spiltString"]);
|
|
|
14079 |
unset($conf["stringProcess::spiltString"]);
|
|
|
14080 |
|
|
|
14081 |
#如果分割字串失敗
|
|
|
14082 |
if($stringProcessedResult["status"]=="false"){
|
|
|
14083 |
|
|
|
14084 |
#設置錯誤識別
|
|
|
14085 |
$result["status"]="false";
|
|
|
14086 |
|
|
|
14087 |
#設置錯誤訊息
|
|
|
14088 |
$result["error"]=$stringProcessedResult;
|
|
|
14089 |
|
|
|
14090 |
#回傳結果
|
|
|
14091 |
return $result;
|
|
|
14092 |
|
|
|
14093 |
}#if end
|
|
|
14094 |
|
|
|
14095 |
#如果分割後的段數只有1段
|
|
|
14096 |
if($stringProcessedResult["dataCounts"]<2){
|
|
|
14097 |
|
|
|
14098 |
#設置警告訊息
|
|
|
14099 |
$result["warning"][]="上傳的檔案沒有副檔名";
|
|
|
14100 |
|
|
|
14101 |
#設置副檔名為"unknow"
|
|
|
14102 |
$FileExtension=".unknow";
|
|
|
14103 |
|
|
|
14104 |
}#if end
|
|
|
14105 |
|
|
|
14106 |
#反之代表有副檔名
|
|
|
14107 |
else{
|
|
|
14108 |
|
|
|
14109 |
#將第一個小數點後的內容視為副檔名
|
|
|
14110 |
|
|
|
14111 |
#檔案名稱分成幾段就執行其減1幾次
|
|
|
14112 |
for($i=1;$i<$stringProcessedResult["dataCounts"];$i++){
|
|
|
14113 |
|
|
|
14114 |
#串接副檔名
|
|
|
14115 |
$FileExtension=$FileExtension.".".$stringProcessedResult["dataArray"][$i];
|
|
|
14116 |
|
|
|
14117 |
}#for end
|
|
|
14118 |
|
|
|
14119 |
}#else end
|
|
|
14120 |
|
|
|
14121 |
#將檔案的類型傳遞到變數
|
|
|
14122 |
$FileType = $_FILES[$conf["formFileName"]]["type"];
|
|
|
14123 |
|
|
|
14124 |
/*
|
|
|
14125 |
#由於隨着瀏覽器不同,其檔案類型的名稱也會不同,所以我們就不從檔案類型去類推其副檔名爲何。
|
|
|
14126 |
|
|
|
14127 |
#取得原始檔案副檔名的陣列,目前僅適用於firefox
|
|
|
14128 |
|
|
|
14129 |
#照片類別
|
|
|
14130 |
if($FileType=="image/png"){
|
|
|
14131 |
|
|
|
14132 |
$FileExtension = "png";
|
|
|
14133 |
|
|
|
14134 |
}
|
|
|
14135 |
|
|
|
14136 |
else if($FileType=="image/jpeg"){
|
|
|
14137 |
|
|
|
14138 |
$FileExtension = "jpg";
|
|
|
14139 |
|
|
|
14140 |
}
|
|
|
14141 |
|
|
|
14142 |
else if($FileType=="image/gif"){
|
|
|
14143 |
|
|
|
14144 |
$FileExtension = "gif";
|
|
|
14145 |
}
|
|
|
14146 |
|
|
|
14147 |
#聲音類別
|
|
|
14148 |
else if($FileType=="audio/x-ms-wma"){
|
|
|
14149 |
|
|
|
14150 |
$FileExtension = "wma";
|
|
|
14151 |
|
|
|
14152 |
}
|
|
|
14153 |
|
|
|
14154 |
else if($FileType=="audio/mpeg"){
|
|
|
14155 |
|
|
|
14156 |
$FileExtension = "mp3";
|
|
|
14157 |
|
|
|
14158 |
}
|
|
|
14159 |
|
|
|
14160 |
else if($FileType=="video/ogg"){
|
|
|
14161 |
|
|
|
14162 |
$FileExtension = "ogg";
|
|
|
14163 |
}
|
|
|
14164 |
|
|
|
14165 |
#影片類別
|
|
|
14166 |
else if($FileType=="video/x-ms-wmv"){
|
|
|
14167 |
|
|
|
14168 |
$FileExtension = "wmv";
|
|
|
14169 |
|
|
|
14170 |
}
|
|
|
14171 |
|
|
|
14172 |
else if($FileType=="video/x-msvideo"){
|
|
|
14173 |
|
|
|
14174 |
$FileExtension = "avi";
|
|
|
14175 |
}
|
|
|
14176 |
|
|
|
14177 |
else if($FileType=="video/ogg"){
|
|
|
14178 |
|
|
|
14179 |
$FileExtension = "ogv";
|
|
|
14180 |
|
|
|
14181 |
}
|
|
|
14182 |
|
|
|
14183 |
else if($FileType=="video/webm"){
|
|
|
14184 |
|
|
|
14185 |
$FileExtension = "webm";
|
|
|
14186 |
|
|
|
14187 |
}
|
|
|
14188 |
|
|
|
14189 |
#純文字類別
|
|
|
14190 |
else if($FileType=="text/plain"){
|
|
|
14191 |
|
|
|
14192 |
$FileExtension = "txt";
|
|
|
14193 |
}
|
|
|
14194 |
|
|
|
14195 |
#壓縮檔類別
|
|
|
14196 |
else if($FileType=="application/x-tar"){
|
|
|
14197 |
|
|
|
14198 |
$FileExtension = "tar";
|
|
|
14199 |
|
|
|
14200 |
}
|
|
|
14201 |
|
|
|
14202 |
else if($FileType=="application/x-7z-compressed"){
|
|
|
14203 |
|
|
|
14204 |
$FileExtension = "7z";
|
|
|
14205 |
|
|
|
14206 |
}
|
|
|
14207 |
|
|
|
14208 |
else if($FileType=="application/zip"){
|
|
|
14209 |
|
|
|
14210 |
$FileExtension = "zip";
|
|
|
14211 |
|
|
|
14212 |
}
|
|
|
14213 |
|
|
|
14214 |
#2元碼檔案
|
|
|
14215 |
else if($FileType=="application/octet-stream"){
|
|
|
14216 |
|
|
|
14217 |
$FileExtension = "exe";
|
|
|
14218 |
|
|
|
14219 |
}
|
|
|
14220 |
|
|
|
14221 |
#如果不是以上的類別
|
|
|
14222 |
else{
|
|
|
14223 |
|
|
|
14224 |
#則賦予 "unknow" 這個副檔名
|
|
|
14225 |
$FileExtension = "unknow";
|
|
|
14226 |
|
|
|
14227 |
}
|
|
|
14228 |
|
|
|
14229 |
*/
|
|
|
14230 |
|
|
|
14231 |
#將原始檔案的大小單位換算成KB
|
|
|
14232 |
$storeFileSizeKb = (($_FILES[$conf["formFileName"]]["size"])/1024);
|
|
|
14233 |
|
|
|
14234 |
#將原始檔案的大小(KB)小數點全部捨棄,
|
|
|
14235 |
$storeFileSizeKb = round($storeFileSizeKb,0);
|
|
|
14236 |
|
|
|
14237 |
#將上傳檔案的錯誤代碼傳遞到變數 $file_error
|
|
|
14238 |
$FileError = $_FILES[$conf["formFileName"]]["error"];
|
|
|
14239 |
|
|
|
14240 |
#如果上傳的檔案是空的
|
|
|
14241 |
if(!isset($_FILES[$conf["formFileName"]]['tmp_name'])){
|
|
|
14242 |
|
|
|
14243 |
#設置錯誤識別
|
|
|
14244 |
$result["status"]="false";
|
|
|
14245 |
|
|
|
14246 |
#設置錯誤訊息
|
|
|
14247 |
$result["error"][]="找不到暫存的已上傳檔案";
|
|
|
14248 |
|
|
|
14249 |
#回傳結果
|
|
|
14250 |
return $result;
|
|
|
14251 |
|
|
|
14252 |
}#if end
|
|
|
14253 |
|
|
|
14254 |
#如果 $NoFileExtension 有設定
|
|
|
14255 |
if(isset($conf["NoFileExtension"])){
|
|
|
14256 |
|
|
|
14257 |
#如果 $NoFileExtension 等於 true,
|
|
|
14258 |
if($conf["NoFileExtension"]=="true"){
|
|
|
14259 |
|
|
|
14260 |
#則副檔名爲""。
|
|
|
14261 |
$FileExtension="";
|
|
|
14262 |
|
|
|
14263 |
}#if end
|
|
|
14264 |
|
|
|
14265 |
}#if end
|
|
|
14266 |
|
|
|
14267 |
#檢查目標資料夾是否存在
|
|
|
14268 |
#函式說明:檢查多個檔案與資料夾是否存在.
|
|
|
14269 |
#回傳的結果:
|
|
|
14270 |
#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
|
|
|
14271 |
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
|
|
|
14272 |
#必填參數:
|
|
|
14273 |
$conf["fileAccess"]["checkMutiFileExist"]["fileArray"]=array($uploadDir);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
|
|
|
14274 |
$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
|
|
|
14275 |
#參考資料來源:
|
|
|
14276 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
14277 |
#http://php.net/manual/en/control-structures.foreach.php
|
|
|
14278 |
$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
|
|
|
14279 |
unset($conf["fileAccess"]["checkMutiFileExist"]);
|
|
|
14280 |
|
|
|
14281 |
#如果檢查失敗
|
|
|
14282 |
if($checkResult["status"]=="false"){
|
|
|
14283 |
|
|
|
14284 |
#設置錯誤識別
|
|
|
14285 |
$result["status"]="false";
|
|
|
14286 |
|
|
|
14287 |
#設置錯誤訊息
|
|
|
14288 |
$result["error"]=$checkResult;
|
|
|
14289 |
|
|
|
14290 |
#回傳結果
|
|
|
14291 |
return $result;
|
|
|
14292 |
|
|
|
14293 |
}#if end
|
|
|
14294 |
|
|
|
14295 |
#如果 目標資料夾 不存在
|
|
|
14296 |
if($checkResult["varExist"][0]=="false"){
|
|
|
14297 |
|
|
|
14298 |
#建立特定資料夾
|
|
|
14299 |
#函式說明:
|
|
|
14300 |
#建立資料夾
|
|
|
14301 |
#回傳結果:
|
|
|
14302 |
#$result,true爲建立成功,false爲建立失敗
|
|
|
14303 |
#必填參數:
|
|
|
14304 |
$conf["fileAccess"]["createNewFolder"]["dirPositionAndName"]=$uploadDir;#新建的位置與名稱
|
|
|
14305 |
#可省略參數:
|
|
|
14306 |
#$conf["dirPermission"]="";新建資料夾的權限設定,預設爲0777,亦即所有人皆可以讀、寫、存取
|
|
|
14307 |
#參考資料:
|
|
|
14308 |
#http:#php.net/manual/en/function.mkdir.php
|
|
|
14309 |
#範本:
|
|
|
14310 |
# mkdir("/path/to/my/dir", 0700);
|
|
|
14311 |
$createFolder=fileAccess::createNewFolder($conf["fileAccess"]["createNewFolder"]);
|
|
|
14312 |
unset($conf["fileAccess"]["createNewFolder"]);
|
|
|
14313 |
|
|
|
14314 |
#如果 $createFolder 等於 "false"
|
|
|
14315 |
if($createFolder=="false"){
|
|
|
14316 |
|
|
|
14317 |
#設置錯誤識別
|
|
|
14318 |
$result["status"]="false";
|
|
|
14319 |
|
|
|
14320 |
#設置錯誤訊息
|
|
|
14321 |
$result["error"][]="建立資料夾失敗";
|
|
|
14322 |
|
|
|
14323 |
#回傳結果
|
|
|
14324 |
return $result;
|
|
|
14325 |
|
|
|
14326 |
}#if end
|
|
|
14327 |
|
|
|
14328 |
}#if end
|
|
|
14329 |
|
|
|
14330 |
#如果要移除同名的檔案
|
|
|
14331 |
if($conf["eraseOldFile"]=="true"){
|
|
|
14332 |
|
|
|
14333 |
#檢查指定的上傳檔案是否已經存在
|
|
|
14334 |
#如果有同名的檔案存在
|
|
|
14335 |
#函式說明:檢查多個檔案與資料夾是否存在.
|
|
|
14336 |
#回傳的結果:
|
|
|
14337 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
14338 |
#$result["error"],錯誤訊息陣列.
|
|
|
14339 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
14340 |
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
|
|
|
14341 |
#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
|
|
|
14342 |
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
|
|
|
14343 |
#必填參數:
|
|
|
14344 |
$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($uploadDir."/".$ServerFilename.$FileExtension);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
|
|
|
14345 |
$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
|
|
|
14346 |
#參考資料來源:
|
|
|
14347 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
14348 |
#http://php.net/manual/en/control-structures.foreach.php
|
|
|
14349 |
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14350 |
unset($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14351 |
|
|
|
14352 |
#如果檢查失敗
|
|
|
14353 |
if($checkMultiFileExist["status"]=="false"){
|
|
|
14354 |
|
|
|
14355 |
#設置錯誤識別
|
|
|
14356 |
$result["status"]="false";
|
|
|
14357 |
|
|
|
14358 |
#設置錯誤訊息
|
|
|
14359 |
$result["error"]=$checkMultiFileExist;
|
|
|
14360 |
|
|
|
14361 |
#回傳結果
|
|
|
14362 |
return $result;
|
|
|
14363 |
|
|
|
14364 |
}#if end
|
|
|
14365 |
|
|
|
14366 |
#如果指定的上傳檔案名稱已經存在
|
|
|
14367 |
if($checkMultiFileExist["varExist"][0]=="true"){
|
|
|
14368 |
|
|
|
14369 |
#移除舊的同名檔案
|
|
|
14370 |
#函式說明:
|
|
|
14371 |
#移除檔案
|
|
|
14372 |
#回傳結果:
|
|
|
14373 |
#$result["status"],"true"代表移除成功,"false"代表移除失敗.
|
|
|
14374 |
#$result["error"],錯誤訊息陣列
|
|
|
14375 |
#$result["warning"],警告訊息陣列
|
|
|
14376 |
#$result["function"],當前執行的函數名稱
|
|
|
14377 |
#必填參數:
|
|
|
14378 |
$conf["form::delFile"]["fileAddress"]=$uploadDir."/".$ServerFilename.$FileExtension;#要移除檔案的位置
|
|
|
14379 |
#可省略參數:
|
|
|
14380 |
#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
14381 |
#$conf["commentsArray"]=array("");
|
|
|
14382 |
$delFile=fileAccess::delFile($conf["form::delFile"]);
|
|
|
14383 |
unset($conf["form::delFile"]);
|
|
|
14384 |
|
|
|
14385 |
#如果移除檔案失敗
|
|
|
14386 |
if($delFile["status"]=="false"){
|
|
|
14387 |
|
|
|
14388 |
#設置錯誤識別
|
|
|
14389 |
$result["status"]="false";
|
|
|
14390 |
|
|
|
14391 |
#設置錯誤訊息
|
|
|
14392 |
$result["error"]=$delFile;
|
|
|
14393 |
|
|
|
14394 |
#回傳結果
|
|
|
14395 |
return $result;
|
|
|
14396 |
|
|
|
14397 |
}#if end
|
|
|
14398 |
|
|
|
14399 |
}#if end
|
|
|
14400 |
|
|
|
14401 |
}#if end
|
|
|
14402 |
|
|
|
14403 |
#反之沒有要移除同名的既有檔案
|
|
|
14404 |
else{
|
|
|
14405 |
|
|
|
14406 |
#檢查是否有同名的檔案
|
|
|
14407 |
#檢查加上編號的上傳檔案名稱是否已經存在
|
|
|
14408 |
#檢查指定的上傳檔案是否已經存在
|
|
|
14409 |
#如果有同名的檔案存在
|
|
|
14410 |
#函式說明:檢查多個檔案與資料夾是否存在.
|
|
|
14411 |
#回傳的結果:
|
|
|
14412 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
14413 |
#$result["error"],錯誤訊息陣列.
|
|
|
14414 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
14415 |
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
|
|
|
14416 |
#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
|
|
|
14417 |
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
|
|
|
14418 |
#必填參數:
|
|
|
14419 |
$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($uploadDir."/".$ServerFilename.$FileExtension);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
|
|
|
14420 |
$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
|
|
|
14421 |
#參考資料來源:
|
|
|
14422 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
14423 |
#http://php.net/manual/en/control-structures.foreach.php
|
|
|
14424 |
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14425 |
unset($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14426 |
|
|
|
14427 |
#如果檢查失敗
|
|
|
14428 |
if($checkMultiFileExist["status"]=="false"){
|
|
|
14429 |
|
|
|
14430 |
#設置錯誤識別
|
|
|
14431 |
$result["status"]="false";
|
|
|
14432 |
|
|
|
14433 |
#設置錯誤訊息
|
|
|
14434 |
$result["error"]=$checkMultiFileExist;
|
|
|
14435 |
|
|
|
14436 |
#回傳結果
|
|
|
14437 |
return $result;
|
|
|
14438 |
|
|
|
14439 |
}#if end
|
|
|
14440 |
|
|
|
14441 |
#如果指定的上傳檔案名稱存在
|
|
|
14442 |
if($checkMultiFileExist["varExist"][0]=="true"){
|
|
|
14443 |
|
|
|
14444 |
#無窮迴圈
|
|
|
14445 |
for($i=1;$i>0;$i++){
|
|
|
14446 |
|
|
|
14447 |
#將上傳檔案的名稱加上編號
|
|
|
14448 |
$ServerFilename=$ServerFilename."(".$i.")";
|
|
|
14449 |
|
|
|
14450 |
#檢查加上編號的上傳檔案名稱是否已經存在
|
|
|
14451 |
#檢查指定的上傳檔案是否已經存在
|
|
|
14452 |
#如果有同名的檔案存在
|
|
|
14453 |
#函式說明:檢查多個檔案與資料夾是否存在.
|
|
|
14454 |
#回傳的結果:
|
|
|
14455 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
14456 |
#$result["error"],錯誤訊息陣列.
|
|
|
14457 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
14458 |
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
|
|
|
14459 |
#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
|
|
|
14460 |
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
|
|
|
14461 |
#必填參數:
|
|
|
14462 |
$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($uploadDir."/".$ServerFilename.$FileExtension);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
|
|
|
14463 |
$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
|
|
|
14464 |
#參考資料來源:
|
|
|
14465 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
14466 |
#http://php.net/manual/en/control-structures.foreach.php
|
|
|
14467 |
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14468 |
unset($conf["fileAccess::checkMultiFileExist"]);
|
|
|
14469 |
|
|
|
14470 |
#如果檢查失敗
|
|
|
14471 |
if($checkMultiFileExist["status"]=="false"){
|
|
|
14472 |
|
|
|
14473 |
#設置錯誤識別
|
|
|
14474 |
$result["status"]="false";
|
|
|
14475 |
|
|
|
14476 |
#設置錯誤訊息
|
|
|
14477 |
$result["error"]=$checkMultiFileExist;
|
|
|
14478 |
|
|
|
14479 |
#回傳結果
|
|
|
14480 |
return $result;
|
|
|
14481 |
|
|
|
14482 |
}#if end
|
|
|
14483 |
|
|
|
14484 |
#如果指定的上傳檔案名稱不存在
|
|
|
14485 |
if($checkMultiFileExist["varExist"][0]=="false"){
|
|
|
14486 |
|
|
|
14487 |
#跳出迴圈
|
|
|
14488 |
break;
|
|
|
14489 |
|
|
|
14490 |
}#if end
|
|
|
14491 |
|
|
|
14492 |
}#for end
|
|
|
14493 |
|
|
|
14494 |
}#if end
|
|
|
14495 |
|
|
|
14496 |
}#else end
|
|
|
14497 |
|
|
|
14498 |
#移動暫存檔案到指定的位置
|
|
|
14499 |
if(move_uploaded_file($_FILES[$conf["formFileName"]]["tmp_name"],$uploadDir."/".$ServerFilename.$FileExtension)){
|
|
|
14500 |
|
|
|
14501 |
#函式說明:
|
|
|
14502 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
|
|
14503 |
#回傳結果:
|
|
|
14504 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
14505 |
#$result["error"],錯誤訊息陣列.
|
|
|
14506 |
#$result["function"],當前執行的函數名稱.
|
|
|
14507 |
#$result["argu"],使用的參數.
|
|
|
14508 |
#$result["cmd"],執行的指令內容.
|
|
|
14509 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
|
|
14510 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
|
|
14511 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
|
|
14512 |
#$result["running"],是否還在執行.
|
|
|
14513 |
#$result["pid"],pid.
|
|
|
14514 |
#$result["statusCode"],執行結束後的代碼.
|
|
|
14515 |
#$result["escape"],陣列,儲存出新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu").
|
|
|
14516 |
#必填參數:
|
|
|
14517 |
#$conf["command"],字串,要執行的指令.
|
|
|
14518 |
$conf["external::callShell"]["command"]="chmod";
|
|
|
14519 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
14520 |
$conf["external::callShell"]["fileArgu"]=__FILE__;
|
|
|
14521 |
#可省略參數:
|
|
|
14522 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
|
|
14523 |
$conf["external::callShell"]["argu"]=array("0770",$uploadDir);
|
|
|
14524 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
|
|
14525 |
#$conf["arguIsAddr"]=array();
|
|
|
14526 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
|
|
14527 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
|
|
14528 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
|
|
14529 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
|
|
14530 |
#$conf["enablePrintDescription"]="true";
|
|
|
14531 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
|
|
14532 |
#$conf["printDescription"]="";
|
|
|
14533 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
|
|
|
14534 |
$conf["external::callShell"]["escapeshellarg"]="true";
|
|
|
14535 |
#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
|
|
|
14536 |
#$conf["thereIsShellVar"]=array();
|
|
|
14537 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
|
|
14538 |
#$conf["username"]="";
|
|
|
14539 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
|
|
14540 |
#$conf["password"]="";
|
|
|
14541 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
|
|
14542 |
#$conf["useScript"]="";
|
|
|
14543 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
|
|
14544 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
|
|
14545 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
|
|
14546 |
#$conf["inBackGround"]="";
|
|
|
14547 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
|
|
14548 |
#$conf["getErr"]="false";
|
|
|
14549 |
#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
|
|
|
14550 |
#$conf["doNotRun"]="false";
|
|
|
14551 |
#參考資料:
|
|
|
14552 |
#exec=>http://php.net/manual/en/function.exec.php
|
|
|
14553 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
|
|
14554 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
|
|
14555 |
#備註:
|
|
|
14556 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
|
|
14557 |
#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
|
|
|
14558 |
$changePermission=external::callShell($conf["external::callShell"]);
|
|
|
14559 |
unset($conf["external::callShell"]);
|
|
|
14560 |
|
|
|
14561 |
#如果 $changePermission["status"] 等於 "false"
|
|
|
14562 |
if($changePermission["status"]=="false"){
|
|
|
14563 |
|
|
|
14564 |
#設置錯誤識別
|
|
|
14565 |
$result["status"]="false";
|
|
|
14566 |
|
|
|
14567 |
#設置錯誤訊息
|
|
|
14568 |
$result["error"]=$changePermission;
|
|
|
14569 |
|
|
|
14570 |
#回傳結果
|
|
|
14571 |
return $result;
|
|
|
14572 |
|
|
|
14573 |
}#if end
|
|
|
14574 |
|
|
|
14575 |
#函式說明:
|
|
|
14576 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
|
|
14577 |
#回傳結果:
|
|
|
14578 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
14579 |
#$result["error"],錯誤訊息陣列.
|
|
|
14580 |
#$result["function"],當前執行的函數名稱.
|
|
|
14581 |
#$result["argu"],使用的參數.
|
|
|
14582 |
#$result["cmd"],執行的指令內容.
|
|
|
14583 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
|
|
14584 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
|
|
14585 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
|
|
14586 |
#$result["running"],是否還在執行.
|
|
|
14587 |
#$result["pid"],pid.
|
|
|
14588 |
#$result["statusCode"],執行結束後的代碼.
|
|
|
14589 |
#$result["escape"],陣列,儲存出新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu").
|
|
|
14590 |
#必填參數:
|
|
|
14591 |
#$conf["command"],字串,要執行的指令.
|
|
|
14592 |
$conf["external"]["callShell"]["command"]="chmod";
|
|
|
14593 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
14594 |
$conf["external"]["callShell"]["fileArgu"]=__FILE__;
|
|
|
14595 |
#可省略參數:
|
|
|
14596 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
|
|
14597 |
$conf["external"]["callShell"]["argu"]=array("0777",$uploadDir."/".$ServerFilename.$FileExtension);
|
|
|
14598 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
|
|
14599 |
#$conf["arguIsAddr"]=array();
|
|
|
14600 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
|
|
14601 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
|
|
14602 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
|
|
14603 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
|
|
14604 |
#$conf["enablePrintDescription"]="true";
|
|
|
14605 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
|
|
14606 |
#$conf["printDescription"]="";
|
|
|
14607 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
|
|
|
14608 |
$conf["external"]["callShell"]["escapeshellarg"]="true";
|
|
|
14609 |
#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
|
|
|
14610 |
#$conf["thereIsShellVar"]=array();
|
|
|
14611 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
|
|
14612 |
#$conf["username"]="";
|
|
|
14613 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
|
|
14614 |
#$conf["password"]="";
|
|
|
14615 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
|
|
14616 |
#$conf["useScript"]="";
|
|
|
14617 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
|
|
14618 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
|
|
14619 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
|
|
14620 |
#$conf["inBackGround"]="";
|
|
|
14621 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
|
|
14622 |
#$conf["getErr"]="false";
|
|
|
14623 |
#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
|
|
|
14624 |
#$conf["doNotRun"]="false";
|
|
|
14625 |
#參考資料:
|
|
|
14626 |
#exec=>http://php.net/manual/en/function.exec.php
|
|
|
14627 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
|
|
14628 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
|
|
14629 |
#備註:
|
|
|
14630 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
|
|
14631 |
#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
|
|
|
14632 |
$changePermission=external::callShell($conf["external"]["callShell"]);
|
|
|
14633 |
unset($conf["external"]["callShell"]);
|
| 226 |
liveuser |
14634 |
|
| 3 |
liveuser |
14635 |
#如果 $changePermission["status"] 等於 "false"
|
|
|
14636 |
if($changePermission["status"]=="false"){
|
|
|
14637 |
|
|
|
14638 |
#設置錯誤識別
|
|
|
14639 |
$result["status"]="false";
|
|
|
14640 |
|
|
|
14641 |
#設置錯誤訊息
|
|
|
14642 |
$result["error"]=$changePermission;
|
|
|
14643 |
|
|
|
14644 |
#回傳結果
|
|
|
14645 |
return $result;
|
|
|
14646 |
|
|
|
14647 |
}#if end
|
|
|
14648 |
|
|
|
14649 |
}#if end
|
|
|
14650 |
|
|
|
14651 |
#反之檔案移動失敗
|
|
|
14652 |
else{
|
|
|
14653 |
|
|
|
14654 |
#設置錯誤識別
|
|
|
14655 |
$result["status"]="false";
|
|
|
14656 |
|
|
|
14657 |
#設置移動檔案失敗的訊息
|
|
|
14658 |
$result["error"][]="移動檔案失敗";
|
|
|
14659 |
|
|
|
14660 |
#回傳錯誤訊息
|
|
|
14661 |
return $result;
|
|
|
14662 |
|
|
|
14663 |
}#else end
|
|
|
14664 |
|
|
|
14665 |
#將指定的檔案名稱與偵測到的副檔名合併在一塊
|
|
|
14666 |
$storeFileName=$ServerFilename.$FileExtension;
|
|
|
14667 |
|
|
|
14668 |
#如果有要將新檔案的相對位置用修改既有資料的方式寫入到資料表裏面
|
|
|
14669 |
#如果 $dbProcess 等於 "true"
|
|
|
14670 |
if($conf["dbProcess"]=="true"){
|
|
|
14671 |
|
|
|
14672 |
#將新檔案的相對位置用修改既有資料的方式寫入到資料表裏面
|
|
|
14673 |
#函式說明:
|
|
|
14674 |
#更新資料表裏面的資料
|
|
|
14675 |
#回傳的結果:
|
|
|
14676 |
#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
|
|
|
14677 |
#$result["error"],錯誤訊息
|
|
|
14678 |
#$result["sql"],執行的sql語法.
|
|
|
14679 |
#必填參數:
|
|
|
14680 |
$conf["db"]["updateDataTableContent"]["dbAddress"]=$conf["dbAddress"];#爲mysql-Server的位置
|
|
|
14681 |
$conf["db"]["updateDataTableContent"]["dbAccount"]=$conf["$dbAccount"];#爲用於連入mysql-Server時要使用的帳號
|
|
|
14682 |
$conf["db"]["updateDataTableContent"]["selectedDataBaseName"]=$conf["dbName"];#要選取的資料庫名稱
|
|
|
14683 |
$conf["db"]["updateDataTableContent"]["tableName"]=$conf["updatingDataTableName"];#要修改的資料表名稱
|
|
|
14684 |
$conf["db"]["updateDataTableContent"]["whereColumn"]=$conf["updatingConditionDataTableColumnName"];#爲用來判斷要更新的哪筆資料的欄位名稱,須爲陣列值
|
|
|
14685 |
$conf["db"]["updateDataTableContent"]["whereValue"]=$conf["updatingConditionDataTableColumnValue"];#為用來判斷是要更新哪筆資料的欄位對應數值,須爲陣列值
|
|
|
14686 |
$conf["db"]["updateDataTableContent"]["tableColumnName"]=$conf["updatingTargetDataTableColumnName"];#資料表項目的名稱陣列
|
|
|
14687 |
$conf["db"]["updateDataTableContent"]["updateDataValue"]=$conf["updatingTargetDataTableColumnValue"];#要更改成對應資料表項目的內容,須為陣列值
|
|
|
14688 |
|
|
|
14689 |
#如果 $conf["db"]["updateDataTableContent"]["updateDataValue"] 裏面其中一個元素爲 "filePosition" ,則會替換成檔案的新位置。
|
|
|
14690 |
for($i=0;$i<count($conf["updatingTargetDataTableColumnValue"]);$i++){
|
|
|
14691 |
|
|
|
14692 |
#如果其中一項元素內容爲 "filePosition"
|
|
|
14693 |
if($conf["db"]["updateDataTableContent"]["updateDataValue"][$i]=="filePosition"){
|
|
|
14694 |
|
|
|
14695 |
#將其更改爲新檔案的位置
|
|
|
14696 |
$conf["db"]["updateDataTableContent"]["updateDataValue"][$i]=$uploadDir."/".$storeFileName;
|
|
|
14697 |
|
|
|
14698 |
}#if end
|
|
|
14699 |
|
|
|
14700 |
}#for end
|
|
|
14701 |
|
|
|
14702 |
#可省略參數:
|
|
|
14703 |
|
|
|
14704 |
#如果 $conf["dbPassword"] 有設置
|
|
|
14705 |
if(isset($conf["dbPassword"])){
|
|
|
14706 |
|
|
|
14707 |
$conf["db"]["updateDataTableContent"]["dbPassword"]=$conf["dbPassword"];#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
|
|
|
14708 |
|
|
|
14709 |
}#if end
|
|
|
14710 |
|
|
|
14711 |
$db["updateDataTableContent"]=db::updateDataTableContent($conf["db"]["updateDataTableContent"]);
|
|
|
14712 |
unset($conf["db"]["updateDataTableContent"]);
|
|
|
14713 |
|
|
|
14714 |
#如果 $db["updateDataTableContent"]["status"] 等於 "false"
|
|
|
14715 |
if($db["updateDataTableContent"]["status"]=="false"){
|
|
|
14716 |
|
|
|
14717 |
#設置錯誤識別
|
|
|
14718 |
$result["status"]="false";
|
|
|
14719 |
|
|
|
14720 |
#設置錯誤訊息
|
|
|
14721 |
$result["error"]=$db["updateDataTableContent"];
|
|
|
14722 |
|
|
|
14723 |
#回傳結果
|
|
|
14724 |
return $result;
|
|
|
14725 |
|
|
|
14726 |
}#if end
|
|
|
14727 |
|
|
|
14728 |
#取得執行的sql語法
|
|
|
14729 |
$result["sql"]=$db["updateDataTableContent"]["sql"];
|
|
|
14730 |
|
|
|
14731 |
}#if end
|
|
|
14732 |
|
|
|
14733 |
#將各項結果存進 $result 陣列變數裏面
|
|
|
14734 |
$result["ServerFileName"]=$storeFileName;#檔案名稱
|
|
|
14735 |
$result["ServerFileType"]=$FileType;#檔案類型
|
|
|
14736 |
$result["ServerFileSize"]=$storeFileSizeKb;#檔案大小
|
|
|
14737 |
$result["fileRelativePosition"]=$uploadDir."/".$storeFileName;#檔案的相對位置
|
|
|
14738 |
$result["error"]["uploadErrorCode"]=$FileError;#上傳的錯誤訊息
|
|
|
14739 |
|
|
|
14740 |
#根據錯誤編號
|
|
|
14741 |
switch($result["error"]["uploadErrorCode"]){
|
|
|
14742 |
|
|
|
14743 |
#如果編號等於0
|
|
|
14744 |
case 0:
|
|
|
14745 |
|
|
|
14746 |
#代表沒有錯誤
|
|
|
14747 |
|
|
|
14748 |
#卸除錯誤識別編號
|
|
|
14749 |
unset($result["error"]);
|
|
|
14750 |
|
|
|
14751 |
#設置錯誤識別
|
|
|
14752 |
$result["status"]="true";
|
|
|
14753 |
|
|
|
14754 |
#回傳結果
|
|
|
14755 |
return $result;
|
|
|
14756 |
|
|
|
14757 |
#跳出switch
|
|
|
14758 |
break;
|
|
|
14759 |
|
|
|
14760 |
#如果編號等於1
|
|
|
14761 |
case 1:
|
|
|
14762 |
|
|
|
14763 |
#設置錯誤訊息
|
|
|
14764 |
$result["error"][]="檔案大小超出 php.ini 設定檔中的 upload_max_filesize";
|
|
|
14765 |
|
|
|
14766 |
#設置錯誤識別
|
|
|
14767 |
$result["status"]="false";
|
|
|
14768 |
|
|
|
14769 |
#回傳結果
|
|
|
14770 |
return $result;
|
|
|
14771 |
|
|
|
14772 |
#跳出switch
|
|
|
14773 |
break;
|
|
|
14774 |
|
|
|
14775 |
#如果編號等於2
|
|
|
14776 |
case 2:
|
|
|
14777 |
|
|
|
14778 |
#設置錯誤訊息
|
|
|
14779 |
$result["error"][]="檔案大小超出網頁所限定的 MAX_FILE_SIZE 大小";
|
|
|
14780 |
|
|
|
14781 |
#設置錯誤識別
|
|
|
14782 |
$result["status"]="false";
|
|
|
14783 |
|
|
|
14784 |
#回傳結果
|
|
|
14785 |
return $result;
|
|
|
14786 |
|
|
|
14787 |
#跳出switch
|
|
|
14788 |
break;
|
|
|
14789 |
|
|
|
14790 |
#如果編號等於3
|
|
|
14791 |
case 3:
|
|
|
14792 |
|
|
|
14793 |
#設置錯誤訊息
|
|
|
14794 |
$result["error"][]="檔案僅上傳成功部份";
|
|
|
14795 |
|
|
|
14796 |
#設置錯誤識別
|
|
|
14797 |
$result["status"]="false";
|
|
|
14798 |
|
|
|
14799 |
#回傳結果
|
|
|
14800 |
return $result;
|
|
|
14801 |
|
|
|
14802 |
#跳出switch
|
|
|
14803 |
break;
|
|
|
14804 |
|
|
|
14805 |
#如果編號等於4
|
|
|
14806 |
case 4:
|
|
|
14807 |
|
|
|
14808 |
#設置錯誤訊息
|
|
|
14809 |
$result["error"][]="沒有上傳的檔案";
|
|
|
14810 |
|
|
|
14811 |
#設置錯誤識別
|
|
|
14812 |
$result["status"]="false";
|
|
|
14813 |
|
|
|
14814 |
#回傳結果
|
|
|
14815 |
return $result;
|
|
|
14816 |
|
|
|
14817 |
#跳出switch
|
|
|
14818 |
break;
|
|
|
14819 |
|
|
|
14820 |
#如果編號等於6
|
|
|
14821 |
case 6:
|
|
|
14822 |
|
|
|
14823 |
#設置錯誤訊息
|
|
|
14824 |
$result["error"][]="暫存資料夾遺失";
|
|
|
14825 |
|
|
|
14826 |
#設置錯誤識別
|
|
|
14827 |
$result["status"]="false";
|
|
|
14828 |
|
|
|
14829 |
#回傳結果
|
|
|
14830 |
return $result;
|
|
|
14831 |
|
|
|
14832 |
#跳出switch
|
|
|
14833 |
break;
|
|
|
14834 |
|
|
|
14835 |
#如果編號等於7
|
|
|
14836 |
case 7:
|
|
|
14837 |
|
|
|
14838 |
#設置錯誤訊息
|
|
|
14839 |
$result["error"][]="檔案寫入硬碟失敗";
|
|
|
14840 |
|
|
|
14841 |
#設置錯誤識別
|
|
|
14842 |
$result["status"]="false";
|
|
|
14843 |
|
|
|
14844 |
#回傳結果
|
|
|
14845 |
return $result;
|
|
|
14846 |
|
|
|
14847 |
#跳出switch
|
|
|
14848 |
break;
|
|
|
14849 |
|
|
|
14850 |
#如果編號等於8
|
|
|
14851 |
case 8:
|
|
|
14852 |
|
|
|
14853 |
#設置錯誤訊息
|
|
|
14854 |
$result["error"][]="某些擴充套件導致檔案上傳功能不能使用,可用phpinfo()來檢查";
|
|
|
14855 |
|
|
|
14856 |
#設置錯誤識別
|
|
|
14857 |
$result["status"]="false";
|
|
|
14858 |
|
|
|
14859 |
#回傳結果
|
|
|
14860 |
return $result;
|
|
|
14861 |
|
|
|
14862 |
#跳出switch
|
|
|
14863 |
break;
|
|
|
14864 |
|
|
|
14865 |
}#switch end
|
|
|
14866 |
|
|
|
14867 |
#執行到這邊代表執行正常
|
|
|
14868 |
|
|
|
14869 |
#將其處理結果設為 "true"
|
|
|
14870 |
$result["status"]="true";
|
|
|
14871 |
|
|
|
14872 |
#回傳結果
|
|
|
14873 |
return $result;
|
|
|
14874 |
|
|
|
14875 |
}#function processUploadedFile end
|
|
|
14876 |
|
|
|
14877 |
/*
|
|
|
14878 |
#函式說明:
|
|
|
14879 |
#處理多個上傳到暫存目錄的檔案,可以移動到指定的位置,並指定檔案的名稱。並且可以指定刪除舊有的檔案,然後將新檔案的相對位置寫入到資料庫裏面。
|
|
|
14880 |
#回傳的變數:
|
|
|
14881 |
#$result["ServerFileName"][$i]#第$i-1個檔案的名稱.
|
|
|
14882 |
#$result["ServerFileType"][$i]#第$i-1個檔案的類型.
|
|
|
14883 |
#$result["ServerFileSize"][$i]#第$i-1個檔案的大小.
|
|
|
14884 |
#$result["status"]#整體上傳有無成功,"true"代表完整成功,"false"代表有過程有錯誤.
|
|
|
14885 |
#$result["error"],錯誤訊息陣列.
|
|
|
14886 |
#$result["fileRelativePosition"][$i]#第$i-1個檔案的相對位置,包含檔案名稱與附檔名。
|
|
|
14887 |
#必填參數:
|
|
|
14888 |
#$conf["formFileName"],為上傳檔案時表單傳送時的名稱陣列.
|
|
|
14889 |
$conf["formFileName"]=array();
|
|
|
14890 |
#可省略參數:
|
|
|
14891 |
#$conf["uploadDirUserDefine"],字串陣列,為存放上傳檔案的目錄,如果沒設定則會自行建立依照系統時間的年月日十分秒來替資料夾命名,並將上傳的檔案存在裏面。
|
|
|
14892 |
#$conf["uploadDirUserDefine"]=array("");
|
|
|
14893 |
#$conf["ServerFilenameUserDefine"],字串陣列,為存放在伺服器上的檔案名稱,如果沒設定則依照台灣時間的年月日時分秒命名
|
|
|
14894 |
#$conf["ServerFilenameUserDefine"]=array("");
|
|
|
14895 |
#$conf["NoFileExtension"],字串陣列,若為 "true" 則表 指定了檔案名稱後,不用再加上檔案型的副檔名,預設皆為為"false".
|
|
|
14896 |
#$conf["NoFileExtension"]=array("true");
|
|
|
14897 |
#$conf["limitPage"],字串陣列,限制只能從哪些網頁檔案過來。
|
|
|
14898 |
#$conf["limitPage"]=array("");
|
|
|
14899 |
#$conf["taskName"],字串,爲該上傳作業的名稱,若沒設定,則預設爲"上傳作業"。
|
|
|
14900 |
#$conf["taskName"]="";
|
|
|
14901 |
#$conf["eraseOldFile"],字串陣列,如果為"true"的話會移除同名的舊檔案,其值爲檔案的相對位置,預設為"false",不移除同名的檔案,並透過編號保留新的檔案.
|
|
|
14902 |
#$conf["eraseOldFile"]=array("");
|
|
|
14903 |
#$conf["dbProcess"],字串,如果爲"true",則會進行資料表資料更新的動作,亦即要設定 $conf["updatingMysqlServerAddress"] $conf["updatingMysqlAccount"] $conf["updatingDataBaseName"] $conf["updatingDataTableName"] $conf["updatingConditionDataTableColumnName"] $conf["updatingConditionDataTableColumnValue"] $conf["updatingTargetDataTableColumnName"] $conf["updatingTargetDataTableColumnValue"] 的內容,預設為"false".
|
|
|
14904 |
#$conf["dbProcess"]="true";
|
|
|
14905 |
#$conf["updatingMysqlServerAddress"],字串,資料庫位於網路上的哪個位置.
|
|
|
14906 |
#$conf["updatingMysqlServerAddress"]=$dbAddress;
|
|
|
14907 |
#$conf["updatingMysqlAccount"],字串,連線時要使用的帳號,省略時代表不用密碼進行連線.
|
|
|
14908 |
#$conf["updatingMysqlAccount"]=$dbAccount;
|
|
|
14909 |
#$conf["updatingMysqlPassword"],字串,連線時要使用的密碼.
|
|
|
14910 |
#$conf["updatingMysqlPassword"]=$dbPassword;
|
|
|
14911 |
#$conf["updatingDataBaseName"],字串,要更新的目標資料所屬資料庫名稱.
|
|
|
14912 |
#$conf["updatingDataBaseName"]=$dbName;
|
|
|
14913 |
#$conf["updatingDataTableName"],字串,要更新的目標資料位於哪個資料表.
|
|
|
14914 |
#$conf["updatingDataTableName"]="";
|
|
|
14915 |
#$conf["updatingConditionDataTableColumnName"],字串陣列,要用哪些欄位來識別要更新哪一筆資料,預設為array("id").
|
|
|
14916 |
#$conf["updatingConditionDataTableColumnName"]=array("id");
|
|
|
14917 |
#$conf["updatingConditionDataTableColumnValue"],字串陣列,該條件欄位內容的數值要爲多少,才是我們要修改的那筆資料。
|
|
|
14918 |
#$conf["updatingConditionDataTableColumnValue"]=array("");
|
|
|
14919 |
#$conf["updatingTargetDataTableColumnName"],字串陣列,要更新的資料欄位有?
|
|
|
14920 |
#$conf["updatingTargetDataTableColumnName"]=array("");
|
|
|
14921 |
#$conf["updatingTargetDataTableColumnValue"],字串陣列,目標資料欄位要改成什麼樣的數值,如果其元素含有"filePosition",則會替換成新檔案的相對位置
|
|
|
14922 |
#$conf["updatingTargetDataTableColumnValue"]=array("");
|
|
|
14923 |
#參考資料:
|
|
|
14924 |
#file_exist()的用法
|
|
|
14925 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
14926 |
#備註:
|
|
|
14927 |
#無.
|
|
|
14928 |
*/
|
|
|
14929 |
public static function processMultiUploadedFile($conf){
|
|
|
14930 |
|
|
|
14931 |
#初始化要回傳的內容
|
|
|
14932 |
$result=array();
|
|
|
14933 |
|
|
|
14934 |
#設置當前執行的函數
|
|
|
14935 |
$result["function"]=__FUNCTION__;
|
|
|
14936 |
|
|
|
14937 |
#如果 $conf 不為陣列
|
|
|
14938 |
if(gettype($conf)!="array"){
|
|
|
14939 |
|
|
|
14940 |
#設置執行失敗
|
|
|
14941 |
$result["status"]="false";
|
|
|
14942 |
|
|
|
14943 |
#設置執行錯誤訊息
|
|
|
14944 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
14945 |
|
|
|
14946 |
#如果傳入的參數為 null
|
|
|
14947 |
if($conf==null){
|
|
|
14948 |
|
|
|
14949 |
#設置執行錯誤訊息
|
|
|
14950 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
14951 |
|
|
|
14952 |
}#if end
|
|
|
14953 |
|
|
|
14954 |
#回傳結果
|
|
|
14955 |
return $result;
|
|
|
14956 |
|
|
|
14957 |
}#if end
|
|
|
14958 |
|
|
|
14959 |
#檢查參數
|
|
|
14960 |
#函式說明:
|
|
|
14961 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
14962 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
14963 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
14964 |
#$result["function"],當前執行的函式名稱.
|
|
|
14965 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
14966 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
14967 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
14968 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
14969 |
#必填參數:
|
|
|
14970 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
14971 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
14972 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
14973 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("formFileName");
|
|
|
14974 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
14975 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
14976 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
14977 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
14978 |
#可省略參數:
|
|
|
14979 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
14980 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="false";
|
|
|
14981 |
#$conf["variableCheck.checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
14982 |
$conf["variableCheck.checkArguments"]["skipableVariableName"]=array("uploadDirUserDefine","ServerFilenameUserDefine","NoFileExtension","limitPage","taskName","eraseOldFile","dbProcess","updatingMysqlServerAddress","updatingMysqlAccount","updatingMysqlPassword","updatingDataBaseName","updatingDataTableName","updatingConditionDataTableColumnName","updatingConditionDataTableColumnValue","updatingTargetDataTableColumnName","updatingTargetDataTableColumnValue");
|
|
|
14983 |
#$conf["variableCheck.checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
14984 |
$conf["variableCheck.checkArguments"]["skipableVariableType"]=array("array","array","array","array","string","array","array","string","string","string","string","string","array","array","array","array");
|
|
|
14985 |
#$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
14986 |
$conf["variableCheck.checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,null,"上傳作業",null,"false",null,null,null,null,null,array("id"),null,null,null);
|
|
|
14987 |
#$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
14988 |
$conf["variableCheck.checkArguments"]["arrayCountEqualCheck"][]=array("uploadDirUserDefine","ServerFilenameUserDefine","NoFileExtension","eraseOldFile");
|
|
|
14989 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
14990 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
14991 |
|
|
|
14992 |
#如果檢查失敗
|
|
|
14993 |
if($checkResult["status"]=="false"){
|
|
|
14994 |
|
|
|
14995 |
#設置執行不正常
|
|
|
14996 |
$result["status"]="false";
|
|
|
14997 |
|
|
|
14998 |
#設置錯誤訊息
|
|
|
14999 |
$result["error"]=$checkResult;
|
|
|
15000 |
|
|
|
15001 |
#回傳結果
|
|
|
15002 |
return $result;
|
|
|
15003 |
|
|
|
15004 |
}#if end
|
|
|
15005 |
|
|
|
15006 |
#如果檢查不通過
|
|
|
15007 |
if($checkResult["passed"]=="false"){
|
|
|
15008 |
|
|
|
15009 |
#設置執行不正常
|
|
|
15010 |
$result["status"]="false";
|
|
|
15011 |
|
|
|
15012 |
#設置錯誤訊息
|
|
|
15013 |
$result["error"]=$checkResult;
|
|
|
15014 |
|
|
|
15015 |
#回傳結果
|
|
|
15016 |
return $result;
|
|
|
15017 |
|
|
|
15018 |
}#if end
|
|
|
15019 |
|
|
|
15020 |
#如果 count($conf["formFileName"]) 為 0
|
|
|
15021 |
if(count($conf["formFileName"])==0){
|
|
|
15022 |
|
|
|
15023 |
#設置執行失敗
|
|
|
15024 |
$result["status"]="false";
|
|
|
15025 |
|
|
|
15026 |
#設置執行錯誤
|
|
|
15027 |
$result["error"][]="陣列變數 \"formFileName\" 裡面必須要有元素";
|
|
|
15028 |
|
|
|
15029 |
#回傳結果
|
|
|
15030 |
return $result;
|
|
|
15031 |
|
|
|
15032 |
}#if end
|
|
|
15033 |
|
|
|
15034 |
#有幾個要接收的檔案就執行幾次
|
|
|
15035 |
for($i=0;$i<count($conf["formFileName"]);$i++){
|
|
|
15036 |
|
|
|
15037 |
#如果 $conf["formFileName"][$i] 不存在
|
|
|
15038 |
if(!isset($conf["formFileName"][$i])){
|
|
|
15039 |
|
|
|
15040 |
#設置執行不正常
|
|
|
15041 |
$result["status"]="false";
|
|
|
15042 |
|
|
|
15043 |
#設置錯誤訊息
|
|
|
15044 |
$result["error"][]="表單檔案變數名稱有缺";
|
|
|
15045 |
|
|
|
15046 |
#回傳結果
|
|
|
15047 |
return $result;
|
|
|
15048 |
|
|
|
15049 |
}#if end
|
|
|
15050 |
|
|
|
15051 |
#函式說明:
|
|
|
15052 |
#處理上傳到暫存目錄的檔案,可以移動到指定的位置,並指定檔案的名稱。並且可以指定刪除舊有的檔案,然後將新檔案的相對位置寫入到資料庫裏面。
|
|
|
15053 |
#回傳的變數:
|
|
|
15054 |
#$result["status"],整體上傳有無成功。"true"代表完整成功 "false"代表有過程有錯誤
|
|
|
15055 |
#$result["error"],錯誤訊息陣列,$result["error"][0] 為"沒有接收到上傳的檔案",則代表沒有上傳檔案.
|
|
|
15056 |
#$result["warning"],警告訊息陣列
|
|
|
15057 |
#$result["ServerFileName"],檔案名稱
|
|
|
15058 |
#$result["ServerFileType"],檔案類型
|
|
|
15059 |
#$result["ServerFileSize"],檔案大小
|
|
|
15060 |
#$result["fileRelativePosition"],檔案的相對位置,包含檔案名稱與附檔名。
|
|
|
15061 |
#必填參數:
|
|
|
15062 |
#$conf["form::processUploadedFile"]["formFileName"],字串,為上傳檔案時表單傳送時的名稱
|
|
|
15063 |
$conf["form::processUploadedFile"]["formFileName"]=$conf["formFileName"][$i];
|
|
|
15064 |
#可省略參數:
|
|
|
15065 |
|
|
|
15066 |
#如果 $conf["uploadDirUserDefine"] 存在
|
|
|
15067 |
if(isset($conf["uploadDirUserDefine"])){
|
|
|
15068 |
|
|
|
15069 |
#如果 $conf["uploadDirUserDefine"][$i] 有設置
|
|
|
15070 |
if(isset($conf["uploadDirUserDefine"][$i])){
|
|
|
15071 |
|
|
|
15072 |
#$conf["form::processUploadedFile"]["uploadDirUserDefine"],字串,為存放上傳檔案的目錄,如果沒設定則會自行建立依照系統時間的年月日十分秒來替資料夾命名,並將上傳的檔案存在裏面。
|
|
|
15073 |
$conf["form::processUploadedFile"]["uploadDirUserDefine"]=$conf["uploadDirUserDefine"][$i];
|
|
|
15074 |
|
|
|
15075 |
}#if end
|
|
|
15076 |
|
|
|
15077 |
}#if end
|
|
|
15078 |
|
|
|
15079 |
#如果 $conf["ServerFilenameUserDefine"] 有設置
|
|
|
15080 |
if(isset($conf["ServerFilenameUserDefine"])){
|
|
|
15081 |
|
|
|
15082 |
#如果 $conf["ServerFilenameUserDefine"][$i] 有設置
|
|
|
15083 |
if(isset($conf["ServerFilenameUserDefine"][$i])){
|
|
|
15084 |
|
|
|
15085 |
#$conf["form::processUploadedFile"]["ServerFilenameUserDefine"],字串,為存放在伺服器上的檔案名稱,如果沒設定則依照台灣時間的年月日時分秒命名
|
|
|
15086 |
$conf["form::processUploadedFile"]["ServerFilenameUserDefine"]=$conf["ServerFilenameUserDefine"][$i];
|
|
|
15087 |
|
|
|
15088 |
}#if end
|
|
|
15089 |
|
|
|
15090 |
}#if end
|
|
|
15091 |
|
|
|
15092 |
#如果 $conf["NoFileExtension"] 有設置
|
|
|
15093 |
if(isset($conf["NoFileExtension"])){
|
|
|
15094 |
|
|
|
15095 |
#如果 $conf["NoFileExtension"][$i] 有設置
|
|
|
15096 |
if(isset($conf["NoFileExtension"][$i])){
|
|
|
15097 |
|
|
|
15098 |
#$conf["form::processUploadedFile"]["NoFileExtension"],字串,若為 "true" 則表 指定了檔案名稱後,不用再加上檔案型的副檔名,預設為"false".
|
|
|
15099 |
$conf["form::processUploadedFile"]["NoFileExtension"]="true";
|
|
|
15100 |
|
|
|
15101 |
}#if end
|
|
|
15102 |
|
|
|
15103 |
}#if end
|
|
|
15104 |
|
|
|
15105 |
#如果 $conf["limitPage"] 有設置
|
|
|
15106 |
if(isset($conf["limitPage"])){
|
|
|
15107 |
|
|
|
15108 |
#$conf["form::processUploadedFile"]["limitPage"],字串陣列,限制只能從哪些網頁檔案過來。
|
|
|
15109 |
$conf["form::processUploadedFile"]["limitPage"]=$conf["limitPage"];
|
|
|
15110 |
|
|
|
15111 |
}#if end
|
|
|
15112 |
|
|
|
15113 |
#如果 $conf["taskName"] 有設置
|
|
|
15114 |
if(isset($conf["taskName"])){
|
|
|
15115 |
|
|
|
15116 |
#$conf["form::processUploadedFile"]["taskName"],字串,爲該上傳作業的名稱,若沒設定,則預設爲"上傳作業"。
|
|
|
15117 |
$conf["form::processUploadedFile"]["taskName"]=$conf["taskName"];
|
|
|
15118 |
|
|
|
15119 |
}#if end
|
|
|
15120 |
|
|
|
15121 |
#如果 $conf["eraseOldFile"] 有設置
|
|
|
15122 |
if(isset($conf["eraseOldFile"])){
|
|
|
15123 |
|
|
|
15124 |
#如果 $conf["eraseOldFile"][$i] 有設置
|
|
|
15125 |
if(isset($conf["eraseOldFile"][$i])){
|
|
|
15126 |
|
|
|
15127 |
#$conf["form::processUploadedFile"]["eraseOldFile"],字串,如果為"true"的話會移除同名的舊檔案,其值爲檔案的相對位置,預設為"false",不移除同名的檔案,並透過編號保留新的檔案.
|
|
|
15128 |
$conf["form::processUploadedFile"]["eraseOldFile"]=$conf["eraseOldFile"][$i];
|
|
|
15129 |
|
|
|
15130 |
}#if end
|
|
|
15131 |
|
|
|
15132 |
}#if end
|
|
|
15133 |
|
|
|
15134 |
#$conf["form::processUploadedFile"]["dbProcess"],字串,如果爲"true",則會進行資料表資料更新的動作,亦即要設定 $conf["updatingMysqlServerAddress"] $conf["updatingMysqlAccount"] $conf["updatingDataBaseName"] $conf["updatingDataTableName"] $conf["updatingConditionDataTableColumnName"] $conf["updatingConditionDataTableColumnValue"] $conf["updatingTargetDataTableColumnName"] $conf["updatingTargetDataTableColumnValue"] 的內容,預設為"false".
|
|
|
15135 |
$conf["form::processUploadedFile"]["dbProcess"]=$conf["dbProcess"];
|
|
|
15136 |
|
|
|
15137 |
#如果 $conf["updatingMysqlServerAddress"] 有設定
|
|
|
15138 |
if(isset($conf["updatingMysqlServerAddress"])){
|
|
|
15139 |
|
|
|
15140 |
#$conf["form::processUploadedFile"]["updatingMysqlServerAddress"],字串,資料庫位於網路上的哪個位置.
|
|
|
15141 |
$conf["form::processUploadedFile"]["updatingMysqlServerAddress"]=$conf["updatingMysqlServerAddress"];
|
|
|
15142 |
|
|
|
15143 |
}#if end
|
|
|
15144 |
|
|
|
15145 |
#如果 $conf["updatingMysqlAccount"] 有設定
|
|
|
15146 |
if(isset($conf["updatingMysqlAccount"])){
|
|
|
15147 |
|
|
|
15148 |
#$conf["form::processUploadedFile"]["updatingMysqlAccount"],字串,連線時要使用的帳號,省略時代表不用密碼進行連線.
|
|
|
15149 |
$conf["form::processUploadedFile"]["updatingMysqlAccount"]=$conf["updatingMysqlAccount"];
|
|
|
15150 |
|
|
|
15151 |
}#if end
|
|
|
15152 |
|
|
|
15153 |
#如果 $conf["updatingMysqlPassword"] 有設定
|
|
|
15154 |
if(isset($conf["updatingMysqlPassword"])){
|
|
|
15155 |
|
|
|
15156 |
#$conf["form::processUploadedFile"]["updatingMysqlPassword"],字串,連線時要使用的密碼.
|
|
|
15157 |
$conf["form::processUploadedFile"]["updatingMysqlPassword"]=$conf["updatingMysqlPassword"];
|
|
|
15158 |
|
|
|
15159 |
}#if end
|
|
|
15160 |
|
|
|
15161 |
#如果 $conf["updatingDataBaseName"] 有設置
|
|
|
15162 |
if(isset($conf["updatingDataBaseName"])){
|
|
|
15163 |
|
|
|
15164 |
#$conf["form::processUploadedFile"]["updatingDataBaseName"],字串,要更新的目標資料所屬資料庫名稱.
|
|
|
15165 |
$conf["form::processUploadedFile"]["updatingDataBaseName"]=$dbName;
|
|
|
15166 |
|
|
|
15167 |
}#if end
|
|
|
15168 |
|
|
|
15169 |
#如果 $conf["updatingDataTableName"] 有設置
|
|
|
15170 |
if(isset($conf["updatingDataTableName"])){
|
|
|
15171 |
|
|
|
15172 |
#$conf["form::processUploadedFile"]["updatingDataTableName"],字串,要更新的目標資料位於哪個資料表.
|
|
|
15173 |
$conf["form::processUploadedFile"]["updatingDataTableName"]=$conf["updatingDataTableName"];
|
|
|
15174 |
|
|
|
15175 |
}#if end
|
|
|
15176 |
|
|
|
15177 |
#如果 $conf["updatingConditionDataTableColumnName"] 有設置
|
|
|
15178 |
if(isset($conf["updatingConditionDataTableColumnName"])){
|
|
|
15179 |
|
|
|
15180 |
#$conf["form::processUploadedFile"]["updatingConditionDataTableColumnName"],字串陣列,要用哪些欄位來識別要更新哪一筆資料,預設為array("id").
|
|
|
15181 |
$conf["form::processUploadedFile"]["updatingConditionDataTableColumnName"]=$conf["updatingConditionDataTableColumnName"];
|
|
|
15182 |
|
|
|
15183 |
}#if end
|
|
|
15184 |
|
|
|
15185 |
#如果 $conf["updatingConditionDataTableColumnValue"] 有設置
|
|
|
15186 |
if(isset($conf["updatingConditionDataTableColumnValue"])){
|
|
|
15187 |
|
|
|
15188 |
#$conf["form::processUploadedFile"]["updatingConditionDataTableColumnValue"],字串陣列,該條件欄位內容的數值要爲多少,才是我們要修改的那筆資料。
|
|
|
15189 |
$conf["form::processUploadedFile"]["updatingConditionDataTableColumnValue"]=$conf["updatingConditionDataTableColumnValue"];
|
|
|
15190 |
|
|
|
15191 |
}#if end
|
|
|
15192 |
|
|
|
15193 |
#如果 $conf["updatingTargetDataTableColumnName"] 有設置
|
|
|
15194 |
if(isset($conf["updatingTargetDataTableColumnName"])){
|
|
|
15195 |
|
|
|
15196 |
#$conf["form::processUploadedFile"]["updatingTargetDataTableColumnName"],字串陣列,要更新的資料欄位有?
|
|
|
15197 |
$conf["form::processUploadedFile"]["updatingTargetDataTableColumnName"]=$conf["updatingTargetDataTableColumnName"];
|
|
|
15198 |
|
|
|
15199 |
}#if end
|
|
|
15200 |
|
|
|
15201 |
#如果 $conf["updatingTargetDataTableColumnValue"] 有設置
|
|
|
15202 |
if(isset($conf["updatingTargetDataTableColumnValue"])){
|
|
|
15203 |
|
|
|
15204 |
#$conf["form::processUploadedFile"]["updatingTargetDataTableColumnValue"],字串陣列,目標資料欄位要改成什麼樣的數值,如果其元素含有"filePosition",則會替換成新檔案的相對位置
|
|
|
15205 |
$conf["form::processUploadedFile"]["updatingTargetDataTableColumnValue"]=$conf["updatingTargetDataTableColumnValue"];
|
|
|
15206 |
|
|
|
15207 |
}#if end
|
|
|
15208 |
|
|
|
15209 |
#參考資料:
|
|
|
15210 |
#file_exist()的用法
|
|
|
15211 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
15212 |
$processUploadedFile=form::processUploadedFile($conf["form::processUploadedFile"]);
|
|
|
15213 |
unset($conf["form::processUploadedFile"]);
|
|
|
15214 |
|
|
|
15215 |
#如果 form::processUploadedFile 執行失敗
|
|
|
15216 |
if($processUploadedFile["status"]=="false"){
|
|
|
15217 |
|
|
|
15218 |
#設置執行不正常
|
|
|
15219 |
$result["status"]="false";
|
|
|
15220 |
|
|
|
15221 |
#設置錯誤訊息
|
|
|
15222 |
$result["error"]=$processUploadedFile;
|
|
|
15223 |
|
|
|
15224 |
#回傳結果
|
|
|
15225 |
return $result;
|
|
|
15226 |
|
|
|
15227 |
}#if end
|
|
|
15228 |
|
|
|
15229 |
#取得回傳的結果
|
|
|
15230 |
|
|
|
15231 |
#$result["ServerFileName"][$i],第$i-1個檔案的名稱.
|
|
|
15232 |
$result["ServerFileName"][$i]=$processUploadedFile["ServerFileName"];
|
|
|
15233 |
|
|
|
15234 |
#$result["ServerFileType"][$i],第$i-1個檔案的類型.
|
|
|
15235 |
$result["ServerFileType"][$i]=$processUploadedFile["ServerFileType"];
|
|
|
15236 |
|
|
|
15237 |
#$result["ServerFileSize"][$i],第$i-1個檔案的大小.
|
|
|
15238 |
$result["ServerFileSize"][$i]=$processUploadedFile["ServerFileSize"];
|
|
|
15239 |
|
|
|
15240 |
#$result["fileRelativePosition"][$i],第$i-1個檔案的相對位置,包含檔案名稱與附檔名。
|
|
|
15241 |
$result["fileRelativePosition"][$i]=$processUploadedFile["fileRelativePosition"];
|
|
|
15242 |
|
|
|
15243 |
}#for end
|
|
|
15244 |
|
|
|
15245 |
#設置執行正常
|
|
|
15246 |
$result["status"]="true";
|
|
|
15247 |
|
|
|
15248 |
#回傳結果
|
|
|
15249 |
return $result;
|
|
|
15250 |
|
|
|
15251 |
}#function processMultiUploadedFile
|
|
|
15252 |
|
|
|
15253 |
/*
|
|
|
15254 |
#函式說明:
|
|
|
15255 |
#上傳多個檔案
|
|
|
15256 |
#回傳結果:
|
|
|
15257 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15258 |
#$result["function"],當前執行的函數.
|
|
|
15259 |
#$result["error"],錯誤訊息陣列.
|
|
|
15260 |
#$result["content"],上傳檔案的語法.
|
|
|
15261 |
#必填參數:
|
|
|
15262 |
#$conf["formFileName"],字串陣列,每個要上傳檔案的表單名稱.
|
|
|
15263 |
$conf["formFileName"]=array("");
|
|
|
15264 |
#可省略參數:
|
|
|
15265 |
#$conf["maxFileSize"],字串陣列,各個檔案的最大限制,單位是位元組(byte)。1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設是10240000(10MB)
|
|
|
15266 |
#$conf["maxFileSize"]=array("10240000");
|
|
|
15267 |
#$conf["browseButtonClass"],字串陣列,瀏覽檔案的按鈕樣式,預設為"__qbpwcf_inputFileCssStyle".
|
|
|
15268 |
#$conf["browseButtonClass"]=array("__inputFileCssStyle");
|
|
|
15269 |
#$conf["acceptType"],字串陣列,限定各個檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
15270 |
#$conf["acceptType"]=array("");
|
|
|
15271 |
#$conf["required"],字串陣列,各個欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
15272 |
#$conf["required"]=array("true");
|
|
|
15273 |
#$conf["comment"],字串陣列,各個上傳檔案的註解,預設不顯示.
|
|
|
15274 |
#$conf["comment"]=array("");
|
|
|
15275 |
#$conf["formStart"],字串,是否為表單的開始,"true"為是,預設為"false".
|
|
|
15276 |
#$conf["formStart"]="true";
|
|
|
15277 |
#$conf["formName"],字串,表單的名稱
|
|
|
15278 |
#$conf["formName"]="";
|
|
|
15279 |
#$conf["formAction"],字串,表單的目標,若有設置$conf["formStart"]為"true",則預設為php檔案自己
|
|
|
15280 |
#$conf["formAction"]="";
|
|
|
15281 |
#$conf["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
15282 |
#$conf["formTarget"]="_self";
|
|
|
15283 |
#參考資料:
|
|
|
15284 |
#無.
|
|
|
15285 |
#備註:
|
|
|
15286 |
#無.
|
|
|
15287 |
*/
|
|
|
15288 |
public static function uploadMultiFile(&$conf){
|
|
|
15289 |
|
|
|
15290 |
#初始化要回傳的變數
|
|
|
15291 |
$result=array();
|
|
|
15292 |
|
|
|
15293 |
#設置當前執行的函式
|
|
|
15294 |
$result["function"]=__FUNCTION__;
|
|
|
15295 |
|
|
|
15296 |
#初始化表單開始的語法
|
|
|
15297 |
$result["content"]="";
|
|
|
15298 |
|
|
|
15299 |
#如果 $conf 不為陣列
|
|
|
15300 |
if(gettype($conf)!="array"){
|
|
|
15301 |
|
|
|
15302 |
#設置執行失敗
|
|
|
15303 |
$result["status"]="false";
|
|
|
15304 |
|
|
|
15305 |
#設置執行錯誤訊息
|
|
|
15306 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
15307 |
|
|
|
15308 |
#如果傳入的參數為 null
|
|
|
15309 |
if($conf==null){
|
|
|
15310 |
|
|
|
15311 |
#設置執行錯誤訊息
|
|
|
15312 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
15313 |
|
|
|
15314 |
}#if end
|
|
|
15315 |
|
|
|
15316 |
#回傳結果
|
|
|
15317 |
return $result;
|
|
|
15318 |
|
|
|
15319 |
}#if end
|
|
|
15320 |
|
|
|
15321 |
#檢查參數
|
|
|
15322 |
#函式說明:
|
|
|
15323 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
15324 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15325 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
15326 |
#$result["function"],當前執行的函式名稱.
|
|
|
15327 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
15328 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
15329 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
15330 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
15331 |
#必填參數:
|
|
|
15332 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
15333 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
15334 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
15335 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName");
|
|
|
15336 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
15337 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
15338 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
15339 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
15340 |
#可省略參數:
|
|
|
15341 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
15342 |
#$conf["canBeEmptyString"]="false";
|
|
|
15343 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
15344 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("maxFileSize","browseButtonClass","formStart","formAction","formTarget","comment","formName","acceptType","required");
|
|
|
15345 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
15346 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","string","string","string","array","string","array","array");
|
|
|
15347 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
15348 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"_self",null,null,null,null);
|
|
|
15349 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
15350 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
15351 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
15352 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
15353 |
|
|
|
15354 |
#如果檢查參數失敗
|
|
|
15355 |
if($checkResult["status"]=="false"){
|
|
|
15356 |
|
|
|
15357 |
#設置執行失敗
|
|
|
15358 |
$result["status"]="false";
|
|
|
15359 |
|
|
|
15360 |
#設置執行錯誤
|
|
|
15361 |
$result["error"]=$checkResult;
|
|
|
15362 |
|
|
|
15363 |
#回傳結果
|
|
|
15364 |
return $result;
|
|
|
15365 |
|
|
|
15366 |
}#if end
|
|
|
15367 |
|
|
|
15368 |
#如果檢查參數不通過
|
|
|
15369 |
if($checkResult["passed"]=="false"){
|
|
|
15370 |
|
|
|
15371 |
#設置執行失敗
|
|
|
15372 |
$result["status"]="false";
|
|
|
15373 |
|
|
|
15374 |
#設置執行錯誤
|
|
|
15375 |
$result["error"]=$checkResult;
|
|
|
15376 |
|
|
|
15377 |
#回傳結果
|
|
|
15378 |
return $result;
|
|
|
15379 |
|
|
|
15380 |
}#if end
|
|
|
15381 |
|
|
|
15382 |
#如果 $conf["formStart"] 跟 $conf["formAction"] 皆有設置
|
|
|
15383 |
if(isset($conf["formStart"]) && isset($conf["formAction"])){
|
|
|
15384 |
|
|
|
15385 |
#函式說明:
|
|
|
15386 |
#表單開始
|
|
|
15387 |
#回傳結果:
|
|
|
15388 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
15389 |
#$result["error"],錯誤訊息陣列.
|
|
|
15390 |
#$resutl["function"],當前執行的函式名稱.
|
|
|
15391 |
#$result["content"],表單開始的語法.
|
|
|
15392 |
#必填參數:
|
|
|
15393 |
$conf["form::start"]["action"]=$conf["formAction"];#爲要交給那個檔案處理該表單傳送的內容
|
|
|
15394 |
#可省略參數:
|
|
|
15395 |
#$conf["legend"]="";#顯示表單的標題
|
|
|
15396 |
|
|
|
15397 |
#如果 $conf["formName"] 有設置
|
|
|
15398 |
if(isset($conf["formName"])){
|
|
|
15399 |
|
|
|
15400 |
$conf["form::start"]["name"]=$conf["formName"];#爲該表單的名稱
|
|
|
15401 |
|
|
|
15402 |
}#if end
|
|
|
15403 |
|
|
|
15404 |
#$conf["form::start"]["method"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
15405 |
|
|
|
15406 |
#如果 $conf["formTarget"] 有設置
|
|
|
15407 |
if(isset($conf["formTarget"])){
|
|
|
15408 |
|
|
|
15409 |
$conf["form::start"]["target"]=$conf["formTarget"];#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
15410 |
|
|
|
15411 |
}#if end
|
|
|
15412 |
|
|
|
15413 |
#$conf["tableStart"]="true";#爲該表單是否要以<table>開始。"true"爲是,"false"為否,預設為"false".
|
|
|
15414 |
#$conf["tableClass"]="";#表格要套用的css樣式,預設爲"__withoutBorder"無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式。
|
|
|
15415 |
#$conf["showFieldsetBorder"]="false";#是否要顯示表單區域的框線,預設為"false"不顯示,"true"代表要顯示.
|
|
|
15416 |
#參考資料:
|
|
|
15417 |
#http://www.w3schools.com/html/html_forms.asp
|
|
|
15418 |
#http://www.w3schools.com/tags/tag_fieldset.asp
|
|
|
15419 |
$formStart=form::start($conf["form::start"]);
|
|
|
15420 |
unset($conf["form::start"]);
|
|
|
15421 |
|
|
|
15422 |
#如果表單開始失敗
|
|
|
15423 |
if($formStart["status"]=="false"){
|
|
|
15424 |
|
|
|
15425 |
#設置執行失敗
|
|
|
15426 |
$result["status"]="false";
|
|
|
15427 |
|
|
|
15428 |
#設置執行錯誤
|
|
|
15429 |
$result["error"]=$formStart;
|
|
|
15430 |
|
|
|
15431 |
#回傳結果
|
|
|
15432 |
return $result;
|
|
|
15433 |
|
|
|
15434 |
}#if end
|
|
|
15435 |
|
|
|
15436 |
#串接表單開始
|
|
|
15437 |
$result["content"]=$result["content"].$formStart["content"];
|
|
|
15438 |
|
|
|
15439 |
}#if end
|
|
|
15440 |
|
|
|
15441 |
#陣列 $conf["formFileName"] 中有幾個元素,就執行幾次
|
|
|
15442 |
for($i=0;$i<count($conf["formFileName"]);$i++){
|
|
|
15443 |
|
|
|
15444 |
#如果 $conf["formFileName"][$i] 不存在
|
|
|
15445 |
if(!isset($conf["formFileName"][$i])){
|
|
|
15446 |
|
|
|
15447 |
#設置執行失敗
|
|
|
15448 |
$result["status"]="false";
|
|
|
15449 |
|
|
|
15450 |
#設置錯誤訊息
|
|
|
15451 |
$result["error"][]="表單變數有缺";
|
|
|
15452 |
|
|
|
15453 |
#回傳結果
|
|
|
15454 |
return $result;
|
|
|
15455 |
|
|
|
15456 |
}#if end
|
|
|
15457 |
|
|
|
15458 |
#函式說明:
|
|
|
15459 |
#可以瀏覽要上傳的檔案
|
|
|
15460 |
#回傳結果:
|
|
|
15461 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15462 |
#$result["function"],當前執行的函數.
|
|
|
15463 |
#$result["error"],錯誤訊息陣列.
|
|
|
15464 |
#$result["content"],上傳檔案的語法.
|
|
|
15465 |
#必填參數:
|
|
|
15466 |
#$conf["formFileName"],字串,該上傳檔案的表單名稱.
|
|
|
15467 |
$conf["form::uploadOneFile"]["formFileName"]=$conf["formFileName"][$i];
|
|
|
15468 |
#可省略參數:
|
|
|
15469 |
|
|
|
15470 |
#如果 $conf["maxFileSize"] 有設置
|
|
|
15471 |
if(isset($conf["form::uploadOneFile"])){
|
|
|
15472 |
|
|
|
15473 |
#如果 $conf["form::uploadOneFile"][$i] 有設置
|
|
|
15474 |
if(isset($conf["form::uploadOneFile"][$i])){
|
|
|
15475 |
|
|
|
15476 |
#$conf["form::uploadOneFile"]["maxFileSize"],字串,檔案的最大限制,單位是位元組(byte)。1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設是10240000(10MB)
|
|
|
15477 |
$conf["form::uploadOneFile"]["maxFileSize"]=$conf["maxFileSize"];
|
|
|
15478 |
|
|
|
15479 |
}#if end
|
|
|
15480 |
|
|
|
15481 |
}#if end
|
|
|
15482 |
|
|
|
15483 |
#如果 $conf["browseButtonClass"] 有設置
|
|
|
15484 |
if(isset($conf["browseButtonClass"])){
|
|
|
15485 |
|
|
|
15486 |
#如果 $conf["browseButtonClass"][$i] 有設置
|
|
|
15487 |
if(isset($conf["browseButtonClass"][$i])){
|
|
|
15488 |
|
|
|
15489 |
#$conf["form::uploadOneFile"]["browseButtonClass"],字串,瀏覽檔案的按鈕樣式,預設為"__inputFileCssStyle".
|
|
|
15490 |
$conf["form::uploadOneFile"]["browseButtonClass"]="__inputFileCssStyle";
|
|
|
15491 |
|
|
|
15492 |
}#if end
|
|
|
15493 |
|
|
|
15494 |
}#if end
|
|
|
15495 |
|
|
|
15496 |
#如果 $conf["acceptType"] 有設置
|
|
|
15497 |
if(isset($conf["acceptType"])){
|
|
|
15498 |
|
|
|
15499 |
#如果 $conf["acceptType"][$i] 存在
|
|
|
15500 |
if(isset($conf["acceptType"][$i])){
|
|
|
15501 |
|
|
|
15502 |
#$conf["form::uploadOneFile"]["acceptType"],字串,限定檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
15503 |
$conf["form::uploadOneFile"]["acceptType"]=$conf["acceptType"][$i];
|
|
|
15504 |
|
|
|
15505 |
}#if end
|
|
|
15506 |
|
|
|
15507 |
}#if end
|
|
|
15508 |
|
|
|
15509 |
#如果 $conf["required"] 有設置
|
|
|
15510 |
if(isset($conf["required"])){
|
|
|
15511 |
|
|
|
15512 |
#如果 $conf["required"][$i] 有設置
|
|
|
15513 |
if(isset($conf["required"][$i])){
|
|
|
15514 |
|
|
|
15515 |
#$conf["form::uploadOneFile"]["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
15516 |
$conf["form::uploadOneFile"]["required"]=$conf["required"][$i];
|
|
|
15517 |
|
|
|
15518 |
}#if end
|
|
|
15519 |
|
|
|
15520 |
}#if end
|
|
|
15521 |
|
|
|
15522 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
15523 |
#$conf["trStart"]="true";
|
|
|
15524 |
#$conf["trClass"],字串,列的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
15525 |
#$conf["trClass"]="__withoutBorder";
|
|
|
15526 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
15527 |
#$conf["tdStart"]="false";
|
|
|
15528 |
#$conf["tdClass"],字串,行的樣式,"__withoutBorder"爲沒有框線的樣式;"__withBorder",有框線的樣式,預設為"__withoutBorder".
|
|
|
15529 |
#$conf["tdClass"]="__withoutBorder";
|
|
|
15530 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
15531 |
#$conf["tdEnd"]="true";
|
|
|
15532 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
15533 |
#$conf["trEnd"]="true";
|
|
|
15534 |
#$conf["form::uploadOneFile"]["formStart"],字串,是否為表單的開始,"true"為是,預設為"false".
|
|
|
15535 |
#$conf["form::uploadOneFile"]["formStart"]=$conf["formStart"];
|
|
|
15536 |
#$conf["form::uploadOneFile"]["formName"],字串,表單的名稱
|
|
|
15537 |
#$conf["form::uploadOneFile"]["formName"]=$conf["formName"];
|
|
|
15538 |
#$conf["form::uploadOneFile"]["formAction"],字串,表單的目標,若有設置$conf["formStart"]為"true",則預設為php檔案自己
|
|
|
15539 |
#$conf["form::uploadOneFile"]["formAction"]=$conf["formAction"];
|
|
|
15540 |
#$conf["form::uploadOneFile"]["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
15541 |
#$conf["form::uploadOneFile"]["formTarget"]=$conf["formTarget"];
|
|
|
15542 |
#$conf["form::uploadOneFile"]["formEnd"],字串,是否為表單的結束,"true"為是,預設為"false".
|
|
|
15543 |
#$conf["form::uploadOneFile"]["formEnd"]=$conf["formEnd"];
|
|
|
15544 |
|
|
|
15545 |
#如果有設定 $conf["comment"]
|
|
|
15546 |
if(isset($conf["comment"])){
|
|
|
15547 |
|
|
|
15548 |
#如果有設定 $conf["comment"][$i]
|
|
|
15549 |
if(isset($conf["comment"][$i])){
|
|
|
15550 |
|
|
|
15551 |
#$conf["form::uploadOneFile"]["comment"],字串,該上傳檔案的註解,預設不顯示.
|
|
|
15552 |
$conf["form::uploadOneFile"]["comment"]=$conf["comment"][$i];
|
|
|
15553 |
|
|
|
15554 |
}#if end
|
|
|
15555 |
|
|
|
15556 |
}#if end
|
|
|
15557 |
|
|
|
15558 |
$uploadOneFile=form::uploadOneFile($conf["form::uploadOneFile"]);
|
|
|
15559 |
unset($conf["form::uploadOneFile"]);
|
|
|
15560 |
|
|
|
15561 |
#如果 form::uploadOneFile 執行失敗
|
|
|
15562 |
if($uploadOneFile["status"]=="false"){
|
|
|
15563 |
|
|
|
15564 |
#設置執行失敗
|
|
|
15565 |
$result["status"]="false";
|
|
|
15566 |
|
|
|
15567 |
#設置錯誤訊息
|
|
|
15568 |
$result["error"]=$uploadOneFile;
|
|
|
15569 |
|
|
|
15570 |
#回傳結果
|
|
|
15571 |
return $result;
|
|
|
15572 |
|
|
|
15573 |
}#if end
|
|
|
15574 |
|
|
|
15575 |
#如果不是最後一筆
|
|
|
15576 |
if($i!=count($conf["formFileName"])-1){
|
|
|
15577 |
|
|
|
15578 |
#取得上傳的語法,結尾空一列.
|
|
|
15579 |
$result["content"]=$result["content"].$uploadOneFile["content"]."<p> </p>";
|
|
|
15580 |
|
|
|
15581 |
}#if end
|
|
|
15582 |
|
|
|
15583 |
#反之是最後一筆
|
|
|
15584 |
else{
|
|
|
15585 |
|
|
|
15586 |
#取得上傳的語法
|
|
|
15587 |
$result["content"]=$result["content"].$uploadOneFile["content"];
|
|
|
15588 |
|
|
|
15589 |
}#else end
|
|
|
15590 |
|
|
|
15591 |
}#for end
|
|
|
15592 |
|
|
|
15593 |
#設置執行正常
|
|
|
15594 |
$result["status"]="true";
|
|
|
15595 |
|
|
|
15596 |
#回傳結果
|
|
|
15597 |
return $result;
|
|
|
15598 |
|
|
|
15599 |
}#function uploadMultiFile end
|
|
|
15600 |
|
|
|
15601 |
/*
|
|
|
15602 |
#函式說明:
|
|
|
15603 |
#上傳多個檔案,包含回上頁跟送出表單的按鈕.
|
|
|
15604 |
#回傳結果:
|
|
|
15605 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15606 |
#$result["function"],當前執行的函數.
|
|
|
15607 |
#$result["error"],錯誤訊息陣列.
|
|
|
15608 |
#$result["content"],上傳檔案的語法.
|
|
|
15609 |
#必填參數:
|
|
|
15610 |
#$conf["formFileName"],字串陣列,該上傳檔案的表單名稱.
|
|
|
15611 |
$conf["formFileName"]=array("");
|
|
|
15612 |
#$conf["actionPage"],字串,處理表單資訊的頁面.
|
|
|
15613 |
$conf["actionPage"]="";
|
|
|
15614 |
#可省略參數:
|
|
|
15615 |
#$conf["backButtonName"],字串,退回上一頁的按鈕要顯示的名稱,預設爲"回上頁"
|
|
|
15616 |
#$conf["backButtonName"]="回上頁";
|
|
|
15617 |
#$conf["backPage"],字串,返回的按鈕點了之後要到哪個頁面,預設是不使用.
|
|
|
15618 |
#$conf["backPage"]="";
|
|
|
15619 |
#$conf["backTarget"],字串,返回按鈕的顯示區塊,可以為"_self"自己這個頁面,"_top"整個畫面,"_blank"新的分頁,"_parent"父頁面,預設為"_self".
|
|
|
15620 |
#$conf["backTarget"]="";
|
|
|
15621 |
#$conf["backButtonClass"],字串,回上頁按鈕的css樣式,預設為"__qbpwcf_button".
|
|
|
15622 |
#$conf["backButtonClass"]="__simpleButtonLinkDefaultButtonCssStyle";
|
|
|
15623 |
#$conf["formName"],字串,表單的名稱
|
|
|
15624 |
#$conf["formName"]="";
|
|
|
15625 |
#$conf["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
15626 |
#$conf["formTarget"]="_self";
|
|
|
15627 |
#$conf["acceptType"],字串陣列,限定各個檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
15628 |
#$conf["acceptType"]=array("");
|
|
|
15629 |
#$conf["comment"],字串陣列,各個上傳檔案的註解,預設不顯示.
|
|
|
15630 |
#$conf["comment"]=array("");
|
|
|
15631 |
#$conf["required"],字串陣列,各個欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
15632 |
#$conf["required"]=array("true");
|
|
|
15633 |
#$conf["maxFileSize"],字串陣列,各個檔案的最大限制,單位是位元組(byte),1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設爲"102400000"(100MB)
|
|
|
15634 |
#$conf["maxFileSize"]=array("102400000");
|
|
|
15635 |
#$conf["browseButtonClass"],字串陣列,瀏覽要上傳檔案的css樣式,預設為"__qbpwcf_inputFileCssStyle".
|
|
|
15636 |
#$conf["browseButtonClass"]=array("__inputFileCssStyle");
|
|
|
15637 |
#$conf["submitButtonClass"],字串,上傳按鈕的css樣式,預設為"__qbpwcf_button".
|
|
|
15638 |
#$conf["submitButtonClass"]="__simpleButtonLinkDefaultButtonCssStyle";
|
|
|
15639 |
#$conf["submitButtonName"],字串,送出鈕要顯示的名稱,預設爲"上傳"
|
|
|
15640 |
#$conf["submitButtonName"]="上傳";
|
|
|
15641 |
#參考資料:
|
|
|
15642 |
#無.
|
|
|
15643 |
#備註:
|
|
|
15644 |
#無.
|
|
|
15645 |
*/
|
|
|
15646 |
public static function uploadMultiFileCom(&$conf){
|
|
|
15647 |
|
|
|
15648 |
#初始化要回傳的變數
|
|
|
15649 |
$result=array();
|
|
|
15650 |
|
|
|
15651 |
#設置當前執行的函式
|
|
|
15652 |
$result["function"]=__FUNCTION__;
|
|
|
15653 |
|
|
|
15654 |
#初始化表單開始的語法
|
|
|
15655 |
$result["content"]="";
|
|
|
15656 |
|
|
|
15657 |
#如果 $conf 不為陣列
|
|
|
15658 |
if(gettype($conf)!="array"){
|
|
|
15659 |
|
|
|
15660 |
#設置執行失敗
|
|
|
15661 |
$result["status"]="false";
|
|
|
15662 |
|
|
|
15663 |
#設置執行錯誤訊息
|
|
|
15664 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
15665 |
|
|
|
15666 |
#如果傳入的參數為 null
|
|
|
15667 |
if($conf==null){
|
|
|
15668 |
|
|
|
15669 |
#設置執行錯誤訊息
|
|
|
15670 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
15671 |
|
|
|
15672 |
}#if end
|
|
|
15673 |
|
|
|
15674 |
#回傳結果
|
|
|
15675 |
return $result;
|
|
|
15676 |
|
|
|
15677 |
}#if end
|
|
|
15678 |
|
|
|
15679 |
#檢查參數
|
|
|
15680 |
#函式說明:
|
|
|
15681 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
15682 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15683 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
15684 |
#$result["function"],當前執行的函式名稱.
|
|
|
15685 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
15686 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
15687 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
15688 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
15689 |
#必填參數:
|
|
|
15690 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
15691 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
15692 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
15693 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("formFileName","actionPage");
|
|
|
15694 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
15695 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
|
|
|
15696 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
15697 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
15698 |
#可省略參數:
|
|
|
15699 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
15700 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
15701 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
15702 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("backButtonName","backPage","backTarget","backButtonClass","formName","formTarget","acceptType","comment","required","maxFileSize","browseButtonClass","submitButtonClass","submitButtonName");
|
|
|
15703 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
15704 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","array","array","array","array","array","string","string");
|
|
|
15705 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
15706 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("回上頁",null,"_self","__qbpwcf_button",null,"_self",null,null,null,null,null,"__qbpwcf_button","上傳");
|
|
|
15707 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
15708 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
15709 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
15710 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
15711 |
|
|
|
15712 |
#如果檢查參數失敗
|
|
|
15713 |
if($checkResult["status"]=="false"){
|
|
|
15714 |
|
|
|
15715 |
#設置執行失敗
|
|
|
15716 |
$result["status"]="false";
|
|
|
15717 |
|
|
|
15718 |
#設置執行錯誤
|
|
|
15719 |
$result["error"]=$checkResult;
|
|
|
15720 |
|
|
|
15721 |
#回傳結果
|
|
|
15722 |
return $result;
|
|
|
15723 |
|
|
|
15724 |
}#if end
|
|
|
15725 |
|
|
|
15726 |
#如果檢查參數不通過
|
|
|
15727 |
if($checkResult["passed"]=="false"){
|
|
|
15728 |
|
|
|
15729 |
#設置執行失敗
|
|
|
15730 |
$result["status"]="false";
|
|
|
15731 |
|
|
|
15732 |
#設置執行錯誤
|
|
|
15733 |
$result["error"]=$checkResult;
|
|
|
15734 |
|
|
|
15735 |
#回傳結果
|
|
|
15736 |
return $result;
|
|
|
15737 |
|
|
|
15738 |
}#if end
|
|
|
15739 |
|
|
|
15740 |
#函式說明:
|
|
|
15741 |
#上傳多個檔案
|
|
|
15742 |
#回傳結果:
|
|
|
15743 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15744 |
#$result["function"],當前執行的函數.
|
|
|
15745 |
#$result["error"],錯誤訊息陣列.
|
|
|
15746 |
#$result["content"],上傳檔案的語法.
|
|
|
15747 |
#必填參數:
|
|
|
15748 |
#$conf["form::uploadMultiFile"]["formFileName"],字串陣列,每個要上傳檔案的表單名稱.
|
|
|
15749 |
$conf["form::uploadMultiFile"]["formFileName"]=$conf["formFileName"];
|
|
|
15750 |
#可省略參數:
|
|
|
15751 |
|
|
|
15752 |
#如果 $conf["maxFileSize"] 有設置
|
|
|
15753 |
if(isset($conf["maxFileSize"])){
|
|
|
15754 |
|
|
|
15755 |
#$conf["form::uploadMultiFile"]["maxFileSize"],字串陣列,各個檔案的最大限制,單位是位元組(byte)。1kb = 1024 byte ; 1mb = 1024 kb 約等與 1024000 byte,預設是10240000(10MB)
|
|
|
15756 |
$conf["form::uploadMultiFile"]["maxFileSize"]=$conf["maxFileSize"];
|
|
|
15757 |
|
|
|
15758 |
}#if end
|
|
|
15759 |
|
|
|
15760 |
#如果有設置 $conf["browseButtonClass"]
|
|
|
15761 |
if(isset($conf["browseButtonClass"])){
|
|
|
15762 |
|
|
|
15763 |
#$conf["form::uploadMultiFile"]["browseButtonClass"],字串陣列,瀏覽檔案的按鈕樣式,預設為"__inputFileCssStyle".
|
|
|
15764 |
$conf["form::uploadMultiFile"]["browseButtonClass"]=$conf["browseButtonClass"];
|
|
|
15765 |
|
|
|
15766 |
}#if end
|
|
|
15767 |
|
|
|
15768 |
#如果有設置 $conf["acceptType"]
|
|
|
15769 |
if(isset($conf["acceptType"])){
|
|
|
15770 |
|
|
|
15771 |
#$conf["form::uploadMultiFile"]["acceptType"],字串陣列,限定各個檔案的類型為"video/*","audio/*","image/*",預設不限定.
|
|
|
15772 |
$conf["form::uploadMultiFile"]["acceptType"]=$conf["acceptType"];
|
|
|
15773 |
|
|
|
15774 |
}#if end
|
|
|
15775 |
|
|
|
15776 |
#如果有設置 $conf["required"]
|
|
|
15777 |
if(isset($conf["required"])){
|
|
|
15778 |
|
|
|
15779 |
#$conf["form::uploadMultiFile"]["required"],字串陣列,各個欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
15780 |
$conf["form::uploadMultiFile"]["required"]=$conf["required"];
|
|
|
15781 |
|
|
|
15782 |
}#if end
|
|
|
15783 |
|
|
|
15784 |
#如果有設置 $conf["comment"]
|
|
|
15785 |
if(isset($conf["comment"])){
|
|
|
15786 |
|
|
|
15787 |
#$conf["form::uploadMultiFile"]["comment"],字串陣列,各個上傳檔案的註解,預設不顯示.
|
|
|
15788 |
$conf["form::uploadMultiFile"]["comment"]=$conf["comment"];
|
|
|
15789 |
|
|
|
15790 |
}#if end
|
|
|
15791 |
|
|
|
15792 |
#$conf["form::uploadMultiFile"]["formStart"],字串,是否為表單的開始,"true"為是,預設為"false".
|
|
|
15793 |
$conf["form::uploadMultiFile"]["formStart"]="true";
|
|
|
15794 |
|
|
|
15795 |
#如果有設置 $conf["formName"]
|
|
|
15796 |
if(isset($conf["formName"])){
|
|
|
15797 |
|
|
|
15798 |
#$conf["form::uploadMultiFile"]["formName"],字串,表單的名稱
|
|
|
15799 |
$conf["form::uploadMultiFile"]["formName"]=$conf["formName"];
|
|
|
15800 |
|
|
|
15801 |
}#if end
|
|
|
15802 |
|
|
|
15803 |
#$conf["form::uploadMultiFile"]["formAction"],字串,表單的目標,若有設置$conf["formStart"]為"true",則預設為php檔案自己
|
|
|
15804 |
$conf["form::uploadMultiFile"]["formAction"]=$conf["actionPage"];
|
|
|
15805 |
|
|
|
15806 |
#如果有設置 $conf["formTarget"]
|
|
|
15807 |
if(isset($conf["formTarget"])){
|
|
|
15808 |
|
|
|
15809 |
#$conf["form::uploadMultiFile"]["formTarget"],字串,表單要呈現回應的位置,預設為"_self".
|
|
|
15810 |
$conf["form::uploadMultiFile"]["formTarget"]=$conf["formTarget"];
|
|
|
15811 |
|
|
|
15812 |
}#if end
|
|
|
15813 |
|
|
|
15814 |
$uploadMultiFile=form::uploadMultiFile($conf["form::uploadMultiFile"]);
|
|
|
15815 |
unset($conf["form::uploadMultiFile"]);
|
|
|
15816 |
|
|
|
15817 |
#如果執行 form::uploadMultiFile 失敗
|
|
|
15818 |
if($uploadMultiFile["status"]=="false"){
|
|
|
15819 |
|
|
|
15820 |
#設置執行失敗
|
|
|
15821 |
$result["status"]="false";
|
|
|
15822 |
|
|
|
15823 |
#設置執行錯誤
|
|
|
15824 |
$result["error"]=$uploadMultiFile;
|
|
|
15825 |
|
|
|
15826 |
#回傳結果
|
|
|
15827 |
return $result;
|
|
|
15828 |
|
|
|
15829 |
}#if end
|
|
|
15830 |
|
|
|
15831 |
#串接多個上傳表單的內容
|
|
|
15832 |
$result["content"]=$result["content"].$uploadMultiFile["content"];
|
|
|
15833 |
|
|
|
15834 |
#建立送出的按鈕
|
|
|
15835 |
#函式說明:
|
|
|
15836 |
#放置按鈕
|
|
|
15837 |
#回傳結果:
|
|
|
15838 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15839 |
#$result["function"],當前執行的函數.
|
|
|
15840 |
#$result["error"],錯誤訊息陣列.
|
|
|
15841 |
#$result["content"],按鈕語法.
|
|
|
15842 |
#必填參數:
|
|
|
15843 |
$conf["form::button"]["buttonDisplayValue"]=$conf["submitButtonName"];#爲按鈕上顯示的文字。
|
|
|
15844 |
#可省略參數:
|
|
|
15845 |
#$conf["buttonStyleName"]="";#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __simpleButtonLinkDefaultButtonCssStyle 。
|
|
|
15846 |
#其屬性爲 "width","height","font-size","text-align"
|
|
|
15847 |
#其屬性值爲 "100%" , "50" , "30" , "center"
|
|
|
15848 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式,預設不設定。
|
|
|
15849 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
15850 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
15851 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
15852 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
15853 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
15854 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
15855 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
15856 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
15857 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
15858 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
15859 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
15860 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
15861 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
15862 |
#$conf["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
15863 |
#$conf["action"]="";#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
15864 |
#$conf["target"]="";#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
15865 |
$conf["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
15866 |
#參考資料:
|
|
|
15867 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
15868 |
$button=form::button($conf["form::button"]);
|
|
|
15869 |
unset($conf["form::button"]);
|
|
|
15870 |
|
|
|
15871 |
#如果建立送出按鈕失敗
|
|
|
15872 |
if($button["status"]=="false"){
|
|
|
15873 |
|
|
|
15874 |
#設置執行失敗
|
|
|
15875 |
$result["status"]="false";
|
|
|
15876 |
|
|
|
15877 |
#設置執行錯誤
|
|
|
15878 |
$result["error"]=$button;
|
|
|
15879 |
|
|
|
15880 |
#回傳結果
|
|
|
15881 |
return $result;
|
|
|
15882 |
|
|
|
15883 |
}#if end
|
|
|
15884 |
|
|
|
15885 |
#空一列然後串接送出按鈕
|
|
|
15886 |
$result["content"]=$result["content"]."<p> </p>".$button["content"];
|
|
|
15887 |
|
|
|
15888 |
#設置執行正常
|
|
|
15889 |
$result["status"]="true";
|
|
|
15890 |
|
|
|
15891 |
#回傳結果
|
|
|
15892 |
return $result;
|
|
|
15893 |
|
|
|
15894 |
}#function uploadMultiFileCom end
|
|
|
15895 |
|
|
|
15896 |
/*
|
|
|
15897 |
#函式說明:
|
|
|
15898 |
#將接收到的表單資訊用serialize壓縮成一字串.
|
|
|
15899 |
#回傳結果:
|
|
|
15900 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15901 |
#$result["function"],當前執行的函數.
|
|
|
15902 |
#$result["error"],錯誤訊息陣列.
|
|
|
15903 |
#$result["content"],serialize後的表單資料字串.
|
|
|
15904 |
#必填參數:
|
|
|
15905 |
#無
|
|
|
15906 |
#可省略參數:
|
|
|
15907 |
#$conf["type"],接收的表單傳送方式,可以用的有"post","get","any",預設為 "any".
|
|
|
15908 |
#$conf["type"]="any";
|
|
|
15909 |
#參考資料:
|
|
|
15910 |
#serialize=>http://php.net/manual/en/function.serialize.php
|
|
|
15911 |
#備註:
|
|
|
15912 |
#無.
|
|
|
15913 |
*/
|
|
|
15914 |
public static function serialize(&$conf=array()){
|
|
|
15915 |
|
|
|
15916 |
#初始化要回傳的結果
|
|
|
15917 |
$result=array();
|
|
|
15918 |
|
|
|
15919 |
#取得當前執行的函數名稱
|
|
|
15920 |
$result["function"]=__FUNCTION__;
|
|
|
15921 |
|
|
|
15922 |
#如果 $conf 不為陣列
|
|
|
15923 |
if(gettype($conf)!="array"){
|
|
|
15924 |
|
|
|
15925 |
#設置執行失敗
|
|
|
15926 |
$result["status"]="false";
|
|
|
15927 |
|
|
|
15928 |
#設置執行錯誤訊息
|
|
|
15929 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
15930 |
|
|
|
15931 |
#如果傳入的參數為 null
|
|
|
15932 |
if($conf==null){
|
|
|
15933 |
|
|
|
15934 |
#設置執行錯誤訊息
|
|
|
15935 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
15936 |
|
|
|
15937 |
}#if end
|
|
|
15938 |
|
|
|
15939 |
#回傳結果
|
|
|
15940 |
return $result;
|
|
|
15941 |
|
|
|
15942 |
}#if end
|
|
|
15943 |
|
|
|
15944 |
#檢查可省略參數
|
|
|
15945 |
#函式說明:
|
|
|
15946 |
#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
|
|
|
15947 |
#回傳結果:
|
|
|
15948 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
15949 |
#$result["error"],錯誤訊息陣列.
|
|
|
15950 |
#$result["function"],當前執行的函式名稱.
|
|
|
15951 |
#$result["passed"],參數是否都通過檢查,"true",代表有通過檢查,"false"代表沒有通過檢查。
|
|
|
15952 |
#必填參數:
|
|
|
15953 |
#$conf["checkedVar"],陣列,要檢查的變數陣列名稱為?
|
|
|
15954 |
$conf["heck::checkSkipableVarType"]["checkedVar"]=$conf;
|
|
|
15955 |
#$conf["sikpableVarNameArray"],字串陣列,要檢查型態是否設定正確的變數名稱陣列.
|
|
|
15956 |
$conf["heck::checkSkipableVarType"]["sikpableVarNameArray"]=array("type");
|
|
|
15957 |
#$argu,要直接存取的陣列變數名稱,變數前面加上「&」,如果要在別的函式裡面使用本函式,請記得將變動過結果($argu)給使用該函式的設定變數(通常是$conf=$argu).
|
|
|
15958 |
$argu=&$conf["heck::checkSkipableVarType"];
|
|
|
15959 |
#可省略參數:
|
|
|
15960 |
#$conf["skipableVarTypeArray"],字串陣列,要檢查的每個變數,其型態應該要為何,null代表不指定變數形態.
|
|
|
15961 |
$conf["heck::checkSkipableVarType"]["skipableVarTypeArray"]=array("array");
|
|
|
15962 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.
|
|
|
15963 |
$conf["heck::checkSkipableVarType"]["skipableVarDefaultValue"]=array("any");
|
|
|
15964 |
$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["heck::checkSkipableVarType"],$argu);
|
|
|
15965 |
unset($conf["heck::checkSkipableVarType"]);
|
|
|
15966 |
$conf=$argu;
|
|
|
15967 |
|
|
|
15968 |
#如果檢查參數失敗
|
|
|
15969 |
if($checkSkipableVarType["status"]=="false"){
|
|
|
15970 |
|
|
|
15971 |
#設置執行失敗
|
|
|
15972 |
$result["status"]="false";
|
|
|
15973 |
|
|
|
15974 |
#設置執行錯誤訊息
|
|
|
15975 |
$result["error"]=$checkSkipableVarType;
|
|
|
15976 |
|
|
|
15977 |
#回傳結果
|
|
|
15978 |
return $result;
|
|
|
15979 |
|
|
|
15980 |
}#if end
|
|
|
15981 |
|
|
|
15982 |
#判斷 $conf["type"]
|
|
|
15983 |
switch($conf["type"]){
|
|
|
15984 |
|
|
|
15985 |
#如果是 post, POST
|
|
|
15986 |
case "post":
|
|
|
15987 |
case "POST":
|
|
|
15988 |
|
|
|
15989 |
#取得 serialize 後的post表單資料
|
|
|
15990 |
$result["content"]=serialize($_POST);
|
|
|
15991 |
break;
|
|
|
15992 |
|
|
|
15993 |
#如果是 get, GET
|
|
|
15994 |
case "get":
|
|
|
15995 |
case "GET":
|
|
|
15996 |
|
|
|
15997 |
#取得 serialize 後的get表單資料
|
|
|
15998 |
$result["content"]=serialize($_GET);
|
|
|
15999 |
break;
|
|
|
16000 |
|
|
|
16001 |
#如果是 any
|
|
|
16002 |
case "any":
|
|
|
16003 |
|
|
|
16004 |
#取得 serialize 後的表單資料
|
|
|
16005 |
$result["content"]=serialize($_REQUEST);
|
|
|
16006 |
break;
|
|
|
16007 |
default:
|
|
|
16008 |
|
|
|
16009 |
#設置錯誤識別
|
|
|
16010 |
$result["status"]="false";
|
|
|
16011 |
|
|
|
16012 |
#設置錯誤訊息
|
|
|
16013 |
$result["error"]="參數 \"type\" 僅能為 post,get,any 之一";
|
|
|
16014 |
|
|
|
16015 |
#回傳結果
|
|
|
16016 |
return $result;
|
|
|
16017 |
|
|
|
16018 |
}#switch end
|
|
|
16019 |
|
|
|
16020 |
#設置執行正常
|
|
|
16021 |
$result["status"]="true";
|
|
|
16022 |
|
|
|
16023 |
#回傳結果
|
|
|
16024 |
return $result;
|
|
|
16025 |
|
|
|
16026 |
}#function serialize end
|
|
|
16027 |
|
|
|
16028 |
/*
|
|
|
16029 |
#函式說明:
|
|
|
16030 |
#將接收到的受到serialize壓縮成一字串的表單資訊進行還原
|
|
|
16031 |
#回傳結果:
|
|
|
16032 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16033 |
#$result["function"],當前執行的函數.
|
|
|
16034 |
#$result["error"],錯誤訊息陣列.
|
|
|
16035 |
#$result["content"],serialize後的表單資料字串.
|
|
|
16036 |
#必填參數:
|
|
|
16037 |
#$conf["serial_FD_str"],透過serialize壓縮過的表單資料
|
|
|
16038 |
$conf["serial_FD_str"]="";
|
|
|
16039 |
#可省略參數:
|
|
|
16040 |
#無
|
|
|
16041 |
#參考資料:
|
|
|
16042 |
#serialize=>http://php.net/manual/en/function.serialize.php
|
|
|
16043 |
#備註:
|
|
|
16044 |
#無.
|
|
|
16045 |
*/
|
|
|
16046 |
public static function unserialize(&$conf){
|
|
|
16047 |
|
|
|
16048 |
#初始化要回傳的結果
|
|
|
16049 |
$result=array();
|
|
|
16050 |
|
|
|
16051 |
#取得當前執行的函數名稱
|
|
|
16052 |
$result["function"]=__FUNCTION__;
|
|
|
16053 |
|
|
|
16054 |
#如果沒有參數
|
|
|
16055 |
if(func_num_args()==0){
|
|
|
16056 |
|
|
|
16057 |
#設置執行失敗
|
|
|
16058 |
$result["status"]="false";
|
|
|
16059 |
|
|
|
16060 |
#設置執行錯誤訊息
|
|
|
16061 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
16062 |
|
|
|
16063 |
#回傳結果
|
|
|
16064 |
return $result;
|
|
|
16065 |
|
|
|
16066 |
}#if end
|
|
|
16067 |
|
|
|
16068 |
#如果 $conf 不為陣列
|
|
|
16069 |
if(gettype($conf)!="array"){
|
|
|
16070 |
|
|
|
16071 |
#設置執行失敗
|
|
|
16072 |
$result["status"]="false";
|
|
|
16073 |
|
|
|
16074 |
#設置執行錯誤訊息
|
|
|
16075 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
16076 |
|
|
|
16077 |
#如果傳入的參數為 null
|
|
|
16078 |
if($conf==null){
|
|
|
16079 |
|
|
|
16080 |
#設置執行錯誤訊息
|
|
|
16081 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
16082 |
|
|
|
16083 |
#回傳結果
|
|
|
16084 |
return $result;
|
|
|
16085 |
|
|
|
16086 |
}#if end
|
|
|
16087 |
|
|
|
16088 |
}#if end
|
|
|
16089 |
|
|
|
16090 |
#檢查參數
|
|
|
16091 |
#函式說明:
|
|
|
16092 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
16093 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16094 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
16095 |
#$result["function"],當前執行的函式名稱.
|
|
|
16096 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
16097 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
16098 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
16099 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
16100 |
#必填參數:
|
|
|
16101 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
16102 |
$conf["variableCheck.checkArguments"]["varInput"]=&$conf;
|
|
|
16103 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
16104 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableName"]=array("serial_FD_str");
|
|
|
16105 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
16106 |
$conf["variableCheck.checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
16107 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
16108 |
$conf["variableCheck.checkArguments"]["referenceVarKey"]="variableCheck.checkArguments";
|
|
|
16109 |
#可省略參數:
|
|
|
16110 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"false"。
|
|
|
16111 |
#$conf["variableCheck.checkArguments"]["canBeEmptyString"]="true";
|
|
|
16112 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
16113 |
#$conf["skipableVariableName"]=array();
|
|
|
16114 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
16115 |
#$conf["skipableVariableType"]=array();
|
|
|
16116 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定.
|
|
|
16117 |
#$conf["skipableVarDefaultValue"]=array("");
|
|
|
16118 |
$checkResult=variableCheck::checkArguments($conf["variableCheck.checkArguments"]);
|
|
|
16119 |
unset($conf["variableCheck.checkArguments"]);
|
|
|
16120 |
|
|
|
16121 |
#如果檢查失敗
|
|
|
16122 |
if($checkResult["status"]=="false"){
|
|
|
16123 |
|
|
|
16124 |
#設置執行不正常
|
|
|
16125 |
$result["status"]="false";
|
|
|
16126 |
|
|
|
16127 |
#程式停止執行
|
|
|
16128 |
$result["error"]=$checkResult;
|
|
|
16129 |
|
|
|
16130 |
#回傳結果
|
|
|
16131 |
return $result;
|
|
|
16132 |
|
|
|
16133 |
}#if end
|
|
|
16134 |
|
|
|
16135 |
#如果檢查不通過
|
|
|
16136 |
if($checkResult["passed"]=="false"){
|
|
|
16137 |
|
|
|
16138 |
#設置執行不正常
|
|
|
16139 |
$result["status"]="false";
|
|
|
16140 |
|
|
|
16141 |
#程式停止執行
|
|
|
16142 |
$result["error"]=$checkResult;
|
|
|
16143 |
|
|
|
16144 |
#回傳結果
|
|
|
16145 |
return $result;
|
|
|
16146 |
|
|
|
16147 |
}#if end
|
|
|
16148 |
|
|
|
16149 |
#取得解開的表單資料
|
|
|
16150 |
$result["content"]=unserialize($conf["serial_FD_str"]);
|
|
|
16151 |
|
|
|
16152 |
#設置執行正常
|
|
|
16153 |
$result["status"]="true";
|
|
|
16154 |
|
|
|
16155 |
#回傳結果
|
|
|
16156 |
return $result;
|
|
|
16157 |
|
|
|
16158 |
}#function unserialize end
|
|
|
16159 |
|
|
|
16160 |
/*
|
|
|
16161 |
#函式說明:
|
|
|
16162 |
#判斷當前php檔的執行是否為ajax的要求.
|
|
|
16163 |
#回傳結果:
|
|
|
16164 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16165 |
#$result["function"],當前執行的函數.
|
|
|
16166 |
#$result["content"],是否為ajax要求,"true"代表是,"false"代表不是.
|
|
|
16167 |
#$result["argu"],使用的參數.
|
|
|
16168 |
#可省略參數:
|
|
|
16169 |
#$conf["useGetVarToRecogniseAjaxRequest"],字串,用來識別是否為ajax要求的get變數名稱,若其值為"true"則代表為ajax要求,反之為"false",判斷好後會將該變數移除.
|
|
|
16170 |
#$conf["useGetVarToRecogniseAjaxRequest"]="is_ajax";
|
|
|
16171 |
#$conf["usePostVarToRecogniseAjaxRequest"],字串,用來識別是否為ajax要求的post變數名稱,若其值為"true"則代表為ajax要求,反之為"false",判斷好後會將該變數移除.
|
|
|
16172 |
#$conf["usePostVarToRecogniseAjaxRequest"]="is_ajax";
|
|
|
16173 |
#參考資料:
|
|
|
16174 |
#無.
|
|
|
16175 |
#備註:
|
|
|
16176 |
#如果client端沒有傳送ajax要求的識別header,則無法識別是ajax要求.
|
|
|
16177 |
*/
|
|
|
16178 |
public static function is_ajax(&$conf=array()){
|
|
|
16179 |
|
|
|
16180 |
#初始化要回傳的結果
|
|
|
16181 |
$result=array();
|
|
|
16182 |
|
|
|
16183 |
#取得當前執行的函數名稱
|
|
|
16184 |
$result["function"]=__FUNCTION__;
|
|
|
16185 |
|
|
|
16186 |
#取得參數
|
|
|
16187 |
$result["argu"]=$conf;
|
|
|
16188 |
|
|
|
16189 |
#如果 $conf 不為陣列
|
|
|
16190 |
if(gettype($conf)!="array"){
|
|
|
16191 |
|
|
|
16192 |
#設置執行失敗
|
|
|
16193 |
$result["status"]="false";
|
|
|
16194 |
|
|
|
16195 |
#設置執行錯誤訊息
|
|
|
16196 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
16197 |
|
|
|
16198 |
#如果傳入的參數為 null
|
|
|
16199 |
if($conf==null){
|
|
|
16200 |
|
|
|
16201 |
#設置執行錯誤訊息
|
|
|
16202 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
16203 |
|
|
|
16204 |
}#if end
|
|
|
16205 |
|
|
|
16206 |
#回傳結果
|
|
|
16207 |
return $result;
|
|
|
16208 |
|
|
|
16209 |
}#if end
|
|
|
16210 |
|
|
|
16211 |
#檢查參數
|
|
|
16212 |
#函式說明:
|
|
|
16213 |
#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
|
|
|
16214 |
#回傳結果:
|
|
|
16215 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16216 |
#$result["error"],錯誤訊息陣列.
|
|
|
16217 |
#$result["function"],當前執行的函式名稱.
|
|
|
16218 |
#$result["passed"],參數是否都通過檢查,"true",代表有通過檢查,"false"代表沒有通過檢查。
|
|
|
16219 |
#必填參數:
|
|
|
16220 |
#$conf["checkedVar"],陣列,要檢查的變數陣列名稱為?
|
|
|
16221 |
$conf["variableCheck::checkSkipableVarType"]["checkedVar"]=$conf;
|
|
|
16222 |
#$conf["sikpableVarNameArray"],字串陣列,要檢查型態是否設定正確的變數名稱陣列.
|
|
|
16223 |
$conf["variableCheck::checkSkipableVarType"]["sikpableVarNameArray"]=array("useGetVarToRecogniseAjaxRequest","usePostVarToRecogniseAjaxRequest");
|
|
|
16224 |
#$argu,要直接存取的陣列變數名稱,變數前面加上「&」,如果要在別的函式裡面使用本函式,請記得將變動過結果($argu)給使用該函式的設定變數(通常是$conf=$argu).
|
|
|
16225 |
$argu=&$conf;
|
|
|
16226 |
#可省略參數:
|
|
|
16227 |
#$conf["skipableVarTypeArray"],字串陣列,要檢查的每個變數,其型態應該要為何,null代表不指定變數形態.
|
|
|
16228 |
$conf["variableCheck::checkSkipableVarType"]["skipableVarTypeArray"]=array("string","string");
|
|
|
16229 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.
|
|
|
16230 |
$conf["variableCheck::checkSkipableVarType"]["skipableVarDefaultValue"]=array(null,null);
|
|
|
16231 |
$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["variableCheck::checkSkipableVarType"],$argu);
|
|
|
16232 |
unset($conf["variableCheck::checkSkipableVarType"]);
|
|
|
16233 |
|
|
|
16234 |
#如果檢查失敗
|
|
|
16235 |
if($checkSkipableVarType["status"]=="false"){
|
|
|
16236 |
|
|
|
16237 |
#設置執行不正常
|
|
|
16238 |
$result["status"]="false";
|
|
|
16239 |
|
|
|
16240 |
#程式停止執行
|
|
|
16241 |
$result["error"]=$checkSkipableVarType;
|
|
|
16242 |
|
|
|
16243 |
#回傳結果
|
|
|
16244 |
return $result;
|
|
|
16245 |
|
|
|
16246 |
}#if end
|
|
|
16247 |
|
|
|
16248 |
#如果檢查不通過
|
|
|
16249 |
if($checkSkipableVarType["passed"]=="false"){
|
|
|
16250 |
|
|
|
16251 |
#設置執行不正常
|
|
|
16252 |
$result["status"]="false";
|
|
|
16253 |
|
|
|
16254 |
#程式停止執行
|
|
|
16255 |
$result["error"]=$checkSkipableVarType;
|
|
|
16256 |
|
|
|
16257 |
#回傳結果
|
|
|
16258 |
return $result;
|
|
|
16259 |
|
|
|
16260 |
}#if end
|
|
|
16261 |
|
|
|
16262 |
#如果存在 $conf["useGetVarToRecogniseAjaxRequest"]
|
|
|
16263 |
if(isset($conf["useGetVarToRecogniseAjaxRequest"])){
|
|
|
16264 |
|
|
|
16265 |
#如果存在 $_GET[$conf["useGetVarToRecogniseAjaxRequest"]]
|
|
|
16266 |
if(isset($_GET[$conf["useGetVarToRecogniseAjaxRequest"]])){
|
|
|
16267 |
|
|
|
16268 |
#如果 $_GET[$conf["useGetVarToRecogniseAjaxRequest"]] 為 "true"
|
|
|
16269 |
if($_GET[$conf["useGetVarToRecogniseAjaxRequest"]]==="true"){
|
|
|
16270 |
|
|
|
16271 |
#設置為ajax要求
|
|
|
16272 |
$result["content"]="true";
|
|
|
16273 |
|
|
|
16274 |
#移除識別 ajax 要求的 post 變數
|
|
|
16275 |
unset($_GET[$conf["useGetVarToRecogniseAjaxRequest"]]);
|
|
|
16276 |
|
|
|
16277 |
}#if end
|
|
|
16278 |
|
|
|
16279 |
}#if end
|
|
|
16280 |
|
|
|
16281 |
}#if end
|
|
|
16282 |
|
|
|
16283 |
#反之如果存在 $conf["usePostVarToRecogniseAjaxRequest"]
|
|
|
16284 |
else if(isset($conf["usePostVarToRecogniseAjaxRequest"])){
|
|
|
16285 |
|
|
|
16286 |
#如果存在 $_POST[$conf["usePostVarToRecogniseAjaxRequest"]]
|
|
|
16287 |
if(isset($_POST[$conf["usePostVarToRecogniseAjaxRequest"]])){
|
|
|
16288 |
|
|
|
16289 |
#如果 $_POST[$conf["usePostVarToRecogniseAjaxRequest"]] 為 "true"
|
|
|
16290 |
if($_POST[$conf["usePostVarToRecogniseAjaxRequest"]]==="true"){
|
|
|
16291 |
|
|
|
16292 |
#設置為ajax要求
|
|
|
16293 |
$result["content"]="true";
|
|
|
16294 |
|
|
|
16295 |
#移除識別 ajax 要求的 post 變數
|
|
|
16296 |
unset($_POST[$conf["usePostVarToRecogniseAjaxRequest"]]);
|
|
|
16297 |
|
|
|
16298 |
}#if end
|
|
|
16299 |
|
|
|
16300 |
}#if end
|
|
|
16301 |
|
|
|
16302 |
}#if end
|
|
|
16303 |
|
|
|
16304 |
#如果存在 $_SERVER['HTTP_X_REQUESTED_WITH']
|
|
|
16305 |
else if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
|
|
|
16306 |
|
|
|
16307 |
#且其 $_SERVER['HTTP_X_REQUESTED_WITH'] 值為 'xmlhttprequest'
|
|
|
16308 |
if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])==='xmlhttprequest'){
|
|
|
16309 |
|
|
|
16310 |
#設置為ajax要求
|
|
|
16311 |
$result["content"]="true";
|
|
|
16312 |
|
|
|
16313 |
}#if end
|
|
|
16314 |
|
|
|
16315 |
}#if end
|
|
|
16316 |
|
|
|
16317 |
#如果不存在 $result["content"]
|
|
|
16318 |
if(!isset($result["content"])){
|
|
|
16319 |
|
|
|
16320 |
#設置不為ajax要求
|
|
|
16321 |
$result["content"]="false";
|
|
|
16322 |
|
|
|
16323 |
}#if end
|
|
|
16324 |
|
|
|
16325 |
#設置執行正常
|
|
|
16326 |
$result["status"]="true";
|
|
|
16327 |
|
|
|
16328 |
#回傳結果
|
|
|
16329 |
return $result;
|
|
|
16330 |
|
|
|
16331 |
}#function is_ajax end
|
| 226 |
liveuser |
16332 |
|
| 3 |
liveuser |
16333 |
/*
|
|
|
16334 |
#函式說明:
|
|
|
16335 |
#水平拉霸
|
|
|
16336 |
#回傳結果:
|
|
|
16337 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16338 |
#$result["function"],當前執行的函數.
|
|
|
16339 |
#$result["content"],js語法.
|
|
|
16340 |
#$result["argu"],使用的參數.
|
|
|
16341 |
#必填參數:
|
|
|
16342 |
#$conf["name"],字串,拉霸的名稱,不可重複,會出錯。
|
|
|
16343 |
$conf["name"]="a";
|
|
|
16344 |
#可省略參數:
|
|
|
16345 |
#$conf["selectedColor"],字串,當前數值於bar上的顏色,預設為"orange".
|
|
|
16346 |
#$conf["selectedColor"]="orange";
|
|
|
16347 |
#$conf["unSelectedColor"],字串,非當前數值於bar上的顏色,預設為#d3d3d3.
|
|
|
16348 |
#$conf["unSelectedColor"]="#d3d3d3";
|
|
|
16349 |
#參考資料:
|
|
|
16350 |
#無.
|
|
|
16351 |
#備註:
|
|
|
16352 |
#會產生 window.qbpwcf.form.bar 物件.若要印出拉霸則可呼叫函式 window.qbpwcf.form.bar.print() 方法.若要存取變更拉霸的設定可呼叫 window.qbpwcf.form.bar.content 取得dom.
|
|
|
16353 |
*/
|
|
|
16354 |
public static function bar(&$conf=array()){
|
| 226 |
liveuser |
16355 |
|
| 3 |
liveuser |
16356 |
#初始化要回傳的結果
|
|
|
16357 |
$result=array();
|
|
|
16358 |
|
|
|
16359 |
#取得當前執行的函數名稱
|
|
|
16360 |
$result["function"]=__FUNCTION__;
|
|
|
16361 |
|
|
|
16362 |
#取得參數
|
|
|
16363 |
$result["argu"]=$conf;
|
|
|
16364 |
|
|
|
16365 |
#如果 $conf 不為陣列
|
|
|
16366 |
if(gettype($conf)!="array"){
|
|
|
16367 |
|
|
|
16368 |
#設置執行失敗
|
|
|
16369 |
$result["status"]="false";
|
|
|
16370 |
|
|
|
16371 |
#設置執行錯誤訊息
|
|
|
16372 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
16373 |
|
|
|
16374 |
#如果傳入的參數為 null
|
|
|
16375 |
if($conf==null){
|
|
|
16376 |
|
|
|
16377 |
#設置執行錯誤訊息
|
|
|
16378 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
16379 |
|
|
|
16380 |
}#if end
|
|
|
16381 |
|
|
|
16382 |
#回傳結果
|
|
|
16383 |
return $result;
|
|
|
16384 |
|
|
|
16385 |
}#if end
|
|
|
16386 |
|
|
|
16387 |
#檢查參數
|
|
|
16388 |
#函式說明:
|
|
|
16389 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
16390 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
16391 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
16392 |
#$result["function"],當前執行的函式名稱.
|
|
|
16393 |
#$result["argu"],設置給予的參數.
|
|
|
16394 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
16395 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
16396 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
16397 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
16398 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
16399 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
16400 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
16401 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
16402 |
#必填寫的參數:
|
|
|
16403 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
16404 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
16405 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
16406 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
16407 |
#可以省略的參數:
|
|
|
16408 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
16409 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name");
|
|
|
16410 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
16411 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
16412 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
16413 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
16414 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
16415 |
#$conf["canNotBeEmpty"]=array();
|
|
|
16416 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
16417 |
#$conf["canBeEmpty"]=array();
|
|
|
16418 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
16419 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("selectedColor","unSelectedColor");
|
|
|
16420 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
16421 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("selectedColor","unSelectedColor");
|
|
|
16422 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
16423 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
16424 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
16425 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("orange","#d3d3d3");
|
|
|
16426 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
16427 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
16428 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
16429 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
16430 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
16431 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
16432 |
#參考資料:
|
|
|
16433 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
16434 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
16435 |
unset($conf["variableCheck::checkArguments"]);
|
| 226 |
liveuser |
16436 |
|
| 3 |
liveuser |
16437 |
#若檢查參數失敗
|
|
|
16438 |
if($checkArguments["status"]==="false"){
|
| 226 |
liveuser |
16439 |
|
| 3 |
liveuser |
16440 |
#設置執行失敗
|
|
|
16441 |
$result["status"]="false";
|
| 226 |
liveuser |
16442 |
|
| 3 |
liveuser |
16443 |
#設置錯誤訊息
|
|
|
16444 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
16445 |
|
| 3 |
liveuser |
16446 |
#回傳結果
|
|
|
16447 |
return $result;
|
| 226 |
liveuser |
16448 |
|
| 3 |
liveuser |
16449 |
}#if end
|
| 226 |
liveuser |
16450 |
|
| 3 |
liveuser |
16451 |
#若檢查參數不通過
|
|
|
16452 |
if($checkArguments["passed"]==="false"){
|
| 226 |
liveuser |
16453 |
|
| 3 |
liveuser |
16454 |
#設置執行失敗
|
|
|
16455 |
$result["status"]="false";
|
| 226 |
liveuser |
16456 |
|
| 3 |
liveuser |
16457 |
#設置錯誤訊息
|
|
|
16458 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
16459 |
|
| 3 |
liveuser |
16460 |
#回傳結果
|
|
|
16461 |
return $result;
|
| 226 |
liveuser |
16462 |
|
| 3 |
liveuser |
16463 |
}#if end
|
| 226 |
liveuser |
16464 |
|
| 3 |
liveuser |
16465 |
#加入 js
|
|
|
16466 |
#函式說明:
|
|
|
16467 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
16468 |
#回傳結果:
|
|
|
16469 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
16470 |
#$result["error"],錯誤訊息陣列
|
|
|
16471 |
#$result["function"],當前執行的函數名稱
|
|
|
16472 |
#$result["content"],要執行的javaScript語法
|
|
|
16473 |
#必填參數:
|
|
|
16474 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
16475 |
$conf["javaScript::toScript"]["script"]=
|
|
|
16476 |
"
|
| 226 |
liveuser |
16477 |
|
| 3 |
liveuser |
16478 |
//確認變數存在 - start
|
|
|
16479 |
if(window.qbpwcf===undefined)
|
|
|
16480 |
{
|
|
|
16481 |
window.qbpwcf={};
|
|
|
16482 |
}
|
| 226 |
liveuser |
16483 |
|
| 3 |
liveuser |
16484 |
if(window.qbpwcf.form===undefined)
|
|
|
16485 |
{
|
|
|
16486 |
window.qbpwcf.form={};
|
|
|
16487 |
}
|
| 226 |
liveuser |
16488 |
|
| 3 |
liveuser |
16489 |
if(window.qbpwcf.form.bar===undefined)
|
|
|
16490 |
{
|
|
|
16491 |
window.qbpwcf.form.bar={};
|
|
|
16492 |
}
|
|
|
16493 |
//確認變數 - end
|
| 226 |
liveuser |
16494 |
|
| 3 |
liveuser |
16495 |
//建立 root div
|
|
|
16496 |
rootDiv=document.createElement('div');
|
|
|
16497 |
rootDiv.id='".$conf["name"]."rootDiv';
|
| 226 |
liveuser |
16498 |
|
| 3 |
liveuser |
16499 |
//建立 onoff div
|
|
|
16500 |
onoffDiv=document.createElement('div');
|
|
|
16501 |
onoffDiv.id='".$conf["name"]."onoffDiv';
|
| 226 |
liveuser |
16502 |
onoffDiv.style.width='200px';
|
|
|
16503 |
|
| 3 |
liveuser |
16504 |
//建立 off 的 div tag
|
|
|
16505 |
offDiv=document.createElement('div');
|
|
|
16506 |
offDiv.id='".$conf["name"]."off';
|
|
|
16507 |
offDiv.innerText='off ';
|
|
|
16508 |
offDiv.style.display='inline';
|
|
|
16509 |
offDiv.style.float='left';
|
| 226 |
liveuser |
16510 |
|
| 3 |
liveuser |
16511 |
//如果點擊了 off 字樣
|
|
|
16512 |
offDiv.addEventListener('click',function(e){
|
| 226 |
liveuser |
16513 |
|
| 3 |
liveuser |
16514 |
//一百次迴圈
|
|
|
16515 |
for(i=0;i<100;i++){
|
| 226 |
liveuser |
16516 |
|
| 3 |
liveuser |
16517 |
//取得該bar part
|
|
|
16518 |
thisBarPart=document.getElementById('".$conf["name"]."bar'+i);
|
| 226 |
liveuser |
16519 |
|
| 3 |
liveuser |
16520 |
//設置為灰色
|
| 226 |
liveuser |
16521 |
thisBarPart.style.borderColor='".$conf["unSelectedColor"]."';
|
|
|
16522 |
|
| 3 |
liveuser |
16523 |
}//for end
|
| 226 |
liveuser |
16524 |
|
| 3 |
liveuser |
16525 |
//取得 bar 數值
|
|
|
16526 |
barVal=document.getElementById('".$conf["name"]."barVal');
|
| 226 |
liveuser |
16527 |
|
| 3 |
liveuser |
16528 |
//設置為 '0%'
|
|
|
16529 |
barVal.innerText='0%';
|
| 226 |
liveuser |
16530 |
|
| 3 |
liveuser |
16531 |
//設置實際數值為 '0'
|
|
|
16532 |
barVal.dataset.val='0';
|
| 226 |
liveuser |
16533 |
|
| 3 |
liveuser |
16534 |
});
|
| 226 |
liveuser |
16535 |
|
| 3 |
liveuser |
16536 |
//放入off的文字
|
|
|
16537 |
onoffDiv.appendChild(offDiv);
|
| 226 |
liveuser |
16538 |
|
| 3 |
liveuser |
16539 |
//建立 on 的 div tag
|
|
|
16540 |
onDiv=document.createElement('div');
|
|
|
16541 |
onDiv.id='".$conf["name"]."on';
|
|
|
16542 |
onDiv.innerText=' on';
|
|
|
16543 |
onDiv.style.display='inline';
|
|
|
16544 |
onDiv.style.float='right';
|
| 226 |
liveuser |
16545 |
|
| 3 |
liveuser |
16546 |
//如果點擊了 on 字樣
|
|
|
16547 |
onDiv.addEventListener('click',function(e){
|
| 226 |
liveuser |
16548 |
|
| 3 |
liveuser |
16549 |
//一百次迴圈
|
|
|
16550 |
for(i=0;i<100;i++){
|
| 226 |
liveuser |
16551 |
|
| 3 |
liveuser |
16552 |
//取得該bar part
|
|
|
16553 |
thisBarPart=document.getElementById('".$conf["name"]."bar'+i);
|
| 226 |
liveuser |
16554 |
|
| 3 |
liveuser |
16555 |
//設置為灰色
|
| 226 |
liveuser |
16556 |
thisBarPart.style.borderColor='".$conf["unSelectedColor"]."';
|
|
|
16557 |
|
| 3 |
liveuser |
16558 |
}//for end
|
| 226 |
liveuser |
16559 |
|
| 3 |
liveuser |
16560 |
//取得 bar 數值
|
|
|
16561 |
barVal=document.getElementById('".$conf["name"]."barVal');
|
| 226 |
liveuser |
16562 |
|
| 3 |
liveuser |
16563 |
//設置為 '0%'
|
|
|
16564 |
barVal.innerText='on';
|
| 226 |
liveuser |
16565 |
|
| 3 |
liveuser |
16566 |
//設置實際數值為 '0'
|
|
|
16567 |
barVal.dataset.value='?';
|
| 226 |
liveuser |
16568 |
|
| 3 |
liveuser |
16569 |
});
|
| 226 |
liveuser |
16570 |
|
| 3 |
liveuser |
16571 |
//放入on的文字
|
|
|
16572 |
onoffDiv.appendChild(onDiv);
|
| 226 |
liveuser |
16573 |
|
| 3 |
liveuser |
16574 |
//建立 on 的 div tag
|
|
|
16575 |
div=document.createElement('div');
|
| 226 |
liveuser |
16576 |
|
| 3 |
liveuser |
16577 |
//放入空div
|
|
|
16578 |
rootDiv.appendChild(div);
|
| 226 |
liveuser |
16579 |
|
| 3 |
liveuser |
16580 |
//放入 on off div
|
|
|
16581 |
rootDiv.appendChild(onoffDiv);
|
| 226 |
liveuser |
16582 |
|
| 3 |
liveuser |
16583 |
//100次迴圈
|
|
|
16584 |
for(i=0;i<100;i++){
|
| 226 |
liveuser |
16585 |
|
| 3 |
liveuser |
16586 |
//建立拉霸
|
|
|
16587 |
line=document.createElement('div');
|
| 226 |
liveuser |
16588 |
|
| 3 |
liveuser |
16589 |
//設置拉霸樣式
|
|
|
16590 |
line.id='".$conf["name"]."bar'+i;
|
|
|
16591 |
line.dataset.val=i+1;
|
|
|
16592 |
line.style.borderStyle='solid';
|
|
|
16593 |
line.style.borderColor='".$conf["unSelectedColor"]."';
|
|
|
16594 |
line.style.borderWidth='1px';
|
| 226 |
liveuser |
16595 |
line.style.borderRadius='1px';
|
| 3 |
liveuser |
16596 |
line.style.display='inline';
|
|
|
16597 |
|
|
|
16598 |
//放入拉霸part
|
|
|
16599 |
rootDiv.appendChild(line);
|
| 226 |
liveuser |
16600 |
|
| 3 |
liveuser |
16601 |
//點擊事件
|
|
|
16602 |
line.addEventListener('click',function(e){
|
| 226 |
liveuser |
16603 |
|
| 3 |
liveuser |
16604 |
//一百次迴圈
|
|
|
16605 |
for(j=0;j<100;j++){
|
| 226 |
liveuser |
16606 |
|
| 3 |
liveuser |
16607 |
//取得該bar part
|
|
|
16608 |
thisBarPart=document.getElementById('".$conf["name"]."bar'+j);
|
| 226 |
liveuser |
16609 |
|
| 3 |
liveuser |
16610 |
//設置為灰色
|
| 226 |
liveuser |
16611 |
thisBarPart.style.borderColor='".$conf["unSelectedColor"]."';
|
|
|
16612 |
|
| 3 |
liveuser |
16613 |
}//for end
|
| 226 |
liveuser |
16614 |
|
| 3 |
liveuser |
16615 |
//選取的點設置為橘色
|
| 226 |
liveuser |
16616 |
e.target.style.borderColor='".$conf["selectedColor"]."';
|
|
|
16617 |
|
| 3 |
liveuser |
16618 |
//設置當前顯示的%數
|
|
|
16619 |
document.getElementById('".$conf["name"]."barVal').innerText=(e.target.dataset.val)+'%';
|
| 226 |
liveuser |
16620 |
|
| 3 |
liveuser |
16621 |
//設置當前顯示的%數值,不含單位
|
|
|
16622 |
document.getElementById('".$conf["name"]."barVal').dataset.val=e.target.dataset.val;
|
| 226 |
liveuser |
16623 |
|
| 3 |
liveuser |
16624 |
});//addEventListener end
|
| 226 |
liveuser |
16625 |
|
| 3 |
liveuser |
16626 |
}//for end
|
| 226 |
liveuser |
16627 |
|
| 3 |
liveuser |
16628 |
//建立 div tag,預設為 '?%'
|
|
|
16629 |
valDiv=document.createElement('div');
|
|
|
16630 |
valDiv.id='".$conf["name"]."barVal';
|
|
|
16631 |
valDiv.innerText='?%';
|
|
|
16632 |
valDiv.dataset.val='?';
|
|
|
16633 |
valDiv.style.display='inline';
|
| 226 |
liveuser |
16634 |
|
| 3 |
liveuser |
16635 |
//放入數值顯示
|
|
|
16636 |
rootDiv.appendChild(valDiv);
|
| 226 |
liveuser |
16637 |
|
| 3 |
liveuser |
16638 |
//取得 拉霸的名稱
|
|
|
16639 |
window.qbpwcf.form.bar.name='".$conf["name"]."';
|
| 226 |
liveuser |
16640 |
|
| 3 |
liveuser |
16641 |
//取得 拉霸的語法
|
|
|
16642 |
window.qbpwcf.form.bar.content=rootDiv;
|
| 226 |
liveuser |
16643 |
|
| 3 |
liveuser |
16644 |
//設置印出 拉霸的語法
|
|
|
16645 |
window.qbpwcf.form.bar.print=function(){
|
| 226 |
liveuser |
16646 |
|
| 3 |
liveuser |
16647 |
//放置root div
|
|
|
16648 |
document.body.appendChild(window.qbpwcf.form.bar.content);
|
| 226 |
liveuser |
16649 |
|
| 3 |
liveuser |
16650 |
}//function end
|
| 226 |
liveuser |
16651 |
|
| 3 |
liveuser |
16652 |
";
|
|
|
16653 |
#可省略參數:
|
|
|
16654 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
16655 |
#$conf["onReady"]="true";
|
|
|
16656 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
16657 |
#$conf["globalJs"]=array();
|
|
|
16658 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
16659 |
#$conf["jsFunciton"]=array();
|
|
|
16660 |
#參考資料:
|
|
|
16661 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
| 226 |
liveuser |
16662 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
16663 |
$result["scriptWithoutTag"]=$conf["javaScript::toScript"]["script"];
|
| 3 |
liveuser |
16664 |
unset($conf["javaScript::toScript"]);
|
| 226 |
liveuser |
16665 |
|
| 3 |
liveuser |
16666 |
#加入 js 失敗
|
|
|
16667 |
if($toScript["status"]==="false"){
|
| 226 |
liveuser |
16668 |
|
| 3 |
liveuser |
16669 |
#設置執行失敗
|
|
|
16670 |
$result["status"]="false";
|
| 226 |
liveuser |
16671 |
|
| 3 |
liveuser |
16672 |
#設置錯誤訊息
|
|
|
16673 |
$result["error"]=$toScript;
|
| 226 |
liveuser |
16674 |
|
| 3 |
liveuser |
16675 |
#回傳結果
|
|
|
16676 |
return $result;
|
| 226 |
liveuser |
16677 |
|
| 3 |
liveuser |
16678 |
}#if end
|
| 226 |
liveuser |
16679 |
|
| 3 |
liveuser |
16680 |
#取得js語法
|
|
|
16681 |
$result["content"]=$toScript["content"];
|
| 226 |
liveuser |
16682 |
|
| 3 |
liveuser |
16683 |
#設置執行正常
|
|
|
16684 |
$result["status"]="true";
|
| 226 |
liveuser |
16685 |
|
| 3 |
liveuser |
16686 |
#回傳結果
|
|
|
16687 |
return $result;
|
| 226 |
liveuser |
16688 |
|
| 3 |
liveuser |
16689 |
}#function bar end
|
|
|
16690 |
|
|
|
16691 |
}#class form end
|
|
|
16692 |
|
|
|
16693 |
?>
|