| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
6 |
Copyright (C) 2015~2024 Min-Jhin,Chen
|
|
|
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 |
frame應用的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class frame{
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
#函式說明:
|
|
|
36 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
37 |
#回傳結果:
|
|
|
38 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
39 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
40 |
#$result["function"],當前執行的函式名稱.
|
|
|
41 |
#必填參數:
|
|
|
42 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
43 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
44 |
#參考資料:
|
|
|
45 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
46 |
*/
|
|
|
47 |
public function __call($method,$arguments){
|
|
|
48 |
|
|
|
49 |
#取得當前執行的函式
|
|
|
50 |
$result["function"]=__FUNCTION__;
|
|
|
51 |
|
|
|
52 |
#設置執行不正常
|
|
|
53 |
$result["status"]="false";
|
|
|
54 |
|
|
|
55 |
#設置執行錯誤
|
|
|
56 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
57 |
|
|
|
58 |
#設置所丟入的參數
|
|
|
59 |
$result["error"][]=$arguments;
|
|
|
60 |
|
|
|
61 |
#回傳結果
|
|
|
62 |
return $result;
|
|
|
63 |
|
|
|
64 |
}#function __call end
|
|
|
65 |
|
|
|
66 |
/*
|
|
|
67 |
#函式說明:
|
|
|
68 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
69 |
#回傳結果:
|
|
|
70 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
71 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
72 |
#$result["function"],當前執行的函式名稱.
|
|
|
73 |
#必填參數:
|
|
|
74 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
75 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
76 |
#參考資料:
|
|
|
77 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
78 |
*/
|
|
|
79 |
public static function __callStatic($method,$arguments){
|
|
|
80 |
|
|
|
81 |
#取得當前執行的函式
|
|
|
82 |
$result["function"]=__FUNCTION__;
|
|
|
83 |
|
|
|
84 |
#設置執行不正常
|
|
|
85 |
$result["status"]="false";
|
|
|
86 |
|
|
|
87 |
#設置執行錯誤
|
|
|
88 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
89 |
|
|
|
90 |
#設置所丟入的參數
|
|
|
91 |
$result["error"][]=$arguments;
|
|
|
92 |
|
|
|
93 |
#回傳結果
|
|
|
94 |
return $result;
|
|
|
95 |
|
|
|
96 |
}#function __callStatic end
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
#函式說明:
|
|
|
100 |
#建立一個 iframe 框架
|
|
|
101 |
#回傳的結果:
|
|
|
102 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。
|
|
|
103 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
104 |
#$result["error"],錯誤訊息提示
|
|
|
105 |
#$result["content"],iframe的語法
|
|
|
106 |
#必填參數:
|
|
|
107 |
#$conf["webPage"],字串,爲放入 iframe 網頁網址.
|
|
|
108 |
$conf["webPage"]="";
|
|
|
109 |
#$conf["name"],爲該 iframe 的名稱.
|
|
|
110 |
$conf["name"]="";
|
|
|
111 |
#$conf["br"],字串,爲放置完該iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。
|
|
|
112 |
$conf["br"]="true";
|
|
|
113 |
#可省略參數:
|
|
|
114 |
#$conf["class"],字串陣列,爲該 iframe 要套用的css樣式類別名稱.
|
|
|
115 |
#$conf["class"]=array("");
|
|
|
116 |
#$conf["scrolling"],字串,是否要取消滾軸功能,"false"代表取消滾軸功能.
|
|
|
117 |
#$conf["scrolling"]="";
|
|
|
118 |
#$conf["width"],字串,iframe的寬度.
|
|
|
119 |
#$conf["width"]="";
|
|
|
120 |
#$conf["height"],字串,iframe的高度.
|
|
|
121 |
#$conf["height"]="";
|
|
|
122 |
#$conf["minWidth"],字串,最小的寬度.
|
|
|
123 |
#$conf["minWidth"]="";
|
|
|
124 |
#$conf["maxWidth"],字串,最大寬度.
|
|
|
125 |
#$conf["maxWidth"]="";
|
|
|
126 |
#$conf["minHeight"],字串,最小的高度.
|
|
|
127 |
#$conf["minHeight"]="";
|
|
|
128 |
#$conf["maxHeight"],字串,最大的高度.
|
|
|
129 |
#$conf["maxHeight"]="";
|
|
|
130 |
#$conf["soucreId"],字串,如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效.
|
|
|
131 |
#$conf["soucreId"]="";
|
|
|
132 |
#$conf["sandbox"],字串,"true"代表要用"sandbox"屬性與搭配的參數來讓iframe的內容儘可能呈現,但不影響_top頁面;預設為"false",不使用"sandbox"參數.
|
|
|
133 |
#$conf["sandbox"]="";
|
|
|
134 |
#$conf["extraAttrAndValue"],字串陣列,div或span每個額外的屬性與其對應的數值,key為屬性名稱,value為屬性數值.
|
|
|
135 |
#$conf["extraAttrAndValue"]=array();
|
|
|
136 |
#$conf["frameExtraAttrAndValue"],字串陣列,frame每個額外的屬性與其對應的數值,key為屬性名稱,value為屬性數值.
|
|
|
137 |
#$conf["frameExtraAttrAndValue"]=array();
|
|
|
138 |
#參考資料:
|
|
|
139 |
#https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
|
|
|
140 |
#備註:
|
|
|
141 |
#無.
|
|
|
142 |
*/
|
|
|
143 |
public static function createIframe(&$conf){
|
|
|
144 |
|
|
|
145 |
#初始化要回傳的結果
|
|
|
146 |
$result=array();
|
|
|
147 |
|
|
|
148 |
#取得當前執行的函數名稱
|
|
|
149 |
$result["function"]=__FUNCTION__;
|
|
|
150 |
|
|
|
151 |
#如果沒有參數
|
|
|
152 |
if(func_num_args()==0){
|
|
|
153 |
|
|
|
154 |
#設置執行失敗
|
|
|
155 |
$result["status"]="false";
|
|
|
156 |
|
|
|
157 |
#設置執行錯誤訊息
|
|
|
158 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
159 |
|
|
|
160 |
#回傳結果
|
|
|
161 |
return $result;
|
|
|
162 |
|
|
|
163 |
}#if end
|
|
|
164 |
|
|
|
165 |
#取得參數
|
|
|
166 |
$result["argu"]=$conf;
|
|
|
167 |
|
|
|
168 |
#如果 $conf 不為陣列
|
|
|
169 |
if(gettype($conf)!=="array"){
|
|
|
170 |
|
|
|
171 |
#設置執行失敗
|
|
|
172 |
$result["status"]="false";
|
|
|
173 |
|
|
|
174 |
#設置執行錯誤訊息
|
|
|
175 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
176 |
|
|
|
177 |
#如果傳入的參數為 null
|
|
|
178 |
if($conf===null){
|
|
|
179 |
|
|
|
180 |
#設置執行錯誤訊息
|
|
|
181 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
182 |
|
|
|
183 |
}#if end
|
|
|
184 |
|
|
|
185 |
#回傳結果
|
|
|
186 |
return $result;
|
|
|
187 |
|
|
|
188 |
}#if end
|
|
|
189 |
|
|
|
190 |
#檢查參數
|
|
|
191 |
#函式說明:
|
|
|
192 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
193 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
194 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
195 |
#$result["function"],當前執行的函式名稱.
|
|
|
196 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
197 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
198 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
199 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
200 |
#必填寫的參數:
|
|
|
201 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
202 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
203 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
204 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webPage","name","br");
|
|
|
205 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
206 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
|
|
|
207 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
208 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
209 |
#可以省略的參數:
|
|
|
210 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
211 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
212 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
213 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId","sandbox","extraAttrAndValue","frameExtraAttrAndValue");
|
|
|
214 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
215 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","string","string","string","string","string","string","string","array","array");
|
|
|
216 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
217 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"true",null,null,null,null,null,null,null,"false",null,null);
|
|
|
218 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
219 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
220 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
221 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
222 |
|
|
|
223 |
#如果檢查失敗
|
|
|
224 |
if($checkResult["status"]=="false"){
|
|
|
225 |
|
|
|
226 |
#設置執行不正常
|
|
|
227 |
$result["status"]="false";
|
|
|
228 |
|
|
|
229 |
#設置錯誤訊息
|
|
|
230 |
$result["error"]=$checkResult;
|
|
|
231 |
|
|
|
232 |
#回傳結果
|
|
|
233 |
return $result;
|
|
|
234 |
|
|
|
235 |
}#if end
|
|
|
236 |
|
|
|
237 |
#如果檢查不通過
|
|
|
238 |
if($checkResult["passed"]=="false"){
|
|
|
239 |
|
|
|
240 |
#設置執行不正常
|
|
|
241 |
$result["status"]="false";
|
|
|
242 |
|
|
|
243 |
#設置錯誤訊息
|
|
|
244 |
$result["error"]=$checkResult;
|
|
|
245 |
|
|
|
246 |
#回傳結果
|
|
|
247 |
return $result;
|
|
|
248 |
|
|
|
249 |
}#if end
|
|
|
250 |
|
|
|
251 |
#如果$conf["class"]不存在
|
|
|
252 |
if(!isset($conf["class"])){
|
|
|
253 |
|
|
|
254 |
#不設定要套用的類別樣式
|
|
|
255 |
$conf["frameCssStyle"]="";
|
|
|
256 |
|
|
|
257 |
}#if end
|
|
|
258 |
|
|
|
259 |
#如果$conf["class"]不爲空,則設定樣式。
|
|
|
260 |
else{
|
|
|
261 |
|
|
|
262 |
#取得class字串
|
|
|
263 |
#涵式說明:
|
|
|
264 |
#建立class屬性字串,亦即套用多個class樣式的設定字串.
|
|
|
265 |
#回傳結果:
|
|
|
266 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
267 |
#$result["function"],當前執行的函數
|
|
|
268 |
#$result["error"],錯誤訊息陣列
|
|
|
269 |
#$result["content"],class屬性字串的內容
|
|
|
270 |
#必填參數:
|
|
|
271 |
#$conf["class"],字串陣列,要套用的類別樣式名稱.
|
|
|
272 |
$conf["css::classStr"]["class"]=$conf["class"];
|
|
|
273 |
$classStr=css::classStr($conf["css::classStr"]);
|
|
|
274 |
unset($conf["css::classStr"]);
|
|
|
275 |
|
|
|
276 |
#如果建立class類別字串失敗
|
|
|
277 |
if($classStr["status"]=="false"){
|
|
|
278 |
|
|
|
279 |
#設置執行不正常
|
|
|
280 |
$result["status"]="false";
|
|
|
281 |
|
|
|
282 |
#設置錯誤訊息
|
|
|
283 |
$result["error"]=$classStr;
|
|
|
284 |
|
|
|
285 |
#回傳結果
|
|
|
286 |
return $result;
|
|
|
287 |
|
|
|
288 |
}#if end
|
|
|
289 |
|
|
|
290 |
#取得類別樣式字串
|
|
|
291 |
$conf["frameCssStyle"]=$classStr["content"];
|
|
|
292 |
|
|
|
293 |
}#else end
|
|
|
294 |
|
|
|
295 |
#如果 $conf["scrolling"] 有設置
|
|
|
296 |
if(isset($conf["scrolling"])){
|
|
|
297 |
|
|
|
298 |
#如果 $conf["scrolling"] 等於 "false"
|
|
|
299 |
if($conf["scrolling"]=="false"){
|
|
|
300 |
|
|
|
301 |
#設定關閉滾軸
|
|
|
302 |
$conf["scrolling"]=" scrolling=no ";
|
|
|
303 |
|
|
|
304 |
}#if end
|
|
|
305 |
|
|
|
306 |
#反之
|
|
|
307 |
else{
|
|
|
308 |
|
|
|
309 |
#不做設定
|
|
|
310 |
$conf["scrolling"]="";
|
|
|
311 |
|
|
|
312 |
}#else end
|
|
|
313 |
|
|
|
314 |
}#if end
|
|
|
315 |
|
|
|
316 |
#反之
|
|
|
317 |
else{
|
|
|
318 |
|
|
|
319 |
#不做設定
|
|
|
320 |
$conf["scrolling"]="";
|
|
|
321 |
|
|
|
322 |
}#else end
|
|
|
323 |
|
|
|
324 |
#初始化 style 字串
|
|
|
325 |
$conf["styleStr"]="";
|
|
|
326 |
|
|
|
327 |
#如果有設定寬度或高度
|
|
|
328 |
if(isset($conf["width"]) || isset($conf["height"])){
|
|
|
329 |
|
|
|
330 |
#如果有設定寬度
|
|
|
331 |
if(isset($conf["width"])){
|
|
|
332 |
|
|
|
333 |
#設定寬度
|
|
|
334 |
$conf["css::styleStr"]["styleName"][]="width";
|
|
|
335 |
$conf["css::styleStr"]["styleValue"][]=$conf["width"];
|
|
|
336 |
|
|
|
337 |
}#if end
|
|
|
338 |
|
|
|
339 |
#如果有設定高度
|
|
|
340 |
if(isset($conf["height"])){
|
|
|
341 |
|
|
|
342 |
#設定高度
|
|
|
343 |
$conf["css::styleStr"]["styleName"][]="height";
|
|
|
344 |
$conf["css::styleStr"]["styleValue"][]=$conf["height"];
|
|
|
345 |
|
|
|
346 |
}#if end
|
|
|
347 |
|
|
|
348 |
#如果有設定最小寬度
|
|
|
349 |
if(isset($conf["minWidth"])){
|
|
|
350 |
|
|
|
351 |
#設定寬度
|
|
|
352 |
$conf["css::styleStr"]["styleName"][]="min-width";
|
|
|
353 |
$conf["css::styleStr"]["styleValue"][]=$conf["minWidth"];
|
|
|
354 |
|
|
|
355 |
}#if end
|
|
|
356 |
|
|
|
357 |
#如果有設定最大寬度
|
|
|
358 |
if(isset($conf["maxWidth"])){
|
|
|
359 |
|
|
|
360 |
#設定寬度
|
|
|
361 |
$conf["css::styleStr"]["styleName"][]="max-width";
|
|
|
362 |
$conf["css::styleStr"]["styleValue"][]=$conf["maxWidth"];
|
|
|
363 |
|
|
|
364 |
}#if end
|
|
|
365 |
|
|
|
366 |
#如果有設定最小高度
|
|
|
367 |
if(isset($conf["minHeight"])){
|
|
|
368 |
|
|
|
369 |
#設定寬度
|
|
|
370 |
$conf["css::styleStr"]["styleName"][]="min-height";
|
|
|
371 |
$conf["css::styleStr"]["styleValue"][]=$conf["minHeight"];
|
|
|
372 |
|
|
|
373 |
}#if end
|
|
|
374 |
|
|
|
375 |
#如果有設定最大高度
|
|
|
376 |
if(isset($conf["maxHeight"])){
|
|
|
377 |
|
|
|
378 |
#設定寬度
|
|
|
379 |
$conf["css::styleStr"]["styleName"][]="max-height";
|
|
|
380 |
$conf["css::styleStr"]["styleValue"][]=$conf["maxHeight"];
|
|
|
381 |
|
|
|
382 |
}#if end
|
|
|
383 |
|
|
|
384 |
#函式說明:
|
|
|
385 |
#建立給與html標籤使用的style屬性字串.
|
|
|
386 |
#回傳的結果:
|
|
|
387 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
388 |
#$result["function"],當前執行的函數
|
|
|
389 |
#$result["error"],錯誤訊息陣列
|
|
|
390 |
#$result["content"],css設定內容
|
|
|
391 |
#必填參數:
|
|
|
392 |
#$conf["css::styleStr"]["styleName"]=array("");#為屬性名稱,須為陣列值
|
|
|
393 |
#$conf["css::styleStr"]["styleValue"]=array("");#為屬性值,須為陣列值
|
|
|
394 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
395 |
unset($conf["css::styleStr"]);
|
|
|
396 |
|
|
|
397 |
#如果建立 style 字串失敗
|
|
|
398 |
if($styleStr["status"]=="false"){
|
|
|
399 |
|
|
|
400 |
#設置執行不正常
|
|
|
401 |
$result["status"]="false";
|
|
|
402 |
|
|
|
403 |
#設置錯誤訊息
|
|
|
404 |
$result["error"]=$styleStr;
|
|
|
405 |
|
|
|
406 |
#回傳結果
|
|
|
407 |
return $result;
|
|
|
408 |
|
|
|
409 |
}#if end
|
|
|
410 |
|
|
|
411 |
#取得 style 字串
|
|
|
412 |
$conf["styleStr"]=$styleStr["content"];
|
|
|
413 |
|
|
|
414 |
}#if end
|
|
|
415 |
|
|
|
416 |
#iframe語法,frameborder = 0 可以讓IE9看起來不會有外框
|
|
|
417 |
#$result["content"]="<iframe src = ".$conf["webPage"]." name = ".$conf["name"].$conf["scrolling"]." id = ".$conf["name"]." frameborder = 0 ".$conf["frameCssStyle"]." ".$conf["styleStr"]." ></iframe>";
|
|
|
418 |
|
|
|
419 |
#初始化儲存div或span其餘的屬性與數值
|
|
|
420 |
$extraAttrAndValue="";
|
|
|
421 |
|
|
|
422 |
#如果有設置 $conf["extraAttrAndValue"]
|
|
|
423 |
if(isset($conf["extraAttrAndValue"])){
|
|
|
424 |
|
|
|
425 |
#針對每個屬性與數值
|
|
|
426 |
foreach($conf["extraAttrAndValue"] as $attr=>$val ){
|
|
|
427 |
|
|
|
428 |
#串接每個屬性與數值
|
|
|
429 |
$extraAttrAndValue=$extraAttrAndValue." ".$attr."=\"".$val."\"";
|
|
|
430 |
|
|
|
431 |
}#foreach end
|
|
|
432 |
|
|
|
433 |
}#if end
|
|
|
434 |
|
|
|
435 |
#初始化儲存frame其餘的屬性與數值
|
|
|
436 |
$frameExtraAttrAndValue="";
|
|
|
437 |
|
|
|
438 |
#如果有設置 $conf["frameExtraAttrAndValue"]
|
|
|
439 |
if(isset($conf["frameExtraAttrAndValue"])){
|
|
|
440 |
|
|
|
441 |
#如果要用 sandbox 參數
|
|
|
442 |
if($conf["sandbox"]==="true"){
|
|
|
443 |
|
|
|
444 |
#增加 sandbox 參數與屬性
|
|
|
445 |
$conf["frameExtraAttrAndValue"][]=array("sandbox"=>"allow-popups allow-scripts allow-modals allow-forms allow-downloads");
|
|
|
446 |
|
|
|
447 |
}#if end
|
|
|
448 |
|
|
|
449 |
#針對每個屬性與數值
|
|
|
450 |
foreach($conf["frameExtraAttrAndValue"] as $attr=>$val ){
|
|
|
451 |
|
|
|
452 |
#串接每個屬性與數值
|
|
|
453 |
$frameExtraAttrAndValue=$frameExtraAttrAndValue." ".$attr."=\"".$val."\"";
|
|
|
454 |
|
|
|
455 |
}#foreach end
|
|
|
456 |
|
|
|
457 |
}#if end
|
|
|
458 |
|
|
|
459 |
#反之沒有設置 $conf["frameExtraAttrAndValue"]
|
|
|
460 |
else{
|
|
|
461 |
|
|
|
462 |
#設置 sandbox 參數與屬性
|
|
|
463 |
$frameExtraAttrAndValue="sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-downloads\"";
|
|
|
464 |
|
|
|
465 |
}#else end
|
|
|
466 |
|
|
|
467 |
#如果 $conf["br"] 爲 "true"
|
|
|
468 |
if($conf["br"]==="true"){
|
|
|
469 |
|
|
|
470 |
#用div包起來,寬高的style與class套用在div上面.
|
|
|
471 |
$result["content"]="<div ".$extraAttrAndValue." ".$conf["frameCssStyle"]." ".$conf["styleStr"].">"."<iframe ".$frameExtraAttrAndValue." style=\"width:100%;height:100%;\" src=\"".$conf["webPage"]."\" name=\"".$conf["name"]."\" ".$conf["scrolling"]." id = \"".$conf["name"]."\" frameborder=0></iframe></div>";
|
|
|
472 |
|
|
|
473 |
#如果存在 $conf["soucreId"]
|
|
|
474 |
if(isset($conf["soucreId"])){
|
|
|
475 |
|
|
|
476 |
#函式說明:
|
|
|
477 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
478 |
#回傳結果:
|
|
|
479 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
480 |
#$result["error"],錯誤訊息陣列
|
|
|
481 |
#$result["function"],當前執行的函數名稱
|
|
|
482 |
#$result["content"],要執行的javaScript語法
|
|
|
483 |
#必填參數:
|
|
|
484 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
485 |
$conf["javascript::toScript"]["script"]=
|
|
|
486 |
"
|
|
|
487 |
window.changeFrameEleHeightToFullLessSource.changeSizeFrameId='".$conf["name"]."';
|
|
|
488 |
window.changeFrameEleHeightToFullLessSource.fixedSizeFrameId='".$conf["soucreId"]."';
|
|
|
489 |
";
|
|
|
490 |
#可省略參數:
|
|
|
491 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
492 |
$conf["javascript::toScript"]["onReady"]="false";
|
|
|
493 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
494 |
#$conf["globalJs"]=array();
|
|
|
495 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
496 |
#$conf["jsFunciton"]=array();
|
|
|
497 |
#參考資料:
|
|
|
498 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
499 |
$toScript=javascript::toScript($conf["javascript::toScript"]);
|
|
|
500 |
unset($conf["javascript::toScript"]);
|
|
|
501 |
|
|
|
502 |
#如果建立script失敗
|
|
|
503 |
if($toScript["status"]==="false"){
|
|
|
504 |
|
|
|
505 |
#設置執行不正常
|
|
|
506 |
$result["status"]="false";
|
|
|
507 |
|
|
|
508 |
#設置錯誤訊息
|
|
|
509 |
$result["error"]=$toScript;
|
|
|
510 |
|
|
|
511 |
#回傳結果
|
|
|
512 |
return $result;
|
|
|
513 |
|
|
|
514 |
}#if end
|
|
|
515 |
|
|
|
516 |
#串接語法
|
|
|
517 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
518 |
|
|
|
519 |
}#if end
|
|
|
520 |
|
|
|
521 |
}#if end
|
|
|
522 |
|
|
|
523 |
#改用span將iframe包起來
|
|
|
524 |
else{
|
|
|
525 |
|
|
|
526 |
#用span包起來,寬高的style與class套用在iframe上面.
|
|
|
527 |
$result["content"]="<span ".$extraAttrAndValue.">"."<iframe ".$frameExtraAttrAndValue." ".$conf["frameCssStyle"]." ".$conf["styleStr"]." src=\"".$conf["webPage"]."\" name=\"".$conf["name"]."\" ".$conf["scrolling"]." id = \"".$conf["name"]."\" frameborder=0></iframe></span>";
|
|
|
528 |
|
|
|
529 |
}#else end
|
|
|
530 |
|
|
|
531 |
#執行到這邊,代表執行成功
|
|
|
532 |
$result["status"]="true";
|
|
|
533 |
|
|
|
534 |
#回傳結果
|
|
|
535 |
return $result;
|
|
|
536 |
|
|
|
537 |
}#function createIframe end
|
|
|
538 |
|
|
|
539 |
/*
|
|
|
540 |
#函式說明:
|
|
|
541 |
#建立多個 iframe
|
|
|
542 |
#回傳的結果:
|
|
|
543 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。
|
|
|
544 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
545 |
#$result["error"],錯誤訊息提示
|
|
|
546 |
#$result["content"],iframe的語法
|
|
|
547 |
#必填參數:
|
|
|
548 |
#$conf["webPage"],字串陣列,爲每個要放入 iframe 的網頁網址.
|
|
|
549 |
$conf["webPage"]=array("");
|
|
|
550 |
#$conf["name"],字串陣列,爲每個 iframe 的名稱與id.
|
|
|
551 |
$conf["name"]=array("");
|
|
|
552 |
#$conf["br"],字串陣列,爲放置完各個iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。
|
|
|
553 |
$conf["br"]=array("true");
|
|
|
554 |
#可省略參數:
|
|
|
555 |
#$conf["class"],字串陣列,爲各個 iframe 要套用的css樣式類別名稱,若不使用請將其元素設為null.
|
|
|
556 |
#$conf["class"]=array(array(""));
|
|
|
557 |
#$conf["scrolling"],字串陣列,是否要取消各個iframe的滾軸功能,"false"代表取消滾軸功能,若不使用請將其元素設為null.
|
|
|
558 |
#$conf["scrolling"]=array("false");
|
|
|
559 |
#$conf["width"],字串陣列,各個iframe的寬度,若不使用請將其元素設為null.
|
|
|
560 |
#$conf["width"]=array("");
|
|
|
561 |
#$conf["height"],字串陣列,各個iframe的高度,若不使用請將其元素設為null.
|
|
|
562 |
#$conf["height"]=array();
|
|
|
563 |
#$conf["minWidth"],字串陣列,各個iframe最小的寬度,若不使用請將其元素設為null.
|
|
|
564 |
#$conf["minWidth"]=array("");
|
|
|
565 |
#$conf["maxWidth"],字串陣列,各個iframe最大寬度,若不使用請將其元素設為null.
|
|
|
566 |
#$conf["maxWidth"]=array("");
|
|
|
567 |
#$conf["minHeight"],字串陣列,各個iframe最小的高度,若不使用請將其元素設為null.
|
|
|
568 |
#$conf["minHeight"]=array("");
|
|
|
569 |
#$conf["maxHeight"],字串陣列,各個最大的高度,若不使用請將其元素設為null.
|
|
|
570 |
#$conf["maxHeight"]=array("");
|
|
|
571 |
#$conf["soucreId"],字串陣列,各個iframe如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效,若不使用請將其元素設為null.
|
|
|
572 |
#$conf["soucreId"]=array("");
|
|
|
573 |
#參考資料:
|
|
|
574 |
#無.
|
|
|
575 |
#備註:
|
|
|
576 |
#無.
|
|
|
577 |
*/
|
|
|
578 |
public static function createMultiIframe(&$conf){
|
|
|
579 |
|
|
|
580 |
#初始化要回傳的結果
|
|
|
581 |
$result=array();
|
|
|
582 |
|
|
|
583 |
#取得當前執行的函數名稱
|
|
|
584 |
$result["function"]=__FUNCTION__;
|
|
|
585 |
|
|
|
586 |
#如果沒有參數
|
|
|
587 |
if(func_num_args()==0){
|
|
|
588 |
|
|
|
589 |
#設置執行失敗
|
|
|
590 |
$result["status"]="false";
|
|
|
591 |
|
|
|
592 |
#設置執行錯誤訊息
|
|
|
593 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
594 |
|
|
|
595 |
#回傳結果
|
|
|
596 |
return $result;
|
|
|
597 |
|
|
|
598 |
}#if end
|
|
|
599 |
|
|
|
600 |
#取得參數
|
|
|
601 |
$result["argu"]=$conf;
|
|
|
602 |
|
|
|
603 |
#如果 $conf 不為陣列
|
|
|
604 |
if(gettype($conf)!=="array"){
|
|
|
605 |
|
|
|
606 |
#設置執行失敗
|
|
|
607 |
$result["status"]="false";
|
|
|
608 |
|
|
|
609 |
#設置執行錯誤訊息
|
|
|
610 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
611 |
|
|
|
612 |
#如果傳入的參數為 null
|
|
|
613 |
if($conf===null){
|
|
|
614 |
|
|
|
615 |
#設置執行錯誤訊息
|
|
|
616 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
617 |
|
|
|
618 |
}#if end
|
|
|
619 |
|
|
|
620 |
#回傳結果
|
|
|
621 |
return $result;
|
|
|
622 |
|
|
|
623 |
}#if end
|
|
|
624 |
|
|
|
625 |
#初始化要回傳的語法
|
|
|
626 |
$result["content"]="";
|
|
|
627 |
|
|
|
628 |
#檢查參數
|
|
|
629 |
#函式說明:
|
|
|
630 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
631 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
632 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
633 |
#$result["function"],當前執行的函式名稱.
|
|
|
634 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
635 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
636 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
637 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
638 |
#必填寫的參數:
|
|
|
639 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
640 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
641 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
642 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webPage","name","br");
|
|
|
643 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
644 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array","array");
|
|
|
645 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
646 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
647 |
#可以省略的參數:
|
|
|
648 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
649 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
650 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
651 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId");
|
|
|
652 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
653 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array");
|
|
|
654 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
655 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,null,null,null,null,null,null);
|
|
|
656 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
657 |
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("webPage","name","br");
|
|
|
658 |
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("br","class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId");
|
|
|
659 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
660 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
661 |
|
|
|
662 |
#如果檢查失敗
|
|
|
663 |
if($checkResult["status"]==="false"){
|
|
|
664 |
|
|
|
665 |
#設置執行不正常
|
|
|
666 |
$result["status"]="false";
|
|
|
667 |
|
|
|
668 |
#設置錯誤訊息
|
|
|
669 |
$result["error"]=$checkResult;
|
|
|
670 |
|
|
|
671 |
#回傳結果
|
|
|
672 |
return $result;
|
|
|
673 |
|
|
|
674 |
}#if end
|
|
|
675 |
|
|
|
676 |
#如果檢查不通過
|
|
|
677 |
if($checkResult["passed"]==="false"){
|
|
|
678 |
|
|
|
679 |
#設置執行不正常
|
|
|
680 |
$result["status"]="false";
|
|
|
681 |
|
|
|
682 |
#設置錯誤訊息
|
|
|
683 |
$result["error"]=$checkResult;
|
|
|
684 |
|
|
|
685 |
#回傳結果
|
|
|
686 |
return $result;
|
|
|
687 |
|
|
|
688 |
}#if end
|
|
|
689 |
|
|
|
690 |
#針對每個 $conf["webPage"]
|
|
|
691 |
foreach($conf["webPage"] as $index=>$url){
|
|
|
692 |
|
|
|
693 |
#初始化參數
|
|
|
694 |
$each=array();
|
|
|
695 |
|
|
|
696 |
#取得參數 "webPage"
|
|
|
697 |
$each["webPage"]=$url;
|
|
|
698 |
|
|
|
699 |
#取得參數 "name"
|
|
|
700 |
$each["name"]=$conf["name"][$index];
|
|
|
701 |
|
|
|
702 |
#取得參數 "br"
|
|
|
703 |
$each["br"]=$conf["br"][$index];
|
|
|
704 |
|
|
|
705 |
#如果有設置 $conf["class"][$index] 參數
|
|
|
706 |
if(isset($conf["class"][$index])){
|
|
|
707 |
|
|
|
708 |
#如果不是 null
|
|
|
709 |
if($conf["class"][$index]!==null){
|
|
|
710 |
|
|
|
711 |
#取得 "class" 參數
|
|
|
712 |
$each["class"]=$conf["class"][$index];
|
|
|
713 |
|
|
|
714 |
}#if end
|
|
|
715 |
|
|
|
716 |
}#if end
|
|
|
717 |
|
|
|
718 |
#如果有設置 $conf["scrolling"] 參數
|
|
|
719 |
if(isset($conf["scrolling"][$index])){
|
|
|
720 |
|
|
|
721 |
#如果不是 null
|
|
|
722 |
if($conf["scrolling"][$index]!==null){
|
|
|
723 |
|
|
|
724 |
#取得 "scrolling" 參數
|
|
|
725 |
$each["scrolling"]=$conf["scrolling"][$index];
|
|
|
726 |
|
|
|
727 |
}#if end
|
|
|
728 |
|
|
|
729 |
}#if end
|
|
|
730 |
|
|
|
731 |
#如果有設置 $conf["width"] 參數
|
|
|
732 |
if(isset($conf["width"][$index])){
|
|
|
733 |
|
|
|
734 |
#如果不是 null
|
|
|
735 |
if($conf["width"][$index]!==null){
|
|
|
736 |
|
|
|
737 |
#取得 "width" 參數
|
|
|
738 |
$each["width"]=$conf["width"][$index];
|
|
|
739 |
|
|
|
740 |
}#if end
|
|
|
741 |
|
|
|
742 |
}#if end
|
|
|
743 |
|
|
|
744 |
#如果有設置 $conf["height"] 參數
|
|
|
745 |
if(isset($conf["height"][$index])){
|
|
|
746 |
|
|
|
747 |
#如果不是 null
|
|
|
748 |
if($conf["height"][$index]!==null){
|
|
|
749 |
|
|
|
750 |
#取得 "height" 參數
|
|
|
751 |
$each["height"]=$conf["height"][$index];
|
|
|
752 |
|
|
|
753 |
}#if end
|
|
|
754 |
|
|
|
755 |
}#if end
|
|
|
756 |
|
|
|
757 |
#如果有設置 $conf["minWidth"] 參數
|
|
|
758 |
if(isset($conf["minWidth"][$index])){
|
|
|
759 |
|
|
|
760 |
#如果不是 null
|
|
|
761 |
if($conf["minWidth"][$index]!==null){
|
|
|
762 |
|
|
|
763 |
#取得 "minWidth" 參數
|
|
|
764 |
$each["minWidth"]=$conf["minWidth"][$index];
|
|
|
765 |
|
|
|
766 |
}#if end
|
|
|
767 |
|
|
|
768 |
}#if end
|
|
|
769 |
|
|
|
770 |
#如果有設置 $conf["maxWidth"] 參數
|
|
|
771 |
if(isset($conf["maxWidth"][$index])){
|
|
|
772 |
|
|
|
773 |
#如果不是 null
|
|
|
774 |
if($conf["maxWidth"][$index]!==null){
|
|
|
775 |
|
|
|
776 |
#取得 "maxWidth" 參數
|
|
|
777 |
$each["maxWidth"]=$conf["maxWidth"][$index];
|
|
|
778 |
|
|
|
779 |
}#if end
|
|
|
780 |
|
|
|
781 |
}#if end
|
|
|
782 |
|
|
|
783 |
#如果有設置 $conf["minHeight"] 參數
|
|
|
784 |
if(isset($conf["minHeight"][$index])){
|
|
|
785 |
|
|
|
786 |
#如果不是 null
|
|
|
787 |
if($conf["minHeight"][$index]!==null){
|
|
|
788 |
|
|
|
789 |
#取得 "minHeight" 參數
|
|
|
790 |
$each["minHeight"]=$conf["minHeight"][$index];
|
|
|
791 |
|
|
|
792 |
}#if end
|
|
|
793 |
|
|
|
794 |
}#if end
|
|
|
795 |
|
|
|
796 |
#如果有設置 $conf["maxHeight"] 參數
|
|
|
797 |
if(isset($conf["maxHeight"][$index])){
|
|
|
798 |
|
|
|
799 |
#如果不是 null
|
|
|
800 |
if($conf["maxHeight"][$index]!==null){
|
|
|
801 |
|
|
|
802 |
#取得 "maxHeight" 參數
|
|
|
803 |
$each["maxHeight"]=$conf["maxHeight"][$index];
|
|
|
804 |
|
|
|
805 |
}#if end
|
|
|
806 |
|
|
|
807 |
}#if end
|
|
|
808 |
|
|
|
809 |
#如果有設置 $conf["soucreId"] 參數
|
|
|
810 |
if(isset($conf["soucreId"][$index])){
|
|
|
811 |
|
|
|
812 |
#如果不是 null
|
|
|
813 |
if($conf["soucreId"][$index]!==null){
|
|
|
814 |
|
|
|
815 |
#取得 "soucreId" 參數
|
|
|
816 |
$each["soucreId"]=$conf["soucreId"][$index];
|
|
|
817 |
|
|
|
818 |
}#if end
|
|
|
819 |
|
|
|
820 |
}#if end
|
|
|
821 |
|
|
|
822 |
#函式說明:
|
|
|
823 |
#建立一個 iframe 框架
|
|
|
824 |
#回傳的結果:
|
|
|
825 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。
|
|
|
826 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
827 |
#$result["error"],錯誤訊息提示
|
|
|
828 |
#$result["content"],iframe的語法
|
|
|
829 |
#必填參數:
|
|
|
830 |
#$conf["webPage"],字串,爲放入 iframe 網頁網址.
|
|
|
831 |
$conf["frame::createIframe"]["webPage"]=$each["webPage"];
|
|
|
832 |
#$conf["name"],爲該 iframe 的名稱.
|
|
|
833 |
$conf["frame::createIframe"]["name"]=$each["name"];
|
|
|
834 |
#$conf["br"],字串,爲放置完該iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。
|
|
|
835 |
$conf["frame::createIframe"]["br"]=$each["br"];
|
|
|
836 |
#可省略參數:
|
|
|
837 |
|
|
|
838 |
#如果存在 $each["class"]
|
|
|
839 |
if(isset($each["class"])){
|
|
|
840 |
|
|
|
841 |
#設置參數
|
|
|
842 |
#$conf["class"],字串陣列,爲該 iframe 要套用的css樣式類別名稱.
|
|
|
843 |
$conf["frame::createIframe"]["class"]=$each["class"];
|
|
|
844 |
|
|
|
845 |
}#if end
|
|
|
846 |
|
|
|
847 |
#如果存在 $each["scrolling"]
|
|
|
848 |
if(isset($each["scrolling"])){
|
|
|
849 |
|
|
|
850 |
#設置參數
|
|
|
851 |
#$conf["scrolling"],字串,是否要取消滾軸功能,"false"代表取消滾軸功能.
|
|
|
852 |
$conf["frame::createIframe"]["scrolling"]=$each["scrolling"];
|
|
|
853 |
|
|
|
854 |
}#if end
|
|
|
855 |
|
|
|
856 |
#如果存在 $each["width"]
|
|
|
857 |
if(isset($each["width"])){
|
|
|
858 |
|
|
|
859 |
#設置參數
|
|
|
860 |
#$conf["width"],字串,iframe的寬度.
|
|
|
861 |
$conf["frame::createIframe"]["width"]=$each["width"];
|
|
|
862 |
|
|
|
863 |
}#if end
|
|
|
864 |
|
|
|
865 |
#如果存在 $each["height"]
|
|
|
866 |
if(isset($each["height"])){
|
|
|
867 |
|
|
|
868 |
#設置參數
|
|
|
869 |
#$conf["height"],字串,iframe的寬度.
|
|
|
870 |
$conf["frame::createIframe"]["height"]=$each["height"];
|
|
|
871 |
|
|
|
872 |
}#if end
|
|
|
873 |
|
|
|
874 |
#如果存在 $each["minWidth"]
|
|
|
875 |
if(isset($each["minWidth"])){
|
|
|
876 |
|
|
|
877 |
#$conf["minWidth"],字串,最小的寬度.
|
|
|
878 |
$conf["frame::createIframe"]["minWidth"]=$each["minWidth"];
|
|
|
879 |
|
|
|
880 |
}#if end
|
|
|
881 |
|
|
|
882 |
#如果存在 $each["maxWidth"]
|
|
|
883 |
if(isset($each["maxWidth"])){
|
|
|
884 |
|
|
|
885 |
#$conf["maxWidth"],字串,最大寬度.
|
|
|
886 |
$conf["frame::createIframe"]["maxWidth"]=$each["minWidth"];
|
|
|
887 |
|
|
|
888 |
}#if end
|
|
|
889 |
|
|
|
890 |
#如果存在 $each["maxWidth"]
|
|
|
891 |
if(isset($each["maxWidth"])){
|
|
|
892 |
|
|
|
893 |
#$conf["minHeight"],字串,最小的高度.
|
|
|
894 |
$conf["frame::createIframe"]["minHeight"]=$each["minHeight"];
|
|
|
895 |
|
|
|
896 |
}#if end
|
|
|
897 |
|
|
|
898 |
#如果存在 $each["maxHeight"]
|
|
|
899 |
if(isset($each["maxHeight"])){
|
|
|
900 |
|
|
|
901 |
#$conf["maxHeight"],字串,最大的高度.
|
|
|
902 |
$conf["frame::createIframe"]["maxHeight"]=$each["maxHeight"];
|
|
|
903 |
|
|
|
904 |
}#if end
|
|
|
905 |
|
|
|
906 |
#如果存在 $each["soucreId"]
|
|
|
907 |
if(isset($each["soucreId"])){
|
|
|
908 |
|
|
|
909 |
#$conf["soucreId"],字串,如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效.
|
|
|
910 |
$conf["frame::createIframe"]["soucreId"]=$each["soucreId"];
|
|
|
911 |
|
|
|
912 |
}#if end
|
|
|
913 |
|
|
|
914 |
$createIframe=frame::createIframe($conf["frame::createIframe"]);
|
|
|
915 |
unset($conf["frame::createIframe"]);
|
|
|
916 |
|
|
|
917 |
#如果建立失敗
|
|
|
918 |
if($createIframe["status"]==="false"){
|
|
|
919 |
|
|
|
920 |
#設置執行不正常
|
|
|
921 |
$result["status"]="false";
|
|
|
922 |
|
|
|
923 |
#設置錯誤訊息
|
|
|
924 |
$result["error"]=$checkResult;
|
|
|
925 |
|
|
|
926 |
#回傳結果
|
|
|
927 |
return $result;
|
|
|
928 |
|
|
|
929 |
}#if end
|
|
|
930 |
|
|
|
931 |
#串接iframe語法
|
|
|
932 |
$result["content"]=$result["content"].$createIframe["content"];
|
|
|
933 |
|
|
|
934 |
}#foreach end
|
|
|
935 |
|
|
|
936 |
#設置執行正常
|
|
|
937 |
$result["status"]="true";
|
|
|
938 |
|
|
|
939 |
#回傳結果
|
|
|
940 |
return $result;
|
|
|
941 |
|
|
|
942 |
}#function createMultiIframe end
|
|
|
943 |
|
|
|
944 |
/*
|
|
|
945 |
#函式說明:
|
|
|
946 |
#用div做成的frame.
|
|
|
947 |
#回傳結果:
|
|
|
948 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.
|
|
|
949 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
950 |
#$result["error"],錯誤訊息提示.
|
|
|
951 |
#$result["content"],div frame的語法.
|
|
|
952 |
#必填參數:
|
|
|
953 |
#$conf["id"],字串,div frame的id.
|
|
|
954 |
$conf["id"]="";
|
|
|
955 |
#可省略參數:
|
|
|
956 |
#$conf["content"],字串陣列,要放入到frame的內容,預設不使用.
|
|
|
957 |
#$conf["content"]=array();
|
|
|
958 |
#$conf["oneScreenSize"],字串,是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.
|
|
|
959 |
#$conf["oneScreenSize"]="";
|
|
|
960 |
#$conf["height"],字串,frame的高度,若 "oneScreenSize" 設置為 "true",則忽略本參數.
|
|
|
961 |
#$conf["height"]="";
|
|
|
962 |
#參考資料:
|
|
|
963 |
#無.
|
|
|
964 |
#備註:
|
|
|
965 |
#無.
|
|
|
966 |
*/
|
|
|
967 |
public static function div(&$conf=array()){
|
|
|
968 |
|
|
|
969 |
#初始化要回傳的結果
|
|
|
970 |
$result=array();
|
|
|
971 |
|
|
|
972 |
#取得當前執行的函數名稱
|
|
|
973 |
$result["function"]=__FUNCTION__;
|
|
|
974 |
|
|
|
975 |
#如果沒有參數
|
|
|
976 |
if(func_num_args()==0){
|
|
|
977 |
|
|
|
978 |
#設置執行失敗
|
|
|
979 |
$result["status"]="false";
|
|
|
980 |
|
|
|
981 |
#設置執行錯誤訊息
|
|
|
982 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
983 |
|
|
|
984 |
#回傳結果
|
|
|
985 |
return $result;
|
|
|
986 |
|
|
|
987 |
}#if end
|
|
|
988 |
|
|
|
989 |
#取得參數
|
|
|
990 |
$result["argu"]=$conf;
|
|
|
991 |
|
|
|
992 |
#如果 $conf 不為陣列
|
|
|
993 |
if(gettype($conf)!=="array"){
|
|
|
994 |
|
|
|
995 |
#設置執行失敗
|
|
|
996 |
$result["status"]="false";
|
|
|
997 |
|
|
|
998 |
#設置執行錯誤訊息
|
|
|
999 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1000 |
|
|
|
1001 |
#如果傳入的參數為 null
|
|
|
1002 |
if($conf===null){
|
|
|
1003 |
|
|
|
1004 |
#設置執行錯誤訊息
|
|
|
1005 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1006 |
|
|
|
1007 |
}#if end
|
|
|
1008 |
|
|
|
1009 |
#回傳結果
|
|
|
1010 |
return $result;
|
|
|
1011 |
|
|
|
1012 |
}#if end
|
|
|
1013 |
|
|
|
1014 |
#檢查參數
|
|
|
1015 |
#函式說明:
|
|
|
1016 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1017 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1018 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1019 |
#$result["function"],當前執行的函式名稱.
|
|
|
1020 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1021 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1022 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1023 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1024 |
#必填寫的參數:
|
|
|
1025 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1026 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
1027 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1028 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");
|
|
|
1029 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1030 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
1031 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1032 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
1033 |
#可以省略的參數:
|
|
|
1034 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
1035 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
1036 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1037 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("content","oneScreenSize","height");
|
|
|
1038 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1039 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
|
|
|
1040 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1041 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(array(),"false",null);
|
|
|
1042 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1043 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
1044 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1045 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1046 |
|
|
|
1047 |
#如果檢查失敗
|
|
|
1048 |
if($checkResult["status"]=="false"){
|
|
|
1049 |
|
|
|
1050 |
#設置執行不正常
|
|
|
1051 |
$result["status"]="false";
|
|
|
1052 |
|
|
|
1053 |
#設置錯誤訊息
|
|
|
1054 |
$result["error"]=$checkResult;
|
|
|
1055 |
|
|
|
1056 |
#回傳結果
|
|
|
1057 |
return $result;
|
|
|
1058 |
|
|
|
1059 |
}#if end
|
|
|
1060 |
|
|
|
1061 |
#如果檢查不通過
|
|
|
1062 |
if($checkResult["passed"]=="false"){
|
|
|
1063 |
|
|
|
1064 |
#設置執行不正常
|
|
|
1065 |
$result["status"]="false";
|
|
|
1066 |
|
|
|
1067 |
#設置錯誤訊息
|
|
|
1068 |
$result["error"]=$checkResult;
|
|
|
1069 |
|
|
|
1070 |
#回傳結果
|
|
|
1071 |
return $result;
|
|
|
1072 |
|
|
|
1073 |
}#if end
|
|
|
1074 |
|
|
|
1075 |
#涵式說明:
|
|
|
1076 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
1077 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
1078 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
1079 |
#$result["error"],陣列,錯訊訊息.
|
|
|
1080 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
1081 |
#必填參數:
|
|
|
1082 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
1083 |
$conf["css::divSection"]["contentArray"]=$conf["content"];
|
|
|
1084 |
#可省略參數
|
|
|
1085 |
#$conf["id"],字串,div區塊的id.
|
|
|
1086 |
$conf["css::divSection"]["id"]=$conf["id"];
|
|
|
1087 |
#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.
|
|
|
1088 |
$conf["css::divSection"]["styleAttr"]=array("overflow-y");
|
|
|
1089 |
#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.
|
|
|
1090 |
$conf["css::divSection"]["styleVal"]=array("auto");
|
|
|
1091 |
|
|
|
1092 |
#如果 "oneScreenSize" 為 "false"
|
|
|
1093 |
if($conf["oneScreenSize"]==="false"){
|
|
|
1094 |
|
|
|
1095 |
#如果有設置 "height"
|
|
|
1096 |
if(isset($conf["height"])){
|
|
|
1097 |
|
|
|
1098 |
#設置高度屬性
|
|
|
1099 |
$conf["css::divSection"]["styleAttr"][]="height";
|
|
|
1100 |
|
|
|
1101 |
#設置高度屬性數值
|
|
|
1102 |
$conf["css::divSection"]["styleVal"][]=$conf["height"];
|
|
|
1103 |
|
|
|
1104 |
}#if end
|
|
|
1105 |
|
|
|
1106 |
}#if end
|
|
|
1107 |
|
|
|
1108 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
1109 |
#$conf["class"]="";
|
|
|
1110 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容.
|
|
|
1111 |
#$conf["title"]=array();
|
|
|
1112 |
#$conf["oneScreenSize"],字串,div區塊是否要占一個螢幕的大小,預設為"false"不設定,"true"為設定成一個螢幕的大小.
|
|
|
1113 |
$conf["css::divSection"]["oneScreenSize"]=$conf["oneScreenSize"];
|
|
|
1114 |
#$conf["textAlignCenter"],字串,div區塊是否要置中,預設為$conf["oneScreenSize"]的值,"false"為不置中,"true"代表要置中.
|
|
|
1115 |
#$conf["textAlignCenter"]="";
|
|
|
1116 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
1117 |
unset($conf["css::divSection"]);
|
|
|
1118 |
|
|
|
1119 |
#如果建立div frame失敗
|
|
|
1120 |
if($divSection["status"]==="false"){
|
|
|
1121 |
|
|
|
1122 |
#設置執行失敗
|
|
|
1123 |
$result["status"]="false";
|
|
|
1124 |
|
|
|
1125 |
#設置執行錯誤訊息
|
|
|
1126 |
$result["error"]=$divSection;
|
|
|
1127 |
|
|
|
1128 |
#回傳結果
|
|
|
1129 |
return $result;
|
|
|
1130 |
|
|
|
1131 |
}#if end
|
|
|
1132 |
|
|
|
1133 |
#設置要回傳的語法
|
|
|
1134 |
$result["content"]=$divSection["content"];
|
|
|
1135 |
|
|
|
1136 |
#設置執行正常
|
|
|
1137 |
$result["status"]="true";
|
|
|
1138 |
|
|
|
1139 |
#回傳結果
|
|
|
1140 |
return $result;
|
|
|
1141 |
|
|
|
1142 |
}#function div end
|
|
|
1143 |
|
|
|
1144 |
/*
|
|
|
1145 |
#函式說明:
|
|
|
1146 |
#建立多個用div做成的frame.
|
|
|
1147 |
#回傳結果:
|
|
|
1148 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.
|
|
|
1149 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
1150 |
#$result["error"],錯誤訊息提示.
|
|
|
1151 |
#$result["content"],div frame的語法.
|
|
|
1152 |
#必填參數:
|
|
|
1153 |
#$conf["id"],字串陣列,每個div frame的id.
|
|
|
1154 |
$conf["id"]=array("");
|
|
|
1155 |
#可省略參數:
|
|
|
1156 |
#$conf["content"],二維字串陣列,要放入到每個frame的內容,預設不使用,若有個要放有的不要放內容,則不放內容的元素設為null.
|
|
|
1157 |
#$conf["content"]=array(array());
|
|
|
1158 |
#$conf["oneScreenSize"],字串陣列,各個frame是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.
|
|
|
1159 |
#$conf["oneScreenSize"]=array("");
|
|
|
1160 |
#$conf["height"],字串陣列,各個frame的高度,若不設置則請給予null,若 "oneScreenSize" 設置為 "true",則忽略本參數.
|
|
|
1161 |
#$conf["height"]=array("");
|
|
|
1162 |
#$conf["div2heightIsSeeHeightLessDiv1height"],字串,"true"代表第2個 div frame如果要跟第1個 div frame 來動態調整高度為用戶看到的高度減去第1個 div frame高度;預設為"false"代表不使用.若 "content" 的元素數量不等於2則會強制為"false".
|
|
|
1163 |
#$conf["div2heightIsSeeHeightLessDiv1height"]="false";
|
|
|
1164 |
#參考資料:
|
|
|
1165 |
#無.
|
|
|
1166 |
#備註:
|
|
|
1167 |
#無.
|
|
|
1168 |
*/
|
|
|
1169 |
public static function multiDiv(&$conf=array()){
|
|
|
1170 |
|
|
|
1171 |
#初始化要回傳的結果
|
|
|
1172 |
$result=array();
|
|
|
1173 |
|
|
|
1174 |
#取得當前執行的函數名稱
|
|
|
1175 |
$result["function"]=__FUNCTION__;
|
|
|
1176 |
|
|
|
1177 |
#初始化語法
|
|
|
1178 |
$result["content"]="";
|
|
|
1179 |
|
|
|
1180 |
#如果沒有參數
|
|
|
1181 |
if(func_num_args()==0){
|
|
|
1182 |
|
|
|
1183 |
#設置執行失敗
|
|
|
1184 |
$result["status"]="false";
|
|
|
1185 |
|
|
|
1186 |
#設置執行錯誤訊息
|
|
|
1187 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
1188 |
|
|
|
1189 |
#回傳結果
|
|
|
1190 |
return $result;
|
|
|
1191 |
|
|
|
1192 |
}#if end
|
|
|
1193 |
|
|
|
1194 |
#取得參數
|
|
|
1195 |
$result["argu"]=$conf;
|
|
|
1196 |
|
|
|
1197 |
#如果 $conf 不為陣列
|
|
|
1198 |
if(gettype($conf)!=="array"){
|
|
|
1199 |
|
|
|
1200 |
#設置執行失敗
|
|
|
1201 |
$result["status"]="false";
|
|
|
1202 |
|
|
|
1203 |
#設置執行錯誤訊息
|
|
|
1204 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
1205 |
|
|
|
1206 |
#如果傳入的參數為 null
|
|
|
1207 |
if($conf===null){
|
|
|
1208 |
|
|
|
1209 |
#設置執行錯誤訊息
|
|
|
1210 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
1211 |
|
|
|
1212 |
}#if end
|
|
|
1213 |
|
|
|
1214 |
#回傳結果
|
|
|
1215 |
return $result;
|
|
|
1216 |
|
|
|
1217 |
}#if end
|
|
|
1218 |
|
|
|
1219 |
#檢查參數
|
|
|
1220 |
#函式說明:
|
|
|
1221 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
1222 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1223 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
1224 |
#$result["function"],當前執行的函式名稱.
|
|
|
1225 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
1226 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
1227 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
1228 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
1229 |
#必填寫的參數:
|
|
|
1230 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
1231 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
1232 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
1233 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");
|
|
|
1234 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
1235 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
|
|
|
1236 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
1237 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
1238 |
#可以省略的參數:
|
|
|
1239 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
1240 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
1241 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
1242 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("content","oneScreenSize","height","div2heightIsSeeHeightLessDiv1height");
|
|
|
1243 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
1244 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","string");
|
|
|
1245 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
1246 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"false");
|
|
|
1247 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
1248 |
#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
|
|
|
1249 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1250 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1251 |
|
|
|
1252 |
#如果檢查失敗
|
|
|
1253 |
if($checkResult["status"]=="false"){
|
|
|
1254 |
|
|
|
1255 |
#設置執行不正常
|
|
|
1256 |
$result["status"]="false";
|
|
|
1257 |
|
|
|
1258 |
#設置錯誤訊息
|
|
|
1259 |
$result["error"]=$checkResult;
|
|
|
1260 |
|
|
|
1261 |
#回傳結果
|
|
|
1262 |
return $result;
|
|
|
1263 |
|
|
|
1264 |
}#if end
|
|
|
1265 |
|
|
|
1266 |
#如果檢查不通過
|
|
|
1267 |
if($checkResult["passed"]=="false"){
|
|
|
1268 |
|
|
|
1269 |
#設置執行不正常
|
|
|
1270 |
$result["status"]="false";
|
|
|
1271 |
|
|
|
1272 |
#設置錯誤訊息
|
|
|
1273 |
$result["error"]=$checkResult;
|
|
|
1274 |
|
|
|
1275 |
#回傳結果
|
|
|
1276 |
return $result;
|
|
|
1277 |
|
|
|
1278 |
}#if end
|
|
|
1279 |
|
|
|
1280 |
#有幾個 $conf["id"] 就執行幾次
|
|
|
1281 |
for($i=0;$i<count($conf["id"]);$i++){
|
|
|
1282 |
|
|
|
1283 |
#函式說明:
|
|
|
1284 |
#用div做成的frame.
|
|
|
1285 |
#回傳結果:
|
|
|
1286 |
#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.
|
|
|
1287 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
1288 |
#$result["error"],錯誤訊息提示.
|
|
|
1289 |
#$result["content"],div frame的語法.
|
|
|
1290 |
#必填參數:
|
|
|
1291 |
#$conf["id"],字串,div frame的id.
|
|
|
1292 |
$conf["frame::div"]["id"]=$conf["id"][$i];
|
|
|
1293 |
#可省略參數:
|
|
|
1294 |
#$conf["content"],字串陣列,要放入到frame的內容,預設不使用.
|
|
|
1295 |
|
|
|
1296 |
#如果存在 "content"
|
|
|
1297 |
if(isset($conf["content"])){
|
|
|
1298 |
|
|
|
1299 |
#如果存在 ["content"][$i]
|
|
|
1300 |
if(isset($conf["content"][$i])){
|
|
|
1301 |
|
|
|
1302 |
#如果不為
|
|
|
1303 |
if($conf["content"][$i]!==null){
|
|
|
1304 |
|
|
|
1305 |
#設置frame的內容
|
|
|
1306 |
$conf["frame::div"]["content"]=$conf["content"][$i];
|
|
|
1307 |
|
|
|
1308 |
#var_dump($conf["frame::div"]["content"][$i]);
|
|
|
1309 |
|
|
|
1310 |
}#if end
|
|
|
1311 |
|
|
|
1312 |
}#if end
|
|
|
1313 |
|
|
|
1314 |
}#if end
|
|
|
1315 |
|
|
|
1316 |
#$conf["oneScreenSize"],字串,是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.
|
|
|
1317 |
|
|
|
1318 |
#如果存在 oneScreenSize
|
|
|
1319 |
if(isset($conf["oneScreenSize"])){
|
|
|
1320 |
|
|
|
1321 |
#如果存在 ["oneScreenSize"][$i]
|
|
|
1322 |
if(isset($conf["oneScreenSize"][$i])){
|
|
|
1323 |
|
|
|
1324 |
#如果不為
|
|
|
1325 |
if($conf["oneScreenSize"][$i]!==null){
|
|
|
1326 |
|
|
|
1327 |
#設置frame的內容
|
|
|
1328 |
$conf["frame::div"]["oneScreenSize"]=$conf["oneScreenSize"][$i];
|
|
|
1329 |
|
|
|
1330 |
}#if end
|
|
|
1331 |
|
|
|
1332 |
}#if end
|
|
|
1333 |
|
|
|
1334 |
}#if end
|
|
|
1335 |
|
|
|
1336 |
#$conf["height"],字串,frame的高度,若 "oneScreenSize" 設置為 "true",則忽略本參數.
|
|
|
1337 |
|
|
|
1338 |
#如果存在 height
|
|
|
1339 |
if(isset($conf["height"])){
|
|
|
1340 |
|
|
|
1341 |
#如果存在 ["height"][$i]
|
|
|
1342 |
if(isset($conf["height"][$i])){
|
|
|
1343 |
|
|
|
1344 |
#如果不為
|
|
|
1345 |
if($conf["height"][$i]!==null){
|
|
|
1346 |
|
|
|
1347 |
#設置frame的內容
|
|
|
1348 |
$conf["frame::div"]["height"]=$conf["height"][$i];
|
|
|
1349 |
|
|
|
1350 |
}#if end
|
|
|
1351 |
|
|
|
1352 |
}#if end
|
|
|
1353 |
|
|
|
1354 |
}#if end
|
|
|
1355 |
|
|
|
1356 |
$div=frame::div($conf["frame::div"]);
|
|
|
1357 |
unset($conf["frame::div"]);
|
|
|
1358 |
|
|
|
1359 |
#如果建立失敗
|
|
|
1360 |
if($div["status"]==="false"){
|
|
|
1361 |
|
|
|
1362 |
#設置執行不正常
|
|
|
1363 |
$result["status"]="false";
|
|
|
1364 |
|
|
|
1365 |
#設置錯誤訊息
|
|
|
1366 |
$result["error"]=$div;
|
|
|
1367 |
|
|
|
1368 |
#回傳結果
|
|
|
1369 |
return $result;
|
|
|
1370 |
|
|
|
1371 |
}#if end
|
|
|
1372 |
|
|
|
1373 |
#串接 div frame
|
|
|
1374 |
$result["content"]=$result["content"].$div["content"];
|
|
|
1375 |
|
|
|
1376 |
}#for end
|
|
|
1377 |
|
|
|
1378 |
#如果剛好有兩個div frame
|
|
|
1379 |
if(count($conf["id"])===2 && $conf["div2heightIsSeeHeightLessDiv1height"]==="true"){
|
|
|
1380 |
|
|
|
1381 |
#函式說明:
|
|
|
1382 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
1383 |
#回傳結果:
|
|
|
1384 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
1385 |
#$result["error"],錯誤訊息陣列
|
|
|
1386 |
#$result["function"],當前執行的函數名稱
|
|
|
1387 |
#$result["content"],要執行的javaScript語法
|
|
|
1388 |
#必填參數:
|
|
|
1389 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
1390 |
$conf["javascript::toScript"]["script"]=
|
|
|
1391 |
"
|
|
|
1392 |
window.changeDivFrameEleHeightToFullLessSource.changeSizeFrameId='".$conf["id"][0]."';
|
|
|
1393 |
window.changeDivFrameEleHeightToFullLessSource.fixedSizeFrameId='".$conf["id"][1]."';
|
|
|
1394 |
";
|
|
|
1395 |
#可省略參數:
|
|
|
1396 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
1397 |
$conf["javascript::toScript"]["onReady"]="false";
|
|
|
1398 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
1399 |
#$conf["globalJs"]=array();
|
|
|
1400 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
1401 |
#$conf["jsFunciton"]=array();
|
|
|
1402 |
#參考資料:
|
|
|
1403 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
1404 |
$toScript=javascript::toScript($conf["javascript::toScript"]);
|
|
|
1405 |
unset($conf["javascript::toScript"]);
|
|
|
1406 |
|
|
|
1407 |
#如果建立script失敗
|
|
|
1408 |
if($toScript["status"]==="false"){
|
|
|
1409 |
|
|
|
1410 |
#設置執行不正常
|
|
|
1411 |
$result["status"]="false";
|
|
|
1412 |
|
|
|
1413 |
#設置錯誤訊息
|
|
|
1414 |
$result["error"]=$toScript;
|
|
|
1415 |
|
|
|
1416 |
#回傳結果
|
|
|
1417 |
return $result;
|
|
|
1418 |
|
|
|
1419 |
}#if end
|
|
|
1420 |
|
|
|
1421 |
#串接語法
|
|
|
1422 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
1423 |
|
|
|
1424 |
}#if end
|
|
|
1425 |
|
|
|
1426 |
#設置執行正常
|
|
|
1427 |
$result["status"]="true";
|
|
|
1428 |
|
|
|
1429 |
#回傳結果
|
|
|
1430 |
return $result;
|
|
|
1431 |
|
|
|
1432 |
}#function multiDiv end
|
|
|
1433 |
|
|
|
1434 |
}#class frame end
|
|
|
1435 |
|
|
|
1436 |
?>
|