| 1 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 623 |
liveuser |
6 |
Copyright (C) 2015~2024 Min-Jhin,Chen
|
| 1 |
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 |
|
| 242 |
liveuser |
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
tab應用相關的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
| 1 |
liveuser |
32 |
class tab{
|
|
|
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 |
#建立給行動版頁面使用的分頁功能
|
|
|
101 |
#回傳結果:
|
|
|
102 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
103 |
#$result["error"],錯誤訊息陣列.
|
|
|
104 |
#$result["function"],當前執行的函數名稱
|
|
|
105 |
#$result["content"],建立bootstrap樣式分頁的語法
|
|
|
106 |
#必填參數:
|
|
|
107 |
#$conf["liName"],字串陣列,每個分頁標籤的名稱.
|
|
|
108 |
$conf["liName"]=array();
|
|
|
109 |
#$conf["liContent"],字串陣列,每個分頁底下的內容為什麼.
|
|
|
110 |
$conf["liContent"]=array();
|
|
|
111 |
#可省略參數:
|
|
|
112 |
#$conf["liIdHeadStr"],字串,每個分頁的id開頭字串,預設為"mobileTab",若在一分html文件裡面使用多個mobile()則會導致衝突,請務必個別指派不同的數值.
|
|
|
113 |
#$conf["liIdHeadStr"]="";
|
|
|
114 |
*/
|
|
|
115 |
function mobile(&$conf){
|
|
|
116 |
|
|
|
117 |
#初始化要回傳的結果
|
|
|
118 |
$result=array();
|
|
|
119 |
|
|
|
120 |
#初始化語法
|
|
|
121 |
$result["content"]="";
|
|
|
122 |
|
|
|
123 |
#取得當前執行的函數名稱
|
|
|
124 |
$result["function"]=__FUNCTION__;
|
|
|
125 |
|
|
|
126 |
#如果沒有參數
|
|
|
127 |
if(func_num_args()==0){
|
|
|
128 |
|
|
|
129 |
#設置執行失敗
|
|
|
130 |
$result["status"]="false";
|
|
|
131 |
|
|
|
132 |
#設置執行錯誤訊息
|
|
|
133 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
134 |
|
|
|
135 |
#回傳結果
|
|
|
136 |
return $result;
|
|
|
137 |
|
|
|
138 |
}#if end
|
|
|
139 |
|
|
|
140 |
#取得參數
|
|
|
141 |
$result["argu"]=$conf;
|
|
|
142 |
|
|
|
143 |
#如果 $conf 不為陣列
|
|
|
144 |
if(gettype($conf)!="array"){
|
|
|
145 |
|
|
|
146 |
#設置執行失敗
|
|
|
147 |
$result["status"]="false";
|
|
|
148 |
|
|
|
149 |
#設置執行錯誤訊息
|
|
|
150 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
151 |
|
|
|
152 |
#如果傳入的參數為 null
|
|
|
153 |
if($conf==null){
|
|
|
154 |
|
|
|
155 |
#設置執行錯誤訊息
|
|
|
156 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
157 |
|
|
|
158 |
}#if end
|
|
|
159 |
|
|
|
160 |
#回傳結果
|
|
|
161 |
return $result;
|
|
|
162 |
|
|
|
163 |
}#if end
|
|
|
164 |
|
|
|
165 |
#檢查參數
|
|
|
166 |
#函式說明:
|
|
|
167 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
168 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
169 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
170 |
#$result["function"],當前執行的函式名稱.
|
|
|
171 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
172 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
173 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
174 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
175 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
176 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
177 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
178 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
179 |
#必填寫的參數:
|
|
|
180 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
181 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
182 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
183 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("liName","liContent");
|
|
|
184 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
185 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array");
|
|
|
186 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
187 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
188 |
#可以省略的參數:
|
|
|
189 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
190 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
191 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
192 |
$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("liName");
|
|
|
193 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
194 |
#$conf["canBeEmpty"]=array();
|
|
|
195 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
196 |
#$conf["skipableVariableCanNotBeEmpty"]=array();
|
|
|
197 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
198 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liIdHeadStr");
|
|
|
199 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
200 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
|
|
|
201 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
202 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("mobileTab");
|
|
|
203 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
204 |
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet");
|
|
|
205 |
#參考資料來源:
|
|
|
206 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
207 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
208 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
209 |
|
|
|
210 |
#如果檢查參數失敗
|
|
|
211 |
if($checkArguments["status"]=="false"){
|
|
|
212 |
|
|
|
213 |
#設置執行失敗
|
|
|
214 |
$result["status"]="false";
|
|
|
215 |
|
|
|
216 |
#設置執行錯誤訊息
|
|
|
217 |
$result["error"]=$checkArguments;
|
|
|
218 |
|
|
|
219 |
#回傳結果
|
|
|
220 |
return $result;
|
|
|
221 |
|
|
|
222 |
}#if end
|
|
|
223 |
|
|
|
224 |
#如果檢查參數不通過
|
|
|
225 |
if($checkArguments["passed"]=="false"){
|
|
|
226 |
|
|
|
227 |
#設置執行失敗
|
|
|
228 |
$result["status"]="false";
|
|
|
229 |
|
|
|
230 |
#設置執行錯誤訊息
|
|
|
231 |
$result["error"]=$checkArguments;
|
|
|
232 |
|
|
|
233 |
#回傳結果
|
|
|
234 |
return $result;
|
|
|
235 |
|
|
|
236 |
}#if end
|
|
|
237 |
|
|
|
238 |
#涵式說明:
|
|
|
239 |
#建立給與html標籤使用的style屬性字串.
|
|
|
240 |
#回傳的結果:
|
|
|
241 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
242 |
#$result["function"],當前執行的函數
|
|
|
243 |
#$result["error"],錯誤訊息陣列
|
|
|
244 |
#$result["content"],css設定內容
|
|
|
245 |
#必填的參數:
|
|
|
246 |
$conf["css::styleStr"]["styleName"]=array("font-size","display","padding-left","padding-right","padding-top","padding-bottom");#為屬性名稱,須為陣列值
|
|
|
247 |
$conf["css::styleStr"]["styleValue"]=array("26px","inline","15px","15px","10px","10px");#為屬性值,須為陣列值
|
|
|
248 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
249 |
unset($conf["css::styleStr"]);
|
|
|
250 |
|
|
|
251 |
#如果建立 style 屬性字串失敗
|
|
|
252 |
if($styleStr["status"]=="false"){
|
|
|
253 |
|
|
|
254 |
#設置執行失敗
|
|
|
255 |
$result["status"]="false";
|
|
|
256 |
|
|
|
257 |
#設置執行錯誤訊息
|
|
|
258 |
$result["error"]=$styleStr;
|
|
|
259 |
|
|
|
260 |
#回傳結果
|
|
|
261 |
return $result;
|
|
|
262 |
|
|
|
263 |
}#if end
|
|
|
264 |
|
|
|
265 |
#tag標題開始
|
|
|
266 |
$result["content"]=$result["content"]."<div>";
|
|
|
267 |
|
|
|
268 |
#上一頁的元素id
|
|
|
269 |
$prePageId=$conf["liIdHeadStr"]."_prePage";
|
|
|
270 |
|
|
|
271 |
#上一頁的標籤
|
|
|
272 |
$result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
|
|
|
273 |
$result["content"]=$result["content"]."<span id=\"".$prePageId."\" class=\"btn btn-default\" >上一頁</span>";
|
|
|
274 |
$result["content"]=$result["content"]."</span>";
|
|
|
275 |
|
|
|
276 |
#當前標題的標籤
|
|
|
277 |
$result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
|
|
|
278 |
$result["content"]=$result["content"]."<span></span>";
|
|
|
279 |
$result["content"]=$result["content"]."</span>";
|
|
|
280 |
|
|
|
281 |
#下一頁的元素id
|
|
|
282 |
$nextPageId=$conf["liIdHeadStr"]."_nextPage";
|
|
|
283 |
|
|
|
284 |
#下一頁的標籤
|
|
|
285 |
$result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
|
|
|
286 |
$result["content"]=$result["content"]."<span id=\"".$nextPageId."\" class=\"btn btn-default\" >下一頁</span>";
|
|
|
287 |
$result["content"]=$result["content"]."</span>";
|
|
|
288 |
|
|
|
289 |
#tag標題結束
|
|
|
290 |
$result["content"]=$result["content"]."</div>";
|
|
|
291 |
|
|
|
292 |
#設置隱藏樣式的css類別名稱
|
|
|
293 |
$hideClass=$conf["liIdHeadStr"]."_hide";
|
|
|
294 |
|
|
|
295 |
#建立 $tabIdHeadStr.hide 類別
|
|
|
296 |
#涵式說明:
|
|
|
297 |
#創建 css 樣式,前面會自動加上「.」.
|
|
|
298 |
#回傳的結果:
|
|
|
299 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
300 |
#$result["css"],css設定內容
|
|
|
301 |
#$result["function"],當前執行的函數
|
|
|
302 |
#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
|
|
|
303 |
#必填的參數:
|
|
|
304 |
$conf["css::createCssStyle"]["cssStyleName"]=$hideClass;#為該 css 樣式的名稱,不能以數字開頭,限定id的css樣式名稱為「樣式名稱.元素名稱」.
|
|
|
305 |
$conf["css::createCssStyle"]["attributes"]=array("display");#為屬性名稱,須為陣列值
|
|
|
306 |
$conf["css::createCssStyle"]["content"]=array("none");#為屬性值,須為陣列值
|
|
|
307 |
$createCssStyle=css::createCssStyle($conf["css::createCssStyle"]);
|
|
|
308 |
unset($conf["css::createCssStyle"]);
|
|
|
309 |
|
|
|
310 |
#如果建立 css 樣式失敗
|
|
|
311 |
if($createCssStyle["status"]=="false"){
|
|
|
312 |
|
|
|
313 |
$result["status"]="false";
|
|
|
314 |
|
|
|
315 |
#設置執行錯誤訊息
|
|
|
316 |
$result["error"]=$createCssStyle;
|
|
|
317 |
|
|
|
318 |
#回傳結果
|
|
|
319 |
return $result;
|
|
|
320 |
|
|
|
321 |
}#if end
|
|
|
322 |
|
|
|
323 |
#串接 css 樣式
|
|
|
324 |
$result["content"]=$result["content"].$createCssStyle["css"];
|
|
|
325 |
|
|
|
326 |
#儲存總共有幾個tab
|
|
|
327 |
$tabCount=count($conf["liContent"]);
|
|
|
328 |
|
|
|
329 |
#$conf["liContent"]有幾個元素就執行幾次
|
|
|
330 |
for($i=0;$i<$tabCount;$i++){
|
|
|
331 |
|
|
|
332 |
#設置div區塊
|
|
|
333 |
#涵式說明:
|
|
|
334 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
335 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
336 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
337 |
#$result["error"],陣列,錯訊訊息.
|
|
|
338 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
339 |
#必填參數:
|
|
|
340 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
341 |
$conf["css::divSection"]["contentArray"]=array($conf["liContent"][$i]);
|
|
|
342 |
#可省略參數
|
|
|
343 |
#$conf["id"],字串,div區塊的id.
|
|
|
344 |
$conf["css::divSection"]["id"]=$conf["liIdHeadStr"].$i;
|
|
|
345 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
346 |
$conf["css::divSection"]["class"]=$hideClass;
|
|
|
347 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
348 |
#$conf["title"]=array();
|
|
|
349 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
350 |
unset($conf["css::divSection"]);
|
|
|
351 |
|
|
|
352 |
#如果建立div區塊失敗
|
|
|
353 |
if($divSection["status"]=="false"){
|
|
|
354 |
|
|
|
355 |
#設置執行失敗
|
|
|
356 |
$result["status"]="false";
|
|
|
357 |
|
|
|
358 |
#設置執行錯誤訊息
|
|
|
359 |
$result["error"]=$divSection;
|
|
|
360 |
|
|
|
361 |
#回傳結果
|
|
|
362 |
return $result;
|
|
|
363 |
|
|
|
364 |
}#if end
|
|
|
365 |
|
|
|
366 |
#串接div的內容
|
|
|
367 |
$result["content"]=$result["content"].$divSection["content"];
|
|
|
368 |
|
|
|
369 |
}#for end
|
|
|
370 |
|
|
|
371 |
#儲存tab名稱變數
|
|
|
372 |
$jsonArray["tabList"]=$conf["liName"];
|
|
|
373 |
|
|
|
374 |
#預設要顯示的tab index
|
|
|
375 |
$jsonArray["tabToShow"]=0;
|
|
|
376 |
|
|
|
377 |
#轉換成json變數
|
|
|
378 |
$jsonData=json_encode($jsonArray);
|
|
|
379 |
|
|
|
380 |
#設置暫存新分頁資訊的webstorage名稱
|
|
|
381 |
$tempWebStorage=$conf["liIdHeadStr"]."_tempWebStorage";
|
|
|
382 |
|
|
|
383 |
#設置儲存哪個分頁要顯示以及每個分頁標題的webSorage變數.
|
|
|
384 |
#涵式說明:
|
|
|
385 |
#儲存變數到local storage
|
|
|
386 |
#回傳結果:
|
|
|
387 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
388 |
#$result["error"],錯誤訊息陣列
|
|
|
389 |
#$result["function"],當前執行的函數名稱
|
|
|
390 |
#$result["content"],要執行的javaScript語法
|
|
|
391 |
#必填參數:
|
|
|
392 |
#$conf["key"],字串,要儲存的key為何.
|
|
|
393 |
$conf["javaScript::saveToLocalStorage"]["key"]=$tempWebStorage;
|
|
|
394 |
#$conf["val"],字串,要儲存的val為何.
|
|
|
395 |
$conf["javaScript::saveToLocalStorage"]["val"]=$jsonData;
|
|
|
396 |
#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
|
|
|
397 |
#$conf["javaScript::saveToLocalStorage"]["noScriptTag"]="false";
|
|
|
398 |
$saveToLocalStorage=javaScript::saveToLocalStorage($conf["javaScript::saveToLocalStorage"]);
|
|
|
399 |
unset($conf["javaScript::saveToLocalStorage"]);
|
|
|
400 |
|
|
|
401 |
#如果建立local storage失敗
|
|
|
402 |
if($saveToLocalStorage["status"]==="false"){
|
|
|
403 |
|
|
|
404 |
#設置執行失敗
|
|
|
405 |
$result["status"]="false";
|
|
|
406 |
|
|
|
407 |
#設置執行錯誤訊息
|
|
|
408 |
$result["error"]=$saveToLocalStorage;
|
|
|
409 |
|
|
|
410 |
#回傳結果
|
|
|
411 |
return $result;
|
|
|
412 |
|
|
|
413 |
}#if end
|
|
|
414 |
|
|
|
415 |
#串接內容
|
|
|
416 |
$result["content"]=$result["content"].$saveToLocalStorage["content"];
|
|
|
417 |
|
|
|
418 |
#設置儲存既有分頁資訊的webstorage名稱
|
|
|
419 |
$webStorage=$conf["liIdHeadStr"]."_webStorage";
|
|
|
420 |
|
|
|
421 |
#設置儲存既有分頁資訊的js變數名稱
|
|
|
422 |
$currentTabInfo=$conf["liIdHeadStr"]."currentTabInfo";
|
|
|
423 |
|
|
|
424 |
#檢查是否存在既有分頁資訊的 local storage 變數.
|
|
|
425 |
#涵式說明:
|
|
|
426 |
#取得儲存在local storage的變數
|
|
|
427 |
#回傳結果:
|
|
|
428 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
429 |
#$result["error"],錯誤訊息陣列
|
|
|
430 |
#$result["function"],當前執行的函數名稱
|
|
|
431 |
#$result["content"],要執行的javaScript語法
|
|
|
432 |
#必填參數:
|
|
|
433 |
#$conf["key"],字串,要儲存的key為何.
|
|
|
434 |
$conf["javaScript::getLocalStorage"]["key"]=$webStorage;
|
|
|
435 |
#$conf["storeVar"],字串,要儲存到哪個javascript變數裡面.
|
|
|
436 |
$conf["javaScript::getLocalStorage"]["storeVar"]=$currentTabInfo;
|
|
|
437 |
#可省略參數:
|
|
|
438 |
#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
|
|
|
439 |
$conf["javaScript::getLocalStorage"]["noScriptTag"]="true";
|
|
|
440 |
#$conf["json"],字串要取出的資料是否json,"true"代表是,"false"代表不是,預設為"false".
|
|
|
441 |
$conf["javaScript::getLocalStorage"]["json"]="true";
|
|
|
442 |
$getLocalStorage=javaScript::getLocalStorage($conf["javaScript::getLocalStorage"]);
|
|
|
443 |
unset($conf["javaScript::getLocalStorage"]);
|
|
|
444 |
|
|
|
445 |
#如果建立語法失敗
|
|
|
446 |
if($getLocalStorage["status"]==="false"){
|
|
|
447 |
|
|
|
448 |
#設置執行失敗
|
|
|
449 |
$result["status"]="false";
|
|
|
450 |
|
|
|
451 |
#設置執行錯誤訊息
|
|
|
452 |
$result["error"]=$getLocalStorage;
|
|
|
453 |
|
|
|
454 |
#回傳結果
|
|
|
455 |
return $result;
|
|
|
456 |
|
|
|
457 |
}#if end
|
|
|
458 |
|
|
|
459 |
#取得儲存在 local storage 中既有的分頁資料
|
|
|
460 |
$script=$getLocalStorage["content"];
|
|
|
461 |
|
|
|
462 |
#設置儲存哪個分頁要顯示以及每個分頁標題的webSorage變數.
|
|
|
463 |
#涵式說明:
|
|
|
464 |
#儲存變數到local storage
|
|
|
465 |
#回傳結果:
|
|
|
466 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
467 |
#$result["error"],錯誤訊息陣列
|
|
|
468 |
#$result["function"],當前執行的函數名稱
|
|
|
469 |
#$result["content"],要執行的javaScript語法
|
|
|
470 |
#必填參數:
|
|
|
471 |
#$conf["key"],字串,要儲存的key為何.
|
|
|
472 |
$conf["javaScript::saveToLocalStorage"]["key"]=$webStorage;
|
|
|
473 |
#$conf["val"],字串,要儲存的val為何.
|
|
|
474 |
$conf["javaScript::saveToLocalStorage"]["val"]=$jsonData;
|
|
|
475 |
#可省略參數:
|
|
|
476 |
#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".
|
|
|
477 |
$conf["javaScript::saveToLocalStorage"]["noScriptTag"]="true";
|
|
|
478 |
$saveToLocalStorage=javaScript::saveToLocalStorage($conf["javaScript::saveToLocalStorage"]);
|
|
|
479 |
unset($conf["javaScript::saveToLocalStorage"]);
|
|
|
480 |
|
|
|
481 |
#如果建立local storage失敗
|
|
|
482 |
if($saveToLocalStorage["status"]==="false"){
|
|
|
483 |
|
|
|
484 |
#設置執行失敗
|
|
|
485 |
$result["status"]="false";
|
|
|
486 |
|
|
|
487 |
#設置執行錯誤訊息
|
|
|
488 |
$result["error"]=$saveToLocalStorage;
|
|
|
489 |
|
|
|
490 |
#回傳結果
|
|
|
491 |
return $result;
|
|
|
492 |
|
|
|
493 |
}#if end
|
|
|
494 |
|
|
|
495 |
#涵式說明:
|
|
|
496 |
#移除儲存在local storage的變數
|
|
|
497 |
#回傳結果:
|
|
|
498 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
499 |
#$result["error"],錯誤訊息陣列
|
|
|
500 |
#$result["function"],當前執行的函數名稱
|
|
|
501 |
#$result["content"],要執行的javaScript語法
|
|
|
502 |
#必填參數:
|
|
|
503 |
#$conf["key"],字串,要儲存的key為何.
|
|
|
504 |
$conf["javaScript::rmLocalStorage"]["key"]=$tempWebStorage;
|
|
|
505 |
#可省略參數:
|
|
|
506 |
#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".
|
|
|
507 |
$conf["javaScript::rmLocalStorage"]["noScriptTag"]="true";
|
|
|
508 |
$rmLocalStorage=javaScript::rmLocalStorage($conf["javaScript::rmLocalStorage"]);
|
|
|
509 |
unset($conf["javaScript::rmLocalStorage"]);
|
|
|
510 |
|
|
|
511 |
#如果建立移除暫存 local storage 變數的語法失敗
|
|
|
512 |
if($rmLocalStorage["status"]=="false"){
|
|
|
513 |
|
|
|
514 |
#設置執行失敗
|
|
|
515 |
$result["status"]="false";
|
|
|
516 |
|
|
|
517 |
#設置執行錯誤訊息
|
|
|
518 |
$result["error"]=$rmLocalStorage;
|
|
|
519 |
|
|
|
520 |
#回傳結果
|
|
|
521 |
return $result;
|
|
|
522 |
|
|
|
523 |
}#if end
|
|
|
524 |
|
|
|
525 |
#建立 prePage 的事件
|
|
|
526 |
#涵式說明:
|
|
|
527 |
#建立特定元素的jquery on click事件
|
|
|
528 |
#回傳結果:
|
|
|
529 |
#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.
|
|
|
530 |
#$result["error"],錯誤訊息陣列.
|
|
|
531 |
#$result["content"],JavaScript的語法.
|
|
|
532 |
#$result["function"],當前執行的函數名稱.
|
|
|
533 |
#$result["importJS"],匯入js的語法,必定含有<script></script>標籤.
|
|
|
534 |
#必填參數:
|
|
|
535 |
#$conf["trigger"],字串,要設定click事件的目標(selector),可以為ID("#element_id"),class(".trigger"),tag("div"),tag&attr("div[data-action=nextPage]"),combine tag&class("div.flip").
|
|
|
536 |
$conf["jquery::onClick"]["trigger"]="#".$prePageId;
|
|
|
537 |
#$conf["content"],字串,click事件觸發後,要做的事情.
|
|
|
538 |
$conf["jquery::onClick"]["content"]=$getLocalStorage["content"]."
|
|
|
539 |
//取得當前分頁的索引
|
|
|
540 |
index=".$currentTabInfo.".tabToShow;
|
|
|
541 |
|
|
|
542 |
//如果是第一個分頁
|
|
|
543 |
if(index==0)
|
|
|
544 |
{
|
|
|
545 |
return false;
|
|
|
546 |
}
|
|
|
547 |
//反之
|
|
|
548 |
else
|
|
|
549 |
{
|
|
|
550 |
//隱藏切換前的分頁內容
|
|
|
551 |
$('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');
|
|
|
552 |
|
|
|
553 |
//恢復下一頁的功能
|
|
|
554 |
$('#".$nextPageId."').attr('disabled',false);
|
|
|
555 |
|
|
|
556 |
//分頁索引-1
|
|
|
557 |
".$currentTabInfo.".tabToShow=index-1;
|
|
|
558 |
|
|
|
559 |
//如果是一個分頁
|
|
|
560 |
if(".$currentTabInfo.".tabToShow==0)
|
|
|
561 |
{
|
|
|
562 |
//停止上一頁的功能
|
|
|
563 |
$('#".$prePageId."').attr('disabled',true);
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
//更新儲存到localStorage的變數(目前看的分頁)
|
|
|
567 |
localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");
|
|
|
568 |
|
|
|
569 |
//更新分頁標題
|
|
|
570 |
$('#".$prePageId."').parent().next().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
|
|
571 |
|
|
|
572 |
//顯示分頁內容
|
|
|
573 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
|
|
574 |
}
|
|
|
575 |
";
|
|
|
576 |
#可省略參數:
|
|
|
577 |
#$conf["jqueryPath"],字串,jquery的位置,預設不指定.
|
|
|
578 |
#$conf["jqueryPath"]="";
|
|
|
579 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jqueryPath"一起設置,預設為當前檔案的位置.
|
|
|
580 |
#$conf["fileArgu"]=__FILE__;
|
|
|
581 |
#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
|
|
|
582 |
$conf["jquery::onClick"]["noScriptTag"]="true";
|
|
|
583 |
#參考資料:
|
|
|
584 |
#selector=>https://api.jquery.com/category/selectors/
|
|
|
585 |
$prePageClickEvent=jquery::onClick($conf["jquery::onClick"]);
|
|
|
586 |
unset($conf["jquery::onClick"]);
|
|
|
587 |
|
|
|
588 |
#如果建立 on click 事件失敗
|
|
|
589 |
if($prePageClickEvent["status"]=="false"){
|
|
|
590 |
|
|
|
591 |
#設置執行失敗
|
|
|
592 |
$result["status"]="false";
|
|
|
593 |
|
|
|
594 |
#設置執行錯誤訊息
|
|
|
595 |
$result["error"]=$prePageClickEvent;
|
|
|
596 |
|
|
|
597 |
#回傳結果
|
|
|
598 |
return $result;
|
|
|
599 |
|
|
|
600 |
}#if end
|
|
|
601 |
|
|
|
602 |
#建立 nextPage 的事件
|
|
|
603 |
#涵式說明:
|
|
|
604 |
#建立特定元素的jquery on click事件
|
|
|
605 |
#回傳結果:
|
|
|
606 |
#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.
|
|
|
607 |
#$result["error"],錯誤訊息陣列.
|
|
|
608 |
#$result["content"],JavaScript的語法.
|
|
|
609 |
#$result["function"],當前執行的函數名稱.
|
|
|
610 |
#$result["importJS"],匯入js的語法,必定含有<script></script>標籤.
|
|
|
611 |
#必填參數:
|
|
|
612 |
#$conf["trigger"],字串,要設定click事件的目標(selector),可以為ID("#element_id"),class(".trigger"),tag("div"),tag&attr("div[data-action=nextPage]"),combine tag&class("div.flip").
|
|
|
613 |
$conf["jquery::onClick"]["trigger"]="#".$nextPageId;
|
|
|
614 |
#$conf["content"],字串,click事件觸發後,要做的事情.
|
|
|
615 |
$conf["jquery::onClick"]["content"]=$getLocalStorage["content"]."
|
|
|
616 |
//取得當前分頁的索引
|
|
|
617 |
index=".$currentTabInfo.".tabToShow;
|
|
|
618 |
|
|
|
619 |
//如果是最後一個分頁
|
|
|
620 |
if(index==".$currentTabInfo.".tabList.length-1)
|
|
|
621 |
{
|
|
|
622 |
return false;
|
|
|
623 |
}
|
|
|
624 |
//反之
|
|
|
625 |
else
|
|
|
626 |
{
|
|
|
627 |
//隱藏切換前的分頁內容
|
|
|
628 |
$('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');
|
|
|
629 |
|
|
|
630 |
//恢復上一頁的功能
|
|
|
631 |
$('#".$prePageId."').attr('disabled',false);
|
|
|
632 |
|
|
|
633 |
//分頁索引+1
|
|
|
634 |
".$currentTabInfo.".tabToShow=index+1;
|
|
|
635 |
|
|
|
636 |
//如果是最後一個分頁
|
|
|
637 |
if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
|
|
|
638 |
{
|
|
|
639 |
//停止下一頁的功能
|
|
|
640 |
$('#".$nextPageId."').attr('disabled',true);
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
//更新儲存到localStorage的變數(目前看的分頁)
|
|
|
644 |
localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");
|
|
|
645 |
|
|
|
646 |
//更新分頁標題
|
|
|
647 |
$('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
|
|
648 |
|
|
|
649 |
//顯示分頁內容
|
|
|
650 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
|
|
651 |
}
|
|
|
652 |
";
|
|
|
653 |
#可省略參數:
|
|
|
654 |
#$conf["jqueryPath"],字串,jquery的位置,預設不指定.
|
|
|
655 |
#$conf["jqueryPath"]="";
|
|
|
656 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jqueryPath"一起設置,預設為當前檔案的位置.
|
|
|
657 |
#$conf["fileArgu"]=__FILE__;
|
|
|
658 |
#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
|
|
|
659 |
$conf["jquery::onClick"]["noScriptTag"]="true";
|
|
|
660 |
#參考資料:
|
|
|
661 |
#selector=>https://api.jquery.com/category/selectors/
|
|
|
662 |
$nextPageClickEvent=jquery::onClick($conf["jquery::onClick"]);
|
|
|
663 |
unset($conf["jquery::onClick"]);
|
|
|
664 |
|
|
|
665 |
#如果建立 on click 事件失敗
|
|
|
666 |
if($nextPageClickEvent["status"]=="false"){
|
|
|
667 |
|
|
|
668 |
#設置執行失敗
|
|
|
669 |
$result["status"]="false";
|
|
|
670 |
|
|
|
671 |
#設置執行錯誤訊息
|
|
|
672 |
$result["error"]=$nextPageClickEvent;
|
|
|
673 |
|
|
|
674 |
#回傳結果
|
|
|
675 |
return $result;
|
|
|
676 |
|
|
|
677 |
}#if end
|
|
|
678 |
|
|
|
679 |
#建立初始化當前瀏覽頁面的功能
|
|
|
680 |
$initialTabViewScript="
|
|
|
681 |
|
|
|
682 |
//取得分頁資訊的變數
|
|
|
683 |
".$getLocalStorage["content"]."
|
|
|
684 |
|
|
|
685 |
//初始化分頁標題
|
|
|
686 |
$('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
|
|
687 |
|
|
|
688 |
//初始化要顯示的分頁內容
|
|
|
689 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
|
|
690 |
|
|
|
691 |
//如果是第一個分頁
|
|
|
692 |
if(".$currentTabInfo.".tabToShow==0)
|
|
|
693 |
{
|
|
|
694 |
//停止上一頁的功能
|
|
|
695 |
$('#".$prePageId."').attr('disabled',true);
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
//如果是最後一個分頁
|
|
|
699 |
if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
|
|
|
700 |
{
|
|
|
701 |
//停止下一頁的功能
|
|
|
702 |
$('#".$nextPageId."').attr('disabled',true);
|
|
|
703 |
}
|
|
|
704 |
";
|
|
|
705 |
|
|
|
706 |
#建立檢查分頁資訊是否存在且結構正確,再決定使用既有的分頁資訊還是建立新的分頁資訊.
|
|
|
707 |
$script=$script."
|
|
|
708 |
|
|
|
709 |
//如果沒有分頁資訊存在
|
|
|
710 |
if(window.".$currentTabInfo."==undefined)
|
|
|
711 |
{
|
|
|
712 |
//建立新的 tab 資訊
|
|
|
713 |
".$saveToLocalStorage["content"]."
|
|
|
714 |
|
|
|
715 |
//將暫存的tab資訊移除
|
|
|
716 |
".$rmLocalStorage["content"]."
|
|
|
717 |
|
|
|
718 |
//設定上一頁按鈕的事件
|
|
|
719 |
".$prePageClickEvent["content"]."
|
|
|
720 |
|
|
|
721 |
//設定下一頁按鈕的事件
|
|
|
722 |
".$nextPageClickEvent["content"]."
|
|
|
723 |
|
|
|
724 |
//初始化要呈現的tab頁面
|
|
|
725 |
".$initialTabViewScript."
|
|
|
726 |
|
|
|
727 |
}//if end
|
|
|
728 |
|
|
|
729 |
//反之檢查既有的tab資訊結構是否正確
|
|
|
730 |
else
|
|
|
731 |
{
|
|
|
732 |
//初始化設置結構檢查不通過
|
|
|
733 |
passed='false';
|
|
|
734 |
|
|
|
735 |
//檢查有無 tabToShow 與 tabList 兩個元素
|
|
|
736 |
if(".$currentTabInfo.".tabToShow!='undefinded' & ".$currentTabInfo.".tabList!='undefinded')
|
|
|
737 |
{
|
|
|
738 |
//檢查 tabToShow 的數值是否正確 與 tabList 的數量是否正確
|
|
|
739 |
if(".$currentTabInfo.".tabToShow<".$tabCount." & ".$currentTabInfo.".tabList.length==.".$tabCount.")
|
|
|
740 |
{
|
|
|
741 |
//設置結構檢查通過
|
|
|
742 |
passed='true';
|
|
|
743 |
|
|
|
744 |
}//if end
|
|
|
745 |
|
|
|
746 |
}//if end
|
|
|
747 |
|
|
|
748 |
//結構資訊正常
|
|
|
749 |
if(passed)
|
|
|
750 |
{
|
|
|
751 |
//將暫存的tab資訊移除
|
|
|
752 |
".$rmLocalStorage["content"]."
|
|
|
753 |
|
|
|
754 |
//設定上一頁按鈕的事件
|
|
|
755 |
".$prePageClickEvent["content"]."
|
|
|
756 |
|
|
|
757 |
//設定下一頁按鈕的事件
|
|
|
758 |
".$nextPageClickEvent["content"]."
|
|
|
759 |
|
|
|
760 |
//初始化要呈現的tab頁面
|
|
|
761 |
".$initialTabViewScript."
|
|
|
762 |
|
|
|
763 |
}//if end
|
|
|
764 |
|
|
|
765 |
//結構資訊不正常
|
|
|
766 |
else
|
|
|
767 |
{
|
|
|
768 |
//建立新的 tab 資訊
|
|
|
769 |
".$saveToLocalStorage["content"]."
|
|
|
770 |
|
|
|
771 |
//將暫存的tab資訊移除
|
|
|
772 |
".$rmLocalStorage["content"]."
|
|
|
773 |
|
|
|
774 |
}//else end
|
|
|
775 |
|
|
|
776 |
}//else end
|
|
|
777 |
";
|
|
|
778 |
|
|
|
779 |
#將 建立檢查分頁資訊是否存在且結構正確,再決定使用既有的分頁資訊還是建立新的分頁資訊 的script語法用<script></script>包起來.
|
|
|
780 |
#涵式說明:
|
|
|
781 |
#將要執行的script語法透過該函式執行
|
|
|
782 |
#回傳結果:
|
|
|
783 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
784 |
#$result["error"],錯誤訊息陣列
|
|
|
785 |
#$result["function"],當前執行的函數名稱
|
|
|
786 |
#$result["content"],要執行的javaScript語法
|
|
|
787 |
#必填的參數:
|
|
|
788 |
#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
|
|
|
789 |
$conf["javaScript::toScript"]["script"]=$script;
|
|
|
790 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
791 |
unset($conf["javaScript::toScript"]);
|
|
|
792 |
|
|
|
793 |
#如果建立
|
|
|
794 |
if($toScript["status"]=="false"){
|
|
|
795 |
|
|
|
796 |
#設置執行失敗
|
|
|
797 |
$result["status"]="false";
|
|
|
798 |
|
|
|
799 |
#設置執行錯誤訊息
|
|
|
800 |
$result["error"]=$toScript;
|
|
|
801 |
|
|
|
802 |
#回傳結果
|
|
|
803 |
return $result;
|
|
|
804 |
|
|
|
805 |
}#if end
|
|
|
806 |
|
|
|
807 |
#串接 script 語法
|
|
|
808 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
809 |
|
|
|
810 |
#用<div></div>包起來
|
|
|
811 |
$result["content"]="<div>".$result["content"]."</div>";
|
|
|
812 |
|
|
|
813 |
#設置執行正常
|
|
|
814 |
$result["status"]="true";
|
|
|
815 |
|
|
|
816 |
#回傳結果
|
|
|
817 |
return $result;
|
|
|
818 |
|
|
|
819 |
}#function mobile end
|
|
|
820 |
|
|
|
821 |
/*
|
|
|
822 |
#函數說明:
|
|
|
823 |
#使用bootstrap樣式建立的分頁功能
|
|
|
824 |
#回傳結果:
|
|
|
825 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
826 |
#$result["error"],錯誤訊息陣列.
|
|
|
827 |
#$result["function"],當前執行的函數名稱
|
|
|
828 |
#$result["content"],建立bootstrap樣式分頁的語法
|
|
|
829 |
#必填參數:
|
|
|
830 |
#$conf["liName"],字串陣列,有幾個分頁標籤.
|
|
|
831 |
$conf["liName"]=array();
|
|
|
832 |
#$conf["liContent"],字串陣列,每個分頁底下的內容為什麼.
|
|
|
833 |
$conf["liContent"]=array();
|
|
|
834 |
#可省略參數:
|
|
|
835 |
#$conf["liId"],陣列,$conf["liContent"]中每個元素的id,用來給$conf["liName"]呼叫要顯示的頁面,預設為$conf["liName"].
|
|
|
836 |
#$conf["liId"]=array();
|
|
|
837 |
#參考資料:
|
|
|
838 |
#http://www.w3schools.com/bootstrap/bootstrap_tabs_pills.asp
|
|
|
839 |
*/
|
|
|
840 |
function bootstrap(&$conf){
|
|
|
841 |
|
|
|
842 |
#初始化要回傳的結果
|
|
|
843 |
$result=array();
|
|
|
844 |
|
|
|
845 |
#取得當前執行的函數名稱
|
|
|
846 |
$result["function"]=__FUNCTION__;
|
|
|
847 |
|
|
|
848 |
#如果沒有參數
|
|
|
849 |
if(func_num_args()==0){
|
|
|
850 |
|
|
|
851 |
#設置執行失敗
|
|
|
852 |
$result["status"]="false";
|
|
|
853 |
|
|
|
854 |
#設置執行錯誤訊息
|
|
|
855 |
$result["error"]="函數".$result["function"]."需要參數";
|
|
|
856 |
|
|
|
857 |
#回傳結果
|
|
|
858 |
return $result;
|
|
|
859 |
|
|
|
860 |
}#if end
|
|
|
861 |
|
|
|
862 |
#取得參數
|
|
|
863 |
$result["argu"]=$conf;
|
|
|
864 |
|
|
|
865 |
#如果 $conf 不為陣列
|
|
|
866 |
if(gettype($conf)!="array"){
|
|
|
867 |
|
|
|
868 |
#設置執行失敗
|
|
|
869 |
$result["status"]="false";
|
|
|
870 |
|
|
|
871 |
#設置執行錯誤訊息
|
|
|
872 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
873 |
|
|
|
874 |
#如果傳入的參數為 null
|
|
|
875 |
if($conf==null){
|
|
|
876 |
|
|
|
877 |
#設置執行錯誤訊息
|
|
|
878 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
879 |
|
|
|
880 |
}#if end
|
|
|
881 |
|
|
|
882 |
#回傳結果
|
|
|
883 |
return $result;
|
|
|
884 |
|
|
|
885 |
}#if end
|
|
|
886 |
|
|
|
887 |
#檢查參數
|
|
|
888 |
#函式說明:
|
|
|
889 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
890 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
891 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
892 |
#$result["function"],當前執行的函式名稱.
|
|
|
893 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
894 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
895 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
896 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
897 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
898 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
899 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
900 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
901 |
#必填寫的參數:
|
|
|
902 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
903 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
904 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
905 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("liName","liContent");
|
|
|
906 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
907 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array");
|
|
|
908 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
909 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
910 |
#可以省略的參數:
|
|
|
911 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
912 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
913 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
914 |
$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("liName");
|
|
|
915 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
916 |
#$conf["canBeEmpty"]=array();
|
|
|
917 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
918 |
#$conf["skipableVariableCanNotBeEmpty"]=array();
|
|
|
919 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
920 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liId");
|
|
|
921 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
922 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
|
|
|
923 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
924 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"liName\"]");
|
|
|
925 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
926 |
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet","liId");
|
|
|
927 |
#參考資料來源:
|
|
|
928 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
929 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
930 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
931 |
|
|
|
932 |
#如果檢查參數失敗
|
|
|
933 |
if($checkArguments["status"]=="false"){
|
|
|
934 |
|
|
|
935 |
#設置執行失敗
|
|
|
936 |
$result["status"]="false";
|
|
|
937 |
|
|
|
938 |
#設置執行錯誤訊息
|
|
|
939 |
$result["error"]=$checkArguments;
|
|
|
940 |
|
|
|
941 |
#回傳結果
|
|
|
942 |
return $result;
|
|
|
943 |
|
|
|
944 |
}#if end
|
|
|
945 |
|
|
|
946 |
#如果檢查參數不通過
|
|
|
947 |
if($checkArguments["passed"]=="false"){
|
|
|
948 |
|
|
|
949 |
#設置執行失敗
|
|
|
950 |
$result["status"]="false";
|
|
|
951 |
|
|
|
952 |
#設置執行錯誤訊息
|
|
|
953 |
$result["error"]=$checkArguments;
|
|
|
954 |
|
|
|
955 |
#回傳結果
|
|
|
956 |
return $result;
|
|
|
957 |
|
|
|
958 |
}#if end
|
|
|
959 |
|
|
|
960 |
#ul開始
|
|
|
961 |
$ul="<ul class=\"nav nav-tabs\">";
|
|
|
962 |
|
|
|
963 |
#初始化tab的內容
|
|
|
964 |
$tab="<div class=\"tab-content\">";
|
|
|
965 |
|
|
|
966 |
#$conf["liName"] 有幾個就執行幾次
|
|
|
967 |
for($i=0;$i<count($conf["liName"]);$i++){
|
|
|
968 |
|
|
|
969 |
#串接 li
|
|
|
970 |
$ul=$ul."<li>";
|
|
|
971 |
$ul=$ul."<a data-toggle=\"tab\" href=\"#".$conf["liId"][$i]."\" >".$conf["liName"][$i]."</a>";
|
|
|
972 |
$ul=$ul."</li>";
|
|
|
973 |
|
|
|
974 |
#如果是第一筆
|
|
|
975 |
if($i===0){
|
|
|
976 |
|
|
|
977 |
#串接 tab 的內容
|
|
|
978 |
$tab=$tab."<div class=\"tab-pane fade in active \" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";
|
|
|
979 |
|
|
|
980 |
}#if end
|
|
|
981 |
|
|
|
982 |
#反之不是第一筆
|
|
|
983 |
else{
|
|
|
984 |
|
|
|
985 |
#串接 tab 的內容
|
|
|
986 |
$tab=$tab."<div class=\"tab-pane fade\" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";
|
|
|
987 |
|
|
|
988 |
}#else end
|
|
|
989 |
|
|
|
990 |
}#for end
|
|
|
991 |
|
|
|
992 |
#ul結束
|
|
|
993 |
$ul=$ul."</ul>";
|
|
|
994 |
|
|
|
995 |
#tab content 結束
|
|
|
996 |
$tab=$tab."</div>";
|
|
|
997 |
|
|
|
998 |
#取得分頁的內容
|
|
|
999 |
$result["content"]=$ul.$tab;
|
|
|
1000 |
|
|
|
1001 |
#設置執行正常
|
|
|
1002 |
$result["status"]="true";
|
|
|
1003 |
|
|
|
1004 |
#回傳結果
|
|
|
1005 |
return $result;
|
|
|
1006 |
|
|
|
1007 |
}#function botostrap
|
|
|
1008 |
|
|
|
1009 |
}#class tab end
|
|
|
1010 |
|
|
|
1011 |
?>
|