1. jquery入門及連動選單 1-1 /templates/phone_book_index_b3.html 1-2 /index.php 1-3 /ajax.php 2. 表單驗證及點擊編輯 2-1 /admin/main.php 2-2 /templates/phone_book_adm_main_b3.html 2-3 /index.php 2-4 /templates/phone_book_index_b3.html 2-5 /save_phone_book.php 2-6 /get_name.php 3. 自適應表格及拉動排序 3-1 /index.php 3-2 /templates/phone_book_index_b3.html 3-3 /admin/cate.php 3-4 /templates/phone_book_adm_cate_b3.html 3-5 /admin/main.php 3-6 /templates/phone_book_adm_main_b3.html 3-7 (利用FooTable的分頁+json功能)/index.php 3-8 (利用FooTable的分頁+json功能)/templates/phone_book_index_b3.html 3-9 (利用FooTable的分頁+json功能)/columns.json 3-10 (利用FooTable的分頁+json功能)/rows.json 3-11 (舊版FooTable)/index.php 3-12 (舊版FooTable)/templates/phone_book_index_b3.html 3-13 (舊版FooTable)tadtools/FooTable.php 4. 大小月曆應用 4-1 /templates/phone_book_adm_main_b3.html 4-2 /interface_menu.php 4-3 /birthday.php 4-4 /templates/phone_book_birthday_b3.html 4-5 /xoops_version.php 4-5 /get_event.php 5. Google圖表應用及頁籤 5-1 /interface_menu.php 5-2 /chart.php 5-3 /templates/phone_book_chart_b3.html 5-4 /xoops_version.php 5-5 /ajax.php 5-6 /templates/phone_book_index_b3.html 5-7 /index.php 5-8 /templates/phone_book_adm_main_b3.html 6. 各種文字檔的匯出匯入 6-1 /interface_menu.php 6-2 /html.php 6-3 /index.php 6-4 /function.php 6-5 /csv.php 6-6 /templates/phone_book_adm_main_b3.html 6-7 /admin/main.php 6-8 /json.php 6-9 /get_json.php 6-10 資料庫語法 7. Excel的匯出與匯入 7-1 /header.php 7-2 /excel.php 7-3 /test.php 7-4 /excel_one.php 7-5 /templates/phone_book_adm_main_b3.html 7-6 /admin/main.php 7-7 /index.php 7-8 /templates/phone_book_index_b3.html 8. 產生PDF檔 8-1 /header.php 8-2 /pdf.php 8-3 /pdf.php (多檔下載版) 9. 輸出Word檔及圖片檔 9-1 /header.php 9-2 /word.php 9-3 /index.php 9-4 /templates/phone_book_index_b3.html
5-7
/index.php
022
$xoopsOption
[
'template_main'
] = set_bootstrap(
'phone_book_index_b3.html'
);
023
include_once
XOOPS_ROOT_PATH .
"/header.php"
;
028
function
show_one_phone_book(
$sn
=
''
)
030
global
$xoopsDB
,
$xoopsTpl
,
$isAdmin
;
038
$myts
= MyTextSanitizer::getInstance();
040
$sql
=
"select * from `"
.
$xoopsDB
->prefix(
"phone_book"
) . "`
041
where `sn` =
'{$sn}'
";
042
$result
=
$xoopsDB
->query(
$sql
)
or
web_error(
$sql
);
043
$all
=
$xoopsDB
->fetchArray(
$result
);
046
foreach
(
$all
as
$k
=>
$v
) {
051
$phone_book_cate_arr
= get_phone_book_cate(
$cate_sn
);
054
$name
=
$myts
->htmlSpecialChars(
$name
);
055
$birthday
=
$myts
->htmlSpecialChars(
$birthday
);
056
$phone
=
$myts
->htmlSpecialChars(
$phone
);
057
$email
=
$myts
->htmlSpecialChars(
$email
);
058
$zip
=
$myts
->htmlSpecialChars(
$zip
);
059
$county
=
$myts
->htmlSpecialChars(
$county
);
060
$city
=
$myts
->htmlSpecialChars(
$city
);
061
$addr
=
$myts
->htmlSpecialChars(
$addr
);
062
$note
=
$myts
->displayTarea(
$note
, 0, 1, 0, 1, 1);
064
$xoopsTpl
->assign(
'sn'
,
$sn
);
065
$xoopsTpl
->assign(
'cate_sn'
,
$cate_sn
);
066
$xoopsTpl
->assign(
'cate_sn_title'
,
$phone_book_cate_arr
[
'cate_title'
]);
067
$xoopsTpl
->assign(
'name'
,
$name
);
068
$xoopsTpl
->assign(
'birthday'
,
$birthday
);
069
$xoopsTpl
->assign(
'phone'
,
$phone
);
070
$xoopsTpl
->assign(
'email'
,
$email
);
071
$xoopsTpl
->assign(
'zip'
,
$zip
);
072
$xoopsTpl
->assign(
'county'
,
$county
);
073
$xoopsTpl
->assign(
'city'
,
$city
);
074
$xoopsTpl
->assign(
'addr'
,
$addr
);
075
$xoopsTpl
->assign(
'note'
,
$note
);
076
$xoopsTpl
->assign(
'action'
,
$_SERVER
[
'PHP_SELF'
]);
077
$xoopsTpl
->assign(
'now_op'
,
'show_one_phone_book'
);
080
$sql
=
"select cate_sn, cate_title from `"
.
$xoopsDB
->prefix(
"phone_book_cate"
) .
"` where `cate_enable` = '1' order by cate_sort"
;
081
$result
=
$xoopsDB
->query(
$sql
)
or
web_error(
$sql
);
082
while
(list(
$csn
,
$cate_title
) =
$xoopsDB
->fetchRow(
$result
)){
083
$arr
[
$csn
]=
$cate_title
;
085
$arr
[
'selected'
]=
$cate_sn
;
086
$json
=json_encode(
$arr
);
087
$json
=
str_replace
(
'"'
,"'",
$json
);
090
include_once
XOOPS_ROOT_PATH.
"/modules/tadtools/jeditable.php"
;
091
$file
=
"save_phone_book.php"
;
092
$jeditable
=
new
jeditable();
094
$jeditable
->setTextCol(
"#name"
,
$file
,
'240px'
,
'36px'
,
"{'sn':$sn }"
,
"點擊編輯"
);
095
$jeditable
->setTextAreaCol(
"#note"
,
$file
,
'500px'
,
'150px'
,
"{'sn':$sn, 'op':'textarea'}"
,
"點擊編輯"
);
096
$jeditable
->setSelectCol(
"#cate_sn"
,
$file
,
$json
,
"{'sn' : $sn}"
,
"點擊編輯"
);
098
$jeditable_set
=
$jeditable
->render();
099
$xoopsTpl
->assign(
"jeditable_set"
,
$jeditable_set
);
104
function
get_phone_book_cate(
$cate_sn
=
''
)
108
if
(
empty
(
$cate_sn
)) {
112
$sql
=
"select * from `"
.
$xoopsDB
->prefix(
"phone_book_cate"
) . "`
113
where `cate_sn` =
'{$cate_sn}'
";
114
$result
=
$xoopsDB
->query(
$sql
)
116
$data
=
$xoopsDB
->fetchArray(
$result
);
121
function
list_phone_book(
$def_cate_sn
=
""
,
$def_county
=
""
,
$def_city
=
""
,
$def_keyword
=
""
)
123
global
$xoopsDB
,
$xoopsTpl
,
$isAdmin
;
127
$and_name
=
$and_cate_sn
=
$and_city
=
""
;
128
if
(!
empty
(
$def_keyword
)){
129
$and_name
=
"and (`name` like '%{$def_keyword}%' or `city` like '%{$def_keyword}%' or `county` like '%{$def_keyword}%' or `addr` like '%{$def_keyword}%')"
;
131
$and_cate_sn
=
empty
(
$def_cate_sn
) ?
""
:
"and `cate_sn` = '{$def_cate_sn}'"
;
132
$and_county
=
empty
(
$def_county
) ?
""
:
"and `county` = '{$def_county}'"
;
133
$and_city
=
empty
(
$def_city
) ?
""
:
"and `city` = '{$def_city}'"
;
137
$phone_book_cate_arr
= get_phone_book_cate_arr();
139
$myts
= MyTextSanitizer::getInstance();
141
$sql
=
"select * from `"
.
$xoopsDB
->prefix(
"phone_book"
) .
"` where 1 $and_cate_sn $and_county $and_city $and_name"
;
144
$PageBar
= getPageBar(
$sql
, 20, 10, null, null,
$bootstrap
);
145
$bar
=
$PageBar
[
'bar'
];
146
$sql
=
$PageBar
[
'sql'
];
147
$total
=
$PageBar
[
'total'
];
149
$result
=
$xoopsDB
->query(
$sql
)
154
while
(
$all
=
$xoopsDB
->fetchArray(
$result
)) {
156
foreach
(
$all
as
$k
=>
$v
) {
161
$name
=
$myts
->htmlSpecialChars(
$name
);
162
$birthday
=
$myts
->htmlSpecialChars(
$birthday
);
163
$phone
=
$myts
->htmlSpecialChars(
$phone
);
164
$email
=
$myts
->htmlSpecialChars(
$email
);
165
$zip
=
$myts
->htmlSpecialChars(
$zip
);
166
$county
=
$myts
->htmlSpecialChars(
$county
);
167
$city
=
$myts
->htmlSpecialChars(
$city
);
168
$addr
=
$myts
->htmlSpecialChars(
$addr
);
169
$note
=
$myts
->displayTarea(
$note
, 0, 1, 0, 1, 1);
171
$all_content
[
$i
][
'sn'
] =
$sn
;
172
$all_content
[
$i
][
'cate_sn'
] =
$cate_sn
;
173
$all_content
[
$i
][
'cate_title'
] =
$phone_book_cate_arr
[
$cate_sn
][
'cate_title'
];
174
$all_content
[
$i
][
'name'
] =
$name
;
175
$all_content
[
$i
][
'birthday'
] =
$birthday
;
176
$all_content
[
$i
][
'phone'
] =
$phone
;
177
$all_content
[
$i
][
'email'
] =
$email
;
178
$all_content
[
$i
][
'zip'
] =
$zip
;
179
$all_content
[
$i
][
'county'
] =
$county
;
180
$all_content
[
$i
][
'city'
] =
$city
;
181
$all_content
[
$i
][
'addr'
] =
$addr
;
182
$all_content
[
$i
][
'note'
] =
$note
;
186
$xoopsTpl
->assign(
'bar'
,
$bar
);
187
$xoopsTpl
->assign(
'action'
,
$_SERVER
[
'PHP_SELF'
]);
188
$xoopsTpl
->assign(
'isAdmin'
,
$isAdmin
);
189
$xoopsTpl
->assign(
'all_content'
,
$all_content
);
190
$xoopsTpl
->assign(
'now_op'
,
'list_phone_book'
);
191
$xoopsTpl
->assign(
'cate_sn'
,
$cate_sn
);
192
$xoopsTpl
->assign(
'cate_arr'
, get_phone_book_cate_arr());
194
$xoopsTpl
->assign(
'def_cate_sn'
,
$def_cate_sn
);
195
$xoopsTpl
->assign(
'def_county'
,
$def_county
);
196
$xoopsTpl
->assign(
'def_city'
,
$def_city
);
197
$xoopsTpl
->assign(
'def_keyword'
,
$def_keyword
);
201
$county_arr
=get_county_arr();
204
$xoopsTpl
->assign(
'county_arr'
,
$county_arr
);
207
if
(
file_exists
(XOOPS_ROOT_PATH.
"/modules/tadtools/FooTable.php"
)){
208
include_once
XOOPS_ROOT_PATH.
"/modules/tadtools/FooTable.php"
;
209
$FooTable
=
new
FooTable();
210
$FooTableJS
=
$FooTable
->render(true);
211
$xoopsTpl
->assign(
'FooTableJS'
,
$FooTableJS
);
216
function
get_county_arr(){
219
$sql
=
"select county from `"
.
$xoopsDB
->prefix(
"phone_book"
) .
"` group by county order by zip"
;
220
$result
=
$xoopsDB
->query(
$sql
)
or
web_error(
$sql
);
221
while
(list(
$county
) =
$xoopsDB
->fetchRow(
$result
)) {
222
$county_arr
[] =
$county
;
228
function
get_phone_book_cate_arr()
232
$sql
=
"select * from `"
.
$xoopsDB
->prefix(
"phone_book_cate"
) . "`
233
where `cate_enable` =
'1'
";
234
$result
=
$xoopsDB
->query(
$sql
)
236
while
(
$data
=
$xoopsDB
->fetchArray(
$result
)) {
237
$cate_sn
=
$data
[
'cate_sn'
];
238
$all
[
$cate_sn
] =
$data
;
243
include_once
$GLOBALS
[
'xoops'
]->path(
'/modules/system/include/functions.php'
);
244
$op
= system_CleanVars(
$_REQUEST
,
'op'
,
''
,
'string'
);
245
$city
= system_CleanVars(
$_REQUEST
,
'city'
,
''
,
'string'
);
246
$sn
= system_CleanVars(
$_REQUEST
,
'sn'
,
''
,
'int'
);
247
$cate_sn
= system_CleanVars(
$_REQUEST
,
'cate_sn'
,
''
,
'int'
);
248
$county
= system_CleanVars(
$_REQUEST
,
'county'
,
''
,
'string'
);
249
$keyword
= system_CleanVars(
$_REQUEST
,
'keyword'
,
''
,
'string'
);
256
list_phone_book(
$cate_sn
,
$county
,
$city
,
$keyword
);
258
show_one_phone_book(
$sn
);
266
$xoopsTpl
->assign(
"toolbar"
, toolbar_bootstrap(
$interface_menu
));
267
$xoopsTpl
->assign(
"isAdmin"
,
$isAdmin
);
268
include_once
XOOPS_ROOT_PATH .
'/footer.php'
;
1. jquery入門及連動選單 1-1 /templates/phone_book_index_b3.html 1-2 /index.php 1-3 /ajax.php 2. 表單驗證及點擊編輯 2-1 /admin/main.php 2-2 /templates/phone_book_adm_main_b3.html 2-3 /index.php 2-4 /templates/phone_book_index_b3.html 2-5 /save_phone_book.php 2-6 /get_name.php 3. 自適應表格及拉動排序 3-1 /index.php 3-2 /templates/phone_book_index_b3.html 3-3 /admin/cate.php 3-4 /templates/phone_book_adm_cate_b3.html 3-5 /admin/main.php 3-6 /templates/phone_book_adm_main_b3.html 3-7 (利用FooTable的分頁+json功能)/index.php 3-8 (利用FooTable的分頁+json功能)/templates/phone_book_index_b3.html 3-9 (利用FooTable的分頁+json功能)/columns.json 3-10 (利用FooTable的分頁+json功能)/rows.json 3-11 (舊版FooTable)/index.php 3-12 (舊版FooTable)/templates/phone_book_index_b3.html 3-13 (舊版FooTable)tadtools/FooTable.php 4. 大小月曆應用 4-1 /templates/phone_book_adm_main_b3.html 4-2 /interface_menu.php 4-3 /birthday.php 4-4 /templates/phone_book_birthday_b3.html 4-5 /xoops_version.php 4-5 /get_event.php 5. Google圖表應用及頁籤 5-1 /interface_menu.php 5-2 /chart.php 5-3 /templates/phone_book_chart_b3.html 5-4 /xoops_version.php 5-5 /ajax.php 5-6 /templates/phone_book_index_b3.html 5-7 /index.php 5-8 /templates/phone_book_adm_main_b3.html 6. 各種文字檔的匯出匯入 6-1 /interface_menu.php 6-2 /html.php 6-3 /index.php 6-4 /function.php 6-5 /csv.php 6-6 /templates/phone_book_adm_main_b3.html 6-7 /admin/main.php 6-8 /json.php 6-9 /get_json.php 6-10 資料庫語法 7. Excel的匯出與匯入 7-1 /header.php 7-2 /excel.php 7-3 /test.php 7-4 /excel_one.php 7-5 /templates/phone_book_adm_main_b3.html 7-6 /admin/main.php 7-7 /index.php 7-8 /templates/phone_book_index_b3.html 8. 產生PDF檔 8-1 /header.php 8-2 /pdf.php 8-3 /pdf.php (多檔下載版) 9. 輸出Word檔及圖片檔 9-1 /header.php 9-2 /word.php 9-3 /index.php 9-4 /templates/phone_book_index_b3.html