| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 226 |
liveuser |
6 |
Copyright (C) 2014~2025 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;
|
| 226 |
liveuser |
25 |
|
| 3 |
liveuser |
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
tab應用相關的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class tab{
|
| 226 |
liveuser |
33 |
|
| 3 |
liveuser |
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){
|
| 226 |
liveuser |
48 |
|
| 3 |
liveuser |
49 |
#取得當前執行的函式
|
|
|
50 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
51 |
|
| 3 |
liveuser |
52 |
#設置執行不正常
|
|
|
53 |
$result["status"]="false";
|
| 226 |
liveuser |
54 |
|
| 3 |
liveuser |
55 |
#設置執行錯誤
|
|
|
56 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
| 226 |
liveuser |
57 |
|
| 3 |
liveuser |
58 |
#設置所丟入的參數
|
|
|
59 |
$result["error"][]=$arguments;
|
| 226 |
liveuser |
60 |
|
| 3 |
liveuser |
61 |
#回傳結果
|
|
|
62 |
return $result;
|
| 226 |
liveuser |
63 |
|
| 3 |
liveuser |
64 |
}#function __call end
|
| 226 |
liveuser |
65 |
|
| 3 |
liveuser |
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){
|
| 226 |
liveuser |
80 |
|
| 3 |
liveuser |
81 |
#取得當前執行的函式
|
|
|
82 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
83 |
|
| 3 |
liveuser |
84 |
#設置執行不正常
|
|
|
85 |
$result["status"]="false";
|
| 226 |
liveuser |
86 |
|
| 3 |
liveuser |
87 |
#設置執行錯誤
|
|
|
88 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
| 226 |
liveuser |
89 |
|
| 3 |
liveuser |
90 |
#設置所丟入的參數
|
|
|
91 |
$result["error"][]=$arguments;
|
| 226 |
liveuser |
92 |
|
| 3 |
liveuser |
93 |
#回傳結果
|
|
|
94 |
return $result;
|
| 226 |
liveuser |
95 |
|
| 3 |
liveuser |
96 |
}#function __callStatic end
|
| 226 |
liveuser |
97 |
|
| 3 |
liveuser |
98 |
/*
|
|
|
99 |
#涵式說明:
|
|
|
100 |
#建立給行動版頁面使用的分頁功能
|
|
|
101 |
#回傳結果:
|
|
|
102 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
103 |
#$result["error"],錯誤訊息陣列.
|
|
|
104 |
#$result["function"],當前執行的函數名稱
|
|
|
105 |
#$result["content"],建立bootstrap樣式分頁的語法
|
|
|
106 |
#必填參數:
|
| 226 |
liveuser |
107 |
#$conf["liName"],字串陣列,每個分頁標籤的名稱.
|
| 3 |
liveuser |
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){
|
| 226 |
liveuser |
116 |
|
| 3 |
liveuser |
117 |
#初始化要回傳的結果
|
|
|
118 |
$result=array();
|
|
|
119 |
|
|
|
120 |
#初始化語法
|
|
|
121 |
$result["content"]="";
|
|
|
122 |
|
|
|
123 |
#取得當前執行的函數名稱
|
|
|
124 |
$result["function"]=__FUNCTION__;
|
|
|
125 |
|
|
|
126 |
#如果沒有參數
|
|
|
127 |
if(func_num_args()==0){
|
| 226 |
liveuser |
128 |
|
| 3 |
liveuser |
129 |
#設置執行失敗
|
|
|
130 |
$result["status"]="false";
|
| 226 |
liveuser |
131 |
|
| 3 |
liveuser |
132 |
#設置執行錯誤訊息
|
|
|
133 |
$result["error"]="函數".$result["function"]."需要參數";
|
| 226 |
liveuser |
134 |
|
| 3 |
liveuser |
135 |
#回傳結果
|
|
|
136 |
return $result;
|
| 226 |
liveuser |
137 |
|
| 3 |
liveuser |
138 |
}#if end
|
| 226 |
liveuser |
139 |
|
| 3 |
liveuser |
140 |
#取得參數
|
|
|
141 |
$result["argu"]=$conf;
|
|
|
142 |
|
|
|
143 |
#如果 $conf 不為陣列
|
|
|
144 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
145 |
|
| 3 |
liveuser |
146 |
#設置執行失敗
|
|
|
147 |
$result["status"]="false";
|
| 226 |
liveuser |
148 |
|
| 3 |
liveuser |
149 |
#設置執行錯誤訊息
|
|
|
150 |
$result["error"][]="\$conf變數須為陣列形態";
|
| 226 |
liveuser |
151 |
|
| 3 |
liveuser |
152 |
#如果傳入的參數為 null
|
|
|
153 |
if($conf==null){
|
| 226 |
liveuser |
154 |
|
| 3 |
liveuser |
155 |
#設置執行錯誤訊息
|
|
|
156 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
157 |
|
| 3 |
liveuser |
158 |
}#if end
|
|
|
159 |
|
|
|
160 |
#回傳結果
|
|
|
161 |
return $result;
|
| 226 |
liveuser |
162 |
|
| 3 |
liveuser |
163 |
}#if end
|
| 226 |
liveuser |
164 |
|
| 3 |
liveuser |
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");
|
| 226 |
liveuser |
199 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
209 |
|
| 3 |
liveuser |
210 |
#如果檢查參數失敗
|
|
|
211 |
if($checkArguments["status"]=="false"){
|
| 226 |
liveuser |
212 |
|
| 3 |
liveuser |
213 |
#設置執行失敗
|
|
|
214 |
$result["status"]="false";
|
| 226 |
liveuser |
215 |
|
| 3 |
liveuser |
216 |
#設置執行錯誤訊息
|
|
|
217 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
218 |
|
| 3 |
liveuser |
219 |
#回傳結果
|
|
|
220 |
return $result;
|
| 226 |
liveuser |
221 |
|
| 3 |
liveuser |
222 |
}#if end
|
| 226 |
liveuser |
223 |
|
| 3 |
liveuser |
224 |
#如果檢查參數不通過
|
|
|
225 |
if($checkArguments["passed"]=="false"){
|
| 226 |
liveuser |
226 |
|
| 3 |
liveuser |
227 |
#設置執行失敗
|
|
|
228 |
$result["status"]="false";
|
| 226 |
liveuser |
229 |
|
| 3 |
liveuser |
230 |
#設置執行錯誤訊息
|
|
|
231 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
232 |
|
| 3 |
liveuser |
233 |
#回傳結果
|
|
|
234 |
return $result;
|
| 226 |
liveuser |
235 |
|
| 3 |
liveuser |
236 |
}#if end
|
| 226 |
liveuser |
237 |
|
|
|
238 |
#涵式說明:
|
| 3 |
liveuser |
239 |
#建立給與html標籤使用的style屬性字串.
|
|
|
240 |
#回傳的結果:
|
| 226 |
liveuser |
241 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
250 |
|
| 3 |
liveuser |
251 |
#如果建立 style 屬性字串失敗
|
|
|
252 |
if($styleStr["status"]=="false"){
|
| 226 |
liveuser |
253 |
|
| 3 |
liveuser |
254 |
#設置執行失敗
|
|
|
255 |
$result["status"]="false";
|
| 226 |
liveuser |
256 |
|
| 3 |
liveuser |
257 |
#設置執行錯誤訊息
|
|
|
258 |
$result["error"]=$styleStr;
|
| 226 |
liveuser |
259 |
|
| 3 |
liveuser |
260 |
#回傳結果
|
|
|
261 |
return $result;
|
| 226 |
liveuser |
262 |
|
| 3 |
liveuser |
263 |
}#if end
|
| 226 |
liveuser |
264 |
|
| 3 |
liveuser |
265 |
#tag標題開始
|
|
|
266 |
$result["content"]=$result["content"]."<div>";
|
| 226 |
liveuser |
267 |
|
| 3 |
liveuser |
268 |
#上一頁的元素id
|
|
|
269 |
$prePageId=$conf["liIdHeadStr"]."_prePage";
|
| 226 |
liveuser |
270 |
|
| 3 |
liveuser |
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>";
|
| 226 |
liveuser |
275 |
|
| 3 |
liveuser |
276 |
#當前標題的標籤
|
|
|
277 |
$result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
|
|
|
278 |
$result["content"]=$result["content"]."<span></span>";
|
|
|
279 |
$result["content"]=$result["content"]."</span>";
|
| 226 |
liveuser |
280 |
|
| 3 |
liveuser |
281 |
#下一頁的元素id
|
|
|
282 |
$nextPageId=$conf["liIdHeadStr"]."_nextPage";
|
| 226 |
liveuser |
283 |
|
| 3 |
liveuser |
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>";
|
| 226 |
liveuser |
288 |
|
| 3 |
liveuser |
289 |
#tag標題結束
|
|
|
290 |
$result["content"]=$result["content"]."</div>";
|
| 226 |
liveuser |
291 |
|
| 3 |
liveuser |
292 |
#設置隱藏樣式的css類別名稱
|
|
|
293 |
$hideClass=$conf["liIdHeadStr"]."_hide";
|
| 226 |
liveuser |
294 |
|
| 3 |
liveuser |
295 |
#建立 $tabIdHeadStr.hide 類別
|
| 226 |
liveuser |
296 |
#涵式說明:
|
| 3 |
liveuser |
297 |
#創建 css 樣式,前面會自動加上「.」.
|
|
|
298 |
#回傳的結果:
|
|
|
299 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
300 |
#$result["css"],css設定內容
|
|
|
301 |
#$result["function"],當前執行的函數
|
| 226 |
liveuser |
302 |
#$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
309 |
|
| 3 |
liveuser |
310 |
#如果建立 css 樣式失敗
|
|
|
311 |
if($createCssStyle["status"]=="false"){
|
| 226 |
liveuser |
312 |
|
| 3 |
liveuser |
313 |
$result["status"]="false";
|
| 226 |
liveuser |
314 |
|
| 3 |
liveuser |
315 |
#設置執行錯誤訊息
|
|
|
316 |
$result["error"]=$createCssStyle;
|
| 226 |
liveuser |
317 |
|
| 3 |
liveuser |
318 |
#回傳結果
|
|
|
319 |
return $result;
|
| 226 |
liveuser |
320 |
|
| 3 |
liveuser |
321 |
}#if end
|
| 226 |
liveuser |
322 |
|
|
|
323 |
#串接 css 樣式
|
| 3 |
liveuser |
324 |
$result["content"]=$result["content"].$createCssStyle["css"];
|
| 226 |
liveuser |
325 |
|
| 3 |
liveuser |
326 |
#儲存總共有幾個tab
|
|
|
327 |
$tabCount=count($conf["liContent"]);
|
| 226 |
liveuser |
328 |
|
| 3 |
liveuser |
329 |
#$conf["liContent"]有幾個元素就執行幾次
|
|
|
330 |
for($i=0;$i<$tabCount;$i++){
|
| 226 |
liveuser |
331 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
351 |
|
| 3 |
liveuser |
352 |
#如果建立div區塊失敗
|
|
|
353 |
if($divSection["status"]=="false"){
|
| 226 |
liveuser |
354 |
|
| 3 |
liveuser |
355 |
#設置執行失敗
|
|
|
356 |
$result["status"]="false";
|
| 226 |
liveuser |
357 |
|
| 3 |
liveuser |
358 |
#設置執行錯誤訊息
|
|
|
359 |
$result["error"]=$divSection;
|
| 226 |
liveuser |
360 |
|
| 3 |
liveuser |
361 |
#回傳結果
|
|
|
362 |
return $result;
|
| 226 |
liveuser |
363 |
|
| 3 |
liveuser |
364 |
}#if end
|
| 226 |
liveuser |
365 |
|
| 3 |
liveuser |
366 |
#串接div的內容
|
|
|
367 |
$result["content"]=$result["content"].$divSection["content"];
|
| 226 |
liveuser |
368 |
|
| 3 |
liveuser |
369 |
}#for end
|
| 226 |
liveuser |
370 |
|
| 3 |
liveuser |
371 |
#儲存tab名稱變數
|
|
|
372 |
$jsonArray["tabList"]=$conf["liName"];
|
| 226 |
liveuser |
373 |
|
| 3 |
liveuser |
374 |
#預設要顯示的tab index
|
| 226 |
liveuser |
375 |
$jsonArray["tabToShow"]=0;
|
|
|
376 |
|
| 3 |
liveuser |
377 |
#轉換成json變數
|
|
|
378 |
$jsonData=json_encode($jsonArray);
|
| 226 |
liveuser |
379 |
|
| 3 |
liveuser |
380 |
#設置暫存新分頁資訊的webstorage名稱
|
|
|
381 |
$tempWebStorage=$conf["liIdHeadStr"]."_tempWebStorage";
|
| 226 |
liveuser |
382 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
400 |
|
| 3 |
liveuser |
401 |
#如果建立local storage失敗
|
|
|
402 |
if($saveToLocalStorage["status"]==="false"){
|
| 226 |
liveuser |
403 |
|
| 3 |
liveuser |
404 |
#設置執行失敗
|
|
|
405 |
$result["status"]="false";
|
| 226 |
liveuser |
406 |
|
| 3 |
liveuser |
407 |
#設置執行錯誤訊息
|
|
|
408 |
$result["error"]=$saveToLocalStorage;
|
| 226 |
liveuser |
409 |
|
| 3 |
liveuser |
410 |
#回傳結果
|
|
|
411 |
return $result;
|
| 226 |
liveuser |
412 |
|
| 3 |
liveuser |
413 |
}#if end
|
| 226 |
liveuser |
414 |
|
| 3 |
liveuser |
415 |
#串接內容
|
|
|
416 |
$result["content"]=$result["content"].$saveToLocalStorage["content"];
|
| 226 |
liveuser |
417 |
|
| 3 |
liveuser |
418 |
#設置儲存既有分頁資訊的webstorage名稱
|
|
|
419 |
$webStorage=$conf["liIdHeadStr"]."_webStorage";
|
| 226 |
liveuser |
420 |
|
| 3 |
liveuser |
421 |
#設置儲存既有分頁資訊的js變數名稱
|
|
|
422 |
$currentTabInfo=$conf["liIdHeadStr"]."currentTabInfo";
|
| 226 |
liveuser |
423 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
444 |
|
| 3 |
liveuser |
445 |
#如果建立語法失敗
|
|
|
446 |
if($getLocalStorage["status"]==="false"){
|
| 226 |
liveuser |
447 |
|
| 3 |
liveuser |
448 |
#設置執行失敗
|
|
|
449 |
$result["status"]="false";
|
| 226 |
liveuser |
450 |
|
| 3 |
liveuser |
451 |
#設置執行錯誤訊息
|
|
|
452 |
$result["error"]=$getLocalStorage;
|
| 226 |
liveuser |
453 |
|
| 3 |
liveuser |
454 |
#回傳結果
|
|
|
455 |
return $result;
|
| 226 |
liveuser |
456 |
|
| 3 |
liveuser |
457 |
}#if end
|
| 226 |
liveuser |
458 |
|
| 3 |
liveuser |
459 |
#取得儲存在 local storage 中既有的分頁資料
|
|
|
460 |
$script=$getLocalStorage["content"];
|
| 226 |
liveuser |
461 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
480 |
|
| 3 |
liveuser |
481 |
#如果建立local storage失敗
|
|
|
482 |
if($saveToLocalStorage["status"]==="false"){
|
| 226 |
liveuser |
483 |
|
| 3 |
liveuser |
484 |
#設置執行失敗
|
|
|
485 |
$result["status"]="false";
|
| 226 |
liveuser |
486 |
|
| 3 |
liveuser |
487 |
#設置執行錯誤訊息
|
|
|
488 |
$result["error"]=$saveToLocalStorage;
|
| 226 |
liveuser |
489 |
|
| 3 |
liveuser |
490 |
#回傳結果
|
|
|
491 |
return $result;
|
| 226 |
liveuser |
492 |
|
| 3 |
liveuser |
493 |
}#if end
|
| 226 |
liveuser |
494 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
510 |
|
| 3 |
liveuser |
511 |
#如果建立移除暫存 local storage 變數的語法失敗
|
|
|
512 |
if($rmLocalStorage["status"]=="false"){
|
| 226 |
liveuser |
513 |
|
| 3 |
liveuser |
514 |
#設置執行失敗
|
|
|
515 |
$result["status"]="false";
|
| 226 |
liveuser |
516 |
|
| 3 |
liveuser |
517 |
#設置執行錯誤訊息
|
|
|
518 |
$result["error"]=$rmLocalStorage;
|
| 226 |
liveuser |
519 |
|
| 3 |
liveuser |
520 |
#回傳結果
|
|
|
521 |
return $result;
|
| 226 |
liveuser |
522 |
|
| 3 |
liveuser |
523 |
}#if end
|
| 226 |
liveuser |
524 |
|
| 3 |
liveuser |
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;
|
| 226 |
liveuser |
541 |
|
| 3 |
liveuser |
542 |
//如果是第一個分頁
|
|
|
543 |
if(index==0)
|
| 226 |
liveuser |
544 |
{
|
| 3 |
liveuser |
545 |
return false;
|
|
|
546 |
}
|
|
|
547 |
//反之
|
|
|
548 |
else
|
|
|
549 |
{
|
|
|
550 |
//隱藏切換前的分頁內容
|
|
|
551 |
$('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');
|
| 226 |
liveuser |
552 |
|
| 3 |
liveuser |
553 |
//恢復下一頁的功能
|
|
|
554 |
$('#".$nextPageId."').attr('disabled',false);
|
| 226 |
liveuser |
555 |
|
| 3 |
liveuser |
556 |
//分頁索引-1
|
|
|
557 |
".$currentTabInfo.".tabToShow=index-1;
|
| 226 |
liveuser |
558 |
|
| 3 |
liveuser |
559 |
//如果是一個分頁
|
|
|
560 |
if(".$currentTabInfo.".tabToShow==0)
|
|
|
561 |
{
|
|
|
562 |
//停止上一頁的功能
|
|
|
563 |
$('#".$prePageId."').attr('disabled',true);
|
|
|
564 |
}
|
| 226 |
liveuser |
565 |
|
| 3 |
liveuser |
566 |
//更新儲存到localStorage的變數(目前看的分頁)
|
|
|
567 |
localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");
|
| 226 |
liveuser |
568 |
|
| 3 |
liveuser |
569 |
//更新分頁標題
|
| 226 |
liveuser |
570 |
$('#".$prePageId."').parent().next().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
|
|
571 |
|
| 3 |
liveuser |
572 |
//顯示分頁內容
|
|
|
573 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
| 226 |
liveuser |
574 |
}
|
|
|
575 |
";
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
587 |
|
| 3 |
liveuser |
588 |
#如果建立 on click 事件失敗
|
|
|
589 |
if($prePageClickEvent["status"]=="false"){
|
| 226 |
liveuser |
590 |
|
| 3 |
liveuser |
591 |
#設置執行失敗
|
|
|
592 |
$result["status"]="false";
|
| 226 |
liveuser |
593 |
|
| 3 |
liveuser |
594 |
#設置執行錯誤訊息
|
|
|
595 |
$result["error"]=$prePageClickEvent;
|
| 226 |
liveuser |
596 |
|
| 3 |
liveuser |
597 |
#回傳結果
|
|
|
598 |
return $result;
|
| 226 |
liveuser |
599 |
|
| 3 |
liveuser |
600 |
}#if end
|
| 226 |
liveuser |
601 |
|
| 3 |
liveuser |
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;
|
| 226 |
liveuser |
618 |
|
| 3 |
liveuser |
619 |
//如果是最後一個分頁
|
|
|
620 |
if(index==".$currentTabInfo.".tabList.length-1)
|
|
|
621 |
{
|
|
|
622 |
return false;
|
|
|
623 |
}
|
|
|
624 |
//反之
|
|
|
625 |
else
|
|
|
626 |
{
|
|
|
627 |
//隱藏切換前的分頁內容
|
|
|
628 |
$('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');
|
| 226 |
liveuser |
629 |
|
| 3 |
liveuser |
630 |
//恢復上一頁的功能
|
|
|
631 |
$('#".$prePageId."').attr('disabled',false);
|
| 226 |
liveuser |
632 |
|
| 3 |
liveuser |
633 |
//分頁索引+1
|
|
|
634 |
".$currentTabInfo.".tabToShow=index+1;
|
| 226 |
liveuser |
635 |
|
| 3 |
liveuser |
636 |
//如果是最後一個分頁
|
|
|
637 |
if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
|
|
|
638 |
{
|
|
|
639 |
//停止下一頁的功能
|
|
|
640 |
$('#".$nextPageId."').attr('disabled',true);
|
|
|
641 |
}
|
| 226 |
liveuser |
642 |
|
| 3 |
liveuser |
643 |
//更新儲存到localStorage的變數(目前看的分頁)
|
|
|
644 |
localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");
|
| 226 |
liveuser |
645 |
|
| 3 |
liveuser |
646 |
//更新分頁標題
|
| 226 |
liveuser |
647 |
$('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
|
|
648 |
|
| 3 |
liveuser |
649 |
//顯示分頁內容
|
|
|
650 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
| 226 |
liveuser |
651 |
}
|
|
|
652 |
";
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
664 |
|
| 3 |
liveuser |
665 |
#如果建立 on click 事件失敗
|
|
|
666 |
if($nextPageClickEvent["status"]=="false"){
|
| 226 |
liveuser |
667 |
|
| 3 |
liveuser |
668 |
#設置執行失敗
|
|
|
669 |
$result["status"]="false";
|
| 226 |
liveuser |
670 |
|
| 3 |
liveuser |
671 |
#設置執行錯誤訊息
|
|
|
672 |
$result["error"]=$nextPageClickEvent;
|
| 226 |
liveuser |
673 |
|
| 3 |
liveuser |
674 |
#回傳結果
|
|
|
675 |
return $result;
|
| 226 |
liveuser |
676 |
|
| 3 |
liveuser |
677 |
}#if end
|
| 226 |
liveuser |
678 |
|
| 3 |
liveuser |
679 |
#建立初始化當前瀏覽頁面的功能
|
|
|
680 |
$initialTabViewScript="
|
| 226 |
liveuser |
681 |
|
| 3 |
liveuser |
682 |
//取得分頁資訊的變數
|
|
|
683 |
".$getLocalStorage["content"]."
|
| 226 |
liveuser |
684 |
|
| 3 |
liveuser |
685 |
//初始化分頁標題
|
|
|
686 |
$('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');
|
| 226 |
liveuser |
687 |
|
| 3 |
liveuser |
688 |
//初始化要顯示的分頁內容
|
|
|
689 |
$('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
|
| 226 |
liveuser |
690 |
|
| 3 |
liveuser |
691 |
//如果是第一個分頁
|
|
|
692 |
if(".$currentTabInfo.".tabToShow==0)
|
|
|
693 |
{
|
|
|
694 |
//停止上一頁的功能
|
|
|
695 |
$('#".$prePageId."').attr('disabled',true);
|
|
|
696 |
}
|
| 226 |
liveuser |
697 |
|
| 3 |
liveuser |
698 |
//如果是最後一個分頁
|
|
|
699 |
if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
|
|
|
700 |
{
|
|
|
701 |
//停止下一頁的功能
|
|
|
702 |
$('#".$nextPageId."').attr('disabled',true);
|
|
|
703 |
}
|
| 226 |
liveuser |
704 |
";
|
|
|
705 |
|
| 3 |
liveuser |
706 |
#建立檢查分頁資訊是否存在且結構正確,再決定使用既有的分頁資訊還是建立新的分頁資訊.
|
|
|
707 |
$script=$script."
|
| 226 |
liveuser |
708 |
|
| 3 |
liveuser |
709 |
//如果沒有分頁資訊存在
|
|
|
710 |
if(window.".$currentTabInfo."==undefined)
|
|
|
711 |
{
|
|
|
712 |
//建立新的 tab 資訊
|
| 226 |
liveuser |
713 |
".$saveToLocalStorage["content"]."
|
|
|
714 |
|
| 3 |
liveuser |
715 |
//將暫存的tab資訊移除
|
|
|
716 |
".$rmLocalStorage["content"]."
|
| 226 |
liveuser |
717 |
|
| 3 |
liveuser |
718 |
//設定上一頁按鈕的事件
|
|
|
719 |
".$prePageClickEvent["content"]."
|
| 226 |
liveuser |
720 |
|
| 3 |
liveuser |
721 |
//設定下一頁按鈕的事件
|
|
|
722 |
".$nextPageClickEvent["content"]."
|
| 226 |
liveuser |
723 |
|
| 3 |
liveuser |
724 |
//初始化要呈現的tab頁面
|
|
|
725 |
".$initialTabViewScript."
|
| 226 |
liveuser |
726 |
|
| 3 |
liveuser |
727 |
}//if end
|
| 226 |
liveuser |
728 |
|
| 3 |
liveuser |
729 |
//反之檢查既有的tab資訊結構是否正確
|
|
|
730 |
else
|
|
|
731 |
{
|
|
|
732 |
//初始化設置結構檢查不通過
|
|
|
733 |
passed='false';
|
| 226 |
liveuser |
734 |
|
| 3 |
liveuser |
735 |
//檢查有無 tabToShow 與 tabList 兩個元素
|
|
|
736 |
if(".$currentTabInfo.".tabToShow!='undefinded' & ".$currentTabInfo.".tabList!='undefinded')
|
|
|
737 |
{
|
|
|
738 |
//檢查 tabToShow 的數值是否正確 與 tabList 的數量是否正確
|
|
|
739 |
if(".$currentTabInfo.".tabToShow<".$tabCount." & ".$currentTabInfo.".tabList.length==.".$tabCount.")
|
| 226 |
liveuser |
740 |
{
|
| 3 |
liveuser |
741 |
//設置結構檢查通過
|
|
|
742 |
passed='true';
|
| 226 |
liveuser |
743 |
|
| 3 |
liveuser |
744 |
}//if end
|
| 226 |
liveuser |
745 |
|
| 3 |
liveuser |
746 |
}//if end
|
| 226 |
liveuser |
747 |
|
| 3 |
liveuser |
748 |
//結構資訊正常
|
|
|
749 |
if(passed)
|
|
|
750 |
{
|
|
|
751 |
//將暫存的tab資訊移除
|
| 226 |
liveuser |
752 |
".$rmLocalStorage["content"]."
|
|
|
753 |
|
| 3 |
liveuser |
754 |
//設定上一頁按鈕的事件
|
|
|
755 |
".$prePageClickEvent["content"]."
|
| 226 |
liveuser |
756 |
|
| 3 |
liveuser |
757 |
//設定下一頁按鈕的事件
|
|
|
758 |
".$nextPageClickEvent["content"]."
|
| 226 |
liveuser |
759 |
|
| 3 |
liveuser |
760 |
//初始化要呈現的tab頁面
|
| 226 |
liveuser |
761 |
".$initialTabViewScript."
|
|
|
762 |
|
| 3 |
liveuser |
763 |
}//if end
|
| 226 |
liveuser |
764 |
|
| 3 |
liveuser |
765 |
//結構資訊不正常
|
|
|
766 |
else
|
|
|
767 |
{
|
|
|
768 |
//建立新的 tab 資訊
|
| 226 |
liveuser |
769 |
".$saveToLocalStorage["content"]."
|
|
|
770 |
|
| 3 |
liveuser |
771 |
//將暫存的tab資訊移除
|
|
|
772 |
".$rmLocalStorage["content"]."
|
| 226 |
liveuser |
773 |
|
| 3 |
liveuser |
774 |
}//else end
|
| 226 |
liveuser |
775 |
|
| 3 |
liveuser |
776 |
}//else end
|
| 226 |
liveuser |
777 |
";
|
|
|
778 |
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
792 |
|
| 3 |
liveuser |
793 |
#如果建立
|
|
|
794 |
if($toScript["status"]=="false"){
|
| 226 |
liveuser |
795 |
|
| 3 |
liveuser |
796 |
#設置執行失敗
|
|
|
797 |
$result["status"]="false";
|
| 226 |
liveuser |
798 |
|
| 3 |
liveuser |
799 |
#設置執行錯誤訊息
|
|
|
800 |
$result["error"]=$toScript;
|
| 226 |
liveuser |
801 |
|
| 3 |
liveuser |
802 |
#回傳結果
|
|
|
803 |
return $result;
|
| 226 |
liveuser |
804 |
|
| 3 |
liveuser |
805 |
}#if end
|
| 226 |
liveuser |
806 |
|
| 3 |
liveuser |
807 |
#串接 script 語法
|
|
|
808 |
$result["content"]=$result["content"].$toScript["content"];
|
| 226 |
liveuser |
809 |
|
| 3 |
liveuser |
810 |
#用<div></div>包起來
|
|
|
811 |
$result["content"]="<div>".$result["content"]."</div>";
|
| 226 |
liveuser |
812 |
|
| 3 |
liveuser |
813 |
#設置執行正常
|
| 226 |
liveuser |
814 |
$result["status"]="true";
|
|
|
815 |
|
| 3 |
liveuser |
816 |
#回傳結果
|
|
|
817 |
return $result;
|
| 226 |
liveuser |
818 |
|
| 3 |
liveuser |
819 |
}#function mobile end
|
| 226 |
liveuser |
820 |
|
| 3 |
liveuser |
821 |
/*
|
|
|
822 |
#函數說明:
|
| 226 |
liveuser |
823 |
#使用bootstrap樣式建立的分頁功能
|
| 3 |
liveuser |
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
|
| 226 |
liveuser |
839 |
*/
|
| 3 |
liveuser |
840 |
function bootstrap(&$conf){
|
| 226 |
liveuser |
841 |
|
| 3 |
liveuser |
842 |
#初始化要回傳的結果
|
|
|
843 |
$result=array();
|
|
|
844 |
|
|
|
845 |
#取得當前執行的函數名稱
|
|
|
846 |
$result["function"]=__FUNCTION__;
|
|
|
847 |
|
|
|
848 |
#如果沒有參數
|
|
|
849 |
if(func_num_args()==0){
|
| 226 |
liveuser |
850 |
|
| 3 |
liveuser |
851 |
#設置執行失敗
|
|
|
852 |
$result["status"]="false";
|
| 226 |
liveuser |
853 |
|
| 3 |
liveuser |
854 |
#設置執行錯誤訊息
|
|
|
855 |
$result["error"]="函數".$result["function"]."需要參數";
|
| 226 |
liveuser |
856 |
|
| 3 |
liveuser |
857 |
#回傳結果
|
|
|
858 |
return $result;
|
| 226 |
liveuser |
859 |
|
| 3 |
liveuser |
860 |
}#if end
|
| 226 |
liveuser |
861 |
|
| 3 |
liveuser |
862 |
#取得參數
|
|
|
863 |
$result["argu"]=$conf;
|
|
|
864 |
|
|
|
865 |
#如果 $conf 不為陣列
|
|
|
866 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
867 |
|
| 3 |
liveuser |
868 |
#設置執行失敗
|
|
|
869 |
$result["status"]="false";
|
| 226 |
liveuser |
870 |
|
| 3 |
liveuser |
871 |
#設置執行錯誤訊息
|
|
|
872 |
$result["error"][]="\$conf變數須為陣列形態";
|
| 226 |
liveuser |
873 |
|
| 3 |
liveuser |
874 |
#如果傳入的參數為 null
|
|
|
875 |
if($conf==null){
|
| 226 |
liveuser |
876 |
|
| 3 |
liveuser |
877 |
#設置執行錯誤訊息
|
|
|
878 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
879 |
|
| 3 |
liveuser |
880 |
}#if end
|
|
|
881 |
|
|
|
882 |
#回傳結果
|
|
|
883 |
return $result;
|
| 226 |
liveuser |
884 |
|
| 3 |
liveuser |
885 |
}#if end
|
| 226 |
liveuser |
886 |
|
| 3 |
liveuser |
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");
|
| 226 |
liveuser |
921 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
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"]);
|
| 226 |
liveuser |
931 |
|
| 3 |
liveuser |
932 |
#如果檢查參數失敗
|
|
|
933 |
if($checkArguments["status"]=="false"){
|
| 226 |
liveuser |
934 |
|
| 3 |
liveuser |
935 |
#設置執行失敗
|
|
|
936 |
$result["status"]="false";
|
| 226 |
liveuser |
937 |
|
| 3 |
liveuser |
938 |
#設置執行錯誤訊息
|
|
|
939 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
940 |
|
| 3 |
liveuser |
941 |
#回傳結果
|
|
|
942 |
return $result;
|
| 226 |
liveuser |
943 |
|
| 3 |
liveuser |
944 |
}#if end
|
| 226 |
liveuser |
945 |
|
| 3 |
liveuser |
946 |
#如果檢查參數不通過
|
|
|
947 |
if($checkArguments["passed"]=="false"){
|
| 226 |
liveuser |
948 |
|
| 3 |
liveuser |
949 |
#設置執行失敗
|
|
|
950 |
$result["status"]="false";
|
| 226 |
liveuser |
951 |
|
| 3 |
liveuser |
952 |
#設置執行錯誤訊息
|
|
|
953 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
954 |
|
| 3 |
liveuser |
955 |
#回傳結果
|
|
|
956 |
return $result;
|
| 226 |
liveuser |
957 |
|
| 3 |
liveuser |
958 |
}#if end
|
| 226 |
liveuser |
959 |
|
| 3 |
liveuser |
960 |
#ul開始
|
|
|
961 |
$ul="<ul class=\"nav nav-tabs\">";
|
| 226 |
liveuser |
962 |
|
| 3 |
liveuser |
963 |
#初始化tab的內容
|
|
|
964 |
$tab="<div class=\"tab-content\">";
|
| 226 |
liveuser |
965 |
|
| 3 |
liveuser |
966 |
#$conf["liName"] 有幾個就執行幾次
|
|
|
967 |
for($i=0;$i<count($conf["liName"]);$i++){
|
| 226 |
liveuser |
968 |
|
| 3 |
liveuser |
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>";
|
| 226 |
liveuser |
973 |
|
| 3 |
liveuser |
974 |
#如果是第一筆
|
|
|
975 |
if($i===0){
|
| 226 |
liveuser |
976 |
|
| 3 |
liveuser |
977 |
#串接 tab 的內容
|
| 226 |
liveuser |
978 |
$tab=$tab."<div class=\"tab-pane fade in active \" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";
|
|
|
979 |
|
| 3 |
liveuser |
980 |
}#if end
|
| 226 |
liveuser |
981 |
|
| 3 |
liveuser |
982 |
#反之不是第一筆
|
|
|
983 |
else{
|
| 226 |
liveuser |
984 |
|
| 3 |
liveuser |
985 |
#串接 tab 的內容
|
| 226 |
liveuser |
986 |
$tab=$tab."<div class=\"tab-pane fade\" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";
|
|
|
987 |
|
| 3 |
liveuser |
988 |
}#else end
|
| 226 |
liveuser |
989 |
|
| 3 |
liveuser |
990 |
}#for end
|
| 226 |
liveuser |
991 |
|
| 3 |
liveuser |
992 |
#ul結束
|
|
|
993 |
$ul=$ul."</ul>";
|
| 226 |
liveuser |
994 |
|
| 3 |
liveuser |
995 |
#tab content 結束
|
|
|
996 |
$tab=$tab."</div>";
|
| 226 |
liveuser |
997 |
|
| 3 |
liveuser |
998 |
#取得分頁的內容
|
|
|
999 |
$result["content"]=$ul.$tab;
|
| 226 |
liveuser |
1000 |
|
| 3 |
liveuser |
1001 |
#設置執行正常
|
|
|
1002 |
$result["status"]="true";
|
| 226 |
liveuser |
1003 |
|
| 3 |
liveuser |
1004 |
#回傳結果
|
|
|
1005 |
return $result;
|
| 226 |
liveuser |
1006 |
|
| 3 |
liveuser |
1007 |
}#function botostrap
|
| 226 |
liveuser |
1008 |
|
| 3 |
liveuser |
1009 |
}#class tab end
|
|
|
1010 |
|
|
|
1011 |
?>
|