| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 239 |
liveuser |
6 |
Copyright (C) 2014~2026 MIN ZHI, CHEN
|
| 3 |
liveuser |
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
namespace qbpwcf;
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
應用ckEditor的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class ckEditor{
|
| 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 |
#匯入ckEditor的函式庫.
|
|
|
101 |
#回傳結果:
|
|
|
102 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
103 |
#$result["error"],錯誤訊息.
|
|
|
104 |
#$result["content"],語法.
|
|
|
105 |
#$result["function"],當前執行的函數名稱.
|
|
|
106 |
#必填參數:
|
|
|
107 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
108 |
$conf["libAddr"]="";
|
|
|
109 |
#可省略參數:
|
|
|
110 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
111 |
#$conf["fileArgu"]=__FILE__;
|
|
|
112 |
#參考資料:
|
|
|
113 |
#無.
|
|
|
114 |
#備註.
|
|
|
115 |
#無.
|
|
|
116 |
*/
|
|
|
117 |
public static function importLib(&$conf){
|
| 226 |
liveuser |
118 |
|
| 3 |
liveuser |
119 |
#初始化要回傳的內容
|
|
|
120 |
$result=array();
|
| 226 |
liveuser |
121 |
|
| 3 |
liveuser |
122 |
#取得當前執行的函數名稱
|
|
|
123 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
124 |
|
| 3 |
liveuser |
125 |
#初始化要回傳的語法
|
|
|
126 |
$result["content"]="";
|
| 226 |
liveuser |
127 |
|
| 3 |
liveuser |
128 |
#如果沒有參數
|
|
|
129 |
if(func_num_args()==0){
|
| 226 |
liveuser |
130 |
|
| 3 |
liveuser |
131 |
#設置執行失敗
|
|
|
132 |
$result["status"]="false";
|
| 226 |
liveuser |
133 |
|
| 3 |
liveuser |
134 |
#設置執行錯誤訊息
|
|
|
135 |
$result["error"]="函數".$result["function"]."需要參數";
|
| 226 |
liveuser |
136 |
|
| 3 |
liveuser |
137 |
#回傳結果
|
|
|
138 |
return $result;
|
| 226 |
liveuser |
139 |
|
| 3 |
liveuser |
140 |
}#if end
|
| 226 |
liveuser |
141 |
|
| 3 |
liveuser |
142 |
#取得參數
|
|
|
143 |
$result["argu"]=$conf;
|
| 226 |
liveuser |
144 |
|
| 3 |
liveuser |
145 |
#如果 $conf 不為陣列
|
|
|
146 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
147 |
|
| 3 |
liveuser |
148 |
#設置執行失敗
|
|
|
149 |
$result["status"]="false";
|
| 226 |
liveuser |
150 |
|
| 3 |
liveuser |
151 |
#設置執行錯誤訊息
|
|
|
152 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
153 |
|
|
|
154 |
#如果傳入的參數為 null
|
|
|
155 |
if($conf==null){
|
| 226 |
liveuser |
156 |
|
| 3 |
liveuser |
157 |
#設置執行錯誤訊息
|
|
|
158 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
159 |
|
| 3 |
liveuser |
160 |
}#if end
|
|
|
161 |
|
|
|
162 |
#回傳結果
|
|
|
163 |
return $result;
|
| 226 |
liveuser |
164 |
|
| 3 |
liveuser |
165 |
}#if end
|
| 226 |
liveuser |
166 |
|
| 3 |
liveuser |
167 |
#檢查參數
|
|
|
168 |
#函式說明:
|
|
|
169 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
170 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
171 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
172 |
#$result["function"],當前執行的函式名稱.
|
|
|
173 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
174 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
175 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
176 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
177 |
#必填寫的參數:
|
|
|
178 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
179 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
180 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
181 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
|
| 226 |
liveuser |
182 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
183 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
184 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
185 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
186 |
#可以省略的參數:
|
|
|
187 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
188 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
189 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
190 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
|
| 226 |
liveuser |
191 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
192 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
|
|
|
193 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
194 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
|
|
|
195 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
196 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
197 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
198 |
unset($conf["variableCheck::checkArguments"]);
|
| 226 |
liveuser |
199 |
|
| 3 |
liveuser |
200 |
#如果檢查參數失敗
|
|
|
201 |
if($checkResult["status"]=="false"){
|
| 226 |
liveuser |
202 |
|
| 3 |
liveuser |
203 |
#設置執行失敗
|
|
|
204 |
$result["status"]="false";
|
| 226 |
liveuser |
205 |
|
| 3 |
liveuser |
206 |
#設置錯誤訊息
|
|
|
207 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
208 |
|
| 3 |
liveuser |
209 |
#回傳結果
|
|
|
210 |
return $result;
|
| 226 |
liveuser |
211 |
|
| 3 |
liveuser |
212 |
}#if end
|
| 226 |
liveuser |
213 |
|
| 3 |
liveuser |
214 |
#如果檢查參數不通過
|
|
|
215 |
if($checkResult["passed"]=="false"){
|
| 226 |
liveuser |
216 |
|
| 3 |
liveuser |
217 |
#設置執行失敗
|
|
|
218 |
$result["status"]="false";
|
| 226 |
liveuser |
219 |
|
| 3 |
liveuser |
220 |
#設置錯誤訊息
|
|
|
221 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
222 |
|
| 3 |
liveuser |
223 |
#回傳結果
|
|
|
224 |
return $result;
|
| 226 |
liveuser |
225 |
|
| 3 |
liveuser |
226 |
}#if end
|
| 226 |
liveuser |
227 |
|
|
|
228 |
#匯入 $conf["libAddr"] js檔案
|
| 3 |
liveuser |
229 |
#函式說明:
|
| 226 |
liveuser |
230 |
#匯入js檔案
|
| 3 |
liveuser |
231 |
#回傳結果:
|
|
|
232 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
233 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
234 |
#$result["error"],陣列,錯訊訊息.
|
|
|
235 |
#$result["content"],字串,匯入css樣式的語法.
|
|
|
236 |
#必填參數:
|
|
|
237 |
#$conf["jsFileLocation"],陣列字串,多個js檔案的位置與名稱,每個元素代表一個js檔案的位置,js副檔名會自動補上.
|
|
|
238 |
$conf["javaScript::import"]["jsFileLocation"]=array($conf["libAddr"]);
|
|
|
239 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
|
|
|
240 |
$conf["javaScript::import"]["fileArgu"]=$conf["fileArgu"];
|
|
|
241 |
#參考資料:
|
|
|
242 |
#php於設常數=>http://php.net/manual/zh/language.constants.predefined.php
|
|
|
243 |
$import=javaScript::import($conf["javaScript::import"]);
|
|
|
244 |
unset($conf["javaScript::import"]);
|
| 226 |
liveuser |
245 |
|
| 3 |
liveuser |
246 |
#如果建立匯入js檔案的語法失敗
|
|
|
247 |
if($import["status"]=="false"){
|
| 226 |
liveuser |
248 |
|
| 3 |
liveuser |
249 |
#設置執行失敗
|
|
|
250 |
$result["status"]="false";
|
| 226 |
liveuser |
251 |
|
| 3 |
liveuser |
252 |
#設置錯誤訊息
|
|
|
253 |
$result["error"]=$import;
|
| 226 |
liveuser |
254 |
|
| 3 |
liveuser |
255 |
#回傳結果
|
|
|
256 |
return $result;
|
| 226 |
liveuser |
257 |
|
| 3 |
liveuser |
258 |
}#if end
|
| 226 |
liveuser |
259 |
|
| 3 |
liveuser |
260 |
#取得js語法
|
|
|
261 |
$result["content"]=$import["content"];
|
| 226 |
liveuser |
262 |
|
| 3 |
liveuser |
263 |
#設置執行正常
|
|
|
264 |
$result["status"]="true";
|
| 226 |
liveuser |
265 |
|
| 3 |
liveuser |
266 |
#回傳結果
|
|
|
267 |
return $result;
|
| 226 |
liveuser |
268 |
|
| 3 |
liveuser |
269 |
}#function importLib end
|
| 226 |
liveuser |
270 |
|
| 3 |
liveuser |
271 |
/*
|
|
|
272 |
#函式說明:
|
|
|
273 |
#即刻編輯與顯示預覽結果的demo.
|
|
|
274 |
#回傳結果:
|
|
|
275 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
276 |
#$result["error"],錯誤訊息.
|
|
|
277 |
#$result["content"],語法.
|
|
|
278 |
#$result["function"],當前執行的函數名稱.
|
|
|
279 |
#必填參數:
|
|
|
280 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
281 |
$conf["libAddr"]="";
|
|
|
282 |
#可省略參數:
|
|
|
283 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
284 |
#$conf["fileArgu"]=__FILE__;
|
|
|
285 |
#參考資料:
|
|
|
286 |
#using ckeditor=>http://docs.ckeditor.com/#!/guide/dev_installation
|
|
|
287 |
#get ckeditor content=>content http://docs.ckeditor.com/#!/guide/dev_savedata
|
|
|
288 |
#備註.
|
|
|
289 |
#無.
|
|
|
290 |
*/
|
|
|
291 |
public static function demo(&$conf){
|
| 226 |
liveuser |
292 |
|
| 3 |
liveuser |
293 |
#初始化要回傳的內容
|
|
|
294 |
$result=array();
|
| 226 |
liveuser |
295 |
|
| 3 |
liveuser |
296 |
#取得當前執行的函數名稱
|
|
|
297 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
298 |
|
| 3 |
liveuser |
299 |
#初始化要回傳的語法
|
|
|
300 |
$result["content"]="";
|
| 226 |
liveuser |
301 |
|
| 3 |
liveuser |
302 |
#如果沒有參數
|
|
|
303 |
if(func_num_args()==0){
|
| 226 |
liveuser |
304 |
|
| 3 |
liveuser |
305 |
#設置執行失敗
|
|
|
306 |
$result["status"]="false";
|
| 226 |
liveuser |
307 |
|
| 3 |
liveuser |
308 |
#設置執行錯誤訊息
|
|
|
309 |
$result["error"]="函數".$result["function"]."需要參數";
|
| 226 |
liveuser |
310 |
|
| 3 |
liveuser |
311 |
#回傳結果
|
|
|
312 |
return $result;
|
| 226 |
liveuser |
313 |
|
| 3 |
liveuser |
314 |
}#if end
|
| 226 |
liveuser |
315 |
|
| 3 |
liveuser |
316 |
#取得參數
|
|
|
317 |
$result["argu"]=$conf;
|
| 226 |
liveuser |
318 |
|
| 3 |
liveuser |
319 |
#如果 $conf 不為陣列
|
|
|
320 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
321 |
|
| 3 |
liveuser |
322 |
#設置執行失敗
|
|
|
323 |
$result["status"]="false";
|
| 226 |
liveuser |
324 |
|
| 3 |
liveuser |
325 |
#設置執行錯誤訊息
|
|
|
326 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
327 |
|
|
|
328 |
#如果傳入的參數為 null
|
|
|
329 |
if($conf==null){
|
| 226 |
liveuser |
330 |
|
| 3 |
liveuser |
331 |
#設置執行錯誤訊息
|
|
|
332 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
333 |
|
| 3 |
liveuser |
334 |
}#if end
|
|
|
335 |
|
|
|
336 |
#回傳結果
|
|
|
337 |
return $result;
|
| 226 |
liveuser |
338 |
|
| 3 |
liveuser |
339 |
}#if end
|
| 226 |
liveuser |
340 |
|
| 3 |
liveuser |
341 |
#檢查參數
|
|
|
342 |
#函式說明:
|
|
|
343 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
344 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
345 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
346 |
#$result["function"],當前執行的函式名稱.
|
|
|
347 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
348 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
349 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
350 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
351 |
#必填寫的參數:
|
|
|
352 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
353 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
354 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
355 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
|
| 226 |
liveuser |
356 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
357 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
|
|
358 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
359 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
360 |
#可以省略的參數:
|
|
|
361 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
362 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
363 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
364 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
|
| 226 |
liveuser |
365 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
366 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
|
|
|
367 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
368 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
|
|
|
369 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
370 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
371 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
372 |
unset($conf["variableCheck::checkArguments"]);
|
| 226 |
liveuser |
373 |
|
| 3 |
liveuser |
374 |
#如果檢查參數失敗
|
|
|
375 |
if($checkResult["status"]=="false"){
|
| 226 |
liveuser |
376 |
|
| 3 |
liveuser |
377 |
#設置執行失敗
|
|
|
378 |
$result["status"]="false";
|
| 226 |
liveuser |
379 |
|
| 3 |
liveuser |
380 |
#設置錯誤訊息
|
|
|
381 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
382 |
|
| 3 |
liveuser |
383 |
#回傳結果
|
|
|
384 |
return $result;
|
| 226 |
liveuser |
385 |
|
| 3 |
liveuser |
386 |
}#if end
|
| 226 |
liveuser |
387 |
|
| 3 |
liveuser |
388 |
#如果檢查參數不通過
|
|
|
389 |
if($checkResult["passed"]=="false"){
|
| 226 |
liveuser |
390 |
|
| 3 |
liveuser |
391 |
#設置執行失敗
|
|
|
392 |
$result["status"]="false";
|
| 226 |
liveuser |
393 |
|
| 3 |
liveuser |
394 |
#設置錯誤訊息
|
|
|
395 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
396 |
|
| 3 |
liveuser |
397 |
#回傳結果
|
|
|
398 |
return $result;
|
| 226 |
liveuser |
399 |
|
| 3 |
liveuser |
400 |
}#if end
|
| 226 |
liveuser |
401 |
|
| 3 |
liveuser |
402 |
#demo用的內容
|
|
|
403 |
$demoContent="
|
|
|
404 |
<div class=\"container\" style=\"padding-top:5%;\" align=\"center\">
|
|
|
405 |
|
|
|
406 |
<!--Logo-->
|
|
|
407 |
<div id=\"header\">
|
|
|
408 |
<div class=\"col-xs-12 text-center padding10\"><div class=\"store-logo\"><img src=\"fedoraBear.png\" class=\"img-responsive\" height=\"99\" width=\"256\"><span class=\"store-name\"><h2>XXXX XXWiFiXX</h2> </span></div>
|
|
|
409 |
</div>
|
| 226 |
liveuser |
410 |
|
|
|
411 |
<!--Promotion-->
|
| 3 |
liveuser |
412 |
<div class=\"row light-gray padding30\">
|
|
|
413 |
<div id=\"section\" class=\"col-sm-12 text-center\"><div class=\"2-row section-img\"><img src=\"fedoraBear.png\" class=\"Wpadding10 img-responsive\" width=\"250\"></div><div class=\"2-row section-content text-left\"><h4>XXXXXXXXX®XXXXXXXXXXXXXXXXXXXXXXXXX !</h4>
|
|
|
414 |
<p> XXXXXXXXXXXXXXXXXXXXXXXXXXXWiFiXXXX,XXXWiFiXXXXX,XXXXXX</p></div>
|
| 226 |
liveuser |
415 |
|
| 3 |
liveuser |
416 |
</div>
|
| 226 |
liveuser |
417 |
</div>
|
|
|
418 |
|
| 3 |
liveuser |
419 |
<hr>
|
|
|
420 |
|
|
|
421 |
<div class=\"col-sm-12 text-center margin-bottom20\"><button type=\"button\" class=\"btn btn-lg btn-primary\"><span class=\"font400 Wpadding30\">Get WiFi <i class=\"fa fa-wifi\" aria-hidden=\"true\"></i></span>
|
|
|
422 |
</button></div>
|
|
|
423 |
|
|
|
424 |
<footer><p>© XXXX XX XXXXXXXX. XXXXXXXXXXX.</p>
|
|
|
425 |
</footer>
|
|
|
426 |
|
|
|
427 |
</div><!--container-->
|
|
|
428 |
|
|
|
429 |
</div>
|
|
|
430 |
";
|
| 226 |
liveuser |
431 |
|
| 3 |
liveuser |
432 |
#建立給ckeditor置換的textarea
|
|
|
433 |
#涵式說明:
|
|
|
434 |
#可以輸入文字的區塊
|
|
|
435 |
#回傳結果:
|
|
|
436 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
437 |
#$result["function"],當前執行的函數.
|
|
|
438 |
#$result["error"],錯誤訊息陣列.
|
| 226 |
liveuser |
439 |
#$result["content"],按鈕語法.
|
| 3 |
liveuser |
440 |
#必填的參數:
|
|
|
441 |
$conf["form::inputTextArea"]["name"]="ckeditor";#爲文字輸入框的名稱,供接收端辨識用。
|
|
|
442 |
$conf["form::inputTextArea"]["readOnly"]="false";#爲是否要爲唯讀,如果爲"true",則爲唯讀。反之則爲"false"。
|
|
|
443 |
#可省略的參數:
|
|
|
444 |
#$conf["id"],字串,文字區塊的id,供javaScript呼叫用.
|
|
|
445 |
$conf["form::inputTextArea"]["id"]="ckeditor";
|
|
|
446 |
#$conf["width"]="";#為輸入框的寬度,預設不指定.
|
|
|
447 |
#$conf["cols"]="";#爲文字輸入框的欄位數(寬),預設爲按照瀏覽器設定值。
|
|
|
448 |
#$conf["rows"]="";#爲文字輸入框的列數(高),預設爲按照瀏覽器設定值。
|
|
|
449 |
#$conf["maxInputLength"]="";#爲文字輸入的長度限制,預設無限制。
|
|
|
450 |
$conf["form::inputTextArea"]["defaultText"]=$demoContent;#爲文字輸入框裏面的預設文字內容,預設是空的。
|
|
|
451 |
#$conf["class"]=;#爲要套用的css樣式。如果沒有指定 ,則採用預設的css樣式,"__inputTextAreaCssStyle",其屬性爲 "width:100%","height:120px","font-size:30px"
|
|
|
452 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
453 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
454 |
#$conf["formStart"]="true";#爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
455 |
#$conf["formAction"]="";#表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
456 |
#$conf["formName"]="";#爲該表單的名稱
|
|
|
457 |
#$conf["formMethod"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
458 |
#$conf["formTarget"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
459 |
#$conf["formEnd"]="true";#爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
460 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
461 |
#$conf["comment"]="";
|
|
|
462 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
463 |
#$conf["required"]="true";
|
|
|
464 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
465 |
#$conf["placeholder"]="";
|
|
|
466 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
467 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
468 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
469 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
470 |
#參考資料來源:
|
|
|
471 |
#input=>http://www.w3schools.com/tags/tag_input.asp
|
|
|
472 |
$inputTextArea=form::inputTextArea($conf["form::inputTextArea"]);
|
|
|
473 |
unset($conf["form::inputTextArea"]);
|
| 226 |
liveuser |
474 |
|
| 3 |
liveuser |
475 |
#如果建立文字區塊失敗
|
|
|
476 |
if($inputTextArea["status"]=="false"){
|
| 226 |
liveuser |
477 |
|
| 3 |
liveuser |
478 |
#設置執行失敗
|
|
|
479 |
$result["status"]="false";
|
| 226 |
liveuser |
480 |
|
| 3 |
liveuser |
481 |
#設置錯誤訊息
|
|
|
482 |
$result["error"]=$inputTextArea;
|
| 226 |
liveuser |
483 |
|
| 3 |
liveuser |
484 |
#回傳結果
|
|
|
485 |
return $result;
|
| 226 |
liveuser |
486 |
|
| 3 |
liveuser |
487 |
}#if end
|
| 226 |
liveuser |
488 |
|
| 3 |
liveuser |
489 |
#取得文字方框的語法
|
|
|
490 |
$result["content"]=$result["content"].$inputTextArea["content"];
|
| 226 |
liveuser |
491 |
|
| 3 |
liveuser |
492 |
#函式說明:
|
|
|
493 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
494 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
495 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
496 |
#$result["error"],陣列,錯訊訊息.
|
|
|
497 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
498 |
#必填參數:
|
|
|
499 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
500 |
$conf["css::divSection"]["contentArray"]=array("以下為ckeditor編輯器預覽的結果:");
|
|
|
501 |
#可省略參數
|
|
|
502 |
#$conf["id"],字串,div區塊的id.
|
|
|
503 |
#$conf["css::divSection"]["id"]="preview";
|
|
|
504 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
505 |
#$conf["class"]="";
|
|
|
506 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
507 |
#$conf["title"]=array();
|
|
|
508 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
509 |
unset($conf["css::divSection"]);
|
| 226 |
liveuser |
510 |
|
| 3 |
liveuser |
511 |
#如果建立div區塊失敗
|
|
|
512 |
if($divSection["status"]=="false"){
|
| 226 |
liveuser |
513 |
|
| 3 |
liveuser |
514 |
#設置執行失敗
|
|
|
515 |
$result["status"]="false";
|
| 226 |
liveuser |
516 |
|
| 3 |
liveuser |
517 |
#設置錯誤訊息
|
|
|
518 |
$result["error"]=$divSection;
|
| 226 |
liveuser |
519 |
|
| 3 |
liveuser |
520 |
#回傳結果
|
|
|
521 |
return $result;
|
| 226 |
liveuser |
522 |
|
| 3 |
liveuser |
523 |
}#if end
|
| 226 |
liveuser |
524 |
|
| 3 |
liveuser |
525 |
#取得div區塊的語法
|
|
|
526 |
$result["content"]=$result["content"].$divSection["content"];
|
| 226 |
liveuser |
527 |
|
| 3 |
liveuser |
528 |
#放置給ckeditor預覽用的區塊
|
|
|
529 |
#函式說明:
|
|
|
530 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
531 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
532 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
533 |
#$result["error"],陣列,錯訊訊息.
|
|
|
534 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
535 |
#必填參數:
|
|
|
536 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
537 |
$conf["css::divSection"]["contentArray"]=array();
|
|
|
538 |
#可省略參數
|
|
|
539 |
#$conf["id"],字串,div區塊的id.
|
|
|
540 |
$conf["css::divSection"]["id"]="preview";
|
|
|
541 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
542 |
#$conf["class"]="";
|
|
|
543 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
544 |
#$conf["title"]=array();
|
|
|
545 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
546 |
unset($conf["css::divSection"]);
|
| 226 |
liveuser |
547 |
|
| 3 |
liveuser |
548 |
#如果建立div區塊失敗
|
|
|
549 |
if($divSection["status"]=="false"){
|
| 226 |
liveuser |
550 |
|
| 3 |
liveuser |
551 |
#設置執行失敗
|
|
|
552 |
$result["status"]="false";
|
| 226 |
liveuser |
553 |
|
| 3 |
liveuser |
554 |
#設置錯誤訊息
|
|
|
555 |
$result["error"]=$divSection;
|
| 226 |
liveuser |
556 |
|
| 3 |
liveuser |
557 |
#回傳結果
|
|
|
558 |
return $result;
|
| 226 |
liveuser |
559 |
|
| 3 |
liveuser |
560 |
}#if end
|
| 226 |
liveuser |
561 |
|
| 3 |
liveuser |
562 |
#取得div區塊的語法
|
|
|
563 |
$result["content"]=$result["content"].$divSection["content"];
|
| 226 |
liveuser |
564 |
|
| 3 |
liveuser |
565 |
#函式說明:
|
|
|
566 |
#匯入ckEditor的函式庫.
|
|
|
567 |
#回傳結果:
|
|
|
568 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
569 |
#$result["error"],錯誤訊息.
|
|
|
570 |
#$result["content"],語法.
|
|
|
571 |
#$result["function"],當前執行的函數名稱.
|
|
|
572 |
#必填參數:
|
|
|
573 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
574 |
$conf["ckEditor::importLib"]["libAddr"]=$conf["libAddr"];
|
|
|
575 |
#可省略參數:
|
|
|
576 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
577 |
$conf["ckEditor::importLib"]["fileArgu"]=$conf["fileArgu"];
|
|
|
578 |
$importLib=ckEditor::importLib($conf["ckEditor::importLib"]);
|
|
|
579 |
unset($conf["ckEditor::importLib"]);
|
| 226 |
liveuser |
580 |
|
| 3 |
liveuser |
581 |
#如果建立匯入 ckeditor js lib 的語法失敗
|
|
|
582 |
if($importLib["status"]=="false"){
|
| 226 |
liveuser |
583 |
|
| 3 |
liveuser |
584 |
#設置執行失敗
|
|
|
585 |
$result["status"]="false";
|
| 226 |
liveuser |
586 |
|
| 3 |
liveuser |
587 |
#設置錯誤訊息
|
|
|
588 |
$result["error"]=$importLib;
|
| 226 |
liveuser |
589 |
|
| 3 |
liveuser |
590 |
#回傳結果
|
|
|
591 |
return $result;
|
| 226 |
liveuser |
592 |
|
| 3 |
liveuser |
593 |
}#if end
|
| 226 |
liveuser |
594 |
|
| 3 |
liveuser |
595 |
#取得匯入ckeditor的語法
|
|
|
596 |
$result["content"]=$result["content"].$importLib["content"];
|
| 226 |
liveuser |
597 |
|
| 3 |
liveuser |
598 |
#涵式說明:
|
|
|
599 |
#將要執行的script語法透過該函式執行
|
|
|
600 |
#回傳結果:
|
|
|
601 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
602 |
#$result["error"],錯誤訊息陣列
|
|
|
603 |
#$result["function"],當前執行的函數名稱
|
|
|
604 |
#$result["content"],要執行的javaScript語法
|
|
|
605 |
#必填的參數:
|
|
|
606 |
#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
|
|
|
607 |
$conf["javaScript::toScript"]["script"]="
|
|
|
608 |
preview='';
|
|
|
609 |
ckeditor=CKEDITOR.replace('ckeditor');
|
|
|
610 |
ckeditor.on('change',function(evt)
|
|
|
611 |
{
|
|
|
612 |
preview=evt.editor.getData();
|
| 226 |
liveuser |
613 |
$('#preview').html(preview);
|
| 3 |
liveuser |
614 |
});
|
|
|
615 |
";
|
|
|
616 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
617 |
unset($conf["javaScript::toScript"]);
|
| 226 |
liveuser |
618 |
|
| 3 |
liveuser |
619 |
#如果轉換成js語法失敗
|
|
|
620 |
if($toScript["status"]=="false"){
|
| 226 |
liveuser |
621 |
|
| 3 |
liveuser |
622 |
#設置執行失敗
|
|
|
623 |
$result["status"]="false";
|
| 226 |
liveuser |
624 |
|
| 3 |
liveuser |
625 |
#設置錯誤訊息
|
|
|
626 |
$result["error"]=$toScript;
|
| 226 |
liveuser |
627 |
|
| 3 |
liveuser |
628 |
#回傳結果
|
|
|
629 |
return $result;
|
| 226 |
liveuser |
630 |
|
| 3 |
liveuser |
631 |
}#if end
|
| 226 |
liveuser |
632 |
|
| 3 |
liveuser |
633 |
#取得使用ckeditor的語法
|
|
|
634 |
$result["content"]=$result["content"].$toScript["content"];
|
| 226 |
liveuser |
635 |
|
| 3 |
liveuser |
636 |
#設置執行正常
|
|
|
637 |
$result["status"]="true";
|
| 226 |
liveuser |
638 |
|
| 3 |
liveuser |
639 |
#回傳結果
|
|
|
640 |
return $result;
|
| 226 |
liveuser |
641 |
|
| 3 |
liveuser |
642 |
}#function demo end
|
| 226 |
liveuser |
643 |
|
| 3 |
liveuser |
644 |
/*
|
|
|
645 |
#函式說明:
|
|
|
646 |
#即刻編輯從資料庫抓出來的資料與顯示預覽結果的demo.
|
|
|
647 |
#回傳結果:
|
|
|
648 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
649 |
#$result["error"],錯誤訊息.
|
|
|
650 |
#$result["content"],語法.
|
|
|
651 |
#$result["function"],當前執行的函數名稱.
|
|
|
652 |
#必填參數:
|
|
|
653 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
654 |
$conf["libAddr"]="";
|
|
|
655 |
#$conf["dbAccount"],字串,連線用的帳戶
|
|
|
656 |
$conf["dbAccount"]="";
|
|
|
657 |
#$conf["dbPassword"],字串,連線用的密碼
|
|
|
658 |
$conf["dbPassword"]="";
|
|
|
659 |
#$conf["dbAddress"],字串,自立庫的位址.
|
|
|
660 |
$conf["dbAddress"]="";
|
|
|
661 |
#$conf["dbName"],字串,資料庫名稱.
|
| 226 |
liveuser |
662 |
$conf["dbName"]="";
|
| 3 |
liveuser |
663 |
#$conf["dtName"],字串,資料表名稱.
|
|
|
664 |
$conf["dtName"]="";
|
|
|
665 |
#$conf["columnName"],字串,欄位名稱.
|
|
|
666 |
$conf["columnName"]="";
|
|
|
667 |
#可省略參數:
|
|
|
668 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
669 |
#$conf["fileArgu"]=__FILE__;
|
|
|
670 |
#$conf["putBy"],字串,內容要放到 textarea 還是用 ckeditor js 的 setData() 方法.前者請設定為"textarea",後者請設定為"native",預設為"textarea".
|
|
|
671 |
#$conf["putBy"]="";
|
|
|
672 |
#參考資料:
|
|
|
673 |
#using ckeditor=>http://docs.ckeditor.com/#!/guide/dev_installation
|
|
|
674 |
#get ckeditor content=>content http://docs.ckeditor.com/#!/guide/dev_savedata
|
|
|
675 |
#CKEDITOR.appendTo('editorSpace');=>清空編輯器的內容.
|
|
|
676 |
#備註.
|
|
|
677 |
#無.
|
|
|
678 |
*/
|
|
|
679 |
public static function demoWithDb(&$conf){
|
| 226 |
liveuser |
680 |
|
| 3 |
liveuser |
681 |
#初始化要回傳的內容
|
|
|
682 |
$result=array();
|
| 226 |
liveuser |
683 |
|
| 3 |
liveuser |
684 |
#取得當前執行的函數名稱
|
|
|
685 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
686 |
|
| 3 |
liveuser |
687 |
#初始化要回傳的語法
|
|
|
688 |
$result["content"]="";
|
| 226 |
liveuser |
689 |
|
| 3 |
liveuser |
690 |
#如果沒有參數
|
|
|
691 |
if(func_num_args()==0){
|
| 226 |
liveuser |
692 |
|
| 3 |
liveuser |
693 |
#設置執行失敗
|
|
|
694 |
$result["status"]="false";
|
| 226 |
liveuser |
695 |
|
| 3 |
liveuser |
696 |
#設置執行錯誤訊息
|
|
|
697 |
$result["error"]="函數".$result["function"]."需要參數";
|
| 226 |
liveuser |
698 |
|
| 3 |
liveuser |
699 |
#回傳結果
|
|
|
700 |
return $result;
|
| 226 |
liveuser |
701 |
|
| 3 |
liveuser |
702 |
}#if end
|
| 226 |
liveuser |
703 |
|
| 3 |
liveuser |
704 |
#取得參數
|
|
|
705 |
$result["argu"]=$conf;
|
| 226 |
liveuser |
706 |
|
| 3 |
liveuser |
707 |
#如果 $conf 不為陣列
|
|
|
708 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
709 |
|
| 3 |
liveuser |
710 |
#設置執行失敗
|
|
|
711 |
$result["status"]="false";
|
| 226 |
liveuser |
712 |
|
| 3 |
liveuser |
713 |
#設置執行錯誤訊息
|
|
|
714 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
715 |
|
|
|
716 |
#如果傳入的參數為 null
|
|
|
717 |
if($conf==null){
|
| 226 |
liveuser |
718 |
|
| 3 |
liveuser |
719 |
#設置執行錯誤訊息
|
|
|
720 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
721 |
|
| 3 |
liveuser |
722 |
}#if end
|
|
|
723 |
|
|
|
724 |
#回傳結果
|
|
|
725 |
return $result;
|
| 226 |
liveuser |
726 |
|
| 3 |
liveuser |
727 |
}#if end
|
| 226 |
liveuser |
728 |
|
| 3 |
liveuser |
729 |
#檢查參數
|
|
|
730 |
#函式說明:
|
|
|
731 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
732 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
733 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
734 |
#$result["function"],當前執行的函式名稱.
|
|
|
735 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
736 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
737 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
738 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
739 |
#必填寫的參數:
|
|
|
740 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
741 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
742 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
743 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr","dbAddress","dbAccount","dbPassword","dbName","dbPassword","dtName","columnName");
|
| 226 |
liveuser |
744 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
745 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string","string","string","string");
|
|
|
746 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
747 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
748 |
#可以省略的參數:
|
|
|
749 |
#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
750 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
751 |
#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
752 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","putBy");
|
| 226 |
liveuser |
753 |
#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
754 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
755 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
756 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,"textarea");
|
|
|
757 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
758 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
759 |
$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
760 |
unset($conf["variableCheck::checkArguments"]);
|
| 226 |
liveuser |
761 |
|
| 3 |
liveuser |
762 |
#如果檢查參數失敗
|
|
|
763 |
if($checkResult["status"]=="false"){
|
| 226 |
liveuser |
764 |
|
| 3 |
liveuser |
765 |
#設置執行失敗
|
|
|
766 |
$result["status"]="false";
|
| 226 |
liveuser |
767 |
|
| 3 |
liveuser |
768 |
#設置錯誤訊息
|
|
|
769 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
770 |
|
| 3 |
liveuser |
771 |
#回傳結果
|
|
|
772 |
return $result;
|
| 226 |
liveuser |
773 |
|
| 3 |
liveuser |
774 |
}#if end
|
| 226 |
liveuser |
775 |
|
| 3 |
liveuser |
776 |
#如果檢查參數不通過
|
|
|
777 |
if($checkResult["passed"]=="false"){
|
| 226 |
liveuser |
778 |
|
| 3 |
liveuser |
779 |
#設置執行失敗
|
|
|
780 |
$result["status"]="false";
|
| 226 |
liveuser |
781 |
|
| 3 |
liveuser |
782 |
#設置錯誤訊息
|
|
|
783 |
$result["error"]=$checkResult;
|
| 226 |
liveuser |
784 |
|
| 3 |
liveuser |
785 |
#回傳結果
|
|
|
786 |
return $result;
|
| 226 |
liveuser |
787 |
|
| 3 |
liveuser |
788 |
}#if end
|
| 226 |
liveuser |
789 |
|
| 3 |
liveuser |
790 |
#取得demo用的資料
|
|
|
791 |
#涵式說明:
|
|
|
792 |
#一次取得資料庫、表的資料
|
|
|
793 |
#回傳的結果
|
|
|
794 |
#$result["status"],執行結果"true"為成功;"false"為執行失敗。
|
|
|
795 |
#$result["error"],錯誤訊息陣列。
|
|
|
796 |
#$result["function"],當前執行的漢書名稱.
|
|
|
797 |
#$result["dataColumnName"],抓取的資料欄位名稱陣列.
|
|
|
798 |
#$result["dataColumnName"][$i]代表第$i+1個欄位名稱
|
|
|
799 |
#$result["dataContent"],爲資料的內容。
|
|
|
800 |
#$result["dataContent"][$conf["WhereColumnName"][$i]][$dataSetNum]
|
|
|
801 |
#$dataSetNum 爲第$dataSetNum+1筆資料
|
|
|
802 |
#$conf["WhereColumnName"][$i] 爲第 $i+1 個欄位的名稱
|
|
|
803 |
#$result["dataCount"],爲取得的資料筆數。
|
|
|
804 |
#$result["sql"],執行的sql字串.
|
|
|
805 |
#必填的參數:
|
|
|
806 |
$conf["db::fastGetDbData"]["dbAddress"]=$conf["dbAddress"];#爲dbServer的位置。
|
|
|
807 |
$conf["db::fastGetDbData"]["dbAccount"]=$conf["dbAccount"];#爲登入dbServer的帳號。
|
|
|
808 |
$conf["db::fastGetDbData"]["dbName"]=$conf["dbName"];#爲要存取的資料庫名稱
|
|
|
809 |
$conf["db::fastGetDbData"]["tableName"]=$conf["dtName"];#爲要存取的資料表名稱
|
|
|
810 |
$conf["db::fastGetDbData"]["columnYouWant"]=array($conf["columnName"]);#你想要的欄位!,若設為「array("*")」則代表全部欄位.
|
|
|
811 |
#可省略的參數:
|
|
|
812 |
$conf["db::fastGetDbData"]["dbPassword"]=$conf["dbPassword"];#爲要存取dbServer的密碼
|
|
|
813 |
#$conf["WhereColumnName"]=array("");#用於判斷語句的欄位項目陣列。
|
|
|
814 |
#$conf["WhereColumnValue"]=array("");#用於判斷語句的欄位數值陣列,若與LIKE搭配,則可以在關鍵自字串的左右名加上「%」符號,這樣就可以搜尋具有該字串的內容。
|
|
|
815 |
#$conf["WhereColumnCombine"]=array("");#用於判斷語句當中需要()起來的判斷式,須爲陣列值,"s"代表「(」,"e"代表「)」 ,若無則須設爲""。
|
|
|
816 |
#$conf["WhereColumnOperator"]=array("");#用於判斷語句的比較符號陣列,可以用的符號有「"="、"!="、">"、"<"、"LIKE"、"NOT LIKE"」,預設都爲「=」。
|
|
|
817 |
#$conf["WhereColumnAndOr"]=array("");#用於判斷語句條件之間成立的條件是AND還是OR,須爲陣列值。其數量應爲要判斷的欄位數量減一。
|
|
|
818 |
#$conf["orderItem"]="";#爲排序的項目依據,若要用隨機抽樣,可以用"rand()",可省略。
|
|
|
819 |
#$conf["ascORdesc"]="";#爲要低增還是遞減排序,asc爲遞增;desc爲遞減。
|
|
|
820 |
#$conf["numberStart"]="0";#為從第幾筆開始讀取,預設為0,代筆第一筆。
|
|
|
821 |
#$conf["numLimit"]="30";#為要取幾筆資料,可以省略,省略則表示不限制數目。
|
|
|
822 |
#$conf["groupBy"]=array("");#爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
|
|
|
823 |
#備註:
|
|
|
824 |
#建議在查詢資料前,能夠檢查是否每個欄位都存在.
|
|
|
825 |
$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
|
|
|
826 |
unset($conf["db::fastGetDbData"]);
|
| 226 |
liveuser |
827 |
|
| 3 |
liveuser |
828 |
#如果從資料庫取得資料失敗
|
|
|
829 |
if($fastGetDbData["status"]=="false"){
|
| 226 |
liveuser |
830 |
|
| 3 |
liveuser |
831 |
#設置執行失敗
|
|
|
832 |
$result["status"]="false";
|
| 226 |
liveuser |
833 |
|
| 3 |
liveuser |
834 |
#設置錯誤訊息
|
|
|
835 |
$result["error"]=$fastGetDbData;
|
| 226 |
liveuser |
836 |
|
| 3 |
liveuser |
837 |
#回傳結果
|
|
|
838 |
return $result;
|
| 226 |
liveuser |
839 |
|
| 3 |
liveuser |
840 |
}#if end
|
| 226 |
liveuser |
841 |
|
| 3 |
liveuser |
842 |
#如果沒有資料
|
|
|
843 |
if($fastGetDbData["dataCount"]==0){
|
| 226 |
liveuser |
844 |
|
| 3 |
liveuser |
845 |
#設置執行失敗
|
|
|
846 |
$result["status"]="false";
|
| 226 |
liveuser |
847 |
|
| 3 |
liveuser |
848 |
#設置錯誤訊息
|
|
|
849 |
$result["error"][]="沒有資料!";
|
| 226 |
liveuser |
850 |
|
| 3 |
liveuser |
851 |
#回傳結果
|
|
|
852 |
return $result;
|
| 226 |
liveuser |
853 |
|
| 3 |
liveuser |
854 |
}#if end
|
| 226 |
liveuser |
855 |
|
| 3 |
liveuser |
856 |
#初始化原生放置內容到textarea的語法
|
|
|
857 |
$setData="";
|
| 226 |
liveuser |
858 |
|
| 3 |
liveuser |
859 |
#如果 $conf["putBy"] 為 "textarea"
|
|
|
860 |
if($conf["putBy"]=="textarea"){
|
| 226 |
liveuser |
861 |
|
| 3 |
liveuser |
862 |
#demo用的內容
|
|
|
863 |
$demoContent=$fastGetDbData["dataContent"]["content"][0];
|
| 226 |
liveuser |
864 |
|
| 3 |
liveuser |
865 |
}#if end
|
| 226 |
liveuser |
866 |
|
| 3 |
liveuser |
867 |
#反之
|
|
|
868 |
else{
|
| 226 |
liveuser |
869 |
|
| 3 |
liveuser |
870 |
#設為空字串
|
|
|
871 |
$demoContent="";
|
| 226 |
liveuser |
872 |
|
| 3 |
liveuser |
873 |
#過濾字串
|
|
|
874 |
#涵式說明:
|
|
|
875 |
#處理字串避免網頁出錯
|
|
|
876 |
#回傳的結果:
|
|
|
877 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
878 |
#$result["function"],當前執行的函數.
|
|
|
879 |
#$result["content"],爲處理好的字串.
|
|
|
880 |
#$result["error"],錯誤訊息陣列.
|
|
|
881 |
#必填的參數:
|
|
|
882 |
$conf["stringProcess::correctCharacter"]["stringIn"]=$fastGetDbData["dataContent"][$conf["columnName"]][0];#爲要處理的字串
|
|
|
883 |
#可省略的參數:
|
|
|
884 |
$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("\r","\n");#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
885 |
#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
|
|
|
886 |
#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
|
|
|
887 |
#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
888 |
$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
|
|
|
889 |
unset($conf["stringProcess::correctCharacter"]);
|
| 226 |
liveuser |
890 |
|
| 3 |
liveuser |
891 |
#如果過濾字串失敗
|
|
|
892 |
if($correctCharacter["status"]=="false"){
|
| 226 |
liveuser |
893 |
|
| 3 |
liveuser |
894 |
#設置執行失敗
|
|
|
895 |
$result["status"]="false";
|
| 226 |
liveuser |
896 |
|
| 3 |
liveuser |
897 |
#設置錯誤訊息
|
|
|
898 |
$result["error"]=$correctCharacter;
|
| 226 |
liveuser |
899 |
|
| 3 |
liveuser |
900 |
#回傳結果
|
|
|
901 |
return $result;
|
| 226 |
liveuser |
902 |
|
| 3 |
liveuser |
903 |
}#if end
|
| 226 |
liveuser |
904 |
|
| 3 |
liveuser |
905 |
#ckeditor原生放置內容到textarea的語法
|
|
|
906 |
$setData="CKEDITOR.instances.ckeditor.setData('".$correctCharacter["content"]."');";
|
| 226 |
liveuser |
907 |
|
| 3 |
liveuser |
908 |
}#else end
|
| 226 |
liveuser |
909 |
|
| 3 |
liveuser |
910 |
#建立給ckeditor置換的textarea
|
|
|
911 |
#涵式說明:
|
|
|
912 |
#可以輸入文字的區塊
|
|
|
913 |
#回傳結果:
|
|
|
914 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
915 |
#$result["function"],當前執行的函數.
|
|
|
916 |
#$result["error"],錯誤訊息陣列.
|
| 226 |
liveuser |
917 |
#$result["content"],按鈕語法.
|
| 3 |
liveuser |
918 |
#必填的參數:
|
|
|
919 |
$conf["form::inputTextArea"]["name"]="ckeditor";#爲文字輸入框的名稱,供接收端辨識用。
|
|
|
920 |
$conf["form::inputTextArea"]["readOnly"]="false";#爲是否要爲唯讀,如果爲"true",則爲唯讀。反之則爲"false"。
|
|
|
921 |
#可省略的參數:
|
|
|
922 |
#$conf["id"],字串,文字區塊的id,供javaScript呼叫用.
|
|
|
923 |
$conf["form::inputTextArea"]["id"]="ckeditor";
|
|
|
924 |
#$conf["width"]="";#為輸入框的寬度,預設不指定.
|
|
|
925 |
#$conf["cols"]="";#爲文字輸入框的欄位數(寬),預設爲按照瀏覽器設定值。
|
|
|
926 |
#$conf["rows"]="";#爲文字輸入框的列數(高),預設爲按照瀏覽器設定值。
|
|
|
927 |
#$conf["maxInputLength"]="";#爲文字輸入的長度限制,預設無限制。
|
|
|
928 |
$conf["form::inputTextArea"]["defaultText"]=$demoContent;#爲文字輸入框裏面的預設文字內容,預設是空的。
|
|
|
929 |
#$conf["class"]=;#爲要套用的css樣式。如果沒有指定 ,則採用預設的css樣式,"__inputTextAreaCssStyle",其屬性爲 "width:100%","height:120px","font-size:30px"
|
|
|
930 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
931 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
932 |
#$conf["formStart"]="true";#爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
933 |
#$conf["formAction"]="";#表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
934 |
#$conf["formName"]="";#爲該表單的名稱
|
|
|
935 |
#$conf["formMethod"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
936 |
#$conf["formTarget"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
937 |
#$conf["formEnd"]="true";#爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
938 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
939 |
#$conf["comment"]="";
|
|
|
940 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
941 |
#$conf["required"]="true";
|
|
|
942 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
943 |
#$conf["placeholder"]="";
|
|
|
944 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
945 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
946 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
947 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
948 |
#參考資料來源:
|
|
|
949 |
#input=>http://www.w3schools.com/tags/tag_input.asp
|
|
|
950 |
$inputTextArea=form::inputTextArea($conf["form::inputTextArea"]);
|
|
|
951 |
unset($conf["form::inputTextArea"]);
|
| 226 |
liveuser |
952 |
|
| 3 |
liveuser |
953 |
#如果建立文字區塊失敗
|
|
|
954 |
if($inputTextArea["status"]=="false"){
|
| 226 |
liveuser |
955 |
|
| 3 |
liveuser |
956 |
#設置執行失敗
|
|
|
957 |
$result["status"]="false";
|
| 226 |
liveuser |
958 |
|
| 3 |
liveuser |
959 |
#設置錯誤訊息
|
|
|
960 |
$result["error"]=$inputTextArea;
|
| 226 |
liveuser |
961 |
|
| 3 |
liveuser |
962 |
#回傳結果
|
|
|
963 |
return $result;
|
| 226 |
liveuser |
964 |
|
| 3 |
liveuser |
965 |
}#if end
|
| 226 |
liveuser |
966 |
|
| 3 |
liveuser |
967 |
#取得文字方框的語法
|
|
|
968 |
$result["content"]=$result["content"].$inputTextArea["content"];
|
| 226 |
liveuser |
969 |
|
| 3 |
liveuser |
970 |
#函式說明:
|
|
|
971 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
972 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
973 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
974 |
#$result["error"],陣列,錯訊訊息.
|
|
|
975 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
976 |
#必填參數:
|
|
|
977 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
978 |
$conf["css::divSection"]["contentArray"]=array("以下為ckeditor編輯器預覽的結果:");
|
|
|
979 |
#可省略參數
|
|
|
980 |
#$conf["id"],字串,div區塊的id.
|
|
|
981 |
#$conf["css::divSection"]["id"]="preview";
|
|
|
982 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
983 |
#$conf["class"]="";
|
|
|
984 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
985 |
#$conf["title"]=array();
|
|
|
986 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
987 |
unset($conf["css::divSection"]);
|
| 226 |
liveuser |
988 |
|
| 3 |
liveuser |
989 |
#如果建立div區塊失敗
|
|
|
990 |
if($divSection["status"]=="false"){
|
| 226 |
liveuser |
991 |
|
| 3 |
liveuser |
992 |
#設置執行失敗
|
|
|
993 |
$result["status"]="false";
|
| 226 |
liveuser |
994 |
|
| 3 |
liveuser |
995 |
#設置錯誤訊息
|
|
|
996 |
$result["error"]=$divSection;
|
| 226 |
liveuser |
997 |
|
| 3 |
liveuser |
998 |
#回傳結果
|
|
|
999 |
return $result;
|
| 226 |
liveuser |
1000 |
|
| 3 |
liveuser |
1001 |
}#if end
|
| 226 |
liveuser |
1002 |
|
| 3 |
liveuser |
1003 |
#取得div區塊的語法
|
|
|
1004 |
$result["content"]=$result["content"].$divSection["content"];
|
| 226 |
liveuser |
1005 |
|
| 3 |
liveuser |
1006 |
#放置給ckeditor預覽用的區塊
|
|
|
1007 |
#函式說明:
|
|
|
1008 |
#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
|
|
|
1009 |
#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
|
|
|
1010 |
#$result["functin"],字串,當前函數的名稱.
|
|
|
1011 |
#$result["error"],陣列,錯訊訊息.
|
|
|
1012 |
#$result["content"],字串,含有<div>標籤的內容.
|
|
|
1013 |
#必填參數:
|
|
|
1014 |
#$conf["contentArray"],字串陣列,要放入的內容陣列.
|
|
|
1015 |
$conf["css::divSection"]["contentArray"]=array();
|
|
|
1016 |
#可省略參數
|
|
|
1017 |
#$conf["id"],字串,div區塊的id.
|
|
|
1018 |
$conf["css::divSection"]["id"]="preview";
|
|
|
1019 |
#$conf["class"],字串,div區段要套用的css樣式.
|
|
|
1020 |
#$conf["class"]="";
|
|
|
1021 |
#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
|
|
|
1022 |
#$conf["title"]=array();
|
|
|
1023 |
$divSection=css::divSection($conf["css::divSection"]);
|
|
|
1024 |
unset($conf["css::divSection"]);
|
| 226 |
liveuser |
1025 |
|
| 3 |
liveuser |
1026 |
#如果建立div區塊失敗
|
|
|
1027 |
if($divSection["status"]=="false"){
|
| 226 |
liveuser |
1028 |
|
| 3 |
liveuser |
1029 |
#設置執行失敗
|
|
|
1030 |
$result["status"]="false";
|
| 226 |
liveuser |
1031 |
|
| 3 |
liveuser |
1032 |
#設置錯誤訊息
|
|
|
1033 |
$result["error"]=$divSection;
|
| 226 |
liveuser |
1034 |
|
| 3 |
liveuser |
1035 |
#回傳結果
|
|
|
1036 |
return $result;
|
| 226 |
liveuser |
1037 |
|
| 3 |
liveuser |
1038 |
}#if end
|
| 226 |
liveuser |
1039 |
|
| 3 |
liveuser |
1040 |
#取得div區塊的語法
|
|
|
1041 |
$result["content"]=$result["content"].$divSection["content"];
|
| 226 |
liveuser |
1042 |
|
| 3 |
liveuser |
1043 |
#函式說明:
|
|
|
1044 |
#匯入ckEditor的函式庫.
|
|
|
1045 |
#回傳結果:
|
|
|
1046 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1047 |
#$result["error"],錯誤訊息.
|
|
|
1048 |
#$result["content"],語法.
|
|
|
1049 |
#$result["function"],當前執行的函數名稱.
|
|
|
1050 |
#必填參數:
|
|
|
1051 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
1052 |
$conf["ckEditor::importLib"]["libAddr"]=$conf["libAddr"];
|
|
|
1053 |
#可省略參數:
|
|
|
1054 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
1055 |
$conf["ckEditor::importLib"]["fileArgu"]=$conf["fileArgu"];
|
|
|
1056 |
$importLib=ckEditor::importLib($conf["ckEditor::importLib"]);
|
|
|
1057 |
unset($conf["ckEditor::importLib"]);
|
| 226 |
liveuser |
1058 |
|
| 3 |
liveuser |
1059 |
#如果建立匯入 ckeditor js lib 的語法失敗
|
|
|
1060 |
if($importLib["status"]=="false"){
|
| 226 |
liveuser |
1061 |
|
| 3 |
liveuser |
1062 |
#設置執行失敗
|
|
|
1063 |
$result["status"]="false";
|
| 226 |
liveuser |
1064 |
|
| 3 |
liveuser |
1065 |
#設置錯誤訊息
|
|
|
1066 |
$result["error"]=$importLib;
|
| 226 |
liveuser |
1067 |
|
| 3 |
liveuser |
1068 |
#回傳結果
|
|
|
1069 |
return $result;
|
| 226 |
liveuser |
1070 |
|
| 3 |
liveuser |
1071 |
}#if end
|
| 226 |
liveuser |
1072 |
|
| 3 |
liveuser |
1073 |
#取得匯入ckeditor的語法
|
|
|
1074 |
$result["content"]=$result["content"].$importLib["content"];
|
| 226 |
liveuser |
1075 |
|
| 3 |
liveuser |
1076 |
#涵式說明:
|
|
|
1077 |
#將要執行的script語法透過該函式執行
|
|
|
1078 |
#回傳結果:
|
|
|
1079 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
1080 |
#$result["error"],錯誤訊息陣列
|
|
|
1081 |
#$result["function"],當前執行的函數名稱
|
|
|
1082 |
#$result["content"],要執行的javaScript語法
|
|
|
1083 |
#必填的參數:
|
|
|
1084 |
#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
|
|
|
1085 |
$conf["javaScript::toScript"]["script"]="
|
| 226 |
liveuser |
1086 |
ckeditor=CKEDITOR.replace('ckeditor');
|
| 3 |
liveuser |
1087 |
".
|
|
|
1088 |
$setData
|
|
|
1089 |
."
|
|
|
1090 |
preview=CKEDITOR.instances.ckeditor.getData();
|
|
|
1091 |
$('#preview').html(preview);
|
|
|
1092 |
ckeditor.on('change',function(evt)
|
|
|
1093 |
{
|
|
|
1094 |
preview=evt.editor.getData();
|
| 226 |
liveuser |
1095 |
$('#preview').html(preview);
|
| 3 |
liveuser |
1096 |
});
|
|
|
1097 |
";
|
|
|
1098 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
1099 |
unset($conf["javaScript::toScript"]);
|
| 226 |
liveuser |
1100 |
|
| 3 |
liveuser |
1101 |
#如果轉換成js語法失敗
|
|
|
1102 |
if($toScript["status"]=="false"){
|
| 226 |
liveuser |
1103 |
|
| 3 |
liveuser |
1104 |
#設置執行失敗
|
|
|
1105 |
$result["status"]="false";
|
| 226 |
liveuser |
1106 |
|
| 3 |
liveuser |
1107 |
#設置錯誤訊息
|
|
|
1108 |
$result["error"]=$toScript;
|
| 226 |
liveuser |
1109 |
|
| 3 |
liveuser |
1110 |
#回傳結果
|
|
|
1111 |
return $result;
|
| 226 |
liveuser |
1112 |
|
| 3 |
liveuser |
1113 |
}#if end
|
| 226 |
liveuser |
1114 |
|
| 3 |
liveuser |
1115 |
#取得使用ckeditor的語法
|
|
|
1116 |
$result["content"]=$result["content"].$toScript["content"];
|
| 226 |
liveuser |
1117 |
|
| 3 |
liveuser |
1118 |
#設置執行正常
|
|
|
1119 |
$result["status"]="true";
|
| 226 |
liveuser |
1120 |
|
| 3 |
liveuser |
1121 |
#回傳結果
|
|
|
1122 |
return $result;
|
| 226 |
liveuser |
1123 |
|
| 3 |
liveuser |
1124 |
}#function demoWithDb end
|
| 226 |
liveuser |
1125 |
|
| 3 |
liveuser |
1126 |
/*
|
|
|
1127 |
#函式說明:
|
| 226 |
liveuser |
1128 |
#用 ckeditror classic v5 來 demo
|
| 3 |
liveuser |
1129 |
#回傳結果:
|
|
|
1130 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1131 |
#$result["error"],錯誤訊息.
|
|
|
1132 |
#$result["content"],語法.
|
|
|
1133 |
#$result["function"],當前執行的函數名稱.
|
|
|
1134 |
#必填參數:
|
|
|
1135 |
#無.
|
|
|
1136 |
#可省略參數:
|
|
|
1137 |
#$conf["libAddr"],字串,函式庫檔案的位置
|
|
|
1138 |
#$conf["libAddr"]="lib/ckeditor/ckeditor";
|
|
|
1139 |
#參考資料:
|
|
|
1140 |
#無.
|
|
|
1141 |
#備註:
|
|
|
1142 |
#建構中...
|
|
|
1143 |
*/
|
|
|
1144 |
public static function demoClassicV5(&$conf){
|
| 226 |
liveuser |
1145 |
|
| 3 |
liveuser |
1146 |
#初始化 $result
|
|
|
1147 |
$result=array();
|
| 226 |
liveuser |
1148 |
|
| 3 |
liveuser |
1149 |
#記錄當前函式名稱
|
|
|
1150 |
$result["funciton"]=__FUNCTION__;
|
| 226 |
liveuser |
1151 |
|
|
|
1152 |
#初始化語法
|
| 3 |
liveuser |
1153 |
$result["content"]="";
|
| 226 |
liveuser |
1154 |
|
| 3 |
liveuser |
1155 |
#建立給ckeditor置換的textarea
|
|
|
1156 |
#涵式說明:
|
|
|
1157 |
#可以輸入文字的區塊
|
|
|
1158 |
#回傳結果:
|
|
|
1159 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1160 |
#$result["function"],當前執行的函數.
|
|
|
1161 |
#$result["error"],錯誤訊息陣列.
|
| 226 |
liveuser |
1162 |
#$result["content"],按鈕語法.
|
| 3 |
liveuser |
1163 |
#必填的參數:
|
|
|
1164 |
$conf["form::inputTextArea"]["name"]="ckeditor";#爲文字輸入框的名稱,供接收端辨識用。
|
|
|
1165 |
$conf["form::inputTextArea"]["readOnly"]="false";#爲是否要爲唯讀,如果爲"true",則爲唯讀。反之則爲"false"。
|
|
|
1166 |
#可省略的參數:
|
|
|
1167 |
#$conf["id"],字串,文字區塊的id,供javaScript呼叫用.
|
|
|
1168 |
$conf["form::inputTextArea"]["id"]="ckeditor";
|
|
|
1169 |
#$conf["width"]="";#為輸入框的寬度,預設不指定.
|
|
|
1170 |
#$conf["cols"]="";#爲文字輸入框的欄位數(寬),預設爲按照瀏覽器設定值。
|
|
|
1171 |
#$conf["rows"]="";#爲文字輸入框的列數(高),預設爲按照瀏覽器設定值。
|
|
|
1172 |
#$conf["maxInputLength"]="";#爲文字輸入的長度限制,預設無限制。
|
|
|
1173 |
$conf["form::inputTextArea"]["defaultText"]="";#爲文字輸入框裏面的預設文字內容,預設是空的。
|
|
|
1174 |
#$conf["class"]=;#爲要套用的css樣式。如果沒有指定 ,則採用預設的css樣式,"__inputTextAreaCssStyle",其屬性爲 "width:100%","height:120px","font-size:30px"
|
|
|
1175 |
#$conf["jsActivitor"]="";#爲觸發js的條件,可以是"onChange"(已改變內容時)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
1176 |
#$conf["jsAction"]="";#爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
1177 |
#$conf["formStart"]="true";#爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
1178 |
#$conf["formAction"]="";#表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
1179 |
#$conf["formName"]="";#爲該表單的名稱
|
|
|
1180 |
#$conf["formMethod"]="";#爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
1181 |
#$conf["formTarget"]="";#為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
1182 |
#$conf["formEnd"]="true";#爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
1183 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
1184 |
#$conf["comment"]="";
|
|
|
1185 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
1186 |
#$conf["required"]="true";
|
|
|
1187 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
1188 |
#$conf["placeholder"]="";
|
|
|
1189 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是",也可以看作新的一列開始,預設為"false".
|
|
|
1190 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是",也可以看成列裏面的元素開始,預設為"false".
|
|
|
1191 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是",也可以看成列裏面的元素結束,預設為"false".
|
|
|
1192 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是",也可以看作該列結束,預設為"false".
|
|
|
1193 |
#參考資料來源:
|
|
|
1194 |
#input=>http://www.w3schools.com/tags/tag_input.asp
|
|
|
1195 |
$inputTextArea=form::inputTextArea($conf["form::inputTextArea"]);
|
|
|
1196 |
unset($conf["form::inputTextArea"]);
|
| 226 |
liveuser |
1197 |
|
| 3 |
liveuser |
1198 |
#如果建立文字區塊失敗
|
|
|
1199 |
if($inputTextArea["status"]=="false"){
|
| 226 |
liveuser |
1200 |
|
| 3 |
liveuser |
1201 |
#設置執行失敗
|
|
|
1202 |
$result["status"]="false";
|
| 226 |
liveuser |
1203 |
|
| 3 |
liveuser |
1204 |
#設置錯誤訊息
|
|
|
1205 |
$result["error"]=$inputTextArea;
|
| 226 |
liveuser |
1206 |
|
| 3 |
liveuser |
1207 |
#回傳結果
|
|
|
1208 |
return $result;
|
| 226 |
liveuser |
1209 |
|
| 3 |
liveuser |
1210 |
}#if end
|
| 226 |
liveuser |
1211 |
|
| 3 |
liveuser |
1212 |
#取得文字方框的語法
|
|
|
1213 |
$result["content"]=$result["content"].$inputTextArea["content"];
|
| 226 |
liveuser |
1214 |
|
| 3 |
liveuser |
1215 |
#預設參數
|
|
|
1216 |
$conf["libAddr"]="lib/ckeditor/ckeditor";
|
| 226 |
liveuser |
1217 |
|
| 3 |
liveuser |
1218 |
#預設參數
|
|
|
1219 |
$conf["fileArgu"]=__FILE__;
|
| 226 |
liveuser |
1220 |
|
| 3 |
liveuser |
1221 |
#函式說明:
|
|
|
1222 |
#匯入ckEditor的函式庫.
|
|
|
1223 |
#回傳結果:
|
|
|
1224 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1225 |
#$result["error"],錯誤訊息.
|
|
|
1226 |
#$result["content"],語法.
|
|
|
1227 |
#$result["function"],當前執行的函數名稱.
|
|
|
1228 |
#必填參數:
|
|
|
1229 |
#$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
|
|
|
1230 |
$conf["ckEditor::importLib"]["libAddr"]=$conf["libAddr"];
|
|
|
1231 |
#可省略參數:
|
|
|
1232 |
#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
|
|
|
1233 |
$conf["ckEditor::importLib"]["fileArgu"]=$conf["fileArgu"];
|
|
|
1234 |
$importLib=ckEditor::importLib($conf["ckEditor::importLib"]);
|
|
|
1235 |
unset($conf["ckEditor::importLib"]);
|
| 226 |
liveuser |
1236 |
|
| 3 |
liveuser |
1237 |
#如果建立匯入 ckeditor js lib 的語法失敗
|
|
|
1238 |
if($importLib["status"]=="false"){
|
| 226 |
liveuser |
1239 |
|
| 3 |
liveuser |
1240 |
#設置執行失敗
|
|
|
1241 |
$result["status"]="false";
|
| 226 |
liveuser |
1242 |
|
| 3 |
liveuser |
1243 |
#設置錯誤訊息
|
|
|
1244 |
$result["error"]=$importLib;
|
| 226 |
liveuser |
1245 |
|
| 3 |
liveuser |
1246 |
#回傳結果
|
|
|
1247 |
return $result;
|
| 226 |
liveuser |
1248 |
|
| 3 |
liveuser |
1249 |
}#if end
|
| 226 |
liveuser |
1250 |
|
| 3 |
liveuser |
1251 |
#取得匯入ckeditor的語法
|
|
|
1252 |
$result["content"]=$result["content"].$importLib["content"];
|
| 226 |
liveuser |
1253 |
|
| 3 |
liveuser |
1254 |
#涵式說明:
|
|
|
1255 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
1256 |
#回傳結果:
|
|
|
1257 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
1258 |
#$result["error"],錯誤訊息陣列
|
|
|
1259 |
#$result["function"],當前執行的函數名稱
|
|
|
1260 |
#$result["content"],要執行的javaScript語法
|
|
|
1261 |
#必填的參數:
|
|
|
1262 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
1263 |
$conf["javaScript::toScript"]["script"]=
|
|
|
1264 |
"
|
|
|
1265 |
//將 id 為 editor 的 textarea 區塊變成編輯器的樣子
|
|
|
1266 |
ClassicEditor.create(document.querySelector('#ckeditor')).catch(error=>{
|
|
|
1267 |
console.error(error);
|
|
|
1268 |
});
|
|
|
1269 |
";
|
|
|
1270 |
#可省略參數:
|
|
|
1271 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
1272 |
#$conf["onReady"]="true";
|
|
|
1273 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
1274 |
#$conf["globalJs"]=array();
|
|
|
1275 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
1276 |
#$conf["jsFunciton"]=array();
|
|
|
1277 |
#參考資料:
|
|
|
1278 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
1279 |
$toScript=javaScript::toScript($conf["javaScript::toScript"]);
|
|
|
1280 |
unset($conf["javaScript::toScript"]);
|
| 226 |
liveuser |
1281 |
|
| 3 |
liveuser |
1282 |
#設置執行正常
|
|
|
1283 |
$result["status"]="true";
|
| 226 |
liveuser |
1284 |
|
| 3 |
liveuser |
1285 |
#設置js語法
|
|
|
1286 |
$result["content"]=$result["content"].$toScript["content"];
|
|
|
1287 |
|
| 226 |
liveuser |
1288 |
#回傳結果
|
| 3 |
liveuser |
1289 |
return $result;
|
| 226 |
liveuser |
1290 |
|
| 3 |
liveuser |
1291 |
}#functino demoClassicV5 end
|
| 226 |
liveuser |
1292 |
|
| 3 |
liveuser |
1293 |
}#class variableCheck end
|
|
|
1294 |
|
|
|
1295 |
?>
|