| 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 |
跟超連結應用有關的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class link{
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
#函式說明:
|
|
|
36 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
37 |
#回傳結果:
|
|
|
38 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
39 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
40 |
#$result["function"],當前執行的函式名稱.
|
|
|
41 |
#必填參數:
|
|
|
42 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
43 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
44 |
#可省略參數:
|
|
|
45 |
#無.
|
|
|
46 |
#參考資料:
|
|
|
47 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
48 |
#備註:
|
|
|
49 |
#無.
|
|
|
50 |
*/
|
|
|
51 |
public function __call($method,$arguments){
|
|
|
52 |
|
|
|
53 |
#取得當前執行的函式
|
|
|
54 |
$result["function"]=__FUNCTION__;
|
|
|
55 |
|
|
|
56 |
#設置執行不正常
|
|
|
57 |
$result["status"]="false";
|
|
|
58 |
|
|
|
59 |
#設置執行錯誤
|
|
|
60 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
61 |
|
|
|
62 |
#設置所丟入的參數
|
|
|
63 |
$result["error"][]=$arguments;
|
|
|
64 |
|
|
|
65 |
#回傳結果
|
|
|
66 |
return $result;
|
|
|
67 |
|
|
|
68 |
}#function __call end
|
|
|
69 |
|
|
|
70 |
/*
|
|
|
71 |
#函式說明:
|
|
|
72 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
73 |
#回傳結果:
|
|
|
74 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
75 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
76 |
#$result["function"],當前執行的函式名稱.
|
|
|
77 |
#必填參數:
|
|
|
78 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
79 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
80 |
#可省略參數:
|
|
|
81 |
#無.
|
|
|
82 |
#參考資料:
|
|
|
83 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
84 |
#備註:
|
|
|
85 |
#無.
|
|
|
86 |
*/
|
|
|
87 |
public static function __callStatic($method,$arguments){
|
|
|
88 |
|
|
|
89 |
#取得當前執行的函式
|
|
|
90 |
$result["function"]=__FUNCTION__;
|
|
|
91 |
|
|
|
92 |
#設置執行不正常
|
|
|
93 |
$result["status"]="false";
|
|
|
94 |
|
|
|
95 |
#設置執行錯誤
|
|
|
96 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
|
|
97 |
|
|
|
98 |
#設置所丟入的參數
|
|
|
99 |
$result["error"][]=$arguments;
|
|
|
100 |
|
|
|
101 |
#回傳結果
|
|
|
102 |
return $result;
|
|
|
103 |
|
|
|
104 |
}#function __callStatic end
|
|
|
105 |
|
|
|
106 |
/*
|
|
|
107 |
#函式說明:
|
|
|
108 |
#放置超鏈結
|
|
|
109 |
#回傳結果:
|
|
|
110 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
111 |
#$result["error"],錯誤訊息
|
|
|
112 |
#$result["content"],語法
|
|
|
113 |
#$result["function"],當前執行的函數名稱
|
|
|
114 |
#必填參數:
|
|
|
115 |
#$conf["position"],字串,爲要連結到的位置,若留空,將會自動變成"#(目標不存在)","#"則可以搭配ajax傳值.
|
|
|
116 |
$conf["position"]="";
|
|
|
117 |
#$conf["linkName",字串,爲連結的顯示名稱
|
|
|
118 |
$conf["linkName"]="";
|
|
|
119 |
#可省略參數:
|
|
|
120 |
#$conf["method"],字串,爲點選連結後,新畫面要如何呈現,可省略預設爲"_self",可用的選項有 _top(覆蓋目前的視窗來顯現新內容) _parent _self _blank(跳新視窗)
|
|
|
121 |
#$conf["method"]="";
|
|
|
122 |
#$conf["class"],字串,爲要套用的css超連節樣式,可省略.
|
|
|
123 |
#$conf["class"]="";
|
|
|
124 |
#$conf["id"],字串,超連結的id.
|
|
|
125 |
#$conf["id"]="";
|
|
|
126 |
#$conf["no_outline"],字串,是否要取消連結的框線,"false為不取消,"true"代表要取消,預設為"false".
|
|
|
127 |
#$conf["no_outline"]="";
|
|
|
128 |
#$conf["callBackFunctions"],字串陣列,點選選項取得回應後要callback的js函數名稱,參數id要記得設定.
|
|
|
129 |
#$conf["callBackFunctions"]=array();
|
|
|
130 |
#參考資料
|
|
|
131 |
#無.
|
|
|
132 |
#備註:
|
|
|
133 |
#無.
|
|
|
134 |
*/
|
|
|
135 |
public static function show_link(&$conf){
|
|
|
136 |
|
|
|
137 |
#初始化要回傳的內容
|
|
|
138 |
$result=array();
|
|
|
139 |
|
|
|
140 |
#取得當前執行的函數名稱
|
|
|
141 |
$result["function"]=__FUNCTION__;
|
|
|
142 |
|
|
|
143 |
#初始化要回傳的語法
|
|
|
144 |
$result["content"]="";
|
|
|
145 |
|
|
|
146 |
#如果 $conf 不為陣列
|
|
|
147 |
if(gettype($conf)!="array"){
|
|
|
148 |
|
|
|
149 |
#設置執行失敗
|
|
|
150 |
$result["status"]="false";
|
|
|
151 |
|
|
|
152 |
#設置執行錯誤訊息
|
|
|
153 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
154 |
|
|
|
155 |
#如果傳入的參數為 null
|
|
|
156 |
if($conf==null){
|
|
|
157 |
|
|
|
158 |
#設置執行錯誤訊息
|
|
|
159 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
160 |
|
|
|
161 |
}#if end
|
|
|
162 |
|
|
|
163 |
#回傳結果
|
|
|
164 |
return $result;
|
|
|
165 |
|
|
|
166 |
}#if end
|
|
|
167 |
|
|
|
168 |
#檢查參數
|
|
|
169 |
#函式說明:
|
|
|
170 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
171 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
172 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
173 |
#$result["function"],當前執行的函式名稱.
|
|
|
174 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
175 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
176 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
177 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
178 |
#必填寫的參數:
|
|
|
179 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
180 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
181 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
182 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("position","linkName");
|
|
|
183 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
184 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
185 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
186 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
187 |
#可以省略的參數:
|
|
|
188 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
189 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
190 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
191 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class","method","imgFilePosition","id","no_outline","callBackFunctions");
|
|
|
192 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
193 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","array");
|
|
|
194 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
195 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"_self",null,null,"false",null);
|
|
|
196 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
197 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
198 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
199 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
200 |
|
|
|
201 |
#如果檢查參數失敗
|
|
|
202 |
if($checkResult["status"]=="false"){
|
|
|
203 |
|
|
|
204 |
#設置執行失敗
|
|
|
205 |
$result["status"]="false";
|
|
|
206 |
|
|
|
207 |
#設置錯誤訊息
|
|
|
208 |
$result["error"]=$checkResult;
|
|
|
209 |
|
|
|
210 |
#回傳結果
|
|
|
211 |
return $result;
|
|
|
212 |
|
|
|
213 |
}#if end
|
|
|
214 |
|
|
|
215 |
#如果檢查參數不通過
|
|
|
216 |
if($checkResult["passed"]=="false"){
|
|
|
217 |
|
|
|
218 |
#設置執行失敗
|
|
|
219 |
$result["status"]="false";
|
|
|
220 |
|
|
|
221 |
#設置錯誤訊息
|
|
|
222 |
$result["error"]=$checkResult;
|
|
|
223 |
|
|
|
224 |
#回傳結果
|
|
|
225 |
return $result;
|
|
|
226 |
|
|
|
227 |
}#if end
|
|
|
228 |
|
|
|
229 |
#存放 js callback 的字串
|
|
|
230 |
$callBackStrTemp="";
|
|
|
231 |
|
|
|
232 |
#初始化js內容為空
|
|
|
233 |
$js="";
|
|
|
234 |
|
|
|
235 |
#如果是一般的 method
|
|
|
236 |
if($conf["method"]==="_self" || $conf["method"]==="_top" || $conf["method"]==="_parent" || $conf["method"]==="_blank"){
|
|
|
237 |
|
|
|
238 |
#設定連結顯示的方式 $conf["method"] 存在,則套用結果
|
|
|
239 |
$conf["method"]=" target = ".$conf["method"];
|
|
|
240 |
|
|
|
241 |
}#if end
|
|
|
242 |
|
|
|
243 |
#反之有設定 $conf["id"]
|
|
|
244 |
else if(isset($conf["id"])){
|
|
|
245 |
|
|
|
246 |
#如果沒有設置 callback function
|
|
|
247 |
if(!isset($conf["callBackFunctions"])){
|
|
|
248 |
|
|
|
249 |
#初始化為空字串
|
|
|
250 |
$conf["callBackFunctions"]="";
|
|
|
251 |
|
|
|
252 |
}#if end
|
|
|
253 |
|
|
|
254 |
#反之
|
|
|
255 |
else{
|
|
|
256 |
#針對每個 $conf["callBackFunctions"]
|
|
|
257 |
foreach($conf["callBackFunctions"] as $callback){
|
|
|
258 |
|
|
|
259 |
#串接 callback 的語法,res為網頁的內容,params.url為目標檔案的相對位置
|
|
|
260 |
$callBackStrTemp=$callBackStrTemp.$callback.".call(this,res,params.url);";
|
|
|
261 |
|
|
|
262 |
}#foreach end
|
|
|
263 |
|
|
|
264 |
}#else end
|
|
|
265 |
|
|
|
266 |
#函式說明:
|
|
|
267 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
268 |
#回傳結果:
|
|
|
269 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
270 |
#$result["error"],錯誤訊息陣列
|
|
|
271 |
#$result["function"],當前執行的函數名稱
|
|
|
272 |
#$result["content"],要執行的javaScript語法
|
|
|
273 |
#必填參數:
|
|
|
274 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
275 |
$conf["javaScript::toScript"]["script"]=
|
|
|
276 |
"
|
|
|
277 |
//將 link 綁定 click 事件
|
|
|
278 |
document.getElementById('".$conf["id"]."').addEventListener('click',function(e){
|
|
|
279 |
|
|
|
280 |
//取消預設事件效果與擴散
|
|
|
281 |
e.preventDefault();
|
|
|
282 |
e.stopPropagation();
|
|
|
283 |
|
|
|
284 |
/*
|
|
|
285 |
設置 window.qbpwcf.ajax 函數
|
|
|
286 |
說明:
|
|
|
287 |
傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.
|
|
|
288 |
參數:
|
|
|
289 |
params={};
|
|
|
290 |
params.method='POST' or 'GET';
|
|
|
291 |
params.headers={name:value};
|
|
|
292 |
params.url='url to request';
|
|
|
293 |
params.resType='json';
|
|
|
294 |
params.preAc='function name to call before send request';
|
|
|
295 |
params.aftAc='function name to call after send request';
|
|
|
296 |
params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use '';
|
|
|
297 |
*/
|
|
|
298 |
params={};
|
|
|
299 |
params.data={};
|
|
|
300 |
params.method='GET';
|
|
|
301 |
params.url='".$conf["position"]."';
|
|
|
302 |
params.resType='document';
|
|
|
303 |
params.preAc=function(){
|
|
|
304 |
|
|
|
305 |
//建立讀取的div
|
|
|
306 |
var loadingDiv=document.createElement('div');
|
|
|
307 |
loadingDiv.id='widow.qbpwcf.link.show_link.loadingDiv';
|
|
|
308 |
|
|
|
309 |
//建立讀取的提示文字
|
|
|
310 |
loadingDiv.innerText='Loading...';
|
|
|
311 |
|
|
|
312 |
//設定讀取的div樣式
|
|
|
313 |
loadingDiv.style.position='fixed';
|
|
|
314 |
loadingDiv.style.textAlign='center';
|
|
|
315 |
loadingDiv.style.color='#FF0000';
|
|
|
316 |
loadingDiv.style.backgroundColor='#AAAAAA';
|
|
|
317 |
loadingDiv.style.opacity='0.9';
|
|
|
318 |
loadingDiv.style.width='100vw';
|
|
|
319 |
loadingDiv.style.height='100vh';
|
|
|
320 |
loadingDiv.style.top='0px';
|
|
|
321 |
loadingDiv.style.left='0px';
|
|
|
322 |
loadingDiv.style.zIndex='1';
|
|
|
323 |
loadingDiv.style.lineHeight='100vh';
|
|
|
324 |
|
|
|
325 |
//append div to body
|
|
|
326 |
document.body.appendChild(loadingDiv);
|
|
|
327 |
|
|
|
328 |
};
|
|
|
329 |
params.aftAc=function(res){
|
|
|
330 |
|
|
|
331 |
//移除讀取的div
|
|
|
332 |
document.getElementById('widow.qbpwcf.link.show_link.loadingDiv').remove();
|
|
|
333 |
|
|
|
334 |
//debug
|
|
|
335 |
if(window.debug){
|
|
|
336 |
|
|
|
337 |
//debug msg
|
|
|
338 |
console.log(res);
|
|
|
339 |
|
|
|
340 |
}//if end
|
|
|
341 |
|
|
|
342 |
//如果有回應
|
|
|
343 |
if(res!==null){
|
|
|
344 |
|
|
|
345 |
//輸出回應
|
|
|
346 |
document.getElementById('".$conf["method"]."').innerHTML=res.body.innerHTML;
|
|
|
347 |
|
|
|
348 |
}//if end
|
|
|
349 |
|
|
|
350 |
//反之
|
|
|
351 |
else{
|
|
|
352 |
|
|
|
353 |
//輸出回應
|
|
|
354 |
document.getElementById('".$conf["method"]."').innerHTML='';
|
|
|
355 |
|
|
|
356 |
}//else end
|
|
|
357 |
|
|
|
358 |
".$callBackStrTemp."
|
|
|
359 |
|
|
|
360 |
};
|
|
|
361 |
window.qbpwcf.ajax.call(this,params);
|
|
|
362 |
|
|
|
363 |
});
|
|
|
364 |
";
|
|
|
365 |
#可省略參數:
|
|
|
366 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
367 |
#$conf["onReady"]="true";
|
|
|
368 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
369 |
#$conf["globalJs"]=array();
|
|
|
370 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
371 |
#$conf["jsFunciton"]=array();
|
|
|
372 |
#參考資料:
|
|
|
373 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
374 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
375 |
unset($conf["javaScript::toScript"]);
|
|
|
376 |
|
|
|
377 |
#如果檢查參數不通過
|
|
|
378 |
if($toScript["status"]=="false"){
|
|
|
379 |
|
|
|
380 |
#設置執行失敗
|
|
|
381 |
$result["status"]="false";
|
|
|
382 |
|
|
|
383 |
#設置錯誤訊息
|
|
|
384 |
$result["error"]=$toScript;
|
|
|
385 |
|
|
|
386 |
#回傳結果
|
|
|
387 |
return $result;
|
|
|
388 |
|
|
|
389 |
}#if end
|
|
|
390 |
|
|
|
391 |
#設置js內容
|
|
|
392 |
$js=$toScript["content"];
|
|
|
393 |
|
|
|
394 |
}#if end
|
|
|
395 |
|
|
|
396 |
#如果 $conf["class"] 不存在,則不設定樣式
|
|
|
397 |
if(!isset($conf["class"])){
|
|
|
398 |
|
|
|
399 |
$conf["class"]="";
|
|
|
400 |
|
|
|
401 |
}#if end
|
|
|
402 |
|
|
|
403 |
#如果 $conf["class"] 存在,則設定樣式
|
|
|
404 |
else{
|
|
|
405 |
|
|
|
406 |
$conf["class"]=" class = ".$conf["class"];
|
|
|
407 |
|
|
|
408 |
}#else end
|
|
|
409 |
|
|
|
410 |
#如果連結位置為空字串
|
|
|
411 |
if($conf["position"]==""){
|
|
|
412 |
|
|
|
413 |
#設為無效的連結
|
|
|
414 |
$conf["position"]="#";
|
|
|
415 |
|
|
|
416 |
#連結名稱加上"目標不存在的提示"
|
|
|
417 |
$conf["linkName"]=$conf["linkName"]."(目標不存在)";
|
|
|
418 |
|
|
|
419 |
}#if end
|
|
|
420 |
|
|
|
421 |
#如果 $conf["id"] 有設置
|
|
|
422 |
if(isset($conf["id"])){
|
|
|
423 |
|
|
|
424 |
#設置id
|
|
|
425 |
$conf["id"]=" id=".$conf["id"]." ";
|
|
|
426 |
|
|
|
427 |
}#if end
|
|
|
428 |
|
|
|
429 |
#反之
|
|
|
430 |
else{
|
|
|
431 |
|
|
|
432 |
#設為空字串
|
|
|
433 |
$conf["id"]="";
|
|
|
434 |
|
|
|
435 |
}#else end
|
|
|
436 |
|
|
|
437 |
#初始化 style 字串
|
|
|
438 |
$style="";
|
|
|
439 |
|
|
|
440 |
#如果 $conf["no_outline"] 為 "true"
|
|
|
441 |
if($conf["no_outline"]=="true"){
|
|
|
442 |
|
|
|
443 |
#函式說明:
|
|
|
444 |
#建立給與html標籤使用的style屬性字串.
|
|
|
445 |
#回傳結果:
|
|
|
446 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
447 |
#$result["function"],當前執行的函數
|
|
|
448 |
#$result["error"],錯誤訊息陣列
|
|
|
449 |
#$result["content"],css設定內容
|
|
|
450 |
#必填參數:
|
|
|
451 |
$conf["css::styleStr"]["styleName"]=array("outline","behavior","text-decoration");#為屬性名稱,須為陣列值
|
|
|
452 |
$conf["css::styleStr"]["styleValue"]=array("none","expression(this.onFocus=this.blur()); /* for IE */","none");#為屬性值,須為陣列值
|
|
|
453 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
454 |
unset($conf["css::styleStr"]);
|
|
|
455 |
|
|
|
456 |
#如果建立 style 字串失敗
|
|
|
457 |
if($styleStr["status"]=="false"){
|
|
|
458 |
|
|
|
459 |
#設置執行失敗
|
|
|
460 |
$result["status"]="false";
|
|
|
461 |
|
|
|
462 |
#設置錯誤訊息
|
|
|
463 |
$result["error"]=$styleStr;
|
|
|
464 |
|
|
|
465 |
#回傳結果
|
|
|
466 |
return $result;
|
|
|
467 |
|
|
|
468 |
}#if end
|
|
|
469 |
|
|
|
470 |
#取得 style 字串
|
|
|
471 |
$style=$styleStr["content"];
|
|
|
472 |
|
|
|
473 |
}#if end
|
|
|
474 |
|
|
|
475 |
#放置超連結的語法
|
|
|
476 |
$result["content"]="<a href= ".$conf["position"]." ".$conf["method"]." ".$conf["class"]." ".$conf["id"]." ".$style." > ".$conf["linkName"]." </a>".$js;
|
|
|
477 |
|
|
|
478 |
#設置執行正常
|
|
|
479 |
$result["status"]="true";
|
|
|
480 |
|
|
|
481 |
#回傳結果
|
|
|
482 |
return $result;
|
|
|
483 |
|
|
|
484 |
}#function show_link end
|
|
|
485 |
|
|
|
486 |
/*
|
|
|
487 |
#函式說明:
|
|
|
488 |
#放置圖片超鏈接
|
|
|
489 |
#回傳的內容:
|
|
|
490 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
491 |
#$result["error"],錯誤訊息
|
|
|
492 |
#$result["content"],語法
|
|
|
493 |
#$result["function"],當前執行的函數名稱
|
|
|
494 |
#必填參數:
|
|
|
495 |
$conf["linkLocation"]="";#爲連結的網路位置。
|
|
|
496 |
$conf["imgFilePosition"]="";#爲圖片檔案的位置。
|
|
|
497 |
#可省略參數:
|
|
|
498 |
#$conf["class"]="";#爲圖片的css類別名稱
|
|
|
499 |
#$conf["method"]="";#爲點選該連結之後,新畫面要如何呈現,可留空,可用的選項有 _top(覆蓋目前的視窗來顯現新內容) _parent(在目前的父頁面顯示新畫面) _blank(跳新視窗) _self(在自己的頁面呈現),預設爲 _self。
|
|
|
500 |
#$conf["imgHeight"]="";#爲圖片的高度,可省略,省略則按照圖片原始高度。
|
|
|
501 |
#$conf["imgWidth"]="";#爲圖片的寬度,可省略,省略則按照圖片原始寬度。
|
|
|
502 |
#$conf["imgLinkName"]="";#若圖片無法顯示,則會出現以下替代文字。
|
|
|
503 |
#$conf["no_outline"],字串,是否要取消連結的框線,"false為不取消,"true"代表要取消,預設為"true".
|
|
|
504 |
#$conf["no_outline"]="";
|
|
|
505 |
#參考資料
|
|
|
506 |
#無.
|
|
|
507 |
#備註:
|
|
|
508 |
#無.
|
|
|
509 |
*/
|
|
|
510 |
public static function showImgLink(&$conf){
|
|
|
511 |
|
|
|
512 |
#初始化要回傳的內容
|
|
|
513 |
$result=array();
|
|
|
514 |
|
|
|
515 |
#取得當前執行的函數名稱
|
|
|
516 |
$result["function"]=__FUNCTION__;
|
|
|
517 |
|
|
|
518 |
#初始化要回傳的語法
|
|
|
519 |
$result["content"]="";
|
|
|
520 |
|
|
|
521 |
#如果 $conf 不為陣列
|
|
|
522 |
if(gettype($conf)!="array"){
|
|
|
523 |
|
|
|
524 |
#設置執行失敗
|
|
|
525 |
$result["status"]="false";
|
|
|
526 |
|
|
|
527 |
#設置執行錯誤訊息
|
|
|
528 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
529 |
|
|
|
530 |
#如果傳入的參數為 null
|
|
|
531 |
if($conf==null){
|
|
|
532 |
|
|
|
533 |
#設置執行錯誤訊息
|
|
|
534 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
535 |
|
|
|
536 |
}#if end
|
|
|
537 |
|
|
|
538 |
#回傳結果
|
|
|
539 |
return $result;
|
|
|
540 |
|
|
|
541 |
}#if end
|
|
|
542 |
|
|
|
543 |
#檢查參數
|
|
|
544 |
#函式說明:
|
|
|
545 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
546 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
547 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
548 |
#$result["function"],當前執行的函式名稱.
|
|
|
549 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
550 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
551 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
552 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
553 |
#必填寫的參數:
|
|
|
554 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
555 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
556 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
557 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("linkLocation","imgFilePosition");
|
|
|
558 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
559 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
560 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
561 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
562 |
#可以省略的參數:
|
|
|
563 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
564 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
565 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
566 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","class","imgHeight","imgWidth","imgLinkName","no_outline");
|
|
|
567 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
568 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string");
|
|
|
569 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
570 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("_self","","","","","true");
|
|
|
571 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
572 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
573 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
574 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
575 |
|
|
|
576 |
#如果檢查參數失敗
|
|
|
577 |
if($checkResult["status"]=="false"){
|
|
|
578 |
|
|
|
579 |
#設置執行失敗
|
|
|
580 |
$result["status"]="false";
|
|
|
581 |
|
|
|
582 |
#設置錯誤訊息
|
|
|
583 |
$result["error"]=$checkResult;
|
|
|
584 |
|
|
|
585 |
#回傳結果
|
|
|
586 |
return $result;
|
|
|
587 |
|
|
|
588 |
}#if end
|
|
|
589 |
|
|
|
590 |
#如果檢查參數不通過
|
|
|
591 |
if($checkResult["passed"]=="false"){
|
|
|
592 |
|
|
|
593 |
#設置執行失敗
|
|
|
594 |
$result["status"]="false";
|
|
|
595 |
|
|
|
596 |
#設置錯誤訊息
|
|
|
597 |
$result["error"]=$checkResult;
|
|
|
598 |
|
|
|
599 |
#回傳結果
|
|
|
600 |
return $result;
|
|
|
601 |
|
|
|
602 |
}#if end
|
|
|
603 |
|
|
|
604 |
#如果 $conf["imgHeight"] 不爲"",則設定圖片高度
|
|
|
605 |
if($conf["imgHeight"]!=""){
|
|
|
606 |
|
|
|
607 |
$conf["imgHeight"]="height = ".$conf["imgHeight"];
|
|
|
608 |
|
|
|
609 |
}#if end
|
|
|
610 |
|
|
|
611 |
#如果 $conf["imgWidth"] 不爲"",則設定圖片寬度
|
|
|
612 |
if($conf["imgWidth"]!=""){
|
|
|
613 |
|
|
|
614 |
$conf["imgWidth"]="width = ".$conf["imgWidth"];
|
|
|
615 |
|
|
|
616 |
}#if end
|
|
|
617 |
|
|
|
618 |
#$conf["imgLinkName"] 不爲"",則設定圖片無法顯示時的替代文字。
|
|
|
619 |
if($conf["imgLinkName"]!=""){
|
|
|
620 |
|
|
|
621 |
$conf["imgLinkName"]="alt = ".$conf["imgLinkName"];
|
|
|
622 |
|
|
|
623 |
}#if end
|
|
|
624 |
|
|
|
625 |
#如果 $conf["class"] 不爲"",則設定css樣式。
|
|
|
626 |
if($conf["class"]!=""){
|
|
|
627 |
|
|
|
628 |
$conf["class"]="class = ".$conf["class"];
|
|
|
629 |
|
|
|
630 |
}#if end
|
|
|
631 |
|
|
|
632 |
#初始化 style 字串
|
|
|
633 |
$style="";
|
|
|
634 |
|
|
|
635 |
#如果 $conf["no_outline"] 為 "true"
|
|
|
636 |
if($conf["no_outline"]=="true"){
|
|
|
637 |
|
|
|
638 |
#函式說明:
|
|
|
639 |
#建立給與html標籤使用的style屬性字串.
|
|
|
640 |
#回傳結果:
|
|
|
641 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
642 |
#$result["function"],當前執行的函數
|
|
|
643 |
#$result["error"],錯誤訊息陣列
|
|
|
644 |
#$result["content"],css設定內容
|
|
|
645 |
#必填參數:
|
|
|
646 |
$conf["css::styleStr"]["styleName"]=array("outline","behavior");#為屬性名稱,須為陣列值
|
|
|
647 |
$conf["css::styleStr"]["styleValue"]=array("none","expression(this.onFocus=this.blur()); /* for IE */");#為屬性值,須為陣列值
|
|
|
648 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
649 |
unset($conf["css::styleStr"]);
|
|
|
650 |
|
|
|
651 |
#如果建立 style 字串失敗
|
|
|
652 |
if($styleStr["status"]=="false"){
|
|
|
653 |
|
|
|
654 |
#設置執行失敗
|
|
|
655 |
$result["status"]="false";
|
|
|
656 |
|
|
|
657 |
#設置錯誤訊息
|
|
|
658 |
$result["error"]=$styleStr;
|
|
|
659 |
|
|
|
660 |
#回傳結果
|
|
|
661 |
return $result;
|
|
|
662 |
|
|
|
663 |
}#if end
|
|
|
664 |
|
|
|
665 |
#取得 style 字串
|
|
|
666 |
$style=$styleStr["content"];
|
|
|
667 |
|
|
|
668 |
}#if end
|
|
|
669 |
|
|
|
670 |
#放置圖片超連結
|
|
|
671 |
$result["content"]=$result["content"]."<a href = ".$conf["linkLocation"]." target = ".$conf["method"]." ".$style." >";
|
|
|
672 |
$result["content"]=$result["content"]."<img src = ".$conf["imgFilePosition"]." ".$conf["imgWidth"]." ".$conf["imgHeight"]." ".$conf["imgLinkName"]." ".$conf["class"]." >";
|
|
|
673 |
$result["content"]=$result["content"]."</a>";
|
|
|
674 |
|
|
|
675 |
#設置執行正常
|
|
|
676 |
$result["status"]="true";
|
|
|
677 |
|
|
|
678 |
#回傳語法
|
|
|
679 |
return $result;
|
|
|
680 |
|
|
|
681 |
}#function showImgLink end
|
|
|
682 |
|
|
|
683 |
/*
|
|
|
684 |
#函式說明:
|
|
|
685 |
#放置超鏈接,裏面可以放各種內容.
|
|
|
686 |
#回傳內容:
|
|
|
687 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
688 |
#$result["error"],錯誤訊息
|
|
|
689 |
#$result["content"],語法
|
|
|
690 |
#$result["function"],當前執行的函數名稱
|
|
|
691 |
#必填參數:
|
|
|
692 |
#$conf["linkLocation"],字串,爲連結的網路位置.
|
|
|
693 |
$conf["linkLocation"]="";
|
|
|
694 |
#$conf["content"],字串陣列,要放置的內容.
|
|
|
695 |
$conf["content"]=array("");
|
|
|
696 |
#可省略參數:
|
|
|
697 |
#$conf["class"],陣列,爲link的css類別名稱.
|
|
|
698 |
#$conf["class"]=array();
|
|
|
699 |
#$conf["method"],爲點選該連結之後,新畫面要如何呈現,可留空,可用的選項有 _top(覆蓋目前的視窗來顯現新內容) _parent(在目前的父頁面顯示新畫面) _blank(跳新視窗) _self(在自己的頁面呈現),預設爲 _self。
|
|
|
700 |
#$conf["method"]="";
|
|
|
701 |
#$conf["no_outline"],字串,是否要取消連結的框線,"false為不取消,"true"代表要取消,預設為"true".
|
|
|
702 |
#$conf["no_outline"]="";
|
|
|
703 |
#$conf["jsTrigger"],字串,要觸發的js函式,參數為事件自己.
|
|
|
704 |
#$conf["jsTrigger"]="";
|
|
|
705 |
#參考資料
|
|
|
706 |
#無.
|
|
|
707 |
#備註:
|
|
|
708 |
#無.
|
|
|
709 |
*/
|
|
|
710 |
public static function aTagSection(&$conf){
|
|
|
711 |
|
|
|
712 |
#初始化要回傳的內容
|
|
|
713 |
$result=array();
|
|
|
714 |
|
|
|
715 |
#取得當前執行的函數名稱
|
|
|
716 |
$result["function"]=__FUNCTION__;
|
|
|
717 |
|
|
|
718 |
#初始化要回傳的語法
|
|
|
719 |
$result["content"]="";
|
|
|
720 |
|
|
|
721 |
#如果 $conf 不為陣列
|
|
|
722 |
if(gettype($conf)!="array"){
|
|
|
723 |
|
|
|
724 |
#設置執行失敗
|
|
|
725 |
$result["status"]="false";
|
|
|
726 |
|
|
|
727 |
#設置執行錯誤訊息
|
|
|
728 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
729 |
|
|
|
730 |
#如果傳入的參數為 null
|
|
|
731 |
if($conf==null){
|
|
|
732 |
|
|
|
733 |
#設置執行錯誤訊息
|
|
|
734 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
735 |
|
|
|
736 |
}#if end
|
|
|
737 |
|
|
|
738 |
#回傳結果
|
|
|
739 |
return $result;
|
|
|
740 |
|
|
|
741 |
}#if end
|
|
|
742 |
|
|
|
743 |
#檢查參數
|
|
|
744 |
#函式說明:
|
|
|
745 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
746 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
747 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
748 |
#$result["function"],當前執行的函式名稱.
|
|
|
749 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
750 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
751 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
752 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
753 |
#必填寫的參數:
|
|
|
754 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
755 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
756 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
757 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("linkLocation","content");
|
|
|
758 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
759 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
|
|
|
760 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
761 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
762 |
#可以省略的參數:
|
|
|
763 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
764 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
765 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
766 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","class","no_outline","jsTrigger");
|
|
|
767 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
768 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string","string");
|
|
|
769 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
770 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("_self",null,"true",null);
|
|
|
771 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
772 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
773 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
774 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
775 |
|
|
|
776 |
#如果檢查參數失敗
|
|
|
777 |
if($checkResult["status"]=="false"){
|
|
|
778 |
|
|
|
779 |
#設置執行失敗
|
|
|
780 |
$result["status"]="false";
|
|
|
781 |
|
|
|
782 |
#設置錯誤訊息
|
|
|
783 |
$result["error"]=$checkResult;
|
|
|
784 |
|
|
|
785 |
#回傳結果
|
|
|
786 |
return $result;
|
|
|
787 |
|
|
|
788 |
}#if end
|
|
|
789 |
|
|
|
790 |
#如果檢查參數不通過
|
|
|
791 |
if($checkResult["passed"]=="false"){
|
|
|
792 |
|
|
|
793 |
#設置執行失敗
|
|
|
794 |
$result["status"]="false";
|
|
|
795 |
|
|
|
796 |
#設置錯誤訊息
|
|
|
797 |
$result["error"]=$checkResult;
|
|
|
798 |
|
|
|
799 |
#回傳結果
|
|
|
800 |
return $result;
|
|
|
801 |
|
|
|
802 |
}#if end
|
|
|
803 |
|
|
|
804 |
#初始化 style 字串
|
|
|
805 |
$style="";
|
|
|
806 |
|
|
|
807 |
#如果 $conf["no_outline"] 為 "true"
|
|
|
808 |
if($conf["no_outline"]==="true"){
|
|
|
809 |
|
|
|
810 |
#函式說明:
|
|
|
811 |
#建立給與html標籤使用的style屬性字串.
|
|
|
812 |
#回傳結果:
|
|
|
813 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
814 |
#$result["function"],當前執行的函數
|
|
|
815 |
#$result["error"],錯誤訊息陣列
|
|
|
816 |
#$result["content"],css設定內容
|
|
|
817 |
#必填參數:
|
|
|
818 |
$conf["css::styleStr"]["styleName"]=array("text-decoration","outline","behavior");#為屬性名稱,須為陣列值
|
|
|
819 |
$conf["css::styleStr"]["styleValue"]=array("none","none","expression(this.onFocus=this.blur()); /* for IE */");#為屬性值,須為陣列值
|
|
|
820 |
$styleStr=css::styleStr($conf["css::styleStr"]);
|
|
|
821 |
unset($conf["css::styleStr"]);
|
|
|
822 |
|
|
|
823 |
#如果建立 style 字串失敗
|
|
|
824 |
if($styleStr["status"]=="false"){
|
|
|
825 |
|
|
|
826 |
#設置執行失敗
|
|
|
827 |
$result["status"]="false";
|
|
|
828 |
|
|
|
829 |
#設置錯誤訊息
|
|
|
830 |
$result["error"]=$styleStr;
|
|
|
831 |
|
|
|
832 |
#回傳結果
|
|
|
833 |
return $result;
|
|
|
834 |
|
|
|
835 |
}#if end
|
|
|
836 |
|
|
|
837 |
#取得 style 字串
|
|
|
838 |
$style=$styleStr["content"];
|
|
|
839 |
|
|
|
840 |
}#if end
|
|
|
841 |
|
|
|
842 |
#初始化 class 字串
|
|
|
843 |
$class="";
|
|
|
844 |
|
|
|
845 |
#如果有設定 class
|
|
|
846 |
if(isset($conf["class"])){
|
|
|
847 |
|
|
|
848 |
#涵式說明:
|
|
|
849 |
#建立class屬性字串,亦即套用多個class樣式的設定字串.
|
|
|
850 |
#回傳結果:
|
|
|
851 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
852 |
#$result["function"],當前執行的函數
|
|
|
853 |
#$result["error"],錯誤訊息陣列
|
|
|
854 |
#$result["content"],class屬性字串的內容
|
|
|
855 |
#必填參數:
|
|
|
856 |
#$conf["class"],字串陣列,要套用的類別樣式名稱.
|
|
|
857 |
$conf["css::classStr"]["class"]=$conf["class"];
|
|
|
858 |
$classStr=css::classStr($conf["css::classStr"]);
|
|
|
859 |
unset($conf["css::classStr"]);
|
|
|
860 |
|
|
|
861 |
#如果建立 style 字串失敗
|
|
|
862 |
if($classStr["status"]=="false"){
|
|
|
863 |
|
|
|
864 |
#設置執行失敗
|
|
|
865 |
$result["status"]="false";
|
|
|
866 |
|
|
|
867 |
#設置錯誤訊息
|
|
|
868 |
$result["error"]=$classStr;
|
|
|
869 |
|
|
|
870 |
#回傳結果
|
|
|
871 |
return $result;
|
|
|
872 |
|
|
|
873 |
}#if end
|
|
|
874 |
|
|
|
875 |
#取得 class 設定字串
|
|
|
876 |
$class=$classStr["content"];
|
|
|
877 |
|
|
|
878 |
}#if end
|
|
|
879 |
|
|
|
880 |
#初始化點擊後要觸發的js語法
|
|
|
881 |
$jsTrigger="";
|
|
|
882 |
|
|
|
883 |
#如果有設置 $conf["jsTrigger"]
|
|
|
884 |
if(isset($conf["jsTrigger"])){
|
|
|
885 |
|
|
|
886 |
#設置點擊觸發的事件
|
|
|
887 |
$jsTrigger="onclick=".$conf["jsTrigger"]."(this)";
|
|
|
888 |
|
|
|
889 |
}#if end
|
|
|
890 |
|
|
|
891 |
#放置圖片超連結 - start
|
|
|
892 |
$result["content"]=$result["content"]."<a ".$class." href=\"".$conf["linkLocation"]."\" target =\"".$conf["method"]."\" ".$style." ".$jsTrigger." >";
|
|
|
893 |
|
|
|
894 |
#針對每個要放置的內容
|
|
|
895 |
foreach($conf["content"] as $content){
|
|
|
896 |
|
|
|
897 |
#串接內容
|
|
|
898 |
$result["content"]=$result["content"].$content;
|
|
|
899 |
|
|
|
900 |
}#foreach end
|
|
|
901 |
|
|
|
902 |
#放置圖片超連結 - end
|
|
|
903 |
$result["content"]=$result["content"]."</a>";
|
|
|
904 |
|
|
|
905 |
#設置執行正常
|
|
|
906 |
$result["status"]="true";
|
|
|
907 |
|
|
|
908 |
#回傳語法
|
|
|
909 |
return $result;
|
|
|
910 |
|
|
|
911 |
}#function aTagSection end
|
|
|
912 |
|
|
|
913 |
/*
|
|
|
914 |
#函式說明:
|
|
|
915 |
#放置超鏈接,裏面可以放各種內容.
|
|
|
916 |
#回傳內容:
|
|
|
917 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
918 |
#$result["error"],錯誤訊息
|
|
|
919 |
#$result["content"],語法
|
|
|
920 |
#$result["function"],當前執行的函數名稱
|
|
|
921 |
#必填參數:
|
|
|
922 |
#$conf["phone"],字串,爲要撥打的號碼.
|
|
|
923 |
$conf["phone"]="";
|
|
|
924 |
#$conf["content"],字串,要顯示的內容.
|
|
|
925 |
$conf["content"]="";
|
|
|
926 |
#可省略參數:
|
|
|
927 |
#$conf["class"],陣列,爲link的css類別名稱.
|
|
|
928 |
#$conf["class"]=array();
|
|
|
929 |
#參考資料
|
|
|
930 |
#無.
|
|
|
931 |
#備註:
|
|
|
932 |
#無.
|
|
|
933 |
*/
|
|
|
934 |
public static function call(&$conf){
|
|
|
935 |
|
|
|
936 |
#初始化要回傳的內容
|
|
|
937 |
$result=array();
|
|
|
938 |
|
|
|
939 |
#取得當前執行的函數名稱
|
|
|
940 |
$result["function"]=__FUNCTION__;
|
|
|
941 |
|
|
|
942 |
#初始化要回傳的語法
|
|
|
943 |
$result["content"]="";
|
|
|
944 |
|
|
|
945 |
#如果 $conf 不為陣列
|
|
|
946 |
if(gettype($conf)!="array"){
|
|
|
947 |
|
|
|
948 |
#設置執行失敗
|
|
|
949 |
$result["status"]="false";
|
|
|
950 |
|
|
|
951 |
#設置執行錯誤訊息
|
|
|
952 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
953 |
|
|
|
954 |
#如果傳入的參數為 null
|
|
|
955 |
if($conf==null){
|
|
|
956 |
|
|
|
957 |
#設置執行錯誤訊息
|
|
|
958 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
|
|
959 |
|
|
|
960 |
}#if end
|
|
|
961 |
|
|
|
962 |
#回傳結果
|
|
|
963 |
return $result;
|
|
|
964 |
|
|
|
965 |
}#if end
|
|
|
966 |
|
|
|
967 |
#取得使用的參數
|
|
|
968 |
$result["argu"]=$conf;
|
|
|
969 |
|
|
|
970 |
#檢查參數
|
|
|
971 |
#函式說明:
|
|
|
972 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
973 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
974 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
975 |
#$result["function"],當前執行的函式名稱.
|
|
|
976 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
977 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
978 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
979 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
980 |
#必填寫的參數:
|
|
|
981 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
982 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
983 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
984 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("phone","content");
|
|
|
985 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
|
|
986 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
987 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
988 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
989 |
#可以省略的參數:
|
|
|
990 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
991 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
|
|
|
992 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
993 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class");
|
|
|
994 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
995 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
|
|
|
996 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
997 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
|
|
|
998 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
999 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
1000 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
1001 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
1002 |
|
|
|
1003 |
#如果檢查參數失敗
|
|
|
1004 |
if($checkResult["status"]=="false"){
|
|
|
1005 |
|
|
|
1006 |
#設置執行失敗
|
|
|
1007 |
$result["status"]="false";
|
|
|
1008 |
|
|
|
1009 |
#設置錯誤訊息
|
|
|
1010 |
$result["error"]=$checkResult;
|
|
|
1011 |
|
|
|
1012 |
#回傳結果
|
|
|
1013 |
return $result;
|
|
|
1014 |
|
|
|
1015 |
}#if end
|
|
|
1016 |
|
|
|
1017 |
#如果檢查參數不通過
|
|
|
1018 |
if($checkResult["passed"]=="false"){
|
|
|
1019 |
|
|
|
1020 |
#設置執行失敗
|
|
|
1021 |
$result["status"]="false";
|
|
|
1022 |
|
|
|
1023 |
#設置錯誤訊息
|
|
|
1024 |
$result["error"]=$checkResult;
|
|
|
1025 |
|
|
|
1026 |
#回傳結果
|
|
|
1027 |
return $result;
|
|
|
1028 |
|
|
|
1029 |
}#if end
|
|
|
1030 |
|
|
|
1031 |
#函式說明:
|
|
|
1032 |
#放置超鏈接,裏面可以放各種內容.
|
|
|
1033 |
#回傳內容:
|
|
|
1034 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1035 |
#$result["error"],錯誤訊息
|
|
|
1036 |
#$result["content"],語法
|
|
|
1037 |
#$result["function"],當前執行的函數名稱
|
|
|
1038 |
#必填參數:
|
|
|
1039 |
#$conf["linkLocation"],字串,爲連結的網路位置.
|
|
|
1040 |
$conf["link::aTagSection"]["linkLocation"]="tel:".$conf["phone"];
|
|
|
1041 |
#$conf["content"],字串陣列,要放置的內容.
|
|
|
1042 |
$conf["link::aTagSection"]["content"]=array($conf["content"]);
|
|
|
1043 |
#可省略參數:
|
|
|
1044 |
|
|
|
1045 |
#如果有設定 class
|
|
|
1046 |
if(isset($conf["class"])){
|
|
|
1047 |
|
|
|
1048 |
#$conf["class"],陣列,爲link的css類別名稱.
|
|
|
1049 |
$conf["link::aTagSection"]["class"]=$conf["class"];
|
|
|
1050 |
|
|
|
1051 |
}#if end
|
|
|
1052 |
|
|
|
1053 |
#$conf["method"],爲點選該連結之後,新畫面要如何呈現,可留空,可用的選項有 _top(覆蓋目前的視窗來顯現新內容) _parent(在目前的父頁面顯示新畫面) _blank(跳新視窗) _self(在自己的頁面呈現),預設爲 _self。
|
|
|
1054 |
#$conf["method"]="";
|
|
|
1055 |
#$conf["no_outline"],字串,是否要取消連結的框線,"false為不取消,"true"代表要取消,預設為"true".
|
|
|
1056 |
#$conf["no_outline"]="";
|
|
|
1057 |
$aTagSection=link::aTagSection($conf["link::aTagSection"]);
|
|
|
1058 |
unset($conf["link::aTagSection"]);
|
|
|
1059 |
|
|
|
1060 |
#如果檢查參數失敗
|
|
|
1061 |
if($aTagSection["status"]=="false"){
|
|
|
1062 |
|
|
|
1063 |
#設置執行失敗
|
|
|
1064 |
$result["status"]="false";
|
|
|
1065 |
|
|
|
1066 |
#設置錯誤訊息
|
|
|
1067 |
$result["error"]=$aTagSection;
|
|
|
1068 |
|
|
|
1069 |
#回傳結果
|
|
|
1070 |
return $result;
|
|
|
1071 |
|
|
|
1072 |
}#if end
|
|
|
1073 |
|
|
|
1074 |
#取得內容
|
|
|
1075 |
$result["content"]=$aTagSection["content"];
|
|
|
1076 |
|
|
|
1077 |
#設置執行結果
|
|
|
1078 |
$result["status"]="true";
|
|
|
1079 |
|
|
|
1080 |
#回傳結果
|
|
|
1081 |
return $result;
|
|
|
1082 |
|
|
|
1083 |
}#function call end
|
|
|
1084 |
|
|
|
1085 |
}#class link end
|
|
|
1086 |
|
|
|
1087 |
?>
|